@@ -49,11 +49,12 @@ def __bool__(self):
49
49
class Ontrak (Instrument ):
50
50
"""
51
51
ontrak Control Systems Data Acquisition Interface
52
- Supported Model: ADU100
53
52
"""
54
53
55
54
VENDOR_ID = 0x0a07
56
55
56
+ SUPPORTED_MODELS = ['ADU100' , 'ADU200' , 'ADU208' , 'ADU222' ]
57
+
57
58
# Specific ADU 100
58
59
ADC_RESOLUTION = 65535
59
60
# UNIPOLAR_GAIN = {
@@ -113,13 +114,16 @@ def setup(self, cfg, raw_logger=LogText):
113
114
# Set specific attributes
114
115
if 'model' not in cfg .keys ():
115
116
raise ValueError ('Missing field model' )
116
- if self .model and self .model not in [ 'ADU100' , 'ADU200' , 'ADU208' ] :
117
- raise ValueError (' Model not supported. Supported models are: ADU100, ADU200, and ADU208' )
117
+ if self .model and self .model not in Ontrak . SUPPORTED_MODELS :
118
+ raise ValueError (f" Model not supported. Supported models are: { ', ' . join ( Ontrak . SUPPORTED_MODELS ) } " )
118
119
# Relays
119
- n_relays = 1 if cfg ['model' ] == 'ADU100' else 4
120
- relay_mode_supported = ['Switch' , 'Switch (one-wire)' , 'Pump' ]
121
- if cfg ['model' ] != 'ADU100' :
122
- relay_mode_supported .append ('Switch (two-wire)' )
120
+ n_relays = 4
121
+ relay_mode_supported = ['Switch' , 'Switch (one-wire)' , 'Switch (two-wire)' , 'Pump' ]
122
+ if cfg ['model' ] == 'ADU100' :
123
+ n_relays = 1
124
+ relay_mode_supported .remove ('Switch (two-wire)' )
125
+ elif cfg ['model' ] == 'ADU222' :
126
+ n_relays = 2
123
127
self .relays_enabled , self .relays_gui_mode , self .relays = [], [None ]* 4 , [None ]* 4
124
128
self .widget_flow_controls_enabled , self .widget_pump_controls_enabled = [None ]* 4 , [None ]* 4
125
129
for r in range (n_relays ):
@@ -146,15 +150,21 @@ def setup(self, cfg, raw_logger=LogText):
146
150
self .widget_flow_controls_enabled [r ] = False
147
151
self .widget_pump_controls_enabled [r ] = True
148
152
# Event Counters
149
- if 'event_counter_channels_enabled' not in cfg .keys ():
150
- raise ValueError ('Missing field event counter channels enabled' )
151
- self .event_counter_channels = cfg ['event_counter_channels_enabled' ]
152
- if 'event_counter_k_factors' not in cfg .keys ():
153
- raise ValueError ('Missing field event counter k factors' )
154
- self .event_counter_k_factors = cfg ['event_counter_k_factors' ]
155
- self ._event_counter_past_timestamps = [float ('nan' )] * len (self .event_counter_channels )
156
- if 'low_flow_alarm_enabled' in cfg .keys ():
157
- self .low_flow_alarm_enabled = cfg ['low_flow_alarm_enabled' ]
153
+ if cfg ['model' ] != 'ADU222' :
154
+ if 'event_counter_channels_enabled' not in cfg .keys ():
155
+ raise ValueError ('Missing field event counter channels enabled' )
156
+ self .event_counter_channels = cfg ['event_counter_channels_enabled' ]
157
+ if 'event_counter_k_factors' not in cfg .keys ():
158
+ raise ValueError ('Missing field event counter k factors' )
159
+ self .event_counter_k_factors = cfg ['event_counter_k_factors' ]
160
+ self ._event_counter_past_timestamps = [float ('nan' )] * len (self .event_counter_channels )
161
+ if 'low_flow_alarm_enabled' in cfg .keys ():
162
+ self .low_flow_alarm_enabled = cfg ['low_flow_alarm_enabled' ]
163
+ else :
164
+ self .event_counter_channels = []
165
+ self .event_counter_k_factors = []
166
+ self ._event_counter_past_timestamps = []
167
+ self .low_flow_alarm_enabled = False
158
168
# Analog Channels
159
169
if cfg ['model' ] == 'ADU100' :
160
170
if 'analog_channels_enabled' not in cfg .keys ():
@@ -218,12 +228,8 @@ def setup_interface(self, cfg):
218
228
219
229
def open (self , ** kwargs ):
220
230
if self ._interface .name .startswith ('usb' ):
221
- if self .model == 'ADU100' :
222
- product_id = 100
223
- elif self .model == 'ADU200' :
224
- product_id = 200
225
- elif self .model == 'ADU208' :
226
- product_id = 208
231
+ if self .model in Ontrak .SUPPORTED_MODELS :
232
+ product_id = int (self .model [3 :])
227
233
else :
228
234
raise ValueError ('Model not supported.' )
229
235
super ().open (vendor_id = self .VENDOR_ID , product_id = product_id , ** kwargs )
0 commit comments