Index: dialin/squish/README.md =================================================================== diff -u --- dialin/squish/README.md (revision 0) +++ dialin/squish/README.md (revision e6e9d40940a3ce8b012b13be4fe65fea5b0a5168) @@ -0,0 +1,46 @@ +This directory contains the scripts written for testing the Denali Applicaiton within SquishQt +without the presence of any hardware. +These scripts mostly contains Denali Messaging functions and some other utility functions. + +Please note that the following instructions have been reformatted to markdown and may change in the near future. + +Steps to use the scripts: + +1 - Squish Qt creates a folder scripts in the testsuite created project in the shared folder. + +``` +/home/denali/Project/testsuites/shared/scripts +``` + +2 - To use them we need to first clone the repo in an appropriate folder of yours. + + +``` + cd /home/denali/Projects/common/ + git clone ssh://git@192.168.10.132:7999/comm/pycommon.git +``` + +3 - then you'll have +``` +/home/denali/Projects/common/pycommon/squishapi/ +``` + +4 - after that go to your testsuites project shared folder : +``` +/home/denali/Project/testsuites/shared/scripts +``` +and create a link to the cloned folder +``` +ln -s ../../../common/pycommon/squishapi/ +``` +Note that the path above is relative and regarding this docuemnt examples. + +5 - How to use it in your scripts is to then import them by the pythonm import. +eg: +``` +import squishapi.denaliMessages as denaliMessages +denaliMessages.send_acknowledge_UI() +``` + + + Index: dialin/squish/__init__.py =================================================================== diff -u --- dialin/squish/__init__.py (revision 0) +++ dialin/squish/__init__.py (revision e6e9d40940a3ce8b012b13be4fe65fea5b0a5168) @@ -0,0 +1 @@ \ No newline at end of file Index: dialin/squish/crc.py =================================================================== diff -u -r11074441e3cf2a05a9b8c55c6a7c9c21bc5fb5a3 -re6e9d40940a3ce8b012b13be4fe65fea5b0a5168 --- dialin/squish/crc.py (.../crc.py) (revision 11074441e3cf2a05a9b8c55c6a7c9c21bc5fb5a3) +++ dialin/squish/crc.py (.../crc.py) (revision e6e9d40940a3ce8b012b13be4fe65fea5b0a5168) @@ -10,9 +10,7 @@ # file crc.py # date 2020/04/08 # author Behrouz NematiPour -# -## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ crc8_table = ( 0, 49, 98, 83, 196, 245, 166, 151, 185, 136, 219, 234, 125, 76, 31, 46, 67, 114, 33, 16, 135, 182, 229, 212, 250, 203, 152, 169, 62, 15, 92, 109, @@ -32,7 +30,6 @@ 130, 179, 224, 209, 70, 119, 36, 21, 59, 10, 89, 104, 255, 206, 157, 172 ) -## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ def crc8(vData): crc = 0 l = len(vData) @@ -43,9 +40,9 @@ i = i + 1 return crc -## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -def calcCRC8(vString, vDelimiter = '.'): + +def calcCRC8(vString, vDelimiter='.'): str = vString.replace(vDelimiter, '') - ba = bytearray.fromhex(str) - x = '{:02X}'.format(crc8(ba), 'x') + ba = bytearray.fromhex(str) + x = '{:02X}'.format(crc8(ba), 'x') return x Index: dialin/squish/denaliMessages.py =================================================================== diff -u -r11074441e3cf2a05a9b8c55c6a7c9c21bc5fb5a3 -re6e9d40940a3ce8b012b13be4fe65fea5b0a5168 --- dialin/squish/denaliMessages.py (.../denaliMessages.py) (revision 11074441e3cf2a05a9b8c55c6a7c9c21bc5fb5a3) +++ dialin/squish/denaliMessages.py (.../denaliMessages.py) (revision e6e9d40940a3ce8b012b13be4fe65fea5b0a5168) @@ -14,58 +14,58 @@ import time import subprocess -import utils -import messageBuilder +from .utils import toI32, toF32, toI16 +from .messageBuilder import buildMessage, toFrames, toCandumpFormat -#from enum import IntEnum class EResponse: Rejected = 0 Accepted = 1 - + + class GuiActionType: - Unknown = 0 - PowerOff = 1 - KeepAlive = 7 - BloodFlow = 5 - DialysateInletFlow = 8 - DialysateOutletFlow = 11 - TreatmentTime = 13 - PowerOffBroadcast = 14 - - AlarmStatus = 2 - AlarmTriggered = 3 - AlarmCleared = 4 - - PressureOcclusion = 9 - LoadCellReadings = 12 - TemperatureSensors = 45 - CanBUSFaultCount = 2457 + Unknown = 0 + PowerOff = 1 + KeepAlive = 7 + BloodFlow = 5 + DialysateInletFlow = 8 + DialysateOutletFlow = 11 + TreatmentTime = 13 + PowerOffBroadcast = 14 - - AdjustBloodDialysateReq = 23 - AdjustBloodDialysateRsp = 24 - - AdjustDurationReq = 22 - AdjustDurationRsp = 27 - - AdjustUltrafiltrationStateReq = 16 # Req and Rsp are the same in this specific message - - AdjustUltrafiltrationEditReq = 17 - AdjustUltrafiltrationEditRsp = 19 + AlarmStatus = 2 + AlarmTriggered = 3 + AlarmCleared = 4 - AdjustUltrafiltrationConfirmReq = 21 - AdjustUltrafiltrationConfirmRsp = 46 + PressureOcclusion = 9 + LoadCellReadings = 12 + TemperatureSensors = 45 + CanBUSFaultCount = 2457 - TreatmentRanges = 26 - String = 65279 + AdjustBloodDialysateReq = 23 + AdjustBloodDialysateRsp = 24 - Acknow = 65535 - - AcknowGeneric = 0 # Generic Acknowledgment is not a unique message ID and inherits its Id from the actual message. Zero is a placeholder + AdjustDurationReq = 22 + AdjustDurationRsp = 27 + AdjustUltrafiltrationStateReq = 16 # Req and Rsp are the same in this specific message + AdjustUltrafiltrationEditReq = 17 + AdjustUltrafiltrationEditRsp = 19 + + AdjustUltrafiltrationConfirmReq = 21 + AdjustUltrafiltrationConfirmRsp = 46 + + TreatmentRanges = 26 + + String = 65279 + + Acknow = 65535 + + AcknowGeneric = 0 # Generic Acknowledgment is not a unique message ID and inherits its Id from the actual message. Zero is a placeholder + + def send_acknowledge_HD(): subprocess.call(['cansend', 'can0', '020#A5.01.00.FF.FF.00.19.00']) @@ -91,368 +91,652 @@ def waitForMessageToBeSent(): time.sleep(0.200) # 200ms -## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ def buildSetTreatmentParamRanges(vMinTreatmentDuration, vMaxTreatmentDuration, vMinUFVolume, vMaxUFVolume, vMinDialysateFlowRate, vMaxDialysateFlowRate): - msg = messageBuilder.buildMessage( GuiActionType.TreatmentRanges, 4 * 6, True, - utils.toI32(vMinTreatmentDuration), - utils.toI32(vMaxTreatmentDuration), - utils.toF32(vMinUFVolume ), - utils.toF32(vMaxUFVolume ), - utils.toI32(vMinDialysateFlowRate), - utils.toI32(vMaxDialysateFlowRate) + """ + + @param vMinTreatmentDuration: + @param vMaxTreatmentDuration: + @param vMinUFVolume: + @param vMaxUFVolume: + @param vMinDialysateFlowRate: + @param vMaxDialysateFlowRate: + @return: + """ + msg = buildMessage(GuiActionType.TreatmentRanges, 4 * 6, True, + toI32(vMinTreatmentDuration), + toI32(vMaxTreatmentDuration), + toF32(vMinUFVolume ), + toF32(vMaxUFVolume ), + toI32(vMinDialysateFlowRate), + toI32(vMaxDialysateFlowRate) ) - return messageBuilder.toFrames(msg) -## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -def setTreatmentParamRanges (vMinTreatmentDuration, vMaxTreatmentDuration, vMinUFVolume, vMaxUFVolume, vMinDialysateFlowRate, vMaxDialysateFlowRate): + return toFrames(msg) + +def setTreatmentParamRanges(vMinTreatmentDuration, vMaxTreatmentDuration, vMinUFVolume, vMaxUFVolume, vMinDialysateFlowRate, vMaxDialysateFlowRate): + """ + + @param vMinTreatmentDuration: + @param vMaxTreatmentDuration: + @param vMinUFVolume: + @param vMaxUFVolume: + @param vMinDialysateFlowRate: + @param vMaxDialysateFlowRate: + @return: + """ frames = buildSetTreatmentParamRanges(vMinTreatmentDuration, vMaxTreatmentDuration, vMinUFVolume, vMaxUFVolume, vMinDialysateFlowRate, vMaxDialysateFlowRate) - frames = messageBuilder.toCandumpFormat(frames) + frames = toCandumpFormat(frames) for frame in frames: subprocess.call(['cansend', 'can0', '020#{}'.format(frame)]) waitForMessageToBeSent() -## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ def buildSetTreatmentBloodFlowRate(vFlowSetPt, vMeasFlow, vRotSpd, vMotSpd, vMCSpd, vMCCurr, vPWM): - msg = messageBuilder.buildMessage( GuiActionType.BloodFlow, 4 * 7, False, - utils.toI32(vFlowSetPt ), - utils.toF32(vMeasFlow ), - utils.toF32(vRotSpd ), - utils.toF32(vMotSpd ), - utils.toF32(vMCSpd ), - utils.toF32(vMCCurr ), - utils.toF32(vPWM ) + """ + + @param vFlowSetPt: + @param vMeasFlow: + @param vRotSpd: + @param vMotSpd: + @param vMCSpd: + @param vMCCurr: + @param vPWM: + @return: + """ + msg = buildMessage(GuiActionType.BloodFlow, 4 * 7, False, + toI32(vFlowSetPt ), + toF32(vMeasFlow ), + toF32(vRotSpd ), + toF32(vMotSpd ), + toF32(vMCSpd ), + toF32(vMCCurr ), + toF32(vPWM ) ) - return messageBuilder.toFrames(msg) -## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -def setTreatmentBloodFlowRate (vFlowSetPt, vMeasFlow, vRotSpd, vMotSpd, vMCSpd, vMCCurr, vPWM): + return toFrames(msg) + +def setTreatmentBloodFlowRate(vFlowSetPt, vMeasFlow, vRotSpd, vMotSpd, vMCSpd, vMCCurr, vPWM): + """ + + @param vFlowSetPt: + @param vMeasFlow: + @param vRotSpd: + @param vMotSpd: + @param vMCSpd: + @param vMCCurr: + @param vPWM: + @return: + """ frames = buildSetTreatmentBloodFlowRate(vFlowSetPt, vMeasFlow, vRotSpd, vMotSpd, vMCSpd, vMCCurr, vPWM) - frames = messageBuilder.toCandumpFormat(frames) + frames = toCandumpFormat(frames) for frame in frames: subprocess.call(['cansend', 'can0', '040#{}'.format(frame)]) waitForMessageToBeSent() -## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ def buildSetTreatmentDialysateFlowRate(vFlowSetPt, vMeasFlow, vRotSpd, vMotSpd, vMCSpd, vMCCurr, vPWM): - msg = messageBuilder.buildMessage( GuiActionType.DialysateInletFlow, 4 * 7, False, - utils.toI32(vFlowSetPt ), - utils.toF32(vMeasFlow ), - utils.toF32(vRotSpd ), - utils.toF32(vMotSpd ), - utils.toF32(vMCSpd ), - utils.toF32(vMCCurr ), - utils.toF32(vPWM ) + """ + + @param vFlowSetPt: + @param vMeasFlow: + @param vRotSpd: + @param vMotSpd: + @param vMCSpd: + @param vMCCurr: + @param vPWM: + @return: + """ + msg = buildMessage(GuiActionType.DialysateInletFlow, 4 * 7, False, + toI32(vFlowSetPt), + toF32(vMeasFlow), + toF32(vRotSpd), + toF32(vMotSpd), + toF32(vMCSpd), + toF32(vMCCurr), + toF32(vPWM) ) - return messageBuilder.toFrames(msg) -## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -def setTreatmentDialysateFlowRate (vFlowSetPt, vMeasFlow, vRotSpd, vMotSpd, vMCSpd, vMCCurr, vPWM): + return toFrames(msg) + +def setTreatmentDialysateFlowRate(vFlowSetPt, vMeasFlow, vRotSpd, vMotSpd, vMCSpd, vMCCurr, vPWM): + """ + + @param vFlowSetPt: + @param vMeasFlow: + @param vRotSpd: + @param vMotSpd: + @param vMCSpd: + @param vMCCurr: + @param vPWM: + @return: + """ frames = buildSetTreatmentDialysateFlowRate(vFlowSetPt, vMeasFlow, vRotSpd, vMotSpd, vMCSpd, vMCCurr, vPWM) - frames = messageBuilder.toCandumpFormat(frames) + frames = toCandumpFormat(frames) for frame in frames: subprocess.call(['cansend', 'can0', '040#{}'.format(frame)]) waitForMessageToBeSent() -## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ def buildTreatmentAdjustBloodDialysateResponse(vAccepted, vReason, vBloodRate, vDialysate): - msg = messageBuilder.buildMessage( GuiActionType.AdjustBloodDialysateRsp, 4 * 4, True, - utils.toI32(vAccepted), - utils.toI32(vReason), - utils.toI32(vBloodRate), - utils.toI32(vDialysate) + """ + + @param vAccepted: + @param vReason: + @param vBloodRate: + @param vDialysate: + @return: + """ + msg = buildMessage(GuiActionType.AdjustBloodDialysateRsp, 4 * 4, True, + toI32(vAccepted), + toI32(vReason), + toI32(vBloodRate), + toI32(vDialysate) ) - return messageBuilder.toFrames(msg) -## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -def sendTreatmentAdjustBloodDialysateResponse (vAccepted, vReason, vBloodRate, vDialysate): + return toFrames(msg) + +def sendTreatmentAdjustBloodDialysateResponse(vAccepted, vReason, vBloodRate, vDialysate): + """ + + @param vAccepted: + @param vReason: + @param vBloodRate: + @param vDialysate: + @return: + """ frames = buildTreatmentAdjustBloodDialysateResponse(vAccepted, vReason, vBloodRate, vDialysate) - frames = messageBuilder.toCandumpFormat(frames) + frames = toCandumpFormat(frames) for frame in frames: subprocess.call(['cansend', 'can0', '020#{}'.format(frame)]) waitForMessageToBeSent() - -## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + def buildTreatmentAdjustDurationResponse(vAccepted, vReason, vDuration, vUltrafiltration): - msg = messageBuilder.buildMessage( GuiActionType.AdjustDurationRsp, 4 * 4, True, - utils.toI32(vAccepted), - utils.toI32(vReason), - utils.toI32(vDuration), - utils.toF32(vUltrafiltration) + """ + + @param vAccepted: + @param vReason: + @param vDuration: + @param vUltrafiltration: + @return: + """ + msg = buildMessage(GuiActionType.AdjustDurationRsp, 4 * 4, True, + toI32(vAccepted), + toI32(vReason), + toI32(vDuration), + toF32(vUltrafiltration) ) - return messageBuilder.toFrames(msg) -## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -def sendTreatmentAdjustDurationResponse (vAccepted, vReason, vDuration, vUltrafiltration): + return toFrames(msg) + + +def sendTreatmentAdjustDurationResponse(vAccepted, vReason, vDuration, vUltrafiltration): + """ + + @param vAccepted: + @param vReason: + @param vDuration: + @param vUltrafiltration: + @return: + """ frames = buildTreatmentAdjustDurationResponse(vAccepted, vReason, vDuration, vUltrafiltration) - frames = messageBuilder.toCandumpFormat(frames) + frames = toCandumpFormat(frames) for frame in frames: subprocess.call(['cansend', 'can0', '020#{}'.format(frame)]) waitForMessageToBeSent() -## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ def buildTreatmentAdjustUltrafiltrationStateResponse(vState): - msg = messageBuilder.buildMessage( GuiActionType.AdjustUltrafiltrationStateReq, 1 * 4 , False, - utils.toI32(vState) + """ + + @param vState: + @return: + """ + msg = buildMessage(GuiActionType.AdjustUltrafiltrationStateReq, 1 * 4 , False, + toI32(vState) ) - return messageBuilder.toFrames(msg) -## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -def setTreatmentAdjustUltrafiltrationStateResponse(vState): + return toFrames(msg) + + +def setTreatmentAdjustUltrafiltrationStateResponse(vState): frames = buildTreatmentAdjustUltrafiltrationStateResponse(vState) - frames = messageBuilder.toCandumpFormat(frames) + frames = toCandumpFormat(frames) for frame in frames: subprocess.call(['cansend', 'can0', '020#{}'.format(frame)]) waitForMessageToBeSent() - -def setTreatmentAdjustUltrafiltrationAccepted(): + + +def setTreatmentAdjustUltrafiltrationAccepted(): setTreatmentAdjustUltrafiltrationStateResponse( EResponse.Accepted ) -def setTreatmentAdjustUltrafiltrationRejected(): + +def setTreatmentAdjustUltrafiltrationRejected(): setTreatmentAdjustUltrafiltrationStateResponse( EResponse.Rejected ) - -## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -# 19 0x020 6 Rsp Y HD UI UF Vol. Change Response (U32)-0=No, 1=Yes (U32) reject reason UF vol-mL (F32) Time-min (U32) Time diff (S32) UF rate-mL/min (F32) Rate diff (F32) -## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + def buildTreatmentAdjustUltrafiltrationEditResponse(vAccepted, vReason, vVolume, vDuration, vDurationDiff, vRate, vRateDiff, vRateOld): - msg = messageBuilder.buildMessage( GuiActionType.AdjustUltrafiltrationEditRsp, 8 * 4 , True, - utils.toI32(vAccepted ), - utils.toI32(vReason ), - utils.toF32(vVolume ), - utils.toI32(vDuration ), - utils.toI32(vDurationDiff), - utils.toF32(vRate ), - utils.toF32(vRateDiff ), - utils.toF32(vRateOld ) + """ + 19 0x020 6 Rsp Y HD UI UF Vol. Change Response (U32)-0=No, 1=Yes (U32) reject reason UF vol-mL (F32) Time-min (U32) Time diff (S32) UF rate-mL/min (F32) Rate diff (F32) + + @param vAccepted: + @param vReason: + @param vVolume: + @param vDuration: + @param vDurationDiff: + @param vRate: + @param vRateDiff: + @param vRateOld: + @return: + """ + msg = buildMessage(GuiActionType.AdjustUltrafiltrationEditRsp, 8 * 4 , True, + toI32(vAccepted ), + toI32(vReason ), + toF32(vVolume ), + toI32(vDuration ), + toI32(vDurationDiff), + toF32(vRate ), + toF32(vRateDiff ), + toF32(vRateOld ) ) - return messageBuilder.toFrames(msg) -## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -def setTreatmentAdjustUltrafiltrationEditResponse (vAccepted, vReason, vVolume, vDuration, vDurationDiff, vRate, vRateDiff, vRateOld): + return toFrames(msg) + +def setTreatmentAdjustUltrafiltrationEditResponse(vAccepted, vReason, vVolume, vDuration, vDurationDiff, vRate, vRateDiff, vRateOld): + """ + + @param vAccepted: + @param vReason: + @param vVolume: + @param vDuration: + @param vDurationDiff: + @param vRate: + @param vRateDiff: + @param vRateOld: + @return: + """ frames = buildTreatmentAdjustUltrafiltrationEditResponse(vAccepted, vReason, vVolume, vDuration, vDurationDiff, vRate, vRateDiff, vRateOld) - frames = messageBuilder.toCandumpFormat(frames) + frames = toCandumpFormat(frames) for frame in frames: subprocess.call(['cansend', 'can0', '020#{}'.format(frame)]) waitForMessageToBeSent() -def setTreatmentAdjustUltrafiltrationEditRejected ( vReason ): +def setTreatmentAdjustUltrafiltrationEditRejected(vReason): + """ + + @param vReason: + @return: + """ frames = buildTreatmentAdjustUltrafiltrationEditResponse(0, vReason, 0, 0, 0, 0, 0, 0) - frames = messageBuilder.toCandumpFormat(frames) + frames = toCandumpFormat(frames) for frame in frames: subprocess.call(['cansend', 'can0', '020#{}'.format(frame)]) waitForMessageToBeSent() -## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -# 46 0x020 6 Rsp Y HD UI UF Vol. Change Confirmation Response (U32)-0=No, 1=Yes (U32) reject reason UF vol-mL (F32) Time-min (U32) UF rate-mL/min (F32) -## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ def buildTreatmentAdjustUltrafiltrationConfirmResponse(vAccepted, vReason, vVolume, vDuration, vRate): - msg = messageBuilder.buildMessage( GuiActionType.AdjustUltrafiltrationConfirmRsp, 5 * 4 , True, - utils.toI32(vAccepted ), - utils.toI32(vReason ), - utils.toF32(vVolume ), - utils.toI32(vDuration ), - utils.toF32(vRate ) + """ + 46 0x020 6 Rsp Y HD UI UF Vol. Change Confirmation Response (U32)-0=No, 1=Yes (U32) reject reason UF vol-mL (F32) Time-min (U32) UF rate-mL/min (F32) + + @param vAccepted: + @param vReason: + @param vVolume: + @param vDuration: + @param vRate: + @return: + """ + msg = buildMessage(GuiActionType.AdjustUltrafiltrationConfirmRsp, 5 * 4 , True, + toI32(vAccepted ), + toI32(vReason ), + toF32(vVolume ), + toI32(vDuration ), + toF32(vRate ) ) - return messageBuilder.toFrames(msg) -## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -def setTreatmentAdjustUltrafiltrationConfirmResponse (vAccepted, vReason, vVolume, vDuration, vRate): + return toFrames(msg) + +def setTreatmentAdjustUltrafiltrationConfirmResponse (vAccepted, vReason, vVolume, vDuration, vRate): + """ + + @param vAccepted: + @param vReason: + @param vVolume: + @param vDuration: + @param vRate: + @return: + """ frames = buildTreatmentAdjustUltrafiltrationConfirmResponse(vAccepted, vReason, vVolume, vDuration, vRate) - frames = messageBuilder.toCandumpFormat(frames) + frames = toCandumpFormat(frames) for frame in frames: subprocess.call(['cansend', 'can0', '020#{}'.format(frame)]) waitForMessageToBeSent() -def setTreatmentAdjustUltrafiltrationConfirmRejected ( vReason ): +def setTreatmentAdjustUltrafiltrationConfirmRejected ( vReason ): + """ + + @param vReason: + @return: + """ frames = buildTreatmentAdjustUltrafiltrationConfirmResponse(0, vReason, 0, 0, 0) - frames = messageBuilder.toCandumpFormat(frames) + frames = toCandumpFormat(frames) for frame in frames: subprocess.call(['cansend', 'can0', '020#{}'.format(frame)]) waitForMessageToBeSent() -## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ def buildTreatmentTime(vSecsTotal, vSecsElap, vSecsRem): - msg = messageBuilder.buildMessage( GuiActionType.TreatmentTime, 3 * 4, False, - utils.toI32(vSecsTotal ), - utils.toI32(vSecsElap ), - utils.toI32(vSecsRem ) + """ + + @param vSecsTotal: + @param vSecsElap: + @param vSecsRem: + @return: + """ + msg = buildMessage(GuiActionType.TreatmentTime, 3 * 4, False, + toI32(vSecsTotal), + toI32(vSecsElap), + toI32(vSecsRem) ) - return messageBuilder.toFrames(msg) -## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -def setTreatmentTime (vSecsTotal, vSecsElap, vSecsRem = None): + return toFrames(msg) + +def setTreatmentTime(vSecsTotal, vSecsElap, vSecsRem = None): + """ + + @param vSecsTotal: + @param vSecsElap: + @param vSecsRem: + @return: + """ if vSecsRem == None: vSecsRem = vSecsTotal - vSecsElap frames = buildTreatmentTime(vSecsTotal, vSecsElap, vSecsRem) - frames = messageBuilder.toCandumpFormat(frames) + frames = toCandumpFormat(frames) for frame in frames: subprocess.call(['cansend', 'can0', '040#{}'.format(frame)]) waitForMessageToBeSent() -## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ def buildSetTreatmentUltrafiltration(vRefUFVol, vMeasUFVol, vRotSpd, vMotSpd, vMCSpd, vMCCurr, vPWM): - msg = messageBuilder.buildMessage( GuiActionType.DialysateOutletFlow, 4 * 7, False, - utils.toF32(vRefUFVol ), - utils.toF32(vMeasUFVol ), - utils.toF32(vRotSpd ), - utils.toF32(vMotSpd ), - utils.toF32(vMCSpd ), - utils.toF32(vMCCurr ), - utils.toF32(vPWM ) + """ + + @param vRefUFVol: + @param vMeasUFVol: + @param vRotSpd: + @param vMotSpd: + @param vMCSpd: + @param vMCCurr: + @param vPWM: + @return: + """ + msg = buildMessage(GuiActionType.DialysateOutletFlow, 4 * 7, False, + toF32(vRefUFVol), + toF32(vMeasUFVol), + toF32(vRotSpd), + toF32(vMotSpd), + toF32(vMCSpd), + toF32(vMCCurr), + toF32(vPWM) ) - return messageBuilder.toFrames(msg) -## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -def setTreatmentUltrafiltration (vRefUFVol, vMeasUFVol, vRotSpd, vMotSpd, vMCSpd, vMCCurr, vPWM): + return toFrames(msg) + +def setTreatmentUltrafiltration(vRefUFVol, vMeasUFVol, vRotSpd, vMotSpd, vMCSpd, vMCCurr, vPWM): + """ + + @param vRefUFVol: + @param vMeasUFVol: + @param vRotSpd: + @param vMotSpd: + @param vMCSpd: + @param vMCCurr: + @param vPWM: + @return: + """ frames = buildSetTreatmentUltrafiltration(vRefUFVol, vMeasUFVol, vRotSpd, vMotSpd, vMCSpd, vMCCurr, vPWM ) - frames = messageBuilder.toCandumpFormat(frames) + frames = toCandumpFormat(frames) for frame in frames: subprocess.call(['cansend', 'can0', '040#{}'.format(frame)]) waitForMessageToBeSent() -## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ def buildSetTreatmentPressureOcclusion(vArtPres, vVenPres, vBPOccl, vDIPOccl, vDOPOccl): - msg = messageBuilder.buildMessage( GuiActionType.PressureOcclusion, 4 * 5, False, - utils.toF32(vArtPres ), - utils.toF32(vVenPres ), - utils.toF32(vBPOccl ), - utils.toF32(vDIPOccl ), - utils.toF32(vDOPOccl ) + """ + + @param vArtPres: + @param vVenPres: + @param vBPOccl: + @param vDIPOccl: + @param vDOPOccl: + @return: + """ + msg = buildMessage(GuiActionType.PressureOcclusion, 4 * 5, False, + toF32(vArtPres), + toF32(vVenPres), + toF32(vBPOccl), + toF32(vDIPOccl), + toF32(vDOPOccl) ) - return messageBuilder.toFrames(msg) -## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -def setTreatmentPressureOcclusion (vArtPres, vVenPres, vBPOccl, vDIPOccl, vDOPOccl): + return toFrames(msg) + +def setTreatmentPressureOcclusion(vArtPres, vVenPres, vBPOccl, vDIPOccl, vDOPOccl): + """ + + @param vArtPres: + @param vVenPres: + @param vBPOccl: + @param vDIPOccl: + @param vDOPOccl: + @return: + """ frames = buildSetTreatmentPressureOcclusion(vArtPres, vVenPres, vBPOccl, vDIPOccl, vDOPOccl) - frames = messageBuilder.toCandumpFormat(frames) + frames = toCandumpFormat(frames) for frame in frames: subprocess.call(['cansend', 'can0', '040#{}'.format(frame)]) waitForMessageToBeSent() -## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -# 12 0x080 8 10 Hz N DG All Load Cell Readings Data Rs1 Prim. (F32) Rs1 Bkup (F32) Rs2 Prim. (F32) Rs2 Bkup (F32) -## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ def buildTreatmentLoadCellReadings(vRs1Prim, vRs1Bkup, vRs2Prim, vRs2Bkup): - msg = messageBuilder.buildMessage( GuiActionType.LoadCellReadings, 4 * 4, False, - utils.toF32(vRs1Prim), - utils.toF32(vRs1Bkup), - utils.toF32(vRs2Prim), - utils.toF32(vRs2Bkup) + """ + 12 0x080 8 10 Hz N DG All Load Cell Readings Data Rs1 Prim. (F32) Rs1 Bkup (F32) Rs2 Prim. (F32) Rs2 Bkup (F32) + + @param vRs1Prim: + @param vRs1Bkup: + @param vRs2Prim: + @param vRs2Bkup: + @return: + """ + msg = buildMessage(GuiActionType.LoadCellReadings, 4 * 4, False, + toF32(vRs1Prim), + toF32(vRs1Bkup), + toF32(vRs2Prim), + toF32(vRs2Bkup) ) - return messageBuilder.toFrames(msg) -## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + return toFrames(msg) + def setTreatmentLoadCellReadings (vRs1Prim, vRs1Bkup, vRs2Prim, vRs2Bkup): frames = buildTreatmentLoadCellReadings(vRs1Prim, vRs1Bkup, vRs2Prim, vRs2Bkup) - frames = messageBuilder.toCandumpFormat(frames) + frames = toCandumpFormat(frames) for frame in frames: subprocess.call(['cansend', 'can0', '080#{}'.format(frame)]) waitForMessageToBeSent() -## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -# 45 0x080 8 ??? Hz N DG All DG Temperature Data ??? -## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ def buildTreatmentTemperatureSensors(vInletPrimaryHeater, vOutletPrimaryHeater, vConductivitySensor1, vConductivitySensor2, vOutletRedundancy, vInletDialysate, vPrimaryHeaterThermoCouple, vPrimmerHeaterThermoCouple, vPrimaryHeaterColdJunction, vTrimmerHeaterColdJunction, vTrimaryHeaterInternal ,vTrimmerHeaterInternal): - msg = messageBuilder.buildMessage( GuiActionType.TemperatureSensors, 4 * 12, False, - utils.toF32(vInletPrimaryHeater ), - utils.toF32(vOutletPrimaryHeater ), - utils.toF32(vConductivitySensor1 ), - utils.toF32(vConductivitySensor2 ), - utils.toF32(vOutletRedundancy ), - utils.toF32(vInletDialysate ), - utils.toF32(vPrimaryHeaterThermoCouple), - utils.toF32(vPrimmerHeaterThermoCouple), - utils.toF32(vPrimaryHeaterColdJunction), - utils.toF32(vTrimmerHeaterColdJunction), - utils.toF32(vTrimaryHeaterInternal ), - utils.toF32(vTrimmerHeaterInternal ) + """ + 45 0x080 8 ??? Hz N DG All DG Temperature Data ??? + + @param vInletPrimaryHeater: + @param vOutletPrimaryHeater: + @param vConductivitySensor1: + @param vConductivitySensor2: + @param vOutletRedundancy: + @param vInletDialysate: + @param vPrimaryHeaterThermoCouple: + @param vPrimmerHeaterThermoCouple: + @param vPrimaryHeaterColdJunction: + @param vTrimmerHeaterColdJunction: + @param vTrimaryHeaterInternal: + @param vTrimmerHeaterInternal: + @return: + """ + + msg = buildMessage(GuiActionType.TemperatureSensors, 4 * 12, False, + toF32(vInletPrimaryHeater), + toF32(vOutletPrimaryHeater), + toF32(vConductivitySensor1), + toF32(vConductivitySensor2), + toF32(vOutletRedundancy), + toF32(vInletDialysate), + toF32(vPrimaryHeaterThermoCouple), + toF32(vPrimmerHeaterThermoCouple), + toF32(vPrimaryHeaterColdJunction), + toF32(vTrimmerHeaterColdJunction), + toF32(vTrimaryHeaterInternal), + toF32(vTrimmerHeaterInternal) ) - return messageBuilder.toFrames(msg) -## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -def setTreatmentTemperatureSensors (vInletPrimaryHeater, vOutletPrimaryHeater, vConductivitySensor1, vConductivitySensor2, vOutletRedundancy, vInletDialysate, vPrimaryHeaterThermoCouple, vPrimmerHeaterThermoCouple, vPrimaryHeaterColdJunction, vTrimmerHeaterColdJunction, vTrimaryHeaterInternal ,vTrimmerHeaterInternal): + return toFrames(msg) + +def setTreatmentTemperatureSensors(vInletPrimaryHeater, vOutletPrimaryHeater, vConductivitySensor1, vConductivitySensor2, vOutletRedundancy, vInletDialysate, vPrimaryHeaterThermoCouple, vPrimmerHeaterThermoCouple, vPrimaryHeaterColdJunction, vTrimmerHeaterColdJunction, vTrimaryHeaterInternal ,vTrimmerHeaterInternal): + """ + + @param vInletPrimaryHeater: + @param vOutletPrimaryHeater: + @param vConductivitySensor1: + @param vConductivitySensor2: + @param vOutletRedundancy: + @param vInletDialysate: + @param vPrimaryHeaterThermoCouple: + @param vPrimmerHeaterThermoCouple: + @param vPrimaryHeaterColdJunction: + @param vTrimmerHeaterColdJunction: + @param vTrimaryHeaterInternal: + @param vTrimmerHeaterInternal: + @return: + """ frames = buildTreatmentTemperatureSensors(vInletPrimaryHeater, vOutletPrimaryHeater, vConductivitySensor1, vConductivitySensor2, vOutletRedundancy, vInletDialysate, vPrimaryHeaterThermoCouple, vPrimmerHeaterThermoCouple, vPrimaryHeaterColdJunction, vTrimmerHeaterColdJunction, vTrimaryHeaterInternal ,vTrimmerHeaterInternal) - frames = messageBuilder.toCandumpFormat(frames) + frames = toCandumpFormat(frames) for frame in frames: subprocess.call(['cansend', 'can0', '080#{}'.format(frame)]) waitForMessageToBeSent() -## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ def buildCanBUSFaultCount(vCount): - msg = messageBuilder.buildMessage( GuiActionType.CanBUSFaultCount, 4 * 1, False, - utils.toI32(vCount) + """ + + @param vCount: + @return: + """ + msg = buildMessage(GuiActionType.CanBUSFaultCount, 4 * 1, False, + toI32(vCount) ) - return messageBuilder.toFrames(msg) -## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -def setCanBUSFaultCount (vCount): + return toFrames(msg) + +def setCanBUSFaultCount(vCount): + """ + + @param vCount: + @return: + """ frames = buildCanBUSFaultCount(vCount) - frames = messageBuilder.toCandumpFormat(frames) + frames = toCandumpFormat(frames) for frame in frames: subprocess.call(['cansend', 'can0', '020#{}'.format(frame)]) waitForMessageToBeSent() -## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ def buildAlarm(vState, vTop, vEsclatesIn, vSilentExpires, vFlags): - msg = messageBuilder.buildMessage( GuiActionType.AlarmStatus, 4 * 4 + 2, False, - utils.toI32(vState ), - utils.toI32(vTop ), - utils.toI32(vEsclatesIn ), - utils.toI32(vSilentExpires ), - utils.toI16(vFlags ) + """ + + @param vState: + @param vTop: + @param vEsclatesIn: + @param vSilentExpires: + @param vFlags: + @return: + """ + msg = buildMessage(GuiActionType.AlarmStatus, 4 * 4 + 2, False, + toI32(vState), + toI32(vTop), + toI32(vEsclatesIn), + toI32(vSilentExpires), + toI16(vFlags) ) - return messageBuilder.toFrames(msg) -## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + return toFrames(msg) + + def sendAlarm(vState, vTop, vEsclatesIn, vSilentExpires, vFlags): frames = buildAlarm(vState, vTop, vEsclatesIn, vSilentExpires, vFlags) - frames = messageBuilder.toCandumpFormat(frames) + frames = toCandumpFormat(frames) for frame in frames: subprocess.call(['cansend', 'can0', '001#{}'.format(frame)]) waitForMessageToBeSent() -## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + def buildAlarmTriggered(vAlarmID): - msg = messageBuilder.buildMessage( GuiActionType.AlarmTriggered, 4 , True, - utils.toI16 (vAlarmID) + """ + + @param vAlarmID: + @return: + """ + msg = buildMessage(GuiActionType.AlarmTriggered, 4 , True, + toI16(vAlarmID) ) - return messageBuilder.toFrames(msg) -## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + return toFrames(msg) + + def setAlarmTriggered(vAlarmID): + """ + + @param vAlarmID: + @return: + """ frames = buildAlarmTriggered(vAlarmID) - frames = messageBuilder.toCandumpFormat(frames) + frames = toCandumpFormat(frames) for frame in frames: subprocess.call(['cansend', 'can0', '001#{}'.format(frame)]) waitForMessageToBeSent() -## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + def buildAlarmCleared(vAlarmID): - msg = messageBuilder.buildMessage( GuiActionType.AlarmCleared, 4 , True, - utils.toI32(vAlarmID) + """ + + @param vAlarmID: + @return: + """ + msg = buildMessage(GuiActionType.AlarmCleared, 4 , True, + toI32(vAlarmID) ) - return messageBuilder.toFrames(msg) -## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + return toFrames(msg) + + def setAlarmCleared(vAlarmID): + """ + + @param vAlarmID: + @return: + """ frames = buildAlarmCleared(vAlarmID) - frames = messageBuilder.toCandumpFormat(frames) + frames = toCandumpFormat(frames) for frame in frames: subprocess.call(['cansend', 'can0', '001#{}'.format(frame)]) waitForMessageToBeSent() -## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + def buildUnknown(): - msg = messageBuilder.buildMessage( GuiActionType.Unknown, 0 , False) - return messageBuilder.toFrames(msg) -## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + """ + + @return: + """ + msg = buildMessage(GuiActionType.Unknown, 0, False) + return toFrames(msg) + + def sendUnknown_HD(): + """ + + @return: None + """ frames = buildUnknown() - frames = messageBuilder.toCandumpFormat(frames) + frames = toCandumpFormat(frames) for frame in frames: subprocess.call(['cansend', 'can0', '001#{}'.format(frame)]) # send from HD waitForMessageToBeSent() -## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + def sendUnknown_DG(): + """ + + @return: None + """ frames = buildUnknown() - frames = messageBuilder.toCandumpFormat(frames) + frames = toCandumpFormat(frames) for frame in frames: subprocess.call(['cansend', 'can0', '070#{}'.format(frame)]) # send from DG waitForMessageToBeSent() + def clear_all_alarms(): + """ + @return: None + """ sendAlarm(0, 0, 0, 0, 0) Index: dialin/squish/messageBuilder.py =================================================================== diff -u -r11074441e3cf2a05a9b8c55c6a7c9c21bc5fb5a3 -re6e9d40940a3ce8b012b13be4fe65fea5b0a5168 --- dialin/squish/messageBuilder.py (.../messageBuilder.py) (revision 11074441e3cf2a05a9b8c55c6a7c9c21bc5fb5a3) +++ dialin/squish/messageBuilder.py (.../messageBuilder.py) (revision e6e9d40940a3ce8b012b13be4fe65fea5b0a5168) @@ -12,45 +12,65 @@ # author Behrouz NematiPour # -import utils -import crc +from .utils import partition, padding, toI16, toI08 +from .crc import calcCRC8 syncByte = 'A5' -## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ def toCandumpFormat(vMsg): + """ + + @param vMsg: + @return: + """ if type(vMsg) == list: for index, value in enumerate(vMsg): - vMsg[index] = ".".join(utils.partition(value, 2, False)) + vMsg[index] = ".".join(partition(value, 2, False)) else: - vMsg = ".".join(utils.partition(vMsg, 2, False)) + vMsg = ".".join(partition(vMsg, 2, False)) return vMsg -## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ def toFrames(vMsg): + """ + + @param vMsg: + @return: + """ mLen = 16 - padded = utils.padding(vMsg, mLen) - frames = utils.partition(padded, mLen, False) + padded = padding(vMsg, mLen) + frames = partition(padded, mLen, False) return frames -## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ def addCRC8(vString, vDelimiter = ""): - return vString + vDelimiter + crc.calcCRC8(vString, vDelimiter) + """ -## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + @param vString: + @param vDelimiter: + @return: + """ + return vString + vDelimiter + calcCRC8(vString, vDelimiter) + def buildMessage(vMsgID, vLen, vAck, *vArgs): - msg = "" + """ + + @param vMsgID: + @param vLen: + @param vAck: + @param vArgs: + @return: + """ + msg = "" if vAck: seq = -1 else: seq = 1 - msg += utils.toI16(seq) # always used seq# (-)1 (for now) - msg += utils.toI16(vMsgID) - msg += utils.toI08(vLen) + msg += toI16(seq) # always used seq# (-)1 (for now) + msg += toI16(vMsgID) + msg += toI08(vLen) for arg in vArgs: msg += arg - msg += crc.calcCRC8(msg) + msg += calcCRC8(msg) return syncByte + msg Index: dialin/squish/unittests.py =================================================================== diff -u -r11074441e3cf2a05a9b8c55c6a7c9c21bc5fb5a3 -re6e9d40940a3ce8b012b13be4fe65fea5b0a5168 --- dialin/squish/unittests.py (.../unittests.py) (revision 11074441e3cf2a05a9b8c55c6a7c9c21bc5fb5a3) +++ dialin/squish/unittests.py (.../unittests.py) (revision e6e9d40940a3ce8b012b13be4fe65fea5b0a5168) @@ -13,14 +13,14 @@ # import test import sys -import crc +from .crc import calcCRC8 -def testPythonVersion(): +def test_python_version(): test.compare(sys.version_info.major,3) test.compare(sys.version_info.minor,6) - test.compare(sys.version_info.micro,4) + test.compare(sys.version_info.micro,8) -def testcrc8(): +def test_crc8(): strByte1 = ( "4B 43 09 00 14 00 00" "00 00 00 00 00 00 00 00" "00 00 00 00 00 00 00 00" @@ -43,7 +43,7 @@ "00 00" #7F ) - test.compare(crc.calcCRC8(strByte1, ' '), '9D') - test.compare(crc.calcCRC8(strByte2, ' '), '55') - test.compare(crc.calcCRC8(strByte3, ' '), '4F') - test.compare(crc.calcCRC8(strByte4, ' '), '7F') + test.compare(calcCRC8(strByte1, ' '), '9D') + test.compare(calcCRC8(strByte2, ' '), '55') + test.compare(calcCRC8(strByte3, ' '), '4F') + test.compare(calcCRC8(strByte4, ' '), '7F') Index: dialin/squish/utils.py =================================================================== diff -u -r11074441e3cf2a05a9b8c55c6a7c9c21bc5fb5a3 -re6e9d40940a3ce8b012b13be4fe65fea5b0a5168 --- dialin/squish/utils.py (.../utils.py) (revision 11074441e3cf2a05a9b8c55c6a7c9c21bc5fb5a3) +++ dialin/squish/utils.py (.../utils.py) (revision e6e9d40940a3ce8b012b13be4fe65fea5b0a5168) @@ -14,54 +14,116 @@ import time import struct -import inspect -#from pathlib import PurePath -## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + def waitForGUI(vDelay = 2): + """ + + @param vDelay: + @return: + """ time.sleep(vDelay) -## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + def toUXX(vValue, vByteCount, vDelimiter): + """ + + @param vValue: + @param vByteCount: + @param vDelimiter: + @return: + """ x = '{0:0{1}X}'.format(int(vValue) & (2**(4*vByteCount)-1), vByteCount, 'x') bytes = partition(x, 2) return vDelimiter.join(bytes) -## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + def toI32(vValue, vDelimiter = ""): + """ + + @param vValue: + @param vDelimiter: + @return: + """ return toUXX(vValue, 8, vDelimiter) -## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + def toI16(vValue, vDelimiter = ""): + """ + + @param vValue: + @param vDelimiter: + @return: + """ return toUXX(vValue, 4, vDelimiter) -## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + def toI08(vValue, vDelimiter = ""): + """ + + @param vValue: + @param vDelimiter: + @return: + """ return toUXX(vValue, 2, vDelimiter) -## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + def toF32(vValue): + """ + + @param vValue: + @return: + """ return '{:08X}'.format(struct.unpack('f', vValue))[0],'X') -## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ def partition(vString, vPart, vRightDirection=True): + """ + + @param vString: + @param vPart: + @param vRightDirection: + @return: + """ return [vString[i: i + vPart] for i in range(0, len(vString), vPart)][::-1 if vRightDirection else 1] -## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ def padding(vString, vLen): + """ + + @param vString: + @param vLen: + @return: + """ lStr = len(vString) lPad = int(lStr / vLen) * vLen + ( vLen * (1 if lStr % vLen else 0) ) return vString.ljust(lPad, "0") -## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ def tstStart(): - print(time.strftime("%H:%M:%S Start", time.localtime())) #, PurePath(inspect.stack()[1][1]).parts[-2]) + """ + @return: + """ + print(time.strftime("%H:%M:%S Start", time.localtime())) + def tstDone(): - print(time.strftime("%H:%M:%S Done ", time.localtime())) #, PurePath(inspect.stack()[1][1]).parts[-2]) + """ + @return: + """ + print(time.strftime("%H:%M:%S Done ", time.localtime())) + def l2ml(vValue): + """ + + @param vValue: + @return: + """ return int(round (vValue, 3) * 1000) def ml2l(vValue): + """ + + @param vValue: + @return: + """ return vValue / 1000 Index: tests/test_imports.py =================================================================== diff -u -ra38adf9aa031c52a18f21b74f91b42bbbfafb794 -re6e9d40940a3ce8b012b13be4fe65fea5b0a5168 --- tests/test_imports.py (.../test_imports.py) (revision a38adf9aa031c52a18f21b74f91b42bbbfafb794) +++ tests/test_imports.py (.../test_imports.py) (revision e6e9d40940a3ce8b012b13be4fe65fea5b0a5168) @@ -66,6 +66,17 @@ 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 --- tools/install_to_venv.sh (revision 0) +++ tools/install_to_venv.sh (revision e6e9d40940a3ce8b012b13be4fe65fea5b0a5168) @@ -0,0 +1,16 @@ +#!/bin/bash + +cd ../ +./build.sh +repo="$HOME/Project/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 +cd $repo +venv=$repo +venv+="venv" +read -p "Enter the path to the repository's virtualenv directory: " -e -i "$venv" venv +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