-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- ReportEvent updated to version 002 (if Report.Version is 002) - Add enum pico.cycler.statey
- Loading branch information
1 parent
d60d989
commit f57e871
Showing
10 changed files
with
147 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
from enum import auto | ||
from typing import List | ||
|
||
from gw.enums import GwStrEnum | ||
|
||
|
||
class PicoCyclerState(GwStrEnum): | ||
""" | ||
Values: | ||
- PicosLive | ||
- RelayOpening | ||
- RelayOpen | ||
- RelayClosing | ||
- PicosRebooting | ||
For more information: | ||
- [ASLs](https://gridworks-type-registry.readthedocs.io/en/latest/) | ||
- [Global Authority](https://gridworks-type-registry.readthedocs.io/en/latest/enums.html#picocyclerstate) | ||
""" | ||
|
||
PicosLive = auto() | ||
RelayOpening = auto() | ||
RelayOpen = auto() | ||
RelayClosing = auto() | ||
PicosRebooting = auto() | ||
|
||
@classmethod | ||
def default(cls) -> "PicoCyclerState": | ||
return cls.PicosLive | ||
|
||
@classmethod | ||
def values(cls) -> List[str]: | ||
return [elt.value for elt in cls] | ||
|
||
@classmethod | ||
def enum_name(cls) -> str: | ||
return "pico.cycler.state" | ||
|
||
@classmethod | ||
def enum_version(cls) -> str: | ||
return "000" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
"""Type machine.states, version 000""" | ||
|
||
from typing import List, Literal | ||
|
||
from pydantic import BaseModel, model_validator | ||
from typing_extensions import Self | ||
|
||
from gwproto.property_format import ( | ||
HandleName, | ||
LeftRightDotStr, | ||
UTCMilliseconds, | ||
) | ||
|
||
|
||
class MachineStates(BaseModel): | ||
""" """ | ||
|
||
MachineHandle: HandleName | ||
StateEnum: LeftRightDotStr | ||
StateList: List[str] | ||
UnixMsList: List[UTCMilliseconds] | ||
TypeName: Literal["machine.states"] = "machine.states" | ||
Version: Literal["000"] = "000" | ||
|
||
@model_validator(mode="after") | ||
def check_axiom_1(self) -> Self: | ||
""" | ||
Axiom 1: List Length Consistency. | ||
StateList and UnixMsList must have the same length | ||
""" | ||
# Implement check for axiom 1" | ||
return self | ||
|
||
@model_validator(mode="after") | ||
def check_axiom_2(self) -> Self: | ||
""" | ||
Axiom 2: If StateEnum is a recognized GridWorks enum, then the StateList elements are all values of that enum.. | ||
""" | ||
# Implement check for axiom 2" | ||
return self |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
""" | ||
Tests for enum pico.cycler.state.000 from the GridWorks Type Registry. | ||
""" | ||
|
||
from gwproto.enums import PicoCyclerState | ||
|
||
|
||
def test_pico_cycler_state() -> None: | ||
assert set(PicoCyclerState.values()) == { | ||
"PicosLive", | ||
"RelayOpening", | ||
"RelayOpen", | ||
"RelayClosing", | ||
"PicosRebooting", | ||
} | ||
|
||
assert PicoCyclerState.default() == PicoCyclerState.PicosLive | ||
assert PicoCyclerState.enum_name() == "pico.cycler.state" | ||
assert PicoCyclerState.enum_version() == "000" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
"""Tests machine.states type, version 000""" | ||
|
||
from gwproto.named_types import MachineStates | ||
|
||
|
||
def test_machine_states_generated() -> None: | ||
d = { | ||
"MachineHandle": "h.pico-cycler", | ||
"StateEnum": "pico.cycler.state", | ||
"StateList": ["PicosLive"], | ||
"UnixMsList": [1731168353695], | ||
"TypeName": "machine.states", | ||
"Version": "000", | ||
} | ||
|
||
d2 = MachineStates.model_validate(d).model_dump(exclude_none=True) | ||
|
||
assert d2 == d |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters