Merge pull request #422 from andyrozman/bug418_historyFix_BolusWizardRecordProblem
Bug418 history fix bolus wizard record problem
This commit is contained in:
commit
ec1262727b
5 changed files with 101 additions and 27 deletions
|
@ -25,8 +25,8 @@ import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicUtil;
|
|||
|
||||
public abstract class MedtronicHistoryDecoder<T extends MedtronicHistoryEntry> implements MedtronicHistoryDecoderInterface<T> {
|
||||
|
||||
@Inject AAPSLogger aapsLogger;
|
||||
@Inject MedtronicUtil medtronicUtil;
|
||||
@Inject protected AAPSLogger aapsLogger;
|
||||
@Inject protected MedtronicUtil medtronicUtil;
|
||||
|
||||
protected ByteUtil bitUtils;
|
||||
|
||||
|
@ -121,7 +121,7 @@ public abstract class MedtronicHistoryDecoder<T extends MedtronicHistoryEntry> i
|
|||
aapsLogger.info(LTag.PUMPCOMM, "STATISTICS OF PUMP DECODE");
|
||||
|
||||
if (unknownOpCodes.size() > 0) {
|
||||
aapsLogger.warn(LTag.PUMPCOMM, "Unknown Op Codes: {}", sb.toString());
|
||||
aapsLogger.warn(LTag.PUMPCOMM, "Unknown Op Codes: " + sb.toString());
|
||||
}
|
||||
|
||||
for (Map.Entry<RecordDecodeStatus, Map<String, String>> entry : mapStatistics.entrySet()) {
|
||||
|
@ -137,9 +137,9 @@ public abstract class MedtronicHistoryDecoder<T extends MedtronicHistoryEntry> i
|
|||
|
||||
String spaces = StringUtils.repeat(" ", 14 - entry.getKey().name().length());
|
||||
|
||||
aapsLogger.info(LTag.PUMPCOMM, " {}{} - {}. Elements: {}", entry.getKey().name(), spaces, entry.getValue().size(), sb.toString());
|
||||
aapsLogger.info(LTag.PUMPCOMM, String.format(" %s%s - %d. Elements: %s", entry.getKey().name(), spaces, entry.getValue().size(), sb.toString()));
|
||||
} else {
|
||||
aapsLogger.info(LTag.PUMPCOMM, " {} - {}", entry.getKey().name(), entry.getValue().size());
|
||||
aapsLogger.info(LTag.PUMPCOMM, String.format(" %s - %d", entry.getKey().name(), entry.getValue().size()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,9 +32,6 @@ import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicUtil;
|
|||
@Singleton
|
||||
public class MedtronicPumpHistoryDecoder extends MedtronicHistoryDecoder<PumpHistoryEntry> {
|
||||
|
||||
private final AAPSLogger aapsLogger;
|
||||
private final MedtronicUtil medtronicUtil;
|
||||
|
||||
private PumpHistoryEntry tbrPreviousRecord;
|
||||
private PumpHistoryEntry changeTimeRecord;
|
||||
|
||||
|
@ -43,7 +40,7 @@ public class MedtronicPumpHistoryDecoder extends MedtronicHistoryDecoder<PumpHis
|
|||
AAPSLogger aapsLogger,
|
||||
MedtronicUtil medtronicUtil
|
||||
) {
|
||||
this.aapsLogger = aapsLogger;
|
||||
super.aapsLogger = aapsLogger;
|
||||
this.medtronicUtil = medtronicUtil;
|
||||
}
|
||||
|
||||
|
@ -67,6 +64,7 @@ public class MedtronicPumpHistoryDecoder extends MedtronicHistoryDecoder<PumpHis
|
|||
int opCode = dataClear.get(counter);
|
||||
boolean special = false;
|
||||
incompletePacket = false;
|
||||
boolean skippedRecords = false;
|
||||
|
||||
if (opCode == 0) {
|
||||
counter++;
|
||||
|
@ -79,9 +77,14 @@ public class MedtronicPumpHistoryDecoder extends MedtronicHistoryDecoder<PumpHis
|
|||
if (skipped != null) {
|
||||
aapsLogger.warn(LTag.PUMPBTCOMM, " ... Skipped " + skipped);
|
||||
skipped = null;
|
||||
skippedRecords = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (skippedRecords) {
|
||||
aapsLogger.error(LTag.PUMPBTCOMM, "We had some skipped bytes, which might indicate error in pump history. Please report this problem.");
|
||||
}
|
||||
|
||||
PumpHistoryEntryType entryType = PumpHistoryEntryType.getByCode(opCode);
|
||||
|
||||
PumpHistoryEntry pe = new PumpHistoryEntry();
|
||||
|
@ -216,12 +219,12 @@ public class MedtronicPumpHistoryDecoder extends MedtronicHistoryDecoder<PumpHis
|
|||
case SelfTest:
|
||||
case JournalEntryInsulinMarker:
|
||||
case JournalEntryOtherMarker:
|
||||
case ChangeBolusWizardSetup512:
|
||||
case BolusWizardSetup512:
|
||||
case ChangeSensorSetup2:
|
||||
case ChangeSensorAlarmSilenceConfig:
|
||||
case ChangeSensorRateOfChangeAlertSetup:
|
||||
case ChangeBolusScrollStepSize:
|
||||
case ChangeBolusWizardSetup:
|
||||
case BolusWizardSetup:
|
||||
case ChangeVariableBolus:
|
||||
case ChangeAudioBolus:
|
||||
case ChangeBGReminderEnable:
|
||||
|
|
|
@ -70,13 +70,14 @@ public class PumpHistoryEntry extends MedtronicHistoryEntry {
|
|||
|
||||
|
||||
public String toString() {
|
||||
Object object = this.getDecodedDataEntry("Object");
|
||||
|
||||
if (object == null) {
|
||||
return super.toString();
|
||||
} else {
|
||||
return "PumpHistoryEntry [DT: " + DT + ", Object=" + object.toString() + "]";
|
||||
}
|
||||
return super.toString();
|
||||
// Object object = this.getDecodedDataEntry("Object");
|
||||
//
|
||||
// if (object == null) {
|
||||
// return super.toString();
|
||||
// } else {
|
||||
// return super.toString() + "PumpHistoryEntry [type=" + StringUtil.getStringInLength(entryType.name(), 20) + ", DT: " + DT + ", Object=" + object.toString() + "]";
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -89,7 +89,7 @@ public enum PumpHistoryEntryType // implements CodeEnum
|
|||
/**/EventUnknown_MM522_0x4c(0x4c, "Unknown Event 0x4c", PumpHistoryEntryGroup.Unknown, 2, 5, 1), //
|
||||
/**/EventUnknown_0x4d(0x4d, "Unknown Event 0x4d", PumpHistoryEntryGroup.Unknown), // V5: 512: 7, 522: 8 ????NS
|
||||
/**/EventUnknown_MM512_0x4e(0x4e, "Unknown Event 0x4e", PumpHistoryEntryGroup.Unknown), // /**/
|
||||
ChangeBolusWizardSetup512(0x4f, "Bolus Wizard Setup (512)", PumpHistoryEntryGroup.Configuration, 2, 5, 32), //
|
||||
BolusWizardSetup512(0x4f, "Bolus Wizard Setup (512)", PumpHistoryEntryGroup.Configuration, 2, 5, 32), //
|
||||
ChangeSensorSetup2(0x50, "Sensor Setup2", PumpHistoryEntryGroup.Configuration, 2, 5, 30), // Ian50
|
||||
/**/Sensor_0x51(0x51, "Unknown Event 0x51", PumpHistoryEntryGroup.Unknown), //
|
||||
/**/Sensor_0x52(0x52, "Unknown Event 0x52", PumpHistoryEntryGroup.Unknown), //
|
||||
|
@ -102,8 +102,8 @@ public enum PumpHistoryEntryType // implements CodeEnum
|
|||
|
||||
// V4
|
||||
// Andy58(0x58, "Unknown", 13, 5, 0), // TO DO is this one really there ???
|
||||
|
||||
ChangeBolusWizardSetup(0x5a, "Bolus Wizard Setup (512)", PumpHistoryEntryGroup.Configuration, 2, 5, 137), // V2: 522+[B=143] // V6 124 -> 144
|
||||
BolusWizardSetup(0x5a, "Bolus Wizard Setup (522)", PumpHistoryEntryGroup.Configuration, 2, 5, 117),
|
||||
// V2: 522+[B=143]; V6: 124, v6: 137, v7: 117/137 [523]
|
||||
BolusWizard(0x5b, "Bolus Wizard Estimate", PumpHistoryEntryGroup.Configuration, 2, 5, 13), // 15 //
|
||||
UnabsorbedInsulin(0x5c, "Unabsorbed Insulin", PumpHistoryEntryGroup.Statistic, 5, 0, 0), // head[1] -> body
|
||||
SaveSettings(0x5d, "Save Settings", PumpHistoryEntryGroup.Configuration), //
|
||||
|
@ -212,9 +212,7 @@ public enum PumpHistoryEntryType // implements CodeEnum
|
|||
static void setSpecialRulesForEntryTypes() {
|
||||
EndResultTotals.addSpecialRuleBody(new SpecialRule(MedtronicDeviceType.Medtronic_523andHigher, 3));
|
||||
Bolus.addSpecialRuleHead(new SpecialRule(MedtronicDeviceType.Medtronic_523andHigher, 8));
|
||||
// BolusWizardChange.addSpecialRuleBody(new SpecialRule(MedtronicDeviceType.Medtronic_522andHigher, 143));
|
||||
//ChangeBolusWizardSetup.addSpecialRuleBody(new SpecialRule(MedtronicDeviceType.Medtronic_523andHigher, 137)); // V5:
|
||||
// 522 has old form
|
||||
BolusWizardSetup.addSpecialRuleBody(new SpecialRule(MedtronicDeviceType.Medtronic_523andHigher, 137));
|
||||
BolusWizard.addSpecialRuleBody(new SpecialRule(MedtronicDeviceType.Medtronic_523andHigher, 15));
|
||||
BolusReminder.addSpecialRuleBody(new SpecialRule(MedtronicDeviceType.Medtronic_523andHigher, 2));
|
||||
ChangeSensorSetup2.addSpecialRuleBody(new SpecialRule(MedtronicDeviceType.Medtronic_523andHigher, 34));
|
||||
|
|
|
@ -1,14 +1,56 @@
|
|||
package info.nightscout.androidaps.plugins.pump.medtronic.comm.history.pump;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Answers;
|
||||
import org.mockito.Mock;
|
||||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
|
||||
import info.nightscout.androidaps.plugins.pump.common.defs.PumpHistoryEntryGroup;
|
||||
import java.util.List;
|
||||
|
||||
import dagger.android.HasAndroidInjector;
|
||||
import info.nightscout.androidaps.interfaces.ActivePluginProvider;
|
||||
import info.nightscout.androidaps.logging.AAPSLogger;
|
||||
import info.nightscout.androidaps.logging.AAPSLoggerTest;
|
||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper;
|
||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkUtil;
|
||||
import info.nightscout.androidaps.plugins.pump.common.utils.ByteUtil;
|
||||
import info.nightscout.androidaps.plugins.pump.medtronic.comm.history.RawHistoryPage;
|
||||
import info.nightscout.androidaps.plugins.pump.medtronic.defs.MedtronicDeviceType;
|
||||
import info.nightscout.androidaps.plugins.pump.medtronic.driver.MedtronicPumpStatus;
|
||||
import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicUtil;
|
||||
import info.nightscout.androidaps.utils.resources.ResourceHelper;
|
||||
import info.nightscout.androidaps.utils.rx.TestAapsSchedulers;
|
||||
import info.nightscout.androidaps.utils.sharedPreferences.SP;
|
||||
|
||||
/**
|
||||
* Created by andy on 11/1/18.
|
||||
*/
|
||||
@Ignore
|
||||
@RunWith(PowerMockRunner.class)
|
||||
public class MedtronicPumpHistoryDecoderUTest {
|
||||
|
||||
@Mock HasAndroidInjector injector;
|
||||
AAPSLogger aapsLogger = new AAPSLoggerTest();
|
||||
RxBusWrapper rxBusWrapper = new RxBusWrapper(new TestAapsSchedulers());
|
||||
@Mock ResourceHelper resourceHelper;
|
||||
@Mock(answer = Answers.RETURNS_DEEP_STUBS) ActivePluginProvider activePluginProvider;
|
||||
@Mock RileyLinkUtil rileyLinkUtil;
|
||||
@Mock SP sp;
|
||||
MedtronicPumpStatus medtronicPumpStatus;
|
||||
MedtronicUtil medtronicUtil;
|
||||
MedtronicPumpHistoryDecoder decoder;
|
||||
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
medtronicPumpStatus = new MedtronicPumpStatus(resourceHelper, sp, rxBusWrapper, rileyLinkUtil);
|
||||
medtronicUtil = new MedtronicUtil(aapsLogger, rxBusWrapper, rileyLinkUtil, medtronicPumpStatus);
|
||||
decoder = new MedtronicPumpHistoryDecoder(aapsLogger, medtronicUtil);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
MedtronicPumpHistoryDecoder decoder = new MedtronicPumpHistoryDecoder();
|
||||
|
||||
|
@ -151,4 +193,34 @@ public class MedtronicPumpHistoryDecoderUTest {
|
|||
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
@Test
|
||||
public void historyProblem_148_amunhateb() throws Exception {
|
||||
byte[] historyPageData = ByteUtil.createByteArrayFromString(
|
||||
"5A 0F 20 F4 0C 03 15 19 11 00 17 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 1E 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 32 50 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 1A 11 00 0F 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 1E 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 32 50 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 33 01 12 12 00 25 DE 2D 43 15 01 50 50 00 26 EA 2D 43 15 01 4B 4B 00 2C C9 34 43 15 62 00 2F CB 17 03 15 01 33 33 00 16 DE 37 43 15 07 00 00 07 FE 23 95 6D 23 95 0A 08 00 2B 00 00 00 00 07 FE 03 8E 2C 04 70 38 00 00 04 70 38 00 00 00 00 00 00 04 70 64 06 00 00 00 06 08 00 2B 00 00 00 2C A0 2F E3 01 04 15 33 00 2F E7 04 44 15 00 16 03 2F E7 04 44 15 33 28 3B C2 06 44 15 00 16 01 3B C2 06 44 15 08 08 17 DB 0B 44 15 00 26 00 06 26 00 0C 26 00 12 28 00 18 26 00 1E 26 00 24 24 00 2A 26 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 09 18 17 DB 0B 44 15 00 26 00 02 26 00 04 26 00 06 24 00 08 24 00 0A 24 00 0C 26 00 0E 26 00 10 26 00 12 28 00 14 28 00 16 28 00 18 26 00 1A 26 00 1C 26 00 1E 26 00 20 26 00 22 26 00 24 24 00 26 24 00 28 24 00 2A 26 00 2C 26 00 2E 26 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 45 45 00 28 E9 2B 44 15 19 00 00 C1 0D 04 15 1A 00 15 C3 0D 04 15 1A 01 33 C3 0D 04 15 01 28 28 00 07 CC 2E 44 15 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 14 2D");
|
||||
|
||||
System.out.println("HDP:" + historyPageData.length);
|
||||
|
||||
medtronicUtil.setMedtronicPumpModel(MedtronicDeviceType.Medtronic_522_722);
|
||||
|
||||
|
||||
RawHistoryPage historyPage = new RawHistoryPage(aapsLogger);
|
||||
historyPage.appendData(historyPageData);
|
||||
|
||||
List<PumpHistoryEntry> pumpHistoryEntries = decoder.processPageAndCreateRecords(historyPage);
|
||||
|
||||
System.out.println("PumpHistoryEntries: " + pumpHistoryEntries.size());
|
||||
|
||||
displayHistoryRecords(pumpHistoryEntries);
|
||||
}
|
||||
|
||||
|
||||
private void displayHistoryRecords(List<PumpHistoryEntry> pumpHistoryEntries) {
|
||||
for (PumpHistoryEntry pumpHistoryEntry : pumpHistoryEntries) {
|
||||
aapsLogger.debug(pumpHistoryEntry.toString());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue