Index: HD/UI.py =================================================================== diff -u -rc5826238ca4b80671231a9c564af3ea01b9be06f -r0da0106eca868b9144298c60911710b3414a5837 --- HD/UI.py (.../UI.py) (revision c5826238ca4b80671231a9c564af3ea01b9be06f) +++ HD/UI.py (.../UI.py) (revision 0da0106eca868b9144298c60911710b3414a5837) @@ -5,7 +5,7 @@ # THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN # WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. # -# @file UI.py +# @file ui.py # # @date 31-Mar-2020 # @author P. Lucia @@ -16,18 +16,18 @@ ############################################################################ from DialIn.CoreCANProtocol import (DenaliMessage, DenaliChannels) -from .utils import integer2ByteArray, float2ByteArray +from utils import integer_to_byte_array, float_to_byte_array import struct class HDUI: """ \class HD_UI - \brief Hemodialysis Device (HD) Dialin API sub-class for UI commands. + \brief Hemodialysis Device (HD) Dialin API sub-class for ui commands. """ - # UI message IDs + # ui message IDs MSG_ID_UI_CHECKIN_WITH_HD = 0x0007 MSG_ID_HD_UF_PAUSE_RESUME_REQUEST = 0x0010 MSG_ID_HD_TREATMENT_PARAMS_RANGES = 0x001A @@ -187,7 +187,7 @@ \param message: response message from HD regarding treatment duration change.\n BOOL Accepted \n U32 Reject reason (if not accepted) \n - U32 Treatment duration (min) \n + U32 treatment duration (min) \n U32 UF volue (mL) \n \returns none @@ -244,8 +244,8 @@ BOOL Accepted \n U32 RejectReason (if not accepted) F32 UF Volume (mL) - converted to Liters \n - U32 Treatment Time (min) \n - S32 Treatment Time Change (min) \n + U32 treatment Time (min) \n + S32 treatment Time Change (min) \n F32 UF Rate (mL/min) \n F32 UF Rate Change (mL/min) @@ -280,30 +280,30 @@ def cmd_ui_checkin_with_hd(self): """ - Constructs and sends the UI check-in message + Constructs and sends the ui check-in message \returns 0 """ message = DenaliMessage.build_message(channel_id=DenaliChannels.dialin_to_hd_ch_id, message_id=self.MSG_ID_UI_CHECKIN_WITH_HD) - print("Sending UI checkin w/ HD") + print("Sending ui checkin w/ HD") self.can_interface.send(message, 0) return 0 def cmd_ui_uf_pause_resume(self, cmd=UF_CMD_PAUSE): """ - Constructs and sends a UI UF command message + Constructs and sends a ui UF command message \param cmd: 0 for pause, 1 for resume \returns none """ - payload = integer2ByteArray(cmd) + payload = integer_to_byte_array(cmd) message = DenaliMessage.build_message(channel_id=DenaliChannels.dialin_to_hd_ch_id, message_id=self.MSG_ID_HD_UF_PAUSE_RESUME_REQUEST, payload=payload) @@ -320,7 +320,7 @@ def cmd_ui_uf_settings_change_request(self, vol=0.0): """ - Constructs and sends a UI UF change settings command message + Constructs and sends a ui UF change settings command message \param vol (float): new ultrafiltration volume setting (in L) @@ -330,7 +330,7 @@ # reset response to this command so we can tell when response is received self.UFChangeResponse = None # build command message - volume = float2ByteArray(vol * self.LITER_TO_ML_CONVERSION_FACTOR) + volume = float_to_byte_array(vol * self.LITER_TO_ML_CONVERSION_FACTOR) message = DenaliMessage.build_message(channel_id=DenaliChannels.dialin_to_hd_ch_id, message_id=self.MSG_ID_UF_SETTINGS_CHANGE_REQUEST_BY_USER, payload=volume) @@ -343,7 +343,7 @@ def cmd_ui_uf_settings_change_confirm(self, vol=0.0, adj=UF_CMD_CHANGE_TIME_TO_ADJUST): """ - Constructs and sends a UI UF change settings command message + Constructs and sends a ui UF change settings command message \param vol (float): new ultrafiltration volume setting (in L) \param adj (int): 0 for adjust time, 1 for adjust rate @@ -355,8 +355,8 @@ self.UFChangeResponse = None # build command message - volume = float2ByteArray(vol * self.LITER_TO_ML_CONVERSION_FACTOR) - adjust = integer2ByteArray(adj) + volume = float_to_byte_array(vol * self.LITER_TO_ML_CONVERSION_FACTOR) + adjust = integer_to_byte_array(adj) payload = volume + adjust message = DenaliMessage.build_message(channel_id=DenaliChannels.dialin_to_hd_ch_id, message_id=self.MSG_ID_UF_SETTINGS_CHANGE_REQUEST_BY_USER, @@ -370,7 +370,7 @@ def cmd_ui_uf_change_settings_confirmed_by_user(self, response=RESPONSE_REJECTED, vol=0.0, tm=0, rate=0.0): """ - Constructs and sends a UI UF change settings confirmed by user message + Constructs and sends a ui UF change settings confirmed by user message \param response (int): 0 for rejected, 1 for confirmed \param vol (float): volume (in L) that was confirmed @@ -380,10 +380,10 @@ \returns none """ - resp = integer2ByteArray(response) - volume = float2ByteArray(vol * self.LITER_TO_ML_CONVERSION_FACTOR) - min = integer2ByteArray(tm) - ufRate = float2ByteArray(rate) + resp = integer_to_byte_array(response) + volume = float_to_byte_array(vol * self.LITER_TO_ML_CONVERSION_FACTOR) + min = integer_to_byte_array(tm) + ufRate = float_to_byte_array(rate) payload = resp + volume + min + ufRate message = DenaliMessage.build_message(channel_id=DenaliChannels.dialin_to_hd_ch_id, message_id=self.MSG_ID_UF_SETTINGS_CHANGE_CONFIRMED_BY_USER, @@ -397,14 +397,14 @@ def cmd_ui_treatment_duration_setting_change_request(self, timeMin=0): """ - Constructs and sends a UI UF change settings confirmed by user message + Constructs and sends a ui UF change settings confirmed by user message \param timeMin (int): treatment time (in min). \returns none """ - payload = integer2ByteArray(timeMin) + payload = integer_to_byte_array(timeMin) message = DenaliMessage.build_message(channel_id=DenaliChannels.dialin_to_hd_ch_id, message_id=self.MSG_ID_TREATMENT_DURATION_SETTING_CHANGE_REQUEST, payload=payload) @@ -418,16 +418,16 @@ def cmd_ui_blood_and_dialysate_flow_settings_change_request(self, bloodFlow, dialFlow): """ - Constructs and sends a UI blood & dialysate flow settings change request by user message + Constructs and sends a ui blood & dialysate flow settings change request by user message \param bloodFlow (int): blood flow rate set point (in mL/min). \param dialFlow (int): dialysate flow rate set point (in mL/min). \returns none """ - bld = integer2ByteArray(bloodFlow) - dial = integer2ByteArray(dialFlow) + bld = integer_to_byte_array(bloodFlow) + dial = integer_to_byte_array(dialFlow) payload = bld + dial message = DenaliMessage.build_message(channel_id=DenaliChannels.dialin_to_hd_ch_id, message_id=self.MSG_ID_BLOOD_DIALYSATE_FLOW_SETTING_CHANGE_REQUEST_BY_USER,