Skip to content

Commit c65fdca

Browse files
authored
Add missing message classes for S2Parser (#147)
* Switch from deprecated __fields__ function to model_fields * Add missing OMBC, DDBC and PPBC messages classes for S2Parser
1 parent c2174dd commit c65fdca

2 files changed

Lines changed: 63 additions & 27 deletions

File tree

development_utilities/generate_s2_message_type_to_class.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616
for name, member in all_members:
1717
if (
1818
inspect.isclass(member)
19-
and hasattr(member, "__fields__")
20-
and ("message_type" in member.__fields__)
19+
and hasattr(member, "model_fields")
20+
and ("message_type" in member.model_fields)
2121
):
22-
print(f" '{member.__fields__['message_type'].default}': {name},")
22+
print(f" '{member.model_fields['message_type'].default}': {name},")
2323

2424
print("}")

src/s2python/s2_parser.py

Lines changed: 60 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,31 @@
2424
FRBCTimerStatus,
2525
FRBCUsageForecast,
2626
)
27-
from s2python.pebc import PEBCPowerConstraints, PEBCEnergyConstraint, PEBCInstruction
28-
from s2python.ppbc import PPBCScheduleInstruction
27+
from s2python.pebc import (
28+
PEBCPowerConstraints,
29+
PEBCEnergyConstraint,
30+
PEBCInstruction,
31+
)
32+
from s2python.ppbc import (
33+
PPBCScheduleInstruction,
34+
PPBCEndInterruptionInstruction,
35+
PPBCPowerProfileDefinition,
36+
PPBCPowerProfileStatus,
37+
PPBCStartInterruptionInstruction
38+
)
39+
from s2python.ombc import (
40+
OMBCInstruction,
41+
OMBCStatus,
42+
OMBCSystemDescription,
43+
OMBCTimerStatus
44+
)
45+
from s2python.ddbc import (
46+
DDBCActuatorStatus,
47+
DDBCAverageDemandRateForecast,
48+
DDBCInstruction,
49+
DDBCSystemDescription,
50+
DDBCTimerStatus,
51+
)
2952

3053
from s2python.message import S2Message
3154
from s2python.validate_values_mixin import S2MessageComponent
@@ -40,28 +63,41 @@
4063

4164
# May be generated with development_utilities/generate_s2_message_type_to_class.py
4265
TYPE_TO_MESSAGE_CLASS: Dict[str, Type[S2Message]] = {
43-
"FRBC.ActuatorStatus": FRBCActuatorStatus,
44-
"FRBC.FillLevelTargetProfile": FRBCFillLevelTargetProfile,
45-
"FRBC.Instruction": FRBCInstruction,
46-
"FRBC.LeakageBehaviour": FRBCLeakageBehaviour,
47-
"FRBC.StorageStatus": FRBCStorageStatus,
48-
"FRBC.SystemDescription": FRBCSystemDescription,
49-
"FRBC.TimerStatus": FRBCTimerStatus,
50-
"FRBC.UsageForecast": FRBCUsageForecast,
51-
"PPBC.ScheduleInstruction": PPBCScheduleInstruction,
52-
"PEBC.PowerConstraints": PEBCPowerConstraints,
53-
"PEBC.Instruction": PEBCInstruction,
54-
"PEBC.EnergyConstraint": PEBCEnergyConstraint,
55-
"Handshake": Handshake,
56-
"HandshakeResponse": HandshakeResponse,
57-
"InstructionStatusUpdate": InstructionStatusUpdate,
58-
"PowerForecast": PowerForecast,
59-
"PowerMeasurement": PowerMeasurement,
60-
"ReceptionStatus": ReceptionStatus,
61-
"ResourceManagerDetails": ResourceManagerDetails,
62-
"RevokeObject": RevokeObject,
63-
"SelectControlType": SelectControlType,
64-
"SessionRequest": SessionRequest,
66+
'DDBC.ActuatorStatus': DDBCActuatorStatus,
67+
'DDBC.AverageDemandRateForecast': DDBCAverageDemandRateForecast,
68+
'DDBC.Instruction': DDBCInstruction,
69+
'DDBC.SystemDescription': DDBCSystemDescription,
70+
'DDBC.TimerStatus': DDBCTimerStatus,
71+
'FRBC.ActuatorStatus': FRBCActuatorStatus,
72+
'FRBC.FillLevelTargetProfile': FRBCFillLevelTargetProfile,
73+
'FRBC.Instruction': FRBCInstruction,
74+
'FRBC.LeakageBehaviour': FRBCLeakageBehaviour,
75+
'FRBC.StorageStatus': FRBCStorageStatus,
76+
'FRBC.SystemDescription': FRBCSystemDescription,
77+
'FRBC.TimerStatus': FRBCTimerStatus,
78+
'FRBC.UsageForecast': FRBCUsageForecast,
79+
'Handshake': Handshake,
80+
'HandshakeResponse': HandshakeResponse,
81+
'InstructionStatusUpdate': InstructionStatusUpdate,
82+
'OMBC.Instruction': OMBCInstruction,
83+
'OMBC.Status': OMBCStatus,
84+
'OMBC.SystemDescription': OMBCSystemDescription,
85+
'OMBC.TimerStatus': OMBCTimerStatus,
86+
'PEBC.EnergyConstraint': PEBCEnergyConstraint,
87+
'PEBC.Instruction': PEBCInstruction,
88+
'PEBC.PowerConstraints': PEBCPowerConstraints,
89+
'PPBC.EndInterruptionInstruction': PPBCEndInterruptionInstruction,
90+
'PPBC.PowerProfileDefinition': PPBCPowerProfileDefinition,
91+
'PPBC.PowerProfileStatus': PPBCPowerProfileStatus,
92+
'PPBC.ScheduleInstruction': PPBCScheduleInstruction,
93+
'PPBC.StartInterruptionInstruction': PPBCStartInterruptionInstruction,
94+
'PowerForecast': PowerForecast,
95+
'PowerMeasurement': PowerMeasurement,
96+
'ReceptionStatus': ReceptionStatus,
97+
'ResourceManagerDetails': ResourceManagerDetails,
98+
'RevokeObject': RevokeObject,
99+
'SelectControlType': SelectControlType,
100+
'SessionRequest': SessionRequest,
65101
}
66102

67103

0 commit comments

Comments
 (0)