Skip to content

Commit c74a656

Browse files
Added PEBC message types to the S2 Parser TYPE_TO_MESSAGE_CLASS dictionary (#121)
* Added PEBC Message classes to the S2 Parser TYPE_TO_MESSAGE_CLASS dict * Added PEBC.EnergyConstraint and PEBC.Instruction message types to S2 parser
1 parent aec41a6 commit c74a656

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/s2python/s2_parser.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
FRBCTimerStatus,
2525
FRBCUsageForecast,
2626
)
27+
from s2python.pebc import PEBCPowerConstraints, PEBCEnergyConstraint, PEBCInstruction
2728
from s2python.ppbc import PPBCScheduleInstruction
2829

2930
from s2python.message import S2Message
@@ -48,6 +49,9 @@
4849
"FRBC.TimerStatus": FRBCTimerStatus,
4950
"FRBC.UsageForecast": FRBCUsageForecast,
5051
"PPBC.ScheduleInstruction": PPBCScheduleInstruction,
52+
"PEBC.PowerConstraints": PEBCPowerConstraints,
53+
"PEBC.Instruction": PEBCInstruction,
54+
"PEBC.EnergyConstraint": PEBCEnergyConstraint,
5155
"Handshake": Handshake,
5256
"HandshakeResponse": HandshakeResponse,
5357
"InstructionStatusUpdate": InstructionStatusUpdate,
@@ -90,7 +94,9 @@ def parse_as_any_message(unparsed_message: Union[dict, str, bytes]) -> S2Message
9094
return TYPE_TO_MESSAGE_CLASS[message_type].model_validate(message_json)
9195

9296
@staticmethod
93-
def parse_as_message(unparsed_message: Union[dict, str, bytes], as_message: Type[M]) -> M:
97+
def parse_as_message(
98+
unparsed_message: Union[dict, str, bytes], as_message: Type[M]
99+
) -> M:
94100
"""Parse the message to a specific S2 python message.
95101
96102
:param unparsed_message: The message as a JSON-formatted string or as a JSON-parsed dictionary.

0 commit comments

Comments
 (0)