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: Callable[[c104.Point], None]) None

set python callback that will be called before server reports a measured value interval-based

Callable signature

Parameters:

point (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_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_auto_transmit(callable=on_before_read_steppoint)
on_before_read(self: c104.Point, callable: 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 (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: 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:
  • point (Point) – point instance

  • previous_state (dict) – dictionary containing the state of the point before the command took effect {"value": float, "quality": :ref:`c104.Quality, updatedAt_ms: int}`

  • message (c104.IncomingMessage) – new command message

Returns:

send command SUCCESS or FAILURE response

Return type:

ResponseState

Raises:

ValueError – If callable signature does not match exactly

Example

>>> def on_setpoint_command(point: c104.Point, previous_state: dict, 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_state, message.cot, point.quality))
>>>     if point.quality.is_good():
>>>         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
>>>     return c104.ResponseState.FAILURE
>>>
>>> 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)
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")
set(self: c104.Point, value: Union[float, c104.Step, c104.Double], quality: c104.Quality, timestamp_ms: int) None

set value, quality and timestamp

Parameters:
  • value (float, c104.Step, c104.Double) – point value

  • quality (Quality) – quality restrictions if any, default: c104.Quality.None

  • timestamp_ms (int) – modification timestamp in milliseconds, default: current utc timestamp

Return type:

None

Example

>>> sv_measurement_point.set(value=-1234.56, quality=c104.Quality.Invalid, timestamp_ms=int(time.time() * 1000))
transmit(self: c104.Point, cause: c104.Cot = c104.Cot.SPONTANEOUS, qualifier: c104.Qoc = c104.Qoc.NONE) bool

Server-side point report a measurement value to connected clients

Client-side point send the command point to the server

Parameters:
Raises:

ValueError – If parent station, server or connection reference is invalid If qualifier is set for points in monitoring direction

Warning

It is recommended to specify a cause and not to use UNKNOWN_COT.

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(qualifier=c104.Qoc.SHORT_PULSE)
property command_mode

set direct or select-and-execute command transmission mode

Type:

c104.CommandMode

property io_address

information object address (read-only)

Type:

int

property quality

Quality bitset object

Type:

Quality

property received_at_ms

timestamp in milliseconds of last incoming message (read-only)

Type:

int

property related_io_address

io_address of a related monitoring point

Type:

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 reported_at_ms

timestamp in milliseconds of last transmission (read-only)

Type:

int

property selected_by

originator address (1-255) = SELECTED, 0 = NOT SELECTED

Type:

int

property sent_at_ms

timestamp in milliseconds of last outgoing message (read-only)

Type:

int

property station

parent Station object (read-only)

Type:

Optional[Station]

property type

iec60870 data Type (read-only)

Type:

Type

property updated_at_ms

timestamp in milliseconds of last value update (read-only)

Type:

int

property value

value

Type:

float

property value_float

value formatted as float (read-only)

Type:

float

property value_int32

value formatted as signed integer (read-only)

Type:

int

property value_uint32

value formatted as unsigned integer (read-only)

Type:

int