Index: leahi_dialin/ui/dd_messaging.py =================================================================== diff -u -rc587268b85d4b16b4102869d2841be84f3a2a23f -r82673b44f61604336cf70c0e72db0e332325c8af --- leahi_dialin/ui/dd_messaging.py (.../dd_messaging.py) (revision c587268b85d4b16b4102869d2841be84f3a2a23f) +++ leahi_dialin/ui/dd_messaging.py (.../dd_messaging.py) (revision 82673b44f61604336cf70c0e72db0e332325c8af) @@ -37,12 +37,13 @@ D43: float, D74: float): """ - Broadcasts DD generate conductivity data - @param D17 (float): Bicarb only conductivity sensor 1 - @param D27 (float): Acid and Bicarb mix conductivity sensor 1 - @param D29 (float): Acid and Bicarb mix conductivity sensor 2 - @param D43 (float): Spent dialysate conductivity sensor - @param D74 (float): Bicarb only conductivity sensor 2 + Broadcasts DD generate conductivity data (Msg ID: 0x1F, 31) + Args: + @param D17 (float): Bicarb only conductivity sensor 1 + @param D27 (float): Acid and Bicarb mix conductivity sensor 1 + @param D29 (float): Acid and Bicarb mix conductivity sensor 2 + @param D43 (float): Spent dialysate conductivity sensor + @param D74 (float): Bicarb only conductivity sensor 2 @return: None """ payload = conversions.float_to_bytearray(D17 ) @@ -69,16 +70,17 @@ D51_spend_pressure : float , is_dial_good : int ): """ - Broadcasts DD generate dialysate data - @param gen_dialysate_exec (int ): Generate dialysate execution state - @param dd_in_progress (int ): Dialysate Delivery in Progress Bool - @param D6_floater_level_1 (int ): Floater level (low, medium and high) - @param D63_bicarb_level (int ): BiCarb Chamber level - @param D46_spent_level (int ): Spent dialysate chamber level - @param D9_hyd_negative_press (float): Hydraulics chamber negative pressure - @param D18_hyd_positive_press (float): Hydraulics chamber positive pressure - @param D51_spend_pressure (float): Spent Dialysate positive pressure - @param is_dial_good (int ): Ready to deliver dialysate or not + Broadcasts DD generate dialysate data (Msg ID: 0x2F, 47) + Args: + @param gen_dialysate_exec (int ): Generate dialysate execution state + @param dd_in_progress (int ): Dialysate Delivery in Progress Bool + @param D6_floater_level_1 (int ): Floater level (low, medium and high) + @param D63_bicarb_level (int ): BiCarb Chamber level + @param D46_spent_level (int ): Spent dialysate chamber level + @param D9_hyd_negative_press (float): Hydraulics chamber negative pressure + @param D18_hyd_positive_press (float): Hydraulics chamber positive pressure + @param D51_spend_pressure (float): Spent Dialysate positive pressure + @param is_dial_good (int ): Ready to deliver dialysate or not @return: None """ payload = conversions.unsigned_integer_to_bytearray(gen_dialysate_exec ) @@ -102,7 +104,7 @@ fpga_id: int, fpga_major: int, fpga_minor: int, fpga_lab: int, compatibility_rev: int): """ - Broadcasts the current dd Version Data + Broadcasts the current dd Version Data (Msg ID: 0x0F, 15) @param major: (uint) - Major version number @param minor: (uint) - Minor version number @param micro: (uint) - Micro version number @@ -137,7 +139,7 @@ def dd_serial(self, serial: str): """ - the dd version serial response message method + the dd version serial response message method (Msg ID: 0x52, 82) @param serial: serial number @return: None """ @@ -149,4 +151,492 @@ message_id=msg_ids.MsgIds.MSG_ID_DD_SERIAL_RESPONSE.value, payload=payload) + self.can_interface.send(message, 0) + + def dd_levels(self, d6Level : int, + d63Level: int, + d46Level: int): + """ + Broadcasts the current DD Level Sensor data (Msg ID: 0x29, 41) + Args: + d6Level (int ): floater switch low, medium and high status + d63Level (int ): bicarb level low or high status + d46Level (int ): Spent dialysate air separation chamber level low or high status + + """ + payload = conversions.unsigned_integer_to_bytearray(d6Level ) + payload += conversions.unsigned_integer_to_bytearray(d63Level ) + payload += conversions.unsigned_integer_to_bytearray(d46Level ) + + message = CAN.DenaliMessage.build_message( + channel_id=CAN.DenaliChannels.dd_sync_broadcast_ch_id, + message_id=msg_ids.MsgIds.MSG_ID_DD_LEVEL_DATA.value, + payload=payload) + + self.can_interface.send(message, 0) + + def dd_pressure(self, m1Pressure : float, + m3Pressure : float, + d9Pressure : float, + d66Pressure : float, + d51Pressure : float, + d18Pressure : float, + d41Pressure : float, + m1PresTemp : float, + m3PresTemp : float, + d9PresTemp : float, + d66PresTemp : float, + d51PresTemp : float, + d18PresTemp : float, + d41PresTemp : float): + """ + Broadcasts the current DD Level Sensor data (Msg ID: 0x1C, 28) + Args: + m1Pressure (float): Water Inlet Input pressure + m3Pressure (float): Water Inlet Output pressure + d9Pressure (float): Hydraulics outlet pressure + d66Pressure (float): Bicarb bag pressure + d51Pressure (float): Spent Dialysate pressure + d18Pressure (float): Fresh Dialysate pressure + d41Pressure (float): Transmembrane pressure + m1PresTemp (float): Water Inlet Input temperature + m3PresTemp (float): Water Inlet Output temperature + d9PresTemp (float): Hydraulics outlet pressure temperature + d66PresTemp (float): Bicarb bag temperature + d51PresTemp (float): Spent Dialysate temperature + d18PresTemp (float): Fresh Dialysate temperature + d41PresTemp (float): Transmembrane temperature + + """ + payload = conversions.float_to_bytearray(m1Pressure ) + payload += conversions.float_to_bytearray(m3Pressure ) + payload += conversions.float_to_bytearray(d9Pressure ) + payload += conversions.float_to_bytearray(d66Pressure ) + payload += conversions.float_to_bytearray(d51Pressure ) + payload += conversions.float_to_bytearray(d18Pressure ) + payload += conversions.float_to_bytearray(d41Pressure ) + payload += conversions.float_to_bytearray(m1PresTemp ) + payload += conversions.float_to_bytearray(m3PresTemp ) + payload += conversions.float_to_bytearray(d9PresTemp ) + payload += conversions.float_to_bytearray(d66PresTemp ) + payload += conversions.float_to_bytearray(d51PresTemp ) + payload += conversions.float_to_bytearray(d18PresTemp ) + payload += conversions.float_to_bytearray(d41PresTemp ) + + message = CAN.DenaliMessage.build_message( + channel_id=CAN.DenaliChannels.dd_sync_broadcast_ch_id, + message_id=msg_ids.MsgIds.MSG_ID_DD_PRESSURES_DATA.value, + payload=payload) + + self.can_interface.send(message, 0) + + def dd_temperature(self, d1Temp : float, + x6Temp : float, + d4Temp : float, + d50Temp : float, + boardTemp : float, + baroTemp : float, + d16CondTemp : float, + d28CondTemp : float, + d30CondTemp : float, + d44CondTemp : float, + d75CondTemp : float, + d4AvgTemp : float, + d50AvgTemp : float, + d28AvgTemp : float, + d30AvgTemp : float): + """ + Broadcasts the current DD Level Sensor data (Msg ID: 0x26, 38) + Args: + d1Temp (float) : Inlet heat exchanger temperature sensor + x6Temp (float) : Outlet heat exchanger temperature sensor + d4Temp (float) : Hydraulics primary heater temperature sensor + d50Temp (float) : Trimmer heater temperature sensor + boardTemp (float) : Board temperature sensor + baroTemp (float) : Barometric temperature sensor + d16CondTemp (float) : D16 temperature value + d28CondTemp (float) : D28 temperature value + d30CondTemp (float) : D30 temperature value + d44CondTemp (float) : D44 temperature value + d75CondTemp (float) : D75 temperature value + d4AvgTemp (float) : D4 moving average temperature value + d50AvgTemp (float) : D50 moving average temperature value + d28AvgTemp (float) : D28 moving average temperature value + d30AvgTemp (float) : D30 moving average temperature value + + """ + payload = conversions.float_to_bytearray(d1Temp ) + payload += conversions.float_to_bytearray(x6Temp ) + payload += conversions.float_to_bytearray(d4Temp ) + payload += conversions.float_to_bytearray(d50Temp ) + payload += conversions.float_to_bytearray(boardTemp ) + payload += conversions.float_to_bytearray(baroTemp ) + payload += conversions.float_to_bytearray(d16CondTemp ) + payload += conversions.float_to_bytearray(d28CondTemp ) + payload += conversions.float_to_bytearray(d30CondTemp ) + payload += conversions.float_to_bytearray(d44CondTemp ) + payload += conversions.float_to_bytearray(d75CondTemp ) + payload += conversions.float_to_bytearray(d4AvgTemp ) + payload += conversions.float_to_bytearray(d50AvgTemp ) + payload += conversions.float_to_bytearray(d28AvgTemp ) + payload += conversions.float_to_bytearray(d30AvgTemp ) + + message = CAN.DenaliMessage.build_message( + channel_id=CAN.DenaliChannels.dd_sync_broadcast_ch_id, + message_id=msg_ids.MsgIds.MSG_ID_DD_TEMPERATURE_DATA.value, + payload=payload) + + self.can_interface.send(message, 0) + + def dd_heaters(self, d5_HeaterDC : float, + d45_HeaterDC : float, + d5_HeaterTargetTemp : float, + d45_HeaterTargetTemp : float, + d5_HeaterState : int , + d45_HeaterState : int , + d5_HeaterControlCounter : int , + d45_HeaterControlCounter: int , + dbg1 : float = 0, + dbg2 : float = 0, + dbg3 : float = 0, + dbg4 : float = 0, + dbg5 : float = 0, + dbg6 : float = 0, + dbg7 : float = 0, + dbg8 : float = 0, + dbg9 : float = 0): + """ + Broadcasts the current DD Heaters data (Msg ID: 0x28, 40) + Args: + d5_HeaterDC (float) : Inlet heat exchanger temperature sensor + d45_HeaterDC (float) : Outlet heat exchanger temperature sensor + d5_HeaterTargetTemp (float) : Hydraulics primary heater temperature sensor + d45_HeaterTargetTemp (float) : Trimmer heater temperature sensor + d5_HeaterState (float) : Board temperature sensor + d45_HeaterState (float) : Barometric temperature sensor + d5_HeaterControlCounter (float) : D16 temperature value + d45_HeaterControlCounter (float) : D28 temperature value + dbg1 (optional) (float) : D28 temperature value + dbg2 (optional) (float) : D28 temperature value + dbg3 (optional) (float) : D30 temperature value + dbg4 (optional) (float) : D44 temperature value + dbg5 (optional) (float) : D75 temperature value + dbg6 (optional) (float) : D4 moving average temperature value + dbg7 (optional) (float) : D50 moving average temperature value + dbg8 (optional) (float) : D28 moving average temperature value + dbg9 (optional) (float) : D30 moving average temperature value + + """ + payload = conversions.float_to_bytearray (d5_HeaterDC ) + payload += conversions.float_to_bytearray (d45_HeaterDC ) + payload += conversions.float_to_bytearray (d5_HeaterTargetTemp ) + payload += conversions.float_to_bytearray (d45_HeaterTargetTemp ) + payload += conversions.unsigned_integer_to_bytearray(d5_HeaterState ) + payload += conversions.unsigned_integer_to_bytearray(d45_HeaterState ) + payload += conversions.unsigned_integer_to_bytearray(d5_HeaterControlCounter ) + payload += conversions.unsigned_integer_to_bytearray(d45_HeaterControlCounter) + payload += conversions.float_to_bytearray (dbg1 ) + payload += conversions.float_to_bytearray (dbg2 ) + payload += conversions.float_to_bytearray (dbg3 ) + payload += conversions.float_to_bytearray (dbg4 ) + payload += conversions.float_to_bytearray (dbg5 ) + payload += conversions.float_to_bytearray (dbg6 ) + payload += conversions.float_to_bytearray (dbg7 ) + payload += conversions.float_to_bytearray (dbg8 ) + payload += conversions.float_to_bytearray (dbg9 ) + + message = CAN.DenaliMessage.build_message( + channel_id=CAN.DenaliChannels.dd_sync_broadcast_ch_id, + message_id=msg_ids.MsgIds.MSG_ID_DD_HEATERS_DATA.value, + payload=payload) + + self.can_interface.send(message, 0) + + def dd_concentrate_pump(self, d11PumpCurrentSetSpeed : float , + d11PumpMeasuredSpeed : float , + d10PumpCurrentSetSpeed : float , + d10PumpMeasuredSpeed : float , + d11PumpTargetRevCount : int , + d11PumpMeasuredRevCount : int , + d10PumpTargetRevCount : int , + d10PumpMeasuredRevCount : int , + d11PumpState : int , + d10PumpState : int , + d11PumpPulseUS : float , + d10PumpPulseUS : float , + d11PumpTargetSpeed : float , + d10PumpTargetSpeed : float , + d11PumpParked : int , + d10PumpParked : int , + d11PumpParkFault : int , + d10PumpParkFault : int , + d76PumpTargetSpeed : float , + d76PumpCurrentSetSpeed : float , + d76PumpMeasuredSpeed : float , + d76PumpTargetRevCount : int , + d76PumpMeasuredRevCount : int , + d76PumpState : int , + d76PumpPulseUS : float ): + """ + Broadcasts the current DD Concentrate Pumps data (Msg ID: 0x25, 37) + Args: + d11PumpCurrentSetSpeed (float) : Concentrate pump D11_Pump current set speed + d11PumpMeasuredSpeed (float) : Concentrate pump D11_Pump measured speed + d10PumpCurrentSetSpeed (float) : Concentrate pump D10_Pump current set speed + d10PumpMeasuredSpeed (float) : Concentrate pump D10_Pump measured speed + d11PumpTargetRevCount (int ) : Concentrate pump D11_Pump target revolution count + d11PumpMeasuredRevCount (int ) : Concentrate pump D11_Pump measured revolution count + d10PumpTargetRevCount (int ) : Concentrate pump D10_Pump target revolution count + d10PumpMeasuredRevCount (int ) : Concentrate pump D10_Pump measured revolution count + d11PumpState (int ) : Concentrate pump D11_Pump current state + d10PumpState (int ) : Concentrate pump D10_Pump current state + d11PumpPulseUS (float) : Concentrate pump D11_Pump pulse in microseconds + d10PumpPulseUS (float) : Concentrate pump D10_Pump pulse in microseconds + d11PumpTargetSpeed (float) : Concentrate pump D11_Pump target speed + d10PumpTargetSpeed (float) : Concentrate pump D10_Pump target speed + d11PumpParked (int ) : Concentrate pump D11_Pump parked status + d10PumpParked (int ) : Concentrate pump D10_Pump parked status + d11PumpParkFault (int ) : Concentrate pump D11_Pump park fault status + d10PumpParkFault (int ) : Concentrate pump D10_Pump park fault status + d76PumpTargetSpeed (float) : Concentrate pump D76_Pump target speed + d76PumpCurrentSetSpeed (float) : Concentrate pump D76_Pump current set speed + d76PumpMeasuredSpeed (float) : Concentrate pump D76_Pump measured speed + d76PumpTargetRevCount (int ) : Concentrate pump D76_Pump target revolution count + d76PumpMeasuredRevCount (int ) : Concentrate pump D76_Pump measured revolution cou + d76PumpState (int ) : Concentrate pump D76_Pump current state + d76PumpPulseUS (float) : Concentrate pump D76_Pump pulse in microseconds + + """ + payload = conversions.float_to_bytearray (d11PumpCurrentSetSpeed ) + payload += conversions.float_to_bytearray (d11PumpMeasuredSpeed ) + payload += conversions.float_to_bytearray (d10PumpCurrentSetSpeed ) + payload += conversions.float_to_bytearray (d10PumpMeasuredSpeed ) + payload += conversions.unsigned_integer_to_bytearray(d11PumpTargetRevCount ) + payload += conversions.unsigned_integer_to_bytearray(d11PumpMeasuredRevCount ) + payload += conversions.unsigned_integer_to_bytearray(d10PumpTargetRevCount ) + payload += conversions.unsigned_integer_to_bytearray(d10PumpMeasuredRevCount ) + payload += conversions.unsigned_integer_to_bytearray(d11PumpState ) + payload += conversions.unsigned_integer_to_bytearray(d10PumpState ) + payload += conversions.float_to_bytearray (d11PumpPulseUS ) + payload += conversions.float_to_bytearray (d10PumpPulseUS ) + payload += conversions.float_to_bytearray (d11PumpTargetSpeed ) + payload += conversions.float_to_bytearray (d10PumpTargetSpeed ) + payload += conversions.unsigned_integer_to_bytearray(d11PumpParked ) + payload += conversions.unsigned_integer_to_bytearray(d10PumpParked ) + payload += conversions.unsigned_integer_to_bytearray(d11PumpParkFault ) + payload += conversions.unsigned_integer_to_bytearray(d10PumpParkFault ) + payload += conversions.float_to_bytearray (d76PumpTargetSpeed ) + payload += conversions.float_to_bytearray (d76PumpCurrentSetSpeed ) + payload += conversions.float_to_bytearray (d76PumpMeasuredSpeed ) + payload += conversions.unsigned_integer_to_bytearray(d76PumpTargetRevCount ) + payload += conversions.unsigned_integer_to_bytearray(d76PumpMeasuredRevCount ) + payload += conversions.unsigned_integer_to_bytearray(d76PumpState ) + payload += conversions.float_to_bytearray (d76PumpPulseUS ) + + message = CAN.DenaliMessage.build_message( + channel_id=CAN.DenaliChannels.dd_sync_broadcast_ch_id, + message_id=msg_ids.MsgIds.MSG_ID_DD_CONCENTRATE_PUMP_DATA.value, + payload=payload) + + self.can_interface.send(message, 0) + + + def dd_dialysate_pump(self, d12PumpTargetRPM : float , + d48PumpTargetRPM : float , + d12PumpMeasuredSpeed : float , + d48PumpMeasuredSpeed : float , + d12PumpCurrentSpeed : float , + d48PumpCurrentSpeed : float , + d12PumpState : int , + d48PumpState : int , + d12PumpTargetPressure : float , + d48PumpTargetPressure : float , + d12PumpMeasuredPressure : float , + d48PumpMeasuredPressure : float , + d12PumpMeasuredCurrent : float , + d48PumpMeasuredCurrent : float , + d12PumpControl : int , + d48PumpControl : int , + d12PumpDirErrCnt : int , + d48PumpDirErrCnt : int , + d12PumpMeasuredDir : int , + d48PumpMeasuredDir : int ): + """ + Broadcasts the current DD Dialysate Pump data (Msg ID: 0x27, 39) + Args: + d12PumpTargetRPM (float) : Dialysate pump D11_Pump current set speed + d48PumpTargetRPM (float) : Dialysate pump D11_Pump measured speed + d12PumpMeasuredSpeed (float) : Dialysate pump D10_Pump current set speed + d48PumpMeasuredSpeed (float) : Dialysate pump D10_Pump measured speed + d12PumpCurrentSpeed (float) : Dialysate pump D11_Pump target revolution count + d48PumpCurrentSpeed (float) : Dialysate pump D11_Pump measured revolution count + d12PumpState (int ) : Dialysate pump D10_Pump target revolution count + d48PumpState (int ) : Dialysate pump D10_Pump measured revolution count + d12PumpTargetPressure (float) : Dialysate pump D11_Pump current state + d48PumpTargetPressure (float) : Dialysate pump D10_Pump current state + d12PumpMeasuredPressure (float) : Dialysate pump D11_Pump pulse in microseconds + d48PumpMeasuredPressure (float) : Dialysate pump D10_Pump pulse in microseconds + d12PumpMeasuredCurrent (float) : Dialysate pump D11_Pump target speed + d48PumpMeasuredCurrent (float) : Dialysate pump D10_Pump target speed + d12PumpControl (int ) : Dialysate pump D11_Pump parked status + d48PumpControl (int ) : Dialysate pump D10_Pump parked status + d12PumpDirErrCnt (int ) : Dialysate pump D11_Pump park fault status + d48PumpDirErrCnt (int ) : Dialysate pump D10_Pump park fault status + d12PumpMeasuredDir (int ) : Dialysate pump D76_Pump target speed + d48PumpMeasuredDir (int ) : Dialysate pump D76_Pump current set speed + + """ + payload = conversions.float_to_bytearray (d12PumpTargetRPM ) + payload += conversions.float_to_bytearray (d48PumpTargetRPM ) + payload += conversions.float_to_bytearray (d12PumpMeasuredSpeed ) + payload += conversions.float_to_bytearray (d48PumpMeasuredSpeed ) + payload += conversions.float_to_bytearray (d12PumpCurrentSpeed ) + payload += conversions.float_to_bytearray (d48PumpCurrentSpeed ) + payload += conversions.unsigned_integer_to_bytearray(d12PumpState ) + payload += conversions.unsigned_integer_to_bytearray(d48PumpState ) + payload += conversions.float_to_bytearray (d12PumpTargetPressure ) + payload += conversions.float_to_bytearray (d48PumpTargetPressure ) + payload += conversions.float_to_bytearray (d12PumpMeasuredPressure ) + payload += conversions.float_to_bytearray (d48PumpMeasuredPressure ) + payload += conversions.float_to_bytearray (d12PumpMeasuredCurrent ) + payload += conversions.float_to_bytearray (d48PumpMeasuredCurrent ) + payload += conversions.unsigned_integer_to_bytearray(d12PumpControl ) + payload += conversions.unsigned_integer_to_bytearray(d48PumpControl ) + payload += conversions.unsigned_integer_to_bytearray(d12PumpDirErrCnt ) + payload += conversions.unsigned_integer_to_bytearray(d48PumpDirErrCnt ) + payload += conversions.unsigned_integer_to_bytearray(d12PumpMeasuredDir ) + payload += conversions.unsigned_integer_to_bytearray(d48PumpMeasuredDir ) + + message = CAN.DenaliMessage.build_message( + channel_id=CAN.DenaliChannels.dd_sync_broadcast_ch_id, + message_id=msg_ids.MsgIds.MSG_ID_DIALYSATE_PUMPS_DATA.value, + payload=payload) + + self.can_interface.send(message, 0) + + def dd_blood_leak(self, blood_leak: int): + """ + Broadcasts the current DD Level Sensor data (Msg ID: 0x60, 96) + Args: + blood_leak (int ): Blood Leak status + + """ + payload = conversions.unsigned_integer_to_bytearray(blood_leak ) + + message = CAN.DenaliMessage.build_message( + channel_id=CAN.DenaliChannels.dd_sync_broadcast_ch_id, + message_id=msg_ids.MsgIds.MSG_ID_DD_BLOOD_LEAK_DATA.value, + payload=payload) + + self.can_interface.send(message, 0) + + def dd_valves(self, D14_VALV : bool, + D52_VALV : bool, + D8_VALV : bool, + D54_VALV : bool, + D53_VALV : bool, + D34_VALV : bool, + D64_VALV : bool, + D31_VALV : bool, + D65_VALV : bool, + D35_VALV : bool, + D40_VALV : bool, + D47_VALV : bool, + D3_VALV : bool, + M4_VALV : bool, + RSRVD_SPACE1 : bool, + RSRVD_SPACE2 : bool, + D23_VALV : bool, + D19_VALV : bool, + D25_VALV : bool, + D26_VALV : bool, + D24_VALV : bool, + D20_VALV : bool, + D21_VALV : bool, + D22_VALV : bool, + D69_VALV : bool, + D71_VALV : bool, + D70_VALV : bool, + D72_VALV : bool, + valvesensedState: list): + """ + Broadcasts the current DD Valve data (Msg ID: 0x1B, 27) + Args: + D14_VALV (bool ): Valve Hydraulics Outlet (D14) + D52_VALV (bool ): Valve Thermal Disinfect (D52) + D8_VALV (bool ): Valve Hydraulics Bypass (D8) + D54_VALV (bool ): Valve Rinse Port (D54) + D53_VALV (bool ): Valve Drain (D53) + D34_VALV (bool ): Valve Dialyzer Bypass (D34) + D64_VALV (bool ): Valve Purge 1 (D64) + D31_VALV (bool ): Valve Pressure Test (D31) + D65_VALV (bool ): Valve DryBcarb Inlet (D65) + D35_VALV (bool ): Valve Dialyzer Inlet (D35) + D40_VALV (bool ): Valve Dialyzer Outlet (D40) + D47_VALV (bool ): Valve Dialysate Out Purge 2 (D47) + D3_VALV (bool ): Valve Hydraulics Inlet (D3) + M4_VALV (bool ): Valve Water Inlet (M4) + RSRVD_SPACE1 (bool ): This space has been reserved + RSRVD_SPACE2 (bool ): This space has been reserved + D23_VALV (bool ): Balancing chamber Valve 1 (D23) + D19_VALV (bool ): Balancing chamber Valve 2 (D19) + D25_VALV (bool ): Balancing chamber Valve 3 (D25) + D26_VALV (bool ): Balancing chamber Valve 7 (D26) + D24_VALV (bool ): Balancing chamber Valve 5 (D24) + D20_VALV (bool ): Balancing chamber Valve 6 (D20) + D21_VALV (bool ): Balancing chamber Valve 4 (D21) + D22_VALV (bool ): Balancing chamber Valve 8 (D22) + D69_VALV (bool ): Ultrafiltration Valve 1 Inlet (D69) + D71_VALV (bool ): Ultrafiltration Valve 2 Inlet (D71) + D70_VALV (bool ): Ultrafiltration Valve 1 Outlet (D70) + D72_VALV (bool ): Ultrafiltration Valve 2 Outlet (D72) + valvesensedState[28] (list[int] ): Sense state of valves + """ + hydraulic_valves = (D14_VALV << 0 )|\ + (D52_VALV << 1 )|\ + (D8_VALV << 2 )|\ + (D54_VALV << 3 )|\ + (D53_VALV << 4 )|\ + (D34_VALV << 5 )|\ + (D64_VALV << 6 )|\ + (D31_VALV << 7 )|\ + (D65_VALV << 8 )|\ + (D35_VALV << 9 )|\ + (D40_VALV << 10)|\ + (D47_VALV << 11)|\ + (D3_VALV << 12)|\ + (M4_VALV << 13)|\ + (RSRVD_SPACE1 << 14)|\ + (RSRVD_SPACE2 << 15) + + balancing_chamber_valves = (D23_VALV << 0 ) | \ + (D19_VALV << 1 )|\ + (D25_VALV << 2 )|\ + (D26_VALV << 3 )|\ + (D24_VALV << 4 )|\ + (D20_VALV << 5 )|\ + (D21_VALV << 6 )|\ + (D22_VALV << 7 ) + + # final 4 bits are reserved and left as 0 + ultrafiltration_valves = (D69_VALV << 0 )|\ + (D71_VALV << 1 )|\ + (D70_VALV << 2 )|\ + (D72_VALV << 3 )|\ + (0 << 4 )|\ + (0 << 5 )|\ + (0 << 6 )|\ + (0 << 7 ) + + payload = conversions.unsigned_short_to_bytearray(hydraulic_valves ) + payload += conversions.unsigned_byte_to_bytearray (balancing_chamber_valves ) + payload += conversions.unsigned_byte_to_bytearray (ultrafiltration_valves ) + for i in range(len(valvesensedState)): + payload += conversions.unsigned_byte_to_bytearray(valvesensedState[i]) + + message = CAN.DenaliMessage.build_message( + channel_id=CAN.DenaliChannels.dd_sync_broadcast_ch_id, + message_id=msg_ids.MsgIds.MSG_ID_DD_VALVES_STATES_DATA.value, + payload=payload) + self.can_interface.send(message, 0) \ No newline at end of file