py61850.client#

Client API

This module contains all class and function to implement an IEC61850 client.

Classes

IedConnection()

Represent a connection to an IED

ControlObject(handle)

client control object

DataSet(handle, ied_connection)

Representation of a dataset on client side

IedClientError(*values)

Used to describe the error reason for most client side service functions

IedConnectionState(*values)

Connection state of the IedConnection instance - either closed(idle), connecting, connected, or closing)

ReasonForInclusion(*values)

Describes the reason for the inclusion of the element in the report

Report(handle)

ReportControlBlock(handle, ied_connection)

Report control block

Exceptions

IedConnectionException(message, error_code, ...)

class py61850.client.IedConnection#

Represent a connection to an IED

abort()#

Abort the connection.

close()#

Close the connection

connect(hostname: str | bytes = b'localhost', port: int = 102)#

Connect to the specified address

create_dataset(dataset_reference: str | bytes, fcdas: list[str | bytes])#

Create a new data set at the connected server device

This function creates a new data set at the server.

Parameters:
  • dataset_reference (str | bytes) – Name of the new data set to create. It is either in the form “LDName/LNodeName.dataSetName” for permanent domain or VMD scope data sets or @dataSetName for an association specific data set. If the LDName part of the reference is missing the resulting data set will be of VMD scope.

  • fcdas (list[str | bytes]) – List of object references of FCDs or FCDAs. The format of this object references is “LDName/LNodeName.item(arrayIndex)component[FC]”

Raises:

IedConnectionException – _description_

See also

delete_dataset

create_rcb_and_subscribe(rcb_reference: str | bytes, callback: Callable[[Report], None], trg_ops: ReportTriggerOptions | None = None, intg_pd: int | None = None, opt_flds: ReportOptions | None = None) ReportControlBlock#

Helper function to create and subscribe a report control block

Parameters:
  • rcb_reference (str | bytes) – Reference of the report contro block

  • callback (Callable[[Report], None]) – Callback function which is triggered every time a report is received

  • trg_ops (ReportTriggerOptions | None, optional) – Trigger options to indicate when the report control block should generate a new report, by default None

  • intg_pd (int | None, optional) – Integrity period for the report control block, by default None

  • opt_flds (ReportOptions | None, optional) – Optional field that should be included in the report, by default None

delete_dataset(dataset_reference: str | bytes)#

Delete a deletable data set at the connected server device

Parameters:

dataset_reference (str | bytes) – Name of the new data set to delete. It is either in the form “LDName/LNodeName.dataSetName” for permanent domain or VMD scope data sets or @dataSetName for an association specific data set. If the LDName part of the reference is missing the resulting data set will be of VMD scope.

Raises:

IedConnectionException – _description_

See also

create_dataset

delete_file(filepath: str | bytes)#

Delete the file on the server

Parameters:

filepath (str | bytes) – Path of the file to be delted

Raises:

IedConnectionException – _description_

download_file(filepath: str | bytes) bytearray#

Download the file

filepathstr | bytes

Path of the file to be downloaded

bytearray

Return content of the file

>>> ied_connection.download_file('comtrade/no-comtrade.txt')
bytearray(b'Dummy file on the server

‘)

get_data_directory(data_reference: str | bytes) list[bytes]#

Returns the directory of the given data object (DO) or sub data objects.

Parameters:

data_reference (str | bytes) – Reference of the data object or sub dataobject, for example “IEDNameLD0/LLN0.Mod.Oper.origin”

Returns:

List of all data attributes or sub data objects.

Return type:

list[bytes]

Raises:

IedConnectionException – _description_

Examples

Only when level is returned by the function (i.e. to retrieve the content of mag the function should be called with the right reference)

>>> ied_connection.get_data_directory('TestIEDGenericIO/GGIO1.AnIn1')
[b'mag', b'q', b't']
>>> ied_connection.get_data_directory('TestIEDGenericIO/GGIO1.AnIn1.mag')
[b'f']
get_data_directory_by_fc(data_reference: str | bytes, fc: FunctionalConstraint) list[bytes]#

Returns the directory of the given data object (DO) or sub data objects.

Parameters:
  • data_reference (str | bytes) – Reference of the data object or sub dataobject, for example “IEDNameLD0/LLN0.Mod”

  • fc (FunctionalConstraint) – Functional constraint used to filter data attribute

Returns:

List of all data attributes or sub data objects.

Return type:

list[bytes]

Raises:

IedConnectionException – _description_

Examples

>>> ied_connection.get_data_directory_by_fc('TestIEDGenericIO/LLN0.Mod',
...     FunctionalConstraint.ST,
    )
[b'q', b't']
>>> ied_connection.get_data_directory_by_fc('TestIEDGenericIO/LLN0.Mod',
...     FunctionalConstraint.CF)
[b'ctlModel']
get_data_directory_fc(data_reference: str | bytes) list[bytes]#

Returns the directory of the given data object (DO) or sub data objects.

Parameters:

data_reference (str | bytes) – Reference of the data object or sub dataobject, for example “IEDNameLD0/LLN0.Mod.Oper.origin”

Returns:

List of all data attributes or sub data objects with the functional constraint in square brackets.

Return type:

list[bytes]

Raises:

IedConnectionException – _description_

Examples

>>> ied_connection.get_data_directory_fc('TestIEDGenericIO/LLN0.Mod')
[b'ctlModel[CF]', b'q[ST]', b't[ST]']
>>> ied_connection.get_data_directory_fc('TestIEDGenericIO/GGIO1.AnIn1')
[b'mag[MX]', b'q[MX]', b't[MX]']
get_dataset_directory(dataset_reference: str | bytes) list[bytes]#

Return the list of reference of FCDA in the dataset

Parameters:

dataset_reference (str | bytes) – Reference of the dataset for example “IEDNameLD0/LLN0.DsRpt”

Returns:

List of reference of FCDA in the dataset

Return type:

list[bytes]

Raises:

IedConnectionException – _description_

get_files(directory_name: str | bytes | None = None) list[FileDirectoryEntry]#

Get the list of files available in the directory.

Parameters:

directory_name (str | bytes | None, optional) – Path of the directory, by default None

Returns:

List of FileDirectoryEntry to represent each file

Return type:

list[FileDirectoryEntry]

Raises:

IedConnectionException – _description_

Examples

To retrieve filepath of files in the base directory, you can use the following code

>>> [f.filepath for f in ied_connection.get_files()]
[b'comtrade/no-comtrade.txt', b'dummy.txt']
get_last_appl_error() LastApplError#

Get the last received control application error

Returns:

Control application error

Return type:

LastApplError

get_logical_device_datasets(logical_device_name: str | bytes) list[bytes]#

Get the dataset reference of the logical device.

Parameters:

logical_device_name (str) – Logical device name, for example “IEDNameLD0”

Returns:

List of reference for each dataset. For example b’LLN0$dataset1’

Return type:

list[str]

Examples

>>> ied_connection.get_logical_device_datasets('TestIEDGenericIO')
[b'LLN0$ControlEvents']
get_logical_device_variables(logical_device_name: str | bytes) list[bytes]#

Returns a list of all MMS variables that are children of the given logical device.

Parameters:

logical_device_name (str | bytes) – Logical device name, for example “IEDNameLD0”

Returns:

List of reference for each items. For example b’GGIO1$CO$SPCSO2$Oper$T’

Return type:

list[bytes]

Raises:

IedConnectionException – _description_

get_logical_devices() list[bytes]#

Get the list of logical devices available at the server.

Returns:

List of logical device name (with ied name included)

Return type:

list[bytes]

Raises:

IedConnectionException – _description_

Examples

>>> ied_connection.get_logical_devices()
[b'TestIEDGenericIO']
get_logical_node_directory(logical_node_reference: str | bytes, acsi_class: ACSIClass) list[bytes]#

Returns the directory of the given logical node (LN) containing elements of the specified ACSI class

Parameters:
  • logical_node_reference (str | bytes) – Logical node reference, for example “IEDNameLD0/LLN0”

  • acsi_class (ACSIClass) – Described which items should be retrieved

