Index: dialin/common/msg_defs.py =================================================================== diff -u -r4a14fb08755f069501169e63a652d8681135462c -r0e3af06905af539b1a86ba8407189dfd5153ad33 --- dialin/common/msg_defs.py (.../msg_defs.py) (revision 4a14fb08755f069501169e63a652d8681135462c) +++ dialin/common/msg_defs.py (.../msg_defs.py) (revision 0e3af06905af539b1a86ba8407189dfd5153ad33) @@ -125,6 +125,10 @@ MSG_ID_UI_TREATMENT_LOG_DATA_REQUEST = 0x75 # UI request treatment log data message MSG_ID_HD_TREATMENT_LOG_DATA_RESPONSE = 0x76 # HD response to UI treatment log data request + MSG_ID_HD_TREATMENT_LOG_DATA = 0x94 # HD to UI treatment log data (periodic 30 min average) + MSG_ID_HD_TREATMENT_LOG_ALARM = 0x95 # HD to UI treatment log alarm + MSG_ID_HD_TREATMENT_LOG_EVENT = 0x96 # HD to UI treatment log event + MSG_ID_DG_DISINFECT_STATE = 0x7E # DG disinfect states Index: dialin/ui/hd_simulator.py =================================================================== diff -u -r6149d1560d7061d4c81d3ec4ca33f4af563d8437 -r0e3af06905af539b1a86ba8407189dfd5153ad33 --- dialin/ui/hd_simulator.py (.../hd_simulator.py) (revision 6149d1560d7061d4c81d3ec4ca33f4af563d8437) +++ dialin/ui/hd_simulator.py (.../hd_simulator.py) (revision 0e3af06905af539b1a86ba8407189dfd5153ad33) @@ -1868,34 +1868,40 @@ self.can_interface.send(message, 0) - def cmd_send_general_response(self, message_id, accepted, reason, fromHD = True,hasParameters = False, parameters_payload = 0x00): + def cmd_send_general_response(self, message_id: int, accepted: int, reason: int, from_hd: bool = True, has_parameters: bool = False, parameters_payload: any = 0x00) -> None : """ - :param message_id: (int) the message id - :param accepted: (int) boolean accept/reject response - :param reason: (int) rejection reason - :return: none + a general method to send any standard response message, by it's id and list of paramters. + :param message_id: the id of the message + :param accepted: the standard accepted parameter of any response message + :param reason: the standard rejection reason parameter of any response message + :param from_hd: if the message shall be send fron hd channel the this needs to be true + :param has_parameters: if the message has parameter this needs to be true. + :param parameters_payload: the list of parameters pre-converted and ready to be concatenated to the payload. + :return: None """ payload = integer_to_bytearray(accepted) payload += integer_to_bytearray(reason) - if hasParameters: + if has_parameters: payload += parameters_payload - message = DenaliMessage.build_message(channel_id= DenaliChannels.hd_to_ui_ch_id if fromHD else DenaliChannels.dg_to_ui_ch_id, + message = DenaliMessage.build_message(channel_id= DenaliChannels.hd_to_ui_ch_id if from_hd else DenaliChannels.dg_to_ui_ch_id, message_id=message_id, payload=payload) self.can_interface.send(message, 0) - def cmd_send_general_progress_data(self, message_id, total, countdown, fromHD = True): + def cmd_send_general_progress_data(self, message_id: int, total: int, countdown: int, from_hd: bool = True) -> None: """ - send the pretreatment filter flush progress data - :param accepted: (U32) Total time in second - :param reason: (U32) count down time in second + a general method t send any standard progress data message, by it's id + :param message_id: the id of the message + :param total: the total value of the progress data + :param countdown: the remaining or countdown value + :param from_hd: if the message shall be send fron hd channel the this needs to be true :return: None """ payload = integer_to_bytearray(total) payload += integer_to_bytearray(countdown) - message = DenaliMessage.build_message(channel_id= DenaliChannels.hd_to_ui_ch_id if fromHD else DenaliChannels.dg_to_ui_ch_id, + message = DenaliMessage.build_message(channel_id= DenaliChannels.hd_to_ui_ch_id if from_hd else DenaliChannels.dg_to_ui_ch_id, message_id=message_id, payload=payload) @@ -2081,6 +2087,70 @@ self.can_interface.send(message, 0) + def cmd_send_treatment_log_data(self, timestamp: int, bloodFlowRate: int, dialysateFlowRate: int, ufRate: float, arterialPressure: float, venousPressure: float) -> None: + """ + send the treatment log data + :param timestamp: (U32) timestamp + :param bloodFlowRate: (U32) blood flow rate + :param dialysateFlowRate: (U32) Dialysate Flow Rate + :param ufRate: (F32) UF Rate + :param arterialPressure: (F32) Arterial Pressure + :param venousPressure: (F32) Venous Pressure + :return: None + """ + payload = integer_to_bytearray(timestamp) + payload += integer_to_bytearray(bloodFlowRate) + payload += integer_to_bytearray(dialysateFlowRate) + payload += float_to_bytearray(ufRate) + payload += float_to_bytearray(arterialPressure) + payload += float_to_bytearray(venousPressure) + + message = DenaliMessage.build_message(channel_id=DenaliChannels.hd_to_ui_ch_id, + message_id=MsgIds.MSG_ID_HD_TREATMENT_LOG_DATA.value, + payload=payload) + + self.can_interface.send(message, 0) + + def cmd_send_treatment_log_alarm(self, timestamp: int, alarmID: int, parameter1: float, parameter2: float) -> None: + """ + send the treatment log data + :param timestamp: (U32) timestamp + :param alarmID: (U32) alarm ID + :param parameter1: (F32) paramter 1 (it's not clear yet how many paramters with what type is required and this is only plceholder) + :param parameter2: (F32) paramter 2 (it's not clear yet how many paramters with what type is required and this is only plceholder) + :return: None + """ + payload = integer_to_bytearray(timestamp) + payload += integer_to_bytearray(alarmID) + payload += integer_to_bytearray(parameter1) + payload += integer_to_bytearray(parameter2) + + message = DenaliMessage.build_message(channel_id=DenaliChannels.hd_to_ui_ch_id, + message_id=MsgIds.MSG_ID_HD_TREATMENT_LOG_ALARM.value, + payload=payload) + + self.can_interface.send(message, 0) + + def cmd_send_treatment_log_event(self, timestamp: int, eventID: int, oldValue: float, newValue: float) -> None: + """ + send the treatment log data + :param timestamp: (U32) timestamp + :param alarmID: (U32) alarm ID + :param oldValue: (F32) the old value + :param newValue: (F32) the new value + :return: none + """ + payload = integer_to_bytearray(timestamp) + payload += integer_to_bytearray(eventID) + payload += float_to_bytearray(oldValue) + payload += float_to_bytearray(newValue) + + message = DenaliMessage.build_message(channel_id=DenaliChannels.hd_to_ui_ch_id, + message_id=MsgIds.MSG_ID_HD_TREATMENT_LOG_EVENT.value, + payload=payload) + + self.can_interface.send(message, 0) + def cmd_send_dg_disinfection_state(self, subMode, flushMode, heatMode, chemicalMode): """ Broadcasts the current DG disinfection mode