Index: dialin/dg/heat_disinfect.py =================================================================== diff -u -r681b3e2813b532d2a15cfeec76fe46fdaf4282e0 -r46fb3f18ae1a349eeb8bcc56d243618737ae3279 --- dialin/dg/heat_disinfect.py (.../heat_disinfect.py) (revision 681b3e2813b532d2a15cfeec76fe46fdaf4282e0) +++ dialin/dg/heat_disinfect.py (.../heat_disinfect.py) (revision 46fb3f18ae1a349eeb8bcc56d243618737ae3279) @@ -1,7 +1,6 @@ import struct from ..utils.conversions import integer_to_bytearray -from ..utils.conversions import float_to_bytearray #TODO remove from ..common.msg_defs import MsgIds, MsgFieldPositions from ..protocols.CAN import (DenaliMessage, DenaliChannels) from ..utils.base import _AbstractSubSystem, _publish, DialinEnum Index: dialin/dg/ro_pump.py =================================================================== diff -u -r65cf1d8021361e0f51aed3a60fceefb54cc784e1 -r46fb3f18ae1a349eeb8bcc56d243618737ae3279 --- dialin/dg/ro_pump.py (.../ro_pump.py) (revision 65cf1d8021361e0f51aed3a60fceefb54cc784e1) +++ dialin/dg/ro_pump.py (.../ro_pump.py) (revision 46fb3f18ae1a349eeb8bcc56d243618737ae3279) @@ -26,9 +26,9 @@ @unique class ROPumpStates(DialinEnum): RO_PUMP_OFF_STATE = 0 - RO_PUMP_RAMP_UP_STATE = 1 - RO_PUMP_VERIFY_FLOW_STATE = 2 - RO_PUMP_CONTROL_TO_TARGET_STATE = 3 + RO_PUMP_RAMP_UP_TO_TARGET_FLOW_STATE = 1 + RO_PUMP_CONTROL_TO_TARGET_FLOW_STATE = 2 + RO_PUMP_CONTROL_TO_MAX_PRESSURE_STATE = 3 RO_PUMP_OPEN_LOOP_STATE = 4 Index: dialin/hd/valves.py =================================================================== diff -u -r0035249fd22540886ba093c4e7dc72f9ba8c8353 -r46fb3f18ae1a349eeb8bcc56d243618737ae3279 --- dialin/hd/valves.py (.../valves.py) (revision 0035249fd22540886ba093c4e7dc72f9ba8c8353) +++ dialin/hd/valves.py (.../valves.py) (revision 46fb3f18ae1a349eeb8bcc56d243618737ae3279) @@ -19,26 +19,29 @@ from ..utils.conversions import integer_to_bytearray from .constants import NO_RESET from ..protocols.CAN import (DenaliMessage, DenaliChannels) -from ..utils.base import _AbstractSubSystem, _publish +from ..utils.base import _AbstractSubSystem, _publish, DialinEnum from ..common import MsgIds from logging import Logger -from ..utils.base import DialinEnum +from enum import unique +@unique class ValvesEnum(DialinEnum): VDI = 0 VDO = 1 VBA = 2 VBV = 3 +@unique class ValvesPositions(DialinEnum): VALVE_POSITION_NOT_IN_POSITION = 0 VALVE_POSITION_A_INSERT_EJECT = 1 VALVE_POSITION_B_OPEN = 2 VALVE_POSITION_C_CLOSE = 3 +@unique class ValvesStates(DialinEnum): VALVE_STATE_WAIT_FOR_POST = 0 VALVE_STATE_HOMING_NOT_STARTED = 1 @@ -49,6 +52,7 @@ VALVE_STATE_IN_BYPASS_MODE = 6 +@unique class AirTrapState(DialinEnum): STATE_CLOSED = 0 STATE_OPEN = 1 @@ -58,9 +62,10 @@ """ \class HDValves - \brief Hemodialysis Device (HD) Dialin API sub-class for valves related commands. + @brief Hemodialysis Device (HD) Dialin API sub-class for valves related commands. """ # Valves states publish message field positions + # Note the MsgFieldPosition was not used since some of the published data are S16 START_POS_VALVES_ID = DenaliMessage.PAYLOAD_START_INDEX END_POS_VALVES_ID = START_POS_VALVES_ID + 4 @@ -98,7 +103,8 @@ """ DGDrainPump constructor - \param outer_instance: reference to the DG (outer) class. + @param can_interface: (DenaliCanMessenger) - Denali CAN messenger object. + @param logger: (Logger) - Dialin logger """ super().__init__() self.can_interface = can_interface @@ -116,6 +122,14 @@ self.hd_air_trap_status = 0 + def get_hd_valves_status(self): + """ + Gets the hd valves status + + @return: (dict) the hd valves status + """ + return self.valves_status + def cmd_hd_valves_broadcast_interval_override(self, ms, reset=NO_RESET): """ Constructs and sends broadcast time interval @@ -148,16 +162,17 @@ """ Constructs and sends the HD valves set position for a valve - \param valve: integer - Valve number: + @param valve: integer - Valve number: VDI = 0 VDO = 1 VBA = 2 VBV = 3 - \param position: integer - Position number: + @param position: integer - Position number: VALVE_POSITION_A_INSERT_EJECT = 1 VALVE_POSITION_B_OPEN = 2 VALVE_POSITION_C_CLOSE = 3 - \returns 1 if successful, zero otherwise + @param reset: integer - 1 to reset a previous override, 0 to override + @returns 1 if successful, zero otherwise """ reset_value = integer_to_bytearray(reset) vlv = integer_to_bytearray(valve) @@ -182,15 +197,16 @@ """ Constructs and sends the HD valves PWM command - \param valve: integer - Valve number: + @param valve: integer - Valve number: VDI = 0 VDO = 1 VBA = 2 VBV = 3 - \param direction: integer - Direction number: + @param direction: integer - Direction number: 0 = Clockwise 1 = Counter clockwise - \returns 1 if successful, zero otherwise + @param reset: integer - 1 to reset a previous override, 0 to override + @returns 1 if successful, zero otherwise """ reset_value = integer_to_bytearray(reset) vlv = integer_to_bytearray(valve) @@ -216,12 +232,12 @@ """ Constructs and sends the HD valves home command - \param vavle: integer - Valve number: + @param valve: integer - Valve number: VDI = 0 VDO = 1 VBA = 2 VBV = 3 - \returns 1 if successful, zero otherwise + @returns 1 if successful, zero otherwise """ payload = integer_to_bytearray(valve) @@ -243,7 +259,8 @@ """ Constructs and sends an open/close command to the HD air trap valve - \returns 1 if successful, zero otherwise + @param valve_state: air trap valve state (open or close) + @returns 1 if successful, zero otherwise """ if valve_state == AirTrapState.STATE_OPEN: @@ -272,8 +289,8 @@ Handles published HD valves data messages. HD valves data are captured for reference. - \param message: published HD valves data message - \returns none + @param message: published HD valves data message + @returns none """ vlv_ID = struct.unpack('i', bytearray( message['message'][self.START_POS_VALVES_ID:self.END_POS_VALVES_ID]))[0] Index: tests/dg_heat_disinfect_test.py =================================================================== diff -u -r681b3e2813b532d2a15cfeec76fe46fdaf4282e0 -r46fb3f18ae1a349eeb8bcc56d243618737ae3279 --- tests/dg_heat_disinfect_test.py (.../dg_heat_disinfect_test.py) (revision 681b3e2813b532d2a15cfeec76fe46fdaf4282e0) +++ tests/dg_heat_disinfect_test.py (.../dg_heat_disinfect_test.py) (revision 46fb3f18ae1a349eeb8bcc56d243618737ae3279) @@ -92,7 +92,6 @@ dg.ro_pump.measured_flow_rate_lpm)) return info - def get_heaters_info(): info = ('Pri_main_DC, {:5.3f}, Pri_small_DC, {:5.3f}, Pri_int_temp, {:5.3f}, Trimmer_DC, {:5.3f}, '. @@ -134,7 +133,6 @@ sleep(1) dg.valves.cmd_valve_override(1, dg.valves.VALVE_RESERVOIR_DRAIN) - def run_heat_disinfect(): complete_counter = 1 @@ -185,7 +183,4 @@ run_heat_disinfect() - #actuate_valve() - - Index: tests/test_hd_valves.py =================================================================== diff -u -r0035249fd22540886ba093c4e7dc72f9ba8c8353 -r46fb3f18ae1a349eeb8bcc56d243618737ae3279 --- tests/test_hd_valves.py (.../test_hd_valves.py) (revision 0035249fd22540886ba093c4e7dc72f9ba8c8353) +++ tests/test_hd_valves.py (.../test_hd_valves.py) (revision 46fb3f18ae1a349eeb8bcc56d243618737ae3279) @@ -24,13 +24,12 @@ # create an HD object called hd hd = HD() hd.cmd_log_in_to_hd() - hd.valves.cmd_hd_valves_broadcast_interval_override(100) + + hd.valves.cmd_hd_valves_broadcast_interval_override(50) sleep(1) - hd.valves.cmd_home_hd_valve(ValvesEnum.VBV.value) + hd.valves.cmd_home_hd_valve(ValvesEnum.VDI.name) - print(hd.valves.valves_status[ValvesEnum.VDI.name]) - - """" + """ # print params every second for a while while True: sleep(0.100) @@ -60,4 +59,5 @@ hd.valves.valves_status[ValvesEnum.VBV.name]['Current']) exit(1) - """ \ No newline at end of file + """ + Index: version.py =================================================================== diff -u -rced5678ead1dc30ee56f53786c4cce3ac2e1efd6 -r46fb3f18ae1a349eeb8bcc56d243618737ae3279 --- version.py (.../version.py) (revision ced5678ead1dc30ee56f53786c4cce3ac2e1efd6) +++ version.py (.../version.py) (revision 46fb3f18ae1a349eeb8bcc56d243618737ae3279) @@ -1,69 +1 @@ -########################################################################### -# -# 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 version.py -# -# @author (last) Peter Lucia -# @date (last) 10-Nov-2020 -# @author (original) Peter Lucia -# @date (original) 16-Jun-2020 -# -############################################################################ -import subprocess - -VERSION = "0.8.1" - - -def get_branch(): - """ - Gets the current branch name in the current git repository - - @return: The current branch name, None if it can't be determined - """ - - try: - return subprocess.check_output("git rev-parse --abbrev-ref HEAD", shell=True).decode("utf-8").strip() - except subprocess.CalledProcessError: - return None - - -def get_last_commit(): - """ - Gets the latest commit in the current git repository - - @return: (str) the latest commit in the current git repository, None if it can't be determined - """ - try: - return subprocess.check_output("git rev-parse --short=7 HEAD", shell=True).decode("utf-8").strip() - except subprocess.CalledProcessError: - return None - - -def check_if_git_repo(): - """ - Checks if we're in a git repo or not to know if we can get the git branch and commit - - @return: True if in a git repo, False otherwise - """ - - return subprocess.call(["git", "branch"], stderr=subprocess.DEVNULL, stdout=subprocess.DEVNULL) == 0 - - -branch = None -commit = None - -DEV_VERSION = VERSION - -if check_if_git_repo(): - branch = get_branch() - commit = get_last_commit() - DEV_VERSION += "-{0}".format(branch) - DEV_VERSION += "-{0}".format(commit) - - -if __name__ == '__main__': - print(VERSION) +dialin/version.py \ No newline at end of file