diff --git a/src/s2python/pebc/__init__.py b/src/s2python/pebc/__init__.py new file mode 100644 index 0000000..489c85c --- /dev/null +++ b/src/s2python/pebc/__init__.py @@ -0,0 +1,10 @@ +from s2python.pebc.pebc_allowed_limit_range import PEBCAllowedLimitRange +from s2python.pebc.pebc_power_constraints import PEBCPowerConstraints +from s2python.pebc.pebc_power_envelope import PEBCPowerEnvelope +from s2python.pebc.pebc_power_envelope_element import PEBCPowerEnvelopeElement +from s2python.pebc.pebc_energy_constraint import PEBCEnergyConstraint +from s2python.generated.gen_s2 import ( + PEBCPowerEnvelopeConsequenceType, + PEBCPowerEnvelopeLimitType, +) +from s2python.pebc.pebc_instruction import PEBCInstruction diff --git a/src/s2python/pebc/pebc_allowed_limit_range.py b/src/s2python/pebc/pebc_allowed_limit_range.py new file mode 100644 index 0000000..244cbec --- /dev/null +++ b/src/s2python/pebc/pebc_allowed_limit_range.py @@ -0,0 +1,26 @@ +from s2python.generated.gen_s2 import ( + PEBCAllowedLimitRange as GenPEBCAllowedLimitRange, + PEBCPowerEnvelopeLimitType as GenPEBCPowerEnvelopeLimitType, +) +from s2python.common import CommodityQuantity, NumberRange +from s2python.validate_values_mixin import ( + catch_and_convert_exceptions, + S2MessageComponent, +) + + +@catch_and_convert_exceptions +class PEBCAllowedLimitRange(GenPEBCAllowedLimitRange, S2MessageComponent["PEBCAllowedLimitRange"]): + model_config = GenPEBCAllowedLimitRange.model_config + model_config["validate_assignment"] = True + + commodity_quantity: CommodityQuantity = GenPEBCAllowedLimitRange.model_fields[ + "commodity_quantity" + ] # type: ignore[assignment] + limit_type: GenPEBCPowerEnvelopeLimitType = GenPEBCAllowedLimitRange.model_fields[ + "limit_type" + ] # type: ignore[assignment] + range_boundary: NumberRange = GenPEBCAllowedLimitRange.model_fields["range_boundary"] # type: ignore[assignment] + abnormal_condition_only: bool = [ + GenPEBCAllowedLimitRange.model_fields["abnormal_condition_only"] # type: ignore[assignment] + ] diff --git a/src/s2python/pebc/pebc_energy_constraint.py b/src/s2python/pebc/pebc_energy_constraint.py new file mode 100644 index 0000000..db09213 --- /dev/null +++ b/src/s2python/pebc/pebc_energy_constraint.py @@ -0,0 +1,25 @@ +import uuid + +from s2python.generated.gen_s2 import ( + PEBCEnergyConstraint as GenPEBCEnergyConstraint, +) +from s2python.common import CommodityQuantity +from s2python.validate_values_mixin import ( + catch_and_convert_exceptions, + S2MessageComponent, +) + + +@catch_and_convert_exceptions +class PEBCEnergyConstraint(GenPEBCEnergyConstraint, S2MessageComponent["PEBCEnergyConstraint"]): + model_config = GenPEBCEnergyConstraint.model_config + model_config["validate_assignment"] = True + + message_id: uuid.UUID = GenPEBCEnergyConstraint.model_fields["message_id"] # type: ignore[assignment] + id: uuid.UUID = GenPEBCEnergyConstraint.model_fields["id"] # type: ignore[assignment] + + upper_average_power: float = GenPEBCEnergyConstraint.model_fields["upper_average_power"] # type: ignore[assignment] + lower_average_power: float = GenPEBCEnergyConstraint.model_fields["lower_average_power"] # type: ignore[assignment] + commodity_quantity: CommodityQuantity = [ + GenPEBCEnergyConstraint.model_fields["commodity_quantity"] # type: ignore[assignment] + ] diff --git a/src/s2python/pebc/pebc_instruction.py b/src/s2python/pebc/pebc_instruction.py new file mode 100644 index 0000000..6f8192b --- /dev/null +++ b/src/s2python/pebc/pebc_instruction.py @@ -0,0 +1,27 @@ +import uuid +from typing import List + +from s2python.generated.gen_s2 import ( + PEBCInstruction as GenPEBCInstruction, +) +from s2python.pebc.pebc_power_envelope import PEBCPowerEnvelope +from s2python.validate_values_mixin import ( + catch_and_convert_exceptions, + S2MessageComponent, +) + + +@catch_and_convert_exceptions +class PEBCInstruction(GenPEBCInstruction, S2MessageComponent["PEBCInstruction"]): + model_config = GenPEBCInstruction.model_config + model_config["validate_assignment"] = True + + message_id: uuid.UUID = GenPEBCInstruction.model_fields["message_id"] # type: ignore[assignment] + id: uuid.UUID = GenPEBCInstruction.model_fields["id"] # type: ignore[assignment] + power_constraints_id: uuid.UUID = [ + GenPEBCInstruction.model_fields["power_constraints_id"] # type: ignore[assignment] + ] + power_envelopes: List[PEBCPowerEnvelope] = [ + GenPEBCInstruction.model_fields["power_envelopes"] # type: ignore[assignment] + ] + abnormal_conditions: bool = GenPEBCInstruction.model_fields["abnormal_conditions"] # type: ignore[assignment] diff --git a/src/s2python/pebc/pebc_power_constraints.py b/src/s2python/pebc/pebc_power_constraints.py new file mode 100644 index 0000000..16264ff --- /dev/null +++ b/src/s2python/pebc/pebc_power_constraints.py @@ -0,0 +1,27 @@ +import uuid +from typing import List + +from s2python.generated.gen_s2 import ( + PEBCPowerConstraints as GenPEBCPowerConstraints, + PEBCPowerEnvelopeConsequenceType as GenPEBCPowerEnvelopeConsequenceType, +) +from s2python.pebc.pebc_allowed_limit_range import PEBCAllowedLimitRange +from s2python.validate_values_mixin import ( + catch_and_convert_exceptions, + S2MessageComponent, +) + + +@catch_and_convert_exceptions +class PEBCPowerConstraints(GenPEBCPowerConstraints, S2MessageComponent["PEBCPowerConstraints"]): + model_config = GenPEBCPowerConstraints.model_config + model_config["validate_assignment"] = True + + message_id: uuid.UUID = GenPEBCPowerConstraints.model_fields["message_id"] # type: ignore[assignment] + id: uuid.UUID = GenPEBCPowerConstraints.model_fields["id"] # type: ignore[assignment] + consequence_type: GenPEBCPowerEnvelopeConsequenceType = GenPEBCPowerConstraints.model_fields[ + "consequence_type" + ] # type: ignore[assignment] + allowed_limit_ranges: List[PEBCAllowedLimitRange] = GenPEBCPowerConstraints.model_fields[ + "allowed_limit_ranges" + ] # type: ignore[assignment] diff --git a/src/s2python/pebc/pebc_power_envelope.py b/src/s2python/pebc/pebc_power_envelope.py new file mode 100644 index 0000000..4033e8b --- /dev/null +++ b/src/s2python/pebc/pebc_power_envelope.py @@ -0,0 +1,23 @@ +from typing import List +from s2python.generated.gen_s2 import ( + PEBCPowerEnvelope as GenPEBCPowerEnvelope, +) +from s2python.pebc.pebc_power_envelope_element import PEBCPowerEnvelopeElement +from s2python.common import CommodityQuantity +from s2python.validate_values_mixin import ( + catch_and_convert_exceptions, + S2MessageComponent, +) + + +@catch_and_convert_exceptions +class PEBCPowerEnvelope(GenPEBCPowerEnvelope, S2MessageComponent["PEBCPowerEnvelope"]): + model_config = GenPEBCPowerEnvelope.model_config + model_config["validate_assignment"] = True + + commodity_quantity: CommodityQuantity = GenPEBCPowerEnvelope.model_fields[ + "commodity_quantity" + ] # type: ignore[assignment] + power_envelope_elements: List[PEBCPowerEnvelopeElement] = GenPEBCPowerEnvelope.model_fields[ + "power_envelope_elements" + ] # type: ignore[assignment] diff --git a/src/s2python/pebc/pebc_power_envelope_element.py b/src/s2python/pebc/pebc_power_envelope_element.py new file mode 100644 index 0000000..8e75440 --- /dev/null +++ b/src/s2python/pebc/pebc_power_envelope_element.py @@ -0,0 +1,16 @@ +from s2python.generated.gen_s2 import ( + PEBCPowerEnvelopeElement as GenPEBCPowerEnvelopeElement, +) +from s2python.validate_values_mixin import ( + catch_and_convert_exceptions, + S2MessageComponent, +) + + +@catch_and_convert_exceptions +class PEBCPowerEnvelopeElement(GenPEBCPowerEnvelopeElement, S2MessageComponent["PEBCPowerEnvelopeElement"]): + model_config = GenPEBCPowerEnvelopeElement.model_config + model_config["validate_assignment"] = True + + lower_limit: float = GenPEBCPowerEnvelopeElement.model_fields["lower_limit"] # type: ignore[assignment] + upper_limit: float = GenPEBCPowerEnvelopeElement.model_fields["upper_limit"] # type: ignore[assignment] diff --git a/src/s2python/s2_control_type.py b/src/s2python/s2_control_type.py index 02b9967..8463d04 100644 --- a/src/s2python/s2_control_type.py +++ b/src/s2python/s2_control_type.py @@ -66,9 +66,10 @@ def deactivate(self, conn: "S2Connection") -> None: """Overwrite with the actual deactivation logic of your Resource Manager for this particular control type.""" -class DDBControlType(S2ControlType): + +class PEBCControlType(S2ControlType): def get_protocol_control_type(self) -> ProtocolControlType: - return ProtocolControlType.DEMAND_DRIVEN_BASED_CONTROL + return ProtocolControlType.POWER_ENVELOPE_BASED_CONTROL def register_handlers(self, handlers: "MessageHandlers") -> None: pass