1use crate::config::{
4 CoilBlock, DeviceConfig, RegisterBlock, RegisterConfig, SimConfig, UpdateMode,
5};
6
7#[must_use]
13pub fn hvac_controller() -> SimConfig {
14 SimConfig {
15 device: DeviceConfig {
16 unit_id: 1,
17 vendor_name: String::from("Acme Controls"),
18 product_code: String::from("ACM-HVAC-100"),
19 revision: String::from("2.1.0"),
20 listen_addr: String::from("127.0.0.1:0"),
21 },
22 registers: RegisterConfig {
23 holding: vec![RegisterBlock {
24 address: 0,
25 count: 10,
26 initial: vec![
27 720, 680, 760, 50, 100, 20, 5, 0, 0, 0,
35 ],
36 mode: UpdateMode::Static,
37 min: 0,
38 max: 1000,
39 }],
40 input: vec![RegisterBlock {
41 address: 0,
42 count: 8,
43 initial: vec![721, 450, 1013, 0, 0, 0, 0, 0],
44 mode: UpdateMode::Random,
45 min: 600,
46 max: 800,
47 }],
48 coils: vec![CoilBlock {
49 address: 0,
50 count: 8,
51 initial: vec![true, false, true, false, false, false, false, false],
52 }],
53 discrete_inputs: vec![],
54 },
55 faults: vec![],
56 }
57}
58
59#[must_use]
63pub fn power_meter() -> SimConfig {
64 SimConfig {
65 device: DeviceConfig {
66 unit_id: 2,
67 vendor_name: String::from("PowerCo"),
68 product_code: String::from("PM-3000"),
69 revision: String::from("1.0.0"),
70 listen_addr: String::from("127.0.0.1:0"),
71 },
72 registers: RegisterConfig {
73 holding: vec![],
74 input: vec![RegisterBlock {
75 address: 0,
76 count: 10,
77 initial: vec![
78 2400, 2390, 2410, 150, 148, 152, 3600, 100, 0, 0,
87 ],
88 mode: UpdateMode::Random,
89 min: 2300,
90 max: 2500,
91 }],
92 coils: vec![],
93 discrete_inputs: vec![],
94 },
95 faults: vec![],
96 }
97}
98
99#[must_use]
104pub fn vfd_drive() -> SimConfig {
105 SimConfig {
106 device: DeviceConfig {
107 unit_id: 3,
108 vendor_name: String::from("DriveTech"),
109 product_code: String::from("VFD-500"),
110 revision: String::from("3.2.1"),
111 listen_addr: String::from("127.0.0.1:0"),
112 },
113 registers: RegisterConfig {
114 holding: vec![RegisterBlock {
115 address: 0,
116 count: 6,
117 initial: vec![
118 1500, 10, 10, 0, 0, 0,
123 ],
124 mode: UpdateMode::Static,
125 min: 0,
126 max: 3600,
127 }],
128 input: vec![RegisterBlock {
129 address: 0,
130 count: 4,
131 initial: vec![0, 0, 480, 25],
132 mode: UpdateMode::Static,
133 min: 0,
134 max: 3600,
135 }],
136 coils: vec![CoilBlock {
137 address: 0,
138 count: 4,
139 initial: vec![false, false, false, false],
140 }],
141 discrete_inputs: vec![CoilBlock {
142 address: 0,
143 count: 4,
144 initial: vec![true, false, false, false],
145 }],
146 },
147 faults: vec![],
148 }
149}
150
151#[must_use]
153pub fn generic_io() -> SimConfig {
154 SimConfig {
155 device: DeviceConfig {
156 unit_id: 1,
157 vendor_name: String::from("Generic"),
158 product_code: String::from("IO-16"),
159 revision: String::from("1.0.0"),
160 listen_addr: String::from("127.0.0.1:0"),
161 },
162 registers: RegisterConfig {
163 holding: vec![RegisterBlock {
164 address: 0,
165 count: 16,
166 initial: vec![0; 16],
167 mode: UpdateMode::Static,
168 min: 0,
169 max: 65535,
170 }],
171 input: vec![RegisterBlock {
172 address: 0,
173 count: 16,
174 initial: vec![0; 16],
175 mode: UpdateMode::Static,
176 min: 0,
177 max: 65535,
178 }],
179 coils: vec![CoilBlock {
180 address: 0,
181 count: 16,
182 initial: vec![false; 16],
183 }],
184 discrete_inputs: vec![CoilBlock {
185 address: 0,
186 count: 16,
187 initial: vec![false; 16],
188 }],
189 },
190 faults: vec![],
191 }
192}