Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions ventilator_alarm.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ def run(self, name):
self.time_last_kick_received == cur_time
if msg['val'] != 0:
self.request_queue.put({'type': 'error', 'value': msg['val']})
elif msg['type'] == "PRES":
if ((msg['val'] > proto.settings_values['PK'] + proto.settings_values['ADPK']) or
(msg['val'] < proto.settings_values['PK'] - proto.settings_values['ADPK'])):
self.request_queue.put({'type': 'alarm', 'priority': 42, 'value': 5})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how is the priority used? Does this make sense given that priority queues are not available for multiprocessing?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my opinion the priority can have a sense. But it depends on what is the final design around alarm. We can imagine a design where a alarm code has its own sound or visual and if several alarms are triggered at the same time, the higher priority can be played first, and when it is fixed the second one, etc.
At least it is easy to remove.

For the value, yes it is just for test, ideally we should assign a name to a value and having a list of alarms somewhere (in protocol.py ?). I made the pull request to get a feedback and not really to merge it yet, just to define a bit more what is expected and if the concept is right.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

5 seems a strange value if we're still using bit field alarms. Ideally we'd have a list of the definitions available somewhere. Is this a placeholder?

self.serial_queue.put({'type': proto.alarm, 'priority': 42, 'val': 5})

# Have we received a watchdog kick in time?
if ((cur_time - self.time_watchdog_kick_checked) > 3):
Expand Down
5 changes: 5 additions & 0 deletions ventilator_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ def send_setting(self, key, val):
print("Send setting to server, set to {}".format({key:val}))
self.__put("/api/settings?returncomplete=false", {key:val})

def send_alarm(self, priority, val):
print("Send alarm to server, set to {}".format({priority:val}))
self.__put("/api/alarms", {'alarmPriority':priority}, {'alarmValue':val})
return

def send_error(self, val):
# self.__put("/api/settings", {'alarmValue':val})
# print("todo; send the alarm")
Expand Down
4 changes: 3 additions & 1 deletion ventilator_request_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,7 @@ def run(self, name):
self.api_client.send_setting(msg['key'], msg['value'])
elif msg['type'] == 'error':
self.api_client.send_error(msg['value'])
elif msg['type'] == 'alarm':
self.api_client.send_alarm(msg['priority'], msg['value'])
except:
print("Invalid message from request")
print("Invalid message from request {}".format(msg))