Skip to content

Commit

Permalink
Add two-wire three-way valve to Ontrak
Browse files Browse the repository at this point in the history
- Add real-time status of flow rate (e.g. OK, WARNING, CRITICAL) in widget auxiliary data
- Add support for one-wire and two-wire three-way valves (switch), one wire uses one relay, two wire uses two relays.
- The two-wire switch implementation turn off power to switch after 25 seconds.
- Add color to AuxDataWidget in case value is CRITICAL, WARNING, or ERROR
- Refactor Ontrak relay_* variables into its own class
- Update MessageBoxAlarm to display part of text as informative (previously in bold).
- Fix difference between FlowControl widget and backend as backend was set by hidden PumpControl widget during init.
  • Loading branch information
doizuc committed Feb 5, 2024
1 parent 6eab29e commit e95b0fd
Show file tree
Hide file tree
Showing 8 changed files with 195 additions and 113 deletions.
2 changes: 1 addition & 1 deletion inlinino/app_signal.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class InstrumentSignals(QtCore.QObject):
new_aux_data = QtCore.pyqtSignal(list)
new_meta_data = QtCore.pyqtSignal(list)
alarm = QtCore.pyqtSignal(bool)
alarm_custom = QtCore.pyqtSignal(str)
alarm_custom = QtCore.pyqtSignal(str, str)


class HyperNavSignals(InstrumentSignals):
Expand Down
28 changes: 9 additions & 19 deletions inlinino/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -472,20 +472,19 @@ def on_new_spectrum_data(self, data):
@QtCore.pyqtSlot(bool)
def on_data_timeout(self, active):
if active and not self.alarm_message_box.active:
txt = ""
txt = self.alarm_message_box.TEXT
if self.instrument.name is not None:
txt += f"Instument: {self.instrument.name}\n"
if self.instrument.interface_name is not None:
txt += f"Port: {self.instrument.interface_name}\n\n"
txt += self.alarm_message_box.TEXT
self.alarm_message_box.show(txt)
elif not active and self.alarm_message_box.active:
self.alarm_message_box.hide()

@QtCore.pyqtSlot(str)
def on_custom_alarm(self, text):
@QtCore.pyqtSlot(str, str)
def on_custom_alarm(self, text, info_text):
if not self.alarm_message_box.active:
self.alarm_message_box.show(text, sound=False)
self.alarm_message_box.show(text, info_text, sound=False)

def closeEvent(self, event):
icon, txt = QtGui.QMessageBox.Question, "Are you sure you want to exit?"
Expand Down Expand Up @@ -528,20 +527,10 @@ def __init__(self, parent):
self.alarm_playlist.setPlaybackMode(QtMultimedia.QMediaPlaylist.Loop) # Playlist is needed for infinite loop
self.alarm_sound.setPlaylist(self.alarm_playlist)

def show(self, txt: str = None, sound: bool = True):
def show(self, txt: str = None, info_txt: str = None, sound: bool = True):
if not self.active:
if txt is None:
txt = ""
if instrument_name is not None:
txt += f"Instument: {instrument_name}\n"
if interface_name is not None:
opt = '' if ':' in interface_name else ' [disconnected]'
txt += f"Port: {interface_name}{opt}\n\n"
self.setInformativeText(txt + self.INFO_TEXT)
self.setText(self.TEXT)
else:
self.setText(txt)
self.setInformativeText('')
self.setText(self.TEXT if txt is None else txt)
self.setInformativeText(self.INFO_TEXT if info_txt is None else info_txt)
super().show()
if sound:
self.alarm_playlist.setCurrentIndex(0)
Expand Down Expand Up @@ -861,7 +850,8 @@ def act_save(self):
else:
self.cfg['model'] = 'UnknownMeterType'
self.cfg['serial_number'] = str(int(foo[-6:], 16))
except:
except Exception as e:
logger.error(e)
self.notification('Unable to parse acs device file.')
return
if 'log_raw' not in self.cfg.keys():
Expand Down
5 changes: 3 additions & 2 deletions inlinino/inlinino_cfg.json
Original file line number Diff line number Diff line change
Expand Up @@ -715,7 +715,7 @@
"log_raw": false,
"log_products": true,
"log_path": "data",
"relay0_mode": "Pump",
"relay0_mode": "Switch (two-wire)",
"relay1_mode": "Switch",
"relay2_mode": "Switch",
"relay3_mode": "Switch",
Expand All @@ -727,7 +727,8 @@
664
],
"analog_channels_enabled": [],
"analog_channels_gains": []
"analog_channels_gains": [],
"low_flow_alarm_enabled": true
},
"6a338538-4a88-11ee-a2f0-acde48001122": {
"module": "ontrak",
Expand Down
Loading

0 comments on commit e95b0fd

Please sign in to comment.