gled_model/asset/output_device/
mod.rs1pub mod routing;
2
3use super::AssetTrait;
4use serde::{Deserialize, Serialize};
5use std::net::IpAddr;
6
7#[derive(Serialize, Deserialize, Debug, PartialEq, Eq, Clone, PartialOrd, Ord)]
8pub enum OutputDevice {
9 Artnet { ip: IpAddr, universes: Vec<u16> },
10 EnttecDmxUsbPro { serial_number: String },
11}
12
13impl Default for OutputDevice {
14 fn default() -> Self {
15 Self::Artnet {
16 ip: [127, 0, 0, 1].into(),
17 universes: vec![],
18 }
19 }
20}
21
22impl AssetTrait for OutputDevice {
23 const DIR_NAME: &'static str = "output_devices";
24 const NAME: &'static str = "Output Device";
25 const SHOW_NAME_IF_SELECTED: bool = true;
26}
27
28impl OutputDevice {
29 pub fn ip(&self) -> Option<IpAddr> {
30 match self {
31 OutputDevice::Artnet { ip, .. } => Some(*ip),
32 _ => None,
33 }
34 }
35
36 pub fn set_ip(&mut self, ip: IpAddr) {
37 if let OutputDevice::Artnet { ip: i, .. } = self {
38 *i = ip
39 }
40 }
41
42 pub fn universes(&self) -> &[u16] {
43 match self {
44 OutputDevice::Artnet { universes, .. } => universes,
45 _ => &[],
46 }
47 }
48
49 pub fn set_univeres(&mut self, universes: Vec<u16>) {
50 if let OutputDevice::Artnet { universes: u, .. } = self {
51 *u = universes
52 }
53 }
54}