MsgCheckValue_v2 extends MessageBase { @Override public void handleMessage(byte[] bytes) { DanaRPump pump = DanaRPump.getInstance(); pump.isNewPump = true; if (L.isEnabled(L.PUMPCOMM)) log.debug("New firmware confirmed"); pump.model = intFromBuff(bytes, 0, 1); pump.protocol = intFromBuff(bytes, 1, 1); pump.productCode = intFromBuff(bytes, 2, 1); if (pump.model != DanaRPump.EXPORT_MODEL) { pump.lastConnection = 0; Notification notification = new Notification(Notification.WRONG_DRIVER, MainApp.gs(R.string.pumpdrivercorrected), Notification.NORMAL); RxBus.INSTANCE.send(new EventNewNotification(notification)); DanaRPlugin.getPlugin().disconnect("Wrong Model"); log.error("Wrong model selected. Switching to Korean DanaR"); DanaRKoreanPlugin.getPlugin().setPluginEnabled(PluginType.PUMP, true); DanaRKoreanPlugin.getPlugin().setFragmentVisible(PluginType.PUMP, true); DanaRPlugin.getPlugin().setPluginEnabled(PluginType.PUMP, false); DanaRPlugin.getPlugin().setFragmentVisible(PluginType.PUMP, false); DanaRPump.reset(); if (DanaRPlugin.getPlugin().isEnabled(PluginType.PROFILE)) { (DanaRPlugin.getPlugin()).setPluginEnabled(PluginType.PROFILE, false); (DanaRKoreanPlugin.getPlugin()).setPluginEnabled(PluginType.PROFILE, true); } ConfigBuilderPlugin.getPlugin().storeSettings("ChangingDanaRv2Driver"); RxBus.INSTANCE.send(new EventRebuildTabs()); ConfigBuilderPlugin.getPlugin().getCommandQueue().readStatus("PumpDriverChange", null); return; } if (pump.protocol != 2) { pump.lastConnection = 0; Notification notification = new Notification(Notification.WRONG_DRIVER, MainApp.gs(R.string.pumpdrivercorrected), Notification.NORMAL); RxBus.INSTANCE.send(new EventNewNotification(notification)); DanaRKoreanPlugin.getPlugin().disconnect("Wrong Model"); log.error("Wrong model selected. Switching to non APS DanaR"); (DanaRv2Plugin.getPlugin()).setPluginEnabled(PluginType.PUMP, false); (DanaRv2Plugin.getPlugin()).setFragmentVisible(PluginType.PUMP, false); (DanaRPlugin.getPlugin()).setPluginEnabled(PluginType.PUMP, true); (DanaRPlugin.getPlugin()).setFragmentVisible(PluginType.PUMP, true); if (DanaRv2Plugin.getPlugin().isEnabled(PluginType.PROFILE)) { (DanaRv2Plugin.getPlugin()).setPluginEnabled(PluginType.PROFILE, false); (DanaRPlugin.getPlugin()).setPluginEnabled(PluginType.PROFILE, true); } ConfigBuilderPlugin.getPlugin().storeSettings("ChangingDanaRv2Driver"); RxBus.INSTANCE.send(new EventRebuildTabs()); ConfigBuilderPlugin.getPlugin().getCommandQueue().readStatus("PumpDriverChange", null); return; } if (L.isEnabled(L.PUMPCOMM)) { log.debug("Model: " + String.format("%02X ", pump.model)); log.debug("Protocol: " + String.format("%02X ", pump.protocol)); log.debug("Product Code: " + String.format("%02X ", pump.productCode)); } } MsgCheckValue_v2(); @Override void handleMessage(byte[] bytes);  }
@Test public void runTest() { Treatment t = new Treatment(); MsgCheckValue_v2 packet = new MsgCheckValue_v2(); packet.handleMessage(createArray(34, (byte) 3)); DanaRPump pump = DanaRPump.getInstance(); assertEquals(DanaRPump.EXPORT_MODEL, pump.model); }