use crate::config::{
CoilBlock, DeviceConfig, RegisterBlock, RegisterConfig, SimConfig, UpdateMode,
};
#[must_use]
pub fn hvac_controller() -> SimConfig {
SimConfig {
device: DeviceConfig {
unit_id: 1,
vendor_name: String::from("Acme Controls"),
product_code: String::from("ACM-HVAC-100"),
revision: String::from("2.1.0"),
listen_addr: String::from("127.0.0.1:0"),
},
registers: RegisterConfig {
holding: vec![RegisterBlock {
address: 0,
count: 10,
initial: vec![
720, 680, 760, 50, 100, 20, 5, 0, 0, 0,
],
mode: UpdateMode::Static,
min: 0,
max: 1000,
}],
input: vec![RegisterBlock {
address: 0,
count: 8,
initial: vec![721, 450, 1013, 0, 0, 0, 0, 0],
mode: UpdateMode::Random,
min: 600,
max: 800,
}],
coils: vec![CoilBlock {
address: 0,
count: 8,
initial: vec![true, false, true, false, false, false, false, false],
}],
discrete_inputs: vec![],
},
faults: vec![],
}
}
#[must_use]
pub fn power_meter() -> SimConfig {
SimConfig {
device: DeviceConfig {
unit_id: 2,
vendor_name: String::from("PowerCo"),
product_code: String::from("PM-3000"),
revision: String::from("1.0.0"),
listen_addr: String::from("127.0.0.1:0"),
},
registers: RegisterConfig {
holding: vec![],
input: vec![RegisterBlock {
address: 0,
count: 10,
initial: vec![
2400, 2390, 2410, 150, 148, 152, 3600, 100, 0, 0,
],
mode: UpdateMode::Random,
min: 2300,
max: 2500,
}],
coils: vec![],
discrete_inputs: vec![],
},
faults: vec![],
}
}
#[must_use]
pub fn vfd_drive() -> SimConfig {
SimConfig {
device: DeviceConfig {
unit_id: 3,
vendor_name: String::from("DriveTech"),
product_code: String::from("VFD-500"),
revision: String::from("3.2.1"),
listen_addr: String::from("127.0.0.1:0"),
},
registers: RegisterConfig {
holding: vec![RegisterBlock {
address: 0,
count: 6,
initial: vec![
1500, 10, 10, 0, 0, 0,
],
mode: UpdateMode::Static,
min: 0,
max: 3600,
}],
input: vec![RegisterBlock {
address: 0,
count: 4,
initial: vec![0, 0, 480, 25],
mode: UpdateMode::Static,
min: 0,
max: 3600,
}],
coils: vec![CoilBlock {
address: 0,
count: 4,
initial: vec![false, false, false, false],
}],
discrete_inputs: vec![CoilBlock {
address: 0,
count: 4,
initial: vec![true, false, false, false],
}],
},
faults: vec![],
}
}
#[must_use]
pub fn generic_io() -> SimConfig {
SimConfig {
device: DeviceConfig {
unit_id: 1,
vendor_name: String::from("Generic"),
product_code: String::from("IO-16"),
revision: String::from("1.0.0"),
listen_addr: String::from("127.0.0.1:0"),
},
registers: RegisterConfig {
holding: vec![RegisterBlock {
address: 0,
count: 16,
initial: vec![0; 16],
mode: UpdateMode::Static,
min: 0,
max: 65535,
}],
input: vec![RegisterBlock {
address: 0,
count: 16,
initial: vec![0; 16],
mode: UpdateMode::Static,
min: 0,
max: 65535,
}],
coils: vec![CoilBlock {
address: 0,
count: 16,
initial: vec![false; 16],
}],
discrete_inputs: vec![CoilBlock {
address: 0,
count: 16,
initial: vec![false; 16],
}],
},
faults: vec![],
}
}