Index: leahi_dialin/ui/dd_messaging.py =================================================================== diff -u -rfdaa21a553063d166174706bff3a6b2e1cb9a9b0 -ra5182b00a866429c2c27e6fba26e17978836805e --- leahi_dialin/ui/dd_messaging.py (.../dd_messaging.py) (revision fdaa21a553063d166174706bff3a6b2e1cb9a9b0) +++ leahi_dialin/ui/dd_messaging.py (.../dd_messaging.py) (revision a5182b00a866429c2c27e6fba26e17978836805e) @@ -528,4 +528,115 @@ 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