MsgStatusTempBasal_v2 extends MessageBase { public void handleMessage(byte[] bytes) { boolean isTempBasalInProgress = (intFromBuff(bytes, 0, 1) & 0x01) == 0x01; boolean isAPSTempBasalInProgress = (intFromBuff(bytes, 0, 1) & 0x02) == 0x02; int tempBasalPercent = intFromBuff(bytes, 1, 1); if (tempBasalPercent > 200) tempBasalPercent = (tempBasalPercent - 200) * 10; int tempBasalTotalSec; if (intFromBuff(bytes, 2, 1) == 150) tempBasalTotalSec = 15 * 60; else if (intFromBuff(bytes, 2, 1) == 160) tempBasalTotalSec = 30 * 60; else tempBasalTotalSec = intFromBuff(bytes, 2, 1) * 60 * 60; int tempBasalRunningSeconds = intFromBuff(bytes, 3, 3); int tempBasalRemainingMin = (tempBasalTotalSec - tempBasalRunningSeconds) / 60; long tempBasalStart = isTempBasalInProgress ? getDateFromTempBasalSecAgo(tempBasalRunningSeconds) : 0; DanaRPump pump = DanaRPump.getInstance(); pump.isTempBasalInProgress = isTempBasalInProgress; pump.tempBasalPercent = tempBasalPercent; pump.tempBasalRemainingMin = tempBasalRemainingMin; pump.tempBasalTotalSec = tempBasalTotalSec; pump.tempBasalStart = tempBasalStart; if (L.isEnabled(L.PUMPCOMM)) { log.debug("Is temp basal running: " + isTempBasalInProgress); log.debug("Is APS temp basal running: " + isAPSTempBasalInProgress); log.debug("Current temp basal percent: " + tempBasalPercent); log.debug("Current temp basal remaining min: " + tempBasalRemainingMin); log.debug("Current temp basal total sec: " + tempBasalTotalSec); log.debug("Current temp basal start: " + DateUtil.dateAndTimeFullString(tempBasalStart)); } } MsgStatusTempBasal_v2(); void handleMessage(byte[] bytes);  }
@Test public void runTest() { MsgStatusTempBasal_v2 packet = new MsgStatusTempBasal_v2(); DanaRPump pump = DanaRPump.getInstance(); packet.handleMessage(createArray(34, (byte) 1)); assertEquals(true, pump.isTempBasalInProgress); packet = new MsgStatusTempBasal_v2(); packet.handleMessage(createArray(34, (byte) 2)); assertEquals(false, pump.isTempBasalInProgress); }