Skip to content

Commit

Permalink
Add support for CHGOVRD
Browse files Browse the repository at this point in the history
  • Loading branch information
gavanderhoorn committed Jan 29, 2023
1 parent 892dfa3 commit f3704a9
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ Whenever a row has no value in the `Sys. SW version` column, that information ha

| Name | Supported? | Sys. SW version |
|:------------------|:----------:|----------------:|
| CHGOVRD | N | 9.40+ |
| CHGOVRD | Y | 9.40+ |
| CKTRKPRG | N | 9.40+ |
| CLLB_CODE_REQ | N | 9.40+ |
| CLLB_PAYLOAD_CONF | N | 9.40+ |
Expand Down
2 changes: 2 additions & 0 deletions src/comet_rpc/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
# author: G.A. vd. Hoorn

from .comet import (
change_override,
dpewrite_str,
dpread,
exec_kcl,
Expand Down Expand Up @@ -68,6 +69,7 @@
"AuthenticationException",
"BadElementInStructureException",
"BadVariableOrRegisterIndexException",
"change_override",
"CometRpcException",
"DeserialisationException",
"DictElementNotFoundException",
Expand Down
29 changes: 29 additions & 0 deletions src/comet_rpc/comet.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
from .fr_errors import ErrorDictionary
from .kliotyps import IoType
from .messages import (
ChangeOverrideResponse,
DpeWriteStrResponse,
DpReadResponse,
ExecKclCommandResponse,
Expand Down Expand Up @@ -221,6 +222,34 @@ def _call(
return response


def change_override(server: str, value: int) -> ChangeOverrideResponse:
"""Set the general override to `value`.
(Apparent) legal values and ranges:
- `-1`: VFINE
- `0`: FINE
- `[1, 100]`
NOTE: this RPC does not seem to work unless the TP has been active at least once.
In Roboguide for instance the general override cannot be changed unless the TP has
appeared on screen / logged in at least once.
NOTE 2: COMET does not appear to report any failures whatsoever. Values which fall
outside the accepted range will NOT result in an RPC status != 0.
:param server: Hostname or IP address of COMET RPC server
:param value: The value to set the general override to
:returns: The parsed response document
:raises UnexpectedRpcStatusException: on any other non-zero RPC status code
"""
response = _call(server, function=RpcId.CHGOVRD, ovrd_val=int(value))
ret = response.RPC[0]
if ret.status != 0:
raise UnexpectedRpcStatusException(ret.status)
return ret


def dpread(server: str, dict_name: str, ele_no: int) -> DpReadResponse:
"""Return the text associated with element `ele_no` from dictionary `dict_name`.
Expand Down
6 changes: 6 additions & 0 deletions src/comet_rpc/messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class RpcId(str, Enum):
# are checked before validators are run (so the conversion to int in
# BaseRpcResponse only happens after the discriminator field has been
# checked)
CHGOVRD = "220"
CPKCL = "87"
DPEWRITE_STR = "83"
DPREAD = "148"
Expand Down Expand Up @@ -214,9 +215,14 @@ class IoGetHdbResponse(BaseRpcResponse):
data: t.List[IoGetHdbResponseElement]


class ChangeOverrideResponse(BaseRpcResponse):
rpc: t.Literal[RpcId.CHGOVRD]


# from https://github.com/pydantic/pydantic/discussions/3754#discussioncomment-2076473
AnnotatedResponseType = te.Annotated[
t.Union[
ChangeOverrideResponse,
ExecKclCommandResponse,
DpeWriteStrResponse,
DpReadResponse,
Expand Down

0 comments on commit f3704a9

Please sign in to comment.