use crate::modules::evok::models::devices::{
    analog_input::AnalogInput, analog_output::AnalogOutput, bus::Bus, extension::Extension,
    neuron::Neuron, onewire::OneWire, register::Register, relay::Relay, uart::Uart,
    user_led::UserLed, watch_dog::Watchdog,
};
use serde::{Deserialize, Serialize};
use strum::{Display, EnumString, IntoStaticStr};
use tokio::sync::mpsc::{Receiver, Sender};

pub type EvokSender = Sender<Vec<u8>>;
pub type EvokReceiver = Receiver<Vec<u8>>;

// Order of the elements in enum is crucial.
// Mapping is done from top to bottom.
// Keep the most complex, relevant and unique at the top.
#[derive(Debug, Deserialize, Serialize)]
#[serde(untagged)]
pub enum UnipiObjects {
    Register(Register),
    OneWire(OneWire),
    Relay(Relay),
    Uart(Uart),
    UserLed(UserLed),
    AnalogInput(AnalogInput),
    AnalogOutput(AnalogOutput),
    Bus(Bus),
    Extension(Extension),
    Watchdog(Watchdog),
    Neuron(Neuron),
}

#[derive(Serialize, Deserialize, Debug, EnumString, IntoStaticStr, Display)]
pub enum CommandType {
    #[strum(serialize = "set")]
    #[serde(rename = "set")]
    Set,
    #[strum(serialize = "all")]
    #[serde(rename = "all")]
    All,
    #[strum(serialize = "filter")]
    #[serde(rename = "filter")]
    Filter,
}
