vaem
Abstracting internal file structure for VAEM package.
VAEM
VAEM driver class.
This is the main class that the user will interact with to control the VAEM valve control module.
Source code in src/vaem/vaem.py
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 | |
__init__(config)
Constructor.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
VAEMConfig
|
A ModbusTCP, or ModbusSerial type to allow the driver to connect to the correct communication interface. |
required |
Returns:
| Type | Description |
|---|---|
|
None |
Raises:
| Type | Description |
|---|---|
TypeError
|
Error occured with config |
Source code in src/vaem/vaem.py
clear_error()
If any error occurs in valve opening, must be cleared with this opperation.
Typical usage example
vaem.clear_error()
Returns:
| Type | Description |
|---|---|
None
|
None |
close_valves()
Closes valves that were previously selected.
Typical usage example
vaem.close_valves()
Returns:
| Type | Description |
|---|---|
None
|
None |
deselect_valve(valve_id)
Deselects one valve in the VAEM.
According to VAEM Logic all selected valves can be opened, others cannot with open command
Typical usage example
valve_id = 1
vaem.deselect_valve(valve_id)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
valve_id
|
int
|
The ID of the valve to select. Valid numbers are from 1 to 8 |
required |
Returns:
| Type | Description |
|---|---|
None
|
None |
Source code in src/vaem/vaem.py
get_current_reduction_time(valve_id)
Gets the time that the current is reduced to the holding current value for the valve selected 1-8.
Typical usage example
valve_id = 1
reduction_time = vaem.get_current_reduction_time(valve_id = valve_id)
print(reduction_time)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
valve_id
|
int
|
Valve ID (1-8) |
required |
Returns:
| Type | Description |
|---|---|
int | None
|
Current reduction time in ms |
Source code in src/vaem/vaem.py
get_delay_time(valve_id)
Gets the current delay time for the valve ID.
Typical usage example
valve_id = 1
delay_time_ms = vaem.get_delay_time(valve_id = valve_id)
print(delay_time_ms)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
valve_id
|
int
|
Valve ID (1-8) |
required |
Returns:
| Type | Description |
|---|---|
int | None
|
Delay time for the valve ID in ms |
Source code in src/vaem/vaem.py
get_error_handling_status()
Gets the current state of the internal error handling of the VAEM device.
Typical usage example
error_handling_status = vaem.get_error_handling_status()
print(error_handling_status)
Returns:
| Type | Description |
|---|---|
int | None
|
State of internal error handling. 1 for enabled, 0 for disabled |
Source code in src/vaem/vaem.py
get_holding_current(valve_id)
Gets the current holding current for the valve selected 1-8.
Typical usage example
valve_id = 1
holding_current = vaem.get_holding_current(valve_id = valve_id)
print(holding_current)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
valve_id
|
int
|
Valve ID (1-8) |
required |
Returns:
| Type | Description |
|---|---|
int | None
|
Holding current of valve in mA |
Source code in src/vaem/vaem.py
get_inrush_current(valve_id)
Gets the Inrush Current for the selected Valve ID.
Typical usage example
valve_id = 1
inrush_current_ma = get_inrush_current(valve_id = valve_id)
print(inrush_current_ma)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
valve_id
|
int
|
Valve ID (1-8) |
required |
Returns:
| Type | Description |
|---|---|
int | None
|
Inrush current for valve ID in mA |
Source code in src/vaem/vaem.py
get_nominal_voltage(valve_id)
Gets the nominal voltage for the specified valve ID.
Typical usage example
valve_id = 1
voltage_mv = get_nominal_voltage(valve_id = valve_id)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
valve_id
|
int
|
Valve ID (1-8) |
required |
Returns:
| Type | Description |
|---|---|
int | None
|
Nominal voltage in mV |
Source code in src/vaem/vaem.py
get_pickup_time(valve_id)
Gets the pickup time for the selected valve ID (1-8).
Typical usage example
valve_id = 1
pickup_time = vaem.get_pickup_time(valve_id = valve_id)
print(pickup_time)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
valve_id
|
int
|
Valve ID 1-8 |
required |
Returns:
| Type | Description |
|---|---|
int | None
|
Pickup time in ms |
Source code in src/vaem/vaem.py
get_status()
Read the status of the VAEM.
The status is return as a dictionary with the following keys:
-> status: 1 if more than 1 valve is active
-> error: 1 if error in valves is present
Typical usage example
status = vaem.get_status()
print(status)
Returns:
| Type | Description |
|---|---|
dict
|
Dictionary of the status for the device. For more information, please refer to the VAEM Operation Instruction manual. |
Source code in src/vaem/vaem.py
get_valve_switching_time(valve_id)
Gets the switching time in ms for the specific valve ID.
Typical usage example
valve_id = 1
switching_time_ms = vaem.get_valve_switching_time(valve_id = valve_id)
print(switching_time_ms)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
valve_id
|
int
|
Valve ID (1-8) |
required |
Returns:
| Type | Description |
|---|---|
int | None
|
Switching time in ms |
Source code in src/vaem/vaem.py
open_selected_valves()
Opens all valves that are selected.
Typical usage example
vaem.open_selected_valves()
Returns:
| Type | Description |
|---|---|
None
|
None |
open_valves(timings)
Selects and opens valves with specified actuation times.
Typical usage example
valve_opening_times = {1: 100, 2: 100, 3: 100, 4: 100, 5: 100, 6: 100, 7: 100, 8: 100, }
vaem.open_valves(timings = valve_opening_times)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
timings
|
dict
|
Dictionary of valve indices and actuation times |
required |
Returns:
| Type | Description |
|---|---|
None
|
None |
Source code in src/vaem/vaem.py
save_settings()
Saves all parameters to non-volatile memory.
Typical usage example
vaem.save_settings()
Returns:
| Type | Description |
|---|---|
None
|
None |
select_valve(valve_id)
Selects one valve in the VAEM.
According to VAEM Logic all selected valves can be opened, others cannot with open command
Typical usage example
valve_id = 1
vaem.select_valve(valve_id = valve_id)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
valve_id
|
int
|
The id of the valve to select |
required |
Returns:
| Type | Description |
|---|---|
None
|
None |
Source code in src/vaem/vaem.py
set_current_reduction_time(valve_id, reduction_time)
Sets the time that the current is reduced to the holding current value for the valve selected 1-8.
Typical usage example
valve_id = 1
current_reduction_time = 100
vaem.set_current_reduction_time(valve_id = valve_id, reduction_time = current_reduction_time)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
valve_id
|
int
|
Valve ID (1-8) |
required |
reduction_time
|
int
|
Desired length of time to go from inrush current to holding current in ms |
required |
Returns:
| Type | Description |
|---|---|
None
|
None |
Source code in src/vaem/vaem.py
set_delay_time(valve_id, delay_time)
Sets the delay time for a specific valve ID.
Typical usage example
valve_id = 1
delay_time = 100
vaem.set_delay_time(valve_id = valve_id, delay_time = delay_time)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
valve_id
|
int
|
Valve ID (1-8) |
required |
delay_time
|
int
|
Delay time to be set for the valve ID |
required |
Returns:
| Type | Description |
|---|---|
None
|
None |
Source code in src/vaem/vaem.py
set_error_handling(activate)
Sets the internal error handling of the vaem. Disabling this will cause the VAEM to omit certain errors.
Typical usage example
turn_off_handling = 0
vaem.set_error_handling(activate = turn_off_handling)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
activate
|
int
|
1 or 0. 1 activates the error handling and 0 disables error handling |
required |
Returns:
| Type | Description |
|---|---|
None
|
None |
Source code in src/vaem/vaem.py
set_holding_current(valve_id, holding_current)
Sets the holding current for the valve selected 1-8.
Typical usage example
valve_id = 1
holding_current = 100
vaem.set_holding_current(valve_id = valve_id, holding_current = holding_current)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
valve_id
|
int
|
Valve ID (1-8) |
required |
holding_current
|
int
|
Holding current in mA (20-400) |
required |
Returns:
| Type | Description |
|---|---|
None
|
None |
Source code in src/vaem/vaem.py
set_inrush_current(valve_id, inrush_current)
Changes the inrush current for the valves based on valve ID.
Typical usage example
valve_id = 1
inrush_current_ma = 100
vaem.set_inrush_current(valve_id = valve_id, inrush_current = inrush_current_ma)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
valve_id
|
int
|
Target valve for selection |
required |
inrush_current
|
int
|
In mA the new inrush current for the valve |
required |
Returns:
| Type | Description |
|---|---|
None
|
None |
Source code in src/vaem/vaem.py
set_nominal_voltage(valve_id, voltage)
Sets the nominal voltage on the valve ID specified.
Typical usage example
valve_id = 1
voltage_mv = 10000
vaem.set_nominal_voltage(valve_id = valve_id, voltage = voltage_mv)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
valve_id
|
int
|
ID number of valve for setting (1-8) |
required |
voltage
|
int
|
Voltage to be set in mV (8000-24000) |
required |
Returns:
| Type | Description |
|---|---|
None
|
None |
Source code in src/vaem/vaem.py
set_pickup_time(valve_id, pickup_time)
Sets the pickup time for the specified valve ID 1-8.
Typical usage example
valve_id = 1
pickup_time = 100
vaem.set_pickup_time(valve_id = valve_id, pickup_time = pickup_time)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
valve_id
|
int
|
ID number for valve (1-8) |
required |
pickup_time
|
int
|
Pickup time in ms |
required |
Returns:
| Type | Description |
|---|---|
None
|
None |
Source code in src/vaem/vaem.py
set_valve_switching_time(valve_id, opening_time)
Sets the switching time for the specified valve.
Typical usage example
valve_id = 1
opening_time = 100
vaem.set_valve_switching_time(valve_id = valve_id, opening_time = opening_time)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
valve_id
|
int
|
ID number of the valve for configuration |
required |
opening_time
|
int
|
Time in milliseconds of which the Valve with the ID will be opened |
required |
Returns:
| Type | Description |
|---|---|
None
|
None |
Source code in src/vaem/vaem.py
VAEMConfig
dataclass
Generic VAEM config dataclass for initialization.
Attributes:
| Name | Type | Description |
|---|---|---|
interface |
str
|
Interface to connect to VAEM. Ex: 'tcp/ip', 'serial' |
unit_id |
int
|
Modbus Unit ID of the VAEM (default: 1) |
Source code in src/vaem/vaem_config.py
VAEMSerialConfig
dataclass
Bases: VAEMConfig
Dataclass for VAEM Serial connection.
Attributes:
| Name | Type | Description |
|---|---|---|
com_port |
str
|
COM port to connect to VAEM |
baudrate |
int
|
Baudrate for the serial connection (default: 9600). Ex: 9600, 19200, 38400, 57600, 115200 |
Typical usage example
vaem_serial_config = VAEMSerialConfig(interface = "serial", com_port = "COM3", baudrate = 9600)
vaem = VAEM(vaem_serial_config)
Source code in src/vaem/vaem_config.py
VAEMTCPConfig
dataclass
Bases: VAEMConfig
Datclass for VAEM TCP/IP connection.
Attributes:
| Name | Type | Description |
|---|---|---|
ip |
str
|
IP address of the VAEM |
port |
int
|
Port number of the VAEM (default: 502) |
Typical usage example
vaem_config = VAEMTCPConfig(interface="tcp/ip", ip=ip, port=502)
vaem = VAEM(config=vaem_config)