1
1
import asyncio
2
2
import enum
3
- import logging
4
3
from collections .abc import Callable , Coroutine
5
4
from dataclasses import dataclass
6
5
from typing import Any
7
6
8
- from fastcs .attributes import AttrR , AttrRW , AttrW , Handler , Sender , Updater
7
+ from fastcs .attributes import (
8
+ AttrHandlerR ,
9
+ AttrHandlerRW ,
10
+ AttrHandlerW ,
11
+ AttrRW ,
12
+ )
9
13
from fastcs .datatypes import Bool , DataType , Enum , Float , Int , String , T
10
14
11
15
from fastcs_pandablocks .types import PandaName
@@ -47,7 +51,7 @@ def attribute_value_to_panda_value(fastcs_datatype: DataType[T], value: T) -> st
47
51
raise NotImplementedError (f"Unknown datatype { fastcs_datatype } " )
48
52
49
53
50
- class DefaultFieldSender (Sender ):
54
+ class DefaultFieldSender (AttrHandlerW ):
51
55
"""Default sender for sending introspected attributes."""
52
56
53
57
def __init__ (
@@ -60,11 +64,8 @@ def __init__(
60
64
self .panda_name = panda_name
61
65
self .put_value_to_panda = put_value_to_panda
62
66
63
- async def put (self , controller : Any , attr : AttrW [T ], value : T ) -> None :
64
- await self .put_value_to_panda (self .panda_name , attr .datatype , value )
65
67
66
-
67
- class DefaultFieldUpdater (Updater ):
68
+ class DefaultFieldUpdater (AttrHandlerR ):
68
69
"""Default updater for updating introspected attributes."""
69
70
70
71
#: We update the fields from the top level
@@ -73,11 +74,8 @@ class DefaultFieldUpdater(Updater):
73
74
def __init__ (self , panda_name : PandaName ):
74
75
self .panda_name = panda_name
75
76
76
- async def update (self , controller : Any , attr : AttrR ) -> None :
77
- pass # TODO: update the attr with the value from the panda
78
-
79
77
80
- class DefaultFieldHandler (DefaultFieldSender , DefaultFieldUpdater , Handler ):
78
+ class DefaultFieldHandler (DefaultFieldSender , DefaultFieldUpdater , AttrHandlerRW ):
81
79
"""Default handler for sending and updating introspected attributes."""
82
80
83
81
def __init__ (
@@ -90,20 +88,12 @@ def __init__(
90
88
super ().__init__ (panda_name , put_value_to_panda )
91
89
92
90
93
- class TableFieldHandler (Handler ):
91
+ class TableFieldHandler (AttrHandlerRW ):
94
92
"""A handler for updating Table valued attributes."""
95
93
96
94
def __init__ (self , panda_name : PandaName ):
97
95
self .panda_name = panda_name
98
96
99
- async def update (self , controller : Any , attr : AttrR ) -> None :
100
- # TODO: Convert to panda value
101
- ...
102
-
103
- async def put (self , controller : Any , attr : AttrW , value : Any ) -> None :
104
- # TODO: Convert to attribtue value
105
- ...
106
-
107
97
108
98
class CaptureHandler (DefaultFieldHandler ):
109
99
"""A handler for capture attributes. Not currently used."""
@@ -143,7 +133,7 @@ async def __call__(self, value: Any):
143
133
)
144
134
145
135
146
- class ArmHandler ( Handler ):
136
+ class ArmSender ( AttrHandlerW ):
147
137
"""A sender for arming and disarming the Pcap."""
148
138
149
139
class ArmCommand (enum .Enum ):
@@ -157,16 +147,3 @@ def __init__(
157
147
):
158
148
self .arm = arm
159
149
self .disarm = disarm
160
-
161
- async def put (
162
- self , controller : Any , attr : AttrW [ArmCommand ], value : ArmCommand
163
- ) -> None :
164
- if value is self .ArmCommand .ARM :
165
- logging .info ("Arming PandA." )
166
- await self .arm ()
167
- else :
168
- logging .info ("Disarming PandA." )
169
- await self .disarm ()
170
-
171
- async def update (self , controller : Any , attr : AttrR [ArmCommand ]) -> None :
172
- pass
0 commit comments