Returns:

Lit of name of items to be retrieved

Return type:

list[bytes]

Raises:

IedConnectionException – _description_

Examples

>>> ied_connection.get_logical_node_directory('TestIEDGenericIO/LLN0',
...     ACSIClass.DATA_OBJECT)
[b'Mod', b'NamPlt', b'Beh', b'Health']

If you want to retrieve all dataset within a logical node, you mut specify the right ACSIClass.

>>> ied_connection.get_logical_node_directory('TestIEDGenericIO/LLN0',
...     ACSIClass.DATA_SET)
[b'ControlEvents']
get_logical_node_variables(logical_node_reference: str | bytes) list[bytes]#

Returns a list of all MMS variables that are children of the given logical node.

Parameters:

logical_node_reference (str | bytes) – Logical node reference, for example “IEDNameLD0/LLN0”

Returns:

List of reference for each items. For example b’GGIO1$CO$SPCSO2$Oper$T’

Return type:

list[bytes]

Raises:

IedConnectionException – _description_

Examples

>>> ied_connection.get_logical_node_variables('TestIEDGenericIO/LLN0')
[b'CF', b'CF$Mod', b'CF$Mod$ctlModel', b'DC', b'DC$NamPlt', b'DC$NamPlt$configRev',
b'DC$NamPlt$d', b'DC$NamPlt$swRev', b'DC$NamPlt$vendor', b'EX', b'EX$NamPlt',
b'EX$NamPlt$ldNs', b'RP', b'RP$ControlEventsRCB01', b'RP$ControlEventsRCB01$BufTm',
b'RP$ControlEventsRCB01$ConfRev', b'RP$ControlEventsRCB01$DatSet',
b'RP$ControlEventsRCB01$GI', b'RP$ControlEventsRCB01$IntgPd',
b'RP$ControlEventsRCB01$OptFlds', b'RP$ControlEventsRCB01$Resv',
b'RP$ControlEventsRCB01$RptEna', b'RP$ControlEventsRCB01$RptID',
b'RP$ControlEventsRCB01$SqNum', b'RP$ControlEventsRCB01$TrgOps',
b'RP$ControlEventsRCB02', b'RP$ControlEventsRCB02$BufTm',
b'RP$ControlEventsRCB02$ConfRev', b'RP$ControlEventsRCB02$DatSet',
b'RP$ControlEventsRCB02$GI', b'RP$ControlEventsRCB02$IntgPd',
b'RP$ControlEventsRCB02$OptFlds', b'RP$ControlEventsRCB02$Resv',
b'RP$ControlEventsRCB02$RptEna', b'RP$ControlEventsRCB02$RptID',
b'RP$ControlEventsRCB02$SqNum', b'RP$ControlEventsRCB02$TrgOps',
b'ST', b'ST$Beh', b'ST$Beh$q', b'ST$Beh$stVal', b'ST$Beh$t', b'ST$Health',
b'ST$Health$q', b'ST$Health$stVal', b'ST$Health$t', b'ST$Mod', b'ST$Mod$q',
b'ST$Mod$t']
get_logical_nodes(logical_device_name: str | bytes) list[bytes]#

Get the list of logical nodes (LN) of a logical device.

Parameters:

logical_device_name (str | bytes) – Logical device name, for example “IEDNameLD0”

Returns:

List of logical nodes

Return type:

list[bytes]

Raises:

IedConnectionException – _description_

Examples

>>> ied_connection.get_logical_nodes('TestIEDGenericIO')
[b'GGIO1', b'LLN0', b'LPHD1']
on_connection_closed(fn: Callable[[IedConnection], None]) bool#

Set a callback which is trigger when the connection status change

on_connection_state_change(fn: Callable[[IedConnection, IedConnectionState], None]) bool#

Set a callback which is trigger when the connection status change

read_boolean(object_reference: str | bytes, fc: FunctionalConstraint) bool#

Read a functional constrained data attribute (FCDA) of type bool.

Parameters:
  • object_reference (str | bytes) – Reference of the data attribute to read

  • fc (FunctionalConstraint) – Functional constraint of the data attribute to read

Returns:

Value of the data attribute

Return type:

bool

Raises:

IedConnectionException – _description_

read_control(object_reference: str | bytes) ControlObject#

Read a controlable data object from the server

Parameters:

object_reference (str | bytes) – Reference of the controllable data object, for example “IEDNameLD0/LLN0.Mod”

Returns:

Control object

Return type:

ControlObject

Raises:

IedConnectionException – _description_

read_dataset(dataset_reference: str | bytes) DataSet#

Create a DataSet by reading a reference on the server

Parameters:

dataset_reference (str | bytes) – Reference of the dataset, for example “IEDNameLD0/LLN0.DsRpt”

Returns:

_description_

Return type:

DataSet

Raises:

IedConnectionException – _description_

read_float(object_reference: str | bytes, fc: FunctionalConstraint) float#

Read a functional constrained data attribute (FCDA) of type float.

Parameters:
  • object_reference (str | bytes) – Reference of the data attribute to read, for example “IEDNameLD0/PTOC1.StrVal.setMag.f”

  • fc (FunctionalConstraint) – Functional constraint of the data attribute to read

Returns:

Value of the data attribute

Return type:

float

Raises:

IedConnectionException – _description_

read_gocb(gocb_reference: str | bytes) GooseControlBlock#

Create a GooseControlBlock by reading a reference on the server

Parameters:

gocb_reference (str | bytes) – Reference of the goose control block

Returns:

_description_

Return type:

GooseControlBlock

Raises:

IedConnectionException – _description_

read_int32(object_reference: str | bytes, fc: FunctionalConstraint) int#

Read a functional constrained data attribute (FCDA) of type int32.

Parameters:
  • object_reference (str | bytes) – Reference of the data attribute to read, for example “IEDNameLD0/LLN0.Beh.stVal”

  • fc (FunctionalConstraint) – Functional constraint of the data attribute to read

Returns:

Value of the data attribute

Return type:

int

Raises:

IedConnectionException – _description_

read_int64(object_reference: str | bytes, fc: FunctionalConstraint) int#

Read a functional constrained data attribute (FCDA) of type int64.

Parameters:
  • object_reference (str | bytes) – Reference of the data attribute to read

  • fc (FunctionalConstraint) – Functional constraint of the data attribute to read

Returns:

Value of the data attribute

Return type:

int

Raises:

IedConnectionException – _description_

read_quality(object_reference: str | bytes, fc: FunctionalConstraint) Quality#

Read a functional constrained data attribute (FCDA) of type Quality

Parameters:
  • object_reference (str | bytes) – Reference of the data attribute to read

  • fc (FunctionalConstraint) – Functional constraint of the data attribute to read

Returns:

Value of the data attribute

Return type:

Quality

Raises:

IedConnectionException – _description_

read_rcb(rcb_reference: str | bytes) ReportControlBlock#

Create a ReportControlBlock by reading a reference on the server

Parameters:

rcb_reference (str | bytes) – Reference of the report control block, for example “IEDNameLD0/LLN0.RP.URCBA” or “IEDNameLD0/LLN0.BR.BRCBA”

Returns:

_description_

Return type:

ReportControlBlock

Raises:

IedConnectionException – _description_

read_string(object_reference: str | bytes, fc: FunctionalConstraint) bytes#

Read a functional constrained data attribute (FCDA) of type string.

Parameters:
  • object_reference (str | bytes) – Reference of the data attribute to read

  • fc (FunctionalConstraint) – Functional constraint of the data attribute to read

Returns:

Value of the data attribute

Return type:

bytes

Raises:

IedConnectionException – _description_

read_timestamp(object_reference: str | bytes, fc: FunctionalConstraint) Timestamp#

Read a functional constrained data attribute (FCDA) of type timestamp.

Parameters:
  • object_reference (str | bytes) – Reference of the data attribute to read

  • fc (FunctionalConstraint) – Functional constraint of the data attribute to read

Returns:

Value of the data attribute

Return type:

Timestamp

Raises:

