Index: dialin/dg/load_cells.py =================================================================== diff -u -ra1d640c70267e6e5e2ad81fc23bc5ca91847b61d -r23e83eef3f47218e11d5e19a92fcfc24ae35b843 --- dialin/dg/load_cells.py (.../load_cells.py) (revision a1d640c70267e6e5e2ad81fc23bc5ca91847b61d) +++ dialin/dg/load_cells.py (.../load_cells.py) (revision 23e83eef3f47218e11d5e19a92fcfc24ae35b843) @@ -67,7 +67,7 @@ self.can_interface.register_receiving_publication_function(channel_id, msg_id, self._handler_load_cells_sync) msg_id = MsgIds.MSG_ID_DG_SEND_LOAD_CELLS_TARE_VALUES_TO_DIALIN.value - self.can_interface.register_receiving_publication_function(channel_id, msg_id, + self.can_interface.register_receiving_publication_function(DenaliChannels.dg_to_dialin_ch_id, msg_id, self._handler_load_cells_tare_values_sync) self.load_cell_A1 = 0.0 @@ -220,11 +220,13 @@ @return: 1 if successful, zero otherwise """ - payload = 0.0 + payload = b'' for cell in DGLoadCellNames.__members__: - tare = self.load_cells_tare_values[cell] - payload += float_to_bytearray(tare) + if 'NUM_OF_LOAD_CELLS' not in cell: + tare = self.load_cells_tare_values[cell] + tare_byte = float_to_bytearray(tare) + payload += tare_byte message = DenaliMessage.build_message(channel_id=DenaliChannels.dialin_to_dg_ch_id, message_id=MsgIds.MSG_ID_DG_SET_LOAD_CELLS_TARE_VALUES.value, @@ -242,3 +244,27 @@ self.logger.debug("Timeout!!!!") return False + def cmd_get_load_cells_tare_values(self): + """ + Constructs and sends the load cell override command + Constraints: + Must be logged into DG. + @return: 1 if successful, zero otherwise + """ + + message = DenaliMessage.build_message(channel_id=DenaliChannels.dialin_to_dg_ch_id, + message_id=MsgIds.MSG_ID_DG_GET_LOAD_CELLS_TARE_VALUES.value) + # Send message + received_message = self.can_interface.send(message) + + self.logger.debug("Getting the load cells tare values") + + # If there is content... + if received_message is not None: + # response payload is OK or not OK + return received_message['message'][DenaliMessage.PAYLOAD_START_INDEX] + else: + self.logger.debug("Timeout!!!!") + return False + + Index: tests/dg_tests.py =================================================================== diff -u -r08cf9026424703efbb28596458734f63a078a1e9 -r23e83eef3f47218e11d5e19a92fcfc24ae35b843 --- tests/dg_tests.py (.../dg_tests.py) (revision 08cf9026424703efbb28596458734f63a078a1e9) +++ tests/dg_tests.py (.../dg_tests.py) (revision 23e83eef3f47218e11d5e19a92fcfc24ae35b843) @@ -17,6 +17,7 @@ from dialin.dg.dialysate_generator import DG from dialin.hd.hemodialysis_device import HD +from dialin.dg.load_cells import DGLoadCellNames from dialin.ui.hd_simulator import HDSimulator from dialin.common.dg_defs import DGHeatDisinfectStates, DGHeatDisinfectUIStates from dialin.dg.heat_disinfect import HeatCancellationModes, NelsonSupportModes @@ -642,15 +643,26 @@ if __name__ == "__main__": dg = DG(log_level='DEBUG') - #dg = DG() dg.cmd_log_in_to_dg() sleep(1) hd = HD(log_level='DEBUG') hd.cmd_log_in_to_hd() sleep(1) - run_test_configs() + while True: + print(dg.rtc.get_rtc_epoch()) + sleep(1) + #dg.load_cells.cmd_get_load_cells_tare_values() + #while True: + # print(dg.load_cells.load_cells_tare_values) + # sleep(0.5) + # if dg.load_cells.load_cells_tare_values[DGLoadCellNames.LOAD_CELL_RESERVOIR_1_PRIMARY.name] != 0.0: + # dg.load_cells.cmd_set_load_cells_tare_values() + # break + + #run_test_configs() + #run_heat_disinfect() #run_flush_mode() Index: tests/tx_test_config_tests.py =================================================================== diff -u --- tests/tx_test_config_tests.py (revision 0) +++ tests/tx_test_config_tests.py (revision 23e83eef3f47218e11d5e19a92fcfc24ae35b843) @@ -0,0 +1,118 @@ + +import os + +from dialin.dg.dialysate_generator import DG +from dialin.hd.hemodialysis_device import HD +from dialin.dg.load_cells import DGLoadCellNames +from dialin.ui.hd_simulator import HDSimulator +from dialin.common.dg_defs import DGHeatDisinfectStates, DGHeatDisinfectUIStates +from dialin.dg.heat_disinfect import HeatCancellationModes, NelsonSupportModes +from dialin.common.dg_defs import DGChemicalDisinfectStates, DGChemDisinfectUIStates +from dialin.common.dg_defs import DGChemDisinfectFlushStates, DGChemDisinfectFlushUIStates +from dialin.dg.chemical_disinfect import ChemCancellationModes +from dialin.dg.drain_pump import DrainPumpStates, DrainPumpRPMFeedBackSensors +from dialin.dg.thermistors import ThermistorsNames +from dialin.dg.temperatures import DGTemperaturesNames +from dialin.dg.dialysate_generator import DGOperationModes +from dialin.hd.temperatures import HDTemperaturesNames +from dialin.dg.concentrate_pumps import DGConcentratePumpsStates +from dialin.dg.uv_reactors import ReactorsNames +from dialin.common.hd_defs import HDOpModes, HDStandbyStates, PreTreatmentWetSelfTestStates, PostTreatmentStates, \ + PreTreatmentDrySelfTestsStates +from dialin.hd.post_treatment import HDPostTreatmentDrainStates +from dialin.common.dg_defs import DGEventList +from dialin.common.hd_defs import HDEventList +from dialin.hd.reservoirs import HDReservoirStates +from dialin.dg.reservoirs import DGReservoirsNames +from dialin.common.dg_defs import DGGenIdleModeBadFillSubStates +from dialin.common.alarm_defs import AlarmList +from dialin.dg.fans import DGFansNames +from dialin.dg.pressures import DGPressures +from dialin.dg.conductivity_sensors import ConductivitySensorsEnum +from dialin.dg.voltages import DGMonitoredVoltages +from dialin.dg.valves import DGValveNames +from dialin.hd.valves import HDValves +from dialin.hd.voltages import HDMonitoredVoltages +from dialin.hd.pretreatment import PreTreatmentRsrvrState +from dialin.common.dg_defs import DGFlushStates, DGHeatDisinfectActiveCoolStates +from dialin.common.test_config_defs import DGTestConfigOptions, HDTestConfigOptions +from time import sleep +from datetime import datetime +import sys + +sys.path.append("..") + + +def expedite_pretreatment(): + + counter = 1 + #dg.load_cells.cmd_get_load_cells_tare_values() + + # For testing only. Use the get function to get the actual tare values + dg.load_cells.load_cells_tare_values[DGLoadCellNames.LOAD_CELL_RESERVOIR_1_PRIMARY.name] = 1726.822998046875 + dg.load_cells.load_cells_tare_values[DGLoadCellNames.LOAD_CELL_RESERVOIR_1_BACKUP.name] = 1716.2781982421875 + dg.load_cells.load_cells_tare_values[DGLoadCellNames.LOAD_CELL_RESERVOIR_2_PRIMARY.name] = 1716.46484375 + dg.load_cells.load_cells_tare_values[DGLoadCellNames.LOAD_CELL_RESERVOIR_2_BACKUP.name] = 1712.1719970703125 + + while True: + if dg.load_cells.load_cells_tare_values[DGLoadCellNames.LOAD_CELL_RESERVOIR_1_PRIMARY.name] != 0.0: + # Received the load cells tare values from DG. Reset both stacks + dg.cmd_dg_software_reset_request() + hd.cmd_hd_software_reset_request() + counter += 1 + + if counter == 2 and 3 == dg.dg_operation_mode: + # After reset log in again + dg.cmd_log_in_to_dg() + # Wait to make sure the log in really happened + sleep(1) + counter += 1 + + if counter == 3: + dg.load_cells.cmd_set_load_cells_tare_values() + counter += 1 + + if counter == 4 and 3 == hd.hd_operation_mode: + hd.cmd_log_in_to_hd() + # Wait to make sure the log in really happened + sleep(1) + counter += 1 + + if counter == 5: + # Set the operation mode is pre-treatment before commanding the start DG + hd.cmd_hd_set_operation_mode(4) + counter += 1 + + if counter == 6 and 4 == hd.hd_operation_mode: + # Start DG cannot be when HD is in standby + dg.hd_proxy.cmd_start_stop_dg() + counter += 1 + + if counter == 7: + hd.test_configs.cmd_set_test_config(HDTestConfigOptions.TEST_CONFIG_EXPEDITE_PRE_TREATMENT.value) + counter += 1 + + sleep(0.5) + + + + + + + + + + + + + + +if __name__ == "__main__": + dg = DG(log_level='DEBUG') + dg.cmd_log_in_to_dg() + sleep(1) + hd = HD(log_level='DEBUG') + hd.cmd_log_in_to_hd() + sleep(1) + + expedite_pretreatment()