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