Index: dialin/ui/crc.py =================================================================== diff -u -r551e0a9620126efd158e93c45e9ed84ee6ec85fb -rf990c9bb863683c74bbe78c71932a14d7cf35422 --- dialin/ui/crc.py (.../crc.py) (revision 551e0a9620126efd158e93c45e9ed84ee6ec85fb) +++ dialin/ui/crc.py (.../crc.py) (revision f990c9bb863683c74bbe78c71932a14d7cf35422) @@ -15,48 +15,49 @@ ############################################################################ crc8_table = ( - 0, 49, 98, 83, 196, 245, 166, 151, 185, 136, 219, 234, 125, 76, 31, 46, - 67, 114, 33, 16, 135, 182, 229, 212, 250, 203, 152, 169, 62, 15, 92, 109, + 0, 49, 98, 83, 196, 245, 166, 151, 185, 136, 219, 234, 125, 76, 31, 46, + 67, 114, 33, 16, 135, 182, 229, 212, 250, 203, 152, 169, 62, 15, 92, 109, 134, 183, 228, 213, 66, 115, 32, 17, 63, 14, 93, 108, 251, 202, 153, 168, 197, 244, 167, 150, 1, 48, 99, 82, 124, 77, 30, 47, 184, 137, 218, 235, - 61, 12, 95, 110, 249, 200, 155, 170, 132, 181, 230, 215, 64, 113, 34, 19, + 61, 12, 95, 110, 249, 200, 155, 170, 132, 181, 230, 215, 64, 113, 34, 19, 126, 79, 28, 45, 186, 139, 216, 233, 199, 246, 165, 148, 3, 50, 97, 80, 187, 138, 217, 232, 127, 78, 29, 44, 2, 51, 96, 81, 198, 247, 164, 149, 248, 201, 154, 171, 60, 13, 94, 111, 65, 112, 35, 18, 133, 180, 231, 214, 122, 75, 24, 41, 190, 143, 220, 237, 195, 242, 161, 144, 7, 54, 101, 84, - 57, 8, 91, 106, 253, 204, 159, 174, 128, 177, 226, 211, 68, 117, 38, 23, + 57, 8, 91, 106, 253, 204, 159, 174, 128, 177, 226, 211, 68, 117, 38, 23, 252, 205, 158, 175, 56, 9, 90, 107, 69, 116, 39, 22, 129, 176, 227, 210, 191, 142, 221, 236, 123, 74, 25, 40, 6, 55, 100, 85, 194, 243, 160, 145, - 71, 118, 37, 20, 131, 178, 225, 208, 254, 207, 156, 173, 58, 11, 88, 105, - 4, 53, 102, 87, 192, 241, 162, 147, 189, 140, 223, 238, 121, 72, 27, 42, + 71, 118, 37, 20, 131, 178, 225, 208, 254, 207, 156, 173, 58, 11, 88, 105, + 4, 53, 102, 87, 192, 241, 162, 147, 189, 140, 223, 238, 121, 72, 27, 42, 193, 240, 163, 146, 5, 52, 103, 86, 120, 73, 26, 43, 188, 141, 222, 239, 130, 179, 224, 209, 70, 119, 36, 21, 59, 10, 89, 104, 255, 206, 157, 172 ) -def crc8(vData): + +def crc8(data): """ generates crc8 for the data vData - :param vData: byte of data - :return: (int) the crc code + @param data: byte of data + @return: (int) the crc code """ crc = 0 - l = len(vData) + length = len(data) i = 0 - while l > 0: - crc = crc8_table[vData[i] ^ crc ] - l = l - 1 + while length > 0: + crc = crc8_table[data[i] ^ crc] + length = length - 1 i = i + 1 return crc -def calcCRC8(vString, vDelimiter='.'): +def calc_crc8(vstring, vdelimiter='.'): """ calculates crc8 for each character in string vString - :param vString: (str) the bytes of data - :param vDelimiter: (character) the string delimiter - :return: the hex formatted crc of the given string + @param vstring: (str) the bytes of data + @param vdelimiter: (character) the string delimiter + @return: the hex formatted crc of the given string """ - str = vString.replace(vDelimiter, '') - ba = bytearray.fromhex(str) + new_str = vstring.replace(vdelimiter, '') + ba = bytearray.fromhex(new_str) x = '{:02X}'.format(crc8(ba), 'x') return x Index: dialin/ui/dg_simulator.py =================================================================== diff -u -rebf0a72a1a1a52f3cfe20975de4857201275888c -rf990c9bb863683c74bbe78c71932a14d7cf35422 --- dialin/ui/dg_simulator.py (.../dg_simulator.py) (revision ebf0a72a1a1a52f3cfe20975de4857201275888c) +++ dialin/ui/dg_simulator.py (.../dg_simulator.py) (revision f990c9bb863683c74bbe78c71932a14d7cf35422) @@ -25,10 +25,10 @@ class DGSimulator(AbstractSubSystem): instance_count = 0 - def __init__(self, can_interface:str="can0", - log_level:str=None, - console_out:bool=False, - passive_mode:bool=False): + def __init__(self, can_interface: str = "can0", + log_level: str = None, + console_out: bool = False, + passive_mode: bool = False): super().__init__() self._log_manager = LogManager(log_level=log_level, log_filepath=self.__class__.__name__ + ".log") @@ -83,11 +83,10 @@ self.can_interface.send(message, 0) - def _handler_system_usage_response(self, message: dict) -> None: + def _handler_system_usage_response(self) -> None: """ Handles a request for system usage - @param message: (dict) the message @return: None """ self.logger.debug("Handling request for system usage.") @@ -107,21 +106,20 @@ @param message: (dict) the message content @return: None """ - START_POS = DenaliMessage.PAYLOAD_START_INDEX - END_POS = START_POS + 4 epoch = struct.unpack('i', bytearray( - message['message'][START_POS:END_POS]))[0] + message['message'][MsgFieldPositions.START_POS_FIELD_1:MsgFieldPositions.END_POS_FIELD_1]))[0] self.logger.debug("DG: Request to set the DG epoch to {0}".format(epoch)) self.cmd_send_set_rtc_response(YES, 0) - def cmd_send_set_rtc_response(self, response, reason): + def cmd_send_set_rtc_response(self, response: int, reason: int) -> None: """ Sends a set RTC response message - @param response: (int) 0=NO, 1=YES + @param response: integer - 0=NO, 1=YES + @param reason: integer - the rejection reason @return: None """ self.logger.debug("DG: Sending response {0} reason {1}".format(response, reason)) @@ -135,10 +133,10 @@ self.can_interface.send(message, 0) - def cmd_send_checkin_dg(self): + def cmd_send_checkin_dg(self) -> None: """ check-in (keep alive) message from DG - :return: none + @return: none """ payload = ["A5", "01", "00", "06", "00", "00", "76", "00"] @@ -149,193 +147,197 @@ self.can_interface.send(message, 0) - def cmd_set_dg_ro_pump_data(self, vSetPtPressure, vFlowRate, vPWM): + def cmd_set_dg_ro_pump_data(self, set_pt_pressure: int, flow_rate: float, pwm: float) -> None: """ the DG RO Pump Data message setter/sender method | MSG | CAN ID | Box | Type | Ack | Src | Dst | Description | #1:(U32) | #2:(F32) | #3:(F32) | |:----:|:------:|:---:|:------:|:---:|:---:|:---:|:-----------: |:--: |:--: |:--: | - |0x1F00| 0x080 | 8 | 1 Hz | N | DG | All | DG RO Pump Data | \ref Data::mPressure | \ref Data::mFlowRate | \ref Data::mPWM | :param vSetPtPressure: + |0x1F00| 0x080 | 8 | 1 Hz | N | DG | All | DG RO Pump Data | \ref Data::mPressure | \ref Data::mFlowRate | \ref Data::mPWM | @param vSetPtPressure: - :param vSetPtPressure: (int) set Point Pressure - :param vFlowRate: (float) Flow Rate - :param vPWM: (float) PWM - :return: none + @param set_pt_pressure: (int) set Point Pressure + @param flow_rate: float - Flow Rate + @param pwm: float - PWM + @return: none """ - payload = integer_to_bytearray(vSetPtPressure) - payload += float_to_bytearray(vFlowRate) - payload += float_to_bytearray(vPWM) + payload = integer_to_bytearray(set_pt_pressure) + payload += float_to_bytearray(flow_rate) + payload += float_to_bytearray(pwm) message = DenaliMessage.build_message(channel_id=DenaliChannels.dg_sync_broadcast_ch_id, message_id=MsgIds.MSG_ID_RO_PUMP_DATA.value, payload=payload) self.can_interface.send(message, 0) - def cmd_set_dg_pressures_data(self, vROInletPSI, vROOutletPSI, vDrainInletPSI, vDrainOutletPSI): + def cmd_set_dg_pressures_data(self, ro_inlet_pressure: float, ro_outlet_pressure: float, + drain_inlet_pressure: float, drain_outlet_pressure: float) -> None: """ the DG Pressures Data message setter/sender method | MSG | CAN ID | Box | Type | Ack | Src | Dst | Description | #1:(F32) | #2:(F32) | #3:(F32) | #4:(F32) | |:----:|:------:|:---:|:------:|:---:|:---:|:---:|:-----------: |:--: |:--: |:--: |:--: | |0x2000| 0x080 | 8 | 1 Hz | N | DG | All | DG Pressures Data | \ref Data::mROInletPSI | \ref Data::mROOutletPSI | \ref Data::mDrainInletPSI | \ref Data::mDrainOutletPSI | - :param vROInletPSI: (float) RO Inlet PSI - :param vROOutletPSI: (float) RO Outlet PSI - :param vDrainInletPSI: (float) Drain Inlet PSI - :param vDrainOutletPSI: (float) Drain Outlet PSI - :return: none + @param ro_inlet_pressure: float - RO Inlet PSI + @param ro_outlet_pressure: float - RO Outlet PSI + @param drain_inlet_pressure: float - Drain Inlet PSI + @param drain_outlet_pressure: float - Drain Outlet PSI + @return: none """ - payload = float_to_bytearray(vROInletPSI) - payload += float_to_bytearray(vROOutletPSI) - payload += float_to_bytearray(vDrainInletPSI) - payload += float_to_bytearray(vDrainOutletPSI) + payload = float_to_bytearray(ro_inlet_pressure) + payload += float_to_bytearray(ro_outlet_pressure) + payload += float_to_bytearray(drain_inlet_pressure) + payload += float_to_bytearray(drain_outlet_pressure) message = DenaliMessage.build_message(channel_id=DenaliChannels.dg_sync_broadcast_ch_id, message_id=MsgIds.MSG_ID_DG_PRESSURES_DATA.value, payload=payload) self.can_interface.send(message, 0) - def cmd_set_dg_drain_pump_data(self, vSetPtRPM, vDACValue): + def cmd_set_dg_drain_pump_data(self, set_pt_pwm: int, dac_value: int) -> None: """ the DG Drain Pump Data message setter/sender method | MSG | CAN ID | Box | Type | Ack | Src | Dst | Description | #1:(U32) | #2:(U32) | |:----:|:------:|:---:|:------:|:---:|:---:|:---:|:-----------: |:--: |:--: | |0x2400| 0x080 | 8 | 1 Hz | N | DG | All | DG Drain Pump Data | \ref Data::mRPM | \ref Data::mDAC | - :param vSetPtRPM: (int) Set Point RPM - :param vDACValue: (int) DAC Value - :return: none + @param set_pt_pwm: integer - Set Point RPM + @param dac_value: integer - DAC Value + @return: none """ - payload = integer_to_bytearray(vSetPtRPM) - payload += integer_to_bytearray(vDACValue) + payload = integer_to_bytearray(set_pt_pwm) + payload += integer_to_bytearray(dac_value) message = DenaliMessage.build_message(channel_id=DenaliChannels.dg_sync_broadcast_ch_id, message_id=MsgIds.MSG_ID_DRAIN_PUMP_DATA.value, payload=payload) self.can_interface.send(message, 0) - def cmd_set_dg_operation_mode(self, vDGOpMode): + def cmd_set_dg_operation_mode(self, dg_op_mode: int) -> None: """ the DG Operation Mode Data message setter/sender method | MSG | CAN ID | Box | Type | Ack | Src | Dst | Description | #1:(U32) | |:----:|:------:|:---:|:------:|:---:|:---:|:---:|:-----------: |:--: | |0x2700| 0x080 | 8 | 1 Hz | N | DG | All | DG Operation Mode Data | \ref Data::mOpMode | - :param vDGOpMode: (int) DG Operation Mode - :return: none + @param dg_op_mode: integer - DG Operation Mode + @return: none """ - payload = integer_to_bytearray(vDGOpMode) + payload = integer_to_bytearray(dg_op_mode) message = DenaliMessage.build_message(channel_id=DenaliChannels.dg_sync_broadcast_ch_id, message_id=MsgIds.MSG_ID_DG_OP_MODE.value, payload=payload) self.can_interface.send(message, 0) - def cmd_set_dg_reservoir_data(self, vActiveReservoir, vFillToVolML, vDrainToVolML): + def cmd_set_dg_reservoir_data(self, active_reservoir: int, fill_to_vol_ml: int, drain_to_vol_ml: int) -> None: """ the DG Reservoir Data message setter/sender method | MSG | CAN ID | Box | Type | Ack | Src | Dst | Description | #1:(U32) | #2:(U32) | #3:(U32) | |:----:|:------:|:---:|:------:|:---:|:---:|:---:|:-----------: |:--: |:--: |:--: | |0x2800| 0x080 | 8 | 1 Hz | N | DG | All | DG Reservoir Data | \ref Data::mActiveReservoir | \ref Data::mFillToVol | \ref Data::mDrainToVol | - :param vActiveReservoir: (int) Active Reservoir - :param vFillToVolML: (int) Fill To Volume ML - :param vDrainToVolML: (int) Drain To Vol ML - :return: none + @param active_reservoir: integer - Active Reservoir + @param fill_to_vol_ml: integer - Fill To Volume ML + @param drain_to_vol_ml: integer - Drain To Vol ML + @return: none """ - payload = integer_to_bytearray(vActiveReservoir) - payload += integer_to_bytearray(vFillToVolML) - payload += integer_to_bytearray(vDrainToVolML) + payload = integer_to_bytearray(active_reservoir) + payload += integer_to_bytearray(fill_to_vol_ml) + payload += integer_to_bytearray(drain_to_vol_ml) message = DenaliMessage.build_message(channel_id=DenaliChannels.dg_sync_broadcast_ch_id, message_id=MsgIds.MSG_ID_DG_RESERVOIR_DATA.value, payload=payload) self.can_interface.send(message, 0) - def cmd_set_dg_valves_states(self, vValvesStates): + def cmd_set_dg_valves_states(self, valves_states): """ the DG Valves States Data message setter/sender method | MSG | CAN ID | Box | Type | Ack | Src | Dst | Description | #1:(U16) | |:----:|:------:|:---:|:------:|:---:|:---:|:---:|:-----------: |:--: | |0x2A00| 0x080 | 8 | 2 Hz | N | DG | All | DG Valves States Data | \ref Data::mStates | - :param vValvesStates: (int)Valves states - :return: none + @param valves_states: integer - Valves states + @return: none """ - payload = integer_to_bytearray(vValvesStates) + payload = integer_to_bytearray(valves_states) message = DenaliMessage.build_message(channel_id=DenaliChannels.dg_sync_broadcast_ch_id, message_id=MsgIds.MSG_ID_DG_VALVES_STATES.value, payload=payload) self.can_interface.send(message, 0) - def cmd_set_dg_heaters_data(self, vMainPriMaryDC, vSmallPrimaryDC, vTrimmerDC): + def cmd_set_dg_heaters_data(self, main_primary_dc: int, small_primary_dc: int, trimmer_dc: int) -> None: """ the DG Heaters Data message setter/sender method | MSG | CAN ID | Box | Type | Ack | Src | Dst | Description | #1:(U32) | #2:(U32) | #3:(U32) | |:----:|:------:|:---:|:------:|:---:|:---:|:---:|:-----------: |:--: |:--: |:--: | |0x2C00| 0x080 | 8 | 2 Hz | N | DG | All | DG Heaters Data | \ref Data::mMainPrimaryDC | \ref Data::mSmallPrimaryDC | \ref Data::mTrimmerDC | - :param vMainPriMaryDC: (int) Main PriMary DC - :param vSmallPrimaryDC: (int) Small Primary DC - :param vTrimmerDC: (int) Trimmer DC - :return: none + @param main_primary_dc: integer - Main PriMary DC + @param small_primary_dc: integer - Small Primary DC + @param trimmer_dc: integer - Trimmer DC + @return: none """ - payload = integer_to_bytearray(vMainPriMaryDC) - payload += integer_to_bytearray(vSmallPrimaryDC) - payload += integer_to_bytearray(vTrimmerDC) + payload = integer_to_bytearray(main_primary_dc) + payload += integer_to_bytearray(small_primary_dc) + payload += integer_to_bytearray(trimmer_dc) message = DenaliMessage.build_message(channel_id=DenaliChannels.dg_sync_broadcast_ch_id, message_id=MsgIds.MSG_ID_DG_HEATERS_DATA.value, payload=payload) self.can_interface.send(message, 0) - def cmd_set_dg_load_cell_readings_data(self, vRs1Prim, vRs1Bkup, vRs2Prim, vRs2Bkup): + def cmd_set_dg_load_cell_readings_data(self, reservoir1_primary: float, reservoir1_backup: float, + reservoir2_primary: float, reservoir2_backup: float) -> None: """ The DG Load Cell Readings Data message setter/sender method | MSG | CAN ID | Box | Type | Ack | Src | Dst | Description | #1:(F32) | #2:(F32) | #3:(F32) | #4:(F32) | |:----:|:------:|:---:|:------:|:---:|:---:|:---:|:-----------: |:--: |:--: |:--: |:--: | |0x0C00| 0x080 | 8 | 10 Hz | N | DG | All | DG Load Cell Readings Data | \ref Data::mReservoir1Prim | \ref Data::mReservoir1Bkup | \ref Data::mReservoir2Prim | \ref Data::mReservoir2Bkup | - :param vRs1Prim: (float) Reservoir 1 Primary - :param vRs1Bkup: (float) Reservoir 1 Backup - :param vRs2Prim: (float) Reservoir 2 Primary - :param vRs2Bkup: (float) Reservoir 2 Backup - :return: none + @param reservoir1_primary: float - Reservoir 1 Primary + @param reservoir1_backup: float - Reservoir 1 Backup + @param reservoir2_primary: float - Reservoir 2 Primary + @param reservoir2_backup: float - Reservoir 2 Backup + @return: none """ - payload = float_to_bytearray(vRs1Prim) - payload += float_to_bytearray(vRs1Bkup) - payload += float_to_bytearray(vRs2Prim) - payload += float_to_bytearray(vRs2Bkup) + payload = float_to_bytearray(reservoir1_primary) + payload += float_to_bytearray(reservoir1_backup) + payload += float_to_bytearray(reservoir2_primary) + payload += float_to_bytearray(reservoir2_backup) message = DenaliMessage.build_message(channel_id=DenaliChannels.dg_sync_broadcast_ch_id, message_id=MsgIds.MSG_ID_LOAD_CELL_READINGS.value, payload=payload) self.can_interface.send(message, 0) - def cmd_set_dg_temperatures_data(self, vInletPrimaryHeater, vOutletPrimaryHeater, vConductivitySensor1, vConductivitySensor2, - vOutletRedundancy, vInletDialysate, vPrimaryHeaterThermocouple, vTrimmerHeaterThermocouple, - vPrimaryHeaterColdJunction, vTrimmerHeaterColdJunction, vPrimaryHeaterInternalTemperature, - vTrimmerHeaterInternalTemperature): + def cmd_set_dg_temperatures_data(self, inlet_primary_heater: float, outlet_primary_heater: float, + conductivity_sensor1: float, conductivity_sensor2: float, + outlet_redundancy: float, inlet_dialysate: float, + primary_heater_thermocouple: float, trimmer_heater_thermocouple: float, + primary_heater_cold_junction: float, trimmer_heater_cold_junction: float, + primary_heater_internal_temp: float, trimmer_heater_internal_temp: float) -> None: """ the DG Temperatures Data message setter/sender method | MSG | CAN ID | Box | Type | Ack | Src | Dst | Description | #1:(F32) | #2:(F32) | #3:(F32) | @@ -349,44 +351,44 @@ | #9:(F32) | #10:(F32) | #11:(F32) | #12:(F32) | | :--: |:--: |:--: |:--: | | \ref Data::mPrimaryHeaterColdJunction | \ref Data::mTrimmerHeaterColdJunction | \ref Data::mPrimaryHeaterInternal | \ref Data::mTrimmerHeaterInternal | - :param vInletPrimaryHeater: (float) Inlet Primary Heater - :param vOutletPrimaryHeater: (float) Outlet Primary Heater - :param vConductivitySensor1: (float) Conductivity Sensor 1 - :param vConductivitySensor2: (float) Conductivity Sensor 2 - :param vOutletRedundancy: (float) Outlet Redundancy - :param vInletDialysate: (float) Inlet Dialysate - :param vPrimaryHeaterThermocouple: (float) Primary Heater Thermocouple - :param vTrimmerHeaterThermocouple: (float) Trimmer Heater Thermocouple - :param vPrimaryHeaterColdJunction: (float) Primary Heater ColdJunction - :param vTrimmerHeaterColdJunction: (float) Trimmer Heater ColdJunction - :param vPrimaryHeaterInternalTemperature: (float) Primary Heater Internal Temperature - :param vTrimmerHeaterInternalTemperature: (float) Trimmer HeaterInternal Temperature - :return: none + @param inlet_primary_heater: (float) Inlet Primary Heater + @param outlet_primary_heater: (float) Outlet Primary Heater + @param conductivity_sensor1: (float) Conductivity Sensor 1 + @param conductivity_sensor2: (float) Conductivity Sensor 2 + @param outlet_redundancy: (float) Outlet Redundancy + @param inlet_dialysate: (float) Inlet Dialysate + @param primary_heater_thermocouple: (float) Primary Heater Thermocouple + @param trimmer_heater_thermocouple: (float) Trimmer Heater Thermocouple + @param primary_heater_cold_junction: (float) Primary Heater ColdJunction + @param trimmer_heater_cold_junction: (float) Trimmer Heater ColdJunction + @param primary_heater_internal_temp: (float) Primary Heater Internal Temperature + @param trimmer_heater_internal_temp: (float) Trimmer HeaterInternal Temperature + @return: none """ - payload = float_to_bytearray(vInletPrimaryHeater) - payload += float_to_bytearray(vOutletPrimaryHeater) - payload += float_to_bytearray(vConductivitySensor1) - payload += float_to_bytearray(vConductivitySensor2) - payload += float_to_bytearray(vOutletRedundancy) - payload += float_to_bytearray(vInletDialysate) - payload += float_to_bytearray(vPrimaryHeaterThermocouple) - payload += float_to_bytearray(vTrimmerHeaterThermocouple) - payload += float_to_bytearray(vPrimaryHeaterColdJunction) - payload += float_to_bytearray(vTrimmerHeaterColdJunction) - payload += float_to_bytearray(vPrimaryHeaterInternalTemperature) - payload += float_to_bytearray(vTrimmerHeaterInternalTemperature) + payload = float_to_bytearray(inlet_primary_heater) + payload += float_to_bytearray(outlet_primary_heater) + payload += float_to_bytearray(conductivity_sensor1) + payload += float_to_bytearray(conductivity_sensor2) + payload += float_to_bytearray(outlet_redundancy) + payload += float_to_bytearray(inlet_dialysate) + payload += float_to_bytearray(primary_heater_thermocouple) + payload += float_to_bytearray(trimmer_heater_thermocouple) + payload += float_to_bytearray(primary_heater_cold_junction) + payload += float_to_bytearray(trimmer_heater_cold_junction) + payload += float_to_bytearray(primary_heater_internal_temp) + payload += float_to_bytearray(trimmer_heater_internal_temp) message = DenaliMessage.build_message(channel_id=DenaliChannels.dg_sync_broadcast_ch_id, message_id=MsgIds.MSG_ID_DG_TEMPERATURE_DATA.value, payload=payload) self.can_interface.send(message, 0) - def cmd_send_unknown_dg(self): + def cmd_send_unknown_dg(self) -> None: """ the unknown message from DG setter/sender method - :return: none + @return: none """ payload = integer_to_bytearray(0) @@ -397,7 +399,9 @@ self.can_interface.send(message, 0) - def cmd_send_accelerometer_dg_data(self, vX, vY, vZ, vXMax, vYMax, vZMax, vXTilt, vYTilt, vZTilt ): + def cmd_send_accelerometer_dg_data(self, x: float, y: float, z: float, + x_max: float, y_max: float, z_max: float, + x_tilt: float, y_tilt: float, z_tilt: float) -> None: """ the accelerometer hd data message method | MSG | CAN ID | Box | Type | Ack | Src | Dst | Description | @@ -416,39 +420,38 @@ |:--: |:--: |:--: | | \ref Data::mXTilt | \ref Data::mYTilt | \ref Data::mXTilt | - :param vX: x axis - :param vY: y axis - :param vZ: z axis - :param vXMax: x axis max - :param vYMax: y axis max - :param vZMax: z axis max - :param vXTilt: x axis tilt - :param vYTilt: y axis tilt - :param vZTilt: z axis tilt - :return: None + @param x: float - x axis + @param y: float - y axis + @param z: float - z axis + @param x_max: float - x axis max + @param y_max: float - y axis max + @param z_max: float - z axis max + @param x_tilt: float - x axis tilt + @param y_tilt: float - y axis tilt + @param z_tilt: float - z axis tilt + @return: None """ - payload = float_to_bytearray(vX) - payload += float_to_bytearray(vY) - payload += float_to_bytearray(vZ) - payload += float_to_bytearray(vXMax) - payload += float_to_bytearray(vYMax) - payload += float_to_bytearray(vZMax) - payload += float_to_bytearray(vXTilt) - payload += float_to_bytearray(vYTilt) - payload += float_to_bytearray(vZTilt) + payload = float_to_bytearray(x) + payload += float_to_bytearray(y) + payload += float_to_bytearray(z) + payload += float_to_bytearray(x_max) + payload += float_to_bytearray(y_max) + payload += float_to_bytearray(z_max) + payload += float_to_bytearray(x_tilt) + payload += float_to_bytearray(y_tilt) + payload += float_to_bytearray(z_tilt) message = DenaliMessage.build_message(channel_id=DenaliChannels.dg_to_ui_ch_id, message_id=MsgIds.MSG_ID_DG_ACCELEROMETER_DATA.value, payload=payload) self.can_interface.send(message, 0) - def _handler_request_dg_version(self, message: dict) -> None: + def _handler_request_dg_version(self) -> None: """ Handles a request for the HD version - @param message: (dict) the received message @return: None """ self.logger.debug("Handling request for dg version.") @@ -469,28 +472,29 @@ self.can_interface.send(message, 0) - def cmd_send_version_dg_data(self, vMajor, vMinor, vMicro, vBuild, vFPGA_id, vFPGA_Major, vFPGA_Minor, vFPGA_Lab ): + def cmd_send_version_dg_data(self, major: int, minor: int, micro: int, build: int, + fpga_id: int, fpga_major: int, fpga_minor: int, fpga_lab: int) -> None: """ - the hd version response message method - :param vMajor: Major version number - :param vMinor: Minor version number - :param vMicro: Micro version number - :param vBuild: Build version number - :param vFPGA_id: FPGA id version number - :param vFPGA_Major: FPGA Major version number - :param vFPGA_Minor: FPGA Minor version number - :param vFPGA_Lab: FPGA Lab version number - :return: None + the dg version response message method + @param major: integer - Major version number + @param minor: integer - Minor version number + @param micro: integer - Micro version number + @param build: integer - Build version number + @param fpga_id: integer - FPGA id version number + @param fpga_major: integer - FPGA Major version number + @param fpga_minor: integer - FPGA Minor version number + @param fpga_lab: integer - FPGA Lab version number + @return: None """ - payload = byte_to_bytearray(vMajor) - payload += byte_to_bytearray(vMinor) - payload += byte_to_bytearray(vMicro) - payload += short_to_bytearray(vBuild) - payload += byte_to_bytearray(vFPGA_id) - payload += byte_to_bytearray(vFPGA_Major) - payload += byte_to_bytearray(vFPGA_Minor) - payload += byte_to_bytearray(vFPGA_Lab) + payload = byte_to_bytearray(major) + payload += byte_to_bytearray(minor) + payload += byte_to_bytearray(micro) + payload += short_to_bytearray(build) + payload += byte_to_bytearray(fpga_id) + payload += byte_to_bytearray(fpga_major) + payload += byte_to_bytearray(fpga_minor) + payload += byte_to_bytearray(fpga_lab) message = DenaliMessage.build_message(channel_id=DenaliChannels.dg_to_ui_ch_id, message_id=MsgIds.MSG_ID_DG_VERSION.value, @@ -499,23 +503,23 @@ self.can_interface.send(message, 0) @staticmethod - def build_dg_debug_text(vText): + def build_dg_debug_text(text: str) -> list: """ the debug text message from DG builder method - :param vText: (str) the debug text - :return: none + @param text: string - the debug text + @return: none """ message_length = 40 - txt = messageBuilder.textToByte(vText, message_length) # + 1 null term + txt = messageBuilder.textToByte(text, message_length) # + 1 null term msg = messageBuilder.buildMessage(GuiActionType.DGDebugText, 1 * (message_length + 1), False, txt) return messageBuilder.toFrames(msg) - def cmd_send_pre_treatment_filter_flush_progress_data(self, total, countdown): + def cmd_send_pre_treatment_filter_flush_progress_data(self, total, countdown) -> None: """ send the pretreatment filter flush progress data - :param accepted: (U32) Total time in second - :param reason: (U32) count down time in second - :return: None + @param total: (U32) Total time in second + @param countdown: (U32) count down time in second + @return: None """ payload = integer_to_bytearray(total) payload += integer_to_bytearray(countdown) @@ -526,19 +530,19 @@ self.can_interface.send(message, 0) - def cmd_send_dg_disinfection_state(self, subMode, flushMode, heatMode, chemicalMode): + def cmd_send_dg_disinfection_state(self, sub_mode: int, flush_mode: int, heat_mode: int, chemical_mode: int) -> None: """ Broadcasts the current DG disinfection mode - :param subMode (int): disinfect states - :param flushMode (int): flush states - :param heatMode (int): heat states - :param ChemicalMode (int): chemical states - :return: + @param sub_mode: disinfect states + @param flush_mode: flush states + @param heat_mode: heat states + @param chemical_mode: chemical states + @return: """ - payload = integer_to_bytearray(subMode) - payload += integer_to_bytearray(flushMode) - payload += integer_to_bytearray(heatMode) - payload += integer_to_bytearray(chemicalMode) + payload = integer_to_bytearray(sub_mode) + payload += integer_to_bytearray(flush_mode) + payload += integer_to_bytearray(heat_mode) + payload += integer_to_bytearray(chemical_mode) message = DenaliMessage.build_message(channel_id=DenaliChannels.dg_sync_broadcast_ch_id, message_id=MsgIdsDialin.MSG_DIALIN_ID_HD_DISINFECT_STATE.value, @@ -548,9 +552,9 @@ def cmd_send_dg_disinfect_progress_time_flush(self, total: int, countdown: int) -> None: """ the broadcast progress water flush time - :param total: the total time - :param countdown: the gradual countdown time - :return: None + @param total: the total time + @param countdown: the gradual countdown time + @return: None """ payload = integer_to_bytearray(total) payload += integer_to_bytearray(countdown) @@ -564,9 +568,9 @@ def cmd_send_dg_disinfect_progress_time_heat(self, total: int, countdown: int) -> None: """ the broadcast progress heat disinfect time - :param total: the total time - :param countdown: the gradual countdown time - :return: None + @param total: the total time + @param countdown: the gradual countdown time + @return: None """ payload = integer_to_bytearray(total) payload += integer_to_bytearray(countdown) @@ -580,9 +584,9 @@ def cmd_send_dg_disinfect_progress_time_checmical(self, total: int, countdown: int) -> None: """ the broadcast progress chemical disinfect time - :param total: the total time - :param countdown: the gradual countdown time - :return: None + @param total: the total time + @param countdown: the gradual countdown time + @return: None """ payload = integer_to_bytearray(total) payload += integer_to_bytearray(countdown) @@ -599,22 +603,22 @@ parameters_payload: any = 0x00) -> 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 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 + @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 is_pure_data: The message only has data + @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 = "" + if not is_pure_data: payload = integer_to_bytearray(accepted) payload += integer_to_bytearray(reason) - if has_parameters: - payload += parameters_payload - else: - if has_parameters: - payload = parameters_payload + if has_parameters: + payload += parameters_payload message = DenaliMessage.build_message(channel_id=DenaliChannels.dg_to_ui_ch_id, message_id=message_id, @@ -625,10 +629,10 @@ def cmd_send_general_dg_progress_data(self, message_id: int, total: int, countdown: int) -> None: """ 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 - :return: None + @param message_id: the id of the message + @param total: the total value of the progress data + @param countdown: the remaining or countdown value + @return: None """ payload = integer_to_bytearray(total) payload += integer_to_bytearray(countdown) @@ -642,8 +646,8 @@ def cmd_ack_send_dg(self, seq: int) -> None: """ sending dg ack message by the sequence seq - :param seq: the message sequence number - :return: None + @param seq: the message sequence number + @return: None """ message = DenaliMessage.build_message(channel_id=DenaliChannels.dg_to_ui_ch_id, message_id=GuiActionType.Acknow, Index: dialin/ui/globals.py =================================================================== diff -u -re5b68dd61c18dd97545d5e527a7f0a8f84061cb6 -rf990c9bb863683c74bbe78c71932a14d7cf35422 --- dialin/ui/globals.py (.../globals.py) (revision e5b68dd61c18dd97545d5e527a7f0a8f84061cb6) +++ dialin/ui/globals.py (.../globals.py) (revision f990c9bb863683c74bbe78c71932a14d7cf35422) @@ -13,6 +13,3 @@ # @date (original) 09-Jul-2020 # ############################################################################ - -def SRSUI(vSRSUI = ""): - return "SRSUI " + "{}".format(vSRSUI).rjust(3, '0') Index: dialin/ui/hd_simulator.py =================================================================== diff -u -rebf0a72a1a1a52f3cfe20975de4857201275888c -rf990c9bb863683c74bbe78c71932a14d7cf35422 --- dialin/ui/hd_simulator.py (.../hd_simulator.py) (revision ebf0a72a1a1a52f3cfe20975de4857201275888c) +++ dialin/ui/hd_simulator.py (.../hd_simulator.py) (revision f990c9bb863683c74bbe78c71932a14d7cf35422) @@ -15,8 +15,6 @@ ############################################################################ import enum from time import sleep -from typing import List, Union -import time from . import messageBuilder from .hd_simulator_alarms import HDAlarmsSimulator @@ -32,10 +30,10 @@ NUM_TREATMENT_PARAMETERS = 18 instanceCount = 0 - def __init__(self, can_interface:str="can0", - log_level:bool= None, - console_out:bool= False, - passive_mode:bool=False): + def __init__(self, can_interface: str = "can0", + log_level: bool = None, + console_out: bool = False, + passive_mode: bool = False): """ The HDSimulator constructor @@ -119,14 +117,13 @@ self.can_interface.send(message, 0) - def _handler_system_usage_response(self, message: dict) -> None: + def _handler_system_usage_response(self) -> None: """ Handles a request for system usage - @param message: (dict) the message @return: None """ - + payload = integer_to_bytearray(1619628663) payload += integer_to_bytearray(1619887863) @@ -143,11 +140,8 @@ @return: None """ - START_POS = DenaliMessage.PAYLOAD_START_INDEX - END_POS = START_POS + 4 - epoch = struct.unpack('i', bytearray( - message['message'][START_POS:END_POS]))[0] + message['message'][MsgFieldPositions.START_POS_FIELD_1:MsgFieldPositions.END_POS_FIELD_1]))[0] self.logger.debug("Request to set the HD epoch to {0}".format(epoch)) @@ -158,6 +152,7 @@ Sends a set RTC response message @param response: (int) 0=NO, 1=YES + @param reason: the rejection reason @return: None """ self.logger.debug("HD: Sending response {0} reason {1}".format(response, reason)) @@ -281,11 +276,9 @@ @param message: the confirm treatment message @return: None """ - START_POS = DenaliMessage.PAYLOAD_START_INDEX - END_POS = START_POS + 4 request = struct.unpack('i', bytearray( - message['message'][START_POS:END_POS]))[0] + message['message'][MsgFieldPositions.START_POS_FIELD_1:MsgFieldPositions.END_POS_FIELD_1]))[0] if request == 0: self.logger.debug("Received UI cancel confirmation of Treatment Parameters. ") @@ -310,11 +303,8 @@ @return: None """ - START_POS = DenaliMessage.PAYLOAD_START_INDEX - END_POS = START_POS + 4 - uf_volume = struct.unpack('f', bytearray( - message['message'][START_POS:END_POS]))[0] + message['message'][MsgFieldPositions.START_POS_FIELD_1:MsgFieldPositions.END_POS_FIELD_1]))[0] self.logger.debug("Received UF Volume: {0} mL".format(uf_volume)) @@ -327,11 +317,9 @@ @param message: the start treatment message @return: None """ - START_POS = DenaliMessage.PAYLOAD_START_INDEX - END_POS = START_POS + 4 request = struct.unpack('i', bytearray( - message['message'][START_POS:END_POS]))[0] + message['message'][MsgFieldPositions.START_POS_FIELD_1:MsgFieldPositions.END_POS_FIELD_1]))[0] if request == 0: self.logger.debug("Selecting treatment parameters") @@ -350,6 +338,7 @@ Sends a start treatment response message @param response: 0=NO, 1=YES + @param reason: the rejection reason @return: None """ self.logger.debug("Sending: {0}".format(response)) @@ -363,21 +352,21 @@ self.can_interface.send(message, 0) - def cmd_send_hd_operation_mode(self, opMode, subMode): + def cmd_send_hd_operation_mode(self, op_mode: int, sub_mode: int = 0): """ Broadcasts the current HD operation mode - @param: (int) opMode - @param: (int) subMode + @param op_mode: hd operation mode + @param sub_mode: hd operation sub-mode @return: None """ - if not isinstance(opMode, int): + if not isinstance(op_mode, int): raise ValueError("Provided mode is not of type 'int'") - if not isinstance(subMode, int): + if not isinstance(sub_mode, int): raise ValueError("Provided mode is not of type 'int'") - payload = integer_to_bytearray(opMode) - payload += integer_to_bytearray(subMode) + payload = integer_to_bytearray(op_mode) + payload += integer_to_bytearray(sub_mode) message = DenaliMessage.build_message(channel_id=DenaliChannels.hd_sync_broadcast_ch_id, message_id=MsgIds.MSG_ID_HD_OP_MODE.value, @@ -388,10 +377,10 @@ def cmd_send_uf_treatment_response(self, accepted, reason, volume): """ Sends the uf volume adjustment response message in pre-treatment - :param accepted: (uint) the acceptance, 1 = accepted, 0 = rejected - :param reason: (uint) the reason for rejection - :param volume: (float) the acceptable/accepted ultrafiltration volume - :return: none + @param accepted: (uint) the acceptance, 1 = accepted, 0 = rejected + @param reason: (uint) the reason for rejection + @param volume: (float) the acceptable/accepted ultrafiltration volume + @return: none """ payload = integer_to_bytearray(accepted) payload += integer_to_bytearray(reason) @@ -417,11 +406,11 @@ self.can_interface.send(message, 0) - def _handler_ui_validate_parameters(self, message): + def _handler_ui_validate_parameters(self) -> None: """ + handler for UI parameters validation - @param message: - @return: + @return: None """ rejections = [ self.treatment_parameter_rejections.param_request_valid, @@ -466,7 +455,7 @@ def cmd_send_acknowledge_hd(self): """ the acknowledge from HD - :return: none + @return: none """ payload = ["A5", "01", "00", "FF", "FF", "00", "19", "00"] @@ -480,7 +469,7 @@ def cmd_send_acknowledge_ui(self): """ the acknowledge from UI - :return: none + @return: none """ payload = ["A5", "01", "00", "FF", "FF", "00", "19", "00"] @@ -494,7 +483,7 @@ def cmd_show_poweroff_dialog(self): """ the message from HD to UI to show the power off dialog - :return: none + @return: none """ payload = ["A5", "01", "00", "01", "00", "01", "00", "38"] @@ -508,7 +497,7 @@ def cmd_hide_poweroff_dialog(self): """ the message from HD to UI to hide the power off dialog - :return: none + @return: none """ payload = ["A5", "01", "00", "01", "00", "01", "01", "09"] @@ -522,7 +511,7 @@ def cmd_show_poweroff_notification_dialog(self): """ the message from HD to UI to show the shutting down notification box - :return: none + @return: none """ payload = ["A5", "01", "00", "0E", "00", "00", "24", "00"] @@ -536,7 +525,7 @@ def cmd_show_poweroff_rejection_dialog(self): """ the message from HD to UI to show the power off dialog - :return: none + @return: none """ payload = ["A5", "01", "00", "01", "00", "01", "02", "5A"] @@ -553,28 +542,28 @@ After each multi-frame message put a 50ms sleep, time.sleep(0.1) it seems it's needed otherwise the test will check a value which has not been received yet. :@param delay: the number of seconds to wait - :return: none + @return: none """ time.sleep(delay) @staticmethod - def build_hd_debug_text(vText): + def build_hd_debug_text(vtext): """ the debug text message from HD builder method - :param vText: (str) the debug text - :return: none + @param vtext: (str) the debug text + @return: none """ message_length = 40 - txt = messageBuilder.textToByte(vText, message_length) # + 1 null term + txt = messageBuilder.textToByte(vtext, message_length) # + 1 null term msg = messageBuilder.buildMessage(GuiActionType.HDDebugText, 1 * (message_length + 1), False, txt) return messageBuilder.toFrames(msg) @staticmethod def cmd_set_hd_debug_text(debug_text): """ the debug text message from HD setter/sender method - :param debug_text: (str) the debug text - :return: none + @param debug_text: (str) the debug text + @return: none """ frames = HDSimulator.build_hd_debug_text(debug_text) @@ -587,127 +576,133 @@ def cmd_set_dg_debug_text(debug_text): """ the debug text message from DG setter/sender method - :param debug_text: (str) the debug text - :return: none + @param debug_text: (str) the debug text + @return: none """ frames = HDSimulator.build_dg_debug_text(debug_text) frames = messageBuilder.toCandumpFormat(frames) for frame in frames: subprocess.call(['cansend', 'can0', '070#{}'.format(frame)]) HDSimulator.wait_for_message_to_be_sent() - def cmd_set_treatment_parameter_ranges(self, vMinTreatmentDuration, vMaxTreatmentDuration, vMinUFVolume, vMaxUFVolume, - vMinDialysateFlowRate, vMaxDialysateFlowRate): + def cmd_set_treatment_parameter_ranges(self, min_treatment_duration: int, max_treatment_duration: int, + min_uf_volume: float, max_uf_volume: float, + min_dialysate_flow_rate: int, max_dialysate_flow_rate: int) -> None: """ The Treatment adjustment parameter ranges data message setter/sender method | MSG | CAN ID | Box | Type | Ack | Src | Dst | Description | #1:(U32) | #2:(U32) | #3:(F32) | #4:(F32) | #5:(U32) | #6:(U32) | |:----:|:------:|:---:|:------:|:---:|:---:|:---:|:-----------: |:--: |:--: |:--: |:--: |:--: |:--: | |0x1A00| 0x020 | 6 | 1/60 Hz| Y | HD | UI | Treatment adjustment param ranges Data | \ref Data::mDuration_Min | \ref Data::mDuration_Max | \ref Data::mUltrafiltration_Volume_Min | \ref Data::mUltrafiltration_Volume_Max | \ref Data::mDialysate_Flow_Min | \ref Data::mDialysate_Flow_Max | - :param vMinTreatmentDuration: (int) Min Treatment Duration - :param vMaxTreatmentDuration: (int) Max Treatment Duration - :param vMinUFVolume: (float) Min UF Volume - :param vMaxUFVolume: (float) Max UF Volume - :param vMinDialysateFlowRate: (int) Min Dialysate Flow Rate - :param vMaxDialysateFlowRate: (int) Max Dialysate Flow Rate - :return: None + @param min_treatment_duration: (int) Min Treatment Duration + @param max_treatment_duration: (int) Max Treatment Duration + @param min_uf_volume: (float) Min UF Volume + @param max_uf_volume: (float) Max UF Volume + @param min_dialysate_flow_rate: (int) Min Dialysate Flow Rate + @param max_dialysate_flow_rate: (int) Max Dialysate Flow Rate + @return: None """ - payload = integer_to_bytearray(vMinTreatmentDuration) - payload += integer_to_bytearray(vMaxTreatmentDuration) - payload += float_to_bytearray(vMinUFVolume) - payload += float_to_bytearray(vMaxUFVolume) - payload += integer_to_bytearray(vMinDialysateFlowRate) - payload += integer_to_bytearray(vMaxDialysateFlowRate) + payload = integer_to_bytearray(min_treatment_duration) + payload += integer_to_bytearray(max_treatment_duration) + payload += float_to_bytearray(min_uf_volume) + payload += float_to_bytearray(max_uf_volume) + payload += integer_to_bytearray(min_dialysate_flow_rate) + payload += integer_to_bytearray(max_dialysate_flow_rate) message = DenaliMessage.build_message(channel_id=DenaliChannels.hd_to_ui_ch_id, message_id=MsgIds.MSG_ID_TREATMENT_PARAM_CHANGE_RANGES.value, payload=payload) self.can_interface.send(message, 0) - def cmd_set_treatment_blood_flow_rate(self, vFlowSetPt, vMeasFlow, vRotSpd, vMotSpd, vMCSpd, vMCCurr, vPWM, vSigStrength): + def cmd_set_treatment_blood_flow_rate(self, flow_set_pt: int, measured_flow: float, + rot_speed: float, mot_speed: float, mc_speed: float, + mc_current: float, pwm: float, signal_strength: float) -> None: """ The Blood Flow Data message setter/sender method | MSG | CAN ID | Box | Type | Ack | Src | Dst | Description | #1:(S32) | #2:(F32) | #3:(F32) | #4:(F32) | #5:(F32) | #6:(F32) | #7:(F32) | #8:(F32) | |:----:|:------:|:---:|:------:|:---:|:---:|:---:|:-----------: |:--: |:--: |:--: |:--: |:--: |:--: |:--: |:--: | |0x0500| 0x040 | 7 | 1 Hz | N | HD | All | Blood Flow Data | \ref Data::mFlowSetPoint | \ref Data::mMeasuredFlow | \ref Data::mRotorSpeed | \ref Data::mMotorSpeed | \ref Data::mMotorCtlSpeed | \ref Data::mMotorCtlCurrent | \ref Data::mPWMDutyCycle | \ref Data::mSigStrenght | - :param vFlowSetPt: (signed int) Flow Set Point - :param vMeasFlow: (float) Measured Flow - :param vRotSpd: (float) Rot Speed - :param vMotSpd: (float) Motor Speed - :param vMCSpd: (float) MC Speed - :param vMCCurr: (float) MC Current - :param vPWM: (float) PWM - :param vSigStrength: (float) Signal strength in percent - :return: None + @param flow_set_pt: (int) Flow Set Point + @param measured_flow: (float) Measured Flow + @param rot_speed: (float) Rot Speed + @param mot_speed: (float) Motor Speed + @param mc_speed: (float) MC Speed + @param mc_current: (float) MC Current + @param pwm: (float) PWM + @param signal_strength: (float) Signal strength in percent + @return: None """ - payload = integer_to_bytearray(vFlowSetPt) - payload += float_to_bytearray(vMeasFlow) - payload += float_to_bytearray(vRotSpd) - payload += float_to_bytearray(vMotSpd) - payload += float_to_bytearray(vMCSpd) - payload += float_to_bytearray(vMCCurr) - payload += float_to_bytearray(vPWM) - payload += float_to_bytearray(vSigStrength) + payload = integer_to_bytearray(flow_set_pt) + payload += float_to_bytearray(measured_flow) + payload += float_to_bytearray(rot_speed) + payload += float_to_bytearray(mot_speed) + payload += float_to_bytearray(mc_speed) + payload += float_to_bytearray(mc_current) + payload += float_to_bytearray(pwm) + payload += float_to_bytearray(signal_strength) message = DenaliMessage.build_message(channel_id=DenaliChannels.hd_sync_broadcast_ch_id, message_id=MsgIds.MSG_ID_BLOOD_FLOW_DATA.value, payload=payload) self.can_interface.send(message, 0) - def cmd_set_treatment_dialysate_flow_rate(self, vFlowSetPt, vMeasFlow, vRotSpd, vMotSpd, vMCSpd, vMCCurr, vPWM, vSigStrength): + def cmd_set_treatment_dialysate_flow_rate(self, flow_set_pt: int, measured_flow: float, + rot_speed: float, mot_speed: float, mc_speed: float, + mc_current: float, pwm: float, signal_strength: float) -> None: """ The Dialysate Flow Data message setter/sender method | MSG | CAN ID | Box | Type | Ack | Src | Dst | Description | #1:(S32) | #2:(F32) | #3:(F32) | #4:(F32) | #5:(F32) | #6:(F32) | #7:(F32) | #8:(F32) | |:----:|:------:|:---:|:------:|:---:|:---:|:---:|:-----------: |:--: |:--: |:--: |:--: |:--: |:--: |:--: |:--: | |0x0800| 0x040 | 7 | 1 Hz | N | HD | All | Dialysate Flow Data | mFlowSetPoint | mMeasuredFlow | mRotorSpeed | mMotorSpeed | mMotorCtlSpeed | mMotorCtlCurrent | mPWMDutyCycle | \ref Data::mSigStrenght | - :param vFlowSetPt: (signed int) Flow Set Point - :param vMeasFlow: (float) Measured Flow - :param vRotSpd: (float) Rot Speed - :param vMotSpd: (float) Motor Speed - :param vMCSpd: (float) MC Speed - :param vMCCurr: (float) MC Current - :param vPWM: (float) PWM - :param vSigStrength: (float) Signal strength in percent - :return: None + @param flow_set_pt: (signed int) Flow Set Point + @param measured_flow: (float) Measured Flow + @param rot_speed: (float) Rot Speed + @param mot_speed: (float) Motor Speed + @param mc_speed: (float) MC Speed + @param mc_current: (float) MC Current + @param pwm: (float) PWM + @param signal_strength: (float) Signal strength in percent + @return: None """ - payload = integer_to_bytearray(vFlowSetPt) - payload += float_to_bytearray(vMeasFlow) - payload += float_to_bytearray(vRotSpd) - payload += float_to_bytearray(vMotSpd) - payload += float_to_bytearray(vMCSpd) - payload += float_to_bytearray(vMCCurr) - payload += float_to_bytearray(vPWM) - payload += float_to_bytearray(vSigStrength) + payload = integer_to_bytearray(flow_set_pt) + payload += float_to_bytearray(measured_flow) + payload += float_to_bytearray(rot_speed) + payload += float_to_bytearray(mot_speed) + payload += float_to_bytearray(mc_speed) + payload += float_to_bytearray(mc_current) + payload += float_to_bytearray(pwm) + payload += float_to_bytearray(signal_strength) message = DenaliMessage.build_message(channel_id=DenaliChannels.hd_sync_broadcast_ch_id, message_id=MsgIds.MSG_ID_DIALYSATE_FLOW_DATA.value, payload=payload) self.can_interface.send(message, 0) - def cmd_send_treatment_adjust_blood_dialysate_response(self, accepted, reason, blood_rate, dialysate_flow_rate): + def cmd_send_treatment_adjust_blood_dialysate_response(self, accepted: int, reason: int, + blood_rate: int, dialysate_flow_rate: int) -> None: """ The Blood/dialysate rate change Response message setter/sender method | MSG | CAN ID | Box | Type | Ack | Src | Dst | Description | #1:(U32) | #2:(U32) | #3:(U32) | #4:(U32) | |:----:|:------:|:---:|:------:|:---:|:---:|:---:|:-----------: |:--: |:--: |:--: |:--: | |0x1800| 0x020 | 6 | Rsp | Y | HD | UI | Blood/dialysate rate change Response | \ref Data::mAccepted | \ref Data::mReason | \ref Data::mBloodRate | \ref Data::mDialysateRate | - :param accepted: (int) boolean accept/reject response - :param reason: (int) rejection reason - :param blood_rate: (int) Blood Flow Rate - :param dialysate_flow_rate: (int) Dialysate Flow Rate - :return: None + @param accepted: (int) boolean accept/reject response + @param reason: (int) rejection reason + @param blood_rate: (int) Blood Flow Rate + @param dialysate_flow_rate: (int) Dialysate Flow Rate + @return: None """ if not isinstance(accepted, int): @@ -730,262 +725,269 @@ self.can_interface.send(message, 0) - def cmd_send_treatment_adjust_duration_response(self, vAccepted, vReason, vDuration, vUltrafiltration): + def cmd_send_treatment_adjust_duration_response(self, accepted: int, reason: int, + duration: int, ultrafiltration: float) -> None: """ The Treatment Duration change Response message setter/sender method | MSG | CAN ID | Box | Type | Ack | Src | Dst | Description | #1:(U32) | #2:(U32) | #3:(U32) | #5:(F32) | |:----:|:------:|:---:|:------:|:---:|:---:|:---:|:-----------: |:--: |:--: |:--: |:--: | |0x1B00| 0x020 | 6 | Rsp | Y | HD | UI | Treatment Duration change Response | \ref Data::mAccepted | \ref Data::mReason | \ref Data::mDuration | \ref Data::mUFVolume | - :param vAccepted: (int) boolean accept/reject response - :param vReason: (int) rejection reason - :param vDuration: (int) Treatment Duration - :param vUltrafiltration: (float) Ultrafiltration Volume - :return: none + @param accepted: (int) boolean accept/reject response + @param reason: (int) rejection reason + @param duration: (int) Treatment Duration + @param ultrafiltration: (float) Ultrafiltration Volume + @return: none """ - payload = integer_to_bytearray(vAccepted) - payload += integer_to_bytearray(vReason) - payload += integer_to_bytearray(vDuration) - payload += float_to_bytearray(vUltrafiltration) + payload = integer_to_bytearray(accepted) + payload += integer_to_bytearray(reason) + payload += integer_to_bytearray(duration) + payload += float_to_bytearray(ultrafiltration) message = DenaliMessage.build_message(channel_id=DenaliChannels.hd_to_ui_ch_id, message_id=MsgIds.MSG_ID_USER_TREATMENT_TIME_CHANGE_RESPONSE.value, payload=payload) self.can_interface.send(message, 0) - def cmd_set_treatment_adjust_ultrafiltration_state_response(self, vAccepted, vReason, vState): + def cmd_set_treatment_adjust_ultrafiltration_state_response(self, accepted: int, reason: int, state: int) -> None: """ the Treatment ultrafiltration adjustment response message setter/sender method - :param vAccepted: (int) boolean accept/reject response - :param vReason: (int) rejection reason - :param vState: (int) Ultrafiltration State - :return: none + @param accepted: (int) boolean accept/reject response + @param reason: (int) rejection reason + @param state: (int) Ultrafiltration State + @return: none """ - payload = integer_to_bytearray(vAccepted) - payload += integer_to_bytearray(vReason) - payload += integer_to_bytearray(vState) + payload = integer_to_bytearray(accepted) + payload += integer_to_bytearray(reason) + payload += integer_to_bytearray(state) message = DenaliMessage.build_message(channel_id=DenaliChannels.hd_to_ui_ch_id, message_id=MsgIds.MSG_ID_USER_UF_PAUSE_RESUME_RESPONSE.value, payload=payload) self.can_interface.send(message, 0) - def cmd_set_treatment_adjust_ultrafiltration_accepted(self, vState): + def cmd_set_treatment_adjust_ultrafiltration_accepted(self, state: int) -> None: """ a convenient method for cmd_set_treatment_adjust_ultrafiltration_state_response which sends accept true - :return: none + @param state: (int) Ultrafiltration State + @return: none """ - self.cmd_set_treatment_adjust_ultrafiltration_state_response(EResponse.Accepted, 0, vState) + self.cmd_set_treatment_adjust_ultrafiltration_state_response(EResponse.Accepted, 0, state) - def cmd_set_treatment_adjust_ultrafiltration_rejected(self, vReason, vState): + def cmd_set_treatment_adjust_ultrafiltration_rejected(self, reason: int, state: int) -> None: """ a convenient method for cmd_set_treatment_adjust_ultrafiltration_state_response which sends accept false - :return: none + @param reason: (int) rejection reason + @param state: (int) Ultrafiltration State + @return: none """ - self.cmd_set_treatment_adjust_ultrafiltration_state_response(EResponse.Rejected, vReason, vState) + self.cmd_set_treatment_adjust_ultrafiltration_state_response(EResponse.Rejected, reason, state) - def cmd_set_treatment_adjust_ultrafiltration_init_response(self, vAccepted, vReason, vVolume): + def cmd_set_treatment_adjust_ultrafiltration_init_response(self, accepted: int, reason: int, volume: float) -> None: """ the ultrafiltration volume change response message setter/sender method | MSG | CAN ID | Box | Type | Ack | Src | Dst | Description | #1:(U32) | #2:(U32) | #3:(F32) |:----:|:------:|:---:|:------:|:---:|:---:|:---:|:-----------: |:--: |:--: |:--: |0x5000| 0x020 | 6 | Rsp | Y | HD | UI | Pre UF Volume Adjustment Response | \ref Data::mAccepted | \ref Data::mReason | \ref Data::mVolume - :param vAccepted: (int) boolean accept/reject response - :param vReason: (int) rejection reason - :param vVolume: (float) Ultrafiltration Volume - :return: none + @param accepted: (int) boolean accept/reject response + @param reason: (int) rejection reason + @param volume: (float) Ultrafiltration Volume + @return: none """ - payload = integer_to_bytearray(vAccepted) - payload += integer_to_bytearray(vReason) - payload += float_to_bytearray(vVolume) + payload = integer_to_bytearray(accepted) + payload += integer_to_bytearray(reason) + payload += float_to_bytearray(volume) message = DenaliMessage.build_message(channel_id=DenaliChannels.hd_to_ui_ch_id, message_id=MsgIds.MSG_ID_HD_SET_UF_VOLUME_PARAMETER_RESPONSE.value, payload=payload) self.can_interface.send(message, 0) - def cmd_set_treatment_adjust_ultrafiltration_edit_response(self, vAccepted, vReason, vVolume, vDuration, vDurationDiff, - vRate, vRateDiff, vRateOld): + def cmd_set_treatment_adjust_ultrafiltration_edit_response(self, accepted: int, reason: int, volume: float, + duration: int, duration_diff: int, + rate: float, rate_diff: float, rate_old: float) -> None: """ the ultrafiltration volume change response message setter/sender method | MSG | CAN ID | Box | Type | Ack | Src | Dst | Description | #1:(U32) | #2:(U32) | #1:(U32) | #2:(U32) | #3:(F32) | #4:(U32) | #5:(F32) | #6:(U32) | #7:(U32) | #8:(F32) | |:----:|:------:|:---:|:------:|:---:|:---:|:---:|:-----------: |:--: |:--: |:--: |:--: |:--: |:--: |:--: |:--: |:--: |:--: | |0x1300| 0x020 | 6 | Rsp | Y | HD | UI | UF Vol. Change Response | \ref Data::mAccepted | \ref Data::mReason | \ref Data::mAccepted | \ref Data::mReason | \ref Data::mVolume | \ref Data::mDuration | \ref Data::mRate | \ref Data::mDurationDiff | \ref Data::mRateDiff | \ref Data::mRateOld | - :param vAccepted: (int) boolean accept/reject response - :param vReason: (int) rejection reason - :param vVolume: (float) Ultrafiltration Volume - :param vDuration: (int) Treatment Duration - :param vDurationDiff: (int) Duration Difference - :param vRate: (float) Ultrafiltration Rate - :param vRateDiff: (float) Ultrafiltration Rate Difference - :param vRateOld: (float) Ultrafiltration Rate Old - :return: none + @param accepted: (int) boolean accept/reject response + @param reason: (int) rejection reason + @param volume: (float) Ultrafiltration Volume + @param duration: (int) Treatment Duration + @param duration_diff: (int) Duration Difference + @param rate: (float) Ultrafiltration Rate + @param rate_diff: (float) Ultrafiltration Rate Difference + @param rate_old: (float) Ultrafiltration Rate Old + @return: none """ - payload = integer_to_bytearray(vAccepted) - payload += integer_to_bytearray(vReason) - payload += float_to_bytearray(vVolume) - payload += integer_to_bytearray(vDuration) - payload += integer_to_bytearray(vDurationDiff) - payload += float_to_bytearray(vRate) - payload += float_to_bytearray(vRateDiff) - payload += float_to_bytearray(vRateOld) + payload = integer_to_bytearray(accepted) + payload += integer_to_bytearray(reason) + payload += float_to_bytearray(volume) + payload += integer_to_bytearray(duration) + payload += integer_to_bytearray(duration_diff) + payload += float_to_bytearray(rate) + payload += float_to_bytearray(rate_diff) + payload += float_to_bytearray(rate_old) message = DenaliMessage.build_message(channel_id=DenaliChannels.hd_to_ui_ch_id, message_id=MsgIds.MSG_ID_USER_UF_SETTINGS_CHANGE_RESPONSE.value, payload=payload) self.can_interface.send(message, 0) - def cmd_set_treatment_adjust_ultrafiltration_edit_rejected(self, vReason): + def cmd_set_treatment_adjust_ultrafiltration_edit_rejected(self, reason: int) -> None: """ a convenient method for cmd_set_treatment_adjust_ultrafiltration_edit_response which only sends a rejection reason and sends other values all as zero - :param vReason: (int) rejection reason - :return: none + @param reason: (int) rejection reason + @return: none """ - self.cmd_set_treatment_adjust_ultrafiltration_edit_response(0, vReason, 0, 0, 0, 0, 0, 0) + self.cmd_set_treatment_adjust_ultrafiltration_edit_response(0, reason, 0, 0, 0, 0, 0, 0) - def cmd_set_treatment_adjust_ultrafiltration_confirm_response(self, vAccepted, vReason, vVolume, vDuration, vRate): + def cmd_set_treatment_adjust_ultrafiltration_confirm_response(self, accepted: int, reason: int, volume: float, + duration: int, rate: float) -> None: """ the ultrafiltration volume Change Confirmation Response message setter/sender method | MSG | CAN ID | Box | Type | Ack | Src | Dst | Description | #1:(U32) | #2:(U32) | #3:(F32) | #4:(U32) | #5:(F32) | |:----:|:------:|:---:|:------:|:---:|:---:|:---:|:-----------: |:--: |:--: |:--: |:--: |:--: | |0x2E00| 0x020 | 6 | Rsp | Y | HD | UI | UF Vol. Change Confirmation Response | \ref Data::mAccepted | \ref Data::mReason | \ref Data::mVolume | \ref Data::mDuration | \ref Data::mRate | - :param vAccepted: (int) boolean accept/reject response - :param vReason: (int) rejection reason - :param vVolume: (float) Ultrafiltration Volume - :param vDuration: (int) Treatment Duration - :param vRate: (float) Ultrafiltration Rate - :return: none + @param accepted: (int) boolean accept/reject response + @param reason: (int) rejection reason + @param volume: (float) Ultrafiltration Volume + @param duration: (int) Treatment Duration + @param rate: (float) Ultrafiltration Rate + @return: none """ - payload = integer_to_bytearray(vAccepted) - payload += integer_to_bytearray(vReason) - payload += float_to_bytearray(vVolume) - payload += integer_to_bytearray(vDuration) - payload += float_to_bytearray(vRate) + payload = integer_to_bytearray(accepted) + payload += integer_to_bytearray(reason) + payload += float_to_bytearray(volume) + payload += integer_to_bytearray(duration) + payload += float_to_bytearray(rate) message = DenaliMessage.build_message(channel_id=DenaliChannels.hd_to_ui_ch_id, message_id=MsgIds.MSG_ID_USER_UF_SETTINGS_CHANGE_CONFIRMATION_RESPONSE.value, payload=payload) self.can_interface.send(message, 0) - def cmd_set_treatment_adjust_ultrafiltration_confirm_rejected(self, vReason): + def cmd_set_treatment_adjust_ultrafiltration_confirm_rejected(self, reason: int) -> None: """ a convenient method for cmd_set_treatment_adjust_ultrafiltration_confirm_response which only sends a rejection reason and sends other values all as zero - :param vReason: (int) rejection reason - :return: none + @param reason: (int) rejection reason + @return: none """ - self.cmd_set_treatment_adjust_ultrafiltration_confirm_response(0, vReason, 0, 0, 0) + self.cmd_set_treatment_adjust_ultrafiltration_confirm_response(0, reason, 0, 0, 0) - def cmd_set_treatment_time(self, vSecsTotal, vSecsElap, vSecsRem=None): + def cmd_set_treatment_time(self, sec_total: int, sec_elapsed: int, sec_remain: int = 0) -> None: """ the Treatment Time Data message setter/sender method | MSG | CAN ID | Box | Type | Ack | Src | Dst | Description | #1:(U32) | #2:(U32) | #3:(U32) | |:----:|:------:|:---:|:------:|:---:|:---:|:---:|:-----------: |:--: |:--: |:--: | |0x0D00| 0x040 | 7 | 1 Hz | N | HD | All | Treatment Time Data | \ref Data::mTotal | \ref Data::mElapsed | \ref Data::mRemaining | - :param vSecsTotal: (int) Treatment Total Duration in Seconds - :param vSecsElap: (int) Treatment Total Elapsed Time in Seconds - :param vSecsRem: (int) Treatment Remaining Time in Seconds - :return: none + @param sec_total: (int) Treatment Total Duration in Seconds + @param sec_elapsed: (int) Treatment Total Elapsed Time in Seconds + @param sec_remain: (int) Treatment Remaining Time in Seconds + @return: none """ - if vSecsRem is None: - vSecsRem = vSecsTotal - vSecsElap + if sec_remain is None: + sec_remain = sec_total - sec_elapsed - payload = integer_to_bytearray(vSecsTotal) - payload += integer_to_bytearray(vSecsElap) - payload += integer_to_bytearray(vSecsRem) + payload = integer_to_bytearray(sec_total) + payload += integer_to_bytearray(sec_elapsed) + payload += integer_to_bytearray(sec_remain) message = DenaliMessage.build_message(channel_id=DenaliChannels.hd_sync_broadcast_ch_id, message_id=MsgIds.MSG_ID_TREATMENT_TIME.value, payload=payload) self.can_interface.send(message, 0) - def cmd_set_treatment_ultrafiltration_outlet_flow_data(self, vRefUFVol, vMeasUFVol, vRotSpd, vMotSpd, vMCSpd, vMCCurr, vPWM): + def cmd_set_treatment_ultrafiltration_outlet_flow_data(self, ref_uf_vol: float, measured_uf_vol: float, + rot_speed: float, mot_speed: float, mc_speed: float, + mc_current: float, pwm: float) -> None: """ the Outlet Flow Data message setter/sender method | MSG | CAN ID | Box | Type | Ack | Src | Dst | Description | #1:(F32) | #2:(F32) | #3:(F32) | #4:(F32) | #5:(F32) | #6:(F32) | #7:(F32) | |:----:|:------:|:---:|:------:|:---:|:---:|:---:|:-----------: |:--: |:--: |:--: |:--: |:--: |:--: |:--: | |0x0B00| 0x040 | 7 | 1 Hz | N | HD | All | Outlet Flow Data | \ref Data::mRefUFVol | \ref Data::mMeasUFVol | \ref Data::mRotorSpeed | \ref Data::mMotorSpeed | \ref Data::mMotorCtlSpeed | \ref Data::mMotorCtlCurrent | \ref Data::mPWMDtCycle | - :param vRefUFVol: (float) Ref UF Volume - :param vMeasUFVol: (float) Measured UF Volume - :param vRotSpd: (float) Rot Speed - :param vMotSpd: (float) Motor Speed - :param vMCSpd: (float) MC Speed - :param vMCCurr: (float) MC Current - :param vPWM: (float) PWM - :return: none + @param ref_uf_vol: (float) Ref UF Volume + @param measured_uf_vol: (float) Measured UF Volume + @param rot_speed: (float) Rot Speed + @param mot_speed: (float) Motor Speed + @param mc_speed: (float) MC Speed + @param mc_current: (float) MC Current + @param pwm: (float) PWM + @return: none """ - payload = float_to_bytearray(vRefUFVol) - payload += float_to_bytearray(vMeasUFVol) - payload += float_to_bytearray(vRotSpd) - payload += float_to_bytearray(vMotSpd) - payload += float_to_bytearray(vMCSpd) - payload += float_to_bytearray(vMCCurr) - payload += float_to_bytearray(vPWM) + payload = float_to_bytearray(ref_uf_vol) + payload += float_to_bytearray(measured_uf_vol) + payload += float_to_bytearray(rot_speed) + payload += float_to_bytearray(mot_speed) + payload += float_to_bytearray(mc_speed) + payload += float_to_bytearray(mc_current) + payload += float_to_bytearray(pwm) message = DenaliMessage.build_message(channel_id=DenaliChannels.hd_sync_broadcast_ch_id, message_id=MsgIds.MSG_ID_DIALYSATE_OUT_FLOW_DATA.value, payload=payload) self.can_interface.send(message, 0) - def cmd_set_pressure_occlusion_data(self, vArterialPressure, vVenousPressure, vBloodPumpOcclusion, vDialysateInletPumpOcclusion, - vDialysateOutletPumpOcclusion): + def cmd_set_pressure_occlusion_data(self, arterial_prs: float, venous_prs: float, blood_pump_occlusion: int, + dialysate_inlet_pump_occlusion: int, dialysate_outlet_pump_occlusion) -> None: """ the Pressure/Occlusion Data messages setter/sender method | MSG | CAN ID | Box | Type | Ack | Src | Dst | Description | #1:(F32) | #2:(F32) | #3:(U32) | #4:(U32) | #5:(U32) | |:----:|:------:|:---:|:------:|:---:|:---:|:---:|:-----------: |:--: |:--: |:--: |:--: |:--: | |0x0900| 0x040 | 7 | 1 Hz | N | HD | All | PressureOcclusion Data | \ref Data::mArterialPressure | \ref Data::mVenousPressure | \ref Data::mBloodPumpOcclusion | \ref Data::mDialysateInletPumpOcclusion | \ref Data::mDialysateOutletPumpOcclusion | - :param vArterialPressure: (float) Arterial Pressure - :param vVenousPressure: (float) Venous Pressure - :param vBloodPumpOcclusion: (uint) Blood Pump Occlusion - :param vDialysateInletPumpOcclusion: (uint) Dialysate Inlet Pump Occlusion - :param vDialysateOutletPumpOcclusion: (uint) Dialysate Outlet Pump Occlusion - :return: none + @param arterial_prs: (float) Arterial Pressure + @param venous_prs: (float) Venous Pressure + @param blood_pump_occlusion: (uint) Blood Pump Occlusion + @param dialysate_inlet_pump_occlusion: (uint) Dialysate Inlet Pump Occlusion + @param dialysate_outlet_pump_occlusion: (uint) Dialysate Outlet Pump Occlusion + @return: none """ - payload = float_to_bytearray(vArterialPressure) - payload += float_to_bytearray(vVenousPressure) - payload += integer_to_bytearray(vBloodPumpOcclusion) - payload += integer_to_bytearray(vDialysateInletPumpOcclusion) - payload += integer_to_bytearray(vDialysateOutletPumpOcclusion) + payload = float_to_bytearray(arterial_prs) + payload += float_to_bytearray(venous_prs) + payload += integer_to_bytearray(blood_pump_occlusion) + payload += integer_to_bytearray(dialysate_inlet_pump_occlusion) + payload += integer_to_bytearray(dialysate_outlet_pump_occlusion) message = DenaliMessage.build_message(channel_id=DenaliChannels.hd_sync_broadcast_ch_id, message_id=MsgIds.MSG_ID_PRESSURE_OCCLUSION_DATA.value, payload=payload) self.can_interface.send(message, 0) - def cmd_set_treatment_states_data(self, - vSubMode, vUFState, vSalineState, vHeparingState, - vRinsebackState, vRecirculateState, - vBloodPrimeState, vTreatmentEndState, vTreammentStopState): + def cmd_set_treatment_states_data(self, sub_mode: int, uf_state: int, saline_state: int, heparing_state: int, + rinseback_state: int, recirculate_state: int, blood_prime_state: int, + treatment_end_state: int, treamment_stop_state: int) -> None: """ the Treatment States Data message setter/sender method | MSG | CAN ID | Box | Type | Ack | Src | Dst | Description | @@ -1004,53 +1006,58 @@ |:--: |:--: |:--: || | \ref Data::vBloodPrimeState | \ref Data::mTreatmentEndState | \ref Data::vTreammentStopState || - :param vSubMode: (int) Sub-Mode - :param vUFState: (int) UF State - :param vSalineState: (int) Saline Bolus State - :param vHeparingState: (int) Saline Bolus State - :param vRinsebackState: (int) Rinseback State - :param vRecirculateState: (int) Recirculate State - :param vBloodPrimeState: (int) Blood Prime State - :param vTreatmentEndState: (int) Treatment End State - :param vTreammentStopState: (int) Treatment Stop State - :return: none + @param sub_mode: (int) Sub-Mode + @param uf_state: (int) UF State + @param saline_state: (int) Saline Bolus State + @param heparing_state: (int) Saline Bolus State + @param rinseback_state: (int) Rinseback State + @param recirculate_state: (int) Recirculate State + @param blood_prime_state: (int) Blood Prime State + @param treatment_end_state: (int) Treatment End State + @param treamment_stop_state: (int) Treatment Stop State + @return: none """ - payload = integer_to_bytearray(vSubMode) - payload += integer_to_bytearray(vUFState) - payload += integer_to_bytearray(vSalineState) - payload += integer_to_bytearray(vHeparingState) - payload += integer_to_bytearray(vRinsebackState) - payload += integer_to_bytearray(vRecirculateState) - payload += integer_to_bytearray(vBloodPrimeState) - payload += integer_to_bytearray(vTreatmentEndState) - payload += integer_to_bytearray(vTreammentStopState) + payload = integer_to_bytearray(sub_mode) + payload += integer_to_bytearray(uf_state) + payload += integer_to_bytearray(saline_state) + payload += integer_to_bytearray(heparing_state) + payload += integer_to_bytearray(rinseback_state) + payload += integer_to_bytearray(recirculate_state) + payload += integer_to_bytearray(blood_prime_state) + payload += integer_to_bytearray(treatment_end_state) + payload += integer_to_bytearray(treamment_stop_state) message = DenaliMessage.build_message(channel_id=DenaliChannels.hd_sync_broadcast_ch_id, message_id=MsgIds.MSG_ID_TREATMENT_STATE.value, payload=payload) self.can_interface.send(message, 0) - def cmd_set_treatment_start_state(self): + def cmd_set_treatment_start_state(self) -> None: """ starting the treatment for user convenience since Tx is not by default running - :return: none + @return: none """ self.cmd_set_treatment_states_data(TXStates.TREATMENT_DIALYSIS_STATE, TXStates.UF_OFF_STATE, TXStates.SALINE_BOLUS_STATE_IDLE, - TXStates.HEPARIN_STATE_OFF) + TXStates.HEPARIN_STATE_OFF, + TXStates.RINSEBACK_STOP_INIT_STATE, + TXStates.TREATMENT_RECIRC_RECIRC_STATE, + TXStates.BLOOD_PRIME_RAMP_STATE, + TXStates.TREATMENT_END_WAIT_FOR_RINSEBACK_STATE, + TXStates.TREATMENT_STOP_RECIRC_STATE) def cmd_set_hd_operation_mode_data(self, operation_mode: int, operation_sub_mode: int) -> None: """ The HD Operation Mode Data message setter/sender method | MSG | CAN ID | Box | Type | Ack | Src | Dst | Description | #1:(U32) | |:----:|:------:|:---:|:------:|:---:|:---:|:---:|:-----------: |:--: | |0x2500| 0x040 | 7 | 1 Hz | N | HD | All | HD Operation Mode Data | \ref Data::mOpMode | - :param operation_mode: (int) Operation Mode - :param operation_sub_mode: (int) Operation Sub-Mode - :return: None + @param operation_mode: (int) Operation Mode + @param operation_sub_mode: (int) Operation Sub-Mode + @return: None """ payload = integer_to_bytearray(operation_mode) @@ -1062,59 +1069,59 @@ self.can_interface.send(message, 0) - def cmd_set_treatment_saline_bolus_data(self, vTarget, vCumulative, vDelivered): + def cmd_set_treatment_saline_bolus_data(self, target: int, cumulative: float, delivered: float) -> None: """ the Treatment Saline Bolus Data message sender method | MSG | CAN ID | Box | Type | Ack | Src | Dst | Description | #1:(U32) | #2:(F32) | #3:(F32) | |:----:|:------:|:---:|:------:|:---:|:---:|:---:|:-----------: |:--: |:--: |:--: | |0x2F00| 0x040 | 7 | 1 Hz | N | HD | All | Treatment Saline Bolus Data | \ref Data::mTarget | \ref Data::mCumulative | \ref Data::mDelivered | - :param vTarget: (int) Saline Bolus Target Volume - :param vCumulative: (float) Saline Bolus Cumulative Volume - :param vDelivered: (float) Saline Bolus Delivered Volume - :return: none + @param target: (int) Saline Bolus Target Volume + @param cumulative: (float) Saline Bolus Cumulative Volume + @param delivered: (float) Saline Bolus Delivered Volume + @return: none """ - payload = integer_to_bytearray(vTarget) - payload += float_to_bytearray(vCumulative) - payload += float_to_bytearray(vDelivered) + payload = integer_to_bytearray(target) + payload += float_to_bytearray(cumulative) + payload += float_to_bytearray(delivered) message = DenaliMessage.build_message(channel_id=DenaliChannels.hd_sync_broadcast_ch_id, message_id=MsgIds.MSG_ID_SALINE_BOLUS_DATA.value, payload=payload) self.can_interface.send(message, 0) - def cmd_set_saline_bolus_response(self, vAccepted, vReason, vTarget, vState): + def cmd_set_saline_bolus_response(self, accepted: int, reason: int, target: int, state: int) -> None: """ the Saline Bolus Response message sender method | MSG | CAN ID | M.Box | Type | Ack | Src | Dest | Description | #1:(U32) | #2:(U32) | #3:(U32) | #3:(U32) | |:---:|:------:|:-----:|:----:|:---:|:---:|:----:|:---------------------:|:--------------------:|:-------------------:|:-------------------:|:-------------------:| | 20 | 0x020 | 6 | Rsp | Y | HD | UI | Saline Bolus Response | \ref Data::mAccepted | \ref Data::mReason | \ref Data::mTarget | \ref Data::mState | - :param vAccepted: (int) boolean accept/reject response - :param vReason: (int) rejection reason - :param vTarget: (int) Saline Bolus Target Volume - :param vState: (int) Saline Bolus current State - :return: none + @param accepted: (int) boolean accept/reject response + @param reason: (int) rejection reason + @param target: (int) Saline Bolus Target Volume + @param state: (int) Saline Bolus current State + @return: none """ - payload = integer_to_bytearray(vAccepted) - payload += integer_to_bytearray(vReason) - payload += integer_to_bytearray(vTarget) - payload += integer_to_bytearray(vState) + payload = integer_to_bytearray(accepted) + payload += integer_to_bytearray(reason) + payload += integer_to_bytearray(target) + payload += integer_to_bytearray(state) message = DenaliMessage.build_message(channel_id=DenaliChannels.hd_to_ui_ch_id, message_id=MsgIds.MSG_ID_USER_SALINE_BOLUS_RESPONSE.value, payload=payload) self.can_interface.send(message, 0) - def cmd_set_canbus_fault_count(self, count): + def cmd_set_canbus_fault_count(self, count: int) -> None: """ the CANBus fault count message setter/sender method - :param count: (int) Fault Count - :return: none + @param count: (int) Fault Count + @return: none """ payload = integer_to_bytearray(count) @@ -1126,10 +1133,10 @@ self.can_interface.send(message, 0) HDSimulator.wait_for_message_to_be_sent() - def cmd_send_unknown_hd(self): + def cmd_send_unknown_hd(self) -> None: """ the unknown message from HD setter/sender method - :return: none + @return: none """ payload = integer_to_bytearray(0) @@ -1140,188 +1147,190 @@ self.can_interface.send(message, 0) - def cmd_set_treatment_heparin_data(self, vCumulative): + def cmd_set_treatment_heparin_data(self, cumulative: float) -> None: """ the Treatment Heparin Data message setter/sender method | MSG | CAN ID | Box | Type | Ack | Src | Dst | Description | #1:(F32) | |:----:|:------:|:---:|:------:|:---:|:---:|:---:|:-----------: |:--: | |0x4D00| 0x040 | 7 | 1 Hz | N | HD | All | Treatment Heparin Data | \ref Data::mCumulative | - :param vCumulative: (float) Heparin Cumulative Volume - :return: none + @param cumulative: (float) Heparin Cumulative Volume + @return: none """ - payload = float_to_bytearray(vCumulative) + payload = float_to_bytearray(cumulative) message = DenaliMessage.build_message(channel_id=DenaliChannels.hd_sync_broadcast_ch_id, message_id=MsgIds.MSG_ID_HD_HEPARIN_DATA_BROADCAST.value, payload=payload) self.can_interface.send(message, 0) - def cmd_set_heparin_pause_resume_response(self, vAccepted, vReason, vState): + def cmd_set_heparin_pause_resume_response(self, accepted: int, reason: int, state: int) -> None: """ the Heparin Response message setter/sender method | MSG | CAN ID | M.Box | Type | Ack | Src | Dest | Description | #1:(U32) | #2:(U32) | #3:(U32) | |:----:|:------:|:-----:|:----:|:---:|:---:|:----:|:----------------:|:--------------------:|:-------------------:|:-------------------:| |0x4C00| 0x020 | 6 | Rsp | Y | HD | UI | Heparin Response | \ref Data::mAccepted | \ref Data::mReason | \ref Data::mState | - :param vAccepted: (int) boolean accept/reject response - :param vReason: (int) rejection reason - :param vState: (int) Heparin current State - :return: none + @param accepted: (int) boolean accept/reject response + @param reason: (int) rejection reason + @param state: (int) Heparin current State + @return: none """ - payload = integer_to_bytearray(vAccepted) - payload += integer_to_bytearray(vReason) - payload += integer_to_bytearray(vState) + payload = integer_to_bytearray(accepted) + payload += integer_to_bytearray(reason) + payload += integer_to_bytearray(state) message = DenaliMessage.build_message(channel_id=DenaliChannels.hd_to_ui_ch_id, message_id=MsgIds.MSG_ID_HD_HEPARIN_PAUSE_RESUME_RESPONSE.value, payload=payload) self.can_interface.send(message, 0) - def cmd_send_treatment_adjust_pressures_limit_response(self, vAccepted, vReason, vArterialLow, vArterialHigh, vVenousLow, - vVenousHigh): + def cmd_send_treatment_adjust_pressures_limit_response(self, accepted: int, reason: int, + arterial_low: int, arterial_high: int, + venous_low: int, venous_high: int) -> None: """ the Blood/dialysate rate change Response message setter/sender method | MSG | CAN ID | Box | Type | Ack | Src | Dst | Description | #1:(U32) | #2:(U32) | #3:(S32) | #4:(S32) | #3:(S32) | #4:(S32) | |:----:|:------:|:---:|:------:|:---:|:---:|:---:|:-----------: |:--: |:--: |:--: |:--: |:--: |:--: | |0x4700| 0x020 | 6 | Rsp | Y | HD | UI | A/V BP Limit Change Response | \ref Data::mAccepted | \ref Data::mReason | \ref Data::mArterialLow | \ref Data::mArterialHigh | \ref Data::mVenousLow | \ref Data::mVenousHigh | - :param vAccepted: (int) boolean accept/reject response - :param vReason: (int) rejection reason - :param vArterialLow: (int) Arterial Pressure Limit Low (mmHg) - :param vArterialHigh: (int) Arterial Pressure Limit High (mmHg) - :param vVenousLow: (int) Venous Pressure Limit Low (mmHg) - :param vVenousHigh: (int) Venous Pressure Limit High (mmHg) - :return: none + @param accepted: (int) boolean accept/reject response + @param reason: (int) rejection reason + @param arterial_low: (int) Arterial Pressure Limit Low (mmHg) + @param arterial_high: (int) Arterial Pressure Limit High (mmHg) + @param venous_low: (int) Venous Pressure Limit Low (mmHg) + @param venous_high: (int) Venous Pressure Limit High (mmHg) + @return: none """ - payload = integer_to_bytearray(vAccepted) - payload += integer_to_bytearray(vReason) - payload += integer_to_bytearray(vArterialLow) - payload += integer_to_bytearray(vArterialHigh) - payload += integer_to_bytearray(vVenousLow) - payload += integer_to_bytearray(vVenousHigh) + payload = integer_to_bytearray(accepted) + payload += integer_to_bytearray(reason) + payload += integer_to_bytearray(arterial_low) + payload += integer_to_bytearray(arterial_high) + payload += integer_to_bytearray(venous_low) + payload += integer_to_bytearray(venous_high) message = DenaliMessage.build_message(channel_id=DenaliChannels.hd_to_ui_ch_id, message_id=MsgIds.MSG_ID_HD_PRESSURE_LIMITS_CHANGE_RESPONSE.value, payload=payload) self.can_interface.send(message, 0) - def cmd_send_treatment_adjust_rinseback_response(self, vAccepted, vReason): + def cmd_send_treatment_adjust_rinseback_response(self, accepted: int, reason: int) -> None: """ the rinseback state change Response message method | MSG | CAN ID | Box | Type | Ack | Src | Dst | Description | #1:(U32) | #2:(U32) | |:----:|:------:|:---:|:------:|:---:|:---:|:---:|:-----------: |:--: |:--: | |0x5300| 0x020 | 6 | Rsp | Y | HD | UI | Rinseback State Change Response | \ref Data::mAccepted | \ref Data::mReason | - :param vAccepted: (int) boolean accept/reject response - :param vReason : (int) rejection reason - :return: None + @param accepted: (int) boolean accept/reject response + @param reason : (int) rejection reason + @return: None """ - payload = integer_to_bytearray(vAccepted) - payload += integer_to_bytearray(vReason) + payload = integer_to_bytearray(accepted) + payload += integer_to_bytearray(reason) message = DenaliMessage.build_message(channel_id=DenaliChannels.hd_to_ui_ch_id, message_id=MsgIds.MSG_ID_HD_RINSEBACK_CMD_RESPONSE.value, payload=payload) self.can_interface.send(message, 0) - def cmd_send_treatment_rinseback_data(self, vTarget, vCurrent, vRate, vTimeoutTotal, vTimeoutCountDown): + def cmd_send_treatment_rinseback_data(self, target: float, current: float, rate: int, + timeout_total: int, timeout_count_down: int) -> None: """ the rinseback state change Response message method | MSG | CAN ID | Box | Type | Ack | Src | Dst | Description | #1:(F32) | #2:(F32) | #3:(U32) | #4:(U32) | #5:(U32) | |:----:|:------:|:---:|:------:|:---:|:---:|:---:|:-----------: |:--: |:--: |:--: |:--: |:--: | |0x5600| 0x020 | 6 | 1Hz | N | HD | UI | Rinseback progress data | \ref Data::mTarget | \ref Data::mCurrent | \ref Data::mRate | \ref Data::mTimeoutTotal | \ref Data::mTimeoutCountDown | - :param vTarget : (float) the target volume in mL - :param vCurrent : (float) the current volume in mL - :param vRate : (uint ) the current flow rate in mL/min - :param vTimeoutTotal : (uint ) Total Timeout - :param vTimeoutCountDown: (uint ) Current Timeout count down - :return: None + @param target: (float) the target volume in mL + @param current: (float) the current volume in mL + @param rate: (int) the current flow rate in mL/min + @param timeout_total: (int) Total Timeout + @param timeout_count_down: (int) Current Timeout count down + @return: None """ - payload = float_to_bytearray(vTarget) - payload += float_to_bytearray(vCurrent) - payload += integer_to_bytearray(vRate) - payload += integer_to_bytearray(vTimeoutTotal) - payload += integer_to_bytearray(vTimeoutCountDown) + payload = float_to_bytearray(target) + payload += float_to_bytearray(current) + payload += integer_to_bytearray(rate) + payload += integer_to_bytearray(timeout_total) + payload += integer_to_bytearray(timeout_count_down) message = DenaliMessage.build_message(channel_id=DenaliChannels.hd_to_ui_ch_id, message_id=MsgIds.MSG_ID_HD_RINSEBACK_PROGRESS.value, payload=payload) self.can_interface.send(message, 0) - def cmd_send_treatment_recirculate_data(self,vTimeoutTotal, vTimeoutCountDown): + def cmd_send_treatment_recirculate_data(self, timeout_total: int, timeout_count_down: int) -> None: """ the rinseback state change Response message method | MSG | CAN ID | Box | Type | Ack | Src | Dst | Description | #1:(U32) | #2:(U32) | |:----:|:------:|:---:|:------:|:---:|:---:|:---:|:-----------: |:--: |:--: | |0x5A00| 0x020 | 6 | 1Hz | N | HD | UI | Rinseback progress data | \ref Data::mTimeoutTotal | \ref Data::mTimeoutCountDown | - :param vTimeoutTotal : (uint ) Total Timeout - :param vTimeoutCountDown: (uint ) Current Timeout count down - :return: None + @param timeout_total: (int) Total Timeout + @param timeout_count_down: (int) Current Timeout count down + @return: None """ - payload = integer_to_bytearray(vTimeoutTotal) - payload += integer_to_bytearray(vTimeoutCountDown) + payload = integer_to_bytearray(timeout_total) + payload += integer_to_bytearray(timeout_count_down) message = DenaliMessage.build_message(channel_id=DenaliChannels.hd_to_ui_ch_id, message_id=MsgIds.MSG_ID_HD_RECIRC_PROGRESS.value, payload=payload) self.can_interface.send(message, 0) - def cmd_send_treatment_blood_prime_data(self, vTarget, vCurrent): + def cmd_send_treatment_blood_prime_data(self, target: float, current: float): """ the bloodprime state change Response message method | MSG | CAN ID | Box | Type | Ack | Src | Dst | Description | #1:(F32) | #2:(F32) | #2:(U32) | |:----:|:------:|:---:|:------:|:---:|:---:|:---:|:-----------: |:--: |:--: |:--: | |0x5900| 0x020 | 6 | 1Hz | N | HD | UI | bloodprime progress data | \ref Data::mTarget | \ref Data::mCurrent | \ref Data::mRate | - :param vTarget : (float) the target volume in mL - :param vCurrent : (float) the current volume in mL - :return: None + @param target : (float) the target volume in mL + @param current : (float) the current volume in mL + @return: None """ - payload = float_to_bytearray(vTarget) - payload += float_to_bytearray(vCurrent) + payload = float_to_bytearray(target) + payload += float_to_bytearray(current) message = DenaliMessage.build_message(channel_id=DenaliChannels.hd_to_ui_ch_id, message_id=MsgIds.MSG_ID_HD_BLOOD_PRIME_PROGRESS.value, payload=payload) self.can_interface.send(message, 0) - def cmd_send_treatment_adjust_recirculate_response(self, vAccepted, vReason): + def cmd_send_treatment_adjust_recirculate_response(self, accepted: int, reason: int) -> None: """ the recirculate state change Response message method | MSG | CAN ID | Box | Type | Ack | Src | Dst | Description | #1:(U32) | #2:(U32) | |:----:|:------:|:---:|:------:|:---:|:---:|:---:|:-----------: |:--: |:--: | |0x5500| 0x020 | 6 | Rsp | Y | HD | UI | Recirculate State Change Response | \ref Data::mAccepted | \ref Data::mReason | - :param vAccepted: (int) boolean accept/reject response - :param vReason : (int) rejection reason - :return: None + @param accepted: (int) boolean accept/reject response + @param reason : (int) rejection reason + @return: None """ - payload = integer_to_bytearray(vAccepted) - payload += integer_to_bytearray(vReason) + payload = integer_to_bytearray(accepted) + payload += integer_to_bytearray(reason) message = DenaliMessage.build_message(channel_id=DenaliChannels.hd_to_ui_ch_id, message_id=MsgIds.MSG_ID_HD_RECIRC_CMD_RESPONSE.value, payload=payload) self.can_interface.send(message, 0) - def _handler_ui_end_treatment(self, message): + def _handler_ui_end_treatment(self, message: dict) -> None: """ Handler function when received a request to end a treatment @@ -1334,32 +1343,34 @@ if request == 0: self.logger.debug("Request to start rinseback") - self.cmd_send_treatment_adjust_end_response(vAccepted=YES, vReason=0) + self.cmd_send_treatment_adjust_end_response(accepted=YES, reason=0) else: self.logger.debug("End treatment unknown request") - def cmd_send_treatment_adjust_end_response(self, vAccepted, vReason): + def cmd_send_treatment_adjust_end_response(self, accepted: int, reason: int): """ the treatment end state change Response message method | MSG | CAN ID | Box | Type | Ack | Src | Dst | Description | #1:(U32) | #2:(U32) | |:----:|:------:|:---:|:------:|:---:|:---:|:---:|:-----------: |:--: |:--: | |0x5800| 0x020 | 6 | Rsp | Y | HD | UI | Treatment End State Change Response | \ref Data::mAccepted | \ref Data::mReason | - :param vAccepted: (int) boolean accept/reject response - :param vReason : (int) rejection reason - :return: None + @param accepted: (int) boolean accept/reject response + @param reason: (int) rejection reason + @return: None """ - payload = integer_to_bytearray(vAccepted) - payload += integer_to_bytearray(vReason) + payload = integer_to_bytearray(accepted) + payload += integer_to_bytearray(reason) message = DenaliMessage.build_message(channel_id=DenaliChannels.hd_to_ui_ch_id, message_id=MsgIds.MSG_ID_HD_TX_END_CMD_RESPONSE.value, payload=payload) self.can_interface.send(message, 0) - def cmd_send_accelerometer_hd_data(self, vX, vY, vZ, vXMax, vYMax, vZMax, vXTilt, vYTilt, vZTilt ): + def cmd_send_accelerometer_hd_data(self, x: float, y: float, z: float, + x_max: float, y_max: float, z_max: float, + x_tilt: float, y_tilt: float, z_tilt: float) -> None: """ the accelerometer hd data message method | MSG | CAN ID | Box | Type | Ack | Src | Dst | Description | @@ -1378,47 +1389,46 @@ |:--: |:--: |:--: | | \ref Data::mXTilt | \ref Data::mYTilt | \ref Data::mXTilt | - :param vX: x axis - :param vY: y axis - :param vZ: z axis - :param vXMax: x axis max - :param vYMax: y axis max - :param vZMax: z axis max - :param vXTilt: x axis tilt - :param vYTilt: y axis tilt - :param vZTilt: z axis tilt - :return: None + @param x: float - x axis + @param y: float - y axis + @param z: float - z axis + @param x_max: float - x axis max + @param y_max: float - y axis max + @param z_max: float - z axis max + @param x_tilt: float - x axis tilt + @param y_tilt: float - y axis tilt + @param z_tilt: float - z axis tilt + @return: None """ - payload = float_to_bytearray(vX) - payload += float_to_bytearray(vY) - payload += float_to_bytearray(vZ) - payload += float_to_bytearray(vXMax) - payload += float_to_bytearray(vYMax) - payload += float_to_bytearray(vZMax) - payload += float_to_bytearray(vXTilt) - payload += float_to_bytearray(vYTilt) - payload += float_to_bytearray(vZTilt) + payload = float_to_bytearray(x) + payload += float_to_bytearray(y) + payload += float_to_bytearray(z) + payload += float_to_bytearray(x_max) + payload += float_to_bytearray(y_max) + payload += float_to_bytearray(z_max) + payload += float_to_bytearray(x_tilt) + payload += float_to_bytearray(y_tilt) + payload += float_to_bytearray(z_tilt) message = DenaliMessage.build_message(channel_id=DenaliChannels.hd_to_ui_ch_id, message_id=MsgIds.MSG_ID_HD_ACCELEROMETER_DATA.value, payload=payload) self.can_interface.send(message, 0) - def _handler_request_hd_version(self, message: dict): + def _handler_request_hd_version(self) -> None: """ Handles a request for the HD version - @param message: (dict) the received message @return: None """ self.logger.debug("Handling request for hd version.") self.cmd_send_version_hd_data(9, 9, 9, 9, 9, 9, 9, 9) self.cmd_send_hd_serial_number() - def cmd_send_hd_serial_number(self): + def cmd_send_hd_serial_number(self) -> None: """ Sends the hd serial number response @@ -1434,28 +1444,29 @@ self.can_interface.send(message, 0) - def cmd_send_version_hd_data(self, vMajor, vMinor, vMicro, vBuild, vFPGA_id, vFPGA_Major, vFPGA_Minor, vFPGA_Lab ): + def cmd_send_version_hd_data(self, major: int, minor: int, micro: int, build: int, + fpga_id: int, fpga_major: int, fpga_minor: int, fpga_lab: int) -> None: """ the hd version response message method - :param vMajor: Major version number - :param vMinor: Minor version number - :param vMicro: Micro version number - :param vBuild: Build version number - :param vFPGA_id: FPGA id version number - :param vFPGA_Major: FPGA Major version number - :param vFPGA_Minor: FPGA Minor version number - :param vFPGA_Lab: FPGA Lab version number - :return: None + @param major: integer - Major version number + @param minor: integer - Minor version number + @param micro: integer - Micro version number + @param build: integer - Build version number + @param fpga_id: integer - FPGA id version number + @param fpga_major: integer - FPGA Major version number + @param fpga_minor: integer - FPGA Minor version number + @param fpga_lab: integer - FPGA Lab version number + @return: None """ - payload = byte_to_bytearray(vMajor) - payload += byte_to_bytearray(vMinor) - payload += byte_to_bytearray(vMicro) - payload += short_to_bytearray(vBuild) - payload += byte_to_bytearray(vFPGA_id) - payload += byte_to_bytearray(vFPGA_Major) - payload += byte_to_bytearray(vFPGA_Minor) - payload += byte_to_bytearray(vFPGA_Lab) + payload = byte_to_bytearray(major) + payload += byte_to_bytearray(minor) + payload += byte_to_bytearray(micro) + payload += short_to_bytearray(build) + payload += byte_to_bytearray(fpga_id) + payload += byte_to_bytearray(fpga_major) + payload += byte_to_bytearray(fpga_minor) + payload += byte_to_bytearray(fpga_lab) message = DenaliMessage.build_message(channel_id=DenaliChannels.hd_to_ui_ch_id, message_id=MsgIds.MSG_ID_HD_VERSION.value, @@ -1471,27 +1482,27 @@ return self.alarms_simulator def cmd_send_pre_treatment_state_data(self, - sub_mode, - water_sample_state, - consumables_self_test_state, - no_cartridge_self_test_state, - installation_state, - dry_self_test_state, - prime_state, - recirculate_state, - patient_connection_state): + sub_mode: int, + water_sample_state: int, + consumables_self_test_state: int, + no_cartridge_self_test_state: int, + installation_state: int, + dry_self_test_state: int, + prime_state: int, + recirculate_state: int, + patient_connection_state: int) -> None: """ sends the broadcast message of the pre-treatment states - :param sub_mode : (U32) the main pre treatment state - :param water_sample_state : (U32) water sample state - :param consumables_self_test_state : (U32) consumables self test state - :param no_cartridge_self_test_state : (U32) no cartridge self-test state - :param installation_state : (U32) installation state - :param dry_self_test_state : (U32) dry self-test state - :param prime_state : (U32) prime state - :param recirculate_state : (U32) recirculate state - :param patient_connection_state : (U32) patient connection state - :return: + @param sub_mode : (int) the main pre treatment state + @param water_sample_state : (int) water sample state + @param consumables_self_test_state : (int) consumables self test state + @param no_cartridge_self_test_state : (int) no cartridge self-test state + @param installation_state : (int) installation state + @param dry_self_test_state : (int) dry self-test state + @param prime_state : (int) prime state + @param recirculate_state : (int) recirculate state + @param patient_connection_state : (int) patient connection state + @return: """ payload = integer_to_bytearray(sub_mode) payload += integer_to_bytearray(water_sample_state) @@ -1509,13 +1520,12 @@ self.can_interface.send(message, 0) - - def cmd_send_pre_treatment_water_sample_response(self, accepted, reason ): + def cmd_send_pre_treatment_water_sample_response(self, accepted: int, reason: int) -> None: """ send the pretreatment water sample response - :param accepted: (U32) accept or reject - :param reason: (U32) rejection reason - :return: None + @param accepted: (int) accept or reject + @param reason: (int) rejection reason + @return: None """ payload = integer_to_bytearray(accepted) payload += integer_to_bytearray(reason) @@ -1526,12 +1536,12 @@ self.can_interface.send(message, 0) - def cmd_send_pre_treatment_self_test_no_cartridge_progress_data(self, total, countdown): + def cmd_send_pre_treatment_self_test_no_cartridge_progress_data(self, total: int, countdown: int) -> None: """ send the pretreatment no cartridge self-tests progress data - :param accepted: (U32) Total time in second - :param reason: (U32) count down time in second - :return: None + @param total: (int) Total time in second + @param countdown: (int) count down time in second + @return: None """ payload = integer_to_bytearray(total) payload += integer_to_bytearray(countdown) @@ -1542,12 +1552,12 @@ self.can_interface.send(message, 0) - def cmd_send_pre_treatment_self_test_dry_progress_data(self, total, countdown): + def cmd_send_pre_treatment_self_test_dry_progress_data(self, total: int, countdown: int) -> None: """ send the pretreatment dry self-tests progress data - :param accepted: (U32) Total time in second - :param reason: (U32) count down time in second - :return: None + @param total: (int) Total time in second + @param countdown: (int) count down time in second + @return: None """ payload = integer_to_bytearray(total) payload += integer_to_bytearray(countdown) @@ -1558,12 +1568,12 @@ self.can_interface.send(message, 0) - def cmd_send_pre_treatment_disposables_prime_progress_data(self, timeout, countdown): + def cmd_send_pre_treatment_disposables_prime_progress_data(self, timeout: int, countdown: int) -> None: """ Broadcasts the progress time data of pre-treatment disposables priming to the UI - :param timeout : (int) the total progress time timeout in seconds - :param countdown: (int) the remaining time in seconds - :return: None + @param timeout : (int) the total progress time timeout in seconds + @param countdown: (int) the remaining time in seconds + @return: None """ payload = bytearray() payload += integer_to_bytearray(timeout) @@ -1575,12 +1585,12 @@ self.can_interface.send(message, 0) - def cmd_send_pre_treatment_prime_start_response(self, accepted, reason ): + def cmd_send_pre_treatment_prime_start_response(self, accepted: int, reason: int) -> None: """ send the pretreatment prime start response - :param accepted: (U32) accept or reject - :param reason: (U32) rejection reason - :return: None + @param accepted: (int) accept or reject + @param reason: (int) rejection reason + @return: None """ payload = integer_to_bytearray(accepted) payload += integer_to_bytearray(reason) @@ -1591,12 +1601,12 @@ self.can_interface.send(message, 0) - def cmd_send_pre_treatment_continue_to_treament_response(self, accepted, reason ): + def cmd_send_pre_treatment_continue_to_treament_response(self, accepted: int, reason: int) -> None: """ send the pretreatment continue to treatment response - :param accepted: (U32) accept or reject - :param reason: (U32) rejection reason - :return: None + @param accepted: (int) accept or reject + @param reason: (int) rejection reason + @return: None """ payload = integer_to_bytearray(accepted) payload += integer_to_bytearray(reason) @@ -1607,12 +1617,12 @@ self.can_interface.send(message, 0) - def cmd_send_pre_treatment_patient_connection_confirm_response(self, accepted, reason ): + def cmd_send_pre_treatment_patient_connection_confirm_response(self, accepted: int, reason: int) -> None: """ send the pretreatment patient connection confirm response - :param accepted: (U32) accept or reject - :param reason: (U32) rejection reason - :return: None + @param accepted: (int) accept or reject + @param reason: (int) rejection reason + @return: None """ payload = integer_to_bytearray(accepted) payload += integer_to_bytearray(reason) @@ -1623,12 +1633,12 @@ self.can_interface.send(message, 0) - def cmd_send_post_treatment_disposable_removal_confirm_response(self, accepted, reason ): + def cmd_send_post_treatment_disposable_removal_confirm_response(self, accepted: int, reason: int) -> None: """ send post treatment disposable removal confirm response - :param accepted: (U32) accept or reject - :param reason: (U32) rejection reason - :return: None + @param accepted: (int) accept or reject + @param reason: (int) rejection reason + @return: None """ payload = integer_to_bytearray(accepted) payload += integer_to_bytearray(reason) @@ -1639,22 +1649,6 @@ self.can_interface.send(message, 0) - def cmd_send_post_treatment_disposable_removal_confirm_response(self, accepted, reason ): - """ - send post treatment disposable removal confirm response - :param accepted: (U32) accept or reject - :param reason: (U32) rejection reason - :return: None - """ - payload = integer_to_bytearray(accepted) - payload += integer_to_bytearray(reason) - - message = DenaliMessage.build_message(channel_id=DenaliChannels.hd_to_ui_ch_id, - message_id=MsgIds.MSG_ID_HD_DISPOSABLE_REMOVAL_CONFIRM_RESPONSE.value, - payload=payload) - - self.can_interface.send(message, 0) - def cmd_send_post_treatment_log_response(self, accepted: bool, reason: int, bood_flow_rate: int, dialysate_flow_rate: int, @@ -1692,42 +1686,42 @@ ) -> None: """ send post treatment log response - :param accepted: true if accpeted - :param reason: the rejection reason - :param bood_flow_rate: bood flow rate - :param dialysate_flow_rate: dialysate flow rate - :param treatment_duration: treatment duration - :param actual_treatment_duration: actual treatment duration - :param acid_concentrate_type: acid concentrate type - :param bicarbonate_concentrate_type: bicarbonate concentrate type - :param potassium_concentration: potassium concentration - :param calcium_concentration: calcium concentration - :param bicarbonate_concentration: bicarbonate concentration - :param sodium_concentration: sodium concentration - :param dialysate_temperature: dialysate temperature - :param dialyzer_type: dialyzer type - :param treatment_date_time: treatment date time - :param average_blood_flow: average blood flow - :param average_dialysate_flow: average dialysate flow - :param dialysate_volume_used: dialysate volume used - :param average_dialysate_temp: average dialysate temp - :param target_uf_volume: target uf volume - :param actual_uf_volume: actual uf volume - :param target_uf_rate: target uf rate - :param actual_uf_rate: actual uf rate - :param saline_bolus_volume: saline bolus volume - :param heparin_type: heparin type - :param heparin_concentration: heparin concentration - :param heparin_bolus_volume: heparin bolus volume - :param heparin_dispense_rate: heparin dispense rate - :param heparin_pre_stop: heparin pre stop - :param heparin_delivered_volume: heparin delivered volume - :param average_arterial_pressure: average arterial pressure - :param average_venous_pressure: average venous pressure - :param end_treatment_early_alarm: end treatment early alarm - :param device_id: device id - :param water_sample_test_result: water sample test result - :return: + @param accepted: true if accpeted + @param reason: the rejection reason + @param bood_flow_rate: bood flow rate + @param dialysate_flow_rate: dialysate flow rate + @param treatment_duration: treatment duration + @param actual_treatment_duration: actual treatment duration + @param acid_concentrate_type: acid concentrate type + @param bicarbonate_concentrate_type: bicarbonate concentrate type + @param potassium_concentration: potassium concentration + @param calcium_concentration: calcium concentration + @param bicarbonate_concentration: bicarbonate concentration + @param sodium_concentration: sodium concentration + @param dialysate_temperature: dialysate temperature + @param dialyzer_type: dialyzer type + @param treatment_date_time: treatment date time + @param average_blood_flow: average blood flow + @param average_dialysate_flow: average dialysate flow + @param dialysate_volume_used: dialysate volume used + @param average_dialysate_temp: average dialysate temp + @param target_uf_volume: target uf volume + @param actual_uf_volume: actual uf volume + @param target_uf_rate: target uf rate + @param actual_uf_rate: actual uf rate + @param saline_bolus_volume: saline bolus volume + @param heparin_type: heparin type + @param heparin_concentration: heparin concentration + @param heparin_bolus_volume: heparin bolus volume + @param heparin_dispense_rate: heparin dispense rate + @param heparin_pre_stop: heparin pre stop + @param heparin_delivered_volume: heparin delivered volume + @param average_arterial_pressure: average arterial pressure + @param average_venous_pressure: average venous pressure + @param end_treatment_early_alarm: end treatment early alarm + @param device_id: device id + @param water_sample_test_result: water sample test result + @return: """ payload = integer_to_bytearray(accepted) @@ -1772,37 +1766,38 @@ self.can_interface.send(message, 0) - def cmd_send_treatment_log_data(self, bloodFlowRate: int, dialysateFlowRate: int, ufRate: float, arterialPressure: float, venousPressure: float) -> None: + def cmd_send_treatment_log_data(self, blood_flow_rate: int, dialysate_flow_rate: int, uf_rate: float, + arterial_pressure: float, venous_pressure: float) -> None: """ send the treatment log data - :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 + @param blood_flow_rate: (int) blood flow rate + @param dialysate_flow_rate: (int) Dialysate Flow Rate + @param uf_rate: (float) UF Rate + @param arterial_pressure: (float) Arterial Pressure + @param venous_pressure: (float) Venous Pressure + @return: None """ - 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) + payload = integer_to_bytearray(blood_flow_rate) + payload += integer_to_bytearray(dialysate_flow_rate) + payload += float_to_bytearray(uf_rate) + payload += float_to_bytearray(arterial_pressure) + payload += float_to_bytearray(venous_pressure) message = DenaliMessage.build_message(channel_id=DenaliChannels.hd_to_ui_ch_id, message_id=MsgIds.MSG_ID_HD_TREATMENT_LOG_PERIODIC_DATA.value, payload=payload) self.can_interface.send(message, 0) - def cmd_send_treatment_log_alarm(self, alarmID: int, parameter1: float, parameter2: float) -> None: + def cmd_send_treatment_log_alarm(self, alarm_id: int, parameter1: float, parameter2: float) -> None: """ send the treatment log data - :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 + @param alarm_id: (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(alarmID) + payload = integer_to_bytearray(alarm_id) payload += float_to_bytearray(parameter1) payload += float_to_bytearray(parameter2) @@ -1812,17 +1807,17 @@ self.can_interface.send(message, 0) - def cmd_send_treatment_log_event(self, eventID: int, oldValue: float, newValue: float) -> None: + def cmd_send_treatment_log_event(self, event_id: int, old_value: float, new_value: float) -> None: """ send the treatment log data - :param alarmID: (U32) alarm ID - :param oldValue: (F32) the old value - :param newValue: (F32) the new value - :return: none + @param event_id: (U32) alarm ID + @param old_value: (F32) the old value + @param new_value: (F32) the new value + @return: none """ - payload = integer_to_bytearray(eventID) - payload += float_to_bytearray(oldValue) - payload += float_to_bytearray(newValue) + payload = integer_to_bytearray(event_id) + payload += float_to_bytearray(old_value) + payload += float_to_bytearray(new_value) message = DenaliMessage.build_message(channel_id=DenaliChannels.hd_to_ui_ch_id, message_id=MsgIds.MSG_ID_HD_TREATMENT_LOG_EVENT.value, @@ -1833,14 +1828,14 @@ def cmd_send_hd_disinfect_response(self, accepted: bool, reason: int) -> None: """ the HD response to the request from UI to initiate a disinfection/flush - :param accepted: boolean accepted or rejected - :param reason: the rejection reason - :return: None + @param accepted: boolean accepted or rejected + @param reason: the rejection reason + @return: None """ payload = integer_to_bytearray(accepted) payload += integer_to_bytearray(reason) - message = DenaliMessage.build_message(channel_id= DenaliChannels.hd_to_ui_ch_id, + message = DenaliMessage.build_message(channel_id=DenaliChannels.hd_to_ui_ch_id, message_id=MsgIds.MSG_ID_HD_DISINFECT_RESPONSE.value, payload=payload) @@ -1849,14 +1844,14 @@ def cmd_send_hd_disinfect_chemical_confirm(self, accepted: bool, reason: int) -> None: """ the HD response to the UI sending the user chimical disinfection steps confirm. - :param accepted: boolean accepted or rejected - :param reason: the rejection reason - :return: None + @param accepted: boolean accepted or rejected + @param reason: the rejection reason + @return: None """ payload = integer_to_bytearray(accepted) payload += integer_to_bytearray(reason) - message = DenaliMessage.build_message(channel_id= DenaliChannels.hd_to_ui_ch_id, + message = DenaliMessage.build_message(channel_id=DenaliChannels.hd_to_ui_ch_id, message_id=MsgIds.MSG_ID_HD_CHEM_DISINFECT_CONFIRM_RESPONSE.value, payload=payload) @@ -1870,24 +1865,24 @@ parameters_payload: any = 0x00) -> 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 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 + @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 is_pure_data: The message only has data + @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 = "" if not is_pure_data: payload = integer_to_bytearray(accepted) payload += integer_to_bytearray(reason) - if has_parameters: - payload += parameters_payload - else: - if has_parameters: - payload = parameters_payload + if has_parameters: + payload += parameters_payload - message = DenaliMessage.build_message(channel_id= DenaliChannels.hd_to_ui_ch_id, + message = DenaliMessage.build_message(channel_id=DenaliChannels.hd_to_ui_ch_id, message_id=message_id, payload=payload) @@ -1896,24 +1891,24 @@ def cmd_send_general_hd_progress_data(self, message_id: int, total: int, countdown: int) -> None: """ 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 - :return: None + @param message_id: the id of the message + @param total: the total value of the progress data + @param countdown: the remaining or countdown value + @return: None """ payload = integer_to_bytearray(total) payload += integer_to_bytearray(countdown) - message = DenaliMessage.build_message(channel_id= DenaliChannels.hd_to_ui_ch_id, + message = DenaliMessage.build_message(channel_id=DenaliChannels.hd_to_ui_ch_id, message_id=message_id, payload=payload) self.can_interface.send(message, 0) def cmd_ack_send_hd(self, seq: int) -> None: """ sending hd ack message by the sequence seq - :param seq: the message sequence number - :return: None + @param seq: the message sequence number + @return: None """ message = DenaliMessage.build_message(channel_id=DenaliChannels.hd_to_ui_ch_id, message_id=GuiActionType.Acknow, Index: dialin/ui/hd_simulator_alarms.py =================================================================== diff -u -rebf0a72a1a1a52f3cfe20975de4857201275888c -rf990c9bb863683c74bbe78c71932a14d7cf35422 --- dialin/ui/hd_simulator_alarms.py (.../hd_simulator_alarms.py) (revision ebf0a72a1a1a52f3cfe20975de4857201275888c) +++ dialin/ui/hd_simulator_alarms.py (.../hd_simulator_alarms.py) (revision f990c9bb863683c74bbe78c71932a14d7cf35422) @@ -22,7 +22,7 @@ DenaliChannels) from logging import Logger from ..utils.base import AbstractSubSystem -from ..utils.conversions import integer_to_bytearray, integer_to_bit_array, float_to_bytearray +from ..utils.conversions import integer_to_bytearray, float_to_bytearray from ..common.msg_defs import MsgIds, MsgFieldPositions from ..common.alarm_defs import AlarmList from dialin.common.prs_defs import AlarmDataTypes @@ -35,75 +35,74 @@ HIGH_PRIORITY_COLOR = "#c53b33" MED_LOW_PRIORITY_COLOR = "#f5a623" -class Alarms: +class Alarms: # TODO: this should be generated from FW # ALARM_ID = (priority, alarmID, escalates in, silent_espires_in, flags) - ALARM_ID_NO_ALARM = (NONE, 0, 0, 0, 0) - ALARM_ID_SOFTWARE_FAULT = (HIGH, 1, 0, 0, 0) - ALARM_ID_STUCK_BUTTON_TEST_FAILED = (HIGH, 2, 0, 0, 0) - ALARM_ID_FPGA_POST_TEST_FAILED = (HIGH, 3, 0, 0, 0) - ALARM_ID_WATCHDOG_POST_TEST_FAILED = (HIGH, 4, 0, 0, 0) - ALARM_ID_UI_COMM_POST_FAILED = (HIGH, 5, 0, 0, 0) - ALARM_ID_BLOOD_PUMP_MC_CURRENT_CHECK = (MED, 6, 0, 0, 0) - ALARM_ID_BLOOD_PUMP_OFF_CHECK = (MED, 7, 0, 0, 0) - ALARM_ID_BLOOD_PUMP_MC_DIRECTION_CHECK = (MED, 8, 0, 0, 0) - ALARM_ID_BLOOD_PUMP_ROTOR_SPEED_CHECK = (HIGH, 9, 0, 0, 0) - ALARM_ID_DIAL_IN_PUMP_MC_CURRENT_CHECK = (MED, 10, 0, 0, 0) - ALARM_ID_DIAL_IN_PUMP_OFF_CHECK = (MED, 11, 0, 0, 0) - ALARM_ID_DIAL_IN_PUMP_MC_DIRECTION_CHECK = (MED, 12, 0, 0, 0) - ALARM_ID_DIAL_IN_PUMP_ROTOR_SPEED_CHECK = (HIGH, 13, 0, 0, 0) - ALARM_ID_DIAL_OUT_PUMP_MC_CURRENT_CHECK = (MED, 14, 0, 0, 0) - ALARM_ID_DIAL_OUT_PUMP_OFF_CHECK = (MED, 15, 0, 0, 0) - ALARM_ID_DIAL_OUT_PUMP_MC_DIRECTION_CHECK = (MED, 16, 0, 0, 0) - ALARM_ID_DIAL_OUT_PUMP_ROTOR_SPEED_CHECK = (HIGH, 17, 0, 0, 0) - ALARM_ID_WATCHDOG_EXPIRED = (HIGH, 18, 0, 0, 0) - ALARM_ID_RTC_COMM_ERROR = (HIGH, 19, 0, 0, 0) - ALARM_ID_RTC_CONFIG_ERROR = (HIGH, 20, 0, 0, 0) - ALARM_ID_DG_COMM_TIMEOUT = (HIGH, 21, 0, 0, 0) - ALARM_ID_UI_COMM_TIMEOUT = (HIGH, 22, 0, 0, 0) - ALARM_ID_COMM_TOO_MANY_BAD_CRCS = (HIGH, 23, 0, 0, 0) - ALARM_ID_TREATMENT_STOPPED_BY_USER = (LOW, 24, 0, 0, 0) - ALARM_ID_BLOOD_SITTING_WARNING = (MED, 25, 0, 0, 0) - ALARM_ID_BLOOD_SITTING_TOO_LONG_NO_RESUME = (MED, 26, 0, 0, 0) - ALARM_ID_BLOOD_SITTING_TOO_LONG_NO_RINSEBACK = (HIGH, 27, 0, 0, 0) - ALARM_ID_CAN_MESSAGE_NOT_ACKED = (HIGH, 28, 0, 0, 0) - ALARM_ID_OCCLUSION_BLOOD_PUMP = (HIGH, 29, 0, 0, 0) - ALARM_ID_OCCLUSION_DIAL_IN_PUMP = (HIGH, 30, 0, 0, 0) - ALARM_ID_OCCLUSION_DIAL_OUT_PUMP = (HIGH, 31, 0, 0, 0) - ALARM_ID_ARTERIAL_PRESSURE_LOW = (HIGH, 32, 0, 0, 0) - ALARM_ID_ARTERIAL_PRESSURE_HIGH = (HIGH, 33, 0, 0, 0) - ALARM_ID_VENOUS_PRESSURE_LOW = (HIGH, 34, 0, 0, 0) - ALARM_ID_VENOUS_PRESSURE_HIGH = (HIGH, 35, 0, 0, 0) - ALARM_ID_UF_RATE_TOO_HIGH_ERROR = (HIGH, 36, 0, 0, 0) - ALARM_ID_UF_VOLUME_ACCURACY_ERROR = (HIGH, 37, 0, 0, 0) - ALARM_ID_RTC_BATTERY_LOW = (HIGH, 38, 0, 0, 0) - ALARM_ID_RTC_OR_TIMER_ACCURACY_FAILURE = (HIGH, 39, 0, 0, 0) - ALARM_ID_RTC_RAM_OPS_ERROR = (HIGH, 40, 0, 0, 0) - ALARM_ID_NVDATA_EEPROM_OPS_FAILURE = (HIGH, 41, 0, 0, 0) - ALARM_ID_NVDATA_MFG_RECORD_CRC_ERROR = (HIGH, 42, 0, 0, 0) - ALARM_ID_NVDATA_SRVC_RECORD_CRC_ERROR = (HIGH, 43, 0, 0, 0) - ALARM_ID_NVDATA_CAL_RECORD_CRC_ERROR = (HIGH, 44, 0, 0, 0) - ALARM_ID_NVDATA_HW_USAGE_DATA_CRC_ERROR = (HIGH, 45, 0, 0, 0) - ALARM_ID_NVDATA_DISINFECTION_DATE_CRC_ERROR = (HIGH, 46, 0, 0, 0) - ALARM_ID_RO_PUMP_OUT_PRESSURE_OUT_OF_RANGE = (HIGH, 47, 0, 0, 0) - ALARM_ID_TEMPERATURE_SENSORS_OUT_OF_RANGE = (HIGH, 48, 0, 0, 0) - ALARM_ID_TEMPERATURE_SENSORS_INCONSISTENT = (HIGH, 49, 0, 0, 0) - ALARM_ID_HD_COMM_TIMEOUT = (HIGH, 50, 0, 0, 0) - ALARM_ID_VALVE_CONTROL_FAILURE = (HIGH, 51, 0, 0, 0) - ALARM_ID_BLOOD_PUMP_FLOW_VS_MOTOR_SPEED_CHECK = (HIGH, 52, 0, 0, 0) - ALARM_ID_DIAL_IN_PUMP_FLOW_VS_MOTOR_SPEED_CHECK = (HIGH, 53, 0, 0, 0) - ALARM_ID_DIAL_OUT_PUMP_FLOW_VS_MOTOR_SPEED_CHECK = (HIGH, 54, 0, 0, 0) - ALARM_ID_BLOOD_PUMP_MOTOR_SPEED_CHECK = (HIGH, 55, 0, 0, 0) - ALARM_ID_DIAL_IN_PUMP_MOTOR_SPEED_CHECK = (HIGH, 56, 0, 0, 0) - ALARM_ID_DIAL_OUT_PUMP_MOTOR_SPEED_CHECK = (HIGH, 57, 0, 0, 0) - ALARM_ID_BLOOD_PUMP_ROTOR_SPEED_TOO_HIGH = (HIGH, 58, 0, 0, 0) - ALARM_ID_INLET_WATER_TEMPERATURE_OUT_OF_RANGE = (HIGH, 59, 0, 0, 0) - ALARM_ID_DOES_NOT_EXIST = (HIGH, 99, 0, 0, 0) + ALARM_ID_NO_ALARM = (NONE, 0, 0, 0, 0) + ALARM_ID_SOFTWARE_FAULT = (HIGH, 1, 0, 0, 0) + ALARM_ID_STUCK_BUTTON_TEST_FAILED = (HIGH, 2, 0, 0, 0) + ALARM_ID_FPGA_POST_TEST_FAILED = (HIGH, 3, 0, 0, 0) + ALARM_ID_WATCHDOG_POST_TEST_FAILED = (HIGH, 4, 0, 0, 0) + ALARM_ID_UI_COMM_POST_FAILED = (HIGH, 5, 0, 0, 0) + ALARM_ID_BLOOD_PUMP_MC_CURRENT_CHECK = (MED, 6, 0, 0, 0) + ALARM_ID_BLOOD_PUMP_OFF_CHECK = (MED, 7, 0, 0, 0) + ALARM_ID_BLOOD_PUMP_MC_DIRECTION_CHECK = (MED, 8, 0, 0, 0) + ALARM_ID_BLOOD_PUMP_ROTOR_SPEED_CHECK = (HIGH, 9, 0, 0, 0) + ALARM_ID_DIAL_IN_PUMP_MC_CURRENT_CHECK = (MED, 10, 0, 0, 0) + ALARM_ID_DIAL_IN_PUMP_OFF_CHECK = (MED, 11, 0, 0, 0) + ALARM_ID_DIAL_IN_PUMP_MC_DIRECTION_CHECK = (MED, 12, 0, 0, 0) + ALARM_ID_DIAL_IN_PUMP_ROTOR_SPEED_CHECK = (HIGH, 13, 0, 0, 0) + ALARM_ID_DIAL_OUT_PUMP_MC_CURRENT_CHECK = (MED, 14, 0, 0, 0) + ALARM_ID_DIAL_OUT_PUMP_OFF_CHECK = (MED, 15, 0, 0, 0) + ALARM_ID_DIAL_OUT_PUMP_MC_DIRECTION_CHECK = (MED, 16, 0, 0, 0) + ALARM_ID_DIAL_OUT_PUMP_ROTOR_SPEED_CHECK = (HIGH, 17, 0, 0, 0) + ALARM_ID_WATCHDOG_EXPIRED = (HIGH, 18, 0, 0, 0) + ALARM_ID_RTC_COMM_ERROR = (HIGH, 19, 0, 0, 0) + ALARM_ID_RTC_CONFIG_ERROR = (HIGH, 20, 0, 0, 0) + ALARM_ID_DG_COMM_TIMEOUT = (HIGH, 21, 0, 0, 0) + ALARM_ID_UI_COMM_TIMEOUT = (HIGH, 22, 0, 0, 0) + ALARM_ID_COMM_TOO_MANY_BAD_CRCS = (HIGH, 23, 0, 0, 0) + ALARM_ID_TREATMENT_STOPPED_BY_USER = (LOW, 24, 0, 0, 0) + ALARM_ID_BLOOD_SITTING_WARNING = (MED, 25, 0, 0, 0) + ALARM_ID_BLOOD_SITTING_TOO_LONG_NO_RESUME = (MED, 26, 0, 0, 0) + ALARM_ID_BLOOD_SITTING_TOO_LONG_NO_RINSEBACK = (HIGH, 27, 0, 0, 0) + ALARM_ID_CAN_MESSAGE_NOT_ACKED = (HIGH, 28, 0, 0, 0) + ALARM_ID_OCCLUSION_BLOOD_PUMP = (HIGH, 29, 0, 0, 0) + ALARM_ID_OCCLUSION_DIAL_IN_PUMP = (HIGH, 30, 0, 0, 0) + ALARM_ID_OCCLUSION_DIAL_OUT_PUMP = (HIGH, 31, 0, 0, 0) + ALARM_ID_ARTERIAL_PRESSURE_LOW = (HIGH, 32, 0, 0, 0) + ALARM_ID_ARTERIAL_PRESSURE_HIGH = (HIGH, 33, 0, 0, 0) + ALARM_ID_VENOUS_PRESSURE_LOW = (HIGH, 34, 0, 0, 0) + ALARM_ID_VENOUS_PRESSURE_HIGH = (HIGH, 35, 0, 0, 0) + ALARM_ID_UF_RATE_TOO_HIGH_ERROR = (HIGH, 36, 0, 0, 0) + ALARM_ID_UF_VOLUME_ACCURACY_ERROR = (HIGH, 37, 0, 0, 0) + ALARM_ID_RTC_BATTERY_LOW = (HIGH, 38, 0, 0, 0) + ALARM_ID_RTC_OR_TIMER_ACCURACY_FAILURE = (HIGH, 39, 0, 0, 0) + ALARM_ID_RTC_RAM_OPS_ERROR = (HIGH, 40, 0, 0, 0) + ALARM_ID_NVDATA_EEPROM_OPS_FAILURE = (HIGH, 41, 0, 0, 0) + ALARM_ID_NVDATA_MFG_RECORD_CRC_ERROR = (HIGH, 42, 0, 0, 0) + ALARM_ID_NVDATA_SRVC_RECORD_CRC_ERROR = (HIGH, 43, 0, 0, 0) + ALARM_ID_NVDATA_CAL_RECORD_CRC_ERROR = (HIGH, 44, 0, 0, 0) + ALARM_ID_NVDATA_HW_USAGE_DATA_CRC_ERROR = (HIGH, 45, 0, 0, 0) + ALARM_ID_NVDATA_DISINFECTION_DATE_CRC_ERROR = (HIGH, 46, 0, 0, 0) + ALARM_ID_RO_PUMP_OUT_PRESSURE_OUT_OF_RANGE = (HIGH, 47, 0, 0, 0) + ALARM_ID_TEMPERATURE_SENSORS_OUT_OF_RANGE = (HIGH, 48, 0, 0, 0) + ALARM_ID_TEMPERATURE_SENSORS_INCONSISTENT = (HIGH, 49, 0, 0, 0) + ALARM_ID_HD_COMM_TIMEOUT = (HIGH, 50, 0, 0, 0) + ALARM_ID_VALVE_CONTROL_FAILURE = (HIGH, 51, 0, 0, 0) + ALARM_ID_BLOOD_PUMP_FLOW_VS_MOTOR_SPEED_CHECK = (HIGH, 52, 0, 0, 0) + ALARM_ID_DIAL_IN_PUMP_FLOW_VS_MOTOR_SPEED_CHECK = (HIGH, 53, 0, 0, 0) + ALARM_ID_DIAL_OUT_PUMP_FLOW_VS_MOTOR_SPEED_CHECK = (HIGH, 54, 0, 0, 0) + ALARM_ID_BLOOD_PUMP_MOTOR_SPEED_CHECK = (HIGH, 55, 0, 0, 0) + ALARM_ID_DIAL_IN_PUMP_MOTOR_SPEED_CHECK = (HIGH, 56, 0, 0, 0) + ALARM_ID_DIAL_OUT_PUMP_MOTOR_SPEED_CHECK = (HIGH, 57, 0, 0, 0) + ALARM_ID_BLOOD_PUMP_ROTOR_SPEED_TOO_HIGH = (HIGH, 58, 0, 0, 0) + ALARM_ID_INLET_WATER_TEMPERATURE_OUT_OF_RANGE = (HIGH, 59, 0, 0, 0) + ALARM_ID_DOES_NOT_EXIST = (HIGH, 99, 0, 0, 0) class HDAlarmsSimulator(AbstractSubSystem): - instanceCount = 0 def __init__(self, can_interface: DenaliCanMessenger, logger: Logger): @@ -174,10 +173,10 @@ self.can_interface.send(message, 0) def cmd_activate_alarm_id(self, state: int = HIGH, - alarm: int = 0, - escalates_in: int = 0, - silence_expires: int = 0, - flags: int = 0): + alarm: int = 0, + escalates_in: int = 0, + silence_expires: int = 0, + flags: int = 0): """ Activates the specified alarm @@ -248,56 +247,61 @@ self.can_interface.send(message, 0) def cmd_make_alarm_flags(self, - system_fault=0, - stop=0, - no_clear=0, - no_resume=0, - no_rinseback=0, - no_end_treatment=0, - no_new_treatment=0, - user_must_ack=0, - alarms_to_escalate=0, - alarms_silenced=0, - lamp_on=0, - unused_1=0, - unused_2=0, - unused_3=0, - unused_4=0, - top_condition=0 - ): + system_fault=0, + stop=0, + no_clear=0, + no_resume=0, + no_rinseback=0, + no_end_treatment=0, + no_new_treatment=0, + user_must_ack=0, + alarms_to_escalate=0, + alarms_silenced=0, + lamp_on=0, + unused_1=0, + unused_2=0, + unused_3=0, + no_minimize=0, + top_condition=0 + ): """ Helper function to construct the flags - @param system_fault: TBD - @param stop: TBD - @param no_clear: TBD - @param no_resume: TBD - @param no_rinseback: TBD - @param no_end_treatment: TBD - @param no_new_treatment: TBD - @param bypass_dialyzer: TBD - @param alarms_to_escalate: TBD - @param alarms_silenced: if the alarm should be silenced - @param user_acknowledge: if the user has already acknowledged the alarm + @param system_fault: One or more system faults has been triggered + @param stop: Alarm(s) have stopped treatment/activity and placed system in a safe state + @param no_clear: One or more active alarms is not recoverable + @param no_resume: The "resume" user recovery option is disabled + @param no_rinseback: The "rinseback" user recovery option is disabled + @param no_end_treatment: The "end treatment" user recovery option is disabled + @param no_new_treatment: A new treatment may not be started without cycling power to system + @param user_must_ack: The "ok" user recovery option is enabled + @param alarms_to_escalate: One or more active alarms will escalate in time + @param alarms_silenced: Alarms have been temporarily silenced by user + @param lamp_on: Alarm lamp is currently on (for syncing to UI) + @param unused_1: unused + @param unused_2: unused + @param unused_3: unused + @param no_minimize: Prevent user from minimizing alarm window + @param top_condition: The top alarm's condition is still being detected @return: (int) containing all the flags """ flags = 0 - flags ^= system_fault * 2 ** 0 \ - | stop * 2 ** 1 \ - | no_clear * 2 ** 2 \ - | no_resume * 2 ** 3 \ - | no_rinseback * 2 ** 4 \ - | no_end_treatment * 2 ** 5 \ - | no_new_treatment * 2 ** 6 \ - | user_must_ack * 2 ** 7 \ - | alarms_to_escalate * 2 ** 8 \ - | alarms_silenced * 2 ** 9 \ - | lamp_on * 2 ** 10 \ - | unused_1 * 2 ** 11 \ - | unused_2 * 2 ** 12 \ - | unused_3 * 2 ** 13 \ - | unused_4 * 2 ** 14 \ - | top_condition * 2 ** 15 + flags ^= system_fault * 2 ** 0 \ + | stop * 2 ** 1 \ + | no_clear * 2 ** 2 \ + | no_resume * 2 ** 3 \ + | no_rinseback * 2 ** 4 \ + | no_end_treatment * 2 ** 5 \ + | no_new_treatment * 2 ** 6 \ + | user_must_ack * 2 ** 7 \ + | alarms_to_escalate * 2 ** 8 \ + | alarms_silenced * 2 ** 9 \ + | lamp_on * 2 ** 10 \ + | unused_1 * 2 ** 11 \ + | unused_2 * 2 ** 12 \ + | unused_3 * 2 ** 13 \ + | no_minimize * 2 ** 14 \ + | top_condition * 2 ** 15 return flags def cmd_send_clear_alarms(self): @@ -361,8 +365,8 @@ self.can_interface.send(message, 0) - def cmd_set_alarm_triggered(self, alarm_id,field_descriptor_1: int, data_field_1: str, - field_descriptor_2: int, data_field_2: str) -> None: + def cmd_set_alarm_triggered(self, alarm_id, field_descriptor_1: int, data_field_1: str, + field_descriptor_2: int, data_field_2: str) -> None: """ Triggers an alarm. @@ -371,27 +375,31 @@ |0x0300| 0x001 | 1 | Event | Y | HD | All | Alarm Triggered | \ref Data::mAlarmID | @param alarm_id: int, the alarm id to trigger + @param field_descriptor_1: alarm data 1 type + @param data_field_1: alarm data 1 + @param field_descriptor_2: alarm data 2 type + @param data_field_2: alarm data 2 @return: None """ zero = integer_to_bytearray(0) payload = integer_to_bytearray(alarm_id) - if (field_descriptor_1 == AlarmDataTypes.ALARM_DATA_TYPE_NONE): + if field_descriptor_1 == AlarmDataTypes.ALARM_DATA_TYPE_NONE: payload += zero payload += zero payload += zero payload += zero else: - if (field_descriptor_1 == AlarmDataTypes.ALARM_DATA_TYPE_F32): + if field_descriptor_1 == AlarmDataTypes.ALARM_DATA_TYPE_F32: payload += integer_to_bytearray(field_descriptor_1) payload += float_to_bytearray(float(data_field_1)) - else: # BOOL, S32, U32 + else: # BOOL, S32, U32 payload += integer_to_bytearray(field_descriptor_1) payload += integer_to_bytearray(int(data_field_1)) - if (field_descriptor_2 == AlarmDataTypes.ALARM_DATA_TYPE_NONE): + if field_descriptor_2 == AlarmDataTypes.ALARM_DATA_TYPE_NONE: payload += zero payload += zero else: - if (field_descriptor_2 == AlarmDataTypes.ALARM_DATA_TYPE_F32): + if field_descriptor_2 == AlarmDataTypes.ALARM_DATA_TYPE_F32: payload += integer_to_bytearray(field_descriptor_2) payload += float_to_bytearray(float(data_field_2)) else: # BOOL, S32, U32 @@ -438,12 +446,11 @@ """ self.flags = flags - def _handler_alarm_acknowledge(self, message): + def _handler_alarm_acknowledge(self) -> None: """ TODO: Remove Handles the alarm acknowledge message - @param message: the message of user acknowledge, contains the alarmID @return: None """ @@ -492,24 +499,24 @@ if self.clear_after_user_action: self.cmd_send_clear_alarms() - def cmd_send_active_list_response(self, accept: bool, reason: int=0, - a0: int=0, a1: int=0, a2: int=0, a3: int=0, a4: int=0, - a5: int=0, a6: int=0, a7: int=0, a8: int=0, a9: int=0) -> None: + def cmd_send_active_list_response(self, accept: bool, reason: int = 0, + a0: int = 0, a1: int = 0, a2: int = 0, a3: int = 0, a4: int = 0, + a5: int = 0, a6: int = 0, a7: int = 0, a8: int = 0, a9: int = 0) -> None: """ send the list of active alarms - :param accept: boolean value true if the request accepted - :param reason: the rejection reason - :param a0: alarm id 0 in the list - First - :param a1: alarm id 1 in the list - :param a2: alarm id 2 in the list - :param a3: alarm id 3 in the list - :param a4: alarm id 4 in the list - :param a5: alarm id 5 in the list - :param a6: alarm id 6 in the list - :param a7: alarm id 7 in the list - :param a8: alarm id 8 in the list - :param a9: alarm id 9 in the list - Last - :return: + @param accept: boolean value true if the request accepted + @param reason: the rejection reason + @param a0: alarm id 0 in the list - First + @param a1: alarm id 1 in the list + @param a2: alarm id 2 in the list + @param a3: alarm id 3 in the list + @param a4: alarm id 4 in the list + @param a5: alarm id 5 in the list + @param a6: alarm id 6 in the list + @param a7: alarm id 7 in the list + @param a8: alarm id 8 in the list + @param a9: alarm id 9 in the list - Last + @return: None """ payload = integer_to_bytearray(accept) payload += integer_to_bytearray(reason) Index: dialin/ui/messageBuilder.py =================================================================== diff -u -rdd42e4d9cfe821b0a755ccc86cc1a4a2a3dd2f37 -rf990c9bb863683c74bbe78c71932a14d7cf35422 --- dialin/ui/messageBuilder.py (.../messageBuilder.py) (revision dd42e4d9cfe821b0a755ccc86cc1a4a2a3dd2f37) +++ dialin/ui/messageBuilder.py (.../messageBuilder.py) (revision f990c9bb863683c74bbe78c71932a14d7cf35422) @@ -18,77 +18,80 @@ syncByte = 'A5' -def toCandumpFormat(vMsg): + +def toCandumpFormat(msg: any) -> str: """ the converter method which converts the message vMsg to the string that candump tool understands. - :param vMsg: the message - :return: converted string to candump tool format + @param msg: the message + @return: converted string to candump tool format """ - if type(vMsg) == list: - for index, value in enumerate(vMsg): - vMsg[index] = ".".join(utils.partition(value, 2, False)) + if type(msg) == list: + for index, value in enumerate(msg): + msg[index] = ".".join(utils.partition(value, 2, False)) else: - vMsg = ".".join(utils.partition(vMsg, 2, False)) - return vMsg + msg = ".".join(utils.partition(msg, 2, False)) + return msg -def toFrames(vMsg): + +def toFrames(msg: any) -> list: """ converts the message vMsg to frames - :param vMsg: adds the crc8 checksum at the end of the message vMsg - :return: the frames + @param msg: adds the crc8 checksum at the end of the message vMsg + @return: the frames """ - mLen = 16 - padded = utils.padding(vMsg, mLen) - frames = utils.partition(padded, mLen, False) + mlen = 16 + padded = utils.padding(msg, mlen) + frames = utils.partition(padded, mlen, False) return frames -def addCRC8(vString, vDelimiter = ""): + +def addCRC8(string: str, delimiter: str = "") -> str: """ adds the crc8 checksum at the end of the string vString - :param vString: the string to be used - :param vDelimiter: the string delimiter - :return: the string with crc8 + @param string: (str) the string to be used + @param delimiter: (str) the string delimiter + @return: the string with crc8 """ - return vString + vDelimiter + crc.calcCRC8(vString, vDelimiter) + return string + delimiter + crc.calc_crc8(string, delimiter) -def textToByte(vText, vLen): +def textToByte(text: str, length) -> str: """ - converts the string vText to bytes by the length of vLen - :param vText: - :param vLen: - :return: converted text + converts the string text to bytes by the given length + @param text: (str) given string + @param length: (int) given length + @return: converted text """ - text = "" - l = len(vText) - for i in range(vLen): - if i < l: - text += utils.toI08(ord(vText[i])) + new_text = "" + text_len = len(text) + for i in range(length): + if i < text_len: + new_text += utils.toI08(ord(text[i])) else: - text += utils.toI08(0) - text += utils.toI08(0) #null /0 - return text - - -def buildMessage(vMsgID, vLen, vAck, *vArgs): + new_text += utils.toI08(0) + new_text += utils.toI08(0) # null /0 + return new_text + + +def buildMessage(msg_id: int, length: int, ack: bool, *args) -> str: """ builds message from the parameter givven - :param vMsgID: the message ID - :param vLen: length of the message payload in bytes - :param vAck: if true the message requires acknowledge back - :param vArgs: payload arguments. - :return: + @param msg_id: (int) the message ID + @param length: (int) length of the message payload in bytes + @param ack: (bool) if true the message requires acknowledge back + @param args: payload arguments. + @return: built message """ msg = "" - if vAck: + if ack: seq = -1 else: - seq = 1 - - msg += utils.toI16(seq) # always used seq# (-)1 (for now) - msg += utils.toI16(vMsgID) - msg += utils.toI08(vLen) - for arg in vArgs: + seq = 1 + + msg += utils.toI16(seq) # always used seq# (-)1 (for now) + msg += utils.toI16(msg_id) + msg += utils.toI08(length) + for arg in args: msg += arg - msg += crc.calcCRC8(msg) + msg += crc.calc_crc8(msg) return syncByte + msg Index: dialin/ui/unittests.py =================================================================== diff -u -r0392b232e0f257fb6946f6e8e2cdf4eadd05974d -rf990c9bb863683c74bbe78c71932a14d7cf35422 --- dialin/ui/unittests.py (.../unittests.py) (revision 0392b232e0f257fb6946f6e8e2cdf4eadd05974d) +++ dialin/ui/unittests.py (.../unittests.py) (revision f990c9bb863683c74bbe78c71932a14d7cf35422) @@ -19,55 +19,58 @@ from dialin.ui import crc from dialin.ui.utils import check_can0 + MICRO = [8, 9] def test_python_version(): """ tests the current python version compatibility - :return: + @return: None """ - test.compare(sys.version_info.major,3) - test.compare(sys.version_info.minor,6) - + test.compare(sys.version_info.major, 3) + test.compare(sys.version_info.minor, 6) + test.compare(sys.version_info.micro in MICRO, True) + def test_crc8(): """ test case for crc8 method - :return: + @return: None """ - strByte1 = ( "4B 43 09 00 14 00 00" - "00 00 00 00 00 00 00 00" - "00 00 00 00 00 00 00 00" - "00 00" # 9D - ) + str_byte1 = ("4B 43 09 00 14 00 00" + "00 00 00 00 00 00 00 00" + "00 00 00 00 00 00 00 00" + "00 00" # 9D + ) - strByte2 = ( "4C 43 02 00 12 03 00" - "00 00 14 00 00 00 00 00" - "00 00 00 00 00 00 7F 00" # 55 - ) - - strByte3 = ( "4A 43 05 00 1C 00 00" - "00 00 00 00 00 00 00 00" - "00 00 00 00 00 00 6A B6" - "99 43 D5 68 6F 44 00 00" - "00 00" #4F - ) - - strByte4 = ( "FB 18 07 00 04 00 00" - "00 00" #7F - ) + str_byte2 = ("4C 43 02 00 12 03 00" + "00 00 14 00 00 00 00 00" + "00 00 00 00 00 00 7F 00" # 55 + ) - test.compare(crc.calcCRC8(strByte1, ' '), '9D') - test.compare(crc.calcCRC8(strByte2, ' '), '55') - test.compare(crc.calcCRC8(strByte3, ' '), '4F') - test.compare(crc.calcCRC8(strByte4, ' '), '7F') + str_byte3 = ("4A 43 05 00 1C 00 00" + "00 00 00 00 00 00 00 00" + "00 00 00 00 00 00 6A B6" + "99 43 D5 68 6F 44 00 00" + "00 00" # 4F + ) + str_byte4 = ("FB 18 07 00 04 00 00" + "00 00" # 7F + ) + + test.compare(crc.calc_crc8(str_byte1, ' '), '9D') + test.compare(crc.calc_crc8(str_byte2, ' '), '55') + test.compare(crc.calc_crc8(str_byte3, ' '), '4F') + test.compare(crc.calc_crc8(str_byte4, ' '), '7F') + + def test_can0(): """ tests if the can0 bus driver presents - :return: + @return: None """ ok, msg = check_can0() test.compare(ok, True, msg) Index: dialin/ui/utils.py =================================================================== diff -u -rdd42e4d9cfe821b0a755ccc86cc1a4a2a3dd2f37 -rf990c9bb863683c74bbe78c71932a14d7cf35422 --- dialin/ui/utils.py (.../utils.py) (revision dd42e4d9cfe821b0a755ccc86cc1a4a2a3dd2f37) +++ dialin/ui/utils.py (.../utils.py) (revision f990c9bb863683c74bbe78c71932a14d7cf35422) @@ -19,155 +19,153 @@ from subprocess import check_output -def SRSUI(vSRSUI = ""): +def srsui(vstr=""): """ for user convenience if wanted to put a note for the SRSUI it makes sure all the numbers are 3 digit aligned to easily read on test results. """ - return "SRSUI " + "{}".format(vSRSUI).rjust(3, '0') + return "SRSUI " + "{}".format(vstr).rjust(3, '0') -def isVisible(object, vObject): +def isVisible(object, vobject): """ checks if the object is visible. - Note: in SquishQt it's a little different - since usual check is wait + Note: in SquishQt it's a little different since usual check is wait Note : object is the squish's builtin variable which should be available within the test I don't thing importing would be a good idea here since it might be a runtime assigned value and it may have different/undefined value when imported out of test """ - if object.exists(vObject): - o_object = findObject(vObject) + if object.exists(vobject): + o_object = findObject(vobject) if o_object is None: return False else: return o_object.visible else: return False - -def waitForGUI(vDelay = 2): +def waitForGUI(delay_s: int = 2): """ a global 2 seconds default wait method which is used to wait for GUI animations mostly to make sure the object is available. - :param vDelay: (int) amount of second for delay - :return: none + @param delay_s: integer - amount of second for delay + @return: none """ - time.sleep(vDelay) + time.sleep(delay_s) -def toUXX(vValue, vByteCount, vDelimiter): +def toUXX(value: int, byte_count: int, delimiter: str) -> str: """ - converts the value vValue to hex - :param vValue: (int) the value - :param vByteCount: (int) number of bytes the value will take eg. U32=4, ... - :param vDelimiter: (str) the output delimiter - :return: hex formated conversion of the vValue + converts the value to hex + @param value: (int) the value + @param byte_count: (int) number of bytes the value will take eg. U32=4, ... + @param delimiter: (str) the output delimiter + @return: hex formated conversion of the value """ - x = '{0:0{1}X}'.format(int(vValue) & (2**(4*vByteCount)-1), vByteCount, 'x') - bytes = partition(x, 2) - return vDelimiter.join(bytes) + x = '{0:0{1}X}'.format(int(value) & (2 ** (4 * byte_count) - 1), byte_count, 'x') + byte_arr = partition(x, 2) + return delimiter.join(byte_arr) -def toI32(vValue, vDelimiter = ""): +def toI32(value: int, delimiter: str = "") -> str: """ - a convenient method for toUXX to convert the value vValue to integer 4 bytes - :param vValue: (int) the value - :param vDelimiter: (str) the output delimiter - :return: hex formated conversion of the vValue to int 4 bytes + a convenient method for toUXX to convert the value to integer 4 bytes + @param value: (int) the value + @param delimiter: (str) the output delimiter + @return: hex formated conversion of the vValue to int 4 bytes """ - return toUXX(vValue, 8, vDelimiter) + return toUXX(value, 8, delimiter) -def toI16(vValue, vDelimiter = ""): +def toI16(value: int, delimiter: str = "") -> str: """ - a convenient method for toUXX to convert the value vValue to integer 2 bytes - :param vValue: (int) the value - :param vDelimiter: (str) the output delimiter - :return: hex formated conversion of the vValue to int 2 bytes + a convenient method for toUXX to convert the value to integer 2 bytes + @param value: (int) the value + @param delimiter: (str) the output delimiter + @return: hex formated conversion of the vValue to int 2 bytes """ - return toUXX(vValue, 4, vDelimiter) + return toUXX(value, 4, delimiter) -def toI08(vValue, vDelimiter = ""): +def toI08(value: int, delimiter: str = "") -> str: """ a convenient method for toUXX to convert the value vValue to integer 1 byte - :param vValue: (int) the value - :param vDelimiter: (str) the output delimiter - :return: hex formated conversion of the vValue to int 1 bytes + @param value: (int) the value + @param delimiter: (str) the output delimiter + @return: hex formated conversion of the vValue to int 1 bytes """ - return toUXX(vValue, 2, vDelimiter) + return toUXX(value, 2, delimiter) -def toF32(vValue): +def toF32(value: float) -> str: """ - converts value vValue to floating point 4 bytes. - :param vValue: (float) the value - :return: hex formated conversion of the vValue to float 4 bytes + converts value to floating point 4 bytes. + @param value: (float) the value + @return: hex formated conversion of the vValue to float 4 bytes """ - return '{:08X}'.format(struct.unpack('f', vValue))[0],'X') + return '{:08X}'.format(struct.unpack('f', value))[0], 'X') -def partition(vString, vPart, vRightDirection=True): +def partition(string: str, part: int, right_rirection: bool = True) -> list: """ splits the given string into sections of vPart long - and puts the sections from left to right if vRightDirection is False - and puts the sections from right to left if vRightDirection is True + and puts the sections from left to right if right_rirection is False + and puts the sections from right to left if right_rirection is True after the split is done - :param vString: (str) the given string - :param vPart: (int) length of the section - :param vRightDirection: (bool) order of sections in the output list - :return: (list) the section of the string vString in list + @param string: (str) the given string + @param part: (int) length of the section + @param right_rirection: (bool) order of sections in the output list + @return: (list) the section of the string in list """ - return [vString[i: i + vPart] for i in range(0, len(vString), vPart)][::-1 if vRightDirection else 1] + return [string[i: i + part] for i in range(0, len(string), part)][::-1 if right_rirection else 1] -def padding(vString, vLen): +def padding(string: str, length: int) -> any: """ added zero at the right side of the string to be of length of vLen - :param vString: (str) the string to add trailing zero to - :param vLen: (int) the entire length of the string - :return: (str) padded string + @param string: (str) the string to add trailing zero to + @param length: (int) the entire length of the string + @return: (str) padded string """ - lStr = len(vString) - lPad = int(lStr / vLen) * vLen + ( vLen * (1 if lStr % vLen else 0) ) - return vString.ljust(lPad, "0") + str_len = len(string) + pad_len = int(str_len / length) * length + (length * (1 if str_len % length else 0)) + return string.ljust(pad_len, "0") -def tstStart(vTestName): +def tstStart(test_name) -> None: """ test case start print out with time - :param vTestName: (str) name of the test case - :return: none - prints out on the console + @param test_name: (str) name of the test case + @return: none - prints out on the console """ - print(time.strftime("%H:%M:%S Start", time.localtime()) + " - " + vTestName) + print(time.strftime("%H:%M:%S Start", time.localtime()) + " - " + test_name) -def tstDone(): +def tstDone() -> None: """ test case end print out with time - :return: none - prints out on the console + @return: none - prints out on the console """ print(time.strftime("%H:%M:%S Done ", time.localtime())) -def l2ml(vValue): +def l2ml(value) -> int: """ converts liter to milliliter - :param (int) vValue: the value in liter. - :return: (int) vValue converted to milliliter. + @param (int) value: the value in liter. + @return: (int) value converted to milliliter. """ - return int(round (vValue, 3) * 1000) + return int(round(value, 3) * 1000) -def ml2l(vValue): +def ml2l(value): """ converts milliliter to liter - :param (int) vValue: the value in milliliter. - :return: (int) vValue converted to liter. + @param (int) value: the value in milliliter. + @return: (int) value converted to liter. """ - return vValue / 1000 + return value / 1000 def dict_update(obj: dict, key: str, value): @@ -188,14 +186,13 @@ def check_can0(): """ check if the can0 bus driver presents - :return: (list) false if can0 not exists, msg as a message + @return: (list) false if can0 not exists, msg as a message """ canid = "can0" ipa = "ip a" ipa = check_output(ipa, shell=True) loc = str(ipa).find(canid) - fnd = loc >= 0 - if (fnd): + if loc >= 0: msg = "can device '{}' found".format(canid) else: msg = "No can device registered as '{}'".format(canid)