Skip to content

Commit

Permalink
Add support of Ontrak ADU222
Browse files Browse the repository at this point in the history
- add support for ADU222
- update dependency download-artifact in GitHub workflow
- bump version to 2.9.14
  • Loading branch information
doizuc committed Nov 22, 2024
1 parent aa02106 commit a6fb428
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 25 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:

steps:
- name: Download All Artifacts
uses: actions/download-artifact@v4
uses: actions/download-artifact@v4.1.8
with:
merge-multiple: True

Expand Down
2 changes: 1 addition & 1 deletion inlinino/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import numpy as np


__version__ = '2.9.14.eta'
__version__ = '2.9.14'

# Setup Logger
logging.basicConfig(level=logging.DEBUG)
Expand Down
19 changes: 18 additions & 1 deletion inlinino/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -793,6 +793,8 @@ def act_activate_fields_for_adu_model(self):
model = self.combobox_model.currentText()
if model == 'ADU100':
self.group_box_analog.setEnabled(True)
self.group_box_flowmeters.setEnabled(True)
self.checkbox_low_flow_alarm_enabled.setEnabled(True)
self.checkbox_relay1_enabled.setEnabled(False)
self.checkbox_relay1_enabled.setChecked(False)
self.combobox_relay1_mode.setEnabled(False)
Expand All @@ -804,6 +806,8 @@ def act_activate_fields_for_adu_model(self):
self.combobox_relay3_mode.setEnabled(False)
elif model in ('ADU200', 'ADU208'):
self.group_box_analog.setEnabled(False)
self.group_box_flowmeters.setEnabled(True)
self.checkbox_low_flow_alarm_enabled.setEnabled(True)
if self.combobox_relay0_mode.currentText() != 'Switch (two-wire)':
self.checkbox_relay1_enabled.setEnabled(True)
self.combobox_relay1_mode.setEnabled(True)
Expand All @@ -812,6 +816,19 @@ def act_activate_fields_for_adu_model(self):
if self.combobox_relay2_mode.currentText() != 'Switch (two-wire)':
self.checkbox_relay3_enabled.setEnabled(True)
self.combobox_relay3_mode.setEnabled(True)
elif model == 'ADU222':
self.group_box_analog.setEnabled(False)
self.group_box_flowmeters.setEnabled(False)
self.checkbox_low_flow_alarm_enabled.setEnabled(False)
if self.combobox_relay0_mode.currentText() != 'Switch (two-wire)':
self.checkbox_relay1_enabled.setEnabled(True)
self.combobox_relay1_mode.setEnabled(True)
self.checkbox_relay2_enabled.setEnabled(False)
self.checkbox_relay2_enabled.setChecked(False)
self.combobox_relay2_mode.setEnabled(False)
self.checkbox_relay3_enabled.setEnabled(False)
self.checkbox_relay3_enabled.setChecked(False)
self.combobox_relay3_mode.setEnabled(False)
else:
raise ValueError(f'Model {model} not supported.')

Expand Down Expand Up @@ -1244,7 +1261,7 @@ def __init__(self, parent):
self.button_box.button(QtGui.QDialogButtonBox.Cancel).clicked.connect(self.reject)
# Update ports list
self.ports = list_serial_comports()
# self.ports.append(type('obj', (object,), {'device': '/dev/ttys001', 'product': 'macOS Virtual Serial', 'description': 'n/a'})) # Debug macOS serial
self.ports.append(type('obj', (object,), {'device': '/dev/ttys004', 'product': 'macOS Virtual Serial', 'description': 'n/a'})) # Debug macOS serial
ports_device = []
for p in self.ports:
# print(f'\n\n===\n{p.description}\n{p.device}\n{p.hwid}\n{p.interface}\n{p.location}\n{p.manufacturer}\n{p.name}\n{p.pid}\n{p.product}\n{p.serial_number}\n{p.vid}')
Expand Down
50 changes: 28 additions & 22 deletions inlinino/instruments/ontrak.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,12 @@ def __bool__(self):
class Ontrak(Instrument):
"""
ontrak Control Systems Data Acquisition Interface
Supported Model: ADU100
"""

VENDOR_ID = 0x0a07

SUPPORTED_MODELS = ['ADU100', 'ADU200', 'ADU208', 'ADU222']

# Specific ADU 100
ADC_RESOLUTION = 65535
# UNIPOLAR_GAIN = {
Expand Down Expand Up @@ -113,13 +114,16 @@ def setup(self, cfg, raw_logger=LogText):
# Set specific attributes
if 'model' not in cfg.keys():
raise ValueError('Missing field model')
if self.model and self.model not in ['ADU100', 'ADU200', 'ADU208']:
raise ValueError('Model not supported. Supported models are: ADU100, ADU200, and ADU208')
if self.model and self.model not in Ontrak.SUPPORTED_MODELS:
raise ValueError(f"Model not supported. Supported models are: {', '.join(Ontrak.SUPPORTED_MODELS)}")
# Relays
n_relays = 1 if cfg['model'] == 'ADU100' else 4
relay_mode_supported = ['Switch', 'Switch (one-wire)', 'Pump']
if cfg['model'] != 'ADU100':
relay_mode_supported.append('Switch (two-wire)')
n_relays = 4
relay_mode_supported = ['Switch', 'Switch (one-wire)', 'Switch (two-wire)', 'Pump']
if cfg['model'] == 'ADU100':
n_relays = 1
relay_mode_supported.remove('Switch (two-wire)')
elif cfg['model'] == 'ADU222':
n_relays = 2
self.relays_enabled, self.relays_gui_mode, self.relays = [], [None]*4, [None]*4
self.widget_flow_controls_enabled, self.widget_pump_controls_enabled = [None]*4, [None]*4
for r in range(n_relays):
Expand All @@ -146,15 +150,21 @@ def setup(self, cfg, raw_logger=LogText):
self.widget_flow_controls_enabled[r] = False
self.widget_pump_controls_enabled[r] = True
# Event Counters
if 'event_counter_channels_enabled' not in cfg.keys():
raise ValueError('Missing field event counter channels enabled')
self.event_counter_channels = cfg['event_counter_channels_enabled']
if 'event_counter_k_factors' not in cfg.keys():
raise ValueError('Missing field event counter k factors')
self.event_counter_k_factors = cfg['event_counter_k_factors']
self._event_counter_past_timestamps = [float('nan')] * len(self.event_counter_channels)
if 'low_flow_alarm_enabled' in cfg.keys():
self.low_flow_alarm_enabled = cfg['low_flow_alarm_enabled']
if cfg['model'] != 'ADU222':
if 'event_counter_channels_enabled' not in cfg.keys():
raise ValueError('Missing field event counter channels enabled')
self.event_counter_channels = cfg['event_counter_channels_enabled']
if 'event_counter_k_factors' not in cfg.keys():
raise ValueError('Missing field event counter k factors')
self.event_counter_k_factors = cfg['event_counter_k_factors']
self._event_counter_past_timestamps = [float('nan')] * len(self.event_counter_channels)
if 'low_flow_alarm_enabled' in cfg.keys():
self.low_flow_alarm_enabled = cfg['low_flow_alarm_enabled']
else:
self.event_counter_channels = []
self.event_counter_k_factors = []
self._event_counter_past_timestamps = []
self.low_flow_alarm_enabled = False
# Analog Channels
if cfg['model'] == 'ADU100':
if 'analog_channels_enabled' not in cfg.keys():
Expand Down Expand Up @@ -218,12 +228,8 @@ def setup_interface(self, cfg):

def open(self, **kwargs):
if self._interface.name.startswith('usb'):
if self.model == 'ADU100':
product_id = 100
elif self.model == 'ADU200':
product_id = 200
elif self.model == 'ADU208':
product_id = 208
if self.model in Ontrak.SUPPORTED_MODELS:
product_id = int(self.model[3:])
else:
raise ValueError('Model not supported.')
super().open(vendor_id=self.VENDOR_ID, product_id=product_id, **kwargs)
Expand Down
8 changes: 8 additions & 0 deletions inlinino/resources/setup_ontrak.ui
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@
<string>ADU208</string>
</property>
</item>
<item>
<property name="text">
<string>ADU222</string>
</property>
</item>
</widget>
</item>
<item row="3" column="0">
Expand Down Expand Up @@ -396,6 +401,9 @@
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<widget class="QGroupBox" name="group_box_flowmeters">
<property name="enabled">
<bool>true</bool>
</property>
<property name="title">
<string>Digital Input(s)</string>
</property>
Expand Down

0 comments on commit a6fb428

Please sign in to comment.