DataChannel¶
Python pydantic class corresponding to json type data.channel, version 000.
- class gwproto.types.DataChannel(*, DisplayName, AboutName, CapturedByName, TelemetryName, TypeName='data.channel', Version='000')¶
Data Channel.
A data channel is a concept of some collection of readings that share all characteristics other than time.
- Parameters:
DisplayName (str)
AboutName (str)
CapturedByName (str)
TelemetryName (TelemetryName)
TypeName (Literal['data.channel'])
Version (Literal['000'])
- as_dict()¶
Translate the object into a dictionary representation that can be serialized into a data.channel.000 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 data.channel.000 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 data.channel.000 representation.
Instances in the class are python-native representations of data.channel.000 objects, while the actual data.channel.000 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 DataChannel.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
- DisplayName:
Description: Display Name. This display name is the handle for the data channel. It is meant to be set by the person/people who will be analyzing time series data. It is only expected to be unique within the data channels associated to a specific Terminal Asset.
- AboutName:
Description: About Name. The name of the SpaceheatNode whose physical quantities are getting captured.
Format: SpaceheatName
- CapturedByName:
Description: The name of the SpaceheatNode that is capturing the physical quantities (which can be AboutName but does not have to be).
Format: SpaceheatName
- TelemetryName:
Description: The name of the physical quantity getting measured.
- 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.data_channel.check_is_spaceheat_name(v)¶
Check SpaceheatName Format.
Validates if the provided string adheres to the SpaceheatName format: Lowercase words separated by periods, where word characters can be alphanumeric or a hyphen, and the first word starts with an alphabet character.
- Parameters:
v (str) – The string to be validated.
- Raises:
ValueError – If the provided string is not in SpaceheatName format.
- class gwproto.types.DataChannel_Maker(display_name, about_name, captured_by_name, telemetry_name)¶
- Parameters:
display_name (str)
about_name (str)
captured_by_name (str)
telemetry_name (TelemetryName)
- classmethod dict_to_tuple(d)¶
Deserialize a dictionary representation of a data.channel.000 message object into a DataChannel python object for internal use.
- This is the near-inverse of the DataChannel.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 DataChannel object.
- Returns:
DataChannel
- Return type:
- classmethod tuple_to_type(tpl)¶
Given a Python class object, returns the serialized JSON type object.
- Parameters:
tpl (DataChannel)
- Return type:
bytes
- classmethod type_to_tuple(t)¶
Given a serialized JSON type object, returns the Python class object.
- Parameters:
t (bytes)
- Return type: