Index: HD_DialOutFlow.py =================================================================== diff -u -r6124a4264e27660239a0a01436dee04d0c63dac6 -rc172ebf4d713b654fb5a75113c96bf7f5ef5d858 --- HD_DialOutFlow.py (.../HD_DialOutFlow.py) (revision 6124a4264e27660239a0a01436dee04d0c63dac6) +++ HD_DialOutFlow.py (.../HD_DialOutFlow.py) (revision c172ebf4d713b654fb5a75113c96bf7f5ef5d858) @@ -18,18 +18,31 @@ """ can = None - MSG_ID_SET_DIALOUT_FLOW_STATE = 0x8016 - MSG_ID_SET_DIALOUT_FLOW_RX = 0X8018 + # Command message ID + MSG_ID_SET_DIALOUT_FLOW_STATE = 0x8017 + MSG_ID_SET_DIALOUT_FLOW_RX = 0x8018 + # Broadcast message ID + MSG_ID_DIALYSATE_UF_DATA = 0x0009 + DIALOUT_STATES = list(DialOutStates) - def __init__(self, hd_object): + # variable storing information received by Handler + + def __init__(self, can_interface): """ Constructor for the HD_Dialout class - :param HD: reference to an HD parent object + :param can_interface: reference to DenaliMessenger """ - self.__can_interface = hd_object.can_interface + self.__can_interface = can_interface + self.__can_interface.registerReceivingPublicationFunction(channel_id=DenaliChannels.hd_sync_broadcast_ch_id, + message_id=self.MSG_ID_DIALYSATE_UF_DATA, + function=self.receiveDialysateUFDataHandler) + self.DialOutBroadcast = {'state': 'None', + 'target_volume': 0, + 'measured_volume': 0, + 'pwm': 0} def setUFState(self, new_state): """ @@ -65,8 +78,8 @@ return_value = None received_msg = None - if isinstance(rx_total_volume_ml, int) and isinstance(rx_time_min, int) and \ - isinstance(rx_flow_rate, int): + if isinstance(rx_total_volume_ml, int) and isinstance(rx_time_min, int) and \ + isinstance(rx_flow_rate, int): payload = list(rx_total_volume_ml.to_bytes(2, DenaliMessage.BYTE_ORDER)) payload += list(rx_time_min.to_bytes(2, DenaliMessage.BYTE_ORDER)) @@ -84,3 +97,15 @@ return return_value + def receiveDialysateUFDataHandler(self, message): + + payload = DenaliMessage.getPayload(message) + + state_num = int.from_bytes(bytearray(payload[0:2]), byteorder=DenaliMessage.BYTE_ORDER, signed=True) + self.DialOutBroadcast['state'] = DialOutStates(state_num).name + self.DialOutBroadcast['target_volume'] = int.from_bytes(bytearray(payload[2:4]), + byteorder=DenaliMessage.BYTE_ORDER, signed=True) + self.DialOutBroadcast['measured_volume'] = int.from_bytes(bytearray(payload[4:6]), + byteorder=DenaliMessage.BYTE_ORDER, signed=True) + self.DialOutBroadcast['pwm'] = int.from_bytes(bytearray(payload[6:8]), + byteorder=DenaliMessage.BYTE_ORDER, signed=True)