Index: dialin/hd/alarms.py =================================================================== diff -u -rbcb19706315a5fd56fc38375379415255391fbac -r1454a1ae9ab6d66750269d471048ffe52c5786de --- dialin/hd/alarms.py (.../alarms.py) (revision bcb19706315a5fd56fc38375379415255391fbac) +++ dialin/hd/alarms.py (.../alarms.py) (revision 1454a1ae9ab6d66750269d471048ffe52c5786de) @@ -193,6 +193,11 @@ message['message'][self.START_POS_ALARMS_FLAGS:self.END_POS_ALARMS_FLAGS]), byteorder=DenaliMessage.BYTE_ORDER) + # if no active alarms from HD, set all alarms (on Dialin side) to False in case we got out of sync + if self.alarm_top == 0: + for x in range(500): + self.alarm_states[x] = False + @_publish(["alarm_states"]) def _handler_alarm_activate(self, message): """ Index: dialin/hd/blood_flow.py =================================================================== diff -u -r0b0c4e54daebd92984808ca943981cccf26bb318 -r1454a1ae9ab6d66750269d471048ffe52c5786de --- dialin/hd/blood_flow.py (.../blood_flow.py) (revision 0b0c4e54daebd92984808ca943981cccf26bb318) +++ dialin/hd/blood_flow.py (.../blood_flow.py) (revision 1454a1ae9ab6d66750269d471048ffe52c5786de) @@ -166,7 +166,7 @@ @param flow: integer - flow set point (in mL/min) to override with (negative for reverse direction) @param mode: integer - 0 for closed loop control mode or 1 for open loop control mode - @param reset: integer - 1 to reset a previous override, 0 to override + @param reset: integer - N/A @return: 1 if successful, zero otherwise """ Index: dialin/hd/dialysate_inlet_flow.py =================================================================== diff -u -r3690e7c9ba3ccd5fe699a1000cacf7241cd82f68 -r1454a1ae9ab6d66750269d471048ffe52c5786de --- dialin/hd/dialysate_inlet_flow.py (.../dialysate_inlet_flow.py) (revision 3690e7c9ba3ccd5fe699a1000cacf7241cd82f68) +++ dialin/hd/dialysate_inlet_flow.py (.../dialysate_inlet_flow.py) (revision 1454a1ae9ab6d66750269d471048ffe52c5786de) @@ -173,7 +173,7 @@ @param flow: integer - flow set point (in mL/min) to override with @param mode: integer - 0 for closed loop control mode or 1 for open loop control mode - @param reset: integer - 1 to reset a previous override, 0 to override + @param reset: integer - N/A @return: 1 if successful, zero otherwise """ Index: dialin/hd/dialysate_outlet_flow.py =================================================================== diff -u -r3690e7c9ba3ccd5fe699a1000cacf7241cd82f68 -r1454a1ae9ab6d66750269d471048ffe52c5786de --- dialin/hd/dialysate_outlet_flow.py (.../dialysate_outlet_flow.py) (revision 3690e7c9ba3ccd5fe699a1000cacf7241cd82f68) +++ dialin/hd/dialysate_outlet_flow.py (.../dialysate_outlet_flow.py) (revision 1454a1ae9ab6d66750269d471048ffe52c5786de) @@ -156,7 +156,7 @@ @param flow: integer - flow set point (in mL/min) to override with @param mode: integer - 0 for closed loop control mode or 1 for open loop control mode - @param reset: integer - 1 to reset a previous override, 0 to override + @param reset: integer - N/A @return: 1 if successful, zero otherwise """ Index: dialin/hd/hemodialysis_device.py =================================================================== diff -u -r527decd42c3e6730a33ff6b7635787d13f9400e5 -r1454a1ae9ab6d66750269d471048ffe52c5786de --- dialin/hd/hemodialysis_device.py (.../hemodialysis_device.py) (revision 527decd42c3e6730a33ff6b7635787d13f9400e5) +++ dialin/hd/hemodialysis_device.py (.../hemodialysis_device.py) (revision 1454a1ae9ab6d66750269d471048ffe52c5786de) @@ -87,10 +87,21 @@ msg_id = MsgIds.MSG_ID_HD_OP_MODE.value self.can_interface.register_receiving_publication_function(channel_id, msg_id, self._handler_hd_op_mode_sync) + msg_id = MsgIds.MSG_ID_HD_CALIBRATION_DATA.value + self.can_interface.register_receiving_publication_function(channel_id, msg_id, + self._handler_hd_cal_data_sync) # create properties self.hd_operation_mode = self.HD_OP_MODE_INIT_POST self.hd_operation_sub_mode = 0 + self.hd_calibration_data = {"Revision":0, + "AccelXOffset":0.0, + "AccelYOffset":0.0, + "AccelZOffset":0.0, + "BloodFlowGain":0.0, + "BloodFlowOffset":0.0, + "DialysateFlowGain":0.0, + "DialysateFlowOffset":0.0} # Create command groups self.accel = HDAccelerometer(self.can_interface, self.logger) @@ -115,6 +126,42 @@ """ return self.hd_operation_mode + @_publish(["hd_calibration_data"]) + def _handler_hd_cal_data_sync(self, message): + """ + Handles published HD calibration data messages. Current HD calibration data + is captured for reference. Call cmd_request_hd_calibration_data() method + to request HD to publish HD calibration data. + + @param message: published HD calibration data broadcast message + @return: None + """ + rev = struct.unpack('i', bytearray( + message['message'][MsgFldPositions.START_POS_FIELD_1:MsgFldPositions.END_POS_FIELD_1])) + acc_x = struct.unpack('f', bytearray( + message['message'][MsgFldPositions.START_POS_FIELD_2:MsgFldPositions.END_POS_FIELD_2])) + acc_y = struct.unpack('f', bytearray( + message['message'][MsgFldPositions.START_POS_FIELD_3:MsgFldPositions.END_POS_FIELD_3])) + acc_z = struct.unpack('f', bytearray( + message['message'][MsgFldPositions.START_POS_FIELD_4:MsgFldPositions.END_POS_FIELD_4])) + bf_g = struct.unpack('f', bytearray( + message['message'][MsgFldPositions.START_POS_FIELD_5:MsgFldPositions.END_POS_FIELD_5])) + bf_o = struct.unpack('f', bytearray( + message['message'][MsgFldPositions.START_POS_FIELD_6:MsgFldPositions.END_POS_FIELD_6])) + df_g = struct.unpack('f', bytearray( + message['message'][MsgFldPositions.START_POS_FIELD_7:MsgFldPositions.END_POS_FIELD_7])) + df_o = struct.unpack('f', bytearray( + message['message'][MsgFldPositions.START_POS_FIELD_8:MsgFldPositions.END_POS_FIELD_8])) + + self.hd_calibration_data["Revision"] = rev[0] + self.hd_calibration_data["AccelXOffset"] = acc_x[0] + self.hd_calibration_data["AccelYOffset"] = acc_y[0] + self.hd_calibration_data["AccelZOffset"] = acc_z[0] + self.hd_calibration_data["BloodFlowGain"] = bf_g[0] + self.hd_calibration_data["BloodFlowOffset"] = bf_o[0] + self.hd_calibration_data["DialysateFlowGain"] = df_g[0] + self.hd_calibration_data["DialysateFlowOffset"] = df_o[0] + @_publish(["hd_operation_mode"]) def _handler_hd_op_mode_sync(self, message): """