GtDriverBooleanactuatorCmd

Python pydantic class corresponding to json type gt.driver.booleanactuator.cmd, version 100.

class gwproto.types.GtDriverBooleanactuatorCmd(*, RelayState, ShNodeAlias, CommandTimeUnixMs, TypeName='gt.driver.booleanactuator.cmd', Version='100')

Boolean Actuator Driver Command.

The boolean actuator actor reports when it has sent an actuation command to its driver so that the SCADA can add this to information to be sent up to the AtomicTNode.

[More info](https://gridworks.readthedocs.io/en/latest/relay-state.html)

Parameters:
  • RelayState (int)

  • ShNodeAlias (str)

  • CommandTimeUnixMs (int)

  • TypeName (Literal['gt.driver.booleanactuator.cmd'])

  • Version (Literal['100'])

as_dict()

Translate the object into a dictionary representation that can be serialized into a gt.driver.booleanactuator.cmd.100 object.

This method prepares the object for serialization by the as_type method, creating a dictionary with key-value pairs that follow the requirements for an instance of the gt.driver.booleanactuator.cmd.100 type. Unlike the standard python dict method, it makes the following substantive changes: - Enum Values: Translates between the values used locally by the actor to the symbol sent in messages. - Removes any key-value pairs where the value is None for a clearer message, especially in cases with many optional attributes.

It also applies these changes recursively to sub-types.

Return type:

Dict[str, Any]

as_type()

Serialize to the gt.driver.booleanactuator.cmd.100 representation.

Instances in the class are python-native representations of gt.driver.booleanactuator.cmd.100 objects, while the actual gt.driver.booleanactuator.cmd.100 object is the serialized UTF-8 byte string designed for sending in a message.

This method calls the as_dict() method, which differs from the native python dict() in the following key ways: - Enum Values: Translates between the values used locally by the actor to the symbol sent in messages. - - Removes any key-value pairs where the value is None for a clearer message, especially in cases with many optional attributes.

It also applies these changes recursively to sub-types.

Its near-inverse is GtDriverBooleanactuatorCmd.type_to_tuple(). If the type (or any sub-types) includes an enum, then the type_to_tuple will map an unrecognized symbol to the default enum value. This is why these two methods are only ‘near’ inverses.

Return type:

bytes

RelayState:
  • Description:

  • Format: Bit

ShNodeAlias:
  • Description:

  • Format: LeftRightDot

CommandTimeUnixMs:
  • Description:

  • Format: ReasonableUnixTimeMs

TypeName:
  • Description: All GridWorks Versioned Types have a fixed TypeName, which is a string of lowercase alphanumeric words separated by periods, most significant word (on the left) starting with an alphabet character, and final word NOT all Hindu-Arabic numerals.

Version:
  • Description: All GridWorks Versioned Types have a fixed version, which is a string of three Hindu-Arabic numerals.

class gwproto.types.gt_driver_booleanactuator_cmd.check_is_bit(v)

Checks Bit format

Bit format: The value must be the integer 0 or the integer 1.

Will not attempt to first interpret as an integer. For example, 1.3 will not be interpreted as 1 but will raise an error.

Parameters:

v (int) – the candidate

Raises:

ValueError – if v is not 0 or 1

class gwproto.types.gt_driver_booleanactuator_cmd.check_is_left_right_dot(v)

Checks LeftRightDot Format

LeftRightDot format: Lowercase alphanumeric words separated by periods, with the most significant word (on the left) starting with an alphabet character.

Parameters:

v (str) – the candidate

Raises:

ValueError – if v is not LeftRightDot format

class gwproto.types.gt_driver_booleanactuator_cmd.check_is_reasonable_unix_time_ms(v)

Checks ReasonableUnixTimeMs format

ReasonableUnixTimeMs format: unix milliseconds between Jan 1 2000 and Jan 1 3000

Parameters:

v (int) – the candidate

Raises:

ValueError – if v is not ReasonableUnixTimeMs format

class gwproto.types.GtDriverBooleanactuatorCmd_Maker(relay_state, sh_node_alias, command_time_unix_ms)
Parameters:
  • relay_state (int)

  • sh_node_alias (str)

  • command_time_unix_ms (int)

classmethod dict_to_tuple(d)

Deserialize a dictionary representation of a gt.driver.booleanactuator.cmd.100 message object into a GtDriverBooleanactuatorCmd python object for internal use.

This is the near-inverse of the GtDriverBooleanactuatorCmd.as_dict() method:
  • Enums: translates between the symbols sent in messages between actors and

the values used by the actors internally once they’ve deserialized the messages.
  • Types: recursively validates and deserializes sub-types.

Note that if a required attribute with a default value is missing in a dict, this method will raise a SchemaError. This differs from the pydantic BaseModel practice of auto-completing missing attributes with default values when they exist.

Parameters:

d (dict) – the dictionary resulting from json.loads(t) for a serialized JSON type object t.

Raises:

SchemaError – if the dict cannot be turned into a GtDriverBooleanactuatorCmd object.

Returns:

GtDriverBooleanactuatorCmd

Return type:

GtDriverBooleanactuatorCmd

classmethod tuple_to_type(tpl)

Given a Python class object, returns the serialized JSON type object.

Parameters:

tpl (GtDriverBooleanactuatorCmd)

Return type:

bytes

classmethod type_to_tuple(t)

Given a serialized JSON type object, returns the Python class object.

Parameters:

t (bytes)

Return type:

GtDriverBooleanactuatorCmd