Index: dialin/common/msg_defs.py =================================================================== diff -u -r4e66eef7643f2271904aa78e1506f83bb712be32 -r6ee95f85e0504b8c7214258074e3022b50c982bd --- dialin/common/msg_defs.py (.../msg_defs.py) (revision 4e66eef7643f2271904aa78e1506f83bb712be32) +++ dialin/common/msg_defs.py (.../msg_defs.py) (revision 6ee95f85e0504b8c7214258074e3022b50c982bd) @@ -74,40 +74,67 @@ MSG_ID_UI_NEW_TREATMENT_PARAMS = 0x35 # UI request to validate new treatment parameter set MSG_ID_HD_NEW_TREATMENT_PARAMS_RESPONSE = 0x36 # HD response to new treatment parameters set MSG_ID_DG_HEAT_DISINFECT_DATA = 0x37 # DG heat disinfection publish data - MSG_ID_UI_START_TREATMENT = 0x38 # UI user request to initiate a treatment - MSG_ID_HD_START_TREATMENT_RESPONSE = 0x39 # HD response to user request to initiate a treatment + MSG_ID_UI_INITIATE_TREATMENT_REQUEST = 0x38 # UI user request to initiate a treatment + MSG_ID_UI_INITIATE_TREATMENT_RESPONSE = 0x39 # HD response to user request to initiate a treatment MSG_ID_HD_VALVES_DATA = 0x3A # HD broadcast of valves data MSG_ID_UI_USER_CONFIRM_TREATMENT_PARAMS = 0x3B # UI user confirmation of treatment parameters - MSG_ID_UI_TREATMENT_END_REQUEST = 0x3C # UI user treatment end request - MSG_ID_HD_TREATMENT_END_RESPONSE = 0x3D # HD response to user request to end treatment + MSG_ID_UI_START_PRIME_REQUEST = 0x3C # UI user has requested to start priming + MSG_ID_HD_START_PRIME_RESPONSE = 0x3D # HD response to user request to start priming MSG_ID_HD_AIR_TRAP_DATA = 0x003E # HD broadcast of air trap data MSG_ID_ALARM_CONDITION_CLEARED = 0x3F # Broadcast that the alarm condition has been cleared MSG_ID_UI_ALARM_USER_ACTION = 0x40 # UI user has requested an alarm action MSG_ID_USER_UF_PAUSE_RESUME_RESPONSE = 0x41 # HD response to user request to pause or resume UF MSG_ID_DG_CONCENTRATE_PUMP_DATA = 0x42 # DG broadcast of concentrate pump data - MSG_ID_DG_PRIMING_STATUS_DATA = 0x43 # HD priming status during cartridge prime + MSG_ID_HD_PRIMING_STATUS_DATA = 0x43 # HD priming status during cartridge prime MSG_ID_DG_UV_REACTORS_DATA = 0x44 # DG broadcast UV reactors data MSG_ID_DG_THERMISTORS_DATA = 0x45 # DG broadcast thermistors data MSG_ID_UI_PRESSURE_LIMITS_CHANGE_REQUEST = 0x46 # UI request to change pressure limits MSG_ID_HD_PRESSURE_LIMITS_CHANGE_RESPONSE = 0x47 # HD response to change pressure limits request MSG_ID_DG_FANS_DATA = 0x48 # DG broadcast fans data - MSG_ID_HD_CALIBRATION_DATA = 0x49 # HD broadcast calibration data - MSG_ID_DG_CALIBRATION_DATA = 0x4A # DG broadcast calibration data + MSG_ID_HD_TREATMENT_STOP_TIMER_DATA = 0x49 # HD broadcast of treatment stop timer (countdown to treatment stop - no rinseback alarm) + MSG_ID_UI_PATIENT_DISCONNECTION_CONFIRM = 0x4A # UI patient disconnection confirm MSG_ID_UI_HEPARIN_PAUSE_RESUME_REQUEST = 0x4B # UI request to pause/resume Heparin delivery MSG_ID_HD_HEPARIN_PAUSE_RESUME_RESPONSE = 0x4C # HD Heparin Pause/Resume Response MSG_ID_HD_HEPARIN_DATA = 0x4D # HD Broadcast heparin data MSG_ID_UI_SET_ALARM_AUDIO_VOLUME_LEVEL_CMD = 0x4E # UI command to set alarm audio volume level MSG_ID_UI_PRE_TREATMENT_UF_REQUEST = 0x4F # UI UF Initialization Request MSG_ID_HD_PRE_TREATMENT_UF_RESPONSE = 0x50 # HD response to user request to adjust the ultrafiltration in pre-treatment + MSG_ID_DG_COMMAND_RESPONSE = 0x51 # DG response to command from HD + MSG_ID_UI_RINSEBACK_CMD = 0x52 # UI rinseback request MSG_ID_HD_RINSEBACK_CMD_RESPONSE = 0x53 # HD rinseback request response + MSG_ID_UI_RECIRC_CMD = 0x54 # UI re-circ request MSG_ID_HD_RECIRC_CMD_RESPONSE = 0x55 # HD re-circ request response MSG_ID_HD_RINSEBACK_PROGRESS = 0x56 # HD broadcast of rinseback progress - MSG_ID_HD_RECIRCULATE_PROGRESS = 0x5A # HD broadcast of recirculate progress - MSG_ID_HD_BLOOD_PRIME_PROGRESS = 0x59 # HD broadcast of blood prime progress MSG_ID_UI_TX_END_CMD = 0x57 # UI end treatment sub-mode user request MSG_ID_HD_TX_END_CMD_RESPONSE = 0x58 # HD end treatment sub-mode user request response + MSG_ID_HD_BLOOD_PRIME_PROGRESS = 0x59 # HD broadcast of blood prime progress + MSG_ID_HD_RECIRC_PROGRESS = 0x5A # HD broadcast of treatment re-circulate progress + MSG_ID_DG_CHANGE_VALVE_SETTING_CMD = 0x5B # HD request to DG to change valve setting + MSG_ID_PRE_TREATMENT_STATE = 0x5C # HD broadcast of pre-treatment state + MSG_ID_UI_SAMPLE_WATER_CMD = 0x5D # UI sample water sub-mode user request + MSG_ID_HD_SAMPLE_WATER_CMD_RESPONSE = 0x5E # HD sample water sub-mode request response + MSG_ID_UI_SAMPLE_WATER_RESULT = 0x5F # UI sample water result message + MSG_ID_DG_FILTER_FLUSH_PROGRESS = 0x60 # DG broadcast of filter flush progress + MSG_ID_HD_NO_CART_SELF_TEST_PROGRESS = 0x61 # HD broadcast of no cartridge self-tests progress + MSG_ID_UI_INSTALLATION_CONFIRM = 0x62 # UI disposable installation user confirmation + MSG_ID_HD_DRY_SELF_TEST_PROGRESS = 0x63 # HD broadcast of dry self-tests progress + MSG_ID_UI_CONTINUE_TO_TREATMENT_REQUEST = 0x64 # UI user has requested to continue to treatment + MSG_ID_HD_CONTINUE_TO_TREATMENT_RESPONSE = 0x65 # HD response to user request to continue to treatment + MSG_ID_UI_PATIENT_CONNECTION_CONFIRM = 0x66 # UI user has confirmed patient connection completed + MSG_ID_HD_PATIENT_CONNECTION_CONFIRM_RESPONSE = 0x67 # HD response to user confirmation of patient connection + MSG_ID_UI_CONSUMABLE_INSTALL_CONFIRM = 0x68 # UI user has confirmed consumable install + MSG_ID_HD_SYRINGE_PUMP_DATA = 0x69 # HD broadcast of syringe pump data MSG_ID_HD_FLUID_LEAK_STATE = 0x6A # HD broadcast of fluid leak state MSG_ID_DG_FLUID_LEAK_STATE = 0x6B # DG broadcast of fluid leak state + MSG_ID_HD_BLOOD_LEAK_STATE = 0x6C # HD broadcast of blood leak state + MSG_ID_UI_HD_SET_RTC_REQUEST = 0x6D # UI to DG Request to set RTC Request + MSG_ID_HD_UI_SET_RTC_RESPONSE = 0x6E # DG to UI set RTC Response + MSG_ID_UI_DG_SET_RTC_REQUEST = 0x6F # UI to HD request to set RTC Request + MSG_ID_DG_UI_SET_RTC_RESPONSE = 0x70 # HD to UI Set RTC Response + MSG_ID_UI_START_TREATMENT_REQUEST = 0x71 # UI user has requested to start treatment + MSG_ID_HD_START_TREATMENT_RESPONSE = 0x72 # response to user request to start treatment + MSG_ID_UI_DISPOSABLE_REMOVAL_CONFIRM = 0x73 # UI user has confirmed disposable removal + MSG_ID_HD_TREATMENT_LOG_DATA = 0x74 # HD sends treatment log data to UI message MSG_ID_CAN_ERROR_COUNT = 0x999 # test code in support of EMC testing @@ -125,7 +152,7 @@ MSG_ID_BLOOD_PUMP_MC_MEAS_SPEED_OVERRIDE = 0x800A # Blood pump motor controller speed override request MSG_ID_BLOOD_PUMP_MC_MEAS_CURR_OVERRIDE = 0x800B # Blood pump motor controller current override request MSG_ID_BLOOD_FLOW_SEND_INTERVAL_OVERRIDE = 0x800C # Blood flow broadcast interval override request - MSG_ID___AVAILABLE_1 = 0x800D # This msg ID is available for use + MSG_ID_TREATMENT_TIME_REMAINING_OVERRIDE = 0x800D # This msg ID is available for use MSG_ID_BLOOD_PUMP_MEAS_SPEED_OVERRIDE = 0x800E # Blood pump measured motor speed override request MSG_ID_BLOOD_PUMP_MEAS_ROTOR_SPEED_OVERRIDE = 0x800F # Blood pump measured rotor speed override request MSG_ID_DIAL_IN_FLOW_SET_PT_OVERRIDE = 0x8010 # Dialysate inlet flow set point override request @@ -154,9 +181,9 @@ MSG_ID_HD_ACCEL_OVERRIDE = 0x8027 # HD accelerometer sensor override request MSG_ID_HD_ACCEL_MAX_OVERRIDE = 0x8028 # HD accelerometer sensor max. override request MSG_ID_HD_ACCEL_SEND_INTERVAL_OVERRIDE = 0x8029 # HD accelerometer data broadcast interval override request - MSG_ID_HD_ACCEL_SET_CALIBRATION = 0x802A # HD accelerometer set calibration factors request - MSG_ID_HD_BLOOD_FLOW_SET_CALIBRATION = 0x802B # Blood flow set calibration factors request - MSG_ID_HD_DIALYSATE_FLOW_SET_CALIBRATION = 0x802C # Dialysate flow set calibration factors request + MSG_ID_HD_SYRINGE_PUMP_SEND_INTERVAL_OVERRIDE = 0x802A # HD syringe pump data broadcast interval override request + MSG_ID_HD_SYRINGE_PUMP_OPERATION_REQUEST = 0x802B # HD syringe pump operation request + MSG_ID_HD_SYRINGE_PUMP_MEASURED_RATE_OVERRIDE = 0x802C # HD syringe pump measured rate override request MSG_ID_HD_SET_PARAMETER_TREATMENT_PARAMETER = 0x802D # Set a treatment parameter (will change actual setting, not an override) MSG_ID_HD_VALVES_HOME = 0x802E # Home an HD Valve MSG_ID_HD_VALVES_POSITION_OVERRIDE = 0x802F # Set an HD valve to a position in counts @@ -171,10 +198,23 @@ MSG_ID_DIAL_IN_PUMP_HOME_CMD = 0x8038 # Dialysate inlet pump home command MSG_ID_DIAL_OUT_PUMP_HOME_CMD = 0x8039 # Dialysate outlet pump home command MSG_ID_SUPER_CLEAR_ALARMS_CMD = 0x803A # Clears all alarms (even if non-recoverable or fault) - MSG_ID_HD_REQUEST_CALIBRATION_DATA = 0x803B # Requests calibration data from HD - MSG_ID_HD_ERASE_CALIBRATION_DATA = 0x803C # Requests calibration data on HD be erased - MSG_ID_HD_FLUID_LEAK_STATE_BROADCAST_INTERVAL_OVERRIDE = 0x8047 # HD fluid leak state broadcast interval override request - MSG_ID_HD_FLUID_LEAK_DETECTOR_STATE_OVERRIDE = 0x8048 # HD fluid leak detector state override request + MSG_ID_HD_SYRINGE_PUMP_MEASURED_FORCE_OVERRIDE = 0x803B # HD syringe pump measured force override request + MSG_ID_HD_SYRINGE_PUMP_SYRINGE_DETECT_OVERRIDE = 0x803C # HD syringe pump measured syringe detection override request + MSG_ID_HD_SET_CALIBRATION_RECORD = 0x803D # HD set calibration record that is received from Dialin + MSG_ID_HD_GET_CALIBRATION_RECORD = 0x803E # HD get calibration record that is requested from Dialin + MSG_ID_HD_SEND_CALIBRATION_RECORD = 0x803F # HD send calibration record to CAN bus to be received in Dialin (equivalent to publish) + MSG_ID_HD_SET_SYSTEM_RECORD = 0x8040 # HD set system record that is received from Dialin + MSG_ID_HD_GET_SYSTEM_RECORD = 0x8041 # HD get system record that is requested from Dialin + MSG_ID_HD_SEND_SYSTEM_RECORD = 0x8042 # HD send system record to CAN bus to be received in Dialin (equivalent to publish) + MSG_ID_HD_GET_SERVICE_RECORD = 0x8043 # HD get service record that is requested from Dialin + MSG_ID_HD_SET_SERVICE_RECORD = 0x8044 # HD set service record that is received from Dialin + MSG_ID_HD_SEND_SERVICE_RECORD = 0x8045 # HD send service record to CAN bus to be received in Dialin (equivalent to publish) + MSG_ID_HD_SET_OP_MODE_REQUEST = 0x8046 # HD set operation mode request + MSG_ID_HD_FLUID_LEAK_SEND_INTERVAL_OVERRIDE = 0x8047 # HD fluid leak state broadcast interval override request + MSG_ID_HD_FLUID_LEAK_STATE_DETECTOR_OVERRIDE = 0x8048 # HD fluid leak state detector override request + MSG_ID_HD_SYRINGE_PUMP_MEASURED_HOME_OVERRIDE = 0x8049 # HD syringe pump measured home override request + MSG_ID_HD_SYRINGE_PUMP_MEASURED_POSITION_OVERRIDE = 0x804A # HD syringe pump measured position override request + MSG_ID_HD_SYRINGE_PUMP_MEASURED_VOLUME_OVERRIDE = 0x804B # HD syringe pump measured volume delivered override request MSG_ID_DG_TESTER_LOGIN_REQUEST = 0XA000 # DG tester log-in MSG_ID_DG_ALARM_STATE_OVERRIDE = 0xA001 # DG alarm state override message ID @@ -201,7 +241,7 @@ MSG_ID_DG_ACCEL_OVERRIDE = 0xA017 # DG accelerometer sensor override request MSG_ID_DG_ACCEL_MAX_OVERRIDE = 0xA018 # DG accelerometer sensor max. override request MSG_ID_DG_ACCEL_SEND_INTERVAL_OVERRIDE = 0xA019 # DG accelerometer data broadcast interval override request - MSG_ID_DG_ACCEL_SET_CALIBRATION = 0xA01A # DG accelerometer set calibration factors request + MSG_ID___AVAILABLE_11 = 0xA01A # This msg ID is available for use MSG_ID_RO_PUMP_SET_PWM = 0xA01B # RO pump set PWM for open loop MSG_ID_DRAIN_PUMP_SET_DELTA_PRESSURE_OVERRIDE = 0xA01C # Drain pump set delta pressure override MSG_ID_HEAT_DISINFECT_RECIRC_PATH_DURATION_MINS = 0xA01D # Heat disinfection recirculation path duration in minutes @@ -216,7 +256,7 @@ MSG_ID_CONCENTRATE_PUMP_STATE_CHANGE_REQUEST = 0xA026 # Concentrate pumps' state change request (on / off) MSG_ID_CONCENTRATE_PUMP_PUBLISH_INTERVAL_OVERRIDE = 0xA027 # Concentrate pumps' data publish interval override request MSG_ID_DG_START_STOP_INLET_UV_REACTOR = 0xA028 # DG start/stop inlet UV reactor - MSG_ID_DG_REQUEST_CALIBRATION_DATA = 0xA029 # Requests calibration data from DG + MSG_ID_DG_REQUEST_CALIBRATION_DATA = 0xA029 # Requests calibration_record data from DG MSG_ID_DG_FANS_DATA_PUBLISH_OVERRIDE = 0xA02A # Fans data publish interval override request MSG_ID_DG_START_STOP_OUTLET_UV_REACTOR = 0xA02B # DG start/stop outlet UV reactor MSG_ID_DG_UV_REACTORS_HEALTH_OVERRIDE = 0xA02C # DG UV reactors health override request @@ -226,9 +266,20 @@ MSG_ID_DG_RO_FLOW_RATE_OVERRIDE = 0xA030 # DG RO flow rate override MSG_ID_DG_RO_PUMP_TARGET_FLOW_OVERRIDE = 0xA031 # DG RO pump target flow rate override MSG_ID_DG_RO_PUMP_TARGET_PRESSURE_OVERRIDE = 0xA032 # DG RO pump target pressure override - MSG_ID_DG_SET_CALIBRATION_DATA = 0xA033 # DG set calibration data MSG_ID_DG_FLUID_LEAK_STATE_BROADCAST_INTERVAL_OVERRIDE = 0xA03F # DG fluid leak state broadcast interval override request MSG_ID_DG_FLUID_LEAK_DETECTOR_STATE_OVERRIDE = 0xA040 # DG fluid leak detector state override request + MSG_ID_DG_SET_CALIBRATION_RECORD = 0xA033 # DG set calibration_record record + MSG_ID_DG_GET_CALIBRATION_RECORD = 0xA034 # DG get calibration_record record + MSG_ID_DG_SEND_CALIBRATION_RECORD = 0xA035 # DG send calibration_record record from firmware + MSG_ID_DG_SET_SYSTEM_RECORD = 0xA036 # DG send system record + MSG_ID_DG_GET_SYSTEM_RECORD = 0xA037 # DG get system record + MSG_ID_DG_SEND_SYSTEM_RECORD = 0xA038 # DG send system record from firmware + MSG_ID_DG_SET_SERVICE_RECORD = 0xA03A # DG set service record that is sent from Dialin + MSG_ID_DG_GET_SERVICE_RECORD = 0xA039 # DG get service record that is requested from Dialin + MSG_ID_DG_SEND_SERVICE_RECORD = 0xA03B # DG send service record that is requested from Dialin + MSG_ID_DG_GET_SCHEDULED_RUNS_RECORD = 0xA03C # DG get scheduled runs that is requested from Dialin + MSG_ID_DG_SET_SCHEDULED_RUNS_RECORD = 0xA03D # DG set scheduled runs that is received from Dialin + MSG_ID_DG_SEND_SCHEDULED_RUNS_RECORD = 0xA03E # DG send scheduled runs to CAN bus to be received in Dialin (equivalent to publish) MSG_ID_HD_DEBUG_EVENT = 0xFFF1 # HD debug event text to be logged in event log MSG_ID_DG_DEBUG_EVENT = 0xFFF2 # DG debug event text to be logged in event log Index: dialin/dg/dialysate_generator.py =================================================================== diff -u -r4e66eef7643f2271904aa78e1506f83bb712be32 -r6ee95f85e0504b8c7214258074e3022b50c982bd --- dialin/dg/dialysate_generator.py (.../dialysate_generator.py) (revision 4e66eef7643f2271904aa78e1506f83bb712be32) +++ dialin/dg/dialysate_generator.py (.../dialysate_generator.py) (revision 6ee95f85e0504b8c7214258074e3022b50c982bd) @@ -16,23 +16,30 @@ import struct from .accelerometer import DGAccelerometer from .alarms import DGAlarms +from .concentrate_pumps import ConcentratePumps +from .conductivity_sensors import ConductivitySensors from .drain_pump import DGDrainPump from .fluid_leak import DGFluidLeak +from .fans import Fans from .hd_proxy import DGHDProxy +from .heaters import Heaters +from .heat_disinfect import HeatDisinfect from .load_cells import DGLoadCells from .pressures import DGPressures from .reservoirs import DGReservoirs -from .valves import DGValves from .ro_pump import DGROPump -from .heaters import Heaters +from .samplewater import DGSampleWater from .temperature_sensors import TemperatureSensors from .conductivity_sensors import ConductivitySensors -from .heat_disinfection import HeatDisinfection +from .heat_disinfect import HeatDisinfect from .thermistors import Thermistors -from .fans import Fans from .uv_reactors import UVReactors from .concentrate_pumps import ConcentratePumps -from .calibration import DGCalibration +from .calibration_record import DGCalibrationNVRecord +from .system_record import DGSystemNVRecord +from .service_record import DGServiceNVRecord +from .scheduled_runs_record import DGScheduledRunsNVRecord +from .valves import DGValves from ..utils.conversions import integer_to_bytearray from ..protocols.CAN import (DenaliCanMessenger, DenaliMessage, DenaliChannels) from ..utils.base import _AbstractSubSystem, _publish, _LogManager @@ -135,29 +142,36 @@ # Create command groups self.accel = DGAccelerometer(self.can_interface, self.logger) self.fluid_leak = DGFluidLeak(self.can_interface, self.logger) + self.alarms = DGAlarms(self.can_interface, self.logger) + self.concentrate_pumps = ConcentratePumps(self.can_interface, self.logger) + self.conductivity_sensors = ConductivitySensors(self.can_interface, self.logger) + self.drain_pump = DGDrainPump(self.can_interface, self.logger) + self.fans = Fans(self.can_interface, self.logger) self.hd_proxy = DGHDProxy(self.can_interface, self.logger) + self.heaters = Heaters(self.can_interface, self.logger) self.load_cells = DGLoadCells(self.can_interface, self.logger) self.pressures = DGPressures(self.can_interface, self.logger) self.reservoirs = DGReservoirs(self.can_interface, self.logger) - self.valves = DGValves(self.can_interface, self.logger) self.ro_pump = DGROPump(self.can_interface, self.logger) - self.drain_pump = DGDrainPump(self.can_interface, self.logger) - self.heaters = Heaters(self.can_interface, self.logger) + self.samplewater = DGSampleWater(self.can_interface, self.logger) self.temperature_sensors = TemperatureSensors(self.can_interface, self.logger) self.conductivity_sensors = ConductivitySensors(self.can_interface, self.logger) self.concentrate_pumps = ConcentratePumps(self.can_interface, self.logger) self.alarms = DGAlarms(self.can_interface, self.logger) - self.heat_disinfect = HeatDisinfection(self.can_interface, self.logger) + self.heat_disinfect = HeatDisinfect(self.can_interface, self.logger) self.thermistors = Thermistors(self.can_interface, self.logger) - self.fans = Fans(self.can_interface, self.logger) self.uv_reactors = UVReactors(self.can_interface, self.logger) - self.calibration = DGCalibration(self.can_interface, self.logger) + self.calibration_record = DGCalibrationNVRecord(self.can_interface, self.logger) + self.system_record = DGSystemNVRecord(self.can_interface, self.logger) + self.service_record = DGServiceNVRecord(self.can_interface, self.logger) + self.scheduled_runs_record = DGScheduledRunsNVRecord(self.can_interface, self.logger) + self.valves = DGValves(self.can_interface, self.logger) def get_version(self): """ Gets the DG version. Assumes DG version has already been requested. - @return: The dg version string + @return: The hd version string """ return self.dg_version Index: dialin/hd/hemodialysis_device.py =================================================================== diff -u -r07fec99b432f13c72a724cd55a8951d9a34e9cec -r6ee95f85e0504b8c7214258074e3022b50c982bd --- dialin/hd/hemodialysis_device.py (.../hemodialysis_device.py) (revision 07fec99b432f13c72a724cd55a8951d9a34e9cec) +++ dialin/hd/hemodialysis_device.py (.../hemodialysis_device.py) (revision 6ee95f85e0504b8c7214258074e3022b50c982bd) @@ -27,7 +27,12 @@ from .dialysate_outlet_flow import HDDialysateOutletFlow from .treatment import HDTreatment from .valves import HDValves +from .calibration_record import HDCalibrationNVRecord +from .system_record import HDSystemNVRecords +from .service_record import HDServiceNVRecords from .pressure_occlusion import HDPressureOcclusion +from .pretreatment import HDPreTreatment +from .syringe_pump import HDSyringePump from ..protocols.CAN import (DenaliMessage, DenaliCanMessenger, DenaliChannels) @@ -36,6 +41,7 @@ from ..utils.base import _AbstractSubSystem, _publish, _LogManager from .constants import NO_RESET from ..common.msg_defs import MsgIds, MsgFieldPositions +from ..common.hd_defs import HDOpModes class HD(_AbstractSubSystem): @@ -47,17 +53,6 @@ # HD login password HD_LOGIN_PASSWORD = '123' - # HD operation modes - HD_OP_MODE_FAULT = 0 - HD_OP_MODE_SERVICE = 1 - HD_OP_MODE_INIT_POST = 2 - HD_OP_MODE_STANDBY = 3 - HD_OP_MODE_PRESCRIPTION = 4 - HD_OP_MODE_OP_PARAMS = 5 - HD_OP_MODE_PRE_TREATMENT = 6 - HD_OP_MODE_TREATMENT = 7 - HD_OP_MODE_POST_TREATMENT = 8 - def __init__(self, can_interface="can0", log_level=None): """ HD object provides test/service commands for the HD sub-system. @@ -88,21 +83,10 @@ msg_id = MsgIds.MSG_ID_HD_OP_MODE.value self.can_interface.register_receiving_publication_function(channel_id, msg_id, self._handler_hd_op_mode_sync) - msg_id = MsgIds.MSG_ID_HD_CALIBRATION_DATA.value - self.can_interface.register_receiving_publication_function(channel_id, msg_id, - self._handler_hd_cal_data_sync) # create properties - self.hd_operation_mode = self.HD_OP_MODE_INIT_POST + self.hd_operation_mode = HDOpModes.MODE_INIT.value self.hd_operation_sub_mode = 0 - self.hd_calibration_data = {"Revision":0, - "AccelXOffset":0.0, - "AccelYOffset":0.0, - "AccelZOffset":0.0, - "BloodFlowGain":0.0, - "BloodFlowOffset":0.0, - "DialysateFlowGain":0.0, - "DialysateFlowOffset":0.0} # Create command groups self.accel = HDAccelerometer(self.can_interface, self.logger) @@ -117,8 +101,13 @@ self.dialysate_inlet_flow = HDDialysateInletFlow(self.can_interface, self.logger) self.dialysate_outlet_flow = HDDialysateOutletFlow(self.can_interface, self.logger) self.treatment = HDTreatment(self.can_interface, self.logger) + self.pretreatment = HDPreTreatment(self.can_interface, self.logger) self.pressure_occlusion = HDPressureOcclusion(self.can_interface, self.logger) + self.syringe_pump = HDSyringePump(self.can_interface, self.logger) self.valves = HDValves(self.can_interface, self.logger) + self.calibration_record = HDCalibrationNVRecord(self.can_interface, self.logger) + self.system_record = HDSystemNVRecords(self.can_interface, self.logger) + self.service_record = HDServiceNVRecords(self.can_interface, self.logger) def get_operation_mode(self): """ @@ -128,50 +117,6 @@ """ return self.hd_operation_mode - def get_hd_calibration_data(self): - """ - Gets the HD calibration record - - @return: The hd calibration record - """ - return self.hd_calibration_data - - @_publish(["hd_calibration_data"]) - def _handler_hd_cal_data_sync(self, message): - """ - Handles published HD calibration data messages. Current HD calibration data - is captured for reference. Call cmd_request_hd_calibration_data() method - to request HD to publish HD calibration data. - - @param message: published HD calibration data broadcast message - @return: None - """ - rev = struct.unpack('i', bytearray( - message['message'][MsgFieldPositions.START_POS_FIELD_1:MsgFieldPositions.END_POS_FIELD_1])) - acc_x = struct.unpack('f', bytearray( - message['message'][MsgFieldPositions.START_POS_FIELD_2:MsgFieldPositions.END_POS_FIELD_2])) - acc_y = struct.unpack('f', bytearray( - message['message'][MsgFieldPositions.START_POS_FIELD_3:MsgFieldPositions.END_POS_FIELD_3])) - acc_z = struct.unpack('f', bytearray( - message['message'][MsgFieldPositions.START_POS_FIELD_4:MsgFieldPositions.END_POS_FIELD_4])) - bf_g = struct.unpack('f', bytearray( - message['message'][MsgFieldPositions.START_POS_FIELD_5:MsgFieldPositions.END_POS_FIELD_5])) - bf_o = struct.unpack('f', bytearray( - message['message'][MsgFieldPositions.START_POS_FIELD_6:MsgFieldPositions.END_POS_FIELD_6])) - df_g = struct.unpack('f', bytearray( - message['message'][MsgFieldPositions.START_POS_FIELD_7:MsgFieldPositions.END_POS_FIELD_7])) - df_o = struct.unpack('f', bytearray( - message['message'][MsgFieldPositions.START_POS_FIELD_8:MsgFieldPositions.END_POS_FIELD_8])) - - self.hd_calibration_data["Revision"] = rev[0] - self.hd_calibration_data["AccelXOffset"] = acc_x[0] - self.hd_calibration_data["AccelYOffset"] = acc_y[0] - self.hd_calibration_data["AccelZOffset"] = acc_z[0] - self.hd_calibration_data["BloodFlowGain"] = bf_g[0] - self.hd_calibration_data["BloodFlowOffset"] = bf_o[0] - self.hd_calibration_data["DialysateFlowGain"] = df_g[0] - self.hd_calibration_data["DialysateFlowOffset"] = df_o[0] - @_publish(["hd_operation_mode"]) def _handler_hd_op_mode_sync(self, message): """ @@ -278,6 +223,48 @@ self.logger.debug("Timeout!!!!") return False + def cmd_hd_set_operation_mode(self, newMode=0): + """ + Constructs and sends a set operation mode request command via CAN bus. + Constraints: + Must be logged into HD. + Transition from current to requested op mode must be legal. + + @param newMode: ID of operation mode to transition to + HD_OP_MODE_FAULT = 0 + HD_OP_MODE_SERVICE = 1 + HD_OP_MODE_INIT_POST = 2 + HD_OP_MODE_STANDBY = 3 + HD_OP_MODE_TREATMENT_PARAMS = 4 + HD_OP_MODE_PRE_TREATMENT = 6 + HD_OP_MODE_TREATMENT = 7 + HD_OP_MODE_POST_TREATMENT = 8 + + @return: 1 if successful, zero otherwise + + """ + + payload = integer_to_bytearray(newMode) + + message = DenaliMessage.build_message(channel_id=DenaliChannels.dialin_to_hd_ch_id, + message_id=MsgIds.MSG_ID_HD_SET_OP_MODE_REQUEST.value, + payload=payload) + + self.logger.debug("Requesting HD mode change to " + str(newMode)) + + # Send message + received_message = self.can_interface.send(message) + + if received_message is not None: + if received_message['message'][DenaliMessage.PAYLOAD_START_INDEX] == 1: + self.logger.debug("Success: Mode change accepted") + else: + self.logger.debug("Failure: Mode change rejected.") + return received_message['message'][DenaliMessage.PAYLOAD_START_INDEX] + else: + self.logger.debug("HD mode change request Timeout!!!!") + return False + def cmd_hd_safety_shutdown_override(self, active=True, reset=NO_RESET): """ Constructs and sends an HD safety shutdown override command via CAN bus.