IedConnectionException – _description_

read_uint32(object_reference: str | bytes, fc: FunctionalConstraint) int#

Read a functional constrained data attribute (FCDA) of type uint32.

Parameters:
  • object_reference (str | bytes) – Reference of the data attribute to read

  • fc (FunctionalConstraint) – Functional constraint of the data attribute to read

Returns:

Value of the data attribute

Return type:

int

Raises:

IedConnectionException – _description_

read_value(object_reference: str | bytes, fc: FunctionalConstraint) MmsValue#

Read a functional constrained data attribute (FCDA) or functional constrained data (FCD).

Parameters:
  • object_reference (str | bytes) – Reference of the data attribute to read

  • fc (FunctionalConstraint) – Functional constraint of the data attribute to read

Returns:

Value of the data attribute

Return type:

MmsValue

Raises:

IedConnectionException – _description_

register_report_handler(rcb_reference: str | bytes, rpt_id: str | bytes, callback: Callable[[Report], None])#

Register a report callback function

Parameters:
  • rcb_reference (str | bytes) – Reference of the report control block

  • rpt_id (str | bytes) – _description_

  • callback (Callable[[Report], None]) – Callback function which is triggered every time a report is received

release()#

Release the connection.

To be sure that the connection will be close the close or abort methods should be used.

set_connect_timeout(timeout: int)#

set the connect timeout in ms

Parameters:

timeout (int) – Timeout in ms

set_filestore_basepath(basepath: str | bytes)#

Set the base directory for the file service

Parameters:

basepath (str | bytes) – _description_

set_gocb_values(gocb: GooseControlBlock, single_request: bool = True)#

Send values of the GooseControlBlock to the server

Parameters:
  • gocb (GooseControlBlock) – _description_

  • single_request (bool, optional) – _description_, by default True

Raises:

IedConnectionException – _description_

set_rcb_values(rcb: ReportControlBlock, single_request: bool = True)#

Send values of the ReportControlBlock to the server

Parameters:
  • rcb (ReportControlBlock) – _description_

  • single_request (bool, optional) – _description_, by default True

Raises:

IedConnectionException – _description_

property status: IedConnectionState#

return the state of the connection.

Returns:

State of the connection

Return type:

IedConnectionState

unregister_report_handler(rcb_reference: str | bytes)#

Unregister a report handler

Parameters:

rcb_reference (str | bytes) – Reference of the report control block

update_dataset_values(dataset: DataSet)#

Update the values stored in the dataset

Parameters:

dataset (DataSet) – _description_

Raises:

IedConnectionException – _description_

update_gocb_values(gocb: GooseControlBlock)#

Update values of a ReportControlBlock by reading values from the server

Parameters:

gocb (GooseControlBlock) – Goose control block to be updated

Raises:

IedConnectionException – _description_

update_rcb_values(rcb: ReportControlBlock)#

Update values of a ReportControlBlock by reading values from the server

Parameters:

rcb (ReportControlBlock) – Report control block to be updated

Raises:

IedConnectionException – _description_

upload_file(source_filename: str | bytes, destination_filename: str | bytes)#

Upload a file (from the local filestore) to the server

Parameters:
  • source_filename (str | bytes) – Local file name relative to the basepath of the filestore

  • destination_filename (str | bytes) – Name of the file in the server

write_boolean(object_reference: str | bytes, fc: FunctionalConstraint, value: bool)#

Write a functional constrained data attribute (FCDA) of type bool.

Parameters:
  • object_reference (str | bytes) – Reference of the data attribute to write

  • fc (FunctionalConstraint) – Functional constraint of the data attribute to write

  • value (bool) – Value to write

Raises:

IedConnectionException – _description_

write_float(object_reference: str | bytes, fc: FunctionalConstraint, value: float)#

Write a functional constrained data attribute (FCDA) of type float.

Parameters:
  • object_reference (str | bytes) – Reference of the data attribute to write, for example “IEDNameLD0/PTOC1.StrVal.setMag.f”

  • fc (FunctionalConstraint) – Functional constraint of the data attribute to write

  • value (float) – Value to write

Raises:

IedConnectionException – _description_

write_int32(object_reference: str | bytes, fc: FunctionalConstraint, value: int)#

Write a functional constrained data attribute (FCDA) of type int32.

Parameters:
  • object_reference (str | bytes) – Reference of the data attribute to write

  • fc (FunctionalConstraint) – Functional constraint of the data attribute to write

  • value (int) – Value to write

Raises:

IedConnectionException – _description_

write_octet_string(object_reference: str | bytes, fc: FunctionalConstraint, value: bytes)#

Write a functional constrained data attribute (FCDA) of type octet string.

Parameters:
  • object_reference (str | bytes) – Reference of the data attribute to write

  • fc (FunctionalConstraint) – Functional constraint of the data attribute to write

  • value (bytes) – Value to write

Raises:

IedConnectionException – _description_

write_string(object_reference: str | bytes, fc: FunctionalConstraint, value: str | bytes)#

Write a functional constrained data attribute (FCDA) of type string.

Parameters:
  • object_reference (str | bytes) – Reference of the data attribute to write

  • fc (FunctionalConstraint) – Functional constraint of the data attribute to write

  • value (str | bytes) – Value to write

Raises:

IedConnectionException – _description_

write_uint32(object_reference: str | bytes, fc: FunctionalConstraint, value: int)#

Write a functional constrained data attribute (FCDA) of type uint32.

Parameters:
  • object_reference (str | bytes) – Reference of the data attribute to write

  • fc (FunctionalConstraint) – Functional constraint of the data attribute to write

  • value (int) – Value to write

Raises:

IedConnectionException – _description_

write_value(object_reference: str | bytes, fc: FunctionalConstraint, value: MmsValue)#

Write a functional constrained data attribute (FCDA) or functional constrained data (FCD).

Parameters:
  • object_reference (str | bytes) – Reference of the data attribute to write

  • fc (FunctionalConstraint) – Functional constraint of the data attribute to write

  • value (MmsValue) – Value to write

Raises:

IedConnectionException – _description_

exception py61850.client.IedConnectionException(message: str, error_code: IedClientError, *args: object)#
class py61850.client.ControlObject(handle: c_void_p)#

client control object

It is used to handle all client side functions of a controllable data object.

cancel() bool#

Send a cancel command to the server.

The cancel command can be used to stop an ongoing operation (when the server and application support this) and to cancel a former select command.

Returns:

True if operation has been successful, False otherwise.

Return type:

bool

property control_model: ControlModel#

Current control model (local representation) applied to the control object.

property ctl_val_type: MmsType#

Return the type of ctlVal.

get_last_appl_error() LastApplError#

Get the last received control application error

Returns:

Control application error

Return type:

LastApplError

get_last_error() IedClientError#

Get the error code of the last synchronous control action (operate, select, select-with-value, cancel)

Returns:

Client error code

Return type:

IedClientError

property object_reference: bytes#

Object reference of the control data object.

on_termination(callback: Callable[[ControlObject], None])#

Set the command termination callback handler for this control object.

This callback is invoked whenever a CommandTermination+ or CommandTermination- message is received. To distinguish between a CommandTermination+ and CommandTermination- please use the get_last_appl_error function. In case of CommandTermination+ the return value of get_last_appl_error has error=NO_ERROR and add_cause``=UNKNOWN set. When ``add_cause is different from UNKNOWN then the client received a CommandTermination- message.

Parameters:

callback (Callable[["ControlObject"], None]) – Callback function to be used

operate(ctl_val: MmsValue, oper_time: int = 0) bool#

Send an operate command to the server.

Parameters:
  • ctl_val (MmsValue) – Control value (for APC the value may be either AnalogueValue (MMS_STRUCT) or MMS_FLOAT/MMS_INTEGER

  • oper_time (int, optional) – Time when the command has to be executed (for time activated control), by default 0. The value represents the local time of the server in milliseconds since epoch. If this value is 0 the command will be executed instantly

Returns:

True if operation has been successful, False otherwise.

Return type:

bool

select() bool#

Send a select command to the server.

The select command is only used for the control model “select-before-operate with normal security”(SBO_NORMAL). The select command has to be sent before the operate command can be used.

Returns:

True if operation has been successful, False otherwise.

Return type:

bool

select_with_value(ctl_val: MmsValue) bool#

Send an select with value command to the server.

The select-with-value command is only used for the control model “select-before-operate with enhanced security” (SBO_ENHANCED). The select-with-value command has to be sent before the operate command can be used.

Parameters:

ctl_val (MmsValue) – Control value (for APC the value may be either AnalogueValue (MMS_STRUCT) or MMS_FLOAT/MMS_INTEGER

Returns:

True if operation has been successful, False otherwise.

Return type:

bool

set_interlock_check(value: bool)#

Set the value of the interlock check flag when a control command is sent.

Parameters:

value (bool) – If true the server will perform a interlock check if supported

set_origin(or_ident: str | bytes, or_cat: OrCat)#

Set the origin parameter for control commands.

The origin parameter is used to identify the client/application that sent a control command. It is intended for later analysis.

Parameters:
  • or_ident (str | bytes) – Originator identification

  • or_cat (OrCat) – Originator category

set_synchro_check(value: bool)#

Set the value of the synchro check flag when a control command is sent.

Parameters:

value (bool) – If true the server will perform a synchro check if supported

set_test_mode(value: bool)#

Set the test mode

When the server supports test mode the commands that are sent with the test flag set are not executed (will have no effect on the ttached physical process).

Parameters:

value (bool) – Value of the test flag

use_constant_t(use_constant_t: bool)#

Use a constant T parameter for all command (select, operate, cancel) of a single control sequence.

Parameters:

use_constant_t (bool) – Enable this behavior with true, disable with false

class py61850.client.DataSet(handle: c_void_p, ied_connection: IedConnection)#

Representation of a dataset on client side

property handle#

Pointer to the underlying C structure

property reference: bytes#

Object reference of the data set.

property size: int#

Number of member of the data set

update_values()#

Update the values stored in the dataset

property values: MmsValue#

Return data set values locally stored in the instance.

See also

update_dataset_values

class py61850.client.IedClientError(*values)#

Used to describe the error reason for most client side service functions

OK = 0#

No error occurred - service request has been successful

NOT_CONNECTED = 1#

The service request can not be executed because the client is not yet connected

ALREADY_CONNECTED = 2#

Connect service not execute because the client is already connected

CONNECTION_LOST = 3#

The service request can not be executed caused by a loss of connection

SERVICE_NOT_SUPPORTED = 4#

The service or some given parameters are not supported by the client stack or by the server

CONNECTION_REJECTED = 5#

Connection rejected by server

OUTSTANDING_CALL_LIMIT_REACHED = 6#

Cannot send request because outstanding call limit is reached

USER_PROVIDED_INVALID_ARGUMENT = 10#

API function has been called with an invalid argument

OBJECT_REFERENCE_INVALID = 12#

The object provided object reference is invalid (there is a syntactical error).

UNEXPECTED_VALUE_RECEIVED = 13#

Received object is of unexpected type

TIMEOUT = 20#

The communication to the server failed with a timeout

ACCESS_DENIED = 21#

The server rejected the access to the requested object/service due to access control

OBJECT_DOES_NOT_EXIST = 22#

The server reported that the requested object does not exist (returned by server)

OBJECT_EXISTS = 23#

The server reported that the requested object already exists

OBJECT_ACCESS_UNSUPPORTED = 24#

The server does not support the requested access method (returned by server)

TYPE_INCONSISTENT = 25#

The server expected an object of another type (returned by server)

TEMPORARILY_UNAVAILABLE = 26#

The object or service is temporarily unavailable (returned by server)

OBJECT_UNDEFINED = 27#

The specified object is not defined in the server (returned by server)

INVALID_ADDRESS = 28#

The specified address is invalid (returned by server)

HARDWARE_FAULT = 29#

Service failed due to a hardware fault (returned by server)

TYPE_UNSUPPORTED = 30#

The requested data type is not supported by the server (returned by server)

OBJECT_ATTRIBUTE_INCONSISTENT = 31#

The provided attributes are inconsistent (returned by server)

OBJECT_VALUE_INVALID = 32#

The provided object value is invalid (returned by server)

OBJECT_INVALIDATED = 33#

The object is invalidated (returned by server)

MALFORMED_MESSAGE = 34#

Received an invalid response message from the server

OBJECT_CONSTRAINT_CONFLICT = 35#

Service was not executed because required resource is still in use

SERVICE_NOT_IMPLEMENTED = 98#

Service not implemented

UNKNOWN = 99#

unknown error

class py61850.client.IedConnectionState(*values)#

Connection state of the IedConnection instance - either closed(idle), connecting, connected, or closing)

class py61850.client.ReasonForInclusion(*values)#

Describes the reason for the inclusion of the element in the report

NOT_INCLUDED = 0#

the element is not included in the received report

DATA_CHANGE = 1#

the element is included due to a change of the data value

QUALITY_CHANGE = 2#

the element is included due to a change in the quality of data

DATA_UPDATE = 4#

the element is included due to an update of the data value

INTEGRITY = 8#

the element is included due to a periodic integrity report task

GI = 16#

the element is included due to a general interrogation by the client

UNKNOWN = 32#

the reason for inclusion is unknown (e.g. report is not configured to include reason-for-inclusion)

class py61850.client.Report(handle: c_void_p)#
property buf_ovfl: bool#

Value of the bufOvfl flag

property conf_rev: int#

Value of the configuration revision

property dataset_name: bytes#

Name of the dataset

property dataset_values: MmsValue#

Received data set values of the report

property entry_id: bytearray | None#

Entry ID of the report

get_data_reference(element_index: int) bytes#

Get the data-reference of the element of the report data set

Parameters:

element_index (int) – _description_

Returns:

_description_

Return type:

bytes

get_reason_for_inclusion(element_index: int) ReasonForInclusion#

Get the reason code (reason for inclusion) for a specific report data set element

Parameters:

element_index (int) – _description_

Returns:

_description_

Return type:

ReasonForInclusion

has_buf_ovfl() bool#

Indicates if the report contains the bufOvfl (buffer overflow) flag

property has_conf_rev: bool#

Indicates if the last received report contains the configuration revision

property has_data_reference: bool#

Indicates if the report contains data references for the reported data set members

property has_dataset_name: bool#

Indicate whether dataset name is included in the report

property has_reason_for_inclusion: bool#

Indicates if the last received report contains reason-for-inclusion information

property has_seq_num: bool#

Indicates if the last received report contains a sequence number

property has_sub_seq_num: bool#

Indicates if the report contains a sub sequence number and a more segments follow flags (for segmented reporting)

property has_timestamp: bool#

Indicates if the last received report contains a timestamp

property more_seqments_follow: bool#

True in case this is part of a segmented report and more report segments will follow or false, if the current report is not a segmented report or is the last segment of a segmented report.

property rcb_reference: bytes#

Reference (name) of the server RCB associated with this ClientReport object

property rpt_id: bytes#

RptId of the server RCB associated with this ClientReport object

property seq_num: int#

Value of the sequence number

property sub_seq_num: int#

Value of the sub sequence number

property timestamp: datetime#

Value of the timestamp

class py61850.client.ReportControlBlock(handle: LP_sClientReportControlBlock, ied_connection: IedConnection)#

Report control block

clear_element_changed()#

Reset the flag used to detect which elment has been changed

property conf_rev: int#

Value of the configuration revision

property element_changed: RcbElement#

List of property changed manually

property handle#

Pointer to the underlying C structure

property is_buffered: bool#

Indicate whether it is a buffered report control block (BRCB) or an unbeffered report control block (URCB)

on_report(callback: Callable[[Report], None])#

Register a report callback function

Parameters:

callback (Callable[["Report"], None]) – _description_

property reference: bytes#

Reference of the report control block

property rpt_ena: bool#

Indicate whther the report control block is enabled

property rpt_id: bytes#

Value of the report id