1- import os
2- import logging
31import copy
2+ import logging
3+ import os
44
5+ from pyaml .common .exception import PyAMLException
56from pyaml .control .controlsystem import ControlSystem
67from pydantic import BaseModel
7- from pyaml .common .exception import PyAMLException
8-
9- PYAMLCLASS : str = "OphydAsyncControlSystem"
10-
11- logger = logging .getLogger (__name__ )
128
9+ from . import __version__
10+ from .epicsR import EpicsR
11+ from .epicsRW import EpicsRW
12+ from .epicsW import EpicsW
13+ from .signal import OASignal
14+ from .tangoR import TangoR
15+ from .tangoRW import TangoRW
1316from .types import (
1417 EpicsConfigR ,
15- EpicsConfigW ,
1618 EpicsConfigRW ,
19+ EpicsConfigW ,
1720 TangoConfigR ,
1821 TangoConfigRW ,
1922)
20- from .signal import OASignal
21- from .epicsR import EpicsR
22- from .epicsW import EpicsW
23- from .epicsRW import EpicsRW
24- from .tangoR import TangoR
25- from .tangoRW import TangoRW
2623
27- from . import __version__
24+ PYAMLCLASS : str = "OphydAsyncControlSystem"
25+
26+ logger = logging .getLogger (__name__ )
2827
29- class ConfigModel (BaseModel ):
3028
29+ class ConfigModel (BaseModel ):
3130 """
3231 Configuration model for an OA Control System.
3332
@@ -36,21 +35,21 @@ class ConfigModel(BaseModel):
3635 name : str
3736 Name of the control system.
3837 prefix : str
39- Prefix added to the PV or attribute name. It can be a
38+ Prefix added to the PV or attribute name. It can be a
4039 for instance, TANGO_HOST, or a PV prefix.
4140 debug_level : int
4241 Debug verbosity level.
4342 scalar_aggregator : str
44- Aggregator module for scalar values. If none specified, writings and
45- readings of sclar value are serialized.
43+ Aggregator module for scalar values. If none specified, writings and
44+ readings of sclar value are serialized.
4645 vector_aggregator : str
4746 Aggregator module for vecrors. If none specified, writings and readings
4847 of vector are serialized,
4948 """
5049
5150 name : str
5251 prefix : str = ""
53- debug_level : str = None
52+ debug_level : str = None
5453 scalar_aggregator : str | None = "pyaml_cs_oa.scalar_aggregator"
5554 vector_aggregator : str | None = None
5655
@@ -61,57 +60,62 @@ class OphydAsyncControlSystem(ControlSystem):
6160 def __init__ (self , cfg : ConfigModel ):
6261 super ().__init__ ()
6362 self ._cfg = cfg
64- self ._devices = {} # Dict containing all attached DeviceAccess
63+ self ._devices = {} # Dict containing all attached DeviceAccess
6564
6665 if self ._cfg .debug_level :
67- log_level = getattr (logging , self ._cfg .debug_level , logging .WARNING )
68- logger .parent .setLevel (log_level )
69- logger .setLevel (log_level )
66+ log_level = getattr (logging , self ._cfg .debug_level , logging .WARNING )
67+ logger .parent .setLevel (log_level )
68+ logger .setLevel (log_level )
69+
70+ logger .log (
71+ logging .WARNING ,
72+ f"PyAML OA control system binding ({ __version__ } ) initialized with name '{ self ._cfg .name } '"
73+ f" and prefix='{ self ._cfg .prefix } '" ,
74+ )
7075
71- logger .log (logging .WARNING , f"PyAML OA control system binding ({ __version__ } ) initialized with name '{ self ._cfg .name } '"
72- f" and prefix='{ self ._cfg .prefix } '" )
73-
7476 def attach (self , devs : list [OASignal ]) -> list [OASignal ]:
75- return self ._attach (devs ,False )
77+ return self ._attach (devs , False )
7678
7779 def attach_array (self , devs : list [OASignal ]) -> list [OASignal ]:
78- return self ._attach (devs ,True )
80+ return self ._attach (devs , True )
7981
80- def _attach (self , devs : list [OASignal ],is_array :bool ) -> list [OASignal ]:
82+ def _attach (self , devs : list [OASignal ], is_array : bool ) -> list [OASignal ]:
8183 # Concatenate the prefix
8284 newDevs = []
83- for d in devs :
85+ for d in devs :
8486 if d is not None :
85-
8687 sig_cfg = d ._cfg
8788 sig_cfg_cls = sig_cfg .__class__
88-
89- if isinstance (d ._cfg ,EpicsConfigR ):
89+
90+ if isinstance (d ._cfg , EpicsConfigR ):
9091 key = self ._cfg .prefix + d ._cfg .read_pvname
9192 sig_cls = EpicsR
9293 config = dict (read_pvname = key )
93- elif isinstance (d ._cfg ,EpicsConfigW ):
94+ elif isinstance (d ._cfg , EpicsConfigW ):
9495 key = self ._cfg .prefix + d ._cfg .write_pvname
9596 sig_cls = EpicsW
9697 config = dict (write_pvname = key )
97- elif isinstance (d ._cfg ,EpicsConfigRW ):
98+ elif isinstance (d ._cfg , EpicsConfigRW ):
9899 key = self ._cfg .prefix + d ._cfg .read_pvname + d ._cfg .write_pvname
99100 sig_cls = EpicsRW
100- config = dict (read_pvname = self ._cfg .prefix + d ._cfg .read_pvname , write_pvname = self ._cfg .prefix + d ._cfg .write_pvname )
101- elif isinstance (d ._cfg ,TangoConfigR ):
101+ config = dict (
102+ read_pvname = self ._cfg .prefix + d ._cfg .read_pvname ,
103+ write_pvname = self ._cfg .prefix + d ._cfg .write_pvname ,
104+ )
105+ elif isinstance (d ._cfg , TangoConfigR ):
102106 key = self ._cfg .prefix + d ._cfg .attribute
103107 sig_cls = TangoR
104108 config = dict (attribute = key )
105- elif isinstance (d ._cfg ,TangoConfigRW ):
109+ elif isinstance (d ._cfg , TangoConfigRW ):
106110 key = self ._cfg .prefix + d ._cfg .attribute
107111 sig_cls = TangoRW
108112 config = dict (attribute = key )
109113 else :
110114 raise PyAMLException (f"OphydAsyncControlSystem: Unsupported type { type (sig_cfg )} " )
111115
112116 if key not in self ._devices :
113- n_conf = dict (d ._cfg ) | config
114- nr = sig_cls (sig_cfg_cls (** n_conf ),is_array )
117+ n_conf = dict (d ._cfg ) | config
118+ nr = sig_cls (sig_cfg_cls (** n_conf ), is_array )
115119 nr .build ()
116120 self ._devices [key ] = nr
117121
@@ -130,7 +134,7 @@ def name(self) -> str:
130134 Name of the control system.
131135 """
132136 return self ._cfg .name
133-
137+
134138 def scalar_aggregator (self ) -> str | None :
135139 """
136140 Returns the module name used for handling aggregator of DeviceAccess
@@ -145,7 +149,7 @@ def scalar_aggregator(self) -> str | None:
145149 def vector_aggregator (self ) -> str | None :
146150 """
147151 Returns the module name used for handling aggregator of DeviceVectorAccess
148-
152+
149153 Returns
150154 -------
151155 str
@@ -154,4 +158,4 @@ def vector_aggregator(self) -> str | None:
154158 return self ._cfg .vector_aggregator
155159
156160 def __repr__ (self ):
157- return repr (self ._cfg ).replace ("ConfigModel" ,self .__class__ .__name__ )
161+ return repr (self ._cfg ).replace ("ConfigModel" , self .__class__ .__name__ )
0 commit comments