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

Callable signature

Parameters:

point (c104.Point) – point instance

Return type:

None

Raises:

ValueError – If callable signature does not match exactly, parent station reference is invalid or function is called from client context

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

Callable signature

Parameters:

point (c104.Point) – point instance

Return type:

None

Raises:

ValueError – If callable signature does not match exactly, parent station reference is invalid or function is called from client context

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, dict, 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

Callable signature

Parameters:
Returns:

send command SUCCESS or FAILURE response

Return type:

c104.ResponseState

Raises:

ValueError – If callable signature does not match exactly

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)

Callable signature

Parameters:
  • point (c104.Point) – point instance

  • interval_ms (int) – fixed delay between timer callback execution, default: 0, min: 50

Return type:

None

Raises:

ValueError – If callable signature does not match exactly

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:

bool

Raises:

ValueError – If 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) bool

Server-side point report a measurement value to connected clients

Client-side point send the command point to the server

Parameters:

cause (c104.Cot) – cause of the transmission

Raises:

ValueError – If 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:

bool

Example

>>> sv_measurement_point.transmit(cause=c104.Cot.SPONTANEOUS)
>>> cl_single_command_point.transmit(cause=c104.Cot.ACTIVATION)
property command_mode

set direct or select-and-execute command transmission mode

Type:

c104.CommandMode

property info

information object

Type:

ref

Type:

c104.Information

property io_address

information object address (read-only)

Type:

int

property processed_at

timestamp with milliseconds of last local information processing (read-only)

Type:

datetime.datetime

property quality

Quality info object (this is just a shortcut to point.info.quality)

Type:

Union[None, c104.Quality, c104.BinaryCounterQuality]

property recorded_at

timestamp with milliseconds transported with the value itself or None (read-only)

Type:

Optional[int]

property related_io_address

io_address of a related monitoring point or None

Type:

Optional[int]

property related_io_autoreturn

toggle automatic return info remote response on or off

Type:

bool

property report_ms

interval in milliseconds between periodic transmission, 0 = no periodic transmission

Type:

int

property selected_by

originator address (0-255) or None

Type:

Optional[int]

property station

parent Station object (read-only)

Type:

Optional[c104.Station]

property timer_ms

interval in milliseconds between timer callbacks, 0 = no periodic transmission

Type:

int

property type

iec60870 data Type (read-only)

Type:

c104.Type

property value

value (this is just a shortcut to point.info.value)

Type:

Union[None, bool, c104.Double, c104.Step, c104.Int7, c104.Int16, int, c104.Byte32, c104.NormalizedFloat, float, c104.EventState, c104.StartEvents, c104.OutputCircuits, c104.PackedSingle]