Control / Operation#

class icspacket.proto.iec61850.control.ControlError(*values)[source]#

Outcome code the client decodes from the error field of a LastApplError diagnostic for an IEC 61850 control request.

Together with a Cause, this tells the caller in what way a control request or response failed.

Added in version 0.2.4.

NO_ERROR = 0#

Indicates the control command completed without error.

UNKNOWN = 1#

Indicates the failure reason could not be classified further.

TIMEOUT = 2#

Indicates the control operation did not complete in time.

OPERATOR_TEST_FAIL = 3#

Indicates the control operation failed while running as an operator test.

class icspacket.proto.iec61850.control.Cause(*values)[source]#

Fine-grained reason the client decodes from the cause field of a LastApplError diagnostic, alongside a ControlError.

Added in version 0.2.4.

exception icspacket.proto.iec61850.control.LastApplError(ctrl_obj: str, error: ControlError, ctlnum: int, cause: Cause, *args: object)[source]#

Exception representing the LastApplError diagnostic from IEC 61850 control services.

Raised when a control service returns an error response containing both a control error and a cause.

Added in version 0.2.4.

Parameters:
  • ctrl_obj (str) – The control object reference string.

  • error (ControlError) – The control error category.

  • ctlnum (int) – The control number associated with the request.

  • cause (Cause) – Detailed cause of the error.

class icspacket.proto.iec61850.control.ControlObject(ref: ObjectReference, spec: TypeDescription, model: ControlModel)[source]#

Represents an IEC 61850 control object reference.

Provides access to control object properties, origin parameters, and the ability to generate operate data structures for issuing control commands.

Implements context manager protocol for safe usage in connection-based operations.

Added in version 0.2.4.

Parameters:
  • ref (ObjectReference) – The object reference for the control point.

  • spec (TypeDescription) – ASN.1 type description of the control object.

  • model (ControlModel) – Control model (e.g., DIRECT_NORMAL or SBO_ENHANCED).

origin_cat: int#

Numeric code for the source category, sent to the server as part of the origin block.

origin_ident: bytes | None#

Byte-string naming or identifying the initiating client/system, sent together with origin_cat.

ctl_num: int#

Running counter that tracks SBO and direct control operations; advanced automatically for direct-operate models.

test: bool#

Marks whether the server should treat this command as a test rather than a normal operation.

interlock_check: bool#

Controls whether the interlock check is applied when the command executes.

synchro_check: bool#

Controls whether the synchrocheck condition is applied when the command executes.

property ctrl_object_ref: ObjectReference#

Reference to the underlying control object node.

property has_time_activated_oper: bool#

Whether this control object supports time-activated operate requests.

property has_ctl_num: bool#

Whether this control object includes a control number field.

property model: ControlModel#

Return the configured control model for this object.

property ctl_val_type: str | None#

Return the ASN.1 Data CHOICE alternative name expected for ctlVal (e.g. "boolean", "integer", "visible_string"), or None if the control object has no Oper.ctlVal attribute.

origin() list[dict[str, int | bytes]][source]#

Build the origin structure according to IEC 61850-7-2, used by get_operate_data() when assembling a control request.

Returns:

Origin information consisting of category and identifier.

Return type:

list[dict[str, int | bytes]]

get_operate_data(ctl_val: Any, oper_time: Timestamp | None = None, check=True) Data[source]#

Assemble the MMS Data payload written to a control object’s Oper attribute to carry out an operate request.

The value supplied in ctl_val is combined with a fresh T timestamp and the origin block; depending on this control object’s capabilities and the check flag, operTm, ctlNum, Test, and/or Check are folded in as well.

Parameters:
  • ctl_val (Any) – The control value to apply.

  • oper_time (Timestamp | None) – Optional timestamp for time-activated control.

  • check (bool) – Whether to include interlock and synchrocheck parameters.

Returns:

ASN.1 encoded Data structure for the operate request.

Return type:

Data

property T: Timestamp#

Return the current control timestamp (T).

Returns:

Timestamp of the control request.

Return type:

Timestamp