Commit 563cb887 authored by Tiago Sarmento's avatar Tiago Sarmento

fix bug with clinical limits cancel

parent 23c5c199
Pipeline #1839 failed with stages
......@@ -244,7 +244,9 @@ class labelledSpin(QtWidgets.QWidget):
return 0
try:
if self.NativeUI.currentMode in self.cmd_type: # only update value if spin w idget corresponds to current mode
if 'SET_TARGET' in self.cmd_type and self.NativeUI.currentMode.replace("/", "_").replace("-", "_") not in self.cmd_type: # only update value if spin w idget corresponds to current mode
return 0
else:
newVal = db[self.tag]
except KeyError:
logging.warning(
......
......@@ -93,14 +93,6 @@ class ClinicalHandler(PayloadHandler):
for key, widget in dict(self.limSpinDict, **self.setSpinDict).items():
if widget.manuallyUpdated:
setVal = widget.get_value()
if "set" not in key:
setkey = key.replace("min", "set").replace("max", "set")
if widget.label in self.absoluteLimits:
multiplier = 1
else:
multiplier = self.setSpinDict[setkey].get_value() / 100
setVal = self.setSpinDict[setkey].get_value() + setVal * multiplier
setVal = round(setVal, widget.decPlaces)
message.append("set" + key + " to " + str(setVal))
......@@ -143,6 +135,8 @@ class ClinicalHandler(PayloadHandler):
widget.manuallyUpdated = False
self.valueDict[key] = widget.get_value()
widget.set_value(widget.get_value())
if 'set' in key:
self.setpoint_changed(widget)
self.active_payload()
self.refresh_button_colour()
......
......@@ -36,7 +36,7 @@ class ModeHandler(PayloadHandler):
) # ["PC/AC", "PC/AC-PRVC", "PC-PSV", "CPAP", 'CURRENT']
self.manuallyUpdatedBoolDict = {mode: False for mode in self.modeList}
self.mainManuallyUpdated = False
self.activeMode = self.modeList[0]
#self.activeMode = self.modeList[0]
with open("NativeUI/configs/mode_config.json") as json_file:
modeDict = json.load(json_file)
......@@ -64,7 +64,6 @@ class ModeHandler(PayloadHandler):
def active_payload(self, *args) -> int:
target_data = self.get_db()
print(target_data)
outdict = {}
for key in self.relevantKeys:
......@@ -125,7 +124,8 @@ class ModeHandler(PayloadHandler):
for command in self.commandList:
logging.info("sending commands:", command)
self.NativeUI.q_send_cmd(*command)
self.modeSwitched.emit(self.activeMode)
if 'SET_MODE' in command:
self.modeSwitched.emit(command[-1])
self.commandSent()
return 0
......@@ -134,6 +134,10 @@ class ModeHandler(PayloadHandler):
for widget in self.spinDict:
if buttonMode in widget or self.NativeUI.currentMode in widget:
self.spinDict[widget].manuallyUpdated = False
print('checking')
print(buttonMode)
print(self.NativeUI.currentMode)
print(widget)
print('cancel pressed')
print(buttonMode)
print(self.NativeUI.currentMode)
......@@ -217,6 +221,8 @@ class ModeHandler(PayloadHandler):
if spin.get_value() != widget.get_value():
spin.simpleSpin.set_value(widget.get_value())
self.refresh_button_colour()
def refresh_main_button_colour(self):
self.manuallyUpdatedBoolDict["CURRENT"] = False
for spin in self.mainSpinDict:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment