Start to implement devices enrollment
This commit is contained in:
52
central_backend/src/devices/device.rs
Normal file
52
central_backend/src/devices/device.rs
Normal file
@ -0,0 +1,52 @@
|
||||
#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
|
||||
pub struct DeviceInfo {
|
||||
reference: String,
|
||||
version: semver::Version,
|
||||
max_relays: usize,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, serde::Serialize, serde::Deserialize, Eq, PartialEq, Hash)]
|
||||
pub struct DeviceId(pub String);
|
||||
|
||||
#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
|
||||
pub struct Device {
|
||||
/// The device ID
|
||||
id: DeviceId,
|
||||
/// Information about the device
|
||||
device: DeviceInfo,
|
||||
/// Name given to the device on the Web UI
|
||||
name: String,
|
||||
/// Description given to the device on the Web UI
|
||||
description: String,
|
||||
/// Specify whether the device is enabled or not
|
||||
enabled: bool,
|
||||
/// Specify whether the device has been validated or not
|
||||
validated: bool,
|
||||
/// Information about the relays handled by the device
|
||||
relays: Vec<DeviceRelay>,
|
||||
}
|
||||
|
||||
/// Structure that contains information about the minimal expected execution
|
||||
/// time of a device
|
||||
#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
|
||||
pub struct DailyMinRuntime {
|
||||
min_runtime: usize,
|
||||
reset_time: usize,
|
||||
catch_up_hours: Vec<usize>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, serde::Serialize, serde::Deserialize, Eq, PartialEq)]
|
||||
pub struct DeviceRelayID(uuid::Uuid);
|
||||
|
||||
#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
|
||||
pub struct DeviceRelay {
|
||||
id: DeviceRelayID,
|
||||
name: String,
|
||||
enabled: bool,
|
||||
priority: usize,
|
||||
consumption: usize,
|
||||
minimal_uptime: usize,
|
||||
minimal_downtime: usize,
|
||||
daily_runtime: Option<DailyMinRuntime>,
|
||||
depends_on: Vec<DeviceRelay>,
|
||||
}
|
Reference in New Issue
Block a user