s2-python 0.0.0__py3-none-any.whl → 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- s2_python-0.1.0.dist-info/METADATA +99 -0
- s2_python-0.1.0.dist-info/RECORD +50 -0
- {s2_python-0.0.0.dist-info → s2_python-0.1.0.dist-info}/WHEEL +1 -1
- s2python/__init__.py +1 -1
- s2python/common/__init__.py +12 -2
- s2python/common/duration.py +7 -4
- s2python/common/handshake.py +6 -3
- s2python/common/handshake_response.py +6 -3
- s2python/common/instruction_status_update.py +14 -5
- s2python/common/number_range.py +22 -10
- s2python/common/power_forecast.py +10 -5
- s2python/common/power_forecast_element.py +11 -5
- s2python/common/power_forecast_value.py +5 -2
- s2python/common/power_measurement.py +8 -5
- s2python/common/power_range.py +12 -4
- s2python/common/power_value.py +5 -2
- s2python/common/reception_status.py +8 -3
- s2python/common/resource_manager_details.py +18 -8
- s2python/common/revoke_object.py +7 -4
- s2python/common/role.py +5 -2
- s2python/common/select_control_type.py +6 -3
- s2python/common/session_request.py +6 -3
- s2python/common/support.py +19 -11
- s2python/common/timer.py +7 -4
- s2python/common/transition.py +16 -9
- s2python/frbc/__init__.py +3 -1
- s2python/frbc/frbc_actuator_description.py +99 -37
- s2python/frbc/frbc_actuator_status.py +13 -6
- s2python/frbc/frbc_fill_level_target_profile.py +21 -6
- s2python/frbc/frbc_fill_level_target_profile_element.py +17 -5
- s2python/frbc/frbc_instruction.py +9 -6
- s2python/frbc/frbc_leakage_behaviour.py +10 -5
- s2python/frbc/frbc_leakage_behaviour_element.py +13 -4
- s2python/frbc/frbc_operation_mode.py +32 -13
- s2python/frbc/frbc_operation_mode_element.py +20 -7
- s2python/frbc/frbc_storage_description.py +13 -4
- s2python/frbc/frbc_storage_status.py +6 -3
- s2python/frbc/frbc_system_description.py +16 -6
- s2python/frbc/frbc_timer_status.py +8 -5
- s2python/frbc/frbc_usage_forecast.py +10 -5
- s2python/frbc/frbc_usage_forecast_element.py +11 -4
- s2python/generated/gen_s2.py +476 -476
- s2python/s2_parser.py +113 -0
- s2python/s2_validation_error.py +4 -1
- s2python/utils.py +8 -3
- s2python/validate_values_mixin.py +90 -37
- s2python/version.py +1 -1
- s2_python-0.0.0.dist-info/METADATA +0 -50
- s2_python-0.0.0.dist-info/RECORD +0 -49
- {s2_python-0.0.0.dist-info → s2_python-0.1.0.dist-info}/entry_points.txt +0 -0
- {s2_python-0.0.0.dist-info → s2_python-0.1.0.dist-info}/top_level.txt +0 -0
s2python/common/timer.py
CHANGED
@@ -2,13 +2,16 @@ import uuid
|
|
2
2
|
|
3
3
|
from s2python.common.duration import Duration
|
4
4
|
from s2python.generated.gen_s2 import Timer as GenTimer
|
5
|
-
from s2python.validate_values_mixin import
|
5
|
+
from s2python.validate_values_mixin import (
|
6
|
+
S2Message,
|
7
|
+
catch_and_convert_exceptions,
|
8
|
+
)
|
6
9
|
|
7
10
|
|
8
11
|
@catch_and_convert_exceptions
|
9
|
-
class Timer(GenTimer,
|
12
|
+
class Timer(GenTimer, S2Message["Timer"]):
|
10
13
|
class Config(GenTimer.Config):
|
11
14
|
validate_assignment = True
|
12
15
|
|
13
|
-
id: uuid.UUID = GenTimer.__fields__[
|
14
|
-
duration: Duration = GenTimer.__fields__[
|
16
|
+
id: uuid.UUID = GenTimer.__fields__["id"].field_info # type: ignore[assignment]
|
17
|
+
duration: Duration = GenTimer.__fields__["duration"].field_info # type: ignore[assignment]
|
s2python/common/transition.py
CHANGED
@@ -1,19 +1,26 @@
|
|
1
1
|
import uuid
|
2
2
|
from typing import Optional, List
|
3
3
|
|
4
|
-
from s2python.common import Duration
|
4
|
+
from s2python.common.duration import Duration
|
5
5
|
from s2python.generated.gen_s2 import Transition as GenTransition
|
6
|
-
from s2python.validate_values_mixin import
|
6
|
+
from s2python.validate_values_mixin import (
|
7
|
+
S2Message,
|
8
|
+
catch_and_convert_exceptions,
|
9
|
+
)
|
7
10
|
|
8
11
|
|
9
12
|
@catch_and_convert_exceptions
|
10
|
-
class Transition(GenTransition,
|
13
|
+
class Transition(GenTransition, S2Message["Transition"]):
|
11
14
|
class Config(GenTransition.Config):
|
12
15
|
validate_assignment = True
|
13
16
|
|
14
|
-
id: uuid.UUID = GenTransition.__fields__[
|
15
|
-
from_: uuid.UUID = GenTransition.__fields__[
|
16
|
-
to: uuid.UUID = GenTransition.__fields__[
|
17
|
-
start_timers: List[uuid.UUID] = GenTransition.__fields__[
|
18
|
-
blocking_timers: List[uuid.UUID] = GenTransition.__fields__[
|
19
|
-
|
17
|
+
id: uuid.UUID = GenTransition.__fields__["id"].field_info # type: ignore[assignment]
|
18
|
+
from_: uuid.UUID = GenTransition.__fields__["from_"].field_info # type: ignore[assignment]
|
19
|
+
to: uuid.UUID = GenTransition.__fields__["to"].field_info # type: ignore[assignment]
|
20
|
+
start_timers: List[uuid.UUID] = GenTransition.__fields__["start_timers"].field_info # type: ignore[assignment]
|
21
|
+
blocking_timers: List[uuid.UUID] = GenTransition.__fields__[
|
22
|
+
"blocking_timers"
|
23
|
+
].field_info # type: ignore[assignment]
|
24
|
+
transition_duration: Optional[Duration] = GenTransition.__fields__[
|
25
|
+
"transition_duration"
|
26
|
+
].field_info # type: ignore[assignment]
|
s2python/frbc/__init__.py
CHANGED
@@ -1,4 +1,6 @@
|
|
1
|
-
from s2python.frbc.frbc_fill_level_target_profile_element import
|
1
|
+
from s2python.frbc.frbc_fill_level_target_profile_element import (
|
2
|
+
FRBCFillLevelTargetProfileElement,
|
3
|
+
)
|
2
4
|
from s2python.frbc.frbc_fill_level_target_profile import FRBCFillLevelTargetProfile
|
3
5
|
from s2python.frbc.frbc_instruction import FRBCInstruction
|
4
6
|
from s2python.frbc.frbc_leakage_behaviour_element import FRBCLeakageBehaviourElement
|
@@ -6,103 +6,165 @@ from pydantic import root_validator
|
|
6
6
|
|
7
7
|
from s2python.common import Transition, Timer, Commodity
|
8
8
|
from s2python.common.support import commodity_has_quantity
|
9
|
-
from s2python.frbc import FRBCOperationMode
|
10
|
-
from s2python.generated.gen_s2 import
|
11
|
-
|
9
|
+
from s2python.frbc.frbc_operation_mode import FRBCOperationMode
|
10
|
+
from s2python.generated.gen_s2 import (
|
11
|
+
FRBCActuatorDescription as GenFRBCActuatorDescription,
|
12
|
+
CommodityQuantity,
|
13
|
+
)
|
14
|
+
from s2python.validate_values_mixin import (
|
15
|
+
S2Message,
|
16
|
+
catch_and_convert_exceptions,
|
17
|
+
)
|
12
18
|
|
13
19
|
|
14
20
|
@catch_and_convert_exceptions
|
15
|
-
class FRBCActuatorDescription(
|
21
|
+
class FRBCActuatorDescription(
|
22
|
+
GenFRBCActuatorDescription, S2Message["FRBCActuatorDescription"]
|
23
|
+
):
|
16
24
|
class Config(GenFRBCActuatorDescription.Config):
|
17
25
|
validate_assignment = True
|
18
26
|
|
19
|
-
id: uuid.UUID = GenFRBCActuatorDescription.__fields__[
|
20
|
-
operation_modes: List[FRBCOperationMode] = GenFRBCActuatorDescription.__fields__[
|
21
|
-
|
22
|
-
|
23
|
-
|
27
|
+
id: uuid.UUID = GenFRBCActuatorDescription.__fields__["id"].field_info # type: ignore[assignment]
|
28
|
+
operation_modes: List[FRBCOperationMode] = GenFRBCActuatorDescription.__fields__[
|
29
|
+
"operation_modes"
|
30
|
+
].field_info # type: ignore[assignment]
|
31
|
+
transitions: List[Transition] = GenFRBCActuatorDescription.__fields__[
|
32
|
+
"transitions"
|
33
|
+
].field_info # type: ignore[assignment]
|
34
|
+
timers: List[Timer] = GenFRBCActuatorDescription.__fields__["timers"].field_info # type: ignore[assignment]
|
35
|
+
supported_commodities: List[Commodity] = GenFRBCActuatorDescription.__fields__[
|
36
|
+
"supported_commodities"
|
37
|
+
].field_info # type: ignore[assignment]
|
24
38
|
|
25
39
|
@root_validator(pre=False)
|
40
|
+
@classmethod
|
26
41
|
def validate_timers_in_transitions(cls, values: Dict[str, Any]) -> Dict[str, Any]:
|
27
42
|
timers_by_id = {timer.id: timer for timer in values.get("timers", {})}
|
28
43
|
transition: Transition
|
29
44
|
for transition in values.get("transitions", []):
|
30
45
|
for start_timer_id in transition.start_timers:
|
31
46
|
if start_timer_id not in timers_by_id:
|
32
|
-
raise ValueError(
|
33
|
-
|
47
|
+
raise ValueError(
|
48
|
+
cls,
|
49
|
+
f"{start_timer_id} was referenced as start timer in transition "
|
50
|
+
f"{transition.id} but was not defined in 'timers'.",
|
51
|
+
)
|
34
52
|
|
35
53
|
for blocking_timer_id in transition.blocking_timers:
|
36
54
|
if blocking_timer_id not in timers_by_id:
|
37
|
-
raise ValueError(
|
38
|
-
|
55
|
+
raise ValueError(
|
56
|
+
cls,
|
57
|
+
f"{blocking_timer_id} was referenced as blocking timer in transition "
|
58
|
+
f"{transition.id} but was not defined in 'timers'.",
|
59
|
+
)
|
39
60
|
|
40
61
|
return values
|
41
62
|
|
42
63
|
@root_validator(pre=False)
|
64
|
+
@classmethod
|
43
65
|
def validate_timers_unique_ids(cls, values: Dict[str, Any]) -> Dict[str, Any]:
|
44
66
|
ids = []
|
45
67
|
timer: Timer
|
46
68
|
for timer in values.get("timers", []):
|
47
69
|
if timer.id in ids:
|
48
|
-
raise ValueError(
|
70
|
+
raise ValueError(
|
71
|
+
cls, f"Id {timer.id} was found multiple times in 'timers'."
|
72
|
+
)
|
49
73
|
ids.append(timer.id)
|
50
74
|
|
51
75
|
return values
|
52
76
|
|
53
77
|
@root_validator(pre=False)
|
54
|
-
|
55
|
-
|
56
|
-
|
78
|
+
@classmethod
|
79
|
+
def validate_operation_modes_in_transitions(
|
80
|
+
cls, values: Dict[str, Any]
|
81
|
+
) -> Dict[str, Any]:
|
82
|
+
operation_mode_by_id = {
|
83
|
+
operation_mode.id: operation_mode
|
84
|
+
for operation_mode in values.get("operation_modes", [])
|
85
|
+
}
|
57
86
|
transition: Transition
|
58
87
|
for transition in values.get("transitions", []):
|
59
88
|
if transition.from_ not in operation_mode_by_id:
|
60
|
-
raise ValueError(
|
61
|
-
|
89
|
+
raise ValueError(
|
90
|
+
cls,
|
91
|
+
f"Operation mode {transition.from_} was referenced as 'from' in transition "
|
92
|
+
f"{transition.id} but was not defined in 'operation_modes'.",
|
93
|
+
)
|
62
94
|
|
63
95
|
if transition.to not in operation_mode_by_id:
|
64
|
-
raise ValueError(
|
65
|
-
|
96
|
+
raise ValueError(
|
97
|
+
cls,
|
98
|
+
f"Operation mode {transition.to} was referenced as 'to' in transition "
|
99
|
+
f"{transition.id} but was not defined in 'operation_modes'.",
|
100
|
+
)
|
66
101
|
|
67
102
|
return values
|
68
103
|
|
69
104
|
@root_validator(pre=False)
|
70
|
-
|
105
|
+
@classmethod
|
106
|
+
def validate_operation_modes_unique_ids(
|
107
|
+
cls, values: Dict[str, Any]
|
108
|
+
) -> Dict[str, Any]:
|
71
109
|
ids = []
|
72
110
|
operation_mode: FRBCOperationMode
|
73
111
|
for operation_mode in values.get("operation_modes", []):
|
74
112
|
if operation_mode.id in ids:
|
75
|
-
raise ValueError(
|
113
|
+
raise ValueError(
|
114
|
+
cls,
|
115
|
+
f"Id {operation_mode.id} was found multiple times in 'operation_modes'.",
|
116
|
+
)
|
76
117
|
ids.append(operation_mode.id)
|
77
118
|
|
78
119
|
return values
|
79
120
|
|
80
121
|
@root_validator(pre=False)
|
81
|
-
|
82
|
-
|
122
|
+
@classmethod
|
123
|
+
def validate_operation_mode_elements_have_all_supported_commodities(
|
124
|
+
cls, values: Dict[str, Any]
|
125
|
+
) -> Dict[str, Any]:
|
126
|
+
supported_commodities = values.get("supported_commodities", [])
|
83
127
|
operation_mode: FRBCOperationMode
|
84
128
|
for operation_mode in values.get("operation_modes", []):
|
85
129
|
for operation_mode_element in operation_mode.elements:
|
86
130
|
for commodity in supported_commodities:
|
87
|
-
power_ranges_for_commodity = [
|
88
|
-
|
89
|
-
|
131
|
+
power_ranges_for_commodity = [
|
132
|
+
power_range
|
133
|
+
for power_range in operation_mode_element.power_ranges
|
134
|
+
if commodity_has_quantity(
|
135
|
+
commodity, power_range.commodity_quantity
|
136
|
+
)
|
137
|
+
]
|
90
138
|
|
91
139
|
if len(power_ranges_for_commodity) > 1:
|
92
|
-
raise ValueError(
|
93
|
-
|
94
|
-
|
140
|
+
raise ValueError(
|
141
|
+
cls,
|
142
|
+
f"Multiple power ranges defined for commodity {commodity} in operation "
|
143
|
+
f"mode {operation_mode.id} and element with fill_level_range "
|
144
|
+
f"{operation_mode_element.fill_level_range}",
|
145
|
+
)
|
95
146
|
if not power_ranges_for_commodity:
|
96
|
-
raise ValueError(
|
97
|
-
|
98
|
-
|
147
|
+
raise ValueError(
|
148
|
+
cls,
|
149
|
+
f"No power ranges defined for commodity {commodity} in operation "
|
150
|
+
f"mode {operation_mode.id} and element with fill_level_range "
|
151
|
+
f"{operation_mode_element.fill_level_range}",
|
152
|
+
)
|
99
153
|
return values
|
100
154
|
|
101
155
|
@root_validator(pre=False)
|
102
|
-
|
103
|
-
|
156
|
+
@classmethod
|
157
|
+
def validate_unique_supported_commodities(
|
158
|
+
cls, values: Dict[str, Any]
|
159
|
+
) -> Dict[str, Any]:
|
160
|
+
supported_commodities: List[CommodityQuantity] = values.get(
|
161
|
+
"supported_commodities", []
|
162
|
+
)
|
104
163
|
|
105
164
|
for supported_commodity in supported_commodities:
|
106
165
|
if supported_commodities.count(supported_commodity) > 1:
|
107
|
-
raise ValueError(
|
166
|
+
raise ValueError(
|
167
|
+
cls,
|
168
|
+
f"Found duplicate {supported_commodity} commodity in 'supported_commodities'",
|
169
|
+
)
|
108
170
|
return values
|
@@ -2,15 +2,22 @@ from typing import Optional
|
|
2
2
|
import uuid
|
3
3
|
|
4
4
|
from s2python.generated.gen_s2 import FRBCActuatorStatus as GenFRBCActuatorStatus
|
5
|
-
from s2python.validate_values_mixin import
|
5
|
+
from s2python.validate_values_mixin import (
|
6
|
+
catch_and_convert_exceptions,
|
7
|
+
S2Message,
|
8
|
+
)
|
6
9
|
|
7
10
|
|
8
11
|
@catch_and_convert_exceptions
|
9
|
-
class FRBCActuatorStatus(GenFRBCActuatorStatus,
|
12
|
+
class FRBCActuatorStatus(GenFRBCActuatorStatus, S2Message["FRBCActuatorStatus"]):
|
10
13
|
class Config(GenFRBCActuatorStatus.Config):
|
11
14
|
validate_assignment = True
|
12
15
|
|
13
|
-
active_operation_mode_id: uuid.UUID = GenFRBCActuatorStatus.__fields__[
|
14
|
-
|
15
|
-
|
16
|
-
|
16
|
+
active_operation_mode_id: uuid.UUID = GenFRBCActuatorStatus.__fields__[
|
17
|
+
"active_operation_mode_id"
|
18
|
+
].field_info # type: ignore[assignment]
|
19
|
+
actuator_id: uuid.UUID = GenFRBCActuatorStatus.__fields__["actuator_id"].field_info # type: ignore[assignment]
|
20
|
+
message_id: uuid.UUID = GenFRBCActuatorStatus.__fields__["message_id"].field_info # type: ignore[assignment]
|
21
|
+
previous_operation_mode_id: Optional[uuid.UUID] = GenFRBCActuatorStatus.__fields__[
|
22
|
+
"previous_operation_mode_id"
|
23
|
+
].field_info # type: ignore[assignment]
|
@@ -1,15 +1,30 @@
|
|
1
1
|
from typing import List
|
2
2
|
import uuid
|
3
3
|
|
4
|
-
from s2python.frbc import
|
5
|
-
|
6
|
-
|
4
|
+
from s2python.frbc.frbc_fill_level_target_profile_element import (
|
5
|
+
FRBCFillLevelTargetProfileElement,
|
6
|
+
)
|
7
|
+
from s2python.generated.gen_s2 import (
|
8
|
+
FRBCFillLevelTargetProfile as GenFRBCFillLevelTargetProfile,
|
9
|
+
)
|
10
|
+
from s2python.validate_values_mixin import (
|
11
|
+
catch_and_convert_exceptions,
|
12
|
+
S2Message,
|
13
|
+
)
|
7
14
|
|
8
15
|
|
9
16
|
@catch_and_convert_exceptions
|
10
|
-
class FRBCFillLevelTargetProfile(
|
17
|
+
class FRBCFillLevelTargetProfile(
|
18
|
+
GenFRBCFillLevelTargetProfile, S2Message["FRBCFillLevelTargetProfile"]
|
19
|
+
):
|
11
20
|
class Config(GenFRBCFillLevelTargetProfile.Config):
|
12
21
|
validate_assignment = True
|
13
22
|
|
14
|
-
elements: List[
|
15
|
-
|
23
|
+
elements: List[
|
24
|
+
FRBCFillLevelTargetProfileElement
|
25
|
+
] = GenFRBCFillLevelTargetProfile.__fields__[
|
26
|
+
"elements"
|
27
|
+
].field_info # type: ignore[assignment]
|
28
|
+
message_id: uuid.UUID = GenFRBCFillLevelTargetProfile.__fields__[
|
29
|
+
"message_id"
|
30
|
+
].field_info # type: ignore[assignment]
|
@@ -1,13 +1,25 @@
|
|
1
1
|
from s2python.common import Duration, NumberRange
|
2
2
|
|
3
|
-
from s2python.generated.gen_s2 import
|
4
|
-
|
3
|
+
from s2python.generated.gen_s2 import (
|
4
|
+
FRBCFillLevelTargetProfileElement as GenFRBCFillLevelTargetProfileElement,
|
5
|
+
)
|
6
|
+
from s2python.validate_values_mixin import (
|
7
|
+
catch_and_convert_exceptions,
|
8
|
+
S2Message,
|
9
|
+
)
|
5
10
|
|
6
11
|
|
7
12
|
@catch_and_convert_exceptions
|
8
|
-
class FRBCFillLevelTargetProfileElement(
|
13
|
+
class FRBCFillLevelTargetProfileElement(
|
14
|
+
GenFRBCFillLevelTargetProfileElement,
|
15
|
+
S2Message["FRBCFillLevelTargetProfileElement"],
|
16
|
+
):
|
9
17
|
class Config(GenFRBCFillLevelTargetProfileElement.Config):
|
10
18
|
validate_assignment = True
|
11
19
|
|
12
|
-
duration: Duration = GenFRBCFillLevelTargetProfileElement.__fields__[
|
13
|
-
|
20
|
+
duration: Duration = GenFRBCFillLevelTargetProfileElement.__fields__[
|
21
|
+
"duration"
|
22
|
+
].field_info # type: ignore[assignment]
|
23
|
+
fill_level_range: NumberRange = GenFRBCFillLevelTargetProfileElement.__fields__[
|
24
|
+
"fill_level_range"
|
25
|
+
].field_info # type: ignore[assignment]
|
@@ -1,15 +1,18 @@
|
|
1
1
|
import uuid
|
2
2
|
|
3
3
|
from s2python.generated.gen_s2 import FRBCInstruction as GenFRBCInstruction
|
4
|
-
from s2python.validate_values_mixin import
|
4
|
+
from s2python.validate_values_mixin import (
|
5
|
+
catch_and_convert_exceptions,
|
6
|
+
S2Message,
|
7
|
+
)
|
5
8
|
|
6
9
|
|
7
10
|
@catch_and_convert_exceptions
|
8
|
-
class FRBCInstruction(GenFRBCInstruction,
|
11
|
+
class FRBCInstruction(GenFRBCInstruction, S2Message["FRBCInstruction"]):
|
9
12
|
class Config(GenFRBCInstruction.Config):
|
10
13
|
validate_assignment = True
|
11
14
|
|
12
|
-
actuator_id: uuid.UUID = GenFRBCInstruction.__fields__[
|
13
|
-
id: uuid.UUID = GenFRBCInstruction.__fields__[
|
14
|
-
message_id: uuid.UUID = GenFRBCInstruction.__fields__[
|
15
|
-
operation_mode:
|
15
|
+
actuator_id: uuid.UUID = GenFRBCInstruction.__fields__["actuator_id"].field_info # type: ignore[assignment]
|
16
|
+
id: uuid.UUID = GenFRBCInstruction.__fields__["id"].field_info # type: ignore[assignment]
|
17
|
+
message_id: uuid.UUID = GenFRBCInstruction.__fields__["message_id"].field_info # type: ignore[assignment]
|
18
|
+
operation_mode: uuid.UUID = GenFRBCInstruction.__fields__["operation_mode"].field_info # type: ignore[assignment]
|
@@ -1,15 +1,20 @@
|
|
1
1
|
from typing import List
|
2
2
|
import uuid
|
3
3
|
|
4
|
-
from s2python.frbc import FRBCLeakageBehaviourElement
|
4
|
+
from s2python.frbc.frbc_leakage_behaviour_element import FRBCLeakageBehaviourElement
|
5
5
|
from s2python.generated.gen_s2 import FRBCLeakageBehaviour as GenFRBCLeakageBehaviour
|
6
|
-
from s2python.validate_values_mixin import
|
6
|
+
from s2python.validate_values_mixin import (
|
7
|
+
catch_and_convert_exceptions,
|
8
|
+
S2Message,
|
9
|
+
)
|
7
10
|
|
8
11
|
|
9
12
|
@catch_and_convert_exceptions
|
10
|
-
class FRBCLeakageBehaviour(GenFRBCLeakageBehaviour,
|
13
|
+
class FRBCLeakageBehaviour(GenFRBCLeakageBehaviour, S2Message["FRBCLeakageBehaviour"]):
|
11
14
|
class Config(GenFRBCLeakageBehaviour.Config):
|
12
15
|
validate_assignment = True
|
13
16
|
|
14
|
-
elements: List[FRBCLeakageBehaviourElement] = GenFRBCLeakageBehaviour.__fields__[
|
15
|
-
|
17
|
+
elements: List[FRBCLeakageBehaviourElement] = GenFRBCLeakageBehaviour.__fields__[
|
18
|
+
"elements"
|
19
|
+
].field_info # type: ignore[assignment]
|
20
|
+
message_id: uuid.UUID = GenFRBCLeakageBehaviour.__fields__["message_id"].field_info # type: ignore[assignment]
|
@@ -1,11 +1,20 @@
|
|
1
1
|
from s2python.common import NumberRange
|
2
|
-
from s2python.generated.gen_s2 import
|
3
|
-
|
2
|
+
from s2python.generated.gen_s2 import (
|
3
|
+
FRBCLeakageBehaviourElement as GenFRBCLeakageBehaviourElement,
|
4
|
+
)
|
5
|
+
from s2python.validate_values_mixin import (
|
6
|
+
catch_and_convert_exceptions,
|
7
|
+
S2Message,
|
8
|
+
)
|
4
9
|
|
5
10
|
|
6
11
|
@catch_and_convert_exceptions
|
7
|
-
class FRBCLeakageBehaviourElement(
|
12
|
+
class FRBCLeakageBehaviourElement(
|
13
|
+
GenFRBCLeakageBehaviourElement, S2Message["FRBCLeakageBehaviourElement"]
|
14
|
+
):
|
8
15
|
class Config(GenFRBCLeakageBehaviourElement.Config):
|
9
16
|
validate_assignment = True
|
10
17
|
|
11
|
-
fill_level_range: NumberRange = GenFRBCLeakageBehaviourElement.__fields__[
|
18
|
+
fill_level_range: NumberRange = GenFRBCLeakageBehaviourElement.__fields__[
|
19
|
+
"fill_level_range"
|
20
|
+
].field_info # type: ignore[assignment]
|
@@ -1,34 +1,53 @@
|
|
1
|
-
#from itertools import pairwise
|
1
|
+
# from itertools import pairwise
|
2
2
|
import uuid
|
3
|
-
from typing import List, Dict, Any
|
3
|
+
from typing import List, Dict, Any
|
4
4
|
|
5
5
|
from pydantic import root_validator
|
6
6
|
|
7
7
|
from s2python.common import NumberRange
|
8
|
-
from s2python.frbc import FRBCOperationModeElement
|
8
|
+
from s2python.frbc.frbc_operation_mode_element import FRBCOperationModeElement
|
9
9
|
from s2python.generated.gen_s2 import FRBCOperationMode as GenFRBCOperationMode
|
10
|
-
from s2python.validate_values_mixin import
|
10
|
+
from s2python.validate_values_mixin import (
|
11
|
+
S2Message,
|
12
|
+
catch_and_convert_exceptions,
|
13
|
+
)
|
11
14
|
from s2python.utils import pairwise
|
12
15
|
|
16
|
+
|
13
17
|
@catch_and_convert_exceptions
|
14
|
-
class FRBCOperationMode(GenFRBCOperationMode,
|
18
|
+
class FRBCOperationMode(GenFRBCOperationMode, S2Message["FRBCOperationMode"]):
|
15
19
|
class Config(GenFRBCOperationMode.Config):
|
16
20
|
validate_assignment = True
|
17
21
|
|
18
|
-
id: uuid.UUID = GenFRBCOperationMode.__fields__[
|
19
|
-
elements: List[FRBCOperationModeElement] = GenFRBCOperationMode.__fields__[
|
22
|
+
id: uuid.UUID = GenFRBCOperationMode.__fields__["id"].field_info # type: ignore[assignment]
|
23
|
+
elements: List[FRBCOperationModeElement] = GenFRBCOperationMode.__fields__[
|
24
|
+
"elements"
|
25
|
+
].field_info # type: ignore[assignment]
|
20
26
|
|
21
27
|
@root_validator(pre=False)
|
22
|
-
|
28
|
+
@classmethod
|
29
|
+
def validate_contiguous_fill_levels_operation_mode_elements(
|
30
|
+
cls, values: Dict[str, Any]
|
31
|
+
) -> Dict[str, Any]:
|
23
32
|
elements_by_fill_level_range: Dict[NumberRange, FRBCOperationModeElement]
|
24
|
-
elements_by_fill_level_range = {
|
33
|
+
elements_by_fill_level_range = {
|
34
|
+
element.fill_level_range: element for element in values.get("elements", [])
|
35
|
+
}
|
25
36
|
|
26
37
|
sorted_fill_level_ranges: List[NumberRange]
|
27
38
|
sorted_fill_level_ranges = list(elements_by_fill_level_range.keys())
|
28
39
|
sorted_fill_level_ranges.sort(key=lambda r: r.start_of_range)
|
29
40
|
|
30
|
-
for current_fill_level_range, next_fill_level_range in pairwise(
|
31
|
-
|
32
|
-
|
33
|
-
|
41
|
+
for current_fill_level_range, next_fill_level_range in pairwise(
|
42
|
+
sorted_fill_level_ranges
|
43
|
+
):
|
44
|
+
if (
|
45
|
+
current_fill_level_range.end_of_range
|
46
|
+
!= next_fill_level_range.start_of_range
|
47
|
+
):
|
48
|
+
raise ValueError(
|
49
|
+
cls,
|
50
|
+
f"Elements with fill level ranges {current_fill_level_range} and "
|
51
|
+
f"{next_fill_level_range} are closest match to each other but not contiguous.",
|
52
|
+
)
|
34
53
|
return values
|
@@ -1,16 +1,29 @@
|
|
1
1
|
from typing import Optional, List
|
2
2
|
|
3
3
|
from s2python.common import NumberRange, PowerRange
|
4
|
-
from s2python.generated.gen_s2 import
|
5
|
-
|
4
|
+
from s2python.generated.gen_s2 import (
|
5
|
+
FRBCOperationModeElement as GenFRBCOperationModeElement,
|
6
|
+
)
|
7
|
+
from s2python.validate_values_mixin import (
|
8
|
+
S2Message,
|
9
|
+
catch_and_convert_exceptions,
|
10
|
+
)
|
6
11
|
|
7
12
|
|
8
13
|
@catch_and_convert_exceptions
|
9
|
-
class FRBCOperationModeElement(
|
14
|
+
class FRBCOperationModeElement(
|
15
|
+
GenFRBCOperationModeElement, S2Message["FRBCOperationModeElement"]
|
16
|
+
):
|
10
17
|
class Config(GenFRBCOperationModeElement.Config):
|
11
18
|
validate_assignment = True
|
12
19
|
|
13
|
-
fill_level_range: NumberRange = GenFRBCOperationModeElement.__fields__[
|
14
|
-
|
15
|
-
|
16
|
-
|
20
|
+
fill_level_range: NumberRange = GenFRBCOperationModeElement.__fields__[
|
21
|
+
"fill_level_range"
|
22
|
+
].field_info # type: ignore[assignment]
|
23
|
+
fill_rate: NumberRange = GenFRBCOperationModeElement.__fields__["fill_rate"].field_info # type: ignore[assignment]
|
24
|
+
power_ranges: List[PowerRange] = GenFRBCOperationModeElement.__fields__[
|
25
|
+
"power_ranges"
|
26
|
+
].field_info # type: ignore[assignment]
|
27
|
+
running_costs: Optional[NumberRange] = GenFRBCOperationModeElement.__fields__[
|
28
|
+
"running_costs"
|
29
|
+
].field_info # type: ignore[assignment]
|
@@ -1,11 +1,20 @@
|
|
1
1
|
from s2python.common import NumberRange
|
2
|
-
from s2python.generated.gen_s2 import
|
3
|
-
|
2
|
+
from s2python.generated.gen_s2 import (
|
3
|
+
FRBCStorageDescription as GenFRBCStorageDescription,
|
4
|
+
)
|
5
|
+
from s2python.validate_values_mixin import (
|
6
|
+
catch_and_convert_exceptions,
|
7
|
+
S2Message,
|
8
|
+
)
|
4
9
|
|
5
10
|
|
6
11
|
@catch_and_convert_exceptions
|
7
|
-
class FRBCStorageDescription(
|
12
|
+
class FRBCStorageDescription(
|
13
|
+
GenFRBCStorageDescription, S2Message["FRBCStorageDescription"]
|
14
|
+
):
|
8
15
|
class Config(GenFRBCStorageDescription.Config):
|
9
16
|
validate_assignment = True
|
10
17
|
|
11
|
-
fill_level_range: NumberRange = GenFRBCStorageDescription.__fields__[
|
18
|
+
fill_level_range: NumberRange = GenFRBCStorageDescription.__fields__[
|
19
|
+
"fill_level_range"
|
20
|
+
].field_info # type: ignore[assignment]
|
@@ -1,12 +1,15 @@
|
|
1
1
|
import uuid
|
2
2
|
|
3
3
|
from s2python.generated.gen_s2 import FRBCStorageStatus as GenFRBCStorageStatus
|
4
|
-
from s2python.validate_values_mixin import
|
4
|
+
from s2python.validate_values_mixin import (
|
5
|
+
catch_and_convert_exceptions,
|
6
|
+
S2Message,
|
7
|
+
)
|
5
8
|
|
6
9
|
|
7
10
|
@catch_and_convert_exceptions
|
8
|
-
class FRBCStorageStatus(GenFRBCStorageStatus,
|
11
|
+
class FRBCStorageStatus(GenFRBCStorageStatus, S2Message["FRBCStorageStatus"]):
|
9
12
|
class Config(GenFRBCStorageStatus.Config):
|
10
13
|
validate_assignment = True
|
11
14
|
|
12
|
-
message_id: uuid.UUID = GenFRBCStorageStatus.__fields__[
|
15
|
+
message_id: uuid.UUID = GenFRBCStorageStatus.__fields__["message_id"].field_info # type: ignore[assignment]
|
@@ -2,15 +2,25 @@ from typing import List
|
|
2
2
|
import uuid
|
3
3
|
|
4
4
|
from s2python.generated.gen_s2 import FRBCSystemDescription as GenFRBCSystemDescription
|
5
|
-
from s2python.validate_values_mixin import
|
6
|
-
|
5
|
+
from s2python.validate_values_mixin import (
|
6
|
+
catch_and_convert_exceptions,
|
7
|
+
S2Message,
|
8
|
+
)
|
9
|
+
from s2python.frbc.frbc_actuator_description import FRBCActuatorDescription
|
10
|
+
from s2python.frbc.frbc_storage_description import FRBCStorageDescription
|
7
11
|
|
8
12
|
|
9
13
|
@catch_and_convert_exceptions
|
10
|
-
class FRBCSystemDescription(
|
14
|
+
class FRBCSystemDescription(
|
15
|
+
GenFRBCSystemDescription, S2Message["FRBCSystemDescription"]
|
16
|
+
):
|
11
17
|
class Config(GenFRBCSystemDescription.Config):
|
12
18
|
validate_assignment = True
|
13
19
|
|
14
|
-
actuators: List[FRBCActuatorDescription] = GenFRBCSystemDescription.__fields__[
|
15
|
-
|
16
|
-
|
20
|
+
actuators: List[FRBCActuatorDescription] = GenFRBCSystemDescription.__fields__[
|
21
|
+
"actuators"
|
22
|
+
].field_info # type: ignore[assignment]
|
23
|
+
message_id: uuid.UUID = GenFRBCSystemDescription.__fields__["message_id"].field_info # type: ignore[assignment]
|
24
|
+
storage: FRBCStorageDescription = GenFRBCSystemDescription.__fields__[
|
25
|
+
"storage"
|
26
|
+
].field_info # type: ignore[assignment]
|