Index: dialin/squish/denaliMessages.py =================================================================== diff -u -r4bdb012848d1b59be5edc31d677b77b9d95f6190 -r511f8ce9d68e437c7812f9d79324719803dfafc9 --- dialin/squish/denaliMessages.py (.../denaliMessages.py) (revision 4bdb012848d1b59be5edc31d677b77b9d95f6190) +++ dialin/squish/denaliMessages.py (.../denaliMessages.py) (revision 511f8ce9d68e437c7812f9d79324719803dfafc9) @@ -52,11 +52,17 @@ AlarmCleared = 4 PressureOcclusion = 9 + + DGDrainPumpData = 36 + DGHeatersData = 44 LoadCellReadings = 12 + DGPressuresData = 32 TemperatureSensors = 45 + CanBUSFaultCount = 2457 + HDDebugText = 0xFFF1 + DGDebugText = 0xFFF2 - AdjustBloodDialysateReq = 23 AdjustBloodDialysateRsp = 24 @@ -103,58 +109,62 @@ # it seems it's needed otherwise the test will check a value which has not been received yet. # ################################################################################################## def waitForMessageToBeSent(): - time.sleep(0.200) # 200ms + time.sleep(0.050) # 50ms -def buildSetTreatmentParamRanges(vMinTreatmentDuration, vMaxTreatmentDuration, vMinUFVolume, vMaxUFVolume, vMinDialysateFlowRate, vMaxDialysateFlowRate): - """ +## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +def buildHDDebugText(vText): + len = 40 + txt = textToByte(vText, len) # + 1 null term + msg = buildMessage( GuiActionType.HDDebugText, 1 * (len + 1), False, txt) + return toFrames(msg) +## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +def setHDDebugText (vText): + frames = buildHDDebugText(vText) + frames = toCandumpFormat(frames) + for frame in frames: + subprocess.call(['cansend', 'can0', '020#{}'.format(frame)]) + waitForMessageToBeSent() - @param vMinTreatmentDuration: - @param vMaxTreatmentDuration: - @param vMinUFVolume: - @param vMaxUFVolume: - @param vMinDialysateFlowRate: - @param vMaxDialysateFlowRate: - @return: - """ +## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +def buildDGDebugText(vText): + len = 40 + txt = textToByte(vText, len) # + 1 null term + msg = buildMessage( GuiActionType.DGDebugText, 1 * (len + 1), False, txt) + + return toFrames(msg) +## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +def setDGDebugText (vText): + frames = buildDGDebugText(vText) + frames = toCandumpFormat(frames) + for frame in frames: + subprocess.call(['cansend', 'can0', '070#{}'.format(frame)]) + waitForMessageToBeSent() + +## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +def buildSetTreatmentParamRanges(vMinTreatmentDuration, vMaxTreatmentDuration, vMinUFVolume, vMaxUFVolume, vMinDialysateFlowRate, vMaxDialysateFlowRate): msg = buildMessage(GuiActionType.TreatmentRanges, 4 * 6, True, toI32(vMinTreatmentDuration), toI32(vMaxTreatmentDuration), - toF32(vMinUFVolume), - toF32(vMaxUFVolume), + toF32(vMinUFVolume ), + toF32(vMaxUFVolume ), toI32(vMinDialysateFlowRate), toI32(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: - """ +def setTreatmentParamRanges(vMinTreatmentDuration, vMaxTreatmentDuration, vMinUFVolume, vMaxUFVolume, vMinDialysateFlowRate, vMaxDialysateFlowRate): frames = buildSetTreatmentParamRanges(vMinTreatmentDuration, vMaxTreatmentDuration, vMinUFVolume, vMaxUFVolume, vMinDialysateFlowRate, vMaxDialysateFlowRate) frames = toCandumpFormat(frames) for frame in frames: subprocess.call(['cansend', 'can0', '020#{}'.format(frame)]) waitForMessageToBeSent() -def buildSetTreatmentBloodFlowRate(vFlowSetPt, vMeasFlow, vRotSpd, vMotSpd, vMCSpd, vMCCurr, vPWM): - """ - @param vFlowSetPt: - @param vMeasFlow: - @param vRotSpd: - @param vMotSpd: - @param vMCSpd: - @param vMCCurr: - @param vPWM: - @return: - """ +def buildSetTreatmentBloodFlowRate(vFlowSetPt, vMeasFlow, vRotSpd, vMotSpd, vMCSpd, vMCCurr, vPWM): msg = buildMessage(GuiActionType.BloodFlow, 4 * 7, False, toI32(vFlowSetPt ), toF32(vMeasFlow ), @@ -166,36 +176,16 @@ ) 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: - """ +def setTreatmentBloodFlowRate(vFlowSetPt, vMeasFlow, vRotSpd, vMotSpd, vMCSpd, vMCCurr, vPWM): frames = buildSetTreatmentBloodFlowRate(vFlowSetPt, vMeasFlow, vRotSpd, vMotSpd, vMCSpd, vMCCurr, vPWM) frames = toCandumpFormat(frames) for frame in frames: subprocess.call(['cansend', 'can0', '040#{}'.format(frame)]) waitForMessageToBeSent() -def buildSetTreatmentDialysateFlowRate(vFlowSetPt, vMeasFlow, vRotSpd, vMotSpd, vMCSpd, vMCCurr, vPWM): - """ - @param vFlowSetPt: - @param vMeasFlow: - @param vRotSpd: - @param vMotSpd: - @param vMCSpd: - @param vMCCurr: - @param vPWM: - @return: - """ +def buildSetTreatmentDialysateFlowRate(vFlowSetPt, vMeasFlow, vRotSpd, vMotSpd, vMCSpd, vMCCurr, vPWM): msg = buildMessage(GuiActionType.DialysateInletFlow, 4 * 7, False, toI32(vFlowSetPt), toF32(vMeasFlow), @@ -207,33 +197,16 @@ ) 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: - """ +def setTreatmentDialysateFlowRate(vFlowSetPt, vMeasFlow, vRotSpd, vMotSpd, vMCSpd, vMCCurr, vPWM): frames = buildSetTreatmentDialysateFlowRate(vFlowSetPt, vMeasFlow, vRotSpd, vMotSpd, vMCSpd, vMCCurr, vPWM) frames = toCandumpFormat(frames) for frame in frames: subprocess.call(['cansend', 'can0', '040#{}'.format(frame)]) waitForMessageToBeSent() + def buildTreatmentAdjustBloodDialysateResponse(vAccepted, vReason, vBloodRate, vDialysate): - """ - - @param vAccepted: - @param vReason: - @param vBloodRate: - @param vDialysate: - @return: - """ msg = buildMessage(GuiActionType.AdjustBloodDialysateRsp, 4 * 4, True, toI32(vAccepted), toI32(vReason), @@ -242,15 +215,8 @@ ) return toFrames(msg) -def sendTreatmentAdjustBloodDialysateResponse(vAccepted, vReason, vBloodRate, vDialysate): - """ - @param vAccepted: - @param vReason: - @param vBloodRate: - @param vDialysate: - @return: - """ +def sendTreatmentAdjustBloodDialysateResponse(vAccepted, vReason, vBloodRate, vDialysate): frames = buildTreatmentAdjustBloodDialysateResponse(vAccepted, vReason, vBloodRate, vDialysate) frames = toCandumpFormat(frames) for frame in frames: @@ -259,14 +225,6 @@ def buildTreatmentAdjustDurationResponse(vAccepted, vReason, vDuration, vUltrafiltration): - """ - - @param vAccepted: - @param vReason: - @param vDuration: - @param vUltrafiltration: - @return: - """ msg = buildMessage(GuiActionType.AdjustDurationRsp, 4 * 4, True, toI32(vAccepted), toI32(vReason), @@ -277,26 +235,14 @@ def sendTreatmentAdjustDurationResponse(vAccepted, vReason, vDuration, vUltrafiltration): - """ - - @param vAccepted: - @param vReason: - @param vDuration: - @param vUltrafiltration: - @return: - """ frames = buildTreatmentAdjustDurationResponse(vAccepted, vReason, vDuration, vUltrafiltration) frames = toCandumpFormat(frames) for frame in frames: subprocess.call(['cansend', 'can0', '020#{}'.format(frame)]) waitForMessageToBeSent() -def buildTreatmentAdjustUltrafiltrationStateResponse(vState): - """ - @param vState: - @return: - """ +def buildTreatmentAdjustUltrafiltrationStateResponse(vState): msg = buildMessage(GuiActionType.AdjustUltrafiltrationStateReq, 1 * 4 , False, toI32(vState) ) @@ -320,19 +266,6 @@ def buildTreatmentAdjustUltrafiltrationEditResponse(vAccepted, vReason, vVolume, vDuration, vDurationDiff, vRate, vRateDiff, 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), @@ -345,48 +278,24 @@ ) 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: - """ +def setTreatmentAdjustUltrafiltrationEditResponse(vAccepted, vReason, vVolume, vDuration, vDurationDiff, vRate, vRateDiff, vRateOld): frames = buildTreatmentAdjustUltrafiltrationEditResponse(vAccepted, vReason, vVolume, vDuration, vDurationDiff, vRate, vRateDiff, vRateOld) frames = toCandumpFormat(frames) for frame in frames: subprocess.call(['cansend', 'can0', '020#{}'.format(frame)]) waitForMessageToBeSent() -def setTreatmentAdjustUltrafiltrationEditRejected(vReason): - """ - @param vReason: - @return: - """ +def setTreatmentAdjustUltrafiltrationEditRejected(vReason): frames = buildTreatmentAdjustUltrafiltrationEditResponse(0, vReason, 0, 0, 0, 0, 0, 0) frames = toCandumpFormat(frames) for frame in frames: subprocess.call(['cansend', 'can0', '020#{}'.format(frame)]) waitForMessageToBeSent() -def buildTreatmentAdjustUltrafiltrationConfirmResponse(vAccepted, vReason, vVolume, vDuration, 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: - """ +def buildTreatmentAdjustUltrafiltrationConfirmResponse(vAccepted, vReason, vVolume, vDuration, vRate): msg = buildMessage(GuiActionType.AdjustUltrafiltrationConfirmRsp, 5 * 4 , True, toI32(vAccepted), toI32(vReason), @@ -396,77 +305,43 @@ ) return toFrames(msg) -def setTreatmentAdjustUltrafiltrationConfirmResponse (vAccepted, vReason, vVolume, vDuration, vRate): - """ - @param vAccepted: - @param vReason: - @param vVolume: - @param vDuration: - @param vRate: - @return: - """ +def setTreatmentAdjustUltrafiltrationConfirmResponse (vAccepted, vReason, vVolume, vDuration, vRate): frames = buildTreatmentAdjustUltrafiltrationConfirmResponse(vAccepted, vReason, vVolume, vDuration, vRate) frames = toCandumpFormat(frames) for frame in frames: subprocess.call(['cansend', 'can0', '020#{}'.format(frame)]) waitForMessageToBeSent() -def setTreatmentAdjustUltrafiltrationConfirmRejected ( vReason ): - """ - @param vReason: - @return: - """ +def setTreatmentAdjustUltrafiltrationConfirmRejected ( vReason ): frames = buildTreatmentAdjustUltrafiltrationConfirmResponse(0, vReason, 0, 0, 0) frames = toCandumpFormat(frames) for frame in frames: subprocess.call(['cansend', 'can0', '020#{}'.format(frame)]) waitForMessageToBeSent() -def buildTreatmentTime(vSecsTotal, vSecsElap, vSecsRem): - """ - @param vSecsTotal: - @param vSecsElap: - @param vSecsRem: - @return: - """ +def buildTreatmentTime(vSecsTotal, vSecsElap, vSecsRem): msg = buildMessage(GuiActionType.TreatmentTime, 3 * 4, False, toI32(vSecsTotal), toI32(vSecsElap), toI32(vSecsRem) ) return toFrames(msg) -def setTreatmentTime(vSecsTotal, vSecsElap, vSecsRem = None): - """ - @param vSecsTotal: - @param vSecsElap: - @param vSecsRem: - @return: - """ +def setTreatmentTime(vSecsTotal, vSecsElap, vSecsRem = None): if vSecsRem == None: vSecsRem = vSecsTotal - vSecsElap frames = buildTreatmentTime(vSecsTotal, vSecsElap, vSecsRem) frames = toCandumpFormat(frames) for frame in frames: subprocess.call(['cansend', 'can0', '040#{}'.format(frame)]) waitForMessageToBeSent() + def buildSetTreatmentUltrafiltration(vRefUFVol, vMeasUFVol, vRotSpd, vMotSpd, vMCSpd, vMCCurr, 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), @@ -478,175 +353,279 @@ ) 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: - """ +def setTreatmentUltrafiltration(vRefUFVol, vMeasUFVol, vRotSpd, vMotSpd, vMCSpd, vMCCurr, vPWM): frames = buildSetTreatmentUltrafiltration(vRefUFVol, vMeasUFVol, vRotSpd, vMotSpd, vMCSpd, vMCCurr, vPWM ) frames = toCandumpFormat(frames) for frame in frames: subprocess.call(['cansend', 'can0', '040#{}'.format(frame)]) waitForMessageToBeSent() - -def buildSetTreatmentPressureOcclusion(vArtPres, vVenPres, vBPOccl, vDIPOccl, 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) - ) + +## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +## 0x0009,040,N,HD,All,PressureOcclusionData,(F32)^ArterialPressure,(F32)^VenousPressure,(F32)^BloodPumpOcclusion,(F32)^DialysateInletPumpOcclusion,(F32)^DialysateOutletPumpOcclusion +## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +def buildPressureOcclusionData(vArterialPressure, vVenousPressure, vBloodPumpOcclusion, vDialysateInletPumpOcclusion, vDialysateOutletPumpOcclusion): + msg = buildMessage( 0x0009, 4+4+4+4+4, False, + toF32(vArterialPressure ), + toF32(vVenousPressure ), + toF32(vBloodPumpOcclusion ), + toF32(vDialysateInletPumpOcclusion ), + toF32(vDialysateOutletPumpOcclusion)) 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) +## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +def setPressureOcclusionData (vArterialPressure, vVenousPressure, vBloodPumpOcclusion, vDialysateInletPumpOcclusion, vDialysateOutletPumpOcclusion): + frames = buildPressureOcclusionData(vArterialPressure, vVenousPressure, vBloodPumpOcclusion, vDialysateInletPumpOcclusion, vDialysateOutletPumpOcclusion) frames = toCandumpFormat(frames) for frame in frames: subprocess.call(['cansend', 'can0', '040#{}'.format(frame)]) waitForMessageToBeSent() + -def buildTreatmentLoadCellReadings(vRs1Prim, vRs1Bkup, vRs2Prim, 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) +## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +## 0x001F,080,N,DG,All,DGROPumpData,(U32)^SetPtPressure,(F32)^FlowRate,(F32)^PWM +## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +def buildDGROPumpData(vSetPtPressure, vFlowRate, vPWM): + msg = buildMessage( 0x001F, 4+4+4, False, + toI32(vSetPtPressure), + toF32(vFlowRate ), + toF32(vPWM )) + return toFrames(msg) - @param vRs1Prim: - @param vRs1Bkup: - @param vRs2Prim: - @param vRs2Bkup: - @return: - """ - msg = buildMessage(GuiActionType.LoadCellReadings, 4 * 4, False, + +## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +def setDGROPumpData(vSetPtPressure, vFlowRate, vPWM): + frames = buildDGROPumpData(vSetPtPressure, vFlowRate, vPWM) + frames = toCandumpFormat(frames) + for frame in frames: + subprocess.call(['cansend', 'can0', '080#{}'.format(frame)]) + waitForMessageToBeSent() + + +## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +## 0x0020,080,N,DG,All,DGPressuresData,(F32)^ROInletPSI,(F32)^ROOutletPSI,(F32)^DrainInletPSI,(F32)^DrainOutletPSI +## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +def buildDGPressuresData(vROInletPSI, vROOutletPSI, vDrainInletPSI, vDrainOutletPSI): + msg = buildMessage( 0x0020, 4+4+4+4, False, + toF32(vROInletPSI ), + toF32(vROOutletPSI ), + toF32(vDrainInletPSI ), + toF32(vDrainOutletPSI)) + return toFrames(msg) + + +## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +def setDGPressuresData(vROInletPSI, vROOutletPSI, vDrainInletPSI, vDrainOutletPSI): + frames = buildDGPressuresData(vROInletPSI, vROOutletPSI, vDrainInletPSI, vDrainOutletPSI) + frames = toCandumpFormat(frames) + for frame in frames: + subprocess.call(['cansend', 'can0', '080#{}'.format(frame)]) + waitForMessageToBeSent() + + +## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +## 0x0024,080,N,DG,All,DGDrainPumpData,(U32)^SetPtRPM,(U32)^DACValue +## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +def buildDGDrainPumpData(vSetPtRPM, vDACValue): + msg = buildMessage( 0x0024, 4+4, False, + toI32(vSetPtRPM), + toI32(vDACValue)) + return toFrames(msg) + + +## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +def setDGDrainPumpData(vSetPtRPM, vDACValue): + frames = buildDGDrainPumpData(vSetPtRPM, vDACValue) + frames = toCandumpFormat(frames) + for frame in frames: + subprocess.call(['cansend', 'can0', '080#{}'.format(frame)]) + waitForMessageToBeSent() + + +## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +## 0x0027,080,N,DG,All,DGOperationMode,(U32)^DGOpMode +## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +def buildDGOperationMode(vDGOpMode): + msg = buildMessage( 0x0027, 4, False, + toI32(vDGOpMode)) + return toFrames(msg) + + +## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +def setDGOperationMode(vDGOpMode): + frames = buildDGOperationMode(vDGOpMode) + frames = toCandumpFormat(frames) + for frame in frames: + subprocess.call(['cansend', 'can0', '080#{}'.format(frame)]) + waitForMessageToBeSent() + + +## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +## 0x0028,080,N,DG,All,DGReservoirData,(U32)^ActiveReservoir,(U32)^FillToVolML,(U32)^DrainToVolML +## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +def buildDGReservoirData(vActiveReservoir, vFillToVolML, vDrainToVolML): + msg = buildMessage( 0x0028, 4+4+4, False, + toI32(vActiveReservoir), + toI32(vFillToVolML ), + toI32(vDrainToVolML )) + return toFrames(msg) + + +## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +def setDGReservoirData(vActiveReservoir, vFillToVolML, vDrainToVolML): + frames = buildDGReservoirData(vActiveReservoir, vFillToVolML, vDrainToVolML) + frames = toCandumpFormat(frames) + for frame in frames: + subprocess.call(['cansend', 'can0', '080#{}'.format(frame)]) + waitForMessageToBeSent() + + +## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +## 0x002A,080,N,DG,All,DGValvesStates,(U16)^ValvesStates +## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +def buildDGValvesStates(vValvesStates): + msg = buildMessage( 0x002A, 2, False, + toI16(vValvesStates)) + return toFrames(msg) + + +## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +def setDGValvesStates(vValvesStates): + frames = buildDGValvesStates(vValvesStates) + frames = toCandumpFormat(frames) + for frame in frames: + subprocess.call(['cansend', 'can0', '080#{}'.format(frame)]) + waitForMessageToBeSent() + + +## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +## 0x002C,080,N,DG,All,DGHeatersData,(U32)^MainPriMaryDC,(U32)^SmallPrimaryDC,(U32)^TrimmerDC +## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +def buildDGHeatersData(vMainPriMaryDC, vSmallPrimaryDC, vTrimmerDC): + msg = buildMessage( 0x002C, 4+4+4, False, + toI32(vMainPriMaryDC ), + toI32(vSmallPrimaryDC), + toI32(vTrimmerDC )) + return toFrames(msg) + + +## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +def setDGHeatersData(vMainPriMaryDC, vSmallPrimaryDC, vTrimmerDC): + frames = buildDGHeatersData(vMainPriMaryDC, vSmallPrimaryDC, vTrimmerDC) + frames = toCandumpFormat(frames) + for frame in frames: + subprocess.call(['cansend', 'can0', '080#{}'.format(frame)]) + waitForMessageToBeSent() + + +## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +## 0x000C,080,N,DG,All,DGLoadCellReadingsData,(F32)^Rs1Prim,(F32)^Rs1Bkup,(F32)^Rs2Prim,(F32)^Rs2Bkup +## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +def buildDGLoadCellReadingsData(vRs1Prim, vRs1Bkup, vRs2Prim, vRs2Bkup): + msg = buildMessage( 0x000C, 4+4+4+4, False, toF32(vRs1Prim), toF32(vRs1Bkup), toF32(vRs2Prim), - toF32(vRs2Bkup) - ) + toF32(vRs2Bkup)) return toFrames(msg) -def setTreatmentLoadCellReadings (vRs1Prim, vRs1Bkup, vRs2Prim, vRs2Bkup): - frames = buildTreatmentLoadCellReadings(vRs1Prim, vRs1Bkup, vRs2Prim, vRs2Bkup) + +## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +def setDGLoadCellReadingsData(vRs1Prim, vRs1Bkup, vRs2Prim, vRs2Bkup): + frames = buildDGLoadCellReadingsData(vRs1Prim, vRs1Bkup, vRs2Prim, vRs2Bkup) frames = toCandumpFormat(frames) for frame in frames: subprocess.call(['cansend', 'can0', '080#{}'.format(frame)]) waitForMessageToBeSent() -def buildTreatmentTemperatureSensors(vInletPrimaryHeater, vOutletPrimaryHeater, vConductivitySensor1, vConductivitySensor2, vOutletRedundancy, vInletDialysate, vPrimaryHeaterThermoCouple, vPrimmerHeaterThermoCouple, vPrimaryHeaterColdJunction, vTrimmerHeaterColdJunction, vTrimaryHeaterInternal ,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) - ) +## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +## 0x002D,080,N,DG,All,DGTemperaturesData,(F32)^InletPrimaryHeater,(F32)^OutletPrimaryHeater,(F32)^ConductivitySensor1,(F32)^ConductivitySensor2,(F32)^OutletRedundancy,(F32)^InletDialysate,(F32)^PrimaryHeaterThermocouple,(F32)^TrimmerHeaterThermocouple,(F32)^PrimaryHeaterColdJunction,(F32)^TrimmerHeaterColdJunction,(F32)^PrimaryHeaterInternalTemperature,(F32)^TrimmerHeaterInternalTemperature +## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +def buildDGTemperaturesData(vInletPrimaryHeater, vOutletPrimaryHeater, vConductivitySensor1, vConductivitySensor2, vOutletRedundancy, vInletDialysate, vPrimaryHeaterThermocouple, vTrimmerHeaterThermocouple, vPrimaryHeaterColdJunction, vTrimmerHeaterColdJunction, vPrimaryHeaterInternalTemperature, vTrimmerHeaterInternalTemperature): + msg = buildMessage( 0x002D, 4+4+4+4+4+4+4+4+4+4+4+4, False, + toF32(vInletPrimaryHeater ), + toF32(vOutletPrimaryHeater ), + toF32(vConductivitySensor1 ), + toF32(vConductivitySensor2 ), + toF32(vOutletRedundancy ), + toF32(vInletDialysate ), + toF32(vPrimaryHeaterThermocouple ), + toF32(vTrimmerHeaterThermocouple ), + toF32(vPrimaryHeaterColdJunction ), + toF32(vTrimmerHeaterColdJunction ), + toF32(vPrimaryHeaterInternalTemperature), + toF32(vTrimmerHeaterInternalTemperature)) 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) +## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +def setDGTemperaturesData(vInletPrimaryHeater, vOutletPrimaryHeater, vConductivitySensor1, vConductivitySensor2, vOutletRedundancy, vInletDialysate, vPrimaryHeaterThermocouple, vTrimmerHeaterThermocouple, vPrimaryHeaterColdJunction, vTrimmerHeaterColdJunction, vPrimaryHeaterInternalTemperature, vTrimmerHeaterInternalTemperature): + frames = buildDGTemperaturesData(vInletPrimaryHeater, vOutletPrimaryHeater, vConductivitySensor1, vConductivitySensor2, vOutletRedundancy, vInletDialysate, vPrimaryHeaterThermocouple, vTrimmerHeaterThermocouple, vPrimaryHeaterColdJunction, vTrimmerHeaterColdJunction, vPrimaryHeaterInternalTemperature, vTrimmerHeaterInternalTemperature) frames = toCandumpFormat(frames) for frame in frames: subprocess.call(['cansend', 'can0', '080#{}'.format(frame)]) waitForMessageToBeSent() -def buildCanBUSFaultCount(vCount): - """ - @param vCount: - @return: - """ +## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +## 0x000F,040,N,HD,All,TreatmentStatesData,(U32)^SubMode,(U32)^UFState,(U32)^SalineState +## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +def buildTreatmentStatesData(vSubMode, vUFState, vSalineState): + msg = buildMessage( 0x000F, 4+4+4, False, + toI32(vSubMode ), + toI32(vUFState ), + toI32(vSalineState)) + return toFrames(msg) + + +## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +def setTreatmentStatesData(vSubMode, vUFState, vSalineState): + frames = buildTreatmentStatesData(vSubMode, vUFState, vSalineState) + frames = toCandumpFormat(frames) + for frame in frames: + subprocess.call(['cansend', 'can0', '040#{}'.format(frame)]) + waitForMessageToBeSent() + + +## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +## 0x0025,040,N,HD,All,HDOperationModeData,(U32)^OpMode +## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +def buildHDOperationModeData(vOpMode): + msg = buildMessage( 0x0025, 4, False, + toI32(vOpMode)) + return toFrames(msg) + + +## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +def setHDOperationModeData(vOpMode): + frames = buildHDOperationModeData(vOpMode) + frames = toCandumpFormat(frames) + for frame in frames: + subprocess.call(['cansend', 'can0', '040#{}'.format(frame)]) + waitForMessageToBeSent() + + + + +def buildCanBUSFaultCount(vCount): msg = buildMessage(GuiActionType.CanBUSFaultCount, 4 * 1, False, toI32(vCount) ) return toFrames(msg) -def setCanBUSFaultCount(vCount): - """ - @param vCount: - @return: - """ +def setCanBUSFaultCount(vCount): frames = buildCanBUSFaultCount(vCount) frames = toCandumpFormat(frames) for frame in frames: subprocess.call(['cansend', 'can0', '020#{}'.format(frame)]) waitForMessageToBeSent() -def buildAlarm(vState, vTop, vEsclatesIn, vSilentExpires, vFlags): - """ - @param vState: - @param vTop: - @param vEsclatesIn: - @param vSilentExpires: - @param vFlags: - @return: - """ +def buildAlarm(vState, vTop, vEsclatesIn, vSilentExpires, vFlags): msg = buildMessage(GuiActionType.AlarmStatus, 4 * 4 + 2, False, toI32(vState), toI32(vTop), @@ -666,23 +645,13 @@ def buildAlarmTriggered(vAlarmID): - """ - - @param vAlarmID: - @return: - """ msg = buildMessage(GuiActionType.AlarmTriggered, 4 , True, toI16(vAlarmID) ) return toFrames(msg) def setAlarmTriggered(vAlarmID): - """ - - @param vAlarmID: - @return: - """ frames = buildAlarmTriggered(vAlarmID) frames = toCandumpFormat(frames) for frame in frames: @@ -691,23 +660,13 @@ def buildAlarmCleared(vAlarmID): - """ - - @param vAlarmID: - @return: - """ msg = buildMessage(GuiActionType.AlarmCleared, 4 , True, toI32(vAlarmID) ) return toFrames(msg) def setAlarmCleared(vAlarmID): - """ - - @param vAlarmID: - @return: - """ frames = buildAlarmCleared(vAlarmID) frames = toCandumpFormat(frames) for frame in frames: @@ -716,19 +675,11 @@ def buildUnknown(): - """ - - @return: - """ msg = buildMessage(GuiActionType.Unknown, 0, False) return toFrames(msg) def sendUnknown_HD(): - """ - - @return: None - """ frames = buildUnknown() frames = toCandumpFormat(frames) for frame in frames: @@ -737,10 +688,6 @@ def sendUnknown_DG(): - """ - - @return: None - """ frames = buildUnknown() frames = toCandumpFormat(frames) for frame in frames: @@ -749,8 +696,5 @@ def clear_all_alarms(): - """ - @return: None - """ sendAlarm(0, 0, 0, 0, 0) Index: dialin/squish/messageBuilder.py =================================================================== diff -u -r4bdb012848d1b59be5edc31d677b77b9d95f6190 -r511f8ce9d68e437c7812f9d79324719803dfafc9 --- dialin/squish/messageBuilder.py (.../messageBuilder.py) (revision 4bdb012848d1b59be5edc31d677b77b9d95f6190) +++ dialin/squish/messageBuilder.py (.../messageBuilder.py) (revision 511f8ce9d68e437c7812f9d79324719803dfafc9) @@ -64,6 +64,19 @@ """ return vString + vDelimiter + calcCRC8(vString, vDelimiter) + +def textToByte(vText, vLen): + text = "" + l = len(vText) + for i in range(vLen): + if i < l: + text += utils.toI08(ord(vText[i])) + else: + text += utils.toI08(0) + text += utils.toI08(0) #null /0 + return text + + def buildMessage(vMsgID, vLen, vAck, *vArgs): """