Index: dialin/hd/pressure_occlusion.py =================================================================== diff -u -r9d9105c7dc3379c2e14996522291b23a19e7ba46 -rcdd3a485aebd088ffcab9848e6f1d0ec50e29624 --- dialin/hd/pressure_occlusion.py (.../pressure_occlusion.py) (revision 9d9105c7dc3379c2e14996522291b23a19e7ba46) +++ dialin/hd/pressure_occlusion.py (.../pressure_occlusion.py) (revision cdd3a485aebd088ffcab9848e6f1d0ec50e29624) @@ -314,3 +314,22 @@ else: print("Timeout!!!!") return False + + # TEST CODE *************************************** + def test_can_message(self, seq): + zero = self.outer_instance.integer2ByteArray(0) + seq1 = self.outer_instance.integer2ByteArray(seq) + seq2 = self.outer_instance.integer2ByteArray(seq+1) + seq3 = self.outer_instance.integer2ByteArray(seq+2) + seq4 = self.outer_instance.integer2ByteArray(seq+3) + seq5 = self.outer_instance.integer2ByteArray(seq+4) + + payload = seq1 + zero + seq2 + zero + seq3 + zero + seq4 + zero + seq5 + + message = DenaliMessage.buildMessage(channel_id=DenaliChannels.dialin_to_hd_ch_id, + message_id=6, + payload=payload) + + received_message = self.outer_instance.can_interface.send(message, 0) + + return True Index: dialin/hd/ui_proxy.py =================================================================== diff -u -rd24761670b6f557bf44ff5bb762c119a2e7cc889 -rcdd3a485aebd088ffcab9848e6f1d0ec50e29624 --- dialin/hd/ui_proxy.py (.../ui_proxy.py) (revision d24761670b6f557bf44ff5bb762c119a2e7cc889) +++ dialin/hd/ui_proxy.py (.../ui_proxy.py) (revision cdd3a485aebd088ffcab9848e6f1d0ec50e29624) @@ -177,7 +177,8 @@ build = struct.unpack('H', bytearray( message['message'][self.START_POS_BUILD:self.END_POS_BUILD])) - self.hd_version = 'v'+str(major)+'.'+str(minor)+'.'+str(build) + self.hd_version = 'v'+str(major[0])+'.'+str(minor[0])+'.'+str(build[0]) + print(self.hd_version) def handler_treatment_param_ranges(self, message): """ Index: tests/SeansHDTestScript.py =================================================================== diff -u --- tests/SeansHDTestScript.py (revision 0) +++ tests/SeansHDTestScript.py (revision cdd3a485aebd088ffcab9848e6f1d0ec50e29624) @@ -0,0 +1,42 @@ +########################################################################### +# +# Copyright (c) 2019-2019 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 HD_TestScript.py +# +# @date 19-Nov-2019 +# @author S. Nash +# +# @brief This is an example test script for the HD. +# +############################################################################ + +import sys +sys.path.append("..") +from dialin.hd.hemodialysis_device import HD +from time import sleep + +if __name__ == "__main__": + # create an HD object called hd + hd = HD() + sleep(2) + + # log into HD +# if hd.cmd_log_in_to_hd() == 0: +# exit(1) + + # reset sequence counter + x = 0 +# sleep(2) + # send large CAN test messages (6 frames each) every 100ms + while True: + sleep(0.1) + hd.pressure_occlusion.test_can_message(x) + x += 6 + + exit(1) + + Index: tests/SeansUFTest.py =================================================================== diff -u --- tests/SeansUFTest.py (revision 0) +++ tests/SeansUFTest.py (revision cdd3a485aebd088ffcab9848e6f1d0ec50e29624) @@ -0,0 +1,56 @@ +########################################################################### +# +# Copyright (c) 2019-2019 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 HD_UFTest.py +# +# @date 28-Jan-2020 +# @author S. Nash +# +# @brief This script simulates 300 grams of load cell increase over 15 minutes (20 mL/min). +# +############################################################################ + +import sys +sys.path.append("..") +from dialin.hd.hemodialysis_device import HD +from time import sleep + +if __name__ == "__main__": + # create an HD object called hd + hd = HD() + sleep(2) + + # log in to HD as tester + if hd.cmd_log_in_to_hd() == 0: + exit(1) + sleep(1) + + loadCellGrams = float(1500.0) #start reservoir at 1.5 L (1,500 g) + hdUFRate = 20.0 #assuming UF rate is 20 mL/min + idealWeightChange = hdUFRate / 60.0 #if DPo is controlling perfectly, this would be the weight gain per second + + while hd.dialysate_outlet_flow.PWMDutyCyclePct < 15.0: #wait for treatment to start + hd.dialysate_outlet_flow.CmdSetLoadCellWeights(loadCellGrams, 0.0, 0.0, 0.0) + sleep(1) + + # simulate load cell increase over time w/ some response to UF control + while True: + sleep(1) + error = hd.dialysate_outlet_flow.PWMDutyCyclePct - hd.dialysate_outlet_flow.PWMDutyCyclePct + addedWeight = error * 0.1 + loadCellGrams += addedWeight + hd.dialysate_outlet_flow.CmdSetLoadCellWeights(loadCellGrams, 0.0, 0.0, 0.0) + print("DPi PWM: " + str(hd.dialysate_outlet_flow.PWMDutyCyclePct) + " DPo PWM: " + str(hd.dialysate_outlet_flow.PWMDutyCyclePct)) + print("Treatment Time: " + str(hd.treatment.TreatmentTimeElapsed) + " sec.") + print("Reservoir Vol.: " + str(loadCellGrams) + " mL.") + print("Reference Vol.: " + str(hd.dialysate_outlet_flow.ReferenceDialysateOutletUFVolume) + " mL.") + print("Meas. UF Vol.: " + str(hd.dialysate_outlet_flow.MeasuredDialysateOutletUFVolume) + " mL.") + print("") + + exit(1) + +