Index: HD/PressureOcclusion.py =================================================================== diff -u -rc5826238ca4b80671231a9c564af3ea01b9be06f -r0da0106eca868b9144298c60911710b3414a5837 --- HD/PressureOcclusion.py (.../PressureOcclusion.py) (revision c5826238ca4b80671231a9c564af3ea01b9be06f) +++ HD/PressureOcclusion.py (.../PressureOcclusion.py) (revision 0da0106eca868b9144298c60911710b3414a5837) @@ -16,8 +16,7 @@ ############################################################################ from DialIn.CoreCANProtocol import (DenaliMessage, DenaliChannels) -from .utils import integer2ByteArray, float2ByteArray -from .HemodialysisDevice import HD +from utils import integer_to_byte_array, float_to_byte_array, RESET import struct @@ -63,37 +62,21 @@ channel_id = DenaliChannels.hd_sync_broadcast_ch_id msg_id = self.MSG_ID_HD_PRESSURE_OCCLUSION_DATA self.can_interface.register_receiving_publication_function(channel_id, msg_id, - self.handlerPresOcclSyncFunction) + self.handler_pressure_occlusion_sync) self.arterialPressure = 0 self.venousPressure = 0.0 self.bloodPumpOcclusion = 0.0 self.dialysateInletPumpOcclusion = 0.0 self.dialysateOutletPumpOcclusion = 0.0 - def test_can_message(self, seq): - zero = integer2ByteArray(0) - seq1 = integer2ByteArray(seq) - seq2 = integer2ByteArray(seq+1) - seq3 = integer2ByteArray(seq+2) - seq4 = integer2ByteArray(seq+3) - seq5 = integer2ByteArray(seq+4) - - payload = seq1 + zero + seq2 + zero + seq3 + zero + seq4 + zero + seq5 - - message = DenaliMessage.build_message(channel_id=DenaliChannels.dialin_to_hd_ch_id, - message_id=6, - payload=payload) - - self.can_interface.send(message, 0) - - def handlerPresOcclSyncFunction(self, message): + def handler_pressure_occlusion_sync(self, message): """ - Handles published pressure & occlusion data messages. Pressure data are captured - for reference. + Handles published pressure & occlusion data messages. Pressure data are captured + for reference. - \param message: published pressure & occlusion data message - \returns none + \param message: published pressure & occlusion data message + \returns none """ art = struct.unpack('f', bytearray( @@ -113,7 +96,7 @@ self.dialysateInletPumpOcclusion = dpi[0] self.dialysateOutletPumpOcclusion = dpo[0] - def CmdArterialPressureMeasuredOverride(self, reset, pres): + def cmd_arterial_pressure_measured_override(self, reset, pres): """ Constructs and sends the measured arterial pressure override command @@ -122,8 +105,8 @@ \returns 1 if successful, zero otherwise """ - rst = integer2ByteArray(reset) - prs = float2ByteArray(pres) + rst = integer_to_byte_array(reset) + prs = float_to_byte_array(pres) payload = rst + prs message = DenaliMessage.build_message(channel_id=DenaliChannels.dialin_to_hd_ch_id, @@ -137,7 +120,7 @@ # If there is content... if received_message is not None: - if reset == HD.RESET: + if reset == RESET: str_res = "reset back to normal. " else: str_res = str(pres) + " mmHg. " @@ -149,9 +132,7 @@ print("Timeout!!!!") return False - - - def CmdVenousPressureMeasuredOverride(self, reset, pres): + def cmd_venous_pressure_measured_override(self, reset, pres): """ Constructs and sends the measured venous pressure \n override command. @@ -161,8 +142,8 @@ \returns 1 if successful, zero otherwise """ - rst = integer2ByteArray(reset) - prs = float2ByteArray(pres) + rst = integer_to_byte_array(reset) + prs = float_to_byte_array(pres) payload = rst + prs message = DenaliMessage.build_message(channel_id=DenaliChannels.dialin_to_hd_ch_id, @@ -176,7 +157,7 @@ # If there is content... if received_message is not None: - if reset == HD.RESET: + if reset == RESET: str_res = "reset back to normal. " else: str_res = str(pres) + " mmHg. " @@ -188,7 +169,7 @@ print("Timeout!!!!") return False - def CmdBloodPumpMeasuredOcclusionOverride(self, reset, occl): + def cmd_blood_pump_measured_occlusion_override(self, reset, occl): """ Constructs and sends the measured blood pump occlusion pressure override command @@ -197,8 +178,8 @@ \returns 1 if successful, zero otherwise """ - rst = integer2ByteArray(reset) - occ = float2ByteArray(occl) + rst = integer_to_byte_array(reset) + occ = float_to_byte_array(occl) payload = rst + occ message = DenaliMessage.build_message(channel_id=DenaliChannels.dialin_to_hd_ch_id, @@ -212,7 +193,7 @@ # If there is content... if received_message is not None: - if reset == HD.RESET: + if reset == RESET: str_res = "reset back to normal. " else: str_res = str(occl) + " mmHg. " @@ -224,7 +205,7 @@ print("Timeout!!!!") return False - def CmdDialysateInletPumpMeasuredOcclusionOverride(self, reset, occl): + def cmd_dialysate_inlet_pump_measured_occlusion_override(self, reset, occl): """ Constructs and sends the measured dialysate inlet pump occlusion pressure override \n command. @@ -234,8 +215,8 @@ \returns 1 if successful, zero otherwise """ - rst = integer2ByteArray(reset) - occ = float2ByteArray(occl) + rst = integer_to_byte_array(reset) + occ = float_to_byte_array(occl) payload = rst + occ message = DenaliMessage.build_message(channel_id=DenaliChannels.dialin_to_hd_ch_id, @@ -249,7 +230,7 @@ # If there is content... if received_message is not None: - if reset == HD.RESET: + if reset == RESET: str_res = "reset back to normal. " else: str_res = str(occl) + " mmHg. " @@ -261,7 +242,7 @@ print("Timeout!!!!") return False - def CmdDialysateOutletPumpMeasuredOcclusionOverride(self, reset, occl): + def cmd_dialysate_outlet_pump_measured_occlusion_override(self, reset, occl): """ Constructs and sends the measured dialysate outlet pump occlusion pressure override \n command. @@ -271,8 +252,8 @@ \returns 1 if successful, zero otherwise """ - rst = integer2ByteArray(reset) - occ = float2ByteArray(occl) + rst = integer_to_byte_array(reset) + occ = float_to_byte_array(occl) payload = rst + occ message = DenaliMessage.build_message(channel_id=DenaliChannels.dialin_to_hd_ch_id, @@ -286,7 +267,7 @@ # If there is content... if received_message is not None: - if reset == HD.RESET: + if reset == RESET: str_res = "reset back to normal. " else: str_res = str(occl) + " mmHg. " @@ -298,7 +279,7 @@ print("Timeout!!!!") return False - def CmdPressureOcclusionBroadcastIntervalOverride(self, reset, ms): + def cmd_pressure_occlusion_broadcast_interval_override(self, reset, ms): """ Constructs and sends the pressure/occlusion broadcast interval override command @@ -307,8 +288,8 @@ \returns 1 if successful, zero otherwise """ - rst = integer2ByteArray(reset) - mis = integer2ByteArray(ms) + rst = integer_to_byte_array(reset) + mis = integer_to_byte_array(ms) payload = rst + mis message = DenaliMessage.build_message(channel_id=DenaliChannels.dialin_to_hd_ch_id, @@ -322,7 +303,7 @@ # If there is content... if received_message is not None: - if reset == HD.RESET: + if reset == RESET: str_res = "reset back to normal: " else: str_res = str(ms) + " ms: "