Point
- class c104.Point
This class represents command and measurement data point of a station and provides access to structured properties of points
- on_before_auto_transmit(self: c104.Point, callable: collections.abc.Callable[[c104.Point], None]) None
set python callback that will be called before server reports a measured value interval-based
- Parameters:
callable (collections.abc.Callable[[c104.Point], None]) – callback function reference
- Return type:
None
- Raises:
ValueError – callable signature does not match exactly, parent station reference is invalid or function is called from client context
**Callable signature** –
Callable Parameters –
------------------- –
point – c104.Point: point instance
Callable Returns –
---------------- –
None –
Warning
The difference between on_before_read and on_before_auto_transmit is the calling context. on_before_read is called when a client sends a command to report a point (interrogation or read). on_before_auto_transmit is called when the server reports a measured value interval-based.
Example
>>> def on_before_auto_transmit_step(point: c104.Point) -> None: >>> print("SV] {0} PERIODIC TRANSMIT on IOA: {1}".format(point.type, point.io_address)) >>> point.value = c104.Int7(random.randint(-64,63)) # import random >>> >>> step_point = sv_station_2.add_point(io_address=31, type=c104.Type.M_ST_TB_1, report_ms=2000) >>> step_point.on_before_auto_transmit(callable=on_before_auto_transmit_step)
- on_before_read(self: c104.Point, callable: collections.abc.Callable[[c104.Point], None]) None
set python callback that will be called on incoming interrogation or read commands to support polling
- Parameters:
callable (collections.abc.Callable[[c104.Point], None]) – callback function reference
- Return type:
None
- Raises:
ValueError – callable signature does not match exactly, parent station reference is invalid or function is called from client context
**Callable signature** –
Callable Parameters –
------------------- –
point – c104.Point: point instance
Callable Returns –
---------------- –
None –
Example
>>> def on_before_read_steppoint(point: c104.Point) -> None: >>> print("SV] {0} READ COMMAND on IOA: {1}".format(point.type, point.io_address)) >>> point.value = random.randint(-64,63) # import random >>> >>> step_point = sv_station_2.add_point(io_address=31, type=c104.Type.M_ST_TB_1, report_ms=2000) >>> step_point.on_before_read(callable=on_before_read_steppoint)
- on_receive(self: c104.Point, callable: collections.abc.Callable[[c104.Point, c104.Information, c104.IncomingMessage], c104.ResponseState]) None
set python callback that will be executed on every incoming message this can be either a command or an monitoring message
- Parameters:
callable (collections.abc.Callable[[c104.Point, c104.Information, c104.IncomingMessage], c104.ResponseState]) – callback function reference
- Return type:
None
- Raises:
ValueError – callable signature does not match exactly
**Callable signature** –
Callable Parameters –
------------------- –
point – c104.Point: point instance
previous_info – c104.Information: Information object containing the state of the point before the command took effect
message – c104.IncomingMessage: new command message
Callable Returns –
---------------- –
c104.ResponseState – send command SUCCESS or FAILURE response
Example
>>> def on_setpoint_command(point: c104.Point, previous_info: c104.Information, message: c104.IncomingMessage) -> c104.ResponseState: >>> print("SV] {0} SETPOINT COMMAND on IOA: {1}, new: {2}, prev: {3}, cot: {4}, quality: {5}".format(point.type, point.io_address, point.value, previous_info, message.cot, point.quality)) >>> if point.related_io_address: >>> print("SV] -> RELATED IO ADDRESS: {}".format(point.related_io_address)) >>> related_point = sv_station_2.get_point(point.related_io_address) >>> if related_point: >>> print("SV] -> RELATED POINT VALUE UPDATE") >>> related_point.value = point.value >>> else: >>> print("SV] -> RELATED POINT NOT FOUND!") >>> return c104.ResponseState.SUCCESS >>> >>> sv_measurement_point = sv_station_2.add_point(io_address=11, type=c104.Type.M_ME_NC_1, report_ms=1000) >>> sv_measurement_point.value = 12.34 >>> sv_command_point = sv_station_2.add_point(io_address=12, type=c104.Type.C_SE_NC_1, report_ms=0, related_io_address=sv_measurement_point.io_address, related_io_autoreturn=True, command_mode=c104.CommandMode.SELECT_AND_EXECUTE) >>> sv_command_point.on_receive(callable=on_setpoint_command)
- on_timer(self: c104.Point, callable: collections.abc.Callable[[c104.Point], None], int) None
set python callback that will be called in a fixed delay (timer_ms)
- Parameters:
callable (collections.abc.Callable[[c104.Point], None]) – callback function reference
interval_ms (int) – interval between two callback executions in milliseconds
- Return type:
None
- Raises:
ValueError – callable signature does not match exactly, parent station reference is invalid or function is called from client context
**Callable signature** –
Callable Parameters –
------------------- –
point – c104.Point: point instance
interval_ms – int: fixed delay between timer callback execution, default: 0, min: 50
Callable Returns –
---------------- –
None –
Example
>>> def on_timer(point: c104.Point) -> None: >>> print("SV] {0} TIMER on IOA: {1}".format(point.type, point.io_address)) >>> point.value = random.randint(-64,63) # import random >>> >>> nv_point = sv_station_2.add_point(io_address=31, type=c104.Type.M_ME_TD_1) >>> nv_point.on_timer(callable=on_timer, interval_ms=1000)
- read(self: c104.Point) bool
send read command
- Returns:
True if the command was successfully accepted by the server, otherwise False
- Return type:
- Raises:
ValueError – parent station or connection reference is invalid or called from remote terminal unit (server) context
Example
>>> if cl_step_point.read(): >>> print("read command successful")
- transmit(self: c104.Point, cause: c104.Cot, originator: int = 0) bool
Server-side point report a measurement value to connected clients
Client-side point send the command point to the server
- Parameters:
- Raises:
ValueError – parent station, server or connection reference is invalid
- Returns:
True if the command was successfully send (server-side) or accepted by the server (client-side), otherwise False
- Return type:
Example
>>> sv_measurement_point.transmit(cause=c104.Cot.SPONTANEOUS) >>> cl_single_command_point.transmit(cause=c104.Cot.ACTIVATION)
- property command_mode
command transmission mode (direct or select-and-execute)
- Type:
- property info
current information
- Type:
- property processed_at
timestamp with milliseconds of last local information processing (read-only)
- Type:
- property quality
the primary quality value (this is just a shortcut to point.info.quality)
- Type:
- property recorded_at
timestamp with milliseconds transported with the value itself or None (read-only)
- Type:
datetime.datetime | None
io_address of a related monitoring point or None
- Type:
int | None
automatic transmission of return info remote messages for related point on incoming client command (only for control points)
- Type:
- property report_ms
interval in milliseconds between periodic transmission, 0 = no periodic transmission
- Type:
- property station
parent Station object (read-only)
- Type:
c104.Station | None
- property timer_ms
interval in milliseconds between timer callbacks, 0 = no periodic transmission
- Type:
- property value
the primary information value (this is just a shortcut to point.info.value)