module controller
Generic controller functionality.
This module holds the controller factory and I/O wrapper classes for use by both the programmer and the library.
- Controller: the controller base class from which every controller version inherits
- IOHandler: handle the I/O wrapper classes and state variables for a task
- IO: base class for an I/O interface, child classes: DI, DO, AI, AO, PT, NI, DIO, AIO
Global Variables
- LOG_FILE
class IO
Generic I/O superclass to store interface id.
method __init__
__init__(id: int, module: str = '')
Save interface and module numbers.
id: interface number module: module number
class DI
method __init__
__init__(id: int, module: str = '')
Save interface and module numbers.
id: interface number module: module number
class DO
method __init__
__init__(id: int, module: str = '')
Save interface and module numbers.
id: interface number module: module number
class AI
method __init__
__init__(id: int, module: str = '')
Save interface and module numbers.
id: interface number module: module number
class AO
method __init__
__init__(id: int, module: str = '')
Save interface and module numbers.
id: interface number module: module number
class NI
method __init__
__init__(id: int, module: str = '')
Save interface and module numbers.
id: interface number module: module number
class PT
method __init__
__init__(id: int, module: str = '')
Save interface and module numbers.
id: interface number module: module number
class DIO
method __init__
__init__(id: int, type: int, module: str = '')
class AIO
method __init__
__init__(id: int, type: int, module: str = '')
class Controller
The controller interface and basic functionality.
Needs to be implemented by every PLC added to the library. Each I/O function takes a module parameter referring to the controller module. It is forwarded to the controller specific _get_data and _set_data functions.
- digitalWrite: write the digital outputs
- analogWrite: write the analog outputs
- digitalRead: read the digital inputs
- analogRead: read the analog inputs
- tempRead: read the temperature inputs
- calibrateIn, calibrateOut, calibrateTemp: calibrate analog values
- read_inputs: read and store controller inputs
- write_outputs: write stored values to controller outputs
- reset: reset all controller outputs
method __init__
__init__()
method analogRead
analogRead(input: int, module: str) → int | bool
Read analog input and return calibrated value in mV.
Return False if the analog input does not exist.
input: Analog input to be read
method analogWrite
analogWrite(output: int, voltage: int, module: str) → bool
Switch the output to the specified voltage.
Return False if analog output does not exist, else return True.
output: Analog output to be switched voltage: Voltage which the selected output should be set to
method calibrateIn
calibrateIn()
method calibrateOut
calibrateOut()
method calibrateTemp
calibrateTemp()
method digitalRead
digitalRead(input: int, module: str) → int
Read the specified digital input and return the value as boolean.
input: Digital input to be read
method digitalWrite
digitalWrite(output: int, value: int, module: str) → bool
Switch the output to the specified value.
output: Digital output to be switched value: Value which the selected output should be set to Return True if value is written, False if out does not exist.
method read_inputs
read_inputs()
Fill the input image with actual data.
method reset
reset()
Reset outputs and close any file descriptors.
method tempRead
tempRead(input: int, module: str) → int
Read PT input and return calibrated value in °C.
Return False if the PT input does not exist.
input: PT input to be read
method write_outputs
write_outputs()
Actually write the outputs from the output image.
class IOHandler
Handle the I/O wrapper classes.
- get_input_image: get an input image (variables -> values) for a task cycle
- process_output_image: process output variables of the cycle function and write outputs
- update_timers: update state of running timers if the program was stopped for a while
- read: read from a specific input interface
- write: write to a specific output interface
method __init__
__init__(
plc_object: Controller,
input_mapping: dict[str, Any],
var_mapping: dict[str, Any]
)
method get_input_image
get_input_image() → dict[str, Any]
method process_output_image
process_output_image(output_image: dict[str, Any]) → None
method read
read(io: IO)
method update_timers
update_timers(stop_duration: int)
Update start time of timer fbs, as program execution was paused.
method write
write(io: IO, value: int | bool)
This file was automatically generated via lazydocs.