s2-python 0.0.1__py3-none-any.whl → 0.2.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.0.1.dist-info → s2_python-0.2.0.dist-info}/METADATA +22 -4
- s2_python-0.2.0.dist-info/RECORD +54 -0
- {s2_python-0.0.1.dist-info → s2_python-0.2.0.dist-info}/WHEEL +1 -1
- s2python/__init__.py +1 -1
- s2python/common/__init__.py +1 -1
- s2python/common/duration.py +5 -5
- s2python/common/handshake.py +5 -5
- s2python/common/handshake_response.py +5 -5
- s2python/common/instruction_status_update.py +6 -10
- s2python/common/number_range.py +17 -21
- s2python/common/power_forecast.py +7 -9
- s2python/common/power_forecast_element.py +9 -10
- s2python/common/power_forecast_value.py +4 -6
- s2python/common/power_measurement.py +7 -7
- s2python/common/power_range.py +11 -13
- s2python/common/power_value.py +4 -4
- s2python/common/reception_status.py +5 -7
- s2python/common/resource_manager_details.py +11 -12
- s2python/common/revoke_object.py +6 -6
- s2python/common/role.py +4 -4
- s2python/common/select_control_type.py +5 -5
- s2python/common/session_request.py +5 -5
- s2python/common/support.py +6 -4
- s2python/common/timer.py +6 -6
- s2python/common/transition.py +12 -14
- s2python/frbc/frbc_actuator_description.py +53 -74
- s2python/frbc/frbc_actuator_status.py +10 -12
- s2python/frbc/frbc_fill_level_target_profile.py +10 -14
- s2python/frbc/frbc_fill_level_target_profile_element.py +7 -9
- s2python/frbc/frbc_instruction.py +8 -8
- s2python/frbc/frbc_leakage_behaviour.py +8 -10
- s2python/frbc/frbc_leakage_behaviour_element.py +6 -8
- s2python/frbc/frbc_operation_mode.py +19 -29
- s2python/frbc/frbc_operation_mode_element.py +11 -13
- s2python/frbc/frbc_storage_description.py +6 -8
- s2python/frbc/frbc_storage_status.py +5 -5
- s2python/frbc/frbc_system_description.py +10 -13
- s2python/frbc/frbc_timer_status.py +7 -7
- s2python/frbc/frbc_usage_forecast.py +7 -9
- s2python/frbc/frbc_usage_forecast_element.py +5 -7
- s2python/frbc/rm.py +0 -0
- s2python/generated/gen_s2.py +1150 -1130
- s2python/reception_status_awaiter.py +60 -0
- s2python/s2_connection.py +470 -0
- s2python/s2_control_type.py +56 -0
- s2python/s2_parser.py +113 -0
- s2python/s2_validation_error.py +7 -5
- s2python/utils.py +7 -2
- s2python/validate_values_mixin.py +32 -89
- s2python/version.py +2 -0
- s2_python-0.0.1.dist-info/RECORD +0 -49
- {s2_python-0.0.1.dist-info → s2_python-0.2.0.dist-info}/entry_points.txt +0 -0
- {s2_python-0.0.1.dist-info → s2_python-0.2.0.dist-info}/top_level.txt +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: s2-python
|
3
|
-
Version: 0.0
|
3
|
+
Version: 0.2.0
|
4
4
|
Summary: S2 Protocol Python Wrapper
|
5
5
|
Home-page: https://github.com/flexiblepower/s2-ws-json-python
|
6
6
|
Author: Flexiblepower
|
@@ -12,10 +12,12 @@ Classifier: Programming Language :: Python :: 3.8
|
|
12
12
|
Classifier: Programming Language :: Python :: 3.9
|
13
13
|
Classifier: Programming Language :: Python :: 3.10
|
14
14
|
Classifier: Programming Language :: Python :: 3.11
|
15
|
+
Classifier: Programming Language :: Python :: 3.12
|
15
16
|
Description-Content-Type: text/x-rst; charset=UTF-8
|
16
|
-
Requires-Dist: pydantic
|
17
|
+
Requires-Dist: pydantic ~=2.8.2
|
17
18
|
Requires-Dist: pytz
|
18
19
|
Requires-Dist: click
|
20
|
+
Requires-Dist: websockets ~=13.0.1
|
19
21
|
Provides-Extra: development
|
20
22
|
Requires-Dist: pip-tools ; extra == 'development'
|
21
23
|
Requires-Dist: datamodel-code-generator ; extra == 'development'
|
@@ -33,13 +35,14 @@ Requires-Dist: pytest ; extra == 'testing'
|
|
33
35
|
Requires-Dist: pytest-coverage ; extra == 'testing'
|
34
36
|
Requires-Dist: pytest-timer ; extra == 'testing'
|
35
37
|
Requires-Dist: mypy ; extra == 'testing'
|
38
|
+
Requires-Dist: types-pytz ; extra == 'testing'
|
36
39
|
Requires-Dist: pylint ; extra == 'testing'
|
37
40
|
|
38
41
|
Python Wrapper for S2 Flexibility Protocol
|
39
42
|
===========================================
|
40
43
|
.. image:: https://img.shields.io/pypi/v/s2-python
|
41
44
|
:alt: PyPI - Version
|
42
|
-
.. image:: https://img.shields.io/pypi/pyversions/
|
45
|
+
.. image:: https://img.shields.io/pypi/pyversions/s2-python
|
43
46
|
:alt: PyPI - Python Version
|
44
47
|
.. image:: https://img.shields.io/pypi/l/s2-python
|
45
48
|
:alt: PyPI - License
|
@@ -49,14 +52,29 @@ is based on the asyncapi description of the protocol provided in the `s2-ws-json
|
|
49
52
|
|
50
53
|
Currently, the package supports the *common* and *FILL RATE BASED CONTROL* types and messages.
|
51
54
|
|
55
|
+
To Install
|
56
|
+
-----------
|
57
|
+
You can install this package using pip or any Python dependency manager that collects the packages from Pypi:
|
58
|
+
|
59
|
+
.. code-block:: bash
|
60
|
+
|
61
|
+
pip install s2-python
|
62
|
+
|
63
|
+
The packages on Pypi may be found `here <https://pypi.org/project/s2-python/>`_
|
52
64
|
|
53
65
|
Example
|
54
66
|
---------
|
55
67
|
|
56
68
|
.. code-block:: python
|
57
69
|
|
70
|
+
from s2python.common import PowerRange, CommodityQuantity
|
71
|
+
|
58
72
|
# create s2 messages as Python objects
|
59
|
-
number_range = PowerRange(
|
73
|
+
number_range = PowerRange(
|
74
|
+
start_of_range=4.0,
|
75
|
+
end_of_range=5.0,
|
76
|
+
commodity_quantity=CommodityQuantity.ELECTRIC_POWER_L1,
|
77
|
+
)
|
60
78
|
# serialize s2 messages
|
61
79
|
number_range.to_json()
|
62
80
|
# deserialize s2 messages
|
@@ -0,0 +1,54 @@
|
|
1
|
+
s2python/__init__.py,sha256=e5lwvqsPl-z7IfEd0hRQhLBRKBYcuw2eqrecXnMfLdg,384
|
2
|
+
s2python/reception_status_awaiter.py,sha256=jKMliFk1XxwsEGtx3vFESbJhUtClB7cTu-td90-qBN8,2137
|
3
|
+
s2python/s2_connection.py,sha256=mGnyEWdf1NlSWKxbBLJ4g_2OgmACNR6UJReJ48QFD8U,17892
|
4
|
+
s2python/s2_control_type.py,sha256=TPG4ZWEi8RbVg50V4BnNfkYb5EEvNsWuG8S5Qx2W-iQ,1721
|
5
|
+
s2python/s2_parser.py,sha256=1ZaCL3bWKHtmidr_VQqp3nzjr8VQjeltRN81stA0mfw,4160
|
6
|
+
s2python/s2_validation_error.py,sha256=BkOLoNsrcQ3MzdCYaPDgs1Wu6lPdlQDpZsTpykKGQmE,384
|
7
|
+
s2python/utils.py,sha256=QX9b-mi-H_YUGTmGmJsrAbaWWM3dgaoaRLRXHHlaZDE,212
|
8
|
+
s2python/validate_values_mixin.py,sha256=hfXW-ViHSwahIgD2r1tmdOtt9uOZEdMCf9Bw2mRJUM8,2541
|
9
|
+
s2python/version.py,sha256=IBzoytgbYYYekQnSTfSmWeYAZ4c_yUFU2oLIAG4UYjs,45
|
10
|
+
s2python/common/__init__.py,sha256=yEAXCS59XpNOEXbEXoN04SwultP-3evgVzFuEUSgB5I,1345
|
11
|
+
s2python/common/duration.py,sha256=Sw1l0-omcPCzlWJP-xkMioQjiBwjTICGoqtYi8BoVOM,649
|
12
|
+
s2python/common/handshake.py,sha256=43MGJWjbPT53DQUP2kclMY82wefcW2uJ3UyHezJPZZU,449
|
13
|
+
s2python/common/handshake_response.py,sha256=CFZ9tPbYWRqvl8HlvcOSRW1akAf8P63Vv_t0dbxAaKA,505
|
14
|
+
s2python/common/instruction_status_update.py,sha256=d-Z_0fZh_yIC-cupkaDG-x19uVxznQVHsyacZW5hwQ0,674
|
15
|
+
s2python/common/number_range.py,sha256=SaUhAJU9uLR0c5Du1-iPRDYyMI3JKmGLBvQHRPeNZws,1044
|
16
|
+
s2python/common/power_forecast.py,sha256=foJKA9Wmm-CzkK7qIfaW4963NqoY1-pZcvBXmUMPazw,686
|
17
|
+
s2python/common/power_forecast_element.py,sha256=HdetbhqTqXa_TWMkpL7P7r3yKdmiNMFmZNtrMT4fAlw,787
|
18
|
+
s2python/common/power_forecast_value.py,sha256=o-KegTZjUsrziNenoZZ9pjfYrkrLG_b5Cr8GcVcebD4,393
|
19
|
+
s2python/common/power_measurement.py,sha256=t6qDcisnI8xSEmfOZeI35MMgkBB5vFqnnc5KsqrPiqk,675
|
20
|
+
s2python/common/power_range.py,sha256=tvzb9cyVs1NLsiN6jo8jdHo9vRqCu4bnvkBvsoqKUbw,668
|
21
|
+
s2python/common/power_value.py,sha256=yVo0OotIk1_SccOLMfkDAYp4V5xCoPUgHDEJBGg8GCs,345
|
22
|
+
s2python/common/reception_status.py,sha256=hOgLDy7KN0aWPiKfN9u-AUUeXnrpW2UDVZRAcUkefZY,507
|
23
|
+
s2python/common/resource_manager_details.py,sha256=CCvnS21vywcaZAAQzPIzU42CkydnBbkAVjgoKbtDeSE,1026
|
24
|
+
s2python/common/revoke_object.py,sha256=6PoKLZjPSz43O_W58zSUFNYamRJD-X1YF1gi0WLtt9s,567
|
25
|
+
s2python/common/role.py,sha256=N8nYdMquBIwNx5RS8UrMGHDHdXy57P_iAcDpdDYm62A,309
|
26
|
+
s2python/common/select_control_type.py,sha256=xCd18THcBthEJjLz9otHscb4pgxsUYghlcxzlEXvhPs,505
|
27
|
+
s2python/common/session_request.py,sha256=kFAqUkl9_yVSLvCT3E0BUQKJC-JPhZk3rW01GiT3tQ4,484
|
28
|
+
s2python/common/support.py,sha256=Kbrf_KGB45Wfr8j2pqDe1lLde6CIr3nl_LYkWnilmV0,1015
|
29
|
+
s2python/common/timer.py,sha256=_zokHPmPHKHx-H9vBau18pcN1HrYBIhWSKkzFzd999w,538
|
30
|
+
s2python/common/transition.py,sha256=nUdJaiWgf6tAgfAMqJmdsKmob063NcZJZMt0ysjjkWE,1046
|
31
|
+
s2python/frbc/__init__.py,sha256=ROV3qZoldPkdgVFfMQr5Mf3GDfBzXaMfhNNCuXY6T0s,1104
|
32
|
+
s2python/frbc/frbc_actuator_description.py,sha256=Ig2jmf2_qsDBfuW90rAVD-e0hkmkIqKdTcQZI3XY3S8,6148
|
33
|
+
s2python/frbc/frbc_actuator_status.py,sha256=4XGk-ueXq6o_kOLTXGK_bfEFdJy8p8jjHDLyohzykSQ,955
|
34
|
+
s2python/frbc/frbc_fill_level_target_profile.py,sha256=od1w2nR35sckV4Bvp_EpfZaMJxKRrDu66X8mliSRuec,862
|
35
|
+
s2python/frbc/frbc_fill_level_target_profile_element.py,sha256=41lYU60Pb9ogBi5Ys2bG0fFnsQ6JuqJSobDkgjLcQNs,818
|
36
|
+
s2python/frbc/frbc_instruction.py,sha256=EyNnt2P9w0955eYoeWPqaHSco0NzbvYAGD0F9vYS0SM,791
|
37
|
+
s2python/frbc/frbc_leakage_behaviour.py,sha256=Esjmsy9jyi2naokTVu6y9oPBVjjlTyEguPF2snQMj7w,776
|
38
|
+
s2python/frbc/frbc_leakage_behaviour_element.py,sha256=5sh9MbcSXT1E9fQmRgCoLLgMD9VZqXCUomSl1NL3j9Y,639
|
39
|
+
s2python/frbc/frbc_operation_mode.py,sha256=B30t7ITSCAzBdNZv4hns7VacVsRN0DyydgTvoF9JYdY,1881
|
40
|
+
s2python/frbc/frbc_operation_mode_element.py,sha256=uin-wgbySldMBbjk14l_ZOH7lpsyXeo1jjCYolB1RNI,1055
|
41
|
+
s2python/frbc/frbc_storage_description.py,sha256=K1bjmG5_2SP14PMIkkldTyvTWQzDTC9KYFuiksW0AS8,604
|
42
|
+
s2python/frbc/frbc_storage_status.py,sha256=TKQeX1vsnYrblgS8UeDu0Siy7p0zedYck85vFVkdiT8,505
|
43
|
+
s2python/frbc/frbc_system_description.py,sha256=g94kqGRNcPXcQQzpb9Wz7dDncbuJsmA4KHa0r7b3r4w,962
|
44
|
+
s2python/frbc/frbc_timer_status.py,sha256=Lh95iJ62FQGeqSTH5oDJnxzWBCzaNZAjunQyGEPOlcM,693
|
45
|
+
s2python/frbc/frbc_usage_forecast.py,sha256=e5tvKpVAsKbjQxN-g8T3RDNivwibJVtkjqmlOHpd2ek,729
|
46
|
+
s2python/frbc/frbc_usage_forecast_element.py,sha256=Njox8S11L3b_b8F-eengIRCSMvHQwp6LgVCE3_u3DPo,583
|
47
|
+
s2python/frbc/rm.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
48
|
+
s2python/generated/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
49
|
+
s2python/generated/gen_s2.py,sha256=eg9J0pcWxCy0oXO8eq9AtoB-GONHZLNd8JANpMhKQCQ,63573
|
50
|
+
s2_python-0.2.0.dist-info/METADATA,sha256=BzbWwIg3QjPHe0ZtOEzrEZd6ANAvAJiWRjHpRsUXALw,3342
|
51
|
+
s2_python-0.2.0.dist-info/WHEEL,sha256=cVxcB9AmuTcXqmwrtPhNK88dr7IR_b6qagTj0UvIEbY,91
|
52
|
+
s2_python-0.2.0.dist-info/entry_points.txt,sha256=feX-xmgJZgSe5-jxMgFKPKCJz4Ys3eQcGrsXsirNZyM,61
|
53
|
+
s2_python-0.2.0.dist-info/top_level.txt,sha256=OLFq0oDhr77Mp-EYLEcWk5P3jvooOt4IHkTI5KYJMc8,9
|
54
|
+
s2_python-0.2.0.dist-info/RECORD,,
|
s2python/__init__.py
CHANGED
@@ -2,7 +2,7 @@ from importlib.metadata import PackageNotFoundError, version # pragma: no cover
|
|
2
2
|
|
3
3
|
try:
|
4
4
|
# Change here if project is renamed and does not equal the package name
|
5
|
-
dist_name = "s2-python"
|
5
|
+
dist_name = "s2-python" # pylint: disable=invalid-name
|
6
6
|
__version__ = version(dist_name)
|
7
7
|
except PackageNotFoundError: # pragma: no cover
|
8
8
|
__version__ = "unknown"
|
s2python/common/__init__.py
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
from s2python.generated.gen_s2 import (
|
2
2
|
RoleType,
|
3
|
+
Currency,
|
3
4
|
CommodityQuantity,
|
4
5
|
Commodity,
|
5
6
|
InstructionStatus,
|
@@ -7,7 +8,6 @@ from s2python.generated.gen_s2 import (
|
|
7
8
|
EnergyManagementRole,
|
8
9
|
SessionRequestType,
|
9
10
|
ControlType,
|
10
|
-
Currency,
|
11
11
|
RevokableObjects,
|
12
12
|
)
|
13
13
|
|
s2python/common/duration.py
CHANGED
@@ -4,19 +4,19 @@ import math
|
|
4
4
|
from s2python.generated.gen_s2 import Duration as GenDuration
|
5
5
|
from s2python.validate_values_mixin import (
|
6
6
|
catch_and_convert_exceptions,
|
7
|
-
|
7
|
+
S2Message,
|
8
8
|
)
|
9
9
|
|
10
10
|
|
11
11
|
@catch_and_convert_exceptions
|
12
|
-
class Duration(GenDuration,
|
12
|
+
class Duration(GenDuration, S2Message["Duration"]):
|
13
13
|
def to_timedelta(self) -> timedelta:
|
14
|
-
return timedelta(milliseconds=self.
|
14
|
+
return timedelta(milliseconds=self.root)
|
15
15
|
|
16
16
|
@staticmethod
|
17
17
|
def from_timedelta(duration: timedelta) -> "Duration":
|
18
|
-
return Duration(
|
18
|
+
return Duration(root=math.ceil(duration.total_seconds() * 1000))
|
19
19
|
|
20
20
|
@staticmethod
|
21
21
|
def from_milliseconds(milliseconds: int) -> "Duration":
|
22
|
-
return Duration(
|
22
|
+
return Duration(root=milliseconds)
|
s2python/common/handshake.py
CHANGED
@@ -3,13 +3,13 @@ import uuid
|
|
3
3
|
from s2python.generated.gen_s2 import Handshake as GenHandshake
|
4
4
|
from s2python.validate_values_mixin import (
|
5
5
|
catch_and_convert_exceptions,
|
6
|
-
|
6
|
+
S2Message,
|
7
7
|
)
|
8
8
|
|
9
9
|
|
10
10
|
@catch_and_convert_exceptions
|
11
|
-
class Handshake(GenHandshake,
|
12
|
-
|
13
|
-
|
11
|
+
class Handshake(GenHandshake, S2Message["Handshake"]):
|
12
|
+
model_config = GenHandshake.model_config
|
13
|
+
model_config["validate_assignment"] = True
|
14
14
|
|
15
|
-
message_id: uuid.UUID = GenHandshake.
|
15
|
+
message_id: uuid.UUID = GenHandshake.model_fields["message_id"] # type: ignore[assignment]
|
@@ -3,13 +3,13 @@ import uuid
|
|
3
3
|
from s2python.generated.gen_s2 import HandshakeResponse as GenHandshakeResponse
|
4
4
|
from s2python.validate_values_mixin import (
|
5
5
|
catch_and_convert_exceptions,
|
6
|
-
|
6
|
+
S2Message,
|
7
7
|
)
|
8
8
|
|
9
9
|
|
10
10
|
@catch_and_convert_exceptions
|
11
|
-
class HandshakeResponse(GenHandshakeResponse,
|
12
|
-
|
13
|
-
|
11
|
+
class HandshakeResponse(GenHandshakeResponse, S2Message["HandshakeResponse"]):
|
12
|
+
model_config = GenHandshakeResponse.model_config
|
13
|
+
model_config["validate_assignment"] = True
|
14
14
|
|
15
|
-
message_id: uuid.UUID = GenHandshakeResponse.
|
15
|
+
message_id: uuid.UUID = GenHandshakeResponse.model_fields["message_id"] # type: ignore[assignment]
|
@@ -5,18 +5,14 @@ from s2python.generated.gen_s2 import (
|
|
5
5
|
)
|
6
6
|
from s2python.validate_values_mixin import (
|
7
7
|
catch_and_convert_exceptions,
|
8
|
-
|
8
|
+
S2Message,
|
9
9
|
)
|
10
10
|
|
11
11
|
|
12
12
|
@catch_and_convert_exceptions
|
13
|
-
class InstructionStatusUpdate(
|
14
|
-
GenInstructionStatusUpdate
|
15
|
-
|
16
|
-
class Config(GenInstructionStatusUpdate.Config):
|
17
|
-
validate_assignment = True
|
13
|
+
class InstructionStatusUpdate(GenInstructionStatusUpdate, S2Message["InstructionStatusUpdate"]):
|
14
|
+
model_config = GenInstructionStatusUpdate.model_config
|
15
|
+
model_config["validate_assignment"] = True
|
18
16
|
|
19
|
-
message_id: uuid.UUID = GenInstructionStatusUpdate.
|
20
|
-
instruction_id: uuid.UUID = GenInstructionStatusUpdate.
|
21
|
-
"instruction_id"
|
22
|
-
].field_info # type: ignore[assignment]
|
17
|
+
message_id: uuid.UUID = GenInstructionStatusUpdate.model_fields["message_id"] # type: ignore[assignment]
|
18
|
+
instruction_id: uuid.UUID = GenInstructionStatusUpdate.model_fields["instruction_id"] # type: ignore[assignment]
|
s2python/common/number_range.py
CHANGED
@@ -1,36 +1,32 @@
|
|
1
|
-
from typing import Any
|
1
|
+
from typing import Any
|
2
|
+
from typing_extensions import Self
|
2
3
|
|
3
|
-
from pydantic import
|
4
|
+
from pydantic import model_validator
|
4
5
|
|
5
6
|
from s2python.validate_values_mixin import (
|
6
|
-
|
7
|
+
S2Message,
|
7
8
|
catch_and_convert_exceptions,
|
8
9
|
)
|
9
10
|
from s2python.generated.gen_s2 import NumberRange as GenNumberRange
|
10
11
|
|
11
12
|
|
12
13
|
@catch_and_convert_exceptions
|
13
|
-
class NumberRange(GenNumberRange,
|
14
|
-
|
15
|
-
|
14
|
+
class NumberRange(GenNumberRange, S2Message["NumberRange"]):
|
15
|
+
model_config = GenNumberRange.model_config
|
16
|
+
model_config["validate_assignment"] = True
|
16
17
|
|
17
|
-
@
|
18
|
-
def validate_start_end_order(
|
19
|
-
if
|
20
|
-
raise ValueError(
|
21
|
-
cls, "start_of_range should not be higher than end_of_range"
|
22
|
-
)
|
18
|
+
@model_validator(mode="after")
|
19
|
+
def validate_start_end_order(self) -> Self: # pylint: disable=duplicate-code
|
20
|
+
if self.start_of_range > self.end_of_range:
|
21
|
+
raise ValueError(self, "start_of_range should not be higher than end_of_range")
|
23
22
|
|
24
|
-
return
|
23
|
+
return self
|
25
24
|
|
26
|
-
def __hash__(self):
|
25
|
+
def __hash__(self) -> int:
|
27
26
|
return hash(f"{self.start_of_range}|{self.end_of_range}")
|
28
27
|
|
29
|
-
def __eq__(self, other):
|
28
|
+
def __eq__(self, other: Any) -> bool:
|
30
29
|
if isinstance(other, NumberRange):
|
31
|
-
return
|
32
|
-
|
33
|
-
|
34
|
-
)
|
35
|
-
else:
|
36
|
-
return False
|
30
|
+
return self.start_of_range == other.start_of_range and self.end_of_range == other.end_of_range
|
31
|
+
|
32
|
+
return False
|
@@ -1,20 +1,18 @@
|
|
1
1
|
from typing import List
|
2
2
|
import uuid
|
3
3
|
|
4
|
-
from s2python.common import PowerForecastElement
|
4
|
+
from s2python.common.power_forecast_element import PowerForecastElement
|
5
5
|
from s2python.generated.gen_s2 import PowerForecast as GenPowerForecast
|
6
6
|
from s2python.validate_values_mixin import (
|
7
7
|
catch_and_convert_exceptions,
|
8
|
-
|
8
|
+
S2Message,
|
9
9
|
)
|
10
10
|
|
11
11
|
|
12
12
|
@catch_and_convert_exceptions
|
13
|
-
class PowerForecast(GenPowerForecast,
|
14
|
-
|
15
|
-
|
13
|
+
class PowerForecast(GenPowerForecast, S2Message["PowerForecast"]):
|
14
|
+
model_config = GenPowerForecast.model_config
|
15
|
+
model_config["validate_assignment"] = True
|
16
16
|
|
17
|
-
message_id: uuid.UUID = GenPowerForecast.
|
18
|
-
elements: List[PowerForecastElement] = GenPowerForecast.
|
19
|
-
"elements"
|
20
|
-
].field_info # type: ignore[assignment]
|
17
|
+
message_id: uuid.UUID = GenPowerForecast.model_fields["message_id"] # type: ignore[assignment]
|
18
|
+
elements: List[PowerForecastElement] = GenPowerForecast.model_fields["elements"] # type: ignore[assignment]
|
@@ -3,19 +3,18 @@ from typing import List
|
|
3
3
|
from s2python.generated.gen_s2 import PowerForecastElement as GenPowerForecastElement
|
4
4
|
from s2python.validate_values_mixin import (
|
5
5
|
catch_and_convert_exceptions,
|
6
|
-
|
6
|
+
S2Message,
|
7
7
|
)
|
8
|
-
from s2python.common import Duration
|
8
|
+
from s2python.common.duration import Duration
|
9
|
+
from s2python.common.power_forecast_value import PowerForecastValue
|
9
10
|
|
10
11
|
|
11
12
|
@catch_and_convert_exceptions
|
12
|
-
class PowerForecastElement(
|
13
|
-
GenPowerForecastElement
|
14
|
-
|
15
|
-
class Config(GenPowerForecastElement.Config):
|
16
|
-
validate_assignment = True
|
13
|
+
class PowerForecastElement(GenPowerForecastElement, S2Message["PowerForecastElement"]):
|
14
|
+
model_config = GenPowerForecastElement.model_config
|
15
|
+
model_config["validate_assignment"] = True
|
17
16
|
|
18
|
-
duration: Duration = GenPowerForecastElement.
|
19
|
-
power_values: List[PowerForecastValue] = GenPowerForecastElement.
|
17
|
+
duration: Duration = GenPowerForecastElement.model_fields["duration"] # type: ignore[assignment]
|
18
|
+
power_values: List[PowerForecastValue] = GenPowerForecastElement.model_fields[
|
20
19
|
"power_values"
|
21
|
-
]
|
20
|
+
] # type: ignore[assignment]
|
@@ -1,13 +1,11 @@
|
|
1
1
|
from s2python.generated.gen_s2 import PowerForecastValue as GenPowerForecastValue
|
2
2
|
from s2python.validate_values_mixin import (
|
3
3
|
catch_and_convert_exceptions,
|
4
|
-
|
4
|
+
S2Message,
|
5
5
|
)
|
6
6
|
|
7
7
|
|
8
8
|
@catch_and_convert_exceptions
|
9
|
-
class PowerForecastValue(
|
10
|
-
GenPowerForecastValue
|
11
|
-
|
12
|
-
class Config(GenPowerForecastValue.Config):
|
13
|
-
validate_assignment = True
|
9
|
+
class PowerForecastValue(GenPowerForecastValue, S2Message["PowerForecastValue"]):
|
10
|
+
model_config = GenPowerForecastValue.model_config
|
11
|
+
model_config["validate_assignment"] = True
|
@@ -1,18 +1,18 @@
|
|
1
1
|
from typing import List
|
2
2
|
import uuid
|
3
3
|
|
4
|
-
from s2python.common import PowerValue
|
4
|
+
from s2python.common.power_value import PowerValue
|
5
5
|
from s2python.generated.gen_s2 import PowerMeasurement as GenPowerMeasurement
|
6
6
|
from s2python.validate_values_mixin import (
|
7
7
|
catch_and_convert_exceptions,
|
8
|
-
|
8
|
+
S2Message,
|
9
9
|
)
|
10
10
|
|
11
11
|
|
12
12
|
@catch_and_convert_exceptions
|
13
|
-
class PowerMeasurement(GenPowerMeasurement,
|
14
|
-
|
15
|
-
|
13
|
+
class PowerMeasurement(GenPowerMeasurement, S2Message["PowerMeasurement"]):
|
14
|
+
model_config = GenPowerMeasurement.model_config
|
15
|
+
model_config["validate_assignment"] = True
|
16
16
|
|
17
|
-
message_id: uuid.UUID = GenPowerMeasurement.
|
18
|
-
values: List[PowerValue] = GenPowerMeasurement.
|
17
|
+
message_id: uuid.UUID = GenPowerMeasurement.model_fields["message_id"] # type: ignore[assignment]
|
18
|
+
values: List[PowerValue] = GenPowerMeasurement.model_fields["values"] # type: ignore[assignment]
|
s2python/common/power_range.py
CHANGED
@@ -1,24 +1,22 @@
|
|
1
|
-
from
|
1
|
+
from typing_extensions import Self
|
2
2
|
|
3
|
-
from pydantic import
|
3
|
+
from pydantic import model_validator
|
4
4
|
|
5
5
|
from s2python.generated.gen_s2 import PowerRange as GenPowerRange
|
6
6
|
from s2python.validate_values_mixin import (
|
7
|
-
|
7
|
+
S2Message,
|
8
8
|
catch_and_convert_exceptions,
|
9
9
|
)
|
10
10
|
|
11
11
|
|
12
12
|
@catch_and_convert_exceptions
|
13
|
-
class PowerRange(GenPowerRange,
|
14
|
-
|
15
|
-
|
13
|
+
class PowerRange(GenPowerRange, S2Message["PowerRange"]):
|
14
|
+
model_config = GenPowerRange.model_config
|
15
|
+
model_config["validate_assignment"] = True
|
16
16
|
|
17
|
-
@
|
18
|
-
def validate_start_end_order(
|
19
|
-
if
|
20
|
-
raise ValueError(
|
21
|
-
cls, "start_of_range should not be higher than end_of_range"
|
22
|
-
)
|
17
|
+
@model_validator(mode="after")
|
18
|
+
def validate_start_end_order(self) -> Self:
|
19
|
+
if self.start_of_range > self.end_of_range:
|
20
|
+
raise ValueError(self, "start_of_range should not be higher than end_of_range")
|
23
21
|
|
24
|
-
return
|
22
|
+
return self
|
s2python/common/power_value.py
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
from s2python.generated.gen_s2 import PowerValue as GenPowerValue
|
2
2
|
from s2python.validate_values_mixin import (
|
3
3
|
catch_and_convert_exceptions,
|
4
|
-
|
4
|
+
S2Message,
|
5
5
|
)
|
6
6
|
|
7
7
|
|
8
8
|
@catch_and_convert_exceptions
|
9
|
-
class PowerValue(GenPowerValue,
|
10
|
-
|
11
|
-
|
9
|
+
class PowerValue(GenPowerValue, S2Message["PowerValue"]):
|
10
|
+
model_config = GenPowerValue.model_config
|
11
|
+
model_config["validate_assignment"] = True
|
@@ -3,15 +3,13 @@ import uuid
|
|
3
3
|
from s2python.generated.gen_s2 import ReceptionStatus as GenReceptionStatus
|
4
4
|
from s2python.validate_values_mixin import (
|
5
5
|
catch_and_convert_exceptions,
|
6
|
-
|
6
|
+
S2Message,
|
7
7
|
)
|
8
8
|
|
9
9
|
|
10
10
|
@catch_and_convert_exceptions
|
11
|
-
class ReceptionStatus(GenReceptionStatus,
|
12
|
-
|
13
|
-
|
11
|
+
class ReceptionStatus(GenReceptionStatus, S2Message["ReceptionStatus"]):
|
12
|
+
model_config = GenReceptionStatus.model_config
|
13
|
+
model_config["validate_assignment"] = True
|
14
14
|
|
15
|
-
subject_message_id: uuid.UUID = GenReceptionStatus.
|
16
|
-
"subject_message_id"
|
17
|
-
].field_info # type: ignore[assignment]
|
15
|
+
subject_message_id: uuid.UUID = GenReceptionStatus.model_fields["subject_message_id"] # type: ignore[assignment]
|
@@ -1,26 +1,25 @@
|
|
1
1
|
from typing import List
|
2
2
|
import uuid
|
3
3
|
|
4
|
-
from s2python.common import Duration
|
4
|
+
from s2python.common.duration import Duration
|
5
|
+
from s2python.common.role import Role
|
5
6
|
from s2python.generated.gen_s2 import (
|
6
7
|
ResourceManagerDetails as GenResourceManagerDetails,
|
7
8
|
)
|
8
9
|
from s2python.validate_values_mixin import (
|
9
10
|
catch_and_convert_exceptions,
|
10
|
-
|
11
|
+
S2Message,
|
11
12
|
)
|
12
13
|
|
13
14
|
|
14
15
|
@catch_and_convert_exceptions
|
15
|
-
class ResourceManagerDetails(
|
16
|
-
GenResourceManagerDetails
|
17
|
-
|
18
|
-
class Config(GenResourceManagerDetails.Config):
|
19
|
-
validate_assignment = True
|
16
|
+
class ResourceManagerDetails(GenResourceManagerDetails, S2Message["ResourceManagerDetails"]):
|
17
|
+
model_config = GenResourceManagerDetails.model_config
|
18
|
+
model_config["validate_assignment"] = True
|
20
19
|
|
21
|
-
instruction_processing_delay: Duration = GenResourceManagerDetails.
|
20
|
+
instruction_processing_delay: Duration = GenResourceManagerDetails.model_fields[
|
22
21
|
"instruction_processing_delay"
|
23
|
-
]
|
24
|
-
message_id: uuid.UUID = GenResourceManagerDetails.
|
25
|
-
resource_id: uuid.UUID = GenResourceManagerDetails.
|
26
|
-
roles: List[Role] = GenResourceManagerDetails.
|
22
|
+
] # type: ignore[assignment]
|
23
|
+
message_id: uuid.UUID = GenResourceManagerDetails.model_fields["message_id"] # type: ignore[assignment]
|
24
|
+
resource_id: uuid.UUID = GenResourceManagerDetails.model_fields["resource_id"] # type: ignore[assignment]
|
25
|
+
roles: List[Role] = GenResourceManagerDetails.model_fields["roles"] # type: ignore[assignment]
|
s2python/common/revoke_object.py
CHANGED
@@ -3,14 +3,14 @@ import uuid
|
|
3
3
|
from s2python.generated.gen_s2 import RevokeObject as GenRevokeObject
|
4
4
|
from s2python.validate_values_mixin import (
|
5
5
|
catch_and_convert_exceptions,
|
6
|
-
|
6
|
+
S2Message,
|
7
7
|
)
|
8
8
|
|
9
9
|
|
10
10
|
@catch_and_convert_exceptions
|
11
|
-
class RevokeObject(GenRevokeObject,
|
12
|
-
|
13
|
-
|
11
|
+
class RevokeObject(GenRevokeObject, S2Message["RevokeObject"]):
|
12
|
+
model_config = GenRevokeObject.model_config
|
13
|
+
model_config["validate_assignment"] = True
|
14
14
|
|
15
|
-
message_id: uuid.UUID = GenRevokeObject.
|
16
|
-
object_id: uuid.UUID = GenRevokeObject.
|
15
|
+
message_id: uuid.UUID = GenRevokeObject.model_fields["message_id"] # type: ignore[assignment]
|
16
|
+
object_id: uuid.UUID = GenRevokeObject.model_fields["object_id"] # type: ignore[assignment]
|
s2python/common/role.py
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
from s2python.generated.gen_s2 import Role as GenRole
|
2
2
|
from s2python.validate_values_mixin import (
|
3
|
-
|
3
|
+
S2Message,
|
4
4
|
catch_and_convert_exceptions,
|
5
5
|
)
|
6
6
|
|
7
7
|
|
8
8
|
@catch_and_convert_exceptions
|
9
|
-
class Role(GenRole,
|
10
|
-
|
11
|
-
|
9
|
+
class Role(GenRole, S2Message["Role"]):
|
10
|
+
model_config = GenRole.model_config
|
11
|
+
model_config["validate_assignment"] = True
|
@@ -3,13 +3,13 @@ import uuid
|
|
3
3
|
from s2python.generated.gen_s2 import SelectControlType as GenSelectControlType
|
4
4
|
from s2python.validate_values_mixin import (
|
5
5
|
catch_and_convert_exceptions,
|
6
|
-
|
6
|
+
S2Message,
|
7
7
|
)
|
8
8
|
|
9
9
|
|
10
10
|
@catch_and_convert_exceptions
|
11
|
-
class SelectControlType(GenSelectControlType,
|
12
|
-
|
13
|
-
|
11
|
+
class SelectControlType(GenSelectControlType, S2Message["SelectControlType"]):
|
12
|
+
model_config = GenSelectControlType.model_config
|
13
|
+
model_config["validate_assignment"] = True
|
14
14
|
|
15
|
-
message_id: uuid.UUID = GenSelectControlType.
|
15
|
+
message_id: uuid.UUID = GenSelectControlType.model_fields["message_id"] # type: ignore[assignment]
|
@@ -3,13 +3,13 @@ import uuid
|
|
3
3
|
from s2python.generated.gen_s2 import SessionRequest as GenSessionRequest
|
4
4
|
from s2python.validate_values_mixin import (
|
5
5
|
catch_and_convert_exceptions,
|
6
|
-
|
6
|
+
S2Message,
|
7
7
|
)
|
8
8
|
|
9
9
|
|
10
10
|
@catch_and_convert_exceptions
|
11
|
-
class SessionRequest(GenSessionRequest,
|
12
|
-
|
13
|
-
|
11
|
+
class SessionRequest(GenSessionRequest, S2Message["SessionRequest"]):
|
12
|
+
model_config = GenSessionRequest.model_config
|
13
|
+
model_config["validate_assignment"] = True
|
14
14
|
|
15
|
-
message_id: uuid.UUID = GenSessionRequest.
|
15
|
+
message_id: uuid.UUID = GenSessionRequest.model_fields["message_id"] # type: ignore[assignment]
|
s2python/common/support.py
CHANGED
@@ -3,23 +3,25 @@ from s2python.common import CommodityQuantity, Commodity
|
|
3
3
|
|
4
4
|
def commodity_has_quantity(commodity: "Commodity", quantity: CommodityQuantity) -> bool:
|
5
5
|
if commodity == Commodity.HEAT:
|
6
|
-
|
6
|
+
result = quantity in [
|
7
7
|
CommodityQuantity.HEAT_THERMAL_POWER,
|
8
8
|
CommodityQuantity.HEAT_TEMPERATURE,
|
9
9
|
CommodityQuantity.HEAT_FLOW_RATE,
|
10
10
|
]
|
11
11
|
elif commodity == Commodity.ELECTRICITY:
|
12
|
-
|
12
|
+
result = quantity in [
|
13
13
|
CommodityQuantity.ELECTRIC_POWER_3_PHASE_SYMMETRIC,
|
14
14
|
CommodityQuantity.ELECTRIC_POWER_L1,
|
15
15
|
CommodityQuantity.ELECTRIC_POWER_L2,
|
16
16
|
CommodityQuantity.ELECTRIC_POWER_L3,
|
17
17
|
]
|
18
18
|
elif commodity == Commodity.GAS:
|
19
|
-
|
19
|
+
result = quantity in [CommodityQuantity.NATURAL_GAS_FLOW_RATE]
|
20
20
|
elif commodity == Commodity.OIL:
|
21
|
-
|
21
|
+
result = quantity in [CommodityQuantity.OIL_FLOW_RATE]
|
22
22
|
else:
|
23
23
|
raise RuntimeError(
|
24
24
|
f"Unsupported commodity {commodity}. Missing implementation."
|
25
25
|
)
|
26
|
+
|
27
|
+
return result
|