Index: dialin/dg/dialysate_generator.py =================================================================== diff -u -r8d1f61499650e23dac6f857e48daad42180db949 -rc3cc81dada72714b9675594cc0c6a79975e8991d --- dialin/dg/dialysate_generator.py (.../dialysate_generator.py) (revision 8d1f61499650e23dac6f857e48daad42180db949) +++ dialin/dg/dialysate_generator.py (.../dialysate_generator.py) (revision c3cc81dada72714b9675594cc0c6a79975e8991d) @@ -62,6 +62,16 @@ START_POS_BUILD = END_POS_MICRO END_POS_BUILD = START_POS_BUILD + 2 + # FPGA + START_POS_FPGA_ID = END_POS_BUILD + END_POS_FPGA_ID = START_POS_FPGA_ID + 1 + START_POS_FPGA_MAJOR = END_POS_FPGA_ID + END_POS_FPGA_MAJOR = START_POS_FPGA_MAJOR + 1 + START_POS_FPGA_MINOR = END_POS_FPGA_MAJOR + END_POS_FPGA_MINOR = START_POS_FPGA_MINOR + 1 + START_POS_FPGA_LAB = END_POS_FPGA_MINOR + END_POS_FPGA_LAB = START_POS_FPGA_LAB + 1 + # DG operation modes DG_OP_MODE_FAULT = 0 DG_OP_MODE_SERVICE = 1 @@ -121,6 +131,7 @@ # initialize variables that will be populated by DG version response self.dg_version = None + self.fpga_version = None # create properties self.dg_operation_mode = self.DG_OP_MODE_INIT_POST self.dg_operation_sub_mode = 0 @@ -160,7 +171,7 @@ """ return self.dg_operation_sub_mode - @_publish(["dg_version"]) + @_publish(["dg_version", "fpga_version"]) def _handler_dg_version(self, message): """ Handler for response from DG regarding its version. @@ -182,11 +193,22 @@ build = struct.unpack('H', bytearray( message['message'][self.START_POS_BUILD:self.END_POS_BUILD])) - if len(major) > 0 and len(minor) > 0 and len(micro) > 0 and len(build) > 0: + fpga_id = struct.unpack('B', bytearray( + message['message'][self.START_POS_FPGA_ID:self.END_POS_FPGA_ID])) + fpga_major = struct.unpack('B', bytearray( + message['message'][self.START_POS_FPGA_MAJOR:self.END_POS_FPGA_MAJOR])) + fpga_minor = struct.unpack('B', bytearray( + message['message'][self.START_POS_FPGA_MINOR:self.END_POS_FPGA_MINOR])) + fpga_lab = struct.unpack('B', bytearray( + message['message'][self.START_POS_FPGA_LAB:self.END_POS_FPGA_LAB])) + + if all([len(each) > 0 for each in [major, minor, micro, build]]): self.dg_version = f"v{major[0]}.{minor[0]}.{micro[0]}-{build[0]}" - self.logger.debug(self.dg_version) + self.logger.debug(f"DG VERSION: {self.dg_version}") - return self.dg_version + if all([len(each) > 0 for each in [fpga_major, fpga_minor, fpga_id, fpga_lab]]): + self.fpga_version = f"ID: {fpga_id[0]} v{fpga_major[0]}.{fpga_minor[0]}.{fpga_lab[0]}" + self.logger.debug(f"DG FPGA VERSION: {self.fpga_version}") @_publish(["dg_operation_mode", "dg_operation_sub_mode"]) def _handler_dg_op_mode_sync(self, message): Index: dialin/dg/ro_pump.py =================================================================== diff -u -r8d1f61499650e23dac6f857e48daad42180db949 -rc3cc81dada72714b9675594cc0c6a79975e8991d --- dialin/dg/ro_pump.py (.../ro_pump.py) (revision 8d1f61499650e23dac6f857e48daad42180db949) +++ dialin/dg/ro_pump.py (.../ro_pump.py) (revision c3cc81dada72714b9675594cc0c6a79975e8991d) @@ -32,8 +32,8 @@ # RO pump message IDs MSG_ID_DG_RO_PUMP_PUBLISHED_DATA = 0x001F MSG_ID_DG_RO_PUMP_PRESSURE_SET_PT_OVERRIDE = 0xA008 - MSG_ID_DG_RO_FLOW_RATE_OVERRIDE = 0xA009, - MSG_ID_DG_RO_PUMP_BROADCAST_INTERVAL_OVERRIDE = 0xA00A, + MSG_ID_DG_RO_FLOW_RATE_OVERRIDE = 0xA009 + MSG_ID_DG_RO_PUMP_BROADCAST_INTERVAL_OVERRIDE = 0xA00A # RO pump broadcast message field positions START_POS_PRES_SET_PT = DenaliMessage.PAYLOAD_START_INDEX Index: dialin/hd/alarms.py =================================================================== diff -u -r80501868a8f9a2c145945bbebb486fb3a32edfb2 -rc3cc81dada72714b9675594cc0c6a79975e8991d --- dialin/hd/alarms.py (.../alarms.py) (revision 80501868a8f9a2c145945bbebb486fb3a32edfb2) +++ dialin/hd/alarms.py (.../alarms.py) (revision c3cc81dada72714b9675594cc0c6a79975e8991d) @@ -176,19 +176,6 @@ """ return self.alarm_states - def get_alarms_state(self): - """ - Gets the alarms state - - None = 0 \n - Low = 1 \n - Medium = 2 \n - High = 3 \n - - @return: The alarms state - """ - return self.alarms_state - def get_alarms_top(self): """ Gets the top alarm @@ -217,18 +204,31 @@ """ Gets the alarms flags + Extract each flag from the flags int using bit-masking. E.g. + + System Fault = result & 1 + Stop = result & 2 + No Clear = result & 4 + No Resume = result & 8 + No Rinseback = result & 16 + No End Treatment = result & 32 + No New Treatment = result & 64 + Bypass Dialyzer = result & 128 + Alarms to Escalate = result & 256 + Alarms Silenced = result & 512 + TBD = result & 1024 + TBD = result & 2048 + TBD = result & 4096 + TBD = result & 8192 + TBD = result & 16384 + TBD = result & 32768 + TBD = result & 65536 + + @return: (int) The alarms flags value """ return self.alarms_flags - def get_alarm_states(self): - """ - Alarm states based on received HD alarm activation and alarm clear messages - - @return: - """ - self.alarm_states = [False] * 500 - def get_alarm_ids(self): """ Returns a dictionary of the alarm short name and the corresponding id @@ -419,8 +419,9 @@ def get_current_alarms_state(self): """ Gets the current alarms state. + None, Low, Medium, or High - @return: the current alarms state in text form. + @return: (str) the current alarms state in text form. """ result = "" if self.alarms_state == self.HD_ALARM_STATE_NONE: Index: dialin/hd/blood_flow.py =================================================================== diff -u -r8d1f61499650e23dac6f857e48daad42180db949 -rc3cc81dada72714b9675594cc0c6a79975e8991d --- dialin/hd/blood_flow.py (.../blood_flow.py) (revision 8d1f61499650e23dac6f857e48daad42180db949) +++ dialin/hd/blood_flow.py (.../blood_flow.py) (revision c3cc81dada72714b9675594cc0c6a79975e8991d) @@ -363,7 +363,7 @@ self.logger.debug("Timeout!!!!") return False - def cmd_blood_pump_rotor_measured_speed_override(self, speed, reset=NO_RESET): + def cmd_blood_pump_measured_rotor_speed_override(self, speed, reset=NO_RESET): """ Constructs and sends the measured blood pump rotor speed override \n command. Index: dialin/hd/ui_proxy.py =================================================================== diff -u -r8d1f61499650e23dac6f857e48daad42180db949 -rc3cc81dada72714b9675594cc0c6a79975e8991d --- dialin/hd/ui_proxy.py (.../ui_proxy.py) (revision 8d1f61499650e23dac6f857e48daad42180db949) +++ dialin/hd/ui_proxy.py (.../ui_proxy.py) (revision c3cc81dada72714b9675594cc0c6a79975e8991d) @@ -78,6 +78,16 @@ START_POS_BUILD = END_POS_MICRO END_POS_BUILD = START_POS_BUILD + 2 + # FPGA + START_POS_FPGA_ID = END_POS_BUILD + END_POS_FPGA_ID = START_POS_FPGA_ID + 1 + START_POS_FPGA_MAJOR = END_POS_FPGA_ID + END_POS_FPGA_MAJOR = START_POS_FPGA_MAJOR + 1 + START_POS_FPGA_MINOR = END_POS_FPGA_MAJOR + END_POS_FPGA_MINOR = START_POS_FPGA_MINOR + 1 + START_POS_FPGA_LAB = END_POS_FPGA_MINOR + END_POS_FPGA_LAB = START_POS_FPGA_LAB + 1 + # HD update on valid treatment parameter ranges message field positions START_POS_MIN_TREAT_TIME = DenaliMessage.PAYLOAD_START_INDEX END_POS_MIN_TREAT_TIME = START_POS_MIN_TREAT_TIME + 4 @@ -159,8 +169,8 @@ self.MSG_ID_UF_SETTINGS_CHANGE_RESPONSE_FROM_HD, self._handler_uf_change_response) self.can_interface.register_receiving_publication_function(channel_id, - self.MSG_ID_UF_SETTINGS_CHANGE_CONFIRM_RESPONSE_FROM_HD, - self.handler_uf_change_confirm_response) + self.MSG_ID_UF_SETTINGS_CHANGE_CONFIRM_RESPONSE_FROM_HD, + self._handler_uf_change_confirm_response) self.can_interface.register_receiving_publication_function(channel_id, self.MSG_ID_TREATMENT_DURATION_SETTING_CHANGE_RESPONSE_FROM_HD, self._handler_treatment_duration_change_response) @@ -174,6 +184,7 @@ # initialize variables that will be populated by HD version response self.hd_version = None + self.fpga_version = None # initialize variables that will be populated by treatment parameter ranges message self.min_treatment_duration_min = 0 self.max_treatment_duration_min = 0 @@ -391,6 +402,7 @@ @_publish([ "hd_version" + "fpga_version" ]) def _handler_hd_version(self, message): """ @@ -413,11 +425,23 @@ build = struct.unpack('H', bytearray( message['message'][self.START_POS_BUILD:self.END_POS_BUILD])) - if len(major) > 0 and len(minor) > 0 and len(micro) > 0 and len(build) > 0: + fpga_id = struct.unpack('B', bytearray( + message['message'][self.START_POS_FPGA_ID:self.END_POS_FPGA_ID])) + fpga_major = struct.unpack('B', bytearray( + message['message'][self.START_POS_FPGA_MAJOR:self.END_POS_FPGA_MAJOR])) + fpga_minor = struct.unpack('B', bytearray( + message['message'][self.START_POS_FPGA_MINOR:self.END_POS_FPGA_MINOR])) + fpga_lab = struct.unpack('B', bytearray( + message['message'][self.START_POS_FPGA_LAB:self.END_POS_FPGA_LAB])) + + if all([len(each) > 0 for each in [major, minor, micro, build]]): self.hd_version = f"v{major[0]}.{minor[0]}.{micro[0]}-{build[0]}" - self.logger.debug(self.hd_version) - return self.hd_version + self.logger.debug(f"HD VERSION: {self.hd_version}") + if all([len(each) > 0 for each in [fpga_major, fpga_minor, fpga_id, fpga_lab]]): + self.fpga_version = f"ID: {fpga_id[0]} v{fpga_major[0]}.{fpga_minor[0]}.{fpga_lab[0]}" + self.logger.debug(f"HD FPGA VERSION: {self.fpga_version}") + @_publish([ "min_treatment_duration_min", "max_treatment_duration_min", @@ -587,18 +611,23 @@ self.uf_old_rate_ml_min = ort[0] - def handler_uf_change_confirm_response(self, message): + @_publish(["uf_change_succeeded", + "uf_change_reject_reason", + "uf_change_volume_ml", + "uf_change_time_min", + "uf_change_rate_ml_min"]) + def _handler_uf_change_confirm_response(self, message): """ Handler for response from HD regarding UF change confirmation. - \param message: response message from HD regarding confirmed ultrafiltration settings change.\n + @param message: response message from HD regarding confirmed ultrafiltration settings change.\n BOOL Accepted \n U32 RejectReason (if not accepted) F32 UF Volume (mL) - converted to Liters \n U32 treatment Time (min) \n F32 UF Rate (mL/min) \n - \returns none + @return: None """ rsp = struct.unpack('i', bytearray( message['message'][self.START_POS_UF_CNF_RSP_RESP:self.END_POS_UF_CNF_RSP_RESP])) Index: dialin/squish/denaliMessages.py =================================================================== diff -u -re9104e0b4a45a64840a7cb66a115839698129844 -rc3cc81dada72714b9675594cc0c6a79975e8991d --- dialin/squish/denaliMessages.py (.../denaliMessages.py) (revision e9104e0b4a45a64840a7cb66a115839698129844) +++ dialin/squish/denaliMessages.py (.../denaliMessages.py) (revision c3cc81dada72714b9675594cc0c6a79975e8991d) @@ -29,14 +29,10 @@ import time import subprocess -import names -if names.DIALIN_LINK: - from dialin.squish import utils - from dialin.squish import messageBuilder -else: - import utils - import messageBuilder +from dialin.squish import utils +from dialin.squish import messageBuilder + class EResponse: Rejected = 0 Accepted = 1 @@ -642,15 +638,15 @@ frames = buildUnknown() frames = messageBuilder.toCandumpFormat(frames) for frame in frames: - subprocess.call(['cansend', 'can0', '001#{}'.format(frame)]) # send from HD + subprocess.call(['cansend', 'can0', '001#{}'.format(frame)]) # send from HD waitForMessageToBeSent() def sendUnknown_DG(): frames = buildUnknown() frames = messageBuilder.toCandumpFormat(frames) for frame in frames: - subprocess.call(['cansend', 'can0', '070#{}'.format(frame)]) # send from DG + subprocess.call(['cansend', 'can0', '070#{}'.format(frame)]) # send from DG waitForMessageToBeSent() Index: dialin/squish/messageBuilder.py =================================================================== diff -u -re9104e0b4a45a64840a7cb66a115839698129844 -rc3cc81dada72714b9675594cc0c6a79975e8991d --- dialin/squish/messageBuilder.py (.../messageBuilder.py) (revision e9104e0b4a45a64840a7cb66a115839698129844) +++ dialin/squish/messageBuilder.py (.../messageBuilder.py) (revision c3cc81dada72714b9675594cc0c6a79975e8991d) @@ -26,14 +26,9 @@ # author Behrouz NematiPour # -import names -if names.DIALIN_LINK: - from dialin.squish import utils - from dialin.squish import crc -else: - import utils - import crc - +from dialin.squish import utils +from dialin.squish import crc + syncByte = 'A5' def toCandumpFormat(vMsg): Index: dialin/squish/unittests.py =================================================================== diff -u -re9104e0b4a45a64840a7cb66a115839698129844 -rc3cc81dada72714b9675594cc0c6a79975e8991d --- dialin/squish/unittests.py (.../unittests.py) (revision e9104e0b4a45a64840a7cb66a115839698129844) +++ dialin/squish/unittests.py (.../unittests.py) (revision c3cc81dada72714b9675594cc0c6a79975e8991d) @@ -28,18 +28,13 @@ import test import sys -import names -if names.DIALIN_LINK: - from dialin.squish import crc - MICRO = [8, 9] -else: - import crc - MICRO = [4] +from dialin.squish import crc +MICRO = [8, 9] def test_python_version(): - 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) Index: dialin/ui/hd_proxy.py =================================================================== diff -u -r80501868a8f9a2c145945bbebb486fb3a32edfb2 -rc3cc81dada72714b9675594cc0c6a79975e8991d --- dialin/ui/hd_proxy.py (.../hd_proxy.py) (revision 80501868a8f9a2c145945bbebb486fb3a32edfb2) +++ dialin/ui/hd_proxy.py (.../hd_proxy.py) (revision c3cc81dada72714b9675594cc0c6a79975e8991d) @@ -116,6 +116,3 @@ self.can_interface.send(message, 0) - - - Index: tests/test_demo.py =================================================================== diff -u -r8d1f61499650e23dac6f857e48daad42180db949 -rc3cc81dada72714b9675594cc0c6a79975e8991d --- tests/test_demo.py (.../test_demo.py) (revision 8d1f61499650e23dac6f857e48daad42180db949) +++ tests/test_demo.py (.../test_demo.py) (revision c3cc81dada72714b9675594cc0c6a79975e8991d) @@ -33,6 +33,7 @@ dg.cmd_ui_request_dg_version() time.sleep(0.5) print(dg.dg_version) + print(dg.fpga_version) def test_hd_version(): @@ -41,12 +42,13 @@ @return: None """ - hd = HD() + hd = HD(log_level="DEBUG") if hd.cmd_log_in_to_hd(): hd.ui.cmd_ui_request_hd_version() time.sleep(0.5) print(f"Current HD version: {hd.ui.hd_version}") + print(f"Current HD FPGA version: {hd.ui.fpga_version}") def test_hd_off_button(): @@ -122,4 +124,5 @@ if __name__ == '__main__': - test_reverse_lookup() + test_hd_version() + # test_dg_version() Index: tests/test_hd_simulator.py =================================================================== diff -u -r80501868a8f9a2c145945bbebb486fb3a32edfb2 -rc3cc81dada72714b9675594cc0c6a79975e8991d --- tests/test_hd_simulator.py (.../test_hd_simulator.py) (revision 80501868a8f9a2c145945bbebb486fb3a32edfb2) +++ tests/test_hd_simulator.py (.../test_hd_simulator.py) (revision c3cc81dada72714b9675594cc0c6a79975e8991d) @@ -85,7 +85,7 @@ if __name__ == '__main__': - test_clear_alarms() + # test_clear_alarms() sleep(1) test_poweroff() Fisheye: Tag c3cc81dada72714b9675594cc0c6a79975e8991d refers to a dead (removed) revision in file `tests/test_imports.py'. Fisheye: No comparison available. Pass `N' to diff? Index: tests/unit_tests/test_imports.py =================================================================== diff -u --- tests/unit_tests/test_imports.py (revision 0) +++ tests/unit_tests/test_imports.py (revision c3cc81dada72714b9675594cc0c6a79975e8991d) @@ -0,0 +1,79 @@ +########################################################################### +# +# Copyright (c) 2019-2020 Diality Inc. - All Rights Reserved. +# +# 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 test_imports.py +# +# @author (last) Peter Lucia +# @date (last) 20-Jul-2020 +# @author (original) Peter Lucia +# @date (original) 07-Apr-2020 +# +############################################################################ +import unittest +import sys +sys.path.append("../../") + + +class Test(unittest.TestCase): + + # @unittest.skip("Skipping test_imports") + def test_hd_imports(self): + from dialin.hd.alarms import HDAlarms + from dialin.hd.blood_flow import HDBloodFlow + from dialin.hd.buttons import HDButtons + from dialin.hd.constants import RESET, NO_RESET + from dialin.hd.dialysate_inlet_flow import HDDialysateInletFlow + from dialin.hd.dialysate_outlet_flow import HDDialysateOutletFlow + from dialin.hd.hemodialysis_device import HD + from dialin.hd.pressure_occlusion import HDPressureOcclusion + from dialin.hd.rtc import HDRTC + from dialin.hd.treatment import HDTreatment + from dialin.hd.ui_proxy import HDUIProxy + from dialin.hd.watchdog import HDWatchdog + + # @unittest.skip("Skipping test_imports") + def test_dg_imports(self): + + from dialin.dg.dialysate_generator import DG + from dialin.dg.drain_pump import DGDrainPump + from dialin.dg.hd_proxy import DGHDProxy + from dialin.dg.load_cells import DGLoadCells + from dialin.dg.pressures import DGPressures + from dialin.dg.reservoirs import DGReservoirs + + + # @unittest.skip("Skipping test_imports") + def test_protocols_imports(self): + + from dialin.protocols.CAN import (DenaliCanMessenger, + DenaliMessage, + DenaliChannels, + LongDenaliMessageBuilder) + + # @unittest.skip("Skipping test_imports") + def test_utils_imports(self): + + from dialin.utils.conversions import (integer_to_bytearray, + float_to_bytearray) + + # @unittest.skip("Skipping test_imports") + def test_api_version(self): + + import dialin + print(dialin.__version__) + + def test_squish(self): + from dialin.squish import (denaliMessages, + crc, + globals, + messageBuilder, + unittests, + utils) + + +if __name__ == '__main__': + unittest.main(verbosity=2) Index: tools/install_to_venv.sh =================================================================== diff -u -r4bdb012848d1b59be5edc31d677b77b9d95f6190 -rc3cc81dada72714b9675594cc0c6a79975e8991d --- tools/install_to_venv.sh (.../install_to_venv.sh) (revision 4bdb012848d1b59be5edc31d677b77b9d95f6190) +++ tools/install_to_venv.sh (.../install_to_venv.sh) (revision c3cc81dada72714b9675594cc0c6a79975e8991d) @@ -17,7 +17,7 @@ cd ../ ./build.sh -repo="$HOME/Project/testsuites/" +repo="$HOME/projects/testsuites/" read -p "Enter the path to the repository: " -e -i "$repo" repo whl_file="$(pwd)/dist/dialin-0.2.0_DEN_3964_Maintenance_1107444-py3-none-any.whl" read -p "Update the full path to the whl file to install to the virtualenv: " -e -i "$whl_file" whl_file @@ -28,4 +28,4 @@ if [ ! -d "$venv" ]; then echo "Could not find $venv" ; exit 1; fi source venv/bin/activate pip3 uninstall dialin -pip3 install $whl_file \ No newline at end of file +pip3 install $whl_file