MsgSettingBasalProfileAll extends MessageBase { public void handleMessage(byte[] bytes) { DanaRPump pump = DanaRPump.getInstance(); if (pump.basal48Enable) { pump.pumpProfiles = new double[4][]; for (int profile = 0; profile < 4; profile++) { int position = intFromBuff(bytes, 107 * profile, 1); pump.pumpProfiles[position] = new double[48]; for (int index = 0; index < 48; index++) { int basal = intFromBuff(bytes, 107 * profile + 2 * index + 1, 2); if (basal < 10) basal = 0; pump.pumpProfiles[position][index] = basal / 100d; } } } else { pump.pumpProfiles = new double[4][]; for (int profile = 0; profile < 4; profile++) { int position = intFromBuff(bytes, 49 * profile, 1); pump.pumpProfiles[position] = new double[24]; for (int index = 0; index < 24; index++) { int basal = intFromBuff(bytes, 59 * profile + 2 * index + 1, 2); if (basal < 10) basal = 0; if (L.isEnabled(L.PUMPCOMM)) log.debug("position " + position + " index " + index); pump.pumpProfiles[position][index] = basal / 100d; } } } if (L.isEnabled(L.PUMPCOMM)) { if (pump.basal48Enable) { for (int profile = 0; profile < 4; profile++) { for (int index = 0; index < 48; index++) { try { log.debug("Basal profile " + profile + ": " + String.format(Locale.ENGLISH, "%02d", index) + "h: " + pump.pumpProfiles[profile][index]); } catch (Exception e){ log.error("Unhandled exception" , e); } } } } else { for (int profile = 0; profile < 4; profile++) { for (int index = 0; index < 24; index++) { try { log.debug("Basal profile " + profile + ": " + String.format(Locale.ENGLISH, "%02d", (index / 2)) + ":" + String.format(Locale.ENGLISH, "%02d", (index % 2) * 30) + " : " + pump.pumpProfiles[profile][index]); } catch (Exception e){ log.error("Unhandled exception" , e); } } } } } } MsgSettingBasalProfileAll(); void handleMessage(byte[] bytes);  }
@Test public void runTest() { AAPSMocker.mockMainApp(); AAPSMocker.mockApplicationContext(); AAPSMocker.mockSP(); AAPSMocker.mockL(); MsgSettingBasalProfileAll packet = new MsgSettingBasalProfileAll(); packet.handleMessage(createArray(400, (byte) 1)); }