Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PEBC skeleton class implementation #60

Open
wants to merge 31 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
48b1155
Publish branch.
VladIftime Dec 25, 2024
dacd4f6
PEBC power envelope limit type
VladIftime Dec 25, 2024
efc364e
Implement PEBCAllowedLimitRange, PEBCPowerEnvelopeElement and PEBCPow…
VladIftime Dec 26, 2024
bb3f15d
Implement PEBCEnergyConstraint and PEBCPowerConstraints classes; add …
VladIftime Dec 26, 2024
d733118
Add PEBCInstruction class and __init__.py file; refactor imports in e…
VladIftime Dec 26, 2024
8d63c42
Add PEBCInstruction class and __init__.py file; refactor imports in e…
VladIftime Dec 26, 2024
743bc49
null
VladIftime Jan 1, 2025
8582a46
OpenAI API Response: {
VladIftime Jan 1, 2025
673b9e2
Payload: {
VladIftime Jan 1, 2025
d790f61
Payload: {
VladIftime Jan 1, 2025
337ffc0
Payload: {
VladIftime Jan 1, 2025
9ab2d41
Payload: {
VladIftime Jan 1, 2025
d60b0e4
Payload: {
VladIftime Jan 2, 2025
b5ac5d6
"Updated pebc_instruction.py and removed a line from pebc_power_const…
VladIftime Jan 2, 2025
992c44e
"Updated pebc_instruction.py and added new feature to pebc_power_cons…
VladIftime Jan 2, 2025
69af086
Removed unnecessary code from pebc_instruction.py and pebc_power_cons…
VladIftime Jan 2, 2025
9cd6efe
"Added new lines in pebc_instruction and pebc_power_constraints modules"
VladIftime Jan 2, 2025
6e8e3c2
Removed unnecessary lines in pebc_instruction.py and pebc_power_const…
VladIftime Jan 2, 2025
097b382
Added new relevant instructions and power constraints in the PEBC mod…
VladIftime Jan 3, 2025
c8db0cf
Added missing elements in pebc_instruction and pebc_power_constraints…
VladIftime Jan 3, 2025
76314a3
Added new methods to pebc_instruction.py and pebc_power_constraints.p…
VladIftime Jan 3, 2025
4f619a7
Refactored class definitions in PEBC modules for improved readability
VladIftime Jan 4, 2025
1e64126
Refactored class definitions in PEBC modules for improved readability
VladIftime Jan 4, 2025
bdf93eb
Added the controll type to s2_control_type wrapper
VladIftime Jan 13, 2025
ba68d80
Added the controll type to s2_control_type wrapper
VladIftime Jan 13, 2025
9f4bdb0
Added missing classes to init
VladIftime Jan 21, 2025
5322535
Removed build files and added the PEBC_instruction in the submodule init
VladIftime Jan 24, 2025
cd83b32
Merge branch 'Dev-VladIftime-Kiflin-PEBC' of github.com:flexiblepower…
VladIftime Jan 24, 2025
7d7e637
Removed build files and added the PEBC_instruction in the submodule init
VladIftime Jan 24, 2025
6931510
Merge branch 'main' into Dev-VladIftime-Kiflin-PEBC
VladIftime Jan 24, 2025
69ef8ba
Fixed the new type of S2Message as union
VladIftime Jan 24, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/s2python/pebc/__init__.py
Original file line number Diff line number Diff line change
@@ -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
26 changes: 26 additions & 0 deletions src/s2python/pebc/pebc_allowed_limit_range.py
Original file line number Diff line number Diff line change
@@ -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]
]
25 changes: 25 additions & 0 deletions src/s2python/pebc/pebc_energy_constraint.py
Original file line number Diff line number Diff line change
@@ -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]
]
27 changes: 27 additions & 0 deletions src/s2python/pebc/pebc_instruction.py
Original file line number Diff line number Diff line change
@@ -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]
27 changes: 27 additions & 0 deletions src/s2python/pebc/pebc_power_constraints.py
Original file line number Diff line number Diff line change
@@ -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]
23 changes: 23 additions & 0 deletions src/s2python/pebc/pebc_power_envelope.py
Original file line number Diff line number Diff line change
@@ -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]
16 changes: 16 additions & 0 deletions src/s2python/pebc/pebc_power_envelope_element.py
Original file line number Diff line number Diff line change
@@ -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]
14 changes: 14 additions & 0 deletions src/s2python/s2_control_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,20 @@ def deactivate(self, conn: "S2Connection") -> None:
"""Overwrite with the actual deactivation logic of your Resource Manager for this particular control type."""


class PEBCControlType(S2ControlType):
def get_protocol_control_type(self) -> ProtocolControlType:
return ProtocolControlType.POWER_ENVELOPE_BASED_CONTROL

def register_handlers(self, handlers: "MessageHandlers") -> None:
pass

@abc.abstractmethod
def activate(self, conn: "S2Connection") -> None: ...

@abc.abstractmethod
def deactivate(self, conn: "S2Connection") -> None: ...


class NoControlControlType(S2ControlType):
def get_protocol_control_type(self) -> ProtocolControlType:
return ProtocolControlType.NOT_CONTROLABLE
Expand Down
Loading