Index: dialin/squish/denaliMessages.py =================================================================== diff -u -r27357f8b363431d4bbb9f15960b24c7036fdc76c -r404342de006f3c76a9a00e76017440954098999d --- dialin/squish/denaliMessages.py (.../denaliMessages.py) (revision 27357f8b363431d4bbb9f15960b24c7036fdc76c) +++ dialin/squish/denaliMessages.py (.../denaliMessages.py) (revision 404342de006f3c76a9a00e76017440954098999d) @@ -14,17 +14,6 @@ # @date (original) 09-Jul-2020 # ############################################################################ -## -# Copyright (c) 2019-2020 Diality Inc. - All Rights Reserved. -# copyright -# 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 denaliMessages.py -# date 2020/04/08 -# author Behrouz NematiPour -# import time import subprocess @@ -90,42 +79,81 @@ def send_acknowledge_HD(): + """ + the acknowledge from HD + :return: none + """ subprocess.call(['cansend', 'can0', '020#A5.01.00.FF.FF.00.19.00']) def send_acknowledge_UI(): + """ + the acknowledge from UI + :return: none + """ subprocess.call(['cansend', 'can0', '100#A5.01.00.FF.FF.00.19.00']) def send_CheckIn_DG(): + """ + check-in (keep alive) message from DG + :return: none + """ subprocess.call(['cansend', 'can0', '010#A5.01.00.06.00.00.76.00']) def show_PowerOffDialog(): + """ + the message from HD to UI to show the power off dialog + :return: none + """ subprocess.call(['cansend', 'can0', '020#A5.01.00.01.00.01.00.38']) def hide_PowerOffDialog(): + """ + the message from HD to UI to hide the power off dialog + :return: none + """ subprocess.call(['cansend', 'can0', '020#A5.01.00.01.00.01.01.09']) def show_PowerOffNotificationDialog(): + """ + the message from HD to UI to shew the shutting down notipication box + :return: none + """ subprocess.call(['cansend', 'can0', '040#A5.01.00.0E.00.00.24.00']) def show_PowerOffRejectionDialog(): + """ + the message from HD to UI to show the power off dialog + :return: none + """ subprocess.call(['cansend', 'can0', '020#A5.01.00.01.00.01.02.5A']) -################################################################################################## -# After each multi-frame message put a 100ms sleep, time.sleep(0.1) # -# it seems it's needed otherwise the test will check a value which has not been received yet. # -################################################################################################## def waitForMessageToBeSent(): + """ + After each multi-frame message put a 100ms sleep, time.sleep(0.1) # + it seems it's needed otherwise the test will check a value which has not been received yet. # + :return: none + """ time.sleep(0.050) # 50ms ## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ def buildHDDebugText(vText): + """ + the debug text message from HD builder method + :param vText: (str) the debug text + :return: none + """ len = 40 txt = messageBuilder.textToByte(vText, len) # + 1 null term msg = messageBuilder.buildMessage( GuiActionType.HDDebugText, 1 * (len + 1), False, txt) return messageBuilder.toFrames(msg) ## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ def setHDDebugText (vText): + """ + the debug text message from HD setter/sender method + :param vText: (str) the debug text + :return: none + """ frames = buildHDDebugText(vText) frames = messageBuilder.toCandumpFormat(frames) for frame in frames: @@ -135,13 +163,23 @@ ## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ def buildDGDebugText(vText): + """ + the debug text message from DG builder method + :param vText: (str) the debug text + :return: none + """ len = 40 txt = messageBuilder.textToByte(vText, len) # + 1 null term msg = messageBuilder.buildMessage( GuiActionType.DGDebugText, 1 * (len + 1), False, txt) return messageBuilder.toFrames(msg) ## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ def setDGDebugText (vText): + """ + the debug text message from DG setter/sender method + :param vText: (str) the debug text + :return: none + """ frames = buildDGDebugText(vText) frames = messageBuilder.toCandumpFormat(frames) for frame in frames: @@ -151,6 +189,19 @@ ## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ def buildSetTreatmentParamRanges(vMinTreatmentDuration, vMaxTreatmentDuration, vMinUFVolume, vMaxUFVolume, vMinDialysateFlowRate, vMaxDialysateFlowRate): + """ + the Treatment adjustment param ranges data message builder method + | MSG | CAN ID | Box | Type | Ack | Src | Dst | Description | #1:(U32) | #2:(U32) | #3:(F32) | #4:(F32) | #5:(U32) | #6:(U32) | + |:----:|:------:|:---:|:------:|:---:|:---:|:---:|:-----------: |:--: |:--: |:--: |:--: |:--: |:--: | + |0x1A00| 0x020 | 6 | 1/60 Hz| Y | HD | UI | Treatment adjustment param ranges Data | \ref Data::mDuration_Min | \ref Data::mDuration_Max | \ref Data::mUltrafiltration_Volume_Min | \ref Data::mUltrafiltration_Volume_Max | \ref Data::mDialysate_Flow_Min | \ref Data::mDialysate_Flow_Max | + :param vMinTreatmentDuration: (int) Min Treatment Duration + :param vMaxTreatmentDuration: (int) Max Treatment Duration + :param vMinUFVolume: (float) Min UF Volume + :param vMaxUFVolume: (float) Max UF Volume + :param vMinDialysateFlowRate: (int) Min Dialysate Flow Rate + :param vMaxDialysateFlowRate: (int) Max Dialysate Flow Rate + :return: (str) built message frame(s) + """ msg = messageBuilder.buildMessage(GuiActionType.TreatmentRanges, 4 * 6, True, utils.toI32(vMinTreatmentDuration), utils.toI32(vMaxTreatmentDuration), @@ -163,6 +214,16 @@ def setTreatmentParamRanges(vMinTreatmentDuration, vMaxTreatmentDuration, vMinUFVolume, vMaxUFVolume, vMinDialysateFlowRate, vMaxDialysateFlowRate): + """ + the Treatment adjustment param ranges data message setter/sender method + :param vMinTreatmentDuration: (int) Min Treatment Duration + :param vMaxTreatmentDuration: (int) Max Treatment Duration + :param vMinUFVolume: (float) Min UF Volume + :param vMaxUFVolume: (float) Max UF Volume + :param vMinDialysateFlowRate: (int) Min Dialysate Flow Rate + :param vMaxDialysateFlowRate: (int) Max Dialysate Flow Rate + :return: none + """ frames = buildSetTreatmentParamRanges(vMinTreatmentDuration, vMaxTreatmentDuration, vMinUFVolume, vMaxUFVolume, vMinDialysateFlowRate, vMaxDialysateFlowRate) frames = messageBuilder.toCandumpFormat(frames) for frame in frames: @@ -171,6 +232,20 @@ def buildSetTreatmentBloodFlowRate(vFlowSetPt, vMeasFlow, vRotSpd, vMotSpd, vMCSpd, vMCCurr, vPWM): + """ + the Blood Flow Data message builder method + | MSG | CAN ID | Box | Type | Ack | Src | Dst | Description | #1:(S32) | #2:(F32) | #3:(F32) | #4:(F32) | #5:(F32) | #6:(F32) | #7:(F32) | + |:----:|:------:|:---:|:------:|:---:|:---:|:---:|:-----------: |:--: |:--: |:--: |:--: |:--: |:--: |:--: | + |0x0500| 0x040 | 7 | 1 Hz | N | HD | All | Blood Flow Data | \ref Data::mFlowSetPoint | \ref Data::mMeasuredFlow | \ref Data::mRotorSpeed | \ref Data::mMotorSpeed | \ref Data::mMotorCtlSpeed | \ref Data::mMotorCtlCurrent | \ref Data::mPWMDutyCycle | + :param vFlowSetPt: (signed int) Flow Set Point + :param vMeasFlow: (float) Measured Flow + :param vRotSpd: (float) Rot Speed + :param vMotSpd: (float) Motor Speed + :param vMCSpd: (float) MC Speed + :param vMCCurr: (float) MC Current + :param vPWM: (float) PWM + :return: (str) built message frame(s) + """ msg = messageBuilder.buildMessage(GuiActionType.BloodFlow, 4 * 7, False, utils.toI32(vFlowSetPt ), utils.toF32(vMeasFlow ), @@ -184,6 +259,17 @@ def setTreatmentBloodFlowRate(vFlowSetPt, vMeasFlow, vRotSpd, vMotSpd, vMCSpd, vMCCurr, vPWM): + """ + the Blood Flow Data message setter/sender method + :param vFlowSetPt: (signed int) Flow Set Point + :param vMeasFlow: (float) Measured Flow + :param vRotSpd: (float) Rot Speed + :param vMotSpd: (float) Motor Speed + :param vMCSpd: (float) MC Speed + :param vMCCurr: (float) MC Current + :param vPWM: (float) PWM + :return: none + """ frames = buildSetTreatmentBloodFlowRate(vFlowSetPt, vMeasFlow, vRotSpd, vMotSpd, vMCSpd, vMCCurr, vPWM) frames = messageBuilder.toCandumpFormat(frames) for frame in frames: @@ -192,6 +278,20 @@ def buildSetTreatmentDialysateFlowRate(vFlowSetPt, vMeasFlow, vRotSpd, vMotSpd, vMCSpd, vMCCurr, vPWM): + """ + the Dialysate Flow Data message builder method + | MSG | CAN ID | Box | Type | Ack | Src | Dst | Description | #1:(S32) | #2:(F32) | #3:(F32) | #4:(F32) | #5:(F32) | #6:(F32) | #7:(F32) | + |:----:|:------:|:---:|:------:|:---:|:---:|:---:|:-----------: |:--: |:--: |:--: |:--: |:--: |:--: |:--: | + |0x0800| 0x040 | 7 | 1 Hz | N | HD | All | Dialysate Flow Data | mFlowSetPoint | mMeasuredFlow | mRotorSpeed | mMotorSpeed | mMotorCtlSpeed | mMotorCtlCurrent | mPWMDutyCycle | + :param vFlowSetPt: (signed int) Flow Set Point + :param vMeasFlow: (float) Measured Flow + :param vRotSpd: (float) Rot Speed + :param vMotSpd: (float) Motor Speed + :param vMCSpd: (float) MC Speed + :param vMCCurr: (float) MC Current + :param vPWM: (float) PWM + :return: (str) built message frame(s) + """ msg = messageBuilder.buildMessage(GuiActionType.DialysateInletFlow, 4 * 7, False, utils.toI32(vFlowSetPt), utils.toF32(vMeasFlow), @@ -205,6 +305,17 @@ def setTreatmentDialysateFlowRate(vFlowSetPt, vMeasFlow, vRotSpd, vMotSpd, vMCSpd, vMCCurr, vPWM): + """ + the Dialysate Flow Data message setter/sender method + :param vFlowSetPt: (signed int) Flow Set Point + :param vMeasFlow: (float) Measured Flow + :param vRotSpd: (float) Rot Speed + :param vMotSpd: (float) Motor Speed + :param vMCSpd: (float) MC Speed + :param vMCCurr: (float) MC Current + :param vPWM: (float) PWM + :return: none + """ frames = buildSetTreatmentDialysateFlowRate(vFlowSetPt, vMeasFlow, vRotSpd, vMotSpd, vMCSpd, vMCCurr, vPWM) frames = messageBuilder.toCandumpFormat(frames) for frame in frames: @@ -213,6 +324,17 @@ def buildTreatmentAdjustBloodDialysateResponse(vAccepted, vReason, vBloodRate, vDialysate): + """ + the Blood/dialysate rate change Response message builder method + | MSG | CAN ID | Box | Type | Ack | Src | Dst | Description | #1:(U32) | #2:(U32) | #3:(U32) | #4:(U32) | + |:----:|:------:|:---:|:------:|:---:|:---:|:---:|:-----------: |:--: |:--: |:--: |:--: | + |0x1800| 0x020 | 6 | Rsp | Y | HD | UI | Blood/dialysate rate change Response | \ref Data::mAccepted | \ref Data::mReason | \ref Data::mBloodRate | \ref Data::mDialysateRate | + :param vAccepted: (int) boolean accept/reject response + :param vReason: (int) rejection reason + :param vBloodRate: (int) Blood Flow Rate + :param vDialysate: (int) Dialysate Flow Rate + :return: (str) built message frame(s) + """ msg = messageBuilder.buildMessage(GuiActionType.AdjustBloodDialysateRsp, 4 * 4, True, utils.toI32(vAccepted), utils.toI32(vReason), @@ -223,6 +345,14 @@ def sendTreatmentAdjustBloodDialysateResponse(vAccepted, vReason, vBloodRate, vDialysate): + """ + the Blood/dialysate rate change Response message setter/sender method + :param vAccepted: (int) boolean accept/reject response + :param vReason: (int) rejection reason + :param vBloodRate: (int) Blood Flow Rate + :param vDialysate: (int) Dialysate Flow Rate + :return: none + """ frames = buildTreatmentAdjustBloodDialysateResponse(vAccepted, vReason, vBloodRate, vDialysate) frames = messageBuilder.toCandumpFormat(frames) for frame in frames: @@ -231,6 +361,17 @@ def buildTreatmentAdjustDurationResponse(vAccepted, vReason, vDuration, vUltrafiltration): + """ + the Treatment Duration change Response message builder method + | MSG | CAN ID | Box | Type | Ack | Src | Dst | Description | #1:(U32) | #2:(U32) | #3:(U32) | #5:(F32) | + |:----:|:------:|:---:|:------:|:---:|:---:|:---:|:-----------: |:--: |:--: |:--: |:--: | + |0x1B00| 0x020 | 6 | Rsp | Y | HD | UI | Treatment Duration change Response | \ref Data::mAccepted | \ref Data::mReason | \ref Data::mDuration | \ref Data::mUFVolume | + :param vAccepted: (int) boolean accept/reject response + :param vReason: (int) rejection reason + :param vDuration: (int) Treatment Duration + :param vUltrafiltration: (float) Ultrafiltration Volume + :return: (str) built message frame(s) + """ msg = messageBuilder.buildMessage(GuiActionType.AdjustDurationRsp, 4 * 4, True, utils.toI32(vAccepted), utils.toI32(vReason), @@ -241,6 +382,14 @@ def sendTreatmentAdjustDurationResponse(vAccepted, vReason, vDuration, vUltrafiltration): + """ + the Treatment Duration change Response message setter/sender method + :param vAccepted: (int) boolean accept/reject response + :param vReason: (int) rejection reason + :param vDuration: (int) Treatment Duration + :param vUltrafiltration: (float) Ultrafiltration Volume + :return: none + """ frames = buildTreatmentAdjustDurationResponse(vAccepted, vReason, vDuration, vUltrafiltration) frames = messageBuilder.toCandumpFormat(frames) for frame in frames: @@ -249,13 +398,27 @@ def buildTreatmentAdjustUltrafiltrationStateResponse(vState): + """ + the Treatment ultrafiltration adjustment response message builder method + | MSG | CAN ID | M.Box | Type | Ack | Src | Dest | Description | #1:(U08) | + |:----:|:------:|:-----:|:----:|:---:|:---:|:----:|:-----------: |:--: | + |0x1000| 0x100 | 9 | Rsp | N | HD | UI | Generic response ACK/NAK | mAccepted | + :param vState: (-128