0.10.5-SNAPSHOT
- added custom comnand for reseting RL configuration - removed guava Splitter and use my own code - remove old unsused code
This commit is contained in:
parent
6d771d8918
commit
a19d71df89
78 changed files with 436 additions and 3575 deletions
|
@ -105,7 +105,7 @@ android {
|
||||||
multiDexEnabled true
|
multiDexEnabled true
|
||||||
versionCode 1500
|
versionCode 1500
|
||||||
// dev_version: 2.3.1-dev
|
// dev_version: 2.3.1-dev
|
||||||
version "medtronic-0.10.4-SNAPSHOT"
|
version "medtronic-0.10.5-SNAPSHOT"
|
||||||
buildConfigField "String", "VERSION", '"' + version + '"'
|
buildConfigField "String", "VERSION", '"' + version + '"'
|
||||||
buildConfigField "String", "BUILDVERSION", '"' + generateGitBuild() + '-' + generateDate() + '"'
|
buildConfigField "String", "BUILDVERSION", '"' + generateGitBuild() + '-' + generateDate() + '"'
|
||||||
buildConfigField "String", "HEAD", '"' + generateGitBuild() + '"'
|
buildConfigField "String", "HEAD", '"' + generateGitBuild() + '"'
|
||||||
|
@ -274,11 +274,17 @@ dependencies {
|
||||||
testImplementation "org.powermock:powermock-module-junit4-rule:${powermockVersion}"
|
testImplementation "org.powermock:powermock-module-junit4-rule:${powermockVersion}"
|
||||||
testImplementation "org.powermock:powermock-module-junit4:${powermockVersion}"
|
testImplementation "org.powermock:powermock-module-junit4:${powermockVersion}"
|
||||||
testImplementation "joda-time:joda-time:2.9.9"
|
testImplementation "joda-time:joda-time:2.9.9"
|
||||||
testImplementation "com.google.truth:truth:0.39"
|
testImplementation("com.google.truth:truth:0.39") {
|
||||||
testImplementation 'org.robolectric:robolectric:3.8'
|
exclude group: "com.google.guava", module: "guava"
|
||||||
|
}
|
||||||
|
testImplementation("org.robolectric:robolectric:3.8") {
|
||||||
|
exclude group: "com.google.guava", module: "guava"
|
||||||
|
}
|
||||||
testImplementation "org.skyscreamer:jsonassert:1.5.0"
|
testImplementation "org.skyscreamer:jsonassert:1.5.0"
|
||||||
testImplementation "org.hamcrest:hamcrest-all:1.3"
|
testImplementation "org.hamcrest:hamcrest-all:1.3"
|
||||||
testImplementation "uk.org.lidalia:slf4j-test:1.2.0"
|
testImplementation("uk.org.lidalia:slf4j-test:1.2.0") {
|
||||||
|
exclude group: "com.google.guava", module: "guava"
|
||||||
|
}
|
||||||
|
|
||||||
androidTestImplementation "org.mockito:mockito-core:2.8.47"
|
androidTestImplementation "org.mockito:mockito-core:2.8.47"
|
||||||
androidTestImplementation "com.google.dexmaker:dexmaker:${dexmakerVersion}"
|
androidTestImplementation "com.google.dexmaker:dexmaker:${dexmakerVersion}"
|
||||||
|
|
|
@ -1,19 +1,17 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble;
|
package info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble;
|
||||||
|
|
||||||
import java.util.UUID;
|
import android.os.SystemClock;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import android.os.SystemClock;
|
import java.util.UUID;
|
||||||
|
|
||||||
import info.nightscout.androidaps.MainApp;
|
import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.logging.L;
|
import info.nightscout.androidaps.logging.L;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkConst;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkUtil;
|
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkUtil;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.command.Reset;
|
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.command.Reset;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.command.ResetRadioConfig;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.command.RileyLinkCommand;
|
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.command.RileyLinkCommand;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.command.SendAndListen;
|
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.command.SendAndListen;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.command.SetHardwareEncoding;
|
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.command.SetHardwareEncoding;
|
||||||
|
@ -29,13 +27,10 @@ import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.defs.Rile
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.defs.RileyLinkFirmwareVersion;
|
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.defs.RileyLinkFirmwareVersion;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.defs.RileyLinkTargetFrequency;
|
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.defs.RileyLinkTargetFrequency;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.operations.BLECommOperationResult;
|
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.operations.BLECommOperationResult;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkTargetDevice;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.common.utils.ByteUtil;
|
import info.nightscout.androidaps.plugins.pump.common.utils.ByteUtil;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.utils.HexDump;
|
import info.nightscout.androidaps.plugins.pump.common.utils.HexDump;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.utils.StringUtil;
|
import info.nightscout.androidaps.plugins.pump.common.utils.StringUtil;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.utils.ThreadUtil;
|
import info.nightscout.androidaps.plugins.pump.common.utils.ThreadUtil;
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.MedtronicPumpPlugin;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.defs.MedtronicCustomActionType;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicConst;
|
import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicConst;
|
||||||
import info.nightscout.androidaps.utils.SP;
|
import info.nightscout.androidaps.utils.SP;
|
||||||
|
|
||||||
|
@ -57,6 +52,7 @@ public class RFSpy {
|
||||||
private UUID responseCountUUID = UUID.fromString(GattAttributes.CHARA_RADIO_RESPONSE_COUNT);
|
private UUID responseCountUUID = UUID.fromString(GattAttributes.CHARA_RADIO_RESPONSE_COUNT);
|
||||||
private RileyLinkFirmwareVersion firmwareVersion;
|
private RileyLinkFirmwareVersion firmwareVersion;
|
||||||
private String bleVersion; // We don't use it so no need of sofisticated logic
|
private String bleVersion; // We don't use it so no need of sofisticated logic
|
||||||
|
double currentFrequencyMHz;
|
||||||
|
|
||||||
|
|
||||||
public RFSpy(RileyLinkBLE rileyLinkBle) {
|
public RFSpy(RileyLinkBLE rileyLinkBle) {
|
||||||
|
@ -141,7 +137,7 @@ public class RFSpy {
|
||||||
String versionString = StringUtil.fromBytes(response);
|
String versionString = StringUtil.fromBytes(response);
|
||||||
|
|
||||||
RileyLinkFirmwareVersion version = RileyLinkFirmwareVersion.getByVersionString(StringUtil
|
RileyLinkFirmwareVersion version = RileyLinkFirmwareVersion.getByVersionString(StringUtil
|
||||||
.fromBytes(response));
|
.fromBytes(response));
|
||||||
|
|
||||||
if (isLogEnabled())
|
if (isLogEnabled())
|
||||||
LOG.trace("Firmware Version string: {}, resolved to {}.", versionString, version);
|
LOG.trace("Firmware Version string: {}, resolved to {}.", versionString, version);
|
||||||
|
@ -170,17 +166,17 @@ public class RFSpy {
|
||||||
|
|
||||||
while (junkInBuffer != null) {
|
while (junkInBuffer != null) {
|
||||||
LOG.warn(ThreadUtil.sig() + "writeToData: draining read queue, found this: "
|
LOG.warn(ThreadUtil.sig() + "writeToData: draining read queue, found this: "
|
||||||
+ ByteUtil.shortHexString(junkInBuffer));
|
+ ByteUtil.shortHexString(junkInBuffer));
|
||||||
junkInBuffer = reader.poll(0);
|
junkInBuffer = reader.poll(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// prepend length, and send it.
|
// prepend length, and send it.
|
||||||
byte[] prepended = ByteUtil.concat(new byte[] { (byte)(bytes.length) }, bytes);
|
byte[] prepended = ByteUtil.concat(new byte[]{(byte) (bytes.length)}, bytes);
|
||||||
|
|
||||||
LOG.debug("writeToData (raw={})", HexDump.toHexStringDisplayable(prepended));
|
LOG.debug("writeToData (raw={})", HexDump.toHexStringDisplayable(prepended));
|
||||||
|
|
||||||
BLECommOperationResult writeCheck = rileyLinkBle.writeCharacteristic_blocking(radioServiceUUID, radioDataUUID,
|
BLECommOperationResult writeCheck = rileyLinkBle.writeCharacteristic_blocking(radioServiceUUID, radioDataUUID,
|
||||||
prepended);
|
prepended);
|
||||||
if (writeCheck.resultCode != BLECommOperationResult.RESULT_SUCCESS) {
|
if (writeCheck.resultCode != BLECommOperationResult.RESULT_SUCCESS) {
|
||||||
LOG.error("BLE Write operation failed, code=" + writeCheck.resultCode);
|
LOG.error("BLE Write operation failed, code=" + writeCheck.resultCode);
|
||||||
return null; // will be a null (invalid) response
|
return null; // will be a null (invalid) response
|
||||||
|
@ -255,42 +251,44 @@ public class RFSpy {
|
||||||
|
|
||||||
|
|
||||||
public RFSpyResponse transmitThenReceive(RadioPacket pkt, byte sendChannel, byte repeatCount, byte delay_ms,
|
public RFSpyResponse transmitThenReceive(RadioPacket pkt, byte sendChannel, byte repeatCount, byte delay_ms,
|
||||||
byte listenChannel, int timeout_ms, byte retryCount) {
|
byte listenChannel, int timeout_ms, byte retryCount) {
|
||||||
return transmitThenReceive(pkt, sendChannel, repeatCount, delay_ms, listenChannel, timeout_ms, retryCount, null);
|
return transmitThenReceive(pkt, sendChannel, repeatCount, delay_ms, listenChannel, timeout_ms, retryCount, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public RFSpyResponse transmitThenReceive(RadioPacket pkt, int timeout_ms) {
|
public RFSpyResponse transmitThenReceive(RadioPacket pkt, int timeout_ms) {
|
||||||
return transmitThenReceive(pkt, (byte)0, (byte)0, (byte)0, (byte)0, timeout_ms, (byte)0);
|
return transmitThenReceive(pkt, (byte) 0, (byte) 0, (byte) 0, (byte) 0, timeout_ms, (byte) 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public RFSpyResponse transmitThenReceive(RadioPacket pkt, byte sendChannel, byte repeatCount, byte delay_ms,
|
public RFSpyResponse transmitThenReceive(RadioPacket pkt, byte sendChannel, byte repeatCount, byte delay_ms,
|
||||||
byte listenChannel, int timeout_ms, byte retryCount, Integer extendPreamble_ms) {
|
byte listenChannel, int timeout_ms, byte retryCount, Integer extendPreamble_ms) {
|
||||||
|
|
||||||
int sendDelay = repeatCount * delay_ms;
|
int sendDelay = repeatCount * delay_ms;
|
||||||
int receiveDelay = timeout_ms * (retryCount + 1);
|
int receiveDelay = timeout_ms * (retryCount + 1);
|
||||||
|
|
||||||
SendAndListen command = new SendAndListen(sendChannel, repeatCount, delay_ms, listenChannel, timeout_ms,
|
SendAndListen command = new SendAndListen(sendChannel, repeatCount, delay_ms, listenChannel, timeout_ms,
|
||||||
retryCount, extendPreamble_ms, pkt);
|
retryCount, extendPreamble_ms, pkt);
|
||||||
|
|
||||||
return writeToData(command, sendDelay + receiveDelay + EXPECTED_MAX_BLUETOOTH_LATENCY_MS);
|
return writeToData(command, sendDelay + receiveDelay + EXPECTED_MAX_BLUETOOTH_LATENCY_MS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public RFSpyResponse updateRegister(CC111XRegister reg, int val) {
|
public RFSpyResponse updateRegister(CC111XRegister reg, int val) {
|
||||||
RFSpyResponse resp = writeToData(new UpdateRegister(reg, (byte)val), EXPECTED_MAX_BLUETOOTH_LATENCY_MS);
|
RFSpyResponse resp = writeToData(new UpdateRegister(reg, (byte) val), EXPECTED_MAX_BLUETOOTH_LATENCY_MS);
|
||||||
return resp;
|
return resp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void setBaseFrequency(double freqMHz) {
|
public void setBaseFrequency(double freqMHz) {
|
||||||
int value = (int)(freqMHz * 1000000 / ((double)(RILEYLINK_FREQ_XTAL) / Math.pow(2.0, 16.0)));
|
int value = (int) (freqMHz * 1000000 / ((double) (RILEYLINK_FREQ_XTAL) / Math.pow(2.0, 16.0)));
|
||||||
updateRegister(CC111XRegister.freq0, (byte)(value & 0xff));
|
updateRegister(CC111XRegister.freq0, (byte) (value & 0xff));
|
||||||
updateRegister(CC111XRegister.freq1, (byte)((value >> 8) & 0xff));
|
updateRegister(CC111XRegister.freq1, (byte) ((value >> 8) & 0xff));
|
||||||
updateRegister(CC111XRegister.freq2, (byte)((value >> 16) & 0xff));
|
updateRegister(CC111XRegister.freq2, (byte) ((value >> 16) & 0xff));
|
||||||
LOG.info("Set frequency to {} MHz", freqMHz);
|
LOG.info("Set frequency to {} MHz", freqMHz);
|
||||||
|
|
||||||
|
this.currentFrequencyMHz = freqMHz;
|
||||||
|
|
||||||
configureRadioForRegion(RileyLinkUtil.getRileyLinkTargetFrequency());
|
configureRadioForRegion(RileyLinkUtil.getRileyLinkTargetFrequency());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -310,7 +308,7 @@ public class RFSpy {
|
||||||
updateRegister(CC111XRegister.deviatn, 0x13);
|
updateRegister(CC111XRegister.deviatn, 0x13);
|
||||||
setMedtronicEncoding();
|
setMedtronicEncoding();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Medtronic_US: {
|
case Medtronic_US: {
|
||||||
// updateRegister(CC111X_MDMCFG4, (byte) 0x99);
|
// updateRegister(CC111X_MDMCFG4, (byte) 0x99);
|
||||||
|
@ -322,7 +320,7 @@ public class RFSpy {
|
||||||
updateRegister(CC111XRegister.deviatn, 0x15);
|
updateRegister(CC111XRegister.deviatn, 0x15);
|
||||||
setMedtronicEncoding();
|
setMedtronicEncoding();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Omnipod: {
|
case Omnipod: {
|
||||||
RFSpyResponse r = null;
|
RFSpyResponse r = null;
|
||||||
|
@ -355,7 +353,7 @@ public class RFSpy {
|
||||||
r = setPreamble(0x6665);
|
r = setPreamble(0x6665);
|
||||||
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
LOG.warn("No region configuration for RfSpy and {}", frequency.name());
|
LOG.warn("No region configuration for RfSpy and {}", frequency.name());
|
||||||
break;
|
break;
|
||||||
|
@ -407,18 +405,21 @@ public class RFSpy {
|
||||||
|
|
||||||
private void setRXFilterMode(RXFilterMode mode) {
|
private void setRXFilterMode(RXFilterMode mode) {
|
||||||
|
|
||||||
byte drate_e = (byte)0x9; // exponent of symbol rate (16kbps)
|
byte drate_e = (byte) 0x9; // exponent of symbol rate (16kbps)
|
||||||
byte chanbw = mode.value;
|
byte chanbw = mode.value;
|
||||||
|
|
||||||
updateRegister(CC111XRegister.mdmcfg4, (byte)(chanbw | drate_e));
|
updateRegister(CC111XRegister.mdmcfg4, (byte) (chanbw | drate_e));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This command while implemented doesn't work correctly, and is of dubious action.
|
* Reset RileyLink Configuration (set all updateRegisters)
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
public RFSpyResponse resetRileyLinkDevice() {
|
public void resetRileyLinkConfiguration() {
|
||||||
// FIXME not working correctly yet
|
this.setBaseFrequency(this.currentFrequencyMHz);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public RFSpyResponse resetRileyLink() {
|
||||||
RFSpyResponse resp = null;
|
RFSpyResponse resp = null;
|
||||||
try {
|
try {
|
||||||
resp = writeToData(new Reset(), EXPECTED_MAX_BLUETOOTH_LATENCY_MS);
|
resp = writeToData(new Reset(), EXPECTED_MAX_BLUETOOTH_LATENCY_MS);
|
||||||
|
@ -430,6 +431,7 @@ public class RFSpy {
|
||||||
return resp;
|
return resp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private boolean isLogEnabled() {
|
private boolean isLogEnabled() {
|
||||||
return L.isEnabled(L.PUMPBTCOMM);
|
return L.isEnabled(L.PUMPBTCOMM);
|
||||||
}
|
}
|
||||||
|
|
|
@ -105,9 +105,13 @@ public class RileyLinkStatusGeneral extends Fragment implements RefreshableInter
|
||||||
|
|
||||||
RileyLinkFirmwareVersion firmwareVersion = rileyLinkServiceData.versionCC110;
|
RileyLinkFirmwareVersion firmwareVersion = rileyLinkServiceData.versionCC110;
|
||||||
|
|
||||||
this.firmwareVersion.setText("BLE113: " + //
|
if (firmwareVersion==null) {
|
||||||
rileyLinkServiceData.versionBLE113 == null ? "-" : rileyLinkServiceData.versionBLE113 + //
|
this.firmwareVersion.setText("BLE113: -\nCC110: -");
|
||||||
"\nCC110: " + firmwareVersion == null ? "-" : firmwareVersion.toString());
|
} else {
|
||||||
|
this.firmwareVersion.setText("BLE113: " + rileyLinkServiceData.versionBLE113 + //
|
||||||
|
"\nCC110: " + firmwareVersion.toString());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO add handling for Omnipod pump status
|
// TODO add handling for Omnipod pump status
|
||||||
|
|
|
@ -4,14 +4,6 @@ package info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service;
|
||||||
* Created by andy on 10/23/18.
|
* Created by andy on 10/23/18.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import android.bluetooth.BluetoothAdapter;
|
import android.bluetooth.BluetoothAdapter;
|
||||||
import android.content.BroadcastReceiver;
|
import android.content.BroadcastReceiver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
@ -19,6 +11,14 @@ import android.content.Intent;
|
||||||
import android.content.IntentFilter;
|
import android.content.IntentFilter;
|
||||||
import android.support.v4.content.LocalBroadcastManager;
|
import android.support.v4.content.LocalBroadcastManager;
|
||||||
|
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import info.nightscout.androidaps.logging.L;
|
import info.nightscout.androidaps.logging.L;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkConst;
|
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkConst;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkUtil;
|
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkUtil;
|
||||||
|
@ -61,22 +61,21 @@ public class RileyLinkBroadcastReceiver extends BroadcastReceiver {
|
||||||
|
|
||||||
// Bluetooth
|
// Bluetooth
|
||||||
this.broadcastIdentifiers.put("Bluetooth", Arrays.asList( //
|
this.broadcastIdentifiers.put("Bluetooth", Arrays.asList( //
|
||||||
RileyLinkConst.Intents.BluetoothConnected, //
|
RileyLinkConst.Intents.BluetoothConnected, //
|
||||||
RileyLinkConst.Intents.BluetoothReconnected, //
|
RileyLinkConst.Intents.BluetoothReconnected));
|
||||||
RileyLinkConst.Intents.BluetoothReconnected));
|
|
||||||
|
|
||||||
// TuneUp
|
// TuneUp
|
||||||
this.broadcastIdentifiers.put("TuneUp", Arrays.asList( //
|
this.broadcastIdentifiers.put("TuneUp", Arrays.asList( //
|
||||||
RileyLinkConst.IPC.MSG_PUMP_tunePump, //
|
RileyLinkConst.IPC.MSG_PUMP_tunePump, //
|
||||||
RileyLinkConst.IPC.MSG_PUMP_quickTune));
|
RileyLinkConst.IPC.MSG_PUMP_quickTune));
|
||||||
|
|
||||||
// RileyLink
|
// RileyLink
|
||||||
this.broadcastIdentifiers.put("RileyLink", Arrays.asList( //
|
this.broadcastIdentifiers.put("RileyLink", Arrays.asList( //
|
||||||
RileyLinkConst.Intents.RileyLinkDisconnected, //
|
RileyLinkConst.Intents.RileyLinkDisconnected, //
|
||||||
RileyLinkConst.Intents.RileyLinkReady, //
|
RileyLinkConst.Intents.RileyLinkReady, //
|
||||||
RileyLinkConst.Intents.RileyLinkDisconnected, //
|
RileyLinkConst.Intents.RileyLinkDisconnected, //
|
||||||
RileyLinkConst.Intents.RileyLinkNewAddressSet, //
|
RileyLinkConst.Intents.RileyLinkNewAddressSet, //
|
||||||
RileyLinkConst.Intents.RileyLinkDisconnect));
|
RileyLinkConst.Intents.RileyLinkDisconnect));
|
||||||
|
|
||||||
// Device Specific
|
// Device Specific
|
||||||
deviceSpecificPrefix = serviceInstance.getDeviceSpecificBroadcastsIdentifierPrefix();
|
deviceSpecificPrefix = serviceInstance.getDeviceSpecificBroadcastsIdentifierPrefix();
|
||||||
|
@ -100,10 +99,10 @@ public class RileyLinkBroadcastReceiver extends BroadcastReceiver {
|
||||||
LOG.debug("Received Broadcast: " + action);
|
LOG.debug("Received Broadcast: " + action);
|
||||||
|
|
||||||
if (!processBluetoothBroadcasts(action) && //
|
if (!processBluetoothBroadcasts(action) && //
|
||||||
!processRileyLinkBroadcasts(action) && //
|
!processRileyLinkBroadcasts(action) && //
|
||||||
!processTuneUpBroadcasts(action) && //
|
!processTuneUpBroadcasts(action) && //
|
||||||
!processDeviceSpecificBroadcasts(action, intent) && //
|
!processDeviceSpecificBroadcasts(action, intent) && //
|
||||||
!processApplicationSpecificBroadcasts(action, intent) //
|
!processApplicationSpecificBroadcasts(action, intent) //
|
||||||
) {
|
) {
|
||||||
LOG.error("Unhandled broadcast: action=" + action);
|
LOG.error("Unhandled broadcast: action=" + action);
|
||||||
}
|
}
|
||||||
|
@ -136,7 +135,7 @@ public class RileyLinkBroadcastReceiver extends BroadcastReceiver {
|
||||||
if (action.equals(RileyLinkConst.Intents.RileyLinkDisconnected)) {
|
if (action.equals(RileyLinkConst.Intents.RileyLinkDisconnected)) {
|
||||||
if (BluetoothAdapter.getDefaultAdapter().isEnabled()) {
|
if (BluetoothAdapter.getDefaultAdapter().isEnabled()) {
|
||||||
RileyLinkUtil
|
RileyLinkUtil
|
||||||
.setServiceState(RileyLinkServiceState.BluetoothError, RileyLinkError.RileyLinkUnreachable);
|
.setServiceState(RileyLinkServiceState.BluetoothError, RileyLinkError.RileyLinkUnreachable);
|
||||||
} else {
|
} else {
|
||||||
RileyLinkUtil.setServiceState(RileyLinkServiceState.BluetoothError, RileyLinkError.BluetoothDisabled);
|
RileyLinkUtil.setServiceState(RileyLinkServiceState.BluetoothError, RileyLinkError.BluetoothDisabled);
|
||||||
}
|
}
|
||||||
|
@ -148,7 +147,7 @@ public class RileyLinkBroadcastReceiver extends BroadcastReceiver {
|
||||||
LOG.warn("MedtronicConst.Intents.RileyLinkReady");
|
LOG.warn("MedtronicConst.Intents.RileyLinkReady");
|
||||||
// sendIPCNotification(RT2Const.IPC.MSG_note_WakingPump);
|
// sendIPCNotification(RT2Const.IPC.MSG_note_WakingPump);
|
||||||
|
|
||||||
if (this.serviceInstance.rileyLinkBLE==null)
|
if (this.serviceInstance.rileyLinkBLE == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
this.serviceInstance.rileyLinkBLE.enableNotifications();
|
this.serviceInstance.rileyLinkBLE.enableNotifications();
|
||||||
|
@ -159,11 +158,11 @@ public class RileyLinkBroadcastReceiver extends BroadcastReceiver {
|
||||||
RileyLinkFirmwareVersion rlVersion = this.serviceInstance.rfspy.getRLVersionCached();
|
RileyLinkFirmwareVersion rlVersion = this.serviceInstance.rfspy.getRLVersionCached();
|
||||||
|
|
||||||
// if (isLoggingEnabled())
|
// if (isLoggingEnabled())
|
||||||
LOG.debug("RfSpy version (BLE113): " + bleVersion);
|
LOG.debug("RfSpy version (BLE113): " + bleVersion);
|
||||||
this.serviceInstance.rileyLinkServiceData.versionBLE113 = bleVersion;
|
this.serviceInstance.rileyLinkServiceData.versionBLE113 = bleVersion;
|
||||||
|
|
||||||
// if (isLoggingEnabled())
|
// if (isLoggingEnabled())
|
||||||
LOG.debug("RfSpy Radio version (CC110): " + rlVersion.name());
|
LOG.debug("RfSpy Radio version (CC110): " + rlVersion.name());
|
||||||
this.serviceInstance.rileyLinkServiceData.versionCC110 = rlVersion;
|
this.serviceInstance.rileyLinkServiceData.versionCC110 = rlVersion;
|
||||||
|
|
||||||
ServiceTask task = new InitializePumpManagerTask(RileyLinkUtil.getTargetDevice());
|
ServiceTask task = new InitializePumpManagerTask(RileyLinkUtil.getTargetDevice());
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.tasks;
|
package info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.tasks;
|
||||||
|
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.RFSpy;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.data.ServiceTransport;
|
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.data.ServiceTransport;
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.MedtronicFragment;
|
import info.nightscout.androidaps.plugins.pump.medtronic.MedtronicFragment;
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.MedtronicPumpPlugin;
|
import info.nightscout.androidaps.plugins.pump.medtronic.MedtronicPumpPlugin;
|
||||||
|
@ -9,16 +8,16 @@ import info.nightscout.androidaps.plugins.pump.medtronic.service.RileyLinkMedtro
|
||||||
/**
|
/**
|
||||||
* Created by geoff on 7/16/16.
|
* Created by geoff on 7/16/16.
|
||||||
*/
|
*/
|
||||||
public class ResetRileyLinkTask extends PumpTask {
|
public class ResetRileyLinkConfigurationTask extends PumpTask {
|
||||||
|
|
||||||
private static final String TAG = "ResetRileyLinkTask";
|
private static final String TAG = "ResetRileyLinkTask";
|
||||||
|
|
||||||
|
|
||||||
public ResetRileyLinkTask() {
|
public ResetRileyLinkConfigurationTask() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public ResetRileyLinkTask(ServiceTransport transport) {
|
public ResetRileyLinkConfigurationTask(ServiceTransport transport) {
|
||||||
super(transport);
|
super(transport);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,7 +26,7 @@ public class ResetRileyLinkTask extends PumpTask {
|
||||||
public void run() {
|
public void run() {
|
||||||
MedtronicFragment.refreshButtonEnabled(false);
|
MedtronicFragment.refreshButtonEnabled(false);
|
||||||
MedtronicPumpPlugin.isBusy = true;
|
MedtronicPumpPlugin.isBusy = true;
|
||||||
RileyLinkMedtronicService.getInstance().resetRileyLinkDevice();
|
RileyLinkMedtronicService.getInstance().resetRileyLinkConfiguration();
|
||||||
MedtronicPumpPlugin.isBusy = false;
|
MedtronicPumpPlugin.isBusy = false;
|
||||||
MedtronicFragment.refreshButtonEnabled(true);
|
MedtronicFragment.refreshButtonEnabled(true);
|
||||||
}
|
}
|
|
@ -9,18 +9,18 @@ import java.util.List;
|
||||||
public class ByteUtil {
|
public class ByteUtil {
|
||||||
|
|
||||||
private final static char[] HEX_DIGITS = {
|
private final static char[] HEX_DIGITS = {
|
||||||
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
|
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
|
||||||
|
|
||||||
private final static String HEX_DIGITS_STR = "0123456789ABCDEF";
|
private final static String HEX_DIGITS_STR = "0123456789ABCDEF";
|
||||||
|
|
||||||
|
|
||||||
public static byte highByte(short s) {
|
public static byte highByte(short s) {
|
||||||
return (byte)(s / 256);
|
return (byte) (s / 256);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static byte lowByte(short s) {
|
public static byte lowByte(short s) {
|
||||||
return (byte)(s % 256);
|
return (byte) (s % 256);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -71,6 +71,15 @@ public class ByteUtil {
|
||||||
return rval;
|
return rval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static byte[] substring(List<Byte> a, int start, int len) {
|
||||||
|
byte[] rval = new byte[len];
|
||||||
|
|
||||||
|
for (int i = start, j = 0; i < start + len; i++, j++) {
|
||||||
|
rval[j] = a.get(i);
|
||||||
|
}
|
||||||
|
return rval;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public static byte[] substring(byte[] a, int start) {
|
public static byte[] substring(byte[] a, int start) {
|
||||||
int len = a.length - start;
|
int len = a.length - start;
|
||||||
|
@ -102,7 +111,7 @@ public class ByteUtil {
|
||||||
public static String showPrintable(byte[] ra) {
|
public static String showPrintable(byte[] ra) {
|
||||||
String s = new String();
|
String s = new String();
|
||||||
for (int i = 0; i < ra.length; i++) {
|
for (int i = 0; i < ra.length; i++) {
|
||||||
char c = (char)ra[i];
|
char c = (char) ra[i];
|
||||||
if (((c >= '0') && (c <= '9')) || ((c >= 'A') && (c <= 'Z')) || ((c >= 'a') && (c <= 'z'))) {
|
if (((c >= '0') && (c <= '9')) || ((c >= 'A') && (c <= 'Z')) || ((c >= 'a') && (c <= 'z'))) {
|
||||||
s = s + c;
|
s = s + c;
|
||||||
} else {
|
} else {
|
||||||
|
@ -115,7 +124,7 @@ public class ByteUtil {
|
||||||
|
|
||||||
public static byte[] fromHexString(String src) {
|
public static byte[] fromHexString(String src) {
|
||||||
String s = src.toUpperCase();
|
String s = src.toUpperCase();
|
||||||
byte[] rval = new byte[] {};
|
byte[] rval = new byte[]{};
|
||||||
if ((s.length() % 2) != 0) {
|
if ((s.length() % 2) != 0) {
|
||||||
// invalid hex string!
|
// invalid hex string!
|
||||||
return null;
|
return null;
|
||||||
|
@ -131,7 +140,7 @@ public class ByteUtil {
|
||||||
// Not a hex digit
|
// Not a hex digit
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
rval = concat(rval, (byte)(highNibbleOrd * 16 + lowNibbleOrd));
|
rval = concat(rval, (byte) (highNibbleOrd * 16 + lowNibbleOrd));
|
||||||
}
|
}
|
||||||
return rval;
|
return rval;
|
||||||
}
|
}
|
||||||
|
@ -201,10 +210,10 @@ public class ByteUtil {
|
||||||
/**
|
/**
|
||||||
* Converts 4 (or less) ints into int. (Shorts are objects, so you can send null if you have less parameters)
|
* Converts 4 (or less) ints into int. (Shorts are objects, so you can send null if you have less parameters)
|
||||||
*
|
*
|
||||||
* @param b1 short 1
|
* @param b1 short 1
|
||||||
* @param b2 short 2
|
* @param b2 short 2
|
||||||
* @param b3 short 3
|
* @param b3 short 3
|
||||||
* @param b4 short 4
|
* @param b4 short 4
|
||||||
* @param flag Conversion Flag (Big Endian, Little endian)
|
* @param flag Conversion Flag (Big Endian, Little endian)
|
||||||
* @return int value
|
* @return int value
|
||||||
*/
|
*/
|
||||||
|
@ -266,7 +275,7 @@ public class ByteUtil {
|
||||||
* @return the correct hex value
|
* @return the correct hex value
|
||||||
*/
|
*/
|
||||||
public static String getCorrectHexValue(int inp) {
|
public static String getCorrectHexValue(int inp) {
|
||||||
String hx = Integer.toHexString((char)inp);
|
String hx = Integer.toHexString((char) inp);
|
||||||
|
|
||||||
if (hx.length() == 0)
|
if (hx.length() == 0)
|
||||||
return "00";
|
return "00";
|
||||||
|
@ -332,7 +341,7 @@ public class ByteUtil {
|
||||||
|
|
||||||
|
|
||||||
public static String getHexCompact(byte byte0) {
|
public static String getHexCompact(byte byte0) {
|
||||||
int i = byte0 != -1 ? convertUnsignedByteToInt(byte0) : (int)byte0;
|
int i = byte0 != -1 ? convertUnsignedByteToInt(byte0) : (int) byte0;
|
||||||
return getHexCompact(i);
|
return getHexCompact(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -418,8 +427,8 @@ public class ByteUtil {
|
||||||
int len = data.length();
|
int len = data.length();
|
||||||
byte[] outArray = new byte[len / 2];
|
byte[] outArray = new byte[len / 2];
|
||||||
for (int i = 0; i < len; i += 2) {
|
for (int i = 0; i < len; i += 2) {
|
||||||
outArray[i / 2] = (byte)((Character.digit(data.charAt(i), 16) << 4) + Character.digit(data.charAt(i + 1),
|
outArray[i / 2] = (byte) ((Character.digit(data.charAt(i), 16) << 4) + Character.digit(data.charAt(i + 1),
|
||||||
16));
|
16));
|
||||||
}
|
}
|
||||||
|
|
||||||
return outArray;
|
return outArray;
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.common.utils;
|
package info.nightscout.androidaps.plugins.pump.common.utils;
|
||||||
|
|
||||||
|
import org.joda.time.LocalDateTime;
|
||||||
|
|
||||||
import java.nio.charset.Charset;
|
import java.nio.charset.Charset;
|
||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
import org.joda.time.LocalDateTime;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by geoff on 4/28/15.
|
* Created by geoff on 4/28/15.
|
||||||
|
@ -12,7 +13,7 @@ import org.joda.time.LocalDateTime;
|
||||||
public class StringUtil {
|
public class StringUtil {
|
||||||
|
|
||||||
public static DecimalFormat DecimalFormaters[] = {
|
public static DecimalFormat DecimalFormaters[] = {
|
||||||
new DecimalFormat("#0"), new DecimalFormat("#0.0"), new DecimalFormat("#0.00"), new DecimalFormat("#0.000") };
|
new DecimalFormat("#0"), new DecimalFormat("#0.0"), new DecimalFormat("#0.00"), new DecimalFormat("#0.000")};
|
||||||
|
|
||||||
|
|
||||||
public static String fromBytes(byte[] ra) {
|
public static String fromBytes(byte[] ra) {
|
||||||
|
@ -97,7 +98,20 @@ public class StringUtil {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static void splitString(String s, int characters) {
|
public static List<String> splitString(String s, int characters) {
|
||||||
|
|
||||||
|
List<String> outString = new ArrayList<>();
|
||||||
|
|
||||||
|
do {
|
||||||
|
if (s.length() > characters) {
|
||||||
|
String token = s.substring(0, characters);
|
||||||
|
outString.add(token);
|
||||||
|
s = s.substring(characters);
|
||||||
|
}
|
||||||
|
} while (s.length() > characters);
|
||||||
|
|
||||||
|
outString.add(s);
|
||||||
|
|
||||||
|
return outString;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,19 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.medtronic;
|
package info.nightscout.androidaps.plugins.pump.medtronic;
|
||||||
|
|
||||||
|
import android.content.ComponentName;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.content.ServiceConnection;
|
||||||
|
import android.os.IBinder;
|
||||||
|
import android.os.SystemClock;
|
||||||
|
import android.support.annotation.NonNull;
|
||||||
|
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
import com.google.gson.GsonBuilder;
|
||||||
|
|
||||||
|
import org.joda.time.LocalDateTime;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
@ -10,22 +24,6 @@ import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.joda.time.LocalDateTime;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import android.content.ComponentName;
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.content.ServiceConnection;
|
|
||||||
import android.os.IBinder;
|
|
||||||
import android.os.SystemClock;
|
|
||||||
import android.support.annotation.NonNull;
|
|
||||||
|
|
||||||
import com.crashlytics.android.answers.CustomEvent;
|
|
||||||
import com.google.gson.Gson;
|
|
||||||
import com.google.gson.GsonBuilder;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.BuildConfig;
|
|
||||||
import info.nightscout.androidaps.MainApp;
|
import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.data.DetailedBolusInfo;
|
import info.nightscout.androidaps.data.DetailedBolusInfo;
|
||||||
|
@ -48,7 +46,7 @@ import info.nightscout.androidaps.plugins.pump.common.defs.PumpDriverState;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.defs.PumpType;
|
import info.nightscout.androidaps.plugins.pump.common.defs.PumpType;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkConst;
|
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkConst;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkServiceState;
|
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkServiceState;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.tasks.ResetRileyLinkTask;
|
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.tasks.ResetRileyLinkConfigurationTask;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.tasks.ServiceTaskExecutor;
|
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.tasks.ServiceTaskExecutor;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.tasks.WakeAndTuneTask;
|
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.tasks.WakeAndTuneTask;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.utils.DateTimeUtil;
|
import info.nightscout.androidaps.plugins.pump.common.utils.DateTimeUtil;
|
||||||
|
@ -66,14 +64,12 @@ import info.nightscout.androidaps.plugins.pump.medtronic.defs.MedtronicCommandTy
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.defs.MedtronicCustomActionType;
|
import info.nightscout.androidaps.plugins.pump.medtronic.defs.MedtronicCustomActionType;
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.defs.MedtronicNotificationType;
|
import info.nightscout.androidaps.plugins.pump.medtronic.defs.MedtronicNotificationType;
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.defs.MedtronicStatusRefreshType;
|
import info.nightscout.androidaps.plugins.pump.medtronic.defs.MedtronicStatusRefreshType;
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.dialog.MedtronicHistoryActivity;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.driver.MedtronicPumpStatus;
|
import info.nightscout.androidaps.plugins.pump.medtronic.driver.MedtronicPumpStatus;
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.events.EventMedtronicPumpValuesChanged;
|
import info.nightscout.androidaps.plugins.pump.medtronic.events.EventMedtronicPumpValuesChanged;
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.service.RileyLinkMedtronicService;
|
import info.nightscout.androidaps.plugins.pump.medtronic.service.RileyLinkMedtronicService;
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicConst;
|
import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicConst;
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicUtil;
|
import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicUtil;
|
||||||
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin;
|
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin;
|
||||||
import info.nightscout.androidaps.utils.FabricPrivacy;
|
|
||||||
import info.nightscout.androidaps.utils.SP;
|
import info.nightscout.androidaps.utils.SP;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -103,7 +99,7 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
|
||||||
|
|
||||||
public static Gson gsonInstance = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create();
|
public static Gson gsonInstance = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create();
|
||||||
public static Gson gsonInstancePretty = new GsonBuilder().excludeFieldsWithoutExposeAnnotation()
|
public static Gson gsonInstancePretty = new GsonBuilder().excludeFieldsWithoutExposeAnnotation()
|
||||||
.setPrettyPrinting().create();
|
.setPrettyPrinting().create();
|
||||||
|
|
||||||
public static boolean isBusy = false;
|
public static boolean isBusy = false;
|
||||||
private List<Long> busyTimestamps = new ArrayList<>();
|
private List<Long> busyTimestamps = new ArrayList<>();
|
||||||
|
@ -113,12 +109,12 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
|
||||||
private MedtronicPumpPlugin() {
|
private MedtronicPumpPlugin() {
|
||||||
|
|
||||||
super(new PluginDescription() //
|
super(new PluginDescription() //
|
||||||
.mainType(PluginType.PUMP) //
|
.mainType(PluginType.PUMP) //
|
||||||
.fragmentClass(MedtronicFragment.class.getName()) //
|
.fragmentClass(MedtronicFragment.class.getName()) //
|
||||||
.pluginName(R.string.medtronic_name) //
|
.pluginName(R.string.medtronic_name) //
|
||||||
.shortName(R.string.medtronic_name_short) //
|
.shortName(R.string.medtronic_name_short) //
|
||||||
.preferencesId(R.xml.pref_medtronic).description(R.string.description_pump_medtronic), //
|
.preferencesId(R.xml.pref_medtronic).description(R.string.description_pump_medtronic), //
|
||||||
PumpType.Medtronic_522_722 // we default to most basic model, correct model from config is loaded later
|
PumpType.Medtronic_522_722 // we default to most basic model, correct model from config is loaded later
|
||||||
);
|
);
|
||||||
|
|
||||||
// TODO remove this later
|
// TODO remove this later
|
||||||
|
@ -139,7 +135,7 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
|
||||||
public void onServiceConnected(ComponentName name, IBinder service) {
|
public void onServiceConnected(ComponentName name, IBinder service) {
|
||||||
if (isLoggingEnabled())
|
if (isLoggingEnabled())
|
||||||
LOG.debug("RileyLinkMedtronicService is connected");
|
LOG.debug("RileyLinkMedtronicService is connected");
|
||||||
RileyLinkMedtronicService.LocalBinder mLocalBinder = (RileyLinkMedtronicService.LocalBinder)service;
|
RileyLinkMedtronicService.LocalBinder mLocalBinder = (RileyLinkMedtronicService.LocalBinder) service;
|
||||||
medtronicService = mLocalBinder.getServiceInstance();
|
medtronicService = mLocalBinder.getServiceInstance();
|
||||||
|
|
||||||
new Thread(() -> {
|
new Thread(() -> {
|
||||||
|
@ -237,12 +233,12 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
|
||||||
if (this.isInitialized) {
|
if (this.isInitialized) {
|
||||||
|
|
||||||
Map<MedtronicStatusRefreshType, Long> statusRefresh = workWithStatusRefresh(
|
Map<MedtronicStatusRefreshType, Long> statusRefresh = workWithStatusRefresh(
|
||||||
StatusRefreshAction.GetData, null, null);
|
StatusRefreshAction.GetData, null, null);
|
||||||
|
|
||||||
if (doWeHaveAnyStatusNeededRefereshing(statusRefresh)) {
|
if (doWeHaveAnyStatusNeededRefereshing(statusRefresh)) {
|
||||||
if (!ConfigBuilderPlugin.getPlugin().getCommandQueue().statusInQueue()) {
|
if (!ConfigBuilderPlugin.getPlugin().getCommandQueue().statusInQueue()) {
|
||||||
ConfigBuilderPlugin.getPlugin().getCommandQueue()
|
ConfigBuilderPlugin.getPlugin().getCommandQueue()
|
||||||
.readStatus("Scheduled Status Refresh", null);
|
.readStatus("Scheduled Status Refresh", null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -388,8 +384,8 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
|
||||||
RileyLinkServiceState rileyLinkServiceState = MedtronicUtil.getServiceState();
|
RileyLinkServiceState rileyLinkServiceState = MedtronicUtil.getServiceState();
|
||||||
|
|
||||||
if (rileyLinkServiceState != RileyLinkServiceState.PumpConnectorReady //
|
if (rileyLinkServiceState != RileyLinkServiceState.PumpConnectorReady //
|
||||||
&& rileyLinkServiceState != RileyLinkServiceState.RileyLinkReady //
|
&& rileyLinkServiceState != RileyLinkServiceState.RileyLinkReady //
|
||||||
&& rileyLinkServiceState != RileyLinkServiceState.TuneUpDevice) {
|
&& rileyLinkServiceState != RileyLinkServiceState.TuneUpDevice) {
|
||||||
if (isLoggingEnabled())
|
if (isLoggingEnabled())
|
||||||
LOG.error("RileyLink unreachable.");
|
LOG.error("RileyLink unreachable.");
|
||||||
return false;
|
return false;
|
||||||
|
@ -402,7 +398,7 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
|
||||||
private void refreshAnyStatusThatNeedsToBeRefreshed() {
|
private void refreshAnyStatusThatNeedsToBeRefreshed() {
|
||||||
|
|
||||||
Map<MedtronicStatusRefreshType, Long> statusRefresh = workWithStatusRefresh(StatusRefreshAction.GetData, null,
|
Map<MedtronicStatusRefreshType, Long> statusRefresh = workWithStatusRefresh(StatusRefreshAction.GetData, null,
|
||||||
null);
|
null);
|
||||||
|
|
||||||
if (!doWeHaveAnyStatusNeededRefereshing(statusRefresh)) {
|
if (!doWeHaveAnyStatusNeededRefereshing(statusRefresh)) {
|
||||||
return;
|
return;
|
||||||
|
@ -433,7 +429,7 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
|
||||||
case PumpHistory: {
|
case PumpHistory: {
|
||||||
readPumpHistory();
|
readPumpHistory();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PumpTime:
|
case PumpTime:
|
||||||
case BatteryStatus:
|
case BatteryStatus:
|
||||||
|
@ -442,13 +438,13 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
|
||||||
refreshTypesNeededToReschedule.add(refreshType.getKey());
|
refreshTypesNeededToReschedule.add(refreshType.getKey());
|
||||||
resetTime = true;
|
resetTime = true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Configuration: {
|
case Configuration: {
|
||||||
medtronicUIComm.executeCommand(refreshType.getKey().getCommandType());
|
medtronicUIComm.executeCommand(refreshType.getKey().getCommandType());
|
||||||
resetTime = true;
|
resetTime = true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -566,7 +562,6 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
|
||||||
if (!sendIdToFirebase) {
|
if (!sendIdToFirebase) {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
sendIdToFirebase = true;
|
sendIdToFirebase = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -606,7 +601,7 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
|
||||||
|
|
||||||
if (isLoggingEnabled())
|
if (isLoggingEnabled())
|
||||||
LOG.debug("Current Basals (h): "
|
LOG.debug("Current Basals (h): "
|
||||||
+ (basalsByHour == null ? "null" : BasalProfile.getProfilesByHourToString(basalsByHour)));
|
+ (basalsByHour == null ? "null" : BasalProfile.getProfilesByHourToString(basalsByHour)));
|
||||||
|
|
||||||
// int index = 0;
|
// int index = 0;
|
||||||
|
|
||||||
|
@ -740,9 +735,9 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
|
||||||
// LOG.debug("MedtronicPumpPlugin::deliverBolus - Start delivery");
|
// LOG.debug("MedtronicPumpPlugin::deliverBolus - Start delivery");
|
||||||
|
|
||||||
MedtronicUITask responseTask = medtronicUIComm.executeCommand(MedtronicCommandType.SetBolus,
|
MedtronicUITask responseTask = medtronicUIComm.executeCommand(MedtronicCommandType.SetBolus,
|
||||||
detailedBolusInfo.insulin);
|
detailedBolusInfo.insulin);
|
||||||
|
|
||||||
Boolean response = (Boolean)responseTask.returnData;
|
Boolean response = (Boolean) responseTask.returnData;
|
||||||
|
|
||||||
setRefreshButtonEnabled(true);
|
setRefreshButtonEnabled(true);
|
||||||
|
|
||||||
|
@ -775,11 +770,11 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
|
||||||
getMDTPumpStatus().reservoirRemainingUnits -= detailedBolusInfo.insulin;
|
getMDTPumpStatus().reservoirRemainingUnits -= detailedBolusInfo.insulin;
|
||||||
|
|
||||||
incrementStatistics(detailedBolusInfo.isSMB ? MedtronicConst.Statistics.SMBBoluses
|
incrementStatistics(detailedBolusInfo.isSMB ? MedtronicConst.Statistics.SMBBoluses
|
||||||
: MedtronicConst.Statistics.StandardBoluses);
|
: MedtronicConst.Statistics.StandardBoluses);
|
||||||
|
|
||||||
// if (response)
|
// if (response)
|
||||||
{
|
{
|
||||||
int bolusTime = (int)(detailedBolusInfo.insulin * 42.0d);
|
int bolusTime = (int) (detailedBolusInfo.insulin * 42.0d);
|
||||||
long time = System.currentTimeMillis() + (bolusTime * 1000);
|
long time = System.currentTimeMillis() + (bolusTime * 1000);
|
||||||
|
|
||||||
this.busyTimestamps.add(time);
|
this.busyTimestamps.add(time);
|
||||||
|
@ -787,15 +782,15 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
|
||||||
}
|
}
|
||||||
|
|
||||||
return new PumpEnactResult().success(true) //
|
return new PumpEnactResult().success(true) //
|
||||||
.enacted(true) //
|
.enacted(true) //
|
||||||
.bolusDelivered(detailedBolusInfo.insulin) //
|
.bolusDelivered(detailedBolusInfo.insulin) //
|
||||||
.carbsDelivered(detailedBolusInfo.carbs);
|
.carbsDelivered(detailedBolusInfo.carbs);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
return new PumpEnactResult() //
|
return new PumpEnactResult() //
|
||||||
.success(bolusDeliveryType == BolusDeliveryType.CancelDelivery) //
|
.success(bolusDeliveryType == BolusDeliveryType.CancelDelivery) //
|
||||||
.enacted(false) //
|
.enacted(false) //
|
||||||
.comment(MainApp.gs(R.string.medtronic_cmd_bolus_could_not_be_delivered));
|
.comment(MainApp.gs(R.string.medtronic_cmd_bolus_could_not_be_delivered));
|
||||||
}
|
}
|
||||||
|
|
||||||
} finally {
|
} finally {
|
||||||
|
@ -815,13 +810,13 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
|
||||||
|
|
||||||
if (success) {
|
if (success) {
|
||||||
return new PumpEnactResult() //
|
return new PumpEnactResult() //
|
||||||
.success(true) //
|
.success(true) //
|
||||||
.enacted(false);
|
.enacted(false);
|
||||||
} else {
|
} else {
|
||||||
return new PumpEnactResult() //
|
return new PumpEnactResult() //
|
||||||
.success(false) //
|
.success(false) //
|
||||||
.enacted(false) //
|
.enacted(false) //
|
||||||
.comment(MainApp.gs(R.string.medtronic_pump_status_pump_unreachable));
|
.comment(MainApp.gs(R.string.medtronic_pump_status_pump_unreachable));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -846,7 +841,7 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
|
||||||
// if false and the same rate is requested enacted=false and success=true is returned and TBR is not changed
|
// if false and the same rate is requested enacted=false and success=true is returned and TBR is not changed
|
||||||
@Override
|
@Override
|
||||||
public PumpEnactResult setTempBasalAbsolute(Double absoluteRate, Integer durationInMinutes, Profile profile,
|
public PumpEnactResult setTempBasalAbsolute(Double absoluteRate, Integer durationInMinutes, Profile profile,
|
||||||
boolean enforceNew) {
|
boolean enforceNew) {
|
||||||
|
|
||||||
setRefreshButtonEnabled(false);
|
setRefreshButtonEnabled(false);
|
||||||
|
|
||||||
|
@ -855,9 +850,9 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
|
||||||
setRefreshButtonEnabled(true);
|
setRefreshButtonEnabled(true);
|
||||||
|
|
||||||
return new PumpEnactResult() //
|
return new PumpEnactResult() //
|
||||||
.success(false) //
|
.success(false) //
|
||||||
.enacted(false) //
|
.enacted(false) //
|
||||||
.comment(MainApp.gs(R.string.medtronic_pump_status_pump_unreachable));
|
.comment(MainApp.gs(R.string.medtronic_pump_status_pump_unreachable));
|
||||||
}
|
}
|
||||||
|
|
||||||
MedtronicUtil.dismissNotification(MedtronicNotificationType.PumpUnreachable);
|
MedtronicUtil.dismissNotification(MedtronicNotificationType.PumpUnreachable);
|
||||||
|
@ -875,11 +870,11 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
|
||||||
LOG.warn(getLogPrefix() + "setTempBasalAbsolute - Could not read current TBR, canceling operation.");
|
LOG.warn(getLogPrefix() + "setTempBasalAbsolute - Could not read current TBR, canceling operation.");
|
||||||
finishAction("TBR");
|
finishAction("TBR");
|
||||||
return new PumpEnactResult().success(false).enacted(false)
|
return new PumpEnactResult().success(false).enacted(false)
|
||||||
.comment(MainApp.gs(R.string.medtronic_cmd_cant_read_tbr));
|
.comment(MainApp.gs(R.string.medtronic_cmd_cant_read_tbr));
|
||||||
} else {
|
} else {
|
||||||
if (isLoggingEnabled())
|
if (isLoggingEnabled())
|
||||||
LOG.info(getLogPrefix() + "setTempBasalAbsolute: Current Basal: duration: {} min, rate={}",
|
LOG.info(getLogPrefix() + "setTempBasalAbsolute: Current Basal: duration: {} min, rate={}",
|
||||||
tbrCurrent.getDurationMinutes(), tbrCurrent.getInsulinRate());
|
tbrCurrent.getDurationMinutes(), tbrCurrent.getInsulinRate());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!enforceNew) {
|
if (!enforceNew) {
|
||||||
|
@ -911,7 +906,7 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
|
||||||
|
|
||||||
MedtronicUITask responseTask2 = medtronicUIComm.executeCommand(MedtronicCommandType.CancelTBR);
|
MedtronicUITask responseTask2 = medtronicUIComm.executeCommand(MedtronicCommandType.CancelTBR);
|
||||||
|
|
||||||
Boolean response = (Boolean)responseTask2.returnData;
|
Boolean response = (Boolean) responseTask2.returnData;
|
||||||
|
|
||||||
if (response) {
|
if (response) {
|
||||||
if (isLoggingEnabled())
|
if (isLoggingEnabled())
|
||||||
|
@ -923,15 +918,15 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
|
||||||
finishAction("TBR");
|
finishAction("TBR");
|
||||||
|
|
||||||
return new PumpEnactResult().success(false).enacted(false)
|
return new PumpEnactResult().success(false).enacted(false)
|
||||||
.comment(MainApp.gs(R.string.medtronic_cmd_cant_cancel_tbr_stop_op));
|
.comment(MainApp.gs(R.string.medtronic_cmd_cant_cancel_tbr_stop_op));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// now start new TBR
|
// now start new TBR
|
||||||
MedtronicUITask responseTask = medtronicUIComm.executeCommand(MedtronicCommandType.SetTemporaryBasal,
|
MedtronicUITask responseTask = medtronicUIComm.executeCommand(MedtronicCommandType.SetTemporaryBasal,
|
||||||
absoluteRate, durationInMinutes);
|
absoluteRate, durationInMinutes);
|
||||||
|
|
||||||
Boolean response = (Boolean)responseTask.returnData;
|
Boolean response = (Boolean) responseTask.returnData;
|
||||||
|
|
||||||
if (isLoggingEnabled())
|
if (isLoggingEnabled())
|
||||||
LOG.info(getLogPrefix() + "setTempBasalAbsolute - setTBR. Response: " + response);
|
LOG.info(getLogPrefix() + "setTempBasalAbsolute - setTBR. Response: " + response);
|
||||||
|
@ -943,10 +938,10 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
|
||||||
pumpStatusLocal.tempBasalLength = durationInMinutes;
|
pumpStatusLocal.tempBasalLength = durationInMinutes;
|
||||||
|
|
||||||
TemporaryBasal tempStart = new TemporaryBasal() //
|
TemporaryBasal tempStart = new TemporaryBasal() //
|
||||||
.date(System.currentTimeMillis()) //
|
.date(System.currentTimeMillis()) //
|
||||||
.duration(durationInMinutes) //
|
.duration(durationInMinutes) //
|
||||||
.absolute(absoluteRate) //
|
.absolute(absoluteRate) //
|
||||||
.source(Source.USER);
|
.source(Source.USER);
|
||||||
|
|
||||||
TreatmentsPlugin.getPlugin().addToHistoryTempBasal(tempStart);
|
TreatmentsPlugin.getPlugin().addToHistoryTempBasal(tempStart);
|
||||||
|
|
||||||
|
@ -955,13 +950,13 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
|
||||||
finishAction("TBR");
|
finishAction("TBR");
|
||||||
|
|
||||||
return new PumpEnactResult().success(true).enacted(true) //
|
return new PumpEnactResult().success(true).enacted(true) //
|
||||||
.absolute(absoluteRate).duration(durationInMinutes);
|
.absolute(absoluteRate).duration(durationInMinutes);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
finishAction("TBR");
|
finishAction("TBR");
|
||||||
|
|
||||||
return new PumpEnactResult().success(false).enacted(false) //
|
return new PumpEnactResult().success(false).enacted(false) //
|
||||||
.comment(MainApp.gs(R.string.medtronic_cmd_tbr_could_not_be_delivered));
|
.comment(MainApp.gs(R.string.medtronic_cmd_tbr_could_not_be_delivered));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -996,7 +991,7 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.getMDTPumpStatus().basalProfileStatus != BasalProfileStatus.NotInitialized
|
if (this.getMDTPumpStatus().basalProfileStatus != BasalProfileStatus.NotInitialized
|
||||||
&& medtronicHistoryData.hasBasalProfileChanged()) {
|
&& medtronicHistoryData.hasBasalProfileChanged()) {
|
||||||
medtronicHistoryData.processLastBasalProfileChange(getMDTPumpStatus());
|
medtronicHistoryData.processLastBasalProfileChange(getMDTPumpStatus());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1040,14 +1035,14 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
|
||||||
if (lastPumpHistoryEntryTime == 0L) {
|
if (lastPumpHistoryEntryTime == 0L) {
|
||||||
if (isLoggingEnabled())
|
if (isLoggingEnabled())
|
||||||
LOG.debug(getLogPrefix() + "readPumpHistoryLogic(): lastPumpHistoryEntryTime: 0L - targetDate: "
|
LOG.debug(getLogPrefix() + "readPumpHistoryLogic(): lastPumpHistoryEntryTime: 0L - targetDate: "
|
||||||
+ targetDate);
|
+ targetDate);
|
||||||
targetDate = timeMinus36h;
|
targetDate = timeMinus36h;
|
||||||
} else {
|
} else {
|
||||||
// LocalDateTime lastHistoryRecordTime = DateTimeUtil.toLocalDateTime(lastPumpHistoryEntryTime);
|
// LocalDateTime lastHistoryRecordTime = DateTimeUtil.toLocalDateTime(lastPumpHistoryEntryTime);
|
||||||
|
|
||||||
if (isLoggingEnabled())
|
if (isLoggingEnabled())
|
||||||
LOG.debug(getLogPrefix() + "readPumpHistoryLogic(): lastPumpHistoryEntryTime: {} - targetDate: {}",
|
LOG.debug(getLogPrefix() + "readPumpHistoryLogic(): lastPumpHistoryEntryTime: {} - targetDate: {}",
|
||||||
lastPumpHistoryEntryTime, targetDate);
|
lastPumpHistoryEntryTime, targetDate);
|
||||||
|
|
||||||
medtronicHistoryData.setLastHistoryRecordTime(lastPumpHistoryEntryTime);
|
medtronicHistoryData.setLastHistoryRecordTime(lastPumpHistoryEntryTime);
|
||||||
|
|
||||||
|
@ -1069,7 +1064,7 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
|
||||||
} else {
|
} else {
|
||||||
if (isLoggingEnabled())
|
if (isLoggingEnabled())
|
||||||
LOG.debug(getLogPrefix() + "readPumpHistoryLogic(): lastPumpHistoryEntry: not null - {}",
|
LOG.debug(getLogPrefix() + "readPumpHistoryLogic(): lastPumpHistoryEntry: not null - {}",
|
||||||
gsonInstancePretty.toJson(lastPumpHistoryEntry));
|
gsonInstancePretty.toJson(lastPumpHistoryEntry));
|
||||||
medtronicHistoryData.setIsInInit(false);
|
medtronicHistoryData.setIsInInit(false);
|
||||||
// medtronicHistoryData.setLastHistoryRecordTime(lastPumpHistoryEntry.atechDateTime);
|
// medtronicHistoryData.setLastHistoryRecordTime(lastPumpHistoryEntry.atechDateTime);
|
||||||
|
|
||||||
|
@ -1079,11 +1074,11 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
|
||||||
LOG.debug("HST: Target Date: {}", targetDate);
|
LOG.debug("HST: Target Date: {}", targetDate);
|
||||||
|
|
||||||
MedtronicUITask responseTask2 = medtronicUIComm.executeCommand(MedtronicCommandType.GetHistoryData,
|
MedtronicUITask responseTask2 = medtronicUIComm.executeCommand(MedtronicCommandType.GetHistoryData,
|
||||||
lastPumpHistoryEntry, targetDate);
|
lastPumpHistoryEntry, targetDate);
|
||||||
|
|
||||||
LOG.debug("HST: After task");
|
LOG.debug("HST: After task");
|
||||||
|
|
||||||
PumpHistoryResult historyResult = (PumpHistoryResult)responseTask2.returnData;
|
PumpHistoryResult historyResult = (PumpHistoryResult) responseTask2.returnData;
|
||||||
|
|
||||||
LOG.debug("HST: History Result: {}", historyResult.toString());
|
LOG.debug("HST: History Result: {}", historyResult.toString());
|
||||||
|
|
||||||
|
@ -1099,7 +1094,7 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
|
||||||
SP.putLong(MedtronicConst.Statistics.LastPumpHistoryEntry, latestEntry.atechDateTime);
|
SP.putLong(MedtronicConst.Statistics.LastPumpHistoryEntry, latestEntry.atechDateTime);
|
||||||
|
|
||||||
LOG.debug("HST: History: valid={}, unprocessed={}", historyResult.validEntries.size(),
|
LOG.debug("HST: History: valid={}, unprocessed={}", historyResult.validEntries.size(),
|
||||||
historyResult.unprocessedEntries.size());
|
historyResult.unprocessedEntries.size());
|
||||||
|
|
||||||
this.medtronicHistoryData.addNewHistory(historyResult);
|
this.medtronicHistoryData.addNewHistory(historyResult);
|
||||||
this.medtronicHistoryData.filterNewEntries();
|
this.medtronicHistoryData.filterNewEntries();
|
||||||
|
@ -1147,15 +1142,15 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
|
||||||
|
|
||||||
workWithStatusRefresh(StatusRefreshAction.Add, refreshType, getTimeInFutureFromMinutes(min));
|
workWithStatusRefresh(StatusRefreshAction.Add, refreshType, getTimeInFutureFromMinutes(min));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PumpTime:
|
case PumpTime:
|
||||||
case Configuration:
|
case Configuration:
|
||||||
case PumpHistory: {
|
case PumpHistory: {
|
||||||
workWithStatusRefresh(StatusRefreshAction.Add, refreshType,
|
workWithStatusRefresh(StatusRefreshAction.Add, refreshType,
|
||||||
getTimeInFutureFromMinutes(refreshType.getRefreshTime() + additionalTimeInMinutes));
|
getTimeInFutureFromMinutes(refreshType.getRefreshTime() + additionalTimeInMinutes));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1166,7 +1161,7 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
|
||||||
|
|
||||||
|
|
||||||
private synchronized Map<MedtronicStatusRefreshType, Long> workWithStatusRefresh(StatusRefreshAction action,
|
private synchronized Map<MedtronicStatusRefreshType, Long> workWithStatusRefresh(StatusRefreshAction action,
|
||||||
MedtronicStatusRefreshType statusRefreshType, Long time) {
|
MedtronicStatusRefreshType statusRefreshType, Long time) {
|
||||||
|
|
||||||
switch (action) {
|
switch (action) {
|
||||||
|
|
||||||
|
@ -1204,7 +1199,7 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
|
||||||
MedtronicUITask responseTask = medtronicUIComm.executeCommand(MedtronicCommandType.ReadTemporaryBasal);
|
MedtronicUITask responseTask = medtronicUIComm.executeCommand(MedtronicCommandType.ReadTemporaryBasal);
|
||||||
|
|
||||||
if (responseTask.hasData()) {
|
if (responseTask.hasData()) {
|
||||||
TempBasalPair tbr = (TempBasalPair)responseTask.returnData;
|
TempBasalPair tbr = (TempBasalPair) responseTask.returnData;
|
||||||
|
|
||||||
// we sometimes get rate returned even if TBR is no longer running
|
// we sometimes get rate returned even if TBR is no longer running
|
||||||
if (tbr.getDurationMinutes() == 0) {
|
if (tbr.getDurationMinutes() == 0) {
|
||||||
|
@ -1229,9 +1224,9 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
|
||||||
setRefreshButtonEnabled(true);
|
setRefreshButtonEnabled(true);
|
||||||
|
|
||||||
return new PumpEnactResult() //
|
return new PumpEnactResult() //
|
||||||
.success(false) //
|
.success(false) //
|
||||||
.enacted(false) //
|
.enacted(false) //
|
||||||
.comment(MainApp.gs(R.string.medtronic_pump_status_pump_unreachable));
|
.comment(MainApp.gs(R.string.medtronic_pump_status_pump_unreachable));
|
||||||
}
|
}
|
||||||
|
|
||||||
MedtronicUtil.dismissNotification(MedtronicNotificationType.PumpUnreachable);
|
MedtronicUtil.dismissNotification(MedtronicNotificationType.PumpUnreachable);
|
||||||
|
@ -1251,12 +1246,12 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
|
||||||
LOG.warn(getLogPrefix() + "cancelTempBasal - Could not read currect TBR, canceling operation.");
|
LOG.warn(getLogPrefix() + "cancelTempBasal - Could not read currect TBR, canceling operation.");
|
||||||
finishAction("TBR");
|
finishAction("TBR");
|
||||||
return new PumpEnactResult().success(false).enacted(false)
|
return new PumpEnactResult().success(false).enacted(false)
|
||||||
.comment(MainApp.gs(R.string.medtronic_cmd_cant_read_tbr));
|
.comment(MainApp.gs(R.string.medtronic_cmd_cant_read_tbr));
|
||||||
}
|
}
|
||||||
|
|
||||||
MedtronicUITask responseTask2 = medtronicUIComm.executeCommand(MedtronicCommandType.CancelTBR);
|
MedtronicUITask responseTask2 = medtronicUIComm.executeCommand(MedtronicCommandType.CancelTBR);
|
||||||
|
|
||||||
Boolean response = (Boolean)responseTask2.returnData;
|
Boolean response = (Boolean) responseTask2.returnData;
|
||||||
|
|
||||||
finishAction("TBR");
|
finishAction("TBR");
|
||||||
|
|
||||||
|
@ -1265,20 +1260,20 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
|
||||||
LOG.info(getLogPrefix() + "cancelTempBasal - Cancel TBR successful.");
|
LOG.info(getLogPrefix() + "cancelTempBasal - Cancel TBR successful.");
|
||||||
|
|
||||||
TemporaryBasal tempBasal = new TemporaryBasal() //
|
TemporaryBasal tempBasal = new TemporaryBasal() //
|
||||||
.date(System.currentTimeMillis()) //
|
.date(System.currentTimeMillis()) //
|
||||||
.duration(0) //
|
.duration(0) //
|
||||||
.source(Source.USER);
|
.source(Source.USER);
|
||||||
|
|
||||||
TreatmentsPlugin.getPlugin().addToHistoryTempBasal(tempBasal);
|
TreatmentsPlugin.getPlugin().addToHistoryTempBasal(tempBasal);
|
||||||
|
|
||||||
return new PumpEnactResult().success(true).enacted(true) //
|
return new PumpEnactResult().success(true).enacted(true) //
|
||||||
.isTempCancel(true);
|
.isTempCancel(true);
|
||||||
} else {
|
} else {
|
||||||
if (isLoggingEnabled())
|
if (isLoggingEnabled())
|
||||||
LOG.info(getLogPrefix() + "cancelTempBasal - Cancel TBR failed.");
|
LOG.info(getLogPrefix() + "cancelTempBasal - Cancel TBR failed.");
|
||||||
|
|
||||||
return new PumpEnactResult().success(response).enacted(response) //
|
return new PumpEnactResult().success(response).enacted(response) //
|
||||||
.comment(MainApp.gs(R.string.medtronic_cmd_cant_cancel_tbr));
|
.comment(MainApp.gs(R.string.medtronic_cmd_cant_cancel_tbr));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1291,9 +1286,9 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
|
||||||
// this shouldn't be needed, but let's do check if profile setting we are setting is same as current one
|
// this shouldn't be needed, but let's do check if profile setting we are setting is same as current one
|
||||||
if (isProfileSame(profile)) {
|
if (isProfileSame(profile)) {
|
||||||
return new PumpEnactResult() //
|
return new PumpEnactResult() //
|
||||||
.success(true) //
|
.success(true) //
|
||||||
.enacted(false) //
|
.enacted(false) //
|
||||||
.comment(MainApp.gs(R.string.medtronic_cmd_basal_profile_not_set_is_same));
|
.comment(MainApp.gs(R.string.medtronic_cmd_basal_profile_not_set_is_same));
|
||||||
}
|
}
|
||||||
|
|
||||||
setRefreshButtonEnabled(false);
|
setRefreshButtonEnabled(false);
|
||||||
|
@ -1303,9 +1298,9 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
|
||||||
setRefreshButtonEnabled(true);
|
setRefreshButtonEnabled(true);
|
||||||
|
|
||||||
return new PumpEnactResult() //
|
return new PumpEnactResult() //
|
||||||
.success(false) //
|
.success(false) //
|
||||||
.enacted(false) //
|
.enacted(false) //
|
||||||
.comment(MainApp.gs(R.string.medtronic_pump_status_pump_unreachable));
|
.comment(MainApp.gs(R.string.medtronic_pump_status_pump_unreachable));
|
||||||
}
|
}
|
||||||
|
|
||||||
MedtronicUtil.dismissNotification(MedtronicNotificationType.PumpUnreachable);
|
MedtronicUtil.dismissNotification(MedtronicNotificationType.PumpUnreachable);
|
||||||
|
@ -1316,15 +1311,15 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
|
||||||
|
|
||||||
if (profileInvalid != null) {
|
if (profileInvalid != null) {
|
||||||
return new PumpEnactResult() //
|
return new PumpEnactResult() //
|
||||||
.success(false) //
|
.success(false) //
|
||||||
.enacted(false) //
|
.enacted(false) //
|
||||||
.comment(MainApp.gs(R.string.medtronic_cmd_set_profile_pattern_overflow, profileInvalid));
|
.comment(MainApp.gs(R.string.medtronic_cmd_set_profile_pattern_overflow, profileInvalid));
|
||||||
}
|
}
|
||||||
|
|
||||||
MedtronicUITask responseTask = medtronicUIComm.executeCommand(MedtronicCommandType.SetBasalProfileSTD,
|
MedtronicUITask responseTask = medtronicUIComm.executeCommand(MedtronicCommandType.SetBasalProfileSTD,
|
||||||
basalProfile);
|
basalProfile);
|
||||||
|
|
||||||
Boolean response = (Boolean)responseTask.returnData;
|
Boolean response = (Boolean) responseTask.returnData;
|
||||||
|
|
||||||
if (isLoggingEnabled())
|
if (isLoggingEnabled())
|
||||||
LOG.info(getLogPrefix() + "Basal Profile was set: " + response);
|
LOG.info(getLogPrefix() + "Basal Profile was set: " + response);
|
||||||
|
@ -1333,7 +1328,7 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
|
||||||
return new PumpEnactResult().success(true).enacted(true);
|
return new PumpEnactResult().success(true).enacted(true);
|
||||||
} else {
|
} else {
|
||||||
return new PumpEnactResult().success(response).enacted(response) //
|
return new PumpEnactResult().success(response).enacted(response) //
|
||||||
.comment(MainApp.gs(R.string.medtronic_cmd_basal_profile_could_not_be_set));
|
.comment(MainApp.gs(R.string.medtronic_cmd_basal_profile_could_not_be_set));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1389,20 +1384,22 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
|
||||||
private List<CustomAction> customActions = null;
|
private List<CustomAction> customActions = null;
|
||||||
|
|
||||||
private CustomAction customActionWakeUpAndTune = new CustomAction(R.string.medtronic_custom_action_wake_and_tune,
|
private CustomAction customActionWakeUpAndTune = new CustomAction(R.string.medtronic_custom_action_wake_and_tune,
|
||||||
MedtronicCustomActionType.WakeUpAndTune);
|
MedtronicCustomActionType.WakeUpAndTune);
|
||||||
|
|
||||||
private CustomAction customActionClearBolusBlock = new CustomAction(
|
private CustomAction customActionClearBolusBlock = new CustomAction(
|
||||||
R.string.medtronic_custom_action_clear_bolus_block, MedtronicCustomActionType.ClearBolusBlock, false);
|
R.string.medtronic_custom_action_clear_bolus_block, MedtronicCustomActionType.ClearBolusBlock, false);
|
||||||
|
|
||||||
// private CustomAction customActionReset = new CustomAction(
|
private CustomAction customActionResetRLConfig = new CustomAction(
|
||||||
// R.string.medtronic_custom_action_reset_rileylink, MedtronicCustomActionType.ResetRileyLink, false);
|
R.string.medtronic_custom_action_reset_rileylink, MedtronicCustomActionType.ResetRileyLinkConfiguration, true);
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<CustomAction> getCustomActions() {
|
public List<CustomAction> getCustomActions() {
|
||||||
|
|
||||||
if (customActions == null) {
|
if (customActions == null) {
|
||||||
this.customActions = Arrays.asList(customActionWakeUpAndTune, customActionClearBolusBlock);
|
this.customActions = Arrays.asList(customActionWakeUpAndTune, //
|
||||||
|
customActionClearBolusBlock, //
|
||||||
|
customActionResetRLConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.customActions;
|
return this.customActions;
|
||||||
|
@ -1412,7 +1409,7 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
|
||||||
@Override
|
@Override
|
||||||
public void executeCustomAction(CustomActionType customActionType) {
|
public void executeCustomAction(CustomActionType customActionType) {
|
||||||
|
|
||||||
MedtronicCustomActionType mcat = (MedtronicCustomActionType)customActionType;
|
MedtronicCustomActionType mcat = (MedtronicCustomActionType) customActionType;
|
||||||
|
|
||||||
switch (mcat) {
|
switch (mcat) {
|
||||||
|
|
||||||
|
@ -1422,18 +1419,20 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
|
||||||
} else {
|
} else {
|
||||||
MedtronicUtil.displayNotConfiguredDialog();
|
MedtronicUtil.displayNotConfiguredDialog();
|
||||||
}
|
}
|
||||||
} break;
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case ClearBolusBlock: {
|
case ClearBolusBlock: {
|
||||||
this.busyTimestamps.clear();
|
this.busyTimestamps.clear();
|
||||||
this.customActionClearBolusBlock.setEnabled(false);
|
this.customActionClearBolusBlock.setEnabled(false);
|
||||||
refreshCustomActionsList();
|
refreshCustomActionsList();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ResetRileyLink: {
|
case ResetRileyLinkConfiguration: {
|
||||||
ServiceTaskExecutor.startTask(new ResetRileyLinkTask());
|
ServiceTaskExecutor.startTask(new ResetRileyLinkConfigurationTask());
|
||||||
} break;
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -1451,8 +1450,8 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
|
||||||
|
|
||||||
if (customAction == MedtronicCustomActionType.ClearBolusBlock) {
|
if (customAction == MedtronicCustomActionType.ClearBolusBlock) {
|
||||||
this.customActionClearBolusBlock.setEnabled(isEnabled);
|
this.customActionClearBolusBlock.setEnabled(isEnabled);
|
||||||
} else if (customAction == MedtronicCustomActionType.ResetRileyLink) {
|
} else if (customAction == MedtronicCustomActionType.ResetRileyLinkConfiguration) {
|
||||||
//this.customActionReset.setEnabled(isEnabled);
|
this.customActionResetRLConfig.setEnabled(isEnabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
refreshCustomActionsList();
|
refreshCustomActionsList();
|
||||||
|
|
|
@ -1,479 +0,0 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.medtronic.comm.data;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by geoff on 5/13/15.
|
|
||||||
* <p>
|
|
||||||
* This class was taken from medtronic-android-uploader.
|
|
||||||
* This class was written such that the constructors did all the work, which resulted
|
|
||||||
* in annoyances such as exceptions during constructors.
|
|
||||||
* <p>
|
|
||||||
* TODO: This class needs to be revisited and probably rewritten. (2016-06-12)
|
|
||||||
* <p>
|
|
||||||
* <p>
|
|
||||||
* <p>
|
|
||||||
* Pete Schwamb
|
|
||||||
*
|
|
||||||
* @ps2 12:04
|
|
||||||
* History entries will not reorder themselves, but some events do update, like dual wave bolus entries
|
|
||||||
* It's like an append only log, and when a page is full, it rotates the page ids and starts appending to a new blank page
|
|
||||||
* Darrell Wright
|
|
||||||
* @beached 12:05
|
|
||||||
* so the timestamp is entry creation not update
|
|
||||||
* time
|
|
||||||
* Pete Schwamb
|
|
||||||
* @ps2 12:06
|
|
||||||
* Yes, I don't think the timestamps ever change
|
|
||||||
* <p>
|
|
||||||
* <p>
|
|
||||||
* GGW: TODO: examine src/ecc1/medtronic for better history parsing
|
|
||||||
*/
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.joda.time.DateTime;
|
|
||||||
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.util.Log;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.plugins.pump.common.utils.ByteUtil;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.common.utils.CRC;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.common.utils.HexDump;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.PumpTimeStamp;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.Record;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.RecordTypeEnum;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.TimeFormat;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.record.IgnoredHistoryEntry;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.defs.MedtronicDeviceType;
|
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
public class Page {
|
|
||||||
|
|
||||||
private final static String TAG = "Page";
|
|
||||||
private static final boolean DEBUG_PAGE = true;
|
|
||||||
// protected PumpModel model;
|
|
||||||
public static MedtronicDeviceType model = MedtronicDeviceType.Medtronic_522;
|
|
||||||
public List<Record> mRecordList;
|
|
||||||
private byte[] crc;
|
|
||||||
private byte[] data;
|
|
||||||
|
|
||||||
|
|
||||||
public Page() {
|
|
||||||
this.model = MedtronicDeviceType.Unknown_Device;
|
|
||||||
mRecordList = new ArrayList<>();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* attemptParseRecord will attempt to create a subclass of Record from the given
|
|
||||||
* data and offset. It will return NULL if it fails. If it succeeds, the returned
|
|
||||||
* subclass of Record can be examined for its length, so that the next attempt can be made.
|
|
||||||
*
|
|
||||||
* TODO maybe try to change this, so that we can loose all the classes and using enum instead with full
|
|
||||||
* configuration. Its something to think about for later versions -- Andy
|
|
||||||
*/
|
|
||||||
public static <T extends Record> T attemptParseRecord(byte[] data, int offsetStart) {
|
|
||||||
// no data?
|
|
||||||
if (data == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
// invalid offset?
|
|
||||||
if (data.length < offsetStart) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
// Log.d(TAG,String.format("checking for handler for record type 0x%02X at index %d",data[offsetStart],offsetStart));
|
|
||||||
RecordTypeEnum en = RecordTypeEnum.fromByte(data[offsetStart]);
|
|
||||||
T record = en.getRecordClassInstance(model);
|
|
||||||
if (record != null) {
|
|
||||||
// have to do this to set the record's opCode
|
|
||||||
byte[] tmpData = new byte[data.length];
|
|
||||||
System.arraycopy(data, offsetStart, tmpData, 0, data.length - offsetStart);
|
|
||||||
boolean didParse = record.parseWithOffset(tmpData, model, offsetStart);
|
|
||||||
if (!didParse) {
|
|
||||||
Log.e(
|
|
||||||
TAG,
|
|
||||||
String.format("attemptParseRecord: class %s (opcode 0x%02X) failed to parse at offset %d",
|
|
||||||
record.getShortTypeName(), data[offsetStart], offsetStart));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return record;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static DateTime parseSimpleDate(byte[] data, int offset) {
|
|
||||||
DateTime timeStamp = null;
|
|
||||||
int seconds = 0;
|
|
||||||
int minutes = 0;
|
|
||||||
int hour = 0;
|
|
||||||
// int high = data[0] >> 4;
|
|
||||||
int low = data[0 + offset] & 0x1F;
|
|
||||||
// int year_high = data[1] >> 4;
|
|
||||||
int mhigh = (data[0 + offset] & 0xE0) >> 4;
|
|
||||||
int mlow = (data[1 + offset] & 0x80) >> 7;
|
|
||||||
int month = mhigh + mlow;
|
|
||||||
int dayOfMonth = low + 1;
|
|
||||||
// python code says year is data[1] & 0x0F, but that will cause problem in 2016.
|
|
||||||
// Hopefully, the remaining bits are part of the year...
|
|
||||||
int year = data[1 + offset] & 0x3F;
|
|
||||||
/*
|
|
||||||
* Log.w(TAG, String.format("Attempting to create DateTime from: %04d-%02d-%02d %02d:%02d:%02d",
|
|
||||||
* year + 2000, month, dayOfMonth, hour, minutes, seconds));
|
|
||||||
*/
|
|
||||||
try {
|
|
||||||
timeStamp = new DateTime(year + 2000, month, dayOfMonth, hour, minutes, seconds);
|
|
||||||
} catch (org.joda.time.IllegalFieldValueException e) {
|
|
||||||
// Log.e(TAG,"Illegal DateTime field");
|
|
||||||
// e.printStackTrace();
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return timeStamp;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static void discoverRecords(byte[] data) {
|
|
||||||
int i = 0;
|
|
||||||
boolean done = false;
|
|
||||||
|
|
||||||
ArrayList<Integer> keyLocations = new ArrayList();
|
|
||||||
while (!done) {
|
|
||||||
RecordTypeEnum en = RecordTypeEnum.fromByte(data[i]);
|
|
||||||
if (en != RecordTypeEnum.Null) {
|
|
||||||
keyLocations.add(i);
|
|
||||||
Log.v(TAG, String.format("Possible record of type %s found at index %d", en, i));
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
* DateTime ts = parseSimpleDate(data,i);
|
|
||||||
* if (ts != null) {
|
|
||||||
* if (ts.year().get() == 2015) {
|
|
||||||
* Log.w(TAG, String.format("Possible simple date at index %d", i));
|
|
||||||
* }
|
|
||||||
* }
|
|
||||||
*/
|
|
||||||
i = i + 1;
|
|
||||||
done = (i >= data.length - 2);
|
|
||||||
}
|
|
||||||
// for each of the discovered key locations, attempt to parse a sequence of records
|
|
||||||
for (RecordTypeEnum en : RecordTypeEnum.values()) {
|
|
||||||
|
|
||||||
}
|
|
||||||
for (int ix = 0; ix < keyLocations.size(); ix++) {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public byte[] getRawData() {
|
|
||||||
if (data == null) {
|
|
||||||
return crc;
|
|
||||||
}
|
|
||||||
if (crc == null) {
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
return ByteUtil.concat(data, crc);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
protected PumpTimeStamp collectTimeStamp(byte[] data, int offset) {
|
|
||||||
try {
|
|
||||||
PumpTimeStamp timestamp = new PumpTimeStamp(TimeFormat.parse5ByteDate(data, offset));
|
|
||||||
return timestamp;
|
|
||||||
} catch (org.joda.time.IllegalFieldValueException e) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public boolean parsePicky(byte[] rawPage, MedtronicDeviceType model) {
|
|
||||||
mRecordList = new ArrayList<>();
|
|
||||||
this.model = model;
|
|
||||||
int pageOffset = 0;
|
|
||||||
|
|
||||||
if ((rawPage == null) || (rawPage.length == 0))
|
|
||||||
return false;
|
|
||||||
this.data = Arrays.copyOfRange(rawPage, 0, rawPage.length - 2);
|
|
||||||
this.crc = Arrays.copyOfRange(rawPage, rawPage.length - 2, rawPage.length);
|
|
||||||
byte[] expectedCrc = CRC.calculate16CCITT(this.data);
|
|
||||||
if (DEBUG_PAGE) {
|
|
||||||
Log.i(TAG, String.format("Data length: %d", data.length));
|
|
||||||
}
|
|
||||||
if (!Arrays.equals(crc, expectedCrc)) {
|
|
||||||
Log.w(
|
|
||||||
TAG,
|
|
||||||
String.format("CRC does not match expected value. Expected: %s Was: %s",
|
|
||||||
HexDump.toHexString(expectedCrc), HexDump.toHexString(crc)));
|
|
||||||
} else {
|
|
||||||
if (DEBUG_PAGE) {
|
|
||||||
Log.i(TAG, "CRC OK");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Record record = null;
|
|
||||||
while (pageOffset < data.length) {
|
|
||||||
if (data[pageOffset] == 0) {
|
|
||||||
if (record != null) {
|
|
||||||
Log.i(TAG, String.format(
|
|
||||||
"End of page or Previous parse fail: prev opcode 0x%02x, curr offset %d, %d bytes remaining",
|
|
||||||
record.getRecordOp(), pageOffset, data.length - pageOffset + 1));
|
|
||||||
break;
|
|
||||||
} else {
|
|
||||||
Log.i(TAG, "WTF?");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
record = attemptParseRecord(data, pageOffset);
|
|
||||||
} catch (org.joda.time.IllegalFieldValueException e) {
|
|
||||||
record = null;
|
|
||||||
}
|
|
||||||
if (record == null) {
|
|
||||||
Log.i(TAG, "PARSE FAIL");
|
|
||||||
pageOffset++;
|
|
||||||
} else {
|
|
||||||
mRecordList.add(record);
|
|
||||||
pageOffset += record.getLength();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ArrayList<Record> pickyRecords = new ArrayList<>();
|
|
||||||
pickyRecords.addAll(mRecordList);
|
|
||||||
parseByDates(rawPage, model);
|
|
||||||
for (Record r : mRecordList) {
|
|
||||||
for (Record r2 : pickyRecords) {
|
|
||||||
if (r.getFoundAtOffset() == r2.getFoundAtOffset()) {
|
|
||||||
Log.v(TAG, "Found matching record at offset " + r.getFoundAtOffset());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public boolean parseByDates(byte[] rawPage, MedtronicDeviceType model) {
|
|
||||||
mRecordList = new ArrayList<>();
|
|
||||||
if (rawPage.length != 1024) {
|
|
||||||
Log.e(TAG, "Unexpected page size. Expected: 1024 Was: " + rawPage.length);
|
|
||||||
// return false;
|
|
||||||
}
|
|
||||||
Page.model = model;
|
|
||||||
if (DEBUG_PAGE) {
|
|
||||||
Log.i(TAG, "Parsing page");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (rawPage.length < 4) {
|
|
||||||
Log.e(TAG, "Page too short, need at least 4 bytes");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.data = Arrays.copyOfRange(rawPage, 0, rawPage.length - 2);
|
|
||||||
this.crc = Arrays.copyOfRange(rawPage, rawPage.length - 2, rawPage.length);
|
|
||||||
byte[] expectedCrc = CRC.calculate16CCITT(this.data);
|
|
||||||
if (DEBUG_PAGE) {
|
|
||||||
Log.i(TAG, String.format("Data length: %d", data.length));
|
|
||||||
}
|
|
||||||
if (!Arrays.equals(crc, expectedCrc)) {
|
|
||||||
Log.w(
|
|
||||||
TAG,
|
|
||||||
String.format("CRC does not match expected value. Expected: %s Was: %s",
|
|
||||||
HexDump.toHexString(expectedCrc), HexDump.toHexString(crc)));
|
|
||||||
} else {
|
|
||||||
if (DEBUG_PAGE) {
|
|
||||||
Log.i(TAG, "CRC OK");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int pageOffset = 0;
|
|
||||||
PumpTimeStamp lastPumpTimeStamp = new PumpTimeStamp();
|
|
||||||
while (pageOffset < this.data.length - 7) {
|
|
||||||
PumpTimeStamp timestamp = collectTimeStamp(data, pageOffset + 2);
|
|
||||||
if (timestamp != null) {
|
|
||||||
String year = timestamp.toString().substring(0, 3);
|
|
||||||
Record record;
|
|
||||||
if ("201".equals(year)) {
|
|
||||||
// maybe found a record.
|
|
||||||
try {
|
|
||||||
record = attemptParseRecord(data, pageOffset);
|
|
||||||
} catch (org.joda.time.IllegalFieldValueException e) {
|
|
||||||
record = null;
|
|
||||||
}
|
|
||||||
if (record != null) {
|
|
||||||
if (timestamp.getLocalDateTime().compareTo(lastPumpTimeStamp.getLocalDateTime()) >= 0) {
|
|
||||||
Log.i(TAG, "Timestamp is increasing");
|
|
||||||
lastPumpTimeStamp = timestamp;
|
|
||||||
mRecordList.add(record);
|
|
||||||
} else {
|
|
||||||
Log.e(TAG, "Timestamp is decreasing");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
pageOffset++;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public boolean parseFrom(byte[] rawPage, MedtronicDeviceType model) {
|
|
||||||
mRecordList = new ArrayList<>(); // wipe old contents each time when parsing.
|
|
||||||
if (rawPage.length != 1024) {
|
|
||||||
Log.e(TAG, "Unexpected page size. Expected: 1024 Was: " + rawPage.length);
|
|
||||||
// return false;
|
|
||||||
}
|
|
||||||
this.model = model;
|
|
||||||
if (DEBUG_PAGE) {
|
|
||||||
Log.i(TAG, "Parsing page");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (rawPage.length < 4) {
|
|
||||||
Log.e(TAG, "Page too short, need at least 4 bytes");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.data = Arrays.copyOfRange(rawPage, 0, rawPage.length - 2);
|
|
||||||
this.crc = Arrays.copyOfRange(rawPage, rawPage.length - 2, rawPage.length);
|
|
||||||
byte[] expectedCrc = CRC.calculate16CCITT(this.data);
|
|
||||||
if (DEBUG_PAGE) {
|
|
||||||
Log.i(TAG, String.format("Data length: %d", data.length));
|
|
||||||
}
|
|
||||||
if (!Arrays.equals(crc, expectedCrc)) {
|
|
||||||
Log.w(
|
|
||||||
TAG,
|
|
||||||
String.format("CRC does not match expected value. Expected: %s Was: %s",
|
|
||||||
HexDump.toHexString(expectedCrc), HexDump.toHexString(crc)));
|
|
||||||
} else {
|
|
||||||
if (DEBUG_PAGE) {
|
|
||||||
Log.i(TAG, "CRC OK");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int dataIndex = 0;
|
|
||||||
boolean done = false;
|
|
||||||
Record previousRecord = null;
|
|
||||||
while (!done) {
|
|
||||||
Record record = null;
|
|
||||||
if (data[dataIndex] != 0) {
|
|
||||||
// If the data byte is zero, assume that means end of page
|
|
||||||
try {
|
|
||||||
record = attemptParseRecord(data, dataIndex);
|
|
||||||
} catch (org.joda.time.IllegalFieldValueException e) {
|
|
||||||
record = null;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
Log.v(TAG, "Zero opcode encountered -- end of page. " + (rawPage.length - dataIndex)
|
|
||||||
+ " bytes remaining.");
|
|
||||||
|
|
||||||
StringBuilder stringBuilder = new StringBuilder();
|
|
||||||
stringBuilder.append("Possible parsing problem: ");
|
|
||||||
stringBuilder.append("Previous record: " + previousRecord);
|
|
||||||
stringBuilder.append(" Content of previous record: "
|
|
||||||
+ HexDump.toHexStringDisplayable(previousRecord.getRawbytes()));
|
|
||||||
|
|
||||||
int remainingData = rawPage.length - dataIndex;
|
|
||||||
byte[] tmpData = new byte[remainingData + 10];
|
|
||||||
System.arraycopy(data, dataIndex, tmpData, 0, remainingData - 10);
|
|
||||||
|
|
||||||
stringBuilder.append(" Remaining data: " + HexDump.toHexStringDisplayable(tmpData));
|
|
||||||
|
|
||||||
Log.v(TAG, stringBuilder.toString());
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (record != null) {
|
|
||||||
if (record instanceof IgnoredHistoryEntry) {
|
|
||||||
IgnoredHistoryEntry he = (IgnoredHistoryEntry)record;
|
|
||||||
Log.v(TAG, "parseFrom: found event " + he.getShortTypeName() + " length=" + record.getLength()
|
|
||||||
+ " offset=" + record.getFoundAtOffset() + " -- IGNORING");
|
|
||||||
} else {
|
|
||||||
Log.v(TAG,
|
|
||||||
"parseFrom: found event " + record.getClass().getSimpleName() + " length=" + record.getLength()
|
|
||||||
+ " offset=" + record.getFoundAtOffset());
|
|
||||||
mRecordList.add(record);
|
|
||||||
}
|
|
||||||
|
|
||||||
dataIndex += record.getLength();
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
StringBuilder stringBuilder = new StringBuilder();
|
|
||||||
stringBuilder.append("Possible parsing problem: ");
|
|
||||||
stringBuilder.append("Previous record: " + previousRecord);
|
|
||||||
stringBuilder.append(" Content of previous record: "
|
|
||||||
+ HexDump.toHexStringDisplayable(previousRecord.getRawbytes()));
|
|
||||||
|
|
||||||
int remainingData = data.length - dataIndex;
|
|
||||||
byte[] tmpData = Arrays.copyOfRange(data, dataIndex, 1022);
|
|
||||||
|
|
||||||
// new byte[remainingData];
|
|
||||||
// System.arraycopy(data, dataIndex, tmpData, 0, remainingData - 2);
|
|
||||||
|
|
||||||
stringBuilder.append(" Remaining data: " + HexDump.toHexStringDisplayable(tmpData));
|
|
||||||
|
|
||||||
Log.e(TAG,
|
|
||||||
String.format("parseFrom: Failed to parse opcode 0x%02x, offset=%d", data[dataIndex], dataIndex));
|
|
||||||
done = true;
|
|
||||||
}
|
|
||||||
if (dataIndex >= data.length - 2) {
|
|
||||||
done = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
previousRecord = record;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (DEBUG_PAGE) {
|
|
||||||
Log.i(TAG, String.format("Number of records: %d", mRecordList.size()));
|
|
||||||
int index = 1;
|
|
||||||
for (Record r : mRecordList) {
|
|
||||||
Log.v(TAG, String.format("Record #%d: %s", index, r.getShortTypeName()));
|
|
||||||
index += 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
*
|
|
||||||
* For IPC serialization
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* private byte[] crc;
|
|
||||||
* private byte[] data;
|
|
||||||
* protected PumpModel model;
|
|
||||||
* public List<Record> mRecordList;
|
|
||||||
*/
|
|
||||||
|
|
||||||
public Bundle pack() {
|
|
||||||
Bundle bundle = new Bundle();
|
|
||||||
bundle.putByteArray("crc", crc);
|
|
||||||
bundle.putByteArray("data", data);
|
|
||||||
bundle.putString("model", model.name());
|
|
||||||
ArrayList<Bundle> records = new ArrayList<>();
|
|
||||||
for (int i = 0; i < mRecordList.size(); i++) {
|
|
||||||
try {
|
|
||||||
records.add(mRecordList.get(i).dictionaryRepresentation());
|
|
||||||
} catch (NullPointerException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
bundle.putParcelableArrayList("mRecordList", records);
|
|
||||||
return bundle;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void unpack(Bundle in) {
|
|
||||||
crc = in.getByteArray("crc");
|
|
||||||
data = in.getByteArray("data");
|
|
||||||
model = MedtronicDeviceType.valueOf(in.getString("model"));
|
|
||||||
ArrayList<Bundle> records = in.getParcelableArrayList("mRecordList");
|
|
||||||
mRecordList = new ArrayList<>();
|
|
||||||
if (records != null) {
|
|
||||||
for (int i = 0; i < records.size(); i++) {
|
|
||||||
Record r = RecordTypeEnum.getRecordClassInstance(records.get(i), model);
|
|
||||||
r.readFromBundle(records.get(i));
|
|
||||||
mRecordList.add(r);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,50 +0,0 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old;
|
|
||||||
|
|
||||||
import org.joda.time.LocalDate;
|
|
||||||
import org.joda.time.LocalDateTime;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by geoff on 6/4/16.
|
|
||||||
* Exists to easily merge 2 byte timestamps and 5 byte timestamps.
|
|
||||||
*/
|
|
||||||
public class PumpTimeStamp {
|
|
||||||
|
|
||||||
private LocalDateTime localDateTime;
|
|
||||||
|
|
||||||
|
|
||||||
public PumpTimeStamp() {
|
|
||||||
localDateTime = new LocalDateTime(1973, 1, 1, 1, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public PumpTimeStamp(String stringRepresentation) {
|
|
||||||
localDateTime.parse(stringRepresentation);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public PumpTimeStamp(LocalDate localDate) {
|
|
||||||
try {
|
|
||||||
localDateTime = new LocalDateTime(localDate);
|
|
||||||
} catch (IllegalArgumentException e) {
|
|
||||||
// This should be caught earlier
|
|
||||||
localDateTime = new LocalDateTime(1973, 1, 1, 1, 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public PumpTimeStamp(LocalDateTime localDateTime) {
|
|
||||||
this.localDateTime = localDateTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public LocalDateTime getLocalDateTime() {
|
|
||||||
return localDateTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return getLocalDateTime().toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,129 +0,0 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old;
|
|
||||||
|
|
||||||
import android.os.Bundle;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.defs.MedtronicDeviceType;
|
|
||||||
|
|
||||||
abstract public class Record {
|
|
||||||
|
|
||||||
protected MedtronicDeviceType model;
|
|
||||||
protected byte recordOp;
|
|
||||||
// protected int length;
|
|
||||||
protected int foundAtOffset;
|
|
||||||
protected byte[] rawbytes = new byte[0];
|
|
||||||
|
|
||||||
|
|
||||||
// protected String recordTypeName = this.getClass().getSimpleName();
|
|
||||||
|
|
||||||
public Record() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
protected static int asUINT8(byte b) {
|
|
||||||
return (b < 0) ? b + 256 : b;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public String getRecordTypeName() {
|
|
||||||
return this.getClass().getSimpleName();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public String getShortTypeName() {
|
|
||||||
return this.getClass().getSimpleName();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void setPumpModel(MedtronicDeviceType model) {
|
|
||||||
this.model = model;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public int getFoundAtOffset() {
|
|
||||||
return foundAtOffset;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public boolean parseWithOffset(byte[] data, MedtronicDeviceType model, int foundAtOffset) {
|
|
||||||
// keep track of where the record was found for later analysis
|
|
||||||
this.foundAtOffset = foundAtOffset;
|
|
||||||
if (data == null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (data.length < 1) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
recordOp = data[0];
|
|
||||||
boolean didParse = parseFrom(data, model);
|
|
||||||
if (didParse) {
|
|
||||||
captureRawBytes(data);
|
|
||||||
}
|
|
||||||
return didParse;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void captureRawBytes(byte[] data) {
|
|
||||||
this.rawbytes = new byte[getLength()];
|
|
||||||
System.arraycopy(data, 0, this.rawbytes, 0, getLength() - 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public boolean parseFrom(byte[] data, MedtronicDeviceType model) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public PumpTimeStamp getTimestamp() {
|
|
||||||
return new PumpTimeStamp();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public int getLength() {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public byte getRecordOp() {
|
|
||||||
return recordOp;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public Bundle dictionaryRepresentation() {
|
|
||||||
Bundle rval = new Bundle();
|
|
||||||
writeToBundle(rval);
|
|
||||||
return rval;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public boolean readFromBundle(Bundle in) {
|
|
||||||
// length is determined at instantiation
|
|
||||||
// record type name is "static"
|
|
||||||
// opcode has already been read.
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public boolean isLargerFormat() {
|
|
||||||
return MedtronicDeviceType.isLargerFormat(model);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void writeToBundle(Bundle in) {
|
|
||||||
in.putInt("length", getLength());
|
|
||||||
in.putInt("foundAtOffset", foundAtOffset);
|
|
||||||
in.putInt("_opcode", recordOp);
|
|
||||||
in.putString("_type", getRecordTypeName());
|
|
||||||
in.putString("_stype", getShortTypeName());
|
|
||||||
in.putByteArray("rawbytes", rawbytes);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public byte[] getRawbytes() {
|
|
||||||
return rawbytes;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public abstract boolean isAAPSRelevant();
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,283 +0,0 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old;
|
|
||||||
|
|
||||||
import java.lang.reflect.Constructor;
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import android.os.Bundle;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.record.AlarmClockReminderPumpEvent;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.record.AlarmSensorPumpEvent;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.record.BGReceivedPumpEvent;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.record.BasalProfileStart;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.record.BatteryPumpEvent;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.record.BolusNormalPumpEvent;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.record.BolusWizardBolusEstimatePumpEvent;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.record.CalBgForPhPumpEvent;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.record.ChangeAlarmClockEnablePumpEvent;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.record.ChangeAlarmNotifyModePumpEvent;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.record.ChangeAudioBolusPumpEvent;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.record.ChangeBGReminderEnablePumpEvent;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.record.ChangeBasalProfilePatternPumpEvent;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.record.ChangeBasalProfilePumpEvent;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.record.ChangeBolusReminderEnablePumpEvent;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.record.ChangeBolusReminderTimePumpEvent;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.record.ChangeBolusScrollStepSizePumpEvent;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.record.ChangeBolusWizardSetupPumpEvent;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.record.ChangeCaptureEventEnablePumpEvent;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.record.ChangeCarbUnitsPumpEvent;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.record.ChangeChildBlockEnablePumpEvent;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.record.ChangeMaxBolusPumpEvent;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.record.ChangeOtherDeviceIDPumpEvent;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.record.ChangeReservoirWarningTimePumpEvent;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.record.ChangeSensorRateOfChangeAlertSetupPumpEvent;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.record.ChangeSensorSetup2PumpEvent;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.record.ChangeTempBasalTypePumpEvent;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.record.ChangeTimeFormatPumpEvent;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.record.ChangeTimePumpEvent;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.record.ChangeVariableBolusPumpEvent;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.record.ChangeWatchdogEnablePumpEvent;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.record.ChangeWatchdogMarriageProfilePumpEvent;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.record.ClearAlarmPumpEvent;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.record.DeleteAlarmClockTimePumpEvent;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.record.DeleteBolusReminderTimePumpEvent;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.record.DeleteOtherDeviceIDPumpEvent;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.record.EnableDisableRemotePumpEvent;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.record.IgnoredHistoryEntry;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.record.InsulinMarkerEvent;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.record.JournalEntryExerciseMarkerPumpEvent;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.record.JournalEntryPumpLowBatteryPumpEvent;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.record.JournalEntryPumpLowReservoirPumpEvent;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.record.Model522ResultTotalsPumpEvent;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.record.NewTimeSet;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.record.PrimePumpEvent;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.record.PumpAlarmPumpEvent;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.record.ResultDailyTotalPumpEvent;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.record.ResumePumpEvent;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.record.RewindPumpEvent;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.record.SuspendPumpEvent;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.record.TempBasalDurationPumpEvent;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.record.TempBasalRatePumpEvent;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.record.UnabsorbedInsulin;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.record.Unknown7ByteEvent1;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.defs.MedtronicDeviceType;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by geoff on 5/28/15.
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public enum RecordTypeEnum {
|
|
||||||
|
|
||||||
Null((byte)0x00, null, 0), //
|
|
||||||
|
|
||||||
// Good Events
|
|
||||||
BolusNormal(0x01, BolusNormalPumpEvent.class), // OK
|
|
||||||
Prime((byte)0x03, PrimePumpEvent.class), // OK
|
|
||||||
AlarmPump((byte)0x06, PumpAlarmPumpEvent.class), //
|
|
||||||
ResultDailyTotal((byte)0x07, ResultDailyTotalPumpEvent.class), // OK
|
|
||||||
ChangeBasalProfile_old_profile((byte)0x08, ChangeBasalProfilePatternPumpEvent.class), // OK
|
|
||||||
ChangeBasalProfile_new_profile((byte)0x09, ChangeBasalProfilePumpEvent.class), // OK
|
|
||||||
|
|
||||||
CalBgForPh((byte)0x0A, CalBgForPhPumpEvent.class), //
|
|
||||||
AlarmSensor((byte)0x0B, AlarmSensorPumpEvent.class), //
|
|
||||||
ClearAlarm((byte)0x0C, ClearAlarmPumpEvent.class), //
|
|
||||||
SelectBasalProfile((byte)0x14, IgnoredHistoryEntry.class, 7), // OK
|
|
||||||
TempBasalDuration((byte)0x16, TempBasalDurationPumpEvent.class), // OK
|
|
||||||
ChangeTime((byte)0x17, ChangeTimePumpEvent.class), // OK
|
|
||||||
NewTimeSet((byte)0x18, NewTimeSet.class), // OK
|
|
||||||
|
|
||||||
JournalEntryPumpLowBattery((byte)0x19, JournalEntryPumpLowBatteryPumpEvent.class), //
|
|
||||||
RECORD_TYPE_BATTERY((byte)0x1A, BatteryPumpEvent.class), //
|
|
||||||
SetAutoOff(0x1b, 7), //
|
|
||||||
Suspend((byte)0x1E, SuspendPumpEvent.class), // OK
|
|
||||||
Resume((byte)0x1F, ResumePumpEvent.class), // OK
|
|
||||||
SelfTest(0x20, 7), //
|
|
||||||
Rewind((byte)0x21, RewindPumpEvent.class), //
|
|
||||||
ClearSettings(0x22, 7), //
|
|
||||||
ChangeChildBlockEnable((byte)0x23, ChangeChildBlockEnablePumpEvent.class), //
|
|
||||||
ChangeMaxBolus((byte)0x24, ChangeMaxBolusPumpEvent.class), //
|
|
||||||
EnableDisableRemote((byte)0x26, EnableDisableRemotePumpEvent.class), //
|
|
||||||
ChangeMaxBasal(0x2c, 7), //
|
|
||||||
EnableBolusWizard(0x2d, 7), //
|
|
||||||
Andy2E(0x2e, 7), //
|
|
||||||
Andy2F(0x2f, 7), //
|
|
||||||
Andy30(0x30, 7), //
|
|
||||||
ChangeBGReminderOffset(0x31, 7), //
|
|
||||||
ChangeAlarmClockTime(0x32, 7), //
|
|
||||||
tempBasal((byte)0x33, TempBasalRatePumpEvent.class), //
|
|
||||||
journalEntryPumpLowReservoir((byte)0x34, JournalEntryPumpLowReservoirPumpEvent.class), //
|
|
||||||
AlarmClockReminder((byte)0x35, AlarmClockReminderPumpEvent.class), //
|
|
||||||
ChangeMeterId(0x36, 7), // 715 = 21 ??
|
|
||||||
MM512_Event_0x37(0x37, 7), //
|
|
||||||
MM512_Event_0x38(0x38, 7), //
|
|
||||||
MM512_Event_0x39(0x39, 7), //
|
|
||||||
MM512_Event_0x3A(0x3A, 7), //
|
|
||||||
MM512_Event_0x3B(0x3b, 7), // Questionable3b
|
|
||||||
changeParadigmLinkID(0x3c, 7), //
|
|
||||||
MM512_Event_0x3D(0x3D, 7), //
|
|
||||||
MM512_Event_0x3E(0x3e, 7), //
|
|
||||||
bgReceived((byte)0x3F, BGReceivedPumpEvent.class), //
|
|
||||||
JournalEntryMealMarker(0x40, 7), //
|
|
||||||
JournalEntryExerciseMarker((byte)0x41, JournalEntryExerciseMarkerPumpEvent.class), //
|
|
||||||
JournalEntryInsulinMarker((byte)0x42, Unknown7ByteEvent1.class), //
|
|
||||||
journalEntryOtherMarker((byte)0x43, InsulinMarkerEvent.class), //
|
|
||||||
|
|
||||||
MM512_Event_0x44(0x44, 7), //
|
|
||||||
MM512_Event_0x45(0x45, 7), //
|
|
||||||
MM512_Event_0x46(0x46, 7), //
|
|
||||||
MM512_Event_0x47(0x47, 7), //
|
|
||||||
MM512_Event_0x48(0x48, 7), //
|
|
||||||
MM512_Event_0x49(0x49, 7), //
|
|
||||||
MM512_Event_0x4a(0x4a, 7), //
|
|
||||||
MM512_Event_0x4b(0x4b, 7), //
|
|
||||||
MM512_Event_0x4c(0x4c, 7), //
|
|
||||||
MM512_Event_0x4d(0x4d, 7), //
|
|
||||||
MM512_Event_0x4e(0x4e, 7), //
|
|
||||||
|
|
||||||
// case changeBolusWizardSetup = 0x4f, 7), //
|
|
||||||
|
|
||||||
changeSensorSetup2((byte)0x50, ChangeSensorSetup2PumpEvent.class), //
|
|
||||||
// case restoreMystery51 = 0x51, 7), //
|
|
||||||
// case restoreMystery52 = 0x52, 7), //
|
|
||||||
// case changeSensorAlarmSilenceConfig = 0x53, 7), //
|
|
||||||
// case restoreMystery54 = 0x54, 7), //
|
|
||||||
// case restoreMystery55 = 0x55, 7), //
|
|
||||||
ChangeSensorRateOfChangeAlertSetup((byte)0x56, ChangeSensorRateOfChangeAlertSetupPumpEvent.class), //
|
|
||||||
ChangeBolusScrollStepSize((byte)0x57, ChangeBolusScrollStepSizePumpEvent.class), //
|
|
||||||
ChangeBolusWizardSetup((byte)0x5A, ChangeBolusWizardSetupPumpEvent.class), //
|
|
||||||
BolusWizardBolusEstimate((byte)0x5B, BolusWizardBolusEstimatePumpEvent.class), //
|
|
||||||
unabsorbedInsulin((byte)0x5C, UnabsorbedInsulin.class), //
|
|
||||||
// case saveSettings = 0x5d, 7), //
|
|
||||||
changeVariableBolus((byte)0x5e, ChangeVariableBolusPumpEvent.class), //
|
|
||||||
changeAudioBolus((byte)0x5f, ChangeAudioBolusPumpEvent.class), //
|
|
||||||
ChangeBGReminderEnable((byte)0x60, ChangeBGReminderEnablePumpEvent.class), //
|
|
||||||
ChangeAlarmClockEnable((byte)0x61, ChangeAlarmClockEnablePumpEvent.class), //
|
|
||||||
|
|
||||||
ChangeTempBasalType((byte)0x62, ChangeTempBasalTypePumpEvent.class), //
|
|
||||||
ChangeAlarmNotifyMode((byte)0x63, ChangeAlarmNotifyModePumpEvent.class), //
|
|
||||||
ChangeTimeFormat((byte)0x64, ChangeTimeFormatPumpEvent.class), //
|
|
||||||
ChangeReservoirWarningTime((byte)0x65, ChangeReservoirWarningTimePumpEvent.class), //
|
|
||||||
ChangeBolusReminderEnable((byte)0x66, ChangeBolusReminderEnablePumpEvent.class), //
|
|
||||||
ChangeBolusReminderTime((byte)0x67, ChangeBolusReminderTimePumpEvent.class), //
|
|
||||||
DeleteBolusReminderTime((byte)0x68, DeleteBolusReminderTimePumpEvent.class), //
|
|
||||||
// case bolusReminder = 0x69, 7), //
|
|
||||||
DeleteAlarmClockTime((byte)0x6a, DeleteAlarmClockTimePumpEvent.class), //
|
|
||||||
DailyTotal515(0x6c, 38), // FIXME
|
|
||||||
dailyTotal522((byte)0x6D, Model522ResultTotalsPumpEvent.class), //
|
|
||||||
dailyTotal523((byte)0x6E, IgnoredHistoryEntry.class, 52), // Sara6E // FIXME
|
|
||||||
ChangeCarbUnits((byte)0x6f, ChangeCarbUnitsPumpEvent.class), //
|
|
||||||
basalProfileStart((byte)0x7B, BasalProfileStart.class), //
|
|
||||||
ChangeWatchdogEnable((byte)0x7c, ChangeWatchdogEnablePumpEvent.class), //
|
|
||||||
ChangeOtherDeviceID((byte)0x7d, ChangeOtherDeviceIDPumpEvent.class), //
|
|
||||||
ChangeWatchdogMarriageProfile((byte)0x81, ChangeWatchdogMarriageProfilePumpEvent.class), //
|
|
||||||
DeleteOtherDeviceID((byte)0x82, DeleteOtherDeviceIDPumpEvent.class), //
|
|
||||||
ChangeCaptureEventEnable((byte)0x83, ChangeCaptureEventEnablePumpEvent.class),
|
|
||||||
|
|
||||||
// Irelevant records (events that don't concern us for AAPS usage)
|
|
||||||
|
|
||||||
;
|
|
||||||
|
|
||||||
private static final String TAG = "RecordTypeEnum";
|
|
||||||
private static Map<Byte, RecordTypeEnum> mapByOpCode = null;
|
|
||||||
private byte opcode;
|
|
||||||
private Class mRecordClass;
|
|
||||||
private int length;
|
|
||||||
private String shortTypeName;
|
|
||||||
|
|
||||||
|
|
||||||
RecordTypeEnum(int b, Class c) {
|
|
||||||
opcode = (byte)b;
|
|
||||||
mRecordClass = c;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
RecordTypeEnum(int b, Class c, int length) {
|
|
||||||
opcode = (byte)b;
|
|
||||||
mRecordClass = c;
|
|
||||||
this.length = length;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
RecordTypeEnum(int b, int length) {
|
|
||||||
this(b, IgnoredHistoryEntry.class, length);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static RecordTypeEnum fromByte(byte b) {
|
|
||||||
for (RecordTypeEnum en : RecordTypeEnum.values()) {
|
|
||||||
if (en.opcode() == b) {
|
|
||||||
return en;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return Null;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static <T extends Record> T getRecordClassInstance(Bundle bundle, MedtronicDeviceType model) {
|
|
||||||
byte opcode = bundle.getByte("_opcode");
|
|
||||||
RecordTypeEnum e = RecordTypeEnum.fromByte(opcode);
|
|
||||||
return e.getRecordClassInstance(model);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public byte opcode() {
|
|
||||||
return opcode;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public Class recordClass() {
|
|
||||||
return mRecordClass;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public <T extends Record> T getRecordClassInstance(MedtronicDeviceType model) {
|
|
||||||
Constructor<T> ctor;
|
|
||||||
T record = null;
|
|
||||||
try {
|
|
||||||
Class c = recordClass();
|
|
||||||
if (c != null) {
|
|
||||||
ctor = recordClass().getConstructor();
|
|
||||||
if (ctor != null) {
|
|
||||||
record = ctor.newInstance();
|
|
||||||
record.setPumpModel(model);
|
|
||||||
|
|
||||||
// if this is IgnoredHistoryEntry we need to set type so that we get correct length and name
|
|
||||||
if (record instanceof IgnoredHistoryEntry) {
|
|
||||||
IgnoredHistoryEntry he = (IgnoredHistoryEntry)record;
|
|
||||||
he.init(this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (NoSuchMethodException e) {
|
|
||||||
// NOTE: these were all OR'd together, but android requires us to separate them.
|
|
||||||
e.printStackTrace();
|
|
||||||
} catch (InvocationTargetException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
} catch (InstantiationException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
} catch (IllegalAccessException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
return record;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public int getLength() {
|
|
||||||
return length;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void setLength(int length) {
|
|
||||||
this.length = length;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public String getShortTypeName() {
|
|
||||||
return shortTypeName;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void setShortTypeName(String shortTypeName) {
|
|
||||||
this.shortTypeName = shortTypeName;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,87 +0,0 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old;
|
|
||||||
|
|
||||||
import org.joda.time.LocalDate;
|
|
||||||
import org.joda.time.LocalDateTime;
|
|
||||||
import org.joda.time.format.DateTimeFormat;
|
|
||||||
import org.joda.time.format.DateTimeFormatter;
|
|
||||||
|
|
||||||
import android.util.Log;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.plugins.pump.common.utils.ByteUtil;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by geoff on 6/4/16.
|
|
||||||
*/
|
|
||||||
public class TimeFormat {
|
|
||||||
|
|
||||||
public static final String standardFormatString = "YYYY-MM-dd HH:mm:ss";
|
|
||||||
private static final boolean DEBUG_TIMEFORMAT = false;
|
|
||||||
private static final String TAG = "TimeFormat";
|
|
||||||
|
|
||||||
|
|
||||||
public TimeFormat() {
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static DateTimeFormatter standardFormatter() {
|
|
||||||
return DateTimeFormat.forPattern(standardFormatString);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static LocalDate parse2ByteDate(byte[] data, int offset) throws org.joda.time.IllegalFieldValueException {
|
|
||||||
int low = ByteUtil.asUINT8(data[0 + offset]) & 0x1F;
|
|
||||||
int mhigh = (ByteUtil.asUINT8(data[0 + offset]) & 0xE0) >> 4;
|
|
||||||
int mlow = (ByteUtil.asUINT8(data[1 + offset]) & 0x80) >> 7;
|
|
||||||
int month = mhigh + mlow;
|
|
||||||
int dayOfMonth = low + 1;
|
|
||||||
int year = 2000 + (ByteUtil.asUINT8(data[offset + 1]) & 0x7F);
|
|
||||||
/*
|
|
||||||
* Log.w(TAG, String.format("Attempting to create DateTime from: %04d-%02d-%02d %02d:%02d:%02d",
|
|
||||||
* year + 2000, month, dayOfMonth, hour, minutes, seconds));
|
|
||||||
*/
|
|
||||||
// try {
|
|
||||||
LocalDate rval = new LocalDate(year, month, dayOfMonth);
|
|
||||||
return rval;
|
|
||||||
/*
|
|
||||||
* } catch (org.joda.time.IllegalFieldValueException e) {
|
|
||||||
* Log.e(TAG,"Illegal DateTime field");
|
|
||||||
* //e.printStackTrace();
|
|
||||||
* return new LocalDate(1973,3,3);
|
|
||||||
* }
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// for relation to old code, replace offset with headerSize
|
|
||||||
|
|
||||||
public static LocalDateTime parse5ByteDate(byte[] data, int offset) throws org.joda.time.IllegalFieldValueException {
|
|
||||||
// offset = headerSize;
|
|
||||||
if (DEBUG_TIMEFORMAT) {
|
|
||||||
Log.w(TAG, String.format("bytes to parse: 0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X", data[offset],
|
|
||||||
data[offset + 1], data[offset + 2], data[offset + 3], data[offset + 4]));
|
|
||||||
}
|
|
||||||
int seconds = data[offset] & 0x3F;
|
|
||||||
int minutes = data[offset + 1] & 0x3F;
|
|
||||||
int hour = data[offset + 2] & 0x1F;
|
|
||||||
int dayOfMonth = data[offset + 3] & 0x1F;
|
|
||||||
// Yes, the month bits are stored in the high bits above seconds and minutes!!
|
|
||||||
int month = ((data[offset] >> 4) & 0x0c) + ((data[offset + 1] >> 6) & 0x03);
|
|
||||||
int year = data[offset + 4] & 0x3F; // Assuming this is correct, need to verify. Otherwise this will be a
|
|
||||||
// problem in 2016.
|
|
||||||
/*
|
|
||||||
* Log.w(TAG,String.format("Attempting to create DateTime from: %04d-%02d-%02d %02d:%02d:%02d",
|
|
||||||
* year+2000,month,dayOfMonth,hour,minutes,seconds));
|
|
||||||
*/
|
|
||||||
// try {
|
|
||||||
LocalDateTime timeStamp = new LocalDateTime(year + 2000, month, dayOfMonth, hour, minutes, seconds);
|
|
||||||
return timeStamp;
|
|
||||||
/*
|
|
||||||
* } catch (org.joda.time.IllegalFieldValueException e) {
|
|
||||||
* Log.e(TAG, "Illegal DateTime field");
|
|
||||||
* //e.printStackTrace();
|
|
||||||
* return new LocalDateTime(1973,2,2,2,2);
|
|
||||||
* }
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,85 +0,0 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old;
|
|
||||||
|
|
||||||
import android.os.Bundle;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.plugins.pump.common.utils.ByteUtil;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.defs.MedtronicDeviceType;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Many events in the history only consist of a single opcode and a datestamp.
|
|
||||||
* This serves to record that a particular event happened at a particular date.
|
|
||||||
* Many of the subclasses of this class only override the opcode.
|
|
||||||
*/
|
|
||||||
abstract public class TimeStampedRecord extends Record {
|
|
||||||
|
|
||||||
// private final static String TAG = "TimeStampedRecord";
|
|
||||||
private final static boolean DEBUG_TIMESTAMPEDRECORD = false;
|
|
||||||
protected PumpTimeStamp timestamp;
|
|
||||||
|
|
||||||
|
|
||||||
public TimeStampedRecord() {
|
|
||||||
timestamp = new PumpTimeStamp();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getLength() {
|
|
||||||
return 7;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public int getDatestampOffset() {
|
|
||||||
return 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public PumpTimeStamp getTimestamp() {
|
|
||||||
return timestamp;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean parseFrom(byte[] data, MedtronicDeviceType model) {
|
|
||||||
return simpleParse(data, getDatestampOffset());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// This is useful if there is no data inside, or we don't care about the data.
|
|
||||||
public boolean simpleParse(byte[] data, int fiveByteDateOffset) {
|
|
||||||
if (getLength() > data.length) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (!collectTimeStamp(data, fiveByteDateOffset)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
rawbytes = ByteUtil.substring(data, 0, getLength());
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
protected boolean collectTimeStamp(byte[] data, int offset) {
|
|
||||||
try {
|
|
||||||
timestamp = new PumpTimeStamp(TimeFormat.parse5ByteDate(data, offset));
|
|
||||||
} catch (org.joda.time.IllegalFieldValueException e) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean readFromBundle(Bundle in) {
|
|
||||||
String timestampString = in.getString("timestamp");
|
|
||||||
timestamp = new PumpTimeStamp(timestampString);
|
|
||||||
return super.readFromBundle(in);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void writeToBundle(Bundle in) {
|
|
||||||
super.writeToBundle(in);
|
|
||||||
in.putString("timestamp", timestamp.toString());
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,25 +0,0 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.record;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.TimeStampedRecord;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by geoff on 6/11/16.
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public class AlarmClockReminderPumpEvent extends TimeStampedRecord {
|
|
||||||
|
|
||||||
public AlarmClockReminderPumpEvent() {
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getShortTypeName() {
|
|
||||||
return "Alarm Reminder";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isAAPSRelevant() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,31 +0,0 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.record;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.TimeStampedRecord;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by geoff on 6/5/16.
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public class AlarmSensorPumpEvent extends TimeStampedRecord {
|
|
||||||
|
|
||||||
public AlarmSensorPumpEvent() {
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getLength() {
|
|
||||||
return 8;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getShortTypeName() {
|
|
||||||
return "Alarm Sensor";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isAAPSRelevant() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,62 +0,0 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.record;
|
|
||||||
|
|
||||||
import android.os.Bundle;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.plugins.pump.common.utils.ByteUtil;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.TimeStampedRecord;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.defs.MedtronicDeviceType;
|
|
||||||
|
|
||||||
public class BGReceivedPumpEvent extends TimeStampedRecord {
|
|
||||||
|
|
||||||
private int amount = 0;
|
|
||||||
private byte[] meter = new byte[3];
|
|
||||||
|
|
||||||
|
|
||||||
public BGReceivedPumpEvent() {
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getLength() {
|
|
||||||
return 10;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getShortTypeName() {
|
|
||||||
return "BG Received";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean parseFrom(byte[] data, MedtronicDeviceType model) {
|
|
||||||
if (!super.simpleParse(data, 2)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
amount = (asUINT8(data[1]) << 3) + (asUINT8(data[4]) >> 5);
|
|
||||||
meter = ByteUtil.substring(data, 7, 3);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean readFromBundle(Bundle in) {
|
|
||||||
amount = in.getInt("amount");
|
|
||||||
meter = in.getByteArray("meter");
|
|
||||||
return super.readFromBundle(in);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void writeToBundle(Bundle in) {
|
|
||||||
super.writeToBundle(in);
|
|
||||||
in.putInt("amount", amount);
|
|
||||||
in.putByteArray("meter", meter);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isAAPSRelevant() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,67 +0,0 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.record;
|
|
||||||
|
|
||||||
import android.os.Bundle;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.TimeStampedRecord;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.defs.MedtronicDeviceType;
|
|
||||||
|
|
||||||
public class BasalProfileStart extends TimeStampedRecord {
|
|
||||||
|
|
||||||
private static final String TAG = "BasalProfileStart";
|
|
||||||
private int offset = 0;
|
|
||||||
private double rate = 0.0;
|
|
||||||
private int profileIndex = 0;
|
|
||||||
|
|
||||||
|
|
||||||
public BasalProfileStart() {
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getLength() {
|
|
||||||
return 10;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getShortTypeName() {
|
|
||||||
return "Basal Profile Start";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean parseFrom(byte[] data, MedtronicDeviceType model) {
|
|
||||||
if (!simpleParse(data, 2)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
profileIndex = asUINT8(data[1]);
|
|
||||||
offset = asUINT8(data[7]) * 30 * 1000 * 60;
|
|
||||||
rate = (double)(asUINT8(data[8])) / 40.0;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean readFromBundle(Bundle in) {
|
|
||||||
offset = in.getInt("offset");
|
|
||||||
rate = in.getDouble("rate");
|
|
||||||
profileIndex = in.getInt("profileIndex");
|
|
||||||
return super.readFromBundle(in);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void writeToBundle(Bundle in) {
|
|
||||||
super.writeToBundle(in);
|
|
||||||
in.putInt("offset", offset);
|
|
||||||
in.putDouble("rate", rate);
|
|
||||||
in.putInt("profileIndex", profileIndex);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isAAPSRelevant() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,21 +0,0 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.record;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.TimeStampedRecord;
|
|
||||||
|
|
||||||
public class BatteryPumpEvent extends TimeStampedRecord {
|
|
||||||
|
|
||||||
public BatteryPumpEvent() {
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getShortTypeName() {
|
|
||||||
return "Battery";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isAAPSRelevant() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,101 +0,0 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.record;
|
|
||||||
|
|
||||||
import android.os.Bundle;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.PumpTimeStamp;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.TimeFormat;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.TimeStampedRecord;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.defs.MedtronicDeviceType;
|
|
||||||
|
|
||||||
public class BolusNormalPumpEvent extends TimeStampedRecord {
|
|
||||||
|
|
||||||
private final static String TAG = "BolusNormalPumpEvent";
|
|
||||||
|
|
||||||
private double programmedAmount = 0.0;
|
|
||||||
private double deliveredAmount = 0.0;
|
|
||||||
private int duration = 0;
|
|
||||||
private double unabsorbedInsulinTotal = 0.0;
|
|
||||||
private String bolusType = "Unset";
|
|
||||||
|
|
||||||
|
|
||||||
public BolusNormalPumpEvent() {
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getLength() {
|
|
||||||
return isLargerFormat() ? 13 : 9;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getShortTypeName() {
|
|
||||||
return "Normal Bolus";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private double insulinDecode(int a, int b) {
|
|
||||||
return ((a << 8) + b) / 40.0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean parseFrom(byte[] data, MedtronicDeviceType model) {
|
|
||||||
if (getLength() > data.length) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (MedtronicDeviceType.isLargerFormat(model)) {
|
|
||||||
programmedAmount = insulinDecode(asUINT8(data[1]), asUINT8(data[2]));
|
|
||||||
deliveredAmount = insulinDecode(asUINT8(data[3]), asUINT8(data[4]));
|
|
||||||
unabsorbedInsulinTotal = insulinDecode(asUINT8(data[5]), asUINT8(data[6]));
|
|
||||||
duration = asUINT8(data[7]) * 30;
|
|
||||||
try {
|
|
||||||
timestamp = new PumpTimeStamp(TimeFormat.parse5ByteDate(data, 8));
|
|
||||||
} catch (org.joda.time.IllegalFieldValueException e) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
programmedAmount = asUINT8(data[1]) / 10.0f;
|
|
||||||
deliveredAmount = asUINT8(data[2]) / 10.0f;
|
|
||||||
duration = asUINT8(data[3]) * 30;
|
|
||||||
unabsorbedInsulinTotal = 0;
|
|
||||||
try {
|
|
||||||
timestamp = new PumpTimeStamp(TimeFormat.parse5ByteDate(data, 4));
|
|
||||||
} catch (org.joda.time.IllegalFieldValueException e) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
bolusType = (duration > 0) ? "square" : "normal";
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean readFromBundle(Bundle in) {
|
|
||||||
programmedAmount = in.getDouble("programmedAmount", 0.0);
|
|
||||||
deliveredAmount = in.getDouble("deliveredAmount", 0.0);
|
|
||||||
duration = in.getInt("duration", 0);
|
|
||||||
unabsorbedInsulinTotal = in.getDouble("unabsorbedInsulinTotal", 0.0);
|
|
||||||
bolusType = in.getString("bolusType", "Unset");
|
|
||||||
return super.readFromBundle(in);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void writeToBundle(Bundle in) {
|
|
||||||
super.writeToBundle(in);
|
|
||||||
in.putDouble("programmedAmount", programmedAmount);
|
|
||||||
in.putDouble("deliveredAmount", deliveredAmount);
|
|
||||||
in.putInt("duration", duration);
|
|
||||||
in.putDouble("unabsorbedInsulinTotal", unabsorbedInsulinTotal);
|
|
||||||
in.putString("bolusType", bolusType);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isAAPSRelevant() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,172 +0,0 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.record;
|
|
||||||
|
|
||||||
import android.os.Bundle;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.TimeStampedRecord;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.defs.MedtronicDeviceType;
|
|
||||||
|
|
||||||
public class BolusWizardBolusEstimatePumpEvent extends TimeStampedRecord {
|
|
||||||
|
|
||||||
private int carbohydrates;
|
|
||||||
private int bloodGlucose;
|
|
||||||
private double foodEstimate;
|
|
||||||
private double correctionEstimate;
|
|
||||||
private double bolusEstimate;
|
|
||||||
private double unabsorbedInsulinTotal;
|
|
||||||
private int bgTargetLow;
|
|
||||||
private int bgTargetHigh;
|
|
||||||
private int insulinSensitivity;
|
|
||||||
private double carbRatio;
|
|
||||||
|
|
||||||
|
|
||||||
public BolusWizardBolusEstimatePumpEvent() {
|
|
||||||
correctionEstimate = (double)0.0;
|
|
||||||
bloodGlucose = 0;
|
|
||||||
carbohydrates = 0;
|
|
||||||
carbRatio = 0.0;
|
|
||||||
insulinSensitivity = 0;
|
|
||||||
bgTargetLow = 0;
|
|
||||||
bgTargetHigh = 0;
|
|
||||||
bolusEstimate = 0.0;
|
|
||||||
foodEstimate = 0.0;
|
|
||||||
unabsorbedInsulinTotal = 0.0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getLength() {
|
|
||||||
return isLargerFormat() ? 22 : 20;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getShortTypeName() {
|
|
||||||
return "Bolus Wizard Est.";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean readFromBundle(Bundle in) {
|
|
||||||
carbohydrates = in.getInt("carbohydrates", 0);
|
|
||||||
bloodGlucose = in.getInt("bloodGlucose", 0);
|
|
||||||
foodEstimate = in.getDouble("foodEstimate", 0);
|
|
||||||
correctionEstimate = in.getDouble("correctionEstimate", 0);
|
|
||||||
bolusEstimate = in.getDouble("bolusEstimate", 0);
|
|
||||||
unabsorbedInsulinTotal = in.getDouble("unabsorbedInsulinTotal", 0);
|
|
||||||
bgTargetLow = in.getInt("bgTargetLow", 0);
|
|
||||||
bgTargetHigh = in.getInt("bgTargetHigh", 0);
|
|
||||||
insulinSensitivity = in.getInt("insulinSensitivity", 0);
|
|
||||||
carbRatio = in.getDouble("carbRatio", 0);
|
|
||||||
return super.readFromBundle(in);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void writeToBundle(Bundle in) {
|
|
||||||
super.writeToBundle(in);
|
|
||||||
in.putInt("carbohydrates", carbohydrates);
|
|
||||||
in.putInt("bloodGlucose", bloodGlucose);
|
|
||||||
in.putDouble("foodEstimate", foodEstimate);
|
|
||||||
in.putDouble("correctionEstimate", correctionEstimate);
|
|
||||||
in.putDouble("bolusEstimate", bolusEstimate);
|
|
||||||
in.putDouble("unabsorbedInsulinTotal", unabsorbedInsulinTotal);
|
|
||||||
in.putInt("bgTargetLow", bgTargetLow);
|
|
||||||
in.putInt("bgTargetHigh", bgTargetHigh);
|
|
||||||
in.putInt("insulinSensitivity", insulinSensitivity);
|
|
||||||
in.putDouble("carbRatio", carbRatio);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public double getCorrectionEstimate() {
|
|
||||||
return correctionEstimate;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public long getBG() {
|
|
||||||
return bloodGlucose;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public int getCarbohydrates() {
|
|
||||||
return carbohydrates;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public double getICRatio() {
|
|
||||||
return carbRatio;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public int getInsulinSensitivity() {
|
|
||||||
return insulinSensitivity;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public int getBgTargetLow() {
|
|
||||||
return bgTargetLow;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public int getBgTargetHigh() {
|
|
||||||
return bgTargetHigh;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public double getBolusEstimate() {
|
|
||||||
return bolusEstimate;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public double getFoodEstimate() {
|
|
||||||
return foodEstimate;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public double getUnabsorbedInsulinTotal() {
|
|
||||||
return unabsorbedInsulinTotal;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private double insulinDecode(int a, int b) {
|
|
||||||
return ((a << 8) + b) / 40.0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean parseFrom(byte[] data, MedtronicDeviceType model) {
|
|
||||||
if (!simpleParse(data, 2)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (MedtronicDeviceType.isLargerFormat(model)) {
|
|
||||||
carbohydrates = (asUINT8(data[8]) & 0x0c << 6) + asUINT8(data[7]);
|
|
||||||
bloodGlucose = (asUINT8(data[8]) & 0x03 << 8) + asUINT8(data[1]);
|
|
||||||
foodEstimate = insulinDecode(asUINT8(data[14]), asUINT8(data[15]));
|
|
||||||
correctionEstimate = (double)((asUINT8(data[16]) & 0b111000) << 5 + asUINT8(data[13])) / 40.0;
|
|
||||||
bolusEstimate = insulinDecode(asUINT8(data[19]), asUINT8(data[20]));
|
|
||||||
unabsorbedInsulinTotal = insulinDecode(asUINT8(data[17]), asUINT8(data[18]));
|
|
||||||
bgTargetLow = asUINT8(data[12]);
|
|
||||||
bgTargetHigh = asUINT8(data[21]);
|
|
||||||
insulinSensitivity = asUINT8(data[11]);
|
|
||||||
carbRatio = (double)(((asUINT8(data[9]) & 0x07) << 8) + asUINT8(data[10])) / 40.0;
|
|
||||||
} else {
|
|
||||||
carbohydrates = asUINT8(data[7]);
|
|
||||||
bloodGlucose = ((asUINT8(data[8]) & 0x03) << 8) + asUINT8(data[1]);
|
|
||||||
foodEstimate = (double)(asUINT8(data[13])) / 10.0;
|
|
||||||
correctionEstimate = (double)((asUINT8(data[14]) << 8) + asUINT8(data[12])) / 10.0;
|
|
||||||
bolusEstimate = (double)(asUINT8(data[18])) / 10.0;
|
|
||||||
unabsorbedInsulinTotal = (double)(asUINT8(data[16])) / 10.0;
|
|
||||||
bgTargetLow = asUINT8(data[11]);
|
|
||||||
bgTargetHigh = asUINT8(data[19]);
|
|
||||||
insulinSensitivity = asUINT8(data[10]);
|
|
||||||
carbRatio = (double)asUINT8(data[9]);
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isAAPSRelevant() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,51 +0,0 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.record;
|
|
||||||
|
|
||||||
import android.os.Bundle;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.TimeStampedRecord;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.defs.MedtronicDeviceType;
|
|
||||||
|
|
||||||
public class CalBgForPhPumpEvent extends TimeStampedRecord {
|
|
||||||
|
|
||||||
private int amount = 0;
|
|
||||||
|
|
||||||
|
|
||||||
public CalBgForPhPumpEvent() {
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getShortTypeName() {
|
|
||||||
return "Cal Bg For Ph";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean parseFrom(byte[] data, MedtronicDeviceType model) {
|
|
||||||
if (!simpleParse(data, 2)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
amount = ((asUINT8(data[6]) & 0x80) << 1) + asUINT8(data[1]);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean readFromBundle(Bundle in) {
|
|
||||||
amount = in.getInt("amount", 0);
|
|
||||||
return super.readFromBundle(in);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void writeToBundle(Bundle in) {
|
|
||||||
super.writeToBundle(in);
|
|
||||||
in.putInt("amount", amount);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isAAPSRelevant() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,24 +0,0 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.record;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.TimeStampedRecord;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by geoff on 6/5/16.
|
|
||||||
*/
|
|
||||||
public class ChangeAlarmClockEnablePumpEvent extends TimeStampedRecord {
|
|
||||||
|
|
||||||
public ChangeAlarmClockEnablePumpEvent() {
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getShortTypeName() {
|
|
||||||
return "Alarm Clock Enable";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isAAPSRelevant() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,22 +0,0 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.record;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.TimeStampedRecord;
|
|
||||||
|
|
||||||
public class ChangeAlarmNotifyModePumpEvent extends TimeStampedRecord {
|
|
||||||
|
|
||||||
public ChangeAlarmNotifyModePumpEvent() {
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getShortTypeName() {
|
|
||||||
return "Ch Alarm Notify Mode";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isAAPSRelevant() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,24 +0,0 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.record;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.TimeStampedRecord;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by geoff on 6/5/16.
|
|
||||||
*/
|
|
||||||
public class ChangeAudioBolusPumpEvent extends TimeStampedRecord {
|
|
||||||
|
|
||||||
public ChangeAudioBolusPumpEvent() {
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getShortTypeName() {
|
|
||||||
return "Ch Audio Bolus";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isAAPSRelevant() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,24 +0,0 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.record;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.TimeStampedRecord;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by geoff on 6/5/16.
|
|
||||||
*/
|
|
||||||
public class ChangeBGReminderEnablePumpEvent extends TimeStampedRecord {
|
|
||||||
|
|
||||||
public ChangeBGReminderEnablePumpEvent() {
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getShortTypeName() {
|
|
||||||
return "Ch BG Rmndr Enable";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isAAPSRelevant() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,31 +0,0 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.record;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.TimeStampedRecord;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by geoff on 6/5/16.
|
|
||||||
*/
|
|
||||||
public class ChangeBasalProfilePatternPumpEvent extends TimeStampedRecord {
|
|
||||||
|
|
||||||
public ChangeBasalProfilePatternPumpEvent() {
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getLength() {
|
|
||||||
return 152;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getShortTypeName() {
|
|
||||||
return "Ch Basal Prof Pat";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isAAPSRelevant() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,28 +0,0 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.record;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.TimeStampedRecord;
|
|
||||||
|
|
||||||
public class ChangeBasalProfilePumpEvent extends TimeStampedRecord {
|
|
||||||
|
|
||||||
public ChangeBasalProfilePumpEvent() {
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getLength() {
|
|
||||||
return 152;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getShortTypeName() {
|
|
||||||
return "Ch Basal Profile";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isAAPSRelevant() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,31 +0,0 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.record;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.TimeStampedRecord;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by geoff on 6/5/16.
|
|
||||||
*/
|
|
||||||
public class ChangeBolusReminderEnablePumpEvent extends TimeStampedRecord {
|
|
||||||
|
|
||||||
public ChangeBolusReminderEnablePumpEvent() {
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getLength() {
|
|
||||||
return 9;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getShortTypeName() {
|
|
||||||
return "Ch Bolus Rmndr Enable";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isAAPSRelevant() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,30 +0,0 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.record;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.TimeStampedRecord;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by geoff on 6/5/16.
|
|
||||||
*/
|
|
||||||
public class ChangeBolusReminderTimePumpEvent extends TimeStampedRecord {
|
|
||||||
|
|
||||||
public ChangeBolusReminderTimePumpEvent() {
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getShortTypeName() {
|
|
||||||
return "Ch Bolus Rmndr Time";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getLength() {
|
|
||||||
return 9;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isAAPSRelevant() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,24 +0,0 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.record;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.TimeStampedRecord;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by geoff on 6/5/16.
|
|
||||||
*/
|
|
||||||
public class ChangeBolusScrollStepSizePumpEvent extends TimeStampedRecord {
|
|
||||||
|
|
||||||
public ChangeBolusScrollStepSizePumpEvent() {
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getShortTypeName() {
|
|
||||||
return "Ch Bolus Scroll SS";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isAAPSRelevant() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,27 +0,0 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.record;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.TimeStampedRecord;
|
|
||||||
|
|
||||||
public class ChangeBolusWizardSetupPumpEvent extends TimeStampedRecord {
|
|
||||||
|
|
||||||
public ChangeBolusWizardSetupPumpEvent() {
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getLength() {
|
|
||||||
return 144;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getShortTypeName() {
|
|
||||||
return "Ch Bolus Wizard Setup";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isAAPSRelevant() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,24 +0,0 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.record;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.TimeStampedRecord;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by geoff on 6/5/16.
|
|
||||||
*/
|
|
||||||
public class ChangeCaptureEventEnablePumpEvent extends TimeStampedRecord {
|
|
||||||
|
|
||||||
public ChangeCaptureEventEnablePumpEvent() {
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getShortTypeName() {
|
|
||||||
return "Ch Capture Event Ena";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isAAPSRelevant() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,24 +0,0 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.record;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.TimeStampedRecord;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by geoff on 6/5/16.
|
|
||||||
*/
|
|
||||||
public class ChangeCarbUnitsPumpEvent extends TimeStampedRecord {
|
|
||||||
|
|
||||||
public ChangeCarbUnitsPumpEvent() {
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getShortTypeName() {
|
|
||||||
return "Ch Carb Units";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isAAPSRelevant() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,24 +0,0 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.record;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.TimeStampedRecord;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by geoff on 6/5/16.
|
|
||||||
*/
|
|
||||||
public class ChangeChildBlockEnablePumpEvent extends TimeStampedRecord {
|
|
||||||
|
|
||||||
public ChangeChildBlockEnablePumpEvent() {
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getShortTypeName() {
|
|
||||||
return "Ch Child Block Ena";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isAAPSRelevant() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,24 +0,0 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.record;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.TimeStampedRecord;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by geoff on 6/5/16.
|
|
||||||
*/
|
|
||||||
public class ChangeMaxBolusPumpEvent extends TimeStampedRecord {
|
|
||||||
|
|
||||||
public ChangeMaxBolusPumpEvent() {
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getShortTypeName() {
|
|
||||||
return "Ch Max Bolux";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isAAPSRelevant() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,27 +0,0 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.record;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.TimeStampedRecord;
|
|
||||||
|
|
||||||
public class ChangeOtherDeviceIDPumpEvent extends TimeStampedRecord {
|
|
||||||
|
|
||||||
public ChangeOtherDeviceIDPumpEvent() {
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getLength() {
|
|
||||||
return 37;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getShortTypeName() {
|
|
||||||
return "Ch Other Dev ID";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isAAPSRelevant() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,24 +0,0 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.record;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.TimeStampedRecord;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by geoff on 6/5/16.
|
|
||||||
*/
|
|
||||||
public class ChangeReservoirWarningTimePumpEvent extends TimeStampedRecord {
|
|
||||||
|
|
||||||
public ChangeReservoirWarningTimePumpEvent() {
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getShortTypeName() {
|
|
||||||
return "Ch Res Warn Time";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isAAPSRelevant() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,30 +0,0 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.record;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.TimeStampedRecord;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by geoff on 6/5/16.
|
|
||||||
*/
|
|
||||||
public class ChangeSensorRateOfChangeAlertSetupPumpEvent extends TimeStampedRecord {
|
|
||||||
|
|
||||||
public ChangeSensorRateOfChangeAlertSetupPumpEvent() {
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getLength() {
|
|
||||||
return 12;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getShortTypeName() {
|
|
||||||
return "Ch Sensor ROC Alert";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isAAPSRelevant() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,31 +0,0 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.record;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.TimeStampedRecord;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by geoff on 6/5/16.
|
|
||||||
*/
|
|
||||||
public class ChangeSensorSetup2PumpEvent extends TimeStampedRecord {
|
|
||||||
|
|
||||||
public ChangeSensorSetup2PumpEvent() {
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getLength() {
|
|
||||||
return 37;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getShortTypeName() {
|
|
||||||
return "Ch Sensor Setup2";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isAAPSRelevant() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,58 +0,0 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.record;
|
|
||||||
|
|
||||||
import android.os.Bundle;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.TimeStampedRecord;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.defs.MedtronicDeviceType;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by geoff on 6/5/16.
|
|
||||||
*/
|
|
||||||
public class ChangeTempBasalTypePumpEvent extends TimeStampedRecord {
|
|
||||||
|
|
||||||
private boolean isPercent = false; // either absolute or percent
|
|
||||||
|
|
||||||
|
|
||||||
public ChangeTempBasalTypePumpEvent() {
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getShortTypeName() {
|
|
||||||
return "Ch Temp Basal Type";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean parseFrom(byte[] data, MedtronicDeviceType model) {
|
|
||||||
if (!simpleParse(data, 2)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (asUINT8(data[1]) == 1) {
|
|
||||||
isPercent = true;
|
|
||||||
} else {
|
|
||||||
isPercent = false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean readFromBundle(Bundle in) {
|
|
||||||
isPercent = in.getBoolean("isPercent", false);
|
|
||||||
return super.readFromBundle(in);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void writeToBundle(Bundle in) {
|
|
||||||
in.putBoolean("isPercent", isPercent);
|
|
||||||
super.writeToBundle(in);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isAAPSRelevant() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,21 +0,0 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.record;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.TimeStampedRecord;
|
|
||||||
|
|
||||||
public class ChangeTimeFormatPumpEvent extends TimeStampedRecord {
|
|
||||||
|
|
||||||
public ChangeTimeFormatPumpEvent() {
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getShortTypeName() {
|
|
||||||
return "Ch Time Format";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isAAPSRelevant() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,28 +0,0 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.record;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.TimeStampedRecord;
|
|
||||||
|
|
||||||
public class ChangeTimePumpEvent extends TimeStampedRecord {
|
|
||||||
|
|
||||||
public ChangeTimePumpEvent() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getLength() {
|
|
||||||
return 14;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getShortTypeName() {
|
|
||||||
return "Change Time";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isAAPSRelevant() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,24 +0,0 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.record;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.TimeStampedRecord;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by geoff on 6/5/16.
|
|
||||||
*/
|
|
||||||
public class ChangeVariableBolusPumpEvent extends TimeStampedRecord {
|
|
||||||
|
|
||||||
public ChangeVariableBolusPumpEvent() {
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getShortTypeName() {
|
|
||||||
return "Ch Var. Bolus";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isAAPSRelevant() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,24 +0,0 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.record;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.TimeStampedRecord;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by geoff on 6/5/16.
|
|
||||||
*/
|
|
||||||
public class ChangeWatchdogEnablePumpEvent extends TimeStampedRecord {
|
|
||||||
|
|
||||||
public ChangeWatchdogEnablePumpEvent() {
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getShortTypeName() {
|
|
||||||
return "Ch Watchdog Enable";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isAAPSRelevant() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,31 +0,0 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.record;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.TimeStampedRecord;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by geoff on 6/5/16.
|
|
||||||
*/
|
|
||||||
public class ChangeWatchdogMarriageProfilePumpEvent extends TimeStampedRecord {
|
|
||||||
|
|
||||||
public ChangeWatchdogMarriageProfilePumpEvent() {
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getLength() {
|
|
||||||
return 12;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getShortTypeName() {
|
|
||||||
return "Ch WD Marriage";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isAAPSRelevant() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,22 +0,0 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.record;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.TimeStampedRecord;
|
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
public class ClearAlarmPumpEvent extends TimeStampedRecord {
|
|
||||||
|
|
||||||
public ClearAlarmPumpEvent() {
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getShortTypeName() {
|
|
||||||
return "Clear Alarm";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isAAPSRelevant() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,30 +0,0 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.record;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.TimeStampedRecord;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by geoff on 6/5/16.
|
|
||||||
*/
|
|
||||||
public class DeleteAlarmClockTimePumpEvent extends TimeStampedRecord {
|
|
||||||
|
|
||||||
public DeleteAlarmClockTimePumpEvent() {
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getLength() {
|
|
||||||
return 14;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getShortTypeName() {
|
|
||||||
return "Del Alarm Clock Time";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isAAPSRelevant() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,30 +0,0 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.record;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.TimeStampedRecord;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by geoff on 6/5/16.
|
|
||||||
*/
|
|
||||||
public class DeleteBolusReminderTimePumpEvent extends TimeStampedRecord {
|
|
||||||
|
|
||||||
public DeleteBolusReminderTimePumpEvent() {
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getLength() {
|
|
||||||
return 9;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getShortTypeName() {
|
|
||||||
return "Del Bolus Rmndr Time";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isAAPSRelevant() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,31 +0,0 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.record;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.TimeStampedRecord;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by geoff on 6/5/16.
|
|
||||||
*/
|
|
||||||
public class DeleteOtherDeviceIDPumpEvent extends TimeStampedRecord {
|
|
||||||
|
|
||||||
public DeleteOtherDeviceIDPumpEvent() {
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getLength() {
|
|
||||||
return 12;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getShortTypeName() {
|
|
||||||
return "Del Other Dev ID";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isAAPSRelevant() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,27 +0,0 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.record;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.TimeStampedRecord;
|
|
||||||
|
|
||||||
public class EnableDisableRemotePumpEvent extends TimeStampedRecord {
|
|
||||||
|
|
||||||
public EnableDisableRemotePumpEvent() {
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getLength() {
|
|
||||||
return 21;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getShortTypeName() {
|
|
||||||
return "Toggle Remote";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isAAPSRelevant() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,54 +0,0 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.record;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.Record;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.RecordTypeEnum;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.defs.MedtronicDeviceType;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by andy on 6/1/18.
|
|
||||||
*/
|
|
||||||
|
|
||||||
public class IgnoredHistoryEntry extends Record {
|
|
||||||
|
|
||||||
// public int lngth = 7;
|
|
||||||
private RecordTypeEnum typeEnum = RecordTypeEnum.Null;
|
|
||||||
|
|
||||||
|
|
||||||
public IgnoredHistoryEntry() {
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void init(RecordTypeEnum typeEnum) {
|
|
||||||
this.typeEnum = typeEnum;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getLength() {
|
|
||||||
return this.typeEnum.getLength();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getRecordTypeName() {
|
|
||||||
return typeEnum.name();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getShortTypeName() {
|
|
||||||
return typeEnum.name();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean parseFrom(byte[] data, MedtronicDeviceType model) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isAAPSRelevant() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,36 +0,0 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.record;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.TimeStampedRecord;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by geoff on 7/16/16.
|
|
||||||
*/
|
|
||||||
public class InsulinMarkerEvent extends TimeStampedRecord {
|
|
||||||
|
|
||||||
public InsulinMarkerEvent() {
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getLength() {
|
|
||||||
return 8;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Darrell Wright:
|
|
||||||
* it is a manual entry of a bolus that the pump didn't deliver, so opcode, timestamp and at least a number to
|
|
||||||
* represent the units of insulin
|
|
||||||
*/
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getShortTypeName() {
|
|
||||||
return "UnknownInsulin";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isAAPSRelevant() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,30 +0,0 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.record;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.TimeStampedRecord;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by geoff on 6/5/16.
|
|
||||||
*/
|
|
||||||
public class JournalEntryExerciseMarkerPumpEvent extends TimeStampedRecord {
|
|
||||||
|
|
||||||
public JournalEntryExerciseMarkerPumpEvent() {
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getLength() {
|
|
||||||
return 8;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getShortTypeName() {
|
|
||||||
return "Exercise Marker";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isAAPSRelevant() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,21 +0,0 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.record;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.TimeStampedRecord;
|
|
||||||
|
|
||||||
public class JournalEntryPumpLowBatteryPumpEvent extends TimeStampedRecord {
|
|
||||||
|
|
||||||
public JournalEntryPumpLowBatteryPumpEvent() {
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getShortTypeName() {
|
|
||||||
return "Low Battery";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isAAPSRelevant() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,21 +0,0 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.record;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.TimeStampedRecord;
|
|
||||||
|
|
||||||
public class JournalEntryPumpLowReservoirPumpEvent extends TimeStampedRecord {
|
|
||||||
|
|
||||||
public JournalEntryPumpLowReservoirPumpEvent() {
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getShortTypeName() {
|
|
||||||
return "Low Reservoir";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isAAPSRelevant() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,33 +0,0 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.record;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.TimeStampedRecord;
|
|
||||||
|
|
||||||
public class Model522ResultTotalsPumpEvent extends TimeStampedRecord {
|
|
||||||
|
|
||||||
public Model522ResultTotalsPumpEvent() {
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getDatestampOffset() {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getLength() {
|
|
||||||
return 44;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getShortTypeName() {
|
|
||||||
return "M522 Result Totals";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isAAPSRelevant() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,24 +0,0 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.record;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.TimeStampedRecord;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.defs.MedtronicDeviceType;
|
|
||||||
|
|
||||||
// This event existed as 0x18 in Roundtrip and early Decocare,
|
|
||||||
// but I don't see a corresponding event in RileyLink_ios.
|
|
||||||
public class NewTimeSet extends TimeStampedRecord {
|
|
||||||
|
|
||||||
public NewTimeSet() {
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean parseFrom(byte[] data, MedtronicDeviceType model) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isAAPSRelevant() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,66 +0,0 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.record;
|
|
||||||
|
|
||||||
import android.os.Bundle;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.TimeStampedRecord;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.defs.MedtronicDeviceType;
|
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
public class PrimePumpEvent extends TimeStampedRecord {
|
|
||||||
|
|
||||||
private double amount = 0.0;
|
|
||||||
private double programmedAmount = 0.0;
|
|
||||||
private String primeType = "unknown";
|
|
||||||
|
|
||||||
|
|
||||||
public PrimePumpEvent() {
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getLength() {
|
|
||||||
return 10;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getShortTypeName() {
|
|
||||||
return "Prime Pump";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean parseFrom(byte[] data, MedtronicDeviceType model) {
|
|
||||||
if (!simpleParse(data, 5)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
amount = (double)(asUINT8(data[4]) << 2) / 40.0;
|
|
||||||
programmedAmount = (double)(asUINT8(data[2]) << 2) / 40.0;
|
|
||||||
primeType = programmedAmount == 0 ? "manual" : "fixed";
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean readFromBundle(Bundle in) {
|
|
||||||
amount = in.getDouble("amount", 0.0);
|
|
||||||
programmedAmount = in.getDouble("programmedAmount", 0);
|
|
||||||
primeType = in.getString("primeType", "unknown");
|
|
||||||
return super.readFromBundle(in);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void writeToBundle(Bundle in) {
|
|
||||||
in.putDouble("amount", amount);
|
|
||||||
in.putDouble("programmedAmount", programmedAmount);
|
|
||||||
in.putString("primeType", primeType);
|
|
||||||
super.writeToBundle(in);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isAAPSRelevant() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,57 +0,0 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.record;
|
|
||||||
|
|
||||||
import android.os.Bundle;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.TimeStampedRecord;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.defs.MedtronicDeviceType;
|
|
||||||
|
|
||||||
public class PumpAlarmPumpEvent extends TimeStampedRecord {
|
|
||||||
|
|
||||||
private int rawtype = 0;
|
|
||||||
|
|
||||||
|
|
||||||
public PumpAlarmPumpEvent() {
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getLength() {
|
|
||||||
return 9;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getShortTypeName() {
|
|
||||||
return "Pump Alarm";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean parseFrom(byte[] data, MedtronicDeviceType model) {
|
|
||||||
if (!simpleParse(data, 4)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
rawtype = asUINT8(data[1]);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean readFromBundle(Bundle in) {
|
|
||||||
rawtype = in.getInt("rawtype", 0);
|
|
||||||
return super.readFromBundle(in);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void writeToBundle(Bundle in) {
|
|
||||||
in.putInt("rawtype", rawtype);
|
|
||||||
super.writeToBundle(in);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isAAPSRelevant() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,51 +0,0 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.record;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.PumpTimeStamp;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.TimeFormat;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.TimeStampedRecord;
|
|
||||||
|
|
||||||
public class ResultDailyTotalPumpEvent extends TimeStampedRecord {
|
|
||||||
|
|
||||||
private static final String TAG = "ResultDailyTotalPumpEvent";
|
|
||||||
|
|
||||||
|
|
||||||
public ResultDailyTotalPumpEvent() {
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getDatestampOffset() {
|
|
||||||
return 5;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getLength() {
|
|
||||||
return isLargerFormat() ? 10 : 7;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected boolean collectTimeStamp(byte[] data, int offset) {
|
|
||||||
try {
|
|
||||||
// This might be a 5 byte date on largerFormat
|
|
||||||
timestamp = new PumpTimeStamp(TimeFormat.parse2ByteDate(data, offset));
|
|
||||||
} catch (org.joda.time.IllegalFieldValueException e) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getShortTypeName() {
|
|
||||||
return "Result Daily Total";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isAAPSRelevant() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,21 +0,0 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.record;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.TimeStampedRecord;
|
|
||||||
|
|
||||||
public class ResumePumpEvent extends TimeStampedRecord {
|
|
||||||
|
|
||||||
public ResumePumpEvent() {
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getShortTypeName() {
|
|
||||||
return "Resume";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isAAPSRelevant() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,21 +0,0 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.record;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.TimeStampedRecord;
|
|
||||||
|
|
||||||
public class RewindPumpEvent extends TimeStampedRecord {
|
|
||||||
|
|
||||||
public RewindPumpEvent() {
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getShortTypeName() {
|
|
||||||
return "Rewind";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isAAPSRelevant() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,47 +0,0 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.record;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.PumpTimeStamp;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.TimeFormat;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.TimeStampedRecord;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.defs.MedtronicDeviceType;
|
|
||||||
|
|
||||||
public class Sara6EPumpEvent extends TimeStampedRecord {
|
|
||||||
|
|
||||||
public Sara6EPumpEvent() {
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getLength() {
|
|
||||||
return 52;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getShortTypeName() {
|
|
||||||
return "Sara6E";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean parseFrom(byte[] data, MedtronicDeviceType model) {
|
|
||||||
// We don't understand this event...
|
|
||||||
// Minimum 16 characters? date components?
|
|
||||||
if (16 > data.length) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
timestamp = new PumpTimeStamp(TimeFormat.parse2ByteDate(data, 1));
|
|
||||||
} catch (org.joda.time.IllegalFieldValueException e) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isAAPSRelevant() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,21 +0,0 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.record;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.TimeStampedRecord;
|
|
||||||
|
|
||||||
public class SuspendPumpEvent extends TimeStampedRecord {
|
|
||||||
|
|
||||||
public SuspendPumpEvent() {
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getShortTypeName() {
|
|
||||||
return "Suspend";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isAAPSRelevant() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,58 +0,0 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.record;
|
|
||||||
|
|
||||||
import android.os.Bundle;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.TimeStampedRecord;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.defs.MedtronicDeviceType;
|
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
public class TempBasalDurationPumpEvent extends TimeStampedRecord {
|
|
||||||
|
|
||||||
private int durationMinutes = 0;
|
|
||||||
|
|
||||||
|
|
||||||
public TempBasalDurationPumpEvent() {
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getShortTypeName() {
|
|
||||||
return "Temp Basal Duration";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public int getDurationMinutes() {
|
|
||||||
return durationMinutes;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean parseFrom(byte[] data, MedtronicDeviceType model) {
|
|
||||||
if (!simpleParse(data, 2)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
durationMinutes = asUINT8(data[1]) * 30;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean readFromBundle(Bundle in) {
|
|
||||||
durationMinutes = in.getInt("durationMinutes", 0);
|
|
||||||
return super.readFromBundle(in);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void writeToBundle(Bundle in) {
|
|
||||||
super.writeToBundle(in);
|
|
||||||
in.putInt("durationMinutes", durationMinutes);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isAAPSRelevant() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,77 +0,0 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.record;
|
|
||||||
|
|
||||||
import android.os.Bundle;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.TimeStampedRecord;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.defs.MedtronicDeviceType;
|
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
public class TempBasalRatePumpEvent extends TimeStampedRecord {
|
|
||||||
|
|
||||||
private double basalRate = 0.0; // rate in Units/hr
|
|
||||||
private boolean mIsPercent = false; // The value is either an absolute number or a percentage
|
|
||||||
|
|
||||||
|
|
||||||
public TempBasalRatePumpEvent() {
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getLength() {
|
|
||||||
return 8;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getShortTypeName() {
|
|
||||||
return "Temp Basal Rate";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public double getBasalRate() {
|
|
||||||
return basalRate;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public boolean isPercent() {
|
|
||||||
return mIsPercent;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean parseFrom(byte[] data, MedtronicDeviceType model) {
|
|
||||||
if (!simpleParse(data, 2)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if ((asUINT8(data[7]) >> 3) == 0) {
|
|
||||||
mIsPercent = false;
|
|
||||||
basalRate = (double)(asUINT8(data[1])) / 40.0;
|
|
||||||
} else {
|
|
||||||
mIsPercent = true;
|
|
||||||
basalRate = asUINT8(data[1]);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean readFromBundle(Bundle in) {
|
|
||||||
basalRate = in.getDouble("basalRate", 0);
|
|
||||||
mIsPercent = in.getBoolean("mIsPercent", false);
|
|
||||||
return super.readFromBundle(in);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void writeToBundle(Bundle in) {
|
|
||||||
in.putDouble("basalRate", basalRate);
|
|
||||||
in.putBoolean("mIsPercent", mIsPercent);
|
|
||||||
super.writeToBundle(in);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isAAPSRelevant() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,111 +0,0 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.record;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.util.Log;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.plugins.pump.common.utils.ByteUtil;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.Record;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.defs.MedtronicDeviceType;
|
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
public class UnabsorbedInsulin extends Record {
|
|
||||||
|
|
||||||
private static final String TAG = "UnabsorbedInsulin";
|
|
||||||
ArrayList<UnabsorbedInsulinRecord> records = new ArrayList<>();
|
|
||||||
private int length = 2;
|
|
||||||
|
|
||||||
|
|
||||||
public UnabsorbedInsulin() {
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getLength() {
|
|
||||||
return length; /* this is a variable sized record */
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getShortTypeName() {
|
|
||||||
return "Unabsorbed Insulin";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean parseFrom(byte[] data, MedtronicDeviceType model) {
|
|
||||||
if (data.length < 2) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
length = asUINT8(data[1]);
|
|
||||||
if (length < 2) {
|
|
||||||
length = 2;
|
|
||||||
}
|
|
||||||
if (length > data.length) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
int numRecords = (asUINT8(data[1]) - 2) / 3;
|
|
||||||
for (int i = 0; i < numRecords; i++) {
|
|
||||||
double amount = (double)(asUINT8(data[2 + (i * 3)])) / 40.0;
|
|
||||||
int age = asUINT8(data[3 + (i * 3)]) + (((asUINT8(data[4 + (i * 3)])) & 0b110000) << 4);
|
|
||||||
records.add(new UnabsorbedInsulinRecord(amount, age));
|
|
||||||
}
|
|
||||||
rawbytes = ByteUtil.substring(data, 0, length);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean readFromBundle(Bundle in) {
|
|
||||||
float[] storedAmounts = in.getFloatArray("amounts");
|
|
||||||
int[] storedAges = in.getIntArray("ages");
|
|
||||||
if ((storedAmounts == null) || (storedAges == null)) {
|
|
||||||
Log.e(TAG, "readFromBundle: failed to load from bundle: null array");
|
|
||||||
} else if (storedAges.length != storedAmounts.length) {
|
|
||||||
Log.e(TAG, "readFromBundle: failed to load from bundle: array size mismatch");
|
|
||||||
} else {
|
|
||||||
for (int i = 0; i < storedAges.length; i++) {
|
|
||||||
records.add(new UnabsorbedInsulinRecord(storedAmounts[i], storedAges[i]));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return super.readFromBundle(in);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void writeToBundle(Bundle in) {
|
|
||||||
// Use parallel arrays to serialize the data. Note there is a small loss
|
|
||||||
// of precision when going from double to float.
|
|
||||||
float[] storedAmounts = new float[records.size()];
|
|
||||||
int[] storedAges = new int[records.size()];
|
|
||||||
for (int i = 0; i < records.size(); i++) {
|
|
||||||
storedAmounts[i] = (float)records.get(i).amount;
|
|
||||||
storedAges[i] = records.get(i).age;
|
|
||||||
}
|
|
||||||
in.putFloatArray("amounts", storedAmounts);
|
|
||||||
in.putIntArray("ages", storedAges);
|
|
||||||
|
|
||||||
super.writeToBundle(in);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isAAPSRelevant() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
class UnabsorbedInsulinRecord {
|
|
||||||
|
|
||||||
public double amount = 0.0;
|
|
||||||
public int age = 0;
|
|
||||||
|
|
||||||
|
|
||||||
public UnabsorbedInsulinRecord(double amount, int age) {
|
|
||||||
this.amount = amount;
|
|
||||||
this.age = age;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,24 +0,0 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.record;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.comm.data.history_old.TimeStampedRecord;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by geoff on 7/16/16.
|
|
||||||
*/
|
|
||||||
public class Unknown7ByteEvent1 extends TimeStampedRecord {
|
|
||||||
|
|
||||||
public Unknown7ByteEvent1() {
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getShortTypeName() {
|
|
||||||
return "Unknown7Byte1";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isAAPSRelevant() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -192,7 +192,7 @@ public class MedtronicPumpHistoryDecoder extends MedtronicHistoryDecoder<PumpHis
|
||||||
case ChangeRemoteId:
|
case ChangeRemoteId:
|
||||||
case ClearAlarm:
|
case ClearAlarm:
|
||||||
case ChangeAlarmNotifyMode: // ChangeUtility:
|
case ChangeAlarmNotifyMode: // ChangeUtility:
|
||||||
case ToggleRemote:
|
case EnableDisableRemote:
|
||||||
case BGReceived: // Ian3F: CGMS
|
case BGReceived: // Ian3F: CGMS
|
||||||
case SensorAlert: // Ian08 CGMS
|
case SensorAlert: // Ian08 CGMS
|
||||||
case ChangeTimeFormat:
|
case ChangeTimeFormat:
|
||||||
|
@ -212,12 +212,12 @@ public class MedtronicPumpHistoryDecoder extends MedtronicHistoryDecoder<PumpHis
|
||||||
case SelfTest:
|
case SelfTest:
|
||||||
case JournalEntryInsulinMarker:
|
case JournalEntryInsulinMarker:
|
||||||
case JournalEntryOtherMarker:
|
case JournalEntryOtherMarker:
|
||||||
case ChangeBolusWizardSetup:
|
case ChangeBolusWizardSetup512:
|
||||||
case ChangeSensorSetup2:
|
case ChangeSensorSetup2:
|
||||||
case ChangeSensorAlarmSilenceConfig:
|
case ChangeSensorAlarmSilenceConfig:
|
||||||
case ChangeSensorRateOfChangeAlertSetup:
|
case ChangeSensorRateOfChangeAlertSetup:
|
||||||
case ChangeBolusScrollStepSize:
|
case ChangeBolusScrollStepSize:
|
||||||
case BolusWizardChange:
|
case ChangeBolusWizardSetup:
|
||||||
case ChangeVariableBolus:
|
case ChangeVariableBolus:
|
||||||
case ChangeAudioBolus:
|
case ChangeAudioBolus:
|
||||||
case ChangeBGReminderEnable:
|
case ChangeBGReminderEnable:
|
||||||
|
@ -236,10 +236,10 @@ public class MedtronicPumpHistoryDecoder extends MedtronicHistoryDecoder<PumpHis
|
||||||
case ReadOtherDevicesStatus:
|
case ReadOtherDevicesStatus:
|
||||||
return RecordDecodeStatus.OK;
|
return RecordDecodeStatus.OK;
|
||||||
|
|
||||||
case Sensor54:
|
case Sensor_0x54:
|
||||||
case Sensor55:
|
case Sensor_0x55:
|
||||||
case Sensor51:
|
case Sensor_0x51:
|
||||||
case Sensor52:
|
case Sensor_0x52:
|
||||||
case EventUnknown_MM522_0x45:
|
case EventUnknown_MM522_0x45:
|
||||||
case EventUnknown_MM522_0x46:
|
case EventUnknown_MM522_0x46:
|
||||||
case EventUnknown_MM522_0x47:
|
case EventUnknown_MM522_0x47:
|
||||||
|
@ -264,7 +264,7 @@ public class MedtronicPumpHistoryDecoder extends MedtronicHistoryDecoder<PumpHis
|
||||||
return RecordDecodeStatus.Ignored;
|
return RecordDecodeStatus.Ignored;
|
||||||
|
|
||||||
case UnabsorbedInsulin:
|
case UnabsorbedInsulin:
|
||||||
return RecordDecodeStatus.Ignored;
|
return RecordDecodeStatus.Ignored;
|
||||||
|
|
||||||
// **** Implemented records ****
|
// **** Implemented records ****
|
||||||
|
|
||||||
|
@ -310,8 +310,8 @@ public class MedtronicPumpHistoryDecoder extends MedtronicHistoryDecoder<PumpHis
|
||||||
return RecordDecodeStatus.OK;
|
return RecordDecodeStatus.OK;
|
||||||
|
|
||||||
case LowBattery:
|
case LowBattery:
|
||||||
case PumpSuspend:
|
case Suspend:
|
||||||
case PumpResume:
|
case Resume:
|
||||||
case Rewind:
|
case Rewind:
|
||||||
case NoDeliveryAlarm:
|
case NoDeliveryAlarm:
|
||||||
case ChangeTempBasalType:
|
case ChangeTempBasalType:
|
||||||
|
@ -411,6 +411,9 @@ public class MedtronicPumpHistoryDecoder extends MedtronicHistoryDecoder<PumpHis
|
||||||
rate = body[1] * 0.025f;
|
rate = body[1] * 0.025f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LOG.info("Basal Profile Start (ERROR): offset={}, rate={}, index={}, body_raw={}", offset, rate, index,
|
||||||
|
body);
|
||||||
|
|
||||||
if (rate == null) {
|
if (rate == null) {
|
||||||
LOG.warn("Basal Profile Start (ERROR): offset={}, rate={}, index={}, body_raw={}", offset, rate, index,
|
LOG.warn("Basal Profile Start (ERROR): offset={}, rate={}, index={}, body_raw={}", offset, rate, index,
|
||||||
body);
|
body);
|
||||||
|
@ -422,6 +425,11 @@ public class MedtronicPumpHistoryDecoder extends MedtronicHistoryDecoder<PumpHis
|
||||||
entry.setDisplayableValue(getFormattedFloat(rate, 3));
|
entry.setDisplayableValue(getFormattedFloat(rate, 3));
|
||||||
return RecordDecodeStatus.OK;
|
return RecordDecodeStatus.OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// profileIndex = asUINT8(data[1]);
|
||||||
|
// offset = asUINT8(data[7]) * 30 * 1000 * 60;
|
||||||
|
// rate = (double)(asUINT8(data[8])) / 40.0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -479,11 +487,14 @@ public class MedtronicPumpHistoryDecoder extends MedtronicHistoryDecoder<PumpHis
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// FIXME
|
|
||||||
private void decodePrime(PumpHistoryEntry entry) {
|
private void decodePrime(PumpHistoryEntry entry) {
|
||||||
float amount = bitUtils.toInt(entry.getHead()[2], entry.getHead()[3]) / 10.0f;
|
float amount = bitUtils.toInt(entry.getHead()[2], entry.getHead()[3]) / 10.0f;
|
||||||
float fixed = bitUtils.toInt(entry.getHead()[0], entry.getHead()[1]) / 10.0f;
|
float fixed = bitUtils.toInt(entry.getHead()[0], entry.getHead()[1]) / 10.0f;
|
||||||
|
|
||||||
|
// amount = (double)(asUINT8(data[4]) << 2) / 40.0;
|
||||||
|
// programmedAmount = (double)(asUINT8(data[2]) << 2) / 40.0;
|
||||||
|
// primeType = programmedAmount == 0 ? "manual" : "fixed";
|
||||||
|
|
||||||
entry.addDecodedData("Amount", amount);
|
entry.addDecodedData("Amount", amount);
|
||||||
entry.addDecodedData("FixedAmount", fixed);
|
entry.addDecodedData("FixedAmount", fixed);
|
||||||
|
|
||||||
|
@ -492,6 +503,28 @@ public class MedtronicPumpHistoryDecoder extends MedtronicHistoryDecoder<PumpHis
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void decodeChangeTempBasalType(PumpHistoryEntry entry) {
|
||||||
|
entry.addDecodedData("isPercent", ByteUtil.asUINT8(entry.getRawDataByIndex(0)) == 1); // index moved from 1 -> 0
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void decodeBgReceived(PumpHistoryEntry entry) {
|
||||||
|
entry.addDecodedData("amount", (ByteUtil.asUINT8(entry.getRawDataByIndex(0)) << 3) + (ByteUtil.asUINT8(entry.getRawDataByIndex(3)) >> 5));
|
||||||
|
entry.addDecodedData("meter", ByteUtil.substring(entry.getRawData(), 6, 3)); // index moved from 1 -> 0
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void decodeCalBGForPH(PumpHistoryEntry entry) {
|
||||||
|
entry.addDecodedData("amount", ((ByteUtil.asUINT8(entry.getRawDataByIndex(5)) & 0x80) << 1) + ByteUtil.asUINT8(entry.getRawDataByIndex(0))); // index moved from 1 -> 0
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void decodeNoDeliveryAlarm(PumpHistoryEntry entry) {
|
||||||
|
//rawtype = asUINT8(data[1]);
|
||||||
|
// not sure if this is actually NoDelivery Alarm?
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void postProcess() {
|
public void postProcess() {
|
||||||
}
|
}
|
||||||
|
@ -530,7 +563,6 @@ public class MedtronicPumpHistoryDecoder extends MedtronicHistoryDecoder<PumpHis
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// FIXME new pumps have single record (I think)
|
|
||||||
private void decodeTempBasal(PumpHistoryEntry entry) {
|
private void decodeTempBasal(PumpHistoryEntry entry) {
|
||||||
|
|
||||||
if (this.tbrPreviousRecord == null) {
|
if (this.tbrPreviousRecord == null) {
|
||||||
|
|
|
@ -10,25 +10,22 @@ import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicUtil;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This file was taken from GGC - GNU Gluco Control and modified/extended for AAPS.
|
* This file was taken from GGC - GNU Gluco Control and modified/extended for AAPS.
|
||||||
*
|
* <p>
|
||||||
* Author: Andy {andy.rozman@gmail.com}
|
* Author: Andy {andy.rozman@gmail.com}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public enum PumpHistoryEntryType // implements CodeEnum
|
public enum PumpHistoryEntryType // implements CodeEnum
|
||||||
{
|
{
|
||||||
|
|
||||||
None(0, "None", PumpHistoryEntryGroup.Unknown, 1, 0, 0), // Bolus(0x01, "Bolus", 4, 5, 4), // 4,5,0 -> 4,5,4
|
None(0, "None", PumpHistoryEntryGroup.Unknown, 1, 0, 0),
|
||||||
// Bolus(0x01, "Bolus", 2, 5, 4),
|
|
||||||
|
|
||||||
Bolus(0x01, "Bolus", PumpHistoryEntryGroup.Bolus, 4, 5, 0), // 523+[H=8]
|
Bolus(0x01, "Bolus", PumpHistoryEntryGroup.Bolus, 4, 5, 0), // 523+[H=8] 9/13
|
||||||
|
|
||||||
Prime(0x03, "Prime", PumpHistoryEntryGroup.Prime, 5, 5, 0), //
|
Prime(0x03, "Prime", PumpHistoryEntryGroup.Prime, 5, 5, 0), //
|
||||||
|
|
||||||
/**/EventUnknown_MM522_0x05((byte)0x05, "Unknown Event 0x05", PumpHistoryEntryGroup.Unknown, 2, 5, 28), //
|
/**/EventUnknown_MM522_0x05((byte) 0x05, "Unknown Event 0x05", PumpHistoryEntryGroup.Unknown, 2, 5, 28), //
|
||||||
NoDeliveryAlarm(0x06, "No Delivery", PumpHistoryEntryGroup.Alarm, 4, 5, 0), //
|
NoDeliveryAlarm(0x06, "No Delivery", PumpHistoryEntryGroup.Alarm, 4, 5, 0), //
|
||||||
EndResultTotals(0x07, "End Result Totals", PumpHistoryEntryGroup.Statistic, 5, 2, 0), // V1: 5/5/41 V2: 5,2,3 V3,
|
EndResultTotals(0x07, "End Result Totals", PumpHistoryEntryGroup.Statistic, 5, 2, 0),
|
||||||
// 5,2,0
|
|
||||||
// V1: 2,5,42; V2:2,5,145; V5: 7/10(523)
|
|
||||||
ChangeBasalProfile_OldProfile(0x08, "Change Basal Profile (Old)", PumpHistoryEntryGroup.Basal, 2, 5, 145),
|
ChangeBasalProfile_OldProfile(0x08, "Change Basal Profile (Old)", PumpHistoryEntryGroup.Basal, 2, 5, 145),
|
||||||
ChangeBasalProfile_NewProfile(0x09, "Change Basal Profile (New)", PumpHistoryEntryGroup.Basal, 2, 5, 145), //
|
ChangeBasalProfile_NewProfile(0x09, "Change Basal Profile (New)", PumpHistoryEntryGroup.Basal, 2, 5, 145), //
|
||||||
/**/EventUnknown_MM512_0x10(0x10, "Unknown Event 0x10", PumpHistoryEntryGroup.Unknown), // 29, 5, 0
|
/**/EventUnknown_MM512_0x10(0x10, "Unknown Event 0x10", PumpHistoryEntryGroup.Unknown), // 29, 5, 0
|
||||||
|
@ -45,23 +42,22 @@ public enum PumpHistoryEntryType // implements CodeEnum
|
||||||
LowBattery(0x19, "LowBattery", PumpHistoryEntryGroup.Notification), //
|
LowBattery(0x19, "LowBattery", PumpHistoryEntryGroup.Notification), //
|
||||||
BatteryChange(0x1a, "Battery Change", PumpHistoryEntryGroup.Notification), //
|
BatteryChange(0x1a, "Battery Change", PumpHistoryEntryGroup.Notification), //
|
||||||
SetAutoOff(0x1b, "Set Auto Off", PumpHistoryEntryGroup.Configuration), //
|
SetAutoOff(0x1b, "Set Auto Off", PumpHistoryEntryGroup.Configuration), //
|
||||||
PumpSuspend(0x1e, "Pump Suspend", PumpHistoryEntryGroup.Basal), //
|
Suspend(0x1e, "Suspend", PumpHistoryEntryGroup.Basal), //
|
||||||
PumpResume(0x1f, "Pump Resume", PumpHistoryEntryGroup.Basal), //
|
Resume(0x1f, "Resume", PumpHistoryEntryGroup.Basal), //
|
||||||
|
|
||||||
SelfTest(0x20, "Self Test", PumpHistoryEntryGroup.Statistic), //
|
SelfTest(0x20, "Self Test", PumpHistoryEntryGroup.Statistic), //
|
||||||
Rewind(0x21, "Rewind", PumpHistoryEntryGroup.Prime), //
|
Rewind(0x21, "Rewind", PumpHistoryEntryGroup.Prime), //
|
||||||
ClearSettings(0x22, "Clear Settings", PumpHistoryEntryGroup.Configuration), // 8?
|
ClearSettings(0x22, "Clear Settings", PumpHistoryEntryGroup.Configuration), //
|
||||||
ChangeChildBlockEnable(0x23, "Change Child Block Enable", PumpHistoryEntryGroup.Configuration), // 8?
|
ChangeChildBlockEnable(0x23, "Change Child Block Enable", PumpHistoryEntryGroup.Configuration), //
|
||||||
ChangeMaxBolus(0x24, "Change Max Bolus", PumpHistoryEntryGroup.Configuration), // 8?
|
ChangeMaxBolus(0x24, "Change Max Bolus", PumpHistoryEntryGroup.Configuration), //
|
||||||
/**/EventUnknown_MM522_0x25(0x25, "Unknown Event 0x25", PumpHistoryEntryGroup.Unknown), // 8?
|
/**/EventUnknown_MM522_0x25(0x25, "Unknown Event 0x25", PumpHistoryEntryGroup.Unknown), // 8?
|
||||||
ToggleRemote(0x26, "Enable/Disable Remote", PumpHistoryEntryGroup.Configuration, 2, 5, 14), // 2, 5, 14 V6:2,5,14
|
EnableDisableRemote(0x26, "Enable/Disable Remote", PumpHistoryEntryGroup.Configuration, 2, 5, 14), // 2, 5, 14 V6:2,5,14
|
||||||
ChangeRemoteId(0x27, "Change Remote ID", PumpHistoryEntryGroup.Configuration), // ??
|
ChangeRemoteId(0x27, "Change Remote ID", PumpHistoryEntryGroup.Configuration), // ??
|
||||||
|
|
||||||
ChangeMaxBasal(0x2c, "Change Max Basal", PumpHistoryEntryGroup.Configuration), //
|
ChangeMaxBasal(0x2c, "Change Max Basal", PumpHistoryEntryGroup.Configuration), //
|
||||||
BolusWizardEnabled(0x2d, "Bolus Wizard Enabled", PumpHistoryEntryGroup.Configuration), // V3 ?
|
BolusWizardEnabled(0x2d, "Bolus Wizard Enabled", PumpHistoryEntryGroup.Configuration), // V3 ?
|
||||||
/**/EventUnknown_MM512_0x2e(0x2e, "Unknown Event 0x2e", PumpHistoryEntryGroup.Unknown), //
|
/**/EventUnknown_MM512_0x2e(0x2e, "Unknown Event 0x2e", PumpHistoryEntryGroup.Unknown), //
|
||||||
/**/BolusWizardEstimate512(0x2f, "Bolus Wizard Estimate (512)", PumpHistoryEntryGroup.Configuration), //
|
/**/BolusWizardEstimate512(0x2f, "Bolus Wizard Estimate (512)", PumpHistoryEntryGroup.Configuration), //
|
||||||
UnabsorbedInsulin512(0x30, "Unabsorbed Insulin (512)", PumpHistoryEntryGroup.Statistic), //
|
UnabsorbedInsulin512(0x30, "Unabsorbed Insulin (512)", PumpHistoryEntryGroup.Statistic), // FIXME
|
||||||
ChangeBGReminderOffset(0x31, "Change BG Reminder Offset", PumpHistoryEntryGroup.Configuration), //
|
ChangeBGReminderOffset(0x31, "Change BG Reminder Offset", PumpHistoryEntryGroup.Configuration), //
|
||||||
ChangeAlarmClockTime(0x32, "Change Alarm Clock Time", PumpHistoryEntryGroup.Configuration), //
|
ChangeAlarmClockTime(0x32, "Change Alarm Clock Time", PumpHistoryEntryGroup.Configuration), //
|
||||||
TempBasalRate(0x33, "TBR Rate", PumpHistoryEntryGroup.Basal, 2, 5, 1), //
|
TempBasalRate(0x33, "TBR Rate", PumpHistoryEntryGroup.Basal, 2, 5, 1), //
|
||||||
|
@ -71,15 +67,16 @@ public enum PumpHistoryEntryType // implements CodeEnum
|
||||||
/**/EventUnknown_MM512_0x37(0x37, "Unknown Event 0x37", PumpHistoryEntryGroup.Unknown), // V:MM512
|
/**/EventUnknown_MM512_0x37(0x37, "Unknown Event 0x37", PumpHistoryEntryGroup.Unknown), // V:MM512
|
||||||
/**/EventUnknown_MM512_0x38(0x38, "Unknown Event 0x38", PumpHistoryEntryGroup.Unknown), //
|
/**/EventUnknown_MM512_0x38(0x38, "Unknown Event 0x38", PumpHistoryEntryGroup.Unknown), //
|
||||||
BGReceived512(0x39, "BG Received (512)", PumpHistoryEntryGroup.Glucose), //
|
BGReceived512(0x39, "BG Received (512)", PumpHistoryEntryGroup.Glucose), //
|
||||||
|
/**/EventUnknown_MM512_0x3a(0x3a, "Unknown Event 0x3a", PumpHistoryEntryGroup.Unknown), //
|
||||||
SensorStatus(0x3b, "Sensor Status", PumpHistoryEntryGroup.Glucose), //
|
SensorStatus(0x3b, "Sensor Status", PumpHistoryEntryGroup.Glucose), //
|
||||||
ChangeParadigmID(0x3c, "Change Paradigm ID", PumpHistoryEntryGroup.Configuration, 2, 5, 14), // V3 ? V6: 2,5,14
|
ChangeParadigmID(0x3c, "Change Paradigm ID", PumpHistoryEntryGroup.Configuration, 2, 5, 14), // V3 ? V6: 2,5,14 ?? is it this length or just 7
|
||||||
|
EventUnknown_MM512_0x3D(0x3d, "Unknown Event 0x3D", PumpHistoryEntryGroup.Unknown), //
|
||||||
|
EventUnknown_MM512_0x3E(0x3e, "Unknown Event 0x3E", PumpHistoryEntryGroup.Unknown), //
|
||||||
BGReceived(0x3f, "BG Received", PumpHistoryEntryGroup.Glucose, 2, 5, 3), // Ian3F
|
BGReceived(0x3f, "BG Received", PumpHistoryEntryGroup.Glucose, 2, 5, 3), // Ian3F
|
||||||
JournalEntryMealMarker(0x40, "Meal Marker", PumpHistoryEntryGroup.Bolus, 2, 5, 2), //
|
JournalEntryMealMarker(0x40, "Meal Marker", PumpHistoryEntryGroup.Bolus, 2, 5, 2), // is size just 7??? V6
|
||||||
JournalEntryExerciseMarker(0x41, "Exercise Marker", PumpHistoryEntryGroup.Bolus, 2, 5, 1), // ??
|
JournalEntryExerciseMarker(0x41, "Exercise Marker", PumpHistoryEntryGroup.Bolus, 2, 5, 1), // ??
|
||||||
// JournalEntryExerciseMarkerPumpEvent
|
JournalEntryInsulinMarker(0x42, "Insulin Marker", PumpHistoryEntryGroup.Bolus, 2, 5, 0), // V6 = body(0)/was=1
|
||||||
JournalEntryInsulinMarker(0x42, "Insulin Marker", PumpHistoryEntryGroup.Bolus, 2, 5, 1), // ?? InsulinMarkerEvent
|
JournalEntryOtherMarker(0x43, "Other Marker", PumpHistoryEntryGroup.Bolus, 2, 5, 1), // V6 = body(1)/was=0
|
||||||
JournalEntryOtherMarker(0x43, "Other Marker", PumpHistoryEntryGroup.Bolus), //
|
|
||||||
EnableSensorAutoCal(0x44, "Enable Sensor AutoCal", PumpHistoryEntryGroup.Glucose), //
|
EnableSensorAutoCal(0x44, "Enable Sensor AutoCal", PumpHistoryEntryGroup.Glucose), //
|
||||||
/**/EventUnknown_MM522_0x45(0x45, "Unknown Event 0x45", PumpHistoryEntryGroup.Unknown, 2, 5, 1), //
|
/**/EventUnknown_MM522_0x45(0x45, "Unknown Event 0x45", PumpHistoryEntryGroup.Unknown, 2, 5, 1), //
|
||||||
/**/EventUnknown_MM522_0x46(0x46, "Unknown Event 0x46", PumpHistoryEntryGroup.Unknown, 2, 5, 1), //
|
/**/EventUnknown_MM522_0x46(0x46, "Unknown Event 0x46", PumpHistoryEntryGroup.Unknown, 2, 5, 1), //
|
||||||
|
@ -91,50 +88,47 @@ public enum PumpHistoryEntryType // implements CodeEnum
|
||||||
/**/EventUnknown_MM522_0x4c(0x4c, "Unknown Event 0x4c", PumpHistoryEntryGroup.Unknown, 2, 5, 1), //
|
/**/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_0x4d(0x4d, "Unknown Event 0x4d", PumpHistoryEntryGroup.Unknown), // V5: 512: 7, 522: 8 ????NS
|
||||||
/**/EventUnknown_MM512_0x4e(0x4e, "Unknown Event 0x4e", PumpHistoryEntryGroup.Unknown), // /**/
|
/**/EventUnknown_MM512_0x4e(0x4e, "Unknown Event 0x4e", PumpHistoryEntryGroup.Unknown), // /**/
|
||||||
ChangeBolusWizardSetup(0x4f, "Bolus Wizard Setup", PumpHistoryEntryGroup.Configuration, 2, 5, 32), //
|
ChangeBolusWizardSetup512(0x4f, "Bolus Wizard Setup (512)", PumpHistoryEntryGroup.Configuration, 2, 5, 32), //
|
||||||
ChangeSensorSetup2(0x50, "Sensor Setup2", PumpHistoryEntryGroup.Configuration, 2, 5, 30), // Ian50
|
ChangeSensorSetup2(0x50, "Sensor Setup2", PumpHistoryEntryGroup.Configuration, 2, 5, 30), // Ian50
|
||||||
/**/Sensor51(0x51, "Unknown Event 0x51", PumpHistoryEntryGroup.Unknown), //
|
/**/Sensor_0x51(0x51, "Unknown Event 0x51", PumpHistoryEntryGroup.Unknown), //
|
||||||
/**/Sensor52(0x52, "Unknown Event 0x52", PumpHistoryEntryGroup.Unknown), //
|
/**/Sensor_0x52(0x52, "Unknown Event 0x52", PumpHistoryEntryGroup.Unknown), //
|
||||||
ChangeSensorAlarmSilenceConfig(0x53, "Sensor Alarm Silence Config", PumpHistoryEntryGroup.Configuration, 2, 5, 1), // 8
|
ChangeSensorAlarmSilenceConfig(0x53, "Sensor Alarm Silence Config", PumpHistoryEntryGroup.Configuration, 2, 5, 1), // 8
|
||||||
// -
|
|
||||||
// ChangeSensorAlarmSilenceConfig
|
/**/Sensor_0x54(0x54, "Unknown Event 0x54", PumpHistoryEntryGroup.Unknown), // Ian54
|
||||||
/**/Sensor54(0x54, "Unknown Event 0x54", PumpHistoryEntryGroup.Unknown), // Ian54
|
/**/Sensor_0x55(0x55, "Unknown Event 0x55", PumpHistoryEntryGroup.Unknown), //
|
||||||
/**/Sensor55(0x55, "Unknown Event 0x55", PumpHistoryEntryGroup.Unknown), //
|
|
||||||
ChangeSensorRateOfChangeAlertSetup(0x56, "Sensor Rate Of Change Alert Setup", PumpHistoryEntryGroup.Configuration, 2, 5, 5), // 12
|
ChangeSensorRateOfChangeAlertSetup(0x56, "Sensor Rate Of Change Alert Setup", PumpHistoryEntryGroup.Configuration, 2, 5, 5), // 12
|
||||||
// ChangeSensorRateOfChangeAlertSetup
|
|
||||||
ChangeBolusScrollStepSize(0x57, "Change Bolus Scroll Step Size", PumpHistoryEntryGroup.Configuration), //
|
ChangeBolusScrollStepSize(0x57, "Change Bolus Scroll Step Size", PumpHistoryEntryGroup.Configuration), //
|
||||||
|
|
||||||
// V4
|
// V4
|
||||||
// Andy58(0x58, "Unknown", 13, 5, 0), // TO DO is this one really there ???
|
// Andy58(0x58, "Unknown", 13, 5, 0), // TO DO is this one really there ???
|
||||||
|
|
||||||
BolusWizardChange(0x5a, "Bolus Wizard Change", PumpHistoryEntryGroup.Configuration, 2, 5, 117), // V2: 522+[B=143] // V6 124/144
|
ChangeBolusWizardSetup(0x5a, "Bolus Wizard Setup (512)", PumpHistoryEntryGroup.Configuration, 2, 5, 137), // V2: 522+[B=143] // V6 124 -> 144
|
||||||
BolusWizardEstimate(0x5b, "Bolus Wizard Estimate", PumpHistoryEntryGroup.Configuration, 2, 5, 13), // 15 //
|
BolusWizardEstimate(0x5b, "Bolus Wizard Estimate", PumpHistoryEntryGroup.Configuration, 2, 5, 13), // 15 //
|
||||||
UnabsorbedInsulin(0x5c, "Unabsorbed Insulin", PumpHistoryEntryGroup.Statistic, 5, 0, 0), // head[1] -> body
|
UnabsorbedInsulin(0x5c, "Unabsorbed Insulin", PumpHistoryEntryGroup.Statistic, 5, 0, 0), // head[1] -> body
|
||||||
// length
|
|
||||||
SaveSettings(0x5d, "Save Settings", PumpHistoryEntryGroup.Configuration), //
|
SaveSettings(0x5d, "Save Settings", PumpHistoryEntryGroup.Configuration), //
|
||||||
ChangeVariableBolus(0x5e, "Change Variable Bolus", PumpHistoryEntryGroup.Configuration), //
|
ChangeVariableBolus(0x5e, "Change Variable Bolus", PumpHistoryEntryGroup.Configuration), //
|
||||||
ChangeAudioBolus(0x5f, "Easy Bolus Enabled", PumpHistoryEntryGroup.Configuration), // V3 ?
|
ChangeAudioBolus(0x5f, "Easy Bolus Enabled", PumpHistoryEntryGroup.Configuration), // V3 ?
|
||||||
ChangeBGReminderEnable(0x60, "BG Reminder Enable", PumpHistoryEntryGroup.Configuration), // questionable60
|
ChangeBGReminderEnable(0x60, "BG Reminder Enable", PumpHistoryEntryGroup.Configuration), // questionable60
|
||||||
ChangeAlarmClockEnable(0x61, "Alarm Clock Enable", PumpHistoryEntryGroup.Configuration), //
|
ChangeAlarmClockEnable(0x61, "Alarm Clock Enable", PumpHistoryEntryGroup.Configuration), //
|
||||||
ChangeTempBasalType((byte)0x62, "Change Basal Type", PumpHistoryEntryGroup.Configuration), // ChangeTempBasalTypePumpEvent
|
ChangeTempBasalType((byte) 0x62, "Change Basal Type", PumpHistoryEntryGroup.Configuration), // ChangeTempBasalTypePumpEvent
|
||||||
ChangeAlarmNotifyMode(0x63, "Change Alarm Notify Mode", PumpHistoryEntryGroup.Configuration), //
|
ChangeAlarmNotifyMode(0x63, "Change Alarm Notify Mode", PumpHistoryEntryGroup.Configuration), //
|
||||||
ChangeTimeFormat(0x64, "Change Time Format", PumpHistoryEntryGroup.Configuration), //
|
ChangeTimeFormat(0x64, "Change Time Format", PumpHistoryEntryGroup.Configuration), //
|
||||||
ChangeReservoirWarningTime((byte)0x65, "Change Reservoir Warning Time", PumpHistoryEntryGroup.Configuration), //
|
ChangeReservoirWarningTime((byte) 0x65, "Change Reservoir Warning Time", PumpHistoryEntryGroup.Configuration), //
|
||||||
ChangeBolusReminderEnable(0x66, "Change Bolus Reminder Enable", PumpHistoryEntryGroup.Configuration, 2, 5, 2), // 9
|
ChangeBolusReminderEnable(0x66, "Change Bolus Reminder Enable", PumpHistoryEntryGroup.Configuration, 2, 5, 2), // 9
|
||||||
ChangeBolusReminderTime((byte)0x67, "Change Bolus Reminder Time", PumpHistoryEntryGroup.Configuration, 2, 5, 2), // 9
|
ChangeBolusReminderTime((byte) 0x67, "Change Bolus Reminder Time", PumpHistoryEntryGroup.Configuration, 2, 5, 2), // 9
|
||||||
DeleteBolusReminderTime((byte)0x68, "Delete Bolus Reminder Time", PumpHistoryEntryGroup.Configuration, 2, 5, 2), // 9
|
DeleteBolusReminderTime((byte) 0x68, "Delete Bolus Reminder Time", PumpHistoryEntryGroup.Configuration, 2, 5, 2), // 9
|
||||||
BolusReminder(0x69, "Bolus Reminder", PumpHistoryEntryGroup.Configuration, 2, 5, 0), // Ian69
|
BolusReminder(0x69, "Bolus Reminder", PumpHistoryEntryGroup.Configuration, 2, 5, 0), // Ian69
|
||||||
DeleteAlarmClockTime(0x6a, "Delete Alarm Clock Time", PumpHistoryEntryGroup.Configuration, 2, 5, 7), // 14
|
DeleteAlarmClockTime(0x6a, "Delete Alarm Clock Time", PumpHistoryEntryGroup.Configuration, 2, 5, 7), // 14
|
||||||
|
|
||||||
DailyTotals515(0x6c, "Daily Totals (515)", PumpHistoryEntryGroup.Statistic, 1, 2, 33), // v4: 0,0,36. v5: 1,2,33
|
DailyTotals515(0x6c, "Daily Totals (515)", PumpHistoryEntryGroup.Statistic, 1, 2, 33), // v4: 0,0,36. v5: 1,2,33
|
||||||
DailyTotals522(0x6d, "Daily Totals (522)", PumpHistoryEntryGroup.Statistic, 1, 2, 41), //
|
DailyTotals522(0x6d, "Daily Totals (522)", PumpHistoryEntryGroup.Statistic, 1, 2, 41), //
|
||||||
DailyTotals523(0x6e, "Daily Totals (523)", PumpHistoryEntryGroup.Statistic, 1, 2, 49), // 1102014-03-17T00:00:00
|
DailyTotals523(0x6e, "Daily Totals (523)", PumpHistoryEntryGroup.Statistic, 1, 2, 49), // 1102014-03-17T00:00:00
|
||||||
ChangeCarbUnits((byte)0x6f, "Change Carb Units", PumpHistoryEntryGroup.Configuration), //
|
ChangeCarbUnits((byte) 0x6f, "Change Carb Units", PumpHistoryEntryGroup.Configuration), //
|
||||||
/**/EventUnknown_MM522_0x70((byte)0x70, "Unknown Event 0x70", PumpHistoryEntryGroup.Unknown, 2, 5, 1), //
|
/**/EventUnknown_MM522_0x70((byte) 0x70, "Unknown Event 0x70", PumpHistoryEntryGroup.Unknown, 2, 5, 1), //
|
||||||
|
|
||||||
BasalProfileStart(0x7b, "Basal Profile Start", PumpHistoryEntryGroup.Basal, 2, 5, 3), // // 722
|
BasalProfileStart(0x7b, "Basal Profile Start", PumpHistoryEntryGroup.Basal, 2, 5, 3), // // 722
|
||||||
ChangeWatchdogEnable((byte)0x7c, "Change Watchdog Enable", PumpHistoryEntryGroup.Configuration), //
|
ChangeWatchdogEnable((byte) 0x7c, "Change Watchdog Enable", PumpHistoryEntryGroup.Configuration), //
|
||||||
ChangeOtherDeviceID((byte)0x7d, "Change Other Device ID", PumpHistoryEntryGroup.Configuration, 2, 5, 30), //
|
ChangeOtherDeviceID((byte) 0x7d, "Change Other Device ID", PumpHistoryEntryGroup.Configuration, 2, 5, 30), //
|
||||||
|
|
||||||
ChangeWatchdogMarriageProfile(0x81, "Change Watchdog Marriage Profile", PumpHistoryEntryGroup.Configuration, 2, 5, 5), // 12
|
ChangeWatchdogMarriageProfile(0x81, "Change Watchdog Marriage Profile", PumpHistoryEntryGroup.Configuration, 2, 5, 5), // 12
|
||||||
DeleteOtherDeviceID(0x82, "Delete Other Device ID", PumpHistoryEntryGroup.Configuration, 2, 5, 5), //
|
DeleteOtherDeviceID(0x82, "Delete Other Device ID", PumpHistoryEntryGroup.Configuration, 2, 5, 5), //
|
||||||
|
@ -206,7 +200,7 @@ public enum PumpHistoryEntryType // implements CodeEnum
|
||||||
|
|
||||||
|
|
||||||
PumpHistoryEntryType(int opCode, String name, PumpHistoryEntryGroup group, int head, int date, int body) {
|
PumpHistoryEntryType(int opCode, String name, PumpHistoryEntryGroup group, int head, int date, int body) {
|
||||||
this.opCode = (byte)opCode;
|
this.opCode = (byte) opCode;
|
||||||
this.description = name;
|
this.description = name;
|
||||||
this.headLength = head;
|
this.headLength = head;
|
||||||
this.dateLength = date;
|
this.dateLength = date;
|
||||||
|
@ -220,7 +214,7 @@ public enum PumpHistoryEntryType // implements CodeEnum
|
||||||
EndResultTotals.addSpecialRuleBody(new SpecialRule(MedtronicDeviceType.Medtronic_523andHigher, 3));
|
EndResultTotals.addSpecialRuleBody(new SpecialRule(MedtronicDeviceType.Medtronic_523andHigher, 3));
|
||||||
Bolus.addSpecialRuleHead(new SpecialRule(MedtronicDeviceType.Medtronic_523andHigher, 8));
|
Bolus.addSpecialRuleHead(new SpecialRule(MedtronicDeviceType.Medtronic_523andHigher, 8));
|
||||||
// BolusWizardChange.addSpecialRuleBody(new SpecialRule(MedtronicDeviceType.Medtronic_522andHigher, 143));
|
// BolusWizardChange.addSpecialRuleBody(new SpecialRule(MedtronicDeviceType.Medtronic_522andHigher, 143));
|
||||||
BolusWizardChange.addSpecialRuleBody(new SpecialRule(MedtronicDeviceType.Medtronic_523andHigher, 137)); // V5:
|
//ChangeBolusWizardSetup.addSpecialRuleBody(new SpecialRule(MedtronicDeviceType.Medtronic_523andHigher, 137)); // V5:
|
||||||
// 522
|
// 522
|
||||||
// has
|
// has
|
||||||
// old
|
// old
|
||||||
|
@ -254,32 +248,32 @@ public enum PumpHistoryEntryType // implements CodeEnum
|
||||||
|
|
||||||
public static boolean isAAPSRelevantEntry(PumpHistoryEntryType entryType) {
|
public static boolean isAAPSRelevantEntry(PumpHistoryEntryType entryType) {
|
||||||
return (entryType == PumpHistoryEntryType.Bolus || // Treatments
|
return (entryType == PumpHistoryEntryType.Bolus || // Treatments
|
||||||
entryType == PumpHistoryEntryType.TempBasalRate || //
|
entryType == PumpHistoryEntryType.TempBasalRate || //
|
||||||
entryType == PumpHistoryEntryType.TempBasalDuration || //
|
entryType == PumpHistoryEntryType.TempBasalDuration || //
|
||||||
|
|
||||||
entryType == PumpHistoryEntryType.Prime || // Pump Status Change
|
entryType == PumpHistoryEntryType.Prime || // Pump Status Change
|
||||||
entryType == PumpHistoryEntryType.PumpSuspend || //
|
entryType == PumpHistoryEntryType.Suspend || //
|
||||||
entryType == PumpHistoryEntryType.PumpResume || //
|
entryType == PumpHistoryEntryType.Resume || //
|
||||||
entryType == PumpHistoryEntryType.Rewind || //
|
entryType == PumpHistoryEntryType.Rewind || //
|
||||||
entryType == PumpHistoryEntryType.NoDeliveryAlarm || // no delivery
|
entryType == PumpHistoryEntryType.NoDeliveryAlarm || // no delivery
|
||||||
entryType == PumpHistoryEntryType.BasalProfileStart || //
|
entryType == PumpHistoryEntryType.BasalProfileStart || //
|
||||||
|
|
||||||
entryType == PumpHistoryEntryType.ChangeTime || // Time Change
|
entryType == PumpHistoryEntryType.ChangeTime || // Time Change
|
||||||
entryType == PumpHistoryEntryType.NewTimeSet || //
|
entryType == PumpHistoryEntryType.NewTimeSet || //
|
||||||
|
|
||||||
entryType == PumpHistoryEntryType.ChangeBasalPattern || // Configuration
|
entryType == PumpHistoryEntryType.ChangeBasalPattern || // Configuration
|
||||||
entryType == PumpHistoryEntryType.ClearSettings || //
|
entryType == PumpHistoryEntryType.ClearSettings || //
|
||||||
entryType == PumpHistoryEntryType.SaveSettings || //
|
entryType == PumpHistoryEntryType.SaveSettings || //
|
||||||
entryType == PumpHistoryEntryType.ChangeMaxBolus || //
|
entryType == PumpHistoryEntryType.ChangeMaxBolus || //
|
||||||
entryType == PumpHistoryEntryType.ChangeMaxBasal || //
|
entryType == PumpHistoryEntryType.ChangeMaxBasal || //
|
||||||
entryType == PumpHistoryEntryType.ChangeTempBasalType || //
|
entryType == PumpHistoryEntryType.ChangeTempBasalType || //
|
||||||
|
|
||||||
entryType == PumpHistoryEntryType.ChangeBasalProfile_NewProfile || // Basal profile
|
entryType == PumpHistoryEntryType.ChangeBasalProfile_NewProfile || // Basal profile
|
||||||
|
|
||||||
entryType == PumpHistoryEntryType.DailyTotals515 || // Daily Totals
|
entryType == PumpHistoryEntryType.DailyTotals515 || // Daily Totals
|
||||||
entryType == PumpHistoryEntryType.DailyTotals522 || //
|
entryType == PumpHistoryEntryType.DailyTotals522 || //
|
||||||
entryType == PumpHistoryEntryType.DailyTotals523 || //
|
entryType == PumpHistoryEntryType.DailyTotals523 || //
|
||||||
entryType == PumpHistoryEntryType.EndResultTotals);
|
entryType == PumpHistoryEntryType.EndResultTotals);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.medtronic.comm.history.pump;
|
package info.nightscout.androidaps.plugins.pump.medtronic.comm.history.pump;
|
||||||
|
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.logging.L;
|
import info.nightscout.androidaps.logging.L;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.utils.DateTimeUtil;
|
import info.nightscout.androidaps.plugins.pump.common.utils.DateTimeUtil;
|
||||||
|
|
||||||
|
@ -92,20 +92,20 @@ public class PumpHistoryResult {
|
||||||
this.validEntries.add(unprocessedEntry);
|
this.validEntries.add(unprocessedEntry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Date: {
|
case Date: {
|
||||||
//LOG.debug("PE. Date search");
|
//LOG.debug("PE. Date search");
|
||||||
|
|
||||||
for (PumpHistoryEntry unprocessedEntry : unprocessedEntries) {
|
for (PumpHistoryEntry unprocessedEntry : unprocessedEntries) {
|
||||||
|
|
||||||
if (unprocessedEntry.atechDateTime==null || unprocessedEntry.atechDateTime==0) {
|
if (unprocessedEntry.atechDateTime == null || unprocessedEntry.atechDateTime == 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (unprocessedEntry.isAfter(this.searchDate)) {
|
if (unprocessedEntry.isAfter(this.searchDate)) {
|
||||||
this.validEntries.add(unprocessedEntry);
|
this.validEntries.add(unprocessedEntry);
|
||||||
} else {
|
} else {
|
||||||
if (DateTimeUtil.getYear(unprocessedEntry.atechDateTime) != 2000)
|
if (DateTimeUtil.getYear(unprocessedEntry.atechDateTime) < 2015)
|
||||||
olderEntries++;
|
olderEntries++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -116,7 +116,7 @@ public class PumpHistoryResult {
|
||||||
searchFinished = true;
|
searchFinished = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
} // switch
|
} // switch
|
||||||
|
|
||||||
|
@ -134,12 +134,12 @@ public class PumpHistoryResult {
|
||||||
|
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "PumpHistoryResult [unprocessed=" + (unprocessedEntries != null ? "" + unprocessedEntries.size() : "0") + //
|
return "PumpHistoryResult [unprocessed=" + (unprocessedEntries != null ? "" + unprocessedEntries.size() : "0") + //
|
||||||
", valid=" + (validEntries != null ? "" + validEntries.size() : "0") + //
|
", valid=" + (validEntries != null ? "" + validEntries.size() : "0") + //
|
||||||
", searchEntry=" + searchEntry + //
|
", searchEntry=" + searchEntry + //
|
||||||
", searchDate=" + searchDate + //
|
", searchDate=" + searchDate + //
|
||||||
", searchType=" + searchType + //
|
", searchType=" + searchType + //
|
||||||
", searchFinished=" + searchFinished + //
|
", searchFinished=" + searchFinished + //
|
||||||
"]";
|
"]";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.medtronic.data;
|
package info.nightscout.androidaps.plugins.pump.medtronic.data;
|
||||||
|
|
||||||
import com.google.common.base.Splitter;
|
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
|
import com.google.gson.GsonBuilder;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.joda.time.LocalDateTime;
|
import org.joda.time.LocalDateTime;
|
||||||
import org.joda.time.Minutes;
|
import org.joda.time.Minutes;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
@ -27,6 +28,7 @@ import info.nightscout.androidaps.db.TemporaryBasal;
|
||||||
import info.nightscout.androidaps.logging.L;
|
import info.nightscout.androidaps.logging.L;
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.DetailedBolusInfoStorage;
|
import info.nightscout.androidaps.plugins.configBuilder.DetailedBolusInfoStorage;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.utils.DateTimeUtil;
|
import info.nightscout.androidaps.plugins.pump.common.utils.DateTimeUtil;
|
||||||
|
import info.nightscout.androidaps.plugins.pump.common.utils.StringUtil;
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.MedtronicPumpPlugin;
|
import info.nightscout.androidaps.plugins.pump.medtronic.MedtronicPumpPlugin;
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.comm.history.pump.MedtronicPumpHistoryDecoder;
|
import info.nightscout.androidaps.plugins.pump.medtronic.comm.history.pump.MedtronicPumpHistoryDecoder;
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.comm.history.pump.PumpHistoryEntry;
|
import info.nightscout.androidaps.plugins.pump.medtronic.comm.history.pump.PumpHistoryEntry;
|
||||||
|
@ -70,6 +72,10 @@ public class MedtronicHistoryData {
|
||||||
public MedtronicHistoryData() {
|
public MedtronicHistoryData() {
|
||||||
this.allHistory = new ArrayList<>();
|
this.allHistory = new ArrayList<>();
|
||||||
this.gsonPretty = MedtronicUtil.gsonInstance;
|
this.gsonPretty = MedtronicUtil.gsonInstance;
|
||||||
|
|
||||||
|
if (this.gsonPretty == null) {
|
||||||
|
this.gsonPretty = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -93,7 +99,7 @@ public class MedtronicHistoryData {
|
||||||
|
|
||||||
this.newHistory = newEntries;
|
this.newHistory = newEntries;
|
||||||
|
|
||||||
showLogs("List of history (before filtering): ", MedtronicPumpPlugin.gsonInstance.toJson(this.newHistory));
|
showLogs("List of history (before filtering): ", gsonPretty.toJson(this.newHistory));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -104,9 +110,13 @@ public class MedtronicHistoryData {
|
||||||
LOG.debug(header);
|
LOG.debug(header);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (final String token : Splitter.fixedLength(3500).split(data)) {
|
if (StringUtils.isNotBlank(data)) {
|
||||||
if (isLogEnabled())
|
for (final String token : StringUtil.splitString(data, 3500)) {
|
||||||
LOG.debug("{}", token);
|
if (isLogEnabled())
|
||||||
|
LOG.debug("{}", token);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
LOG.debug("No data.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -123,45 +133,50 @@ public class MedtronicHistoryData {
|
||||||
List<PumpHistoryEntry> bolusEstimates = new ArrayList<>();
|
List<PumpHistoryEntry> bolusEstimates = new ArrayList<>();
|
||||||
long atechDate = DateTimeUtil.toATechDate(new GregorianCalendar());
|
long atechDate = DateTimeUtil.toATechDate(new GregorianCalendar());
|
||||||
|
|
||||||
for (PumpHistoryEntry pumpHistoryEntry : newHistory) {
|
LOG.debug("Filter new entries: Before {}", newHistory);
|
||||||
|
|
||||||
if (!this.allHistory.contains(pumpHistoryEntry)) {
|
if (isCollectionEmpty(newHistory)) {
|
||||||
|
|
||||||
PumpHistoryEntryType type = pumpHistoryEntry.getEntryType();
|
for (PumpHistoryEntry pumpHistoryEntry : newHistory) {
|
||||||
|
|
||||||
if (type == PumpHistoryEntryType.TempBasalRate || type == PumpHistoryEntryType.TempBasalDuration) {
|
if (!this.allHistory.contains(pumpHistoryEntry)) {
|
||||||
TBRs.add(pumpHistoryEntry);
|
|
||||||
} else if (type == PumpHistoryEntryType.BolusWizardEstimate) {
|
|
||||||
bolusEstimates.add(pumpHistoryEntry);
|
|
||||||
newHistory2.add(pumpHistoryEntry);
|
|
||||||
} else {
|
|
||||||
|
|
||||||
if (type == PumpHistoryEntryType.EndResultTotals) {
|
PumpHistoryEntryType type = pumpHistoryEntry.getEntryType();
|
||||||
if (!DateTimeUtil.isSameDay(atechDate, pumpHistoryEntry.atechDateTime)) {
|
|
||||||
|
if (type == PumpHistoryEntryType.TempBasalRate || type == PumpHistoryEntryType.TempBasalDuration) {
|
||||||
|
TBRs.add(pumpHistoryEntry);
|
||||||
|
} else if (type == PumpHistoryEntryType.BolusWizardEstimate) {
|
||||||
|
bolusEstimates.add(pumpHistoryEntry);
|
||||||
|
newHistory2.add(pumpHistoryEntry);
|
||||||
|
} else {
|
||||||
|
|
||||||
|
if (type == PumpHistoryEntryType.EndResultTotals) {
|
||||||
|
if (!DateTimeUtil.isSameDay(atechDate, pumpHistoryEntry.atechDateTime)) {
|
||||||
|
newHistory2.add(pumpHistoryEntry);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
newHistory2.add(pumpHistoryEntry);
|
newHistory2.add(pumpHistoryEntry);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
newHistory2.add(pumpHistoryEntry);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TBRs = preProcessTBRs(TBRs);
|
||||||
|
|
||||||
|
if (bolusEstimates.size() > 0) {
|
||||||
|
extendBolusRecords(bolusEstimates, newHistory2);
|
||||||
|
}
|
||||||
|
|
||||||
|
newHistory2.addAll(TBRs);
|
||||||
|
|
||||||
|
this.newHistory = newHistory2;
|
||||||
|
|
||||||
|
sort(this.newHistory);
|
||||||
}
|
}
|
||||||
|
|
||||||
TBRs = preProcessTBRs(TBRs);
|
|
||||||
|
|
||||||
if (bolusEstimates.size() > 0) {
|
|
||||||
extendBolusRecords(bolusEstimates, newHistory2);
|
|
||||||
}
|
|
||||||
|
|
||||||
newHistory2.addAll(TBRs);
|
|
||||||
|
|
||||||
this.newHistory = newHistory2;
|
|
||||||
|
|
||||||
sort(this.newHistory);
|
|
||||||
|
|
||||||
if (isLogEnabled())
|
if (isLogEnabled())
|
||||||
LOG.debug("New History entries found: {}", this.newHistory.size());
|
LOG.debug("New History entries found: {}", this.newHistory.size());
|
||||||
showLogs("List of history (after filtering): ", MedtronicPumpPlugin.gsonInstance.toJson(this.newHistory));
|
showLogs("List of history (after filtering): ", gsonPretty.toJson(this.newHistory));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -263,14 +278,14 @@ public class MedtronicHistoryData {
|
||||||
|
|
||||||
showLogs("isPumpSuspended: ", MedtronicPumpPlugin.gsonInstancePretty.toJson(items));
|
showLogs("isPumpSuspended: ", MedtronicPumpPlugin.gsonInstancePretty.toJson(items));
|
||||||
|
|
||||||
if (!items.isEmpty()) {
|
if (!isCollectionEmpty(items)) {
|
||||||
|
|
||||||
PumpHistoryEntryType pumpHistoryEntryType = items.get(0).getEntryType();
|
PumpHistoryEntryType pumpHistoryEntryType = items.get(0).getEntryType();
|
||||||
|
|
||||||
boolean isSuspended = !(pumpHistoryEntryType == PumpHistoryEntryType.TempBasalCombined || //
|
boolean isSuspended = !(pumpHistoryEntryType == PumpHistoryEntryType.TempBasalCombined || //
|
||||||
pumpHistoryEntryType == PumpHistoryEntryType.BasalProfileStart || //
|
pumpHistoryEntryType == PumpHistoryEntryType.BasalProfileStart || //
|
||||||
pumpHistoryEntryType == PumpHistoryEntryType.Bolus || //
|
pumpHistoryEntryType == PumpHistoryEntryType.Bolus || //
|
||||||
pumpHistoryEntryType == PumpHistoryEntryType.PumpResume || //
|
pumpHistoryEntryType == PumpHistoryEntryType.Resume || //
|
||||||
pumpHistoryEntryType == PumpHistoryEntryType.Prime);
|
pumpHistoryEntryType == PumpHistoryEntryType.Prime);
|
||||||
|
|
||||||
LOG.debug("isPumpSuspended. Last entry type={}, isSuspended={}", pumpHistoryEntryType, isSuspended);
|
LOG.debug("isPumpSuspended. Last entry type={}, isSuspended={}", pumpHistoryEntryType, isSuspended);
|
||||||
|
@ -313,8 +328,8 @@ public class MedtronicHistoryData {
|
||||||
PumpHistoryEntryType.Bolus, //
|
PumpHistoryEntryType.Bolus, //
|
||||||
PumpHistoryEntryType.TempBasalCombined, //
|
PumpHistoryEntryType.TempBasalCombined, //
|
||||||
PumpHistoryEntryType.Prime, //
|
PumpHistoryEntryType.Prime, //
|
||||||
PumpHistoryEntryType.PumpSuspend, //
|
PumpHistoryEntryType.Suspend, //
|
||||||
PumpHistoryEntryType.PumpResume, //
|
PumpHistoryEntryType.Resume, //
|
||||||
PumpHistoryEntryType.Rewind, //
|
PumpHistoryEntryType.Rewind, //
|
||||||
PumpHistoryEntryType.NoDeliveryAlarm, //
|
PumpHistoryEntryType.NoDeliveryAlarm, //
|
||||||
PumpHistoryEntryType.BasalProfileStart);
|
PumpHistoryEntryType.BasalProfileStart);
|
||||||
|
@ -860,8 +875,7 @@ public class MedtronicHistoryData {
|
||||||
oldestEntryTime = oldestEntryTime.plusSeconds(this.pumpTime.timeDifference);
|
oldestEntryTime = oldestEntryTime.plusSeconds(this.pumpTime.timeDifference);
|
||||||
}
|
}
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
if (isLogEnabled())
|
LOG.error("Problem decoding date from last record: {}" + currentTreatment);
|
||||||
LOG.error("Problem decoding date from last record: {}" + currentTreatment);
|
|
||||||
return 10; // default return of 10 minutes
|
return 10; // default return of 10 minutes
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,10 +5,8 @@ import info.nightscout.androidaps.plugins.pump.common.utils.StringUtil;
|
||||||
/**
|
/**
|
||||||
* Created by andy on 6/2/18.
|
* Created by andy on 6/2/18.
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
|
||||||
public class PumpTimeStampedRecord {
|
public class PumpTimeStampedRecord {
|
||||||
|
|
||||||
// protected LocalDateTime localDateTime;
|
|
||||||
protected int decimalPrecission = 2;
|
protected int decimalPrecission = 2;
|
||||||
public long atechDateTime;
|
public long atechDateTime;
|
||||||
|
|
||||||
|
@ -23,15 +21,6 @@ public class PumpTimeStampedRecord {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// public LocalDateTime getLocalDateTime() {
|
|
||||||
// return localDateTime;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// public void setLocalDateTime(LocalDateTime ATechDate) {
|
|
||||||
// this.localDateTime = ATechDate;
|
|
||||||
// }
|
|
||||||
|
|
||||||
public String getFormattedDecimal(double value) {
|
public String getFormattedDecimal(double value) {
|
||||||
return StringUtil.getFormatedValueUS(value, this.decimalPrecission);
|
return StringUtil.getFormatedValueUS(value, this.decimalPrecission);
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ public enum MedtronicCustomActionType implements CustomActionType {
|
||||||
|
|
||||||
WakeUpAndTune(), //
|
WakeUpAndTune(), //
|
||||||
ClearBolusBlock(), //
|
ClearBolusBlock(), //
|
||||||
ResetRileyLink(), //
|
ResetRileyLinkConfiguration(), //
|
||||||
|
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.medtronic.service;
|
package info.nightscout.androidaps.plugins.pump.medtronic.service;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.IntentFilter;
|
import android.content.IntentFilter;
|
||||||
import android.content.res.Configuration;
|
import android.content.res.Configuration;
|
||||||
import android.os.Binder;
|
import android.os.Binder;
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
|
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import info.nightscout.androidaps.MainApp;
|
import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.logging.L;
|
import info.nightscout.androidaps.logging.L;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkCommunicationManager;
|
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkCommunicationManager;
|
||||||
|
@ -53,7 +53,7 @@ public class RileyLinkMedtronicService extends RileyLinkService {
|
||||||
if (isLogEnabled())
|
if (isLogEnabled())
|
||||||
LOG.debug("RileyLinkMedtronicService newly constructed");
|
LOG.debug("RileyLinkMedtronicService newly constructed");
|
||||||
MedtronicUtil.setMedtronicService(this);
|
MedtronicUtil.setMedtronicService(this);
|
||||||
pumpStatus = (MedtronicPumpStatus)MedtronicPumpPlugin.getPlugin().getPumpStatusData();
|
pumpStatus = (MedtronicPumpStatus) MedtronicPumpPlugin.getPlugin().getPumpStatusData();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -113,8 +113,8 @@ public class RileyLinkMedtronicService extends RileyLinkService {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void resetRileyLinkDevice() {
|
public void resetRileyLinkConfiguration() {
|
||||||
rfspy.resetRileyLinkDevice();
|
rfspy.resetRileyLinkConfiguration();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -135,17 +135,17 @@ public class RileyLinkMedtronicService extends RileyLinkService {
|
||||||
if (pumpIDBytes == null) {
|
if (pumpIDBytes == null) {
|
||||||
LOG.error("Invalid pump ID? - PumpID is null.");
|
LOG.error("Invalid pump ID? - PumpID is null.");
|
||||||
|
|
||||||
rileyLinkServiceData.setPumpID("000000", new byte[] { 0, 0, 0 });
|
rileyLinkServiceData.setPumpID("000000", new byte[]{0, 0, 0});
|
||||||
|
|
||||||
} else if (pumpIDBytes.length != 3) {
|
} else if (pumpIDBytes.length != 3) {
|
||||||
LOG.error("Invalid pump ID? " + ByteUtil.shortHexString(pumpIDBytes));
|
LOG.error("Invalid pump ID? " + ByteUtil.shortHexString(pumpIDBytes));
|
||||||
|
|
||||||
rileyLinkServiceData.setPumpID("000000", new byte[] { 0, 0, 0 });
|
rileyLinkServiceData.setPumpID("000000", new byte[]{0, 0, 0});
|
||||||
|
|
||||||
} else if (pumpID.equals("000000")) {
|
} else if (pumpID.equals("000000")) {
|
||||||
LOG.error("Using pump ID " + pumpID);
|
LOG.error("Using pump ID " + pumpID);
|
||||||
|
|
||||||
rileyLinkServiceData.setPumpID(pumpID, new byte[] { 0, 0, 0 });
|
rileyLinkServiceData.setPumpID(pumpID, new byte[]{0, 0, 0});
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
LOG.info("Using pump ID " + pumpID);
|
LOG.info("Using pump ID " + pumpID);
|
||||||
|
@ -190,7 +190,7 @@ public class RileyLinkMedtronicService extends RileyLinkService {
|
||||||
|
|
||||||
|
|
||||||
public boolean handleDeviceSpecificBroadcasts(Intent intent) {
|
public boolean handleDeviceSpecificBroadcasts(Intent intent) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1349,8 +1349,8 @@
|
||||||
<string name="medtronic_pump_type">Pump Type</string>
|
<string name="medtronic_pump_type">Pump Type</string>
|
||||||
<string name="medtronic_pump_frequency">Pump Frequency</string>
|
<string name="medtronic_pump_frequency">Pump Frequency</string>
|
||||||
<string name="medtronic_pump_bolus_delay">Delay before Bolus is started (s)</string>
|
<string name="medtronic_pump_bolus_delay">Delay before Bolus is started (s)</string>
|
||||||
<string name="medtronic_pump_max_bolus">Max Bolus on Pump</string>
|
<string name="medtronic_pump_max_bolus">Max Bolus on Pump (U)</string>
|
||||||
<string name="medtronic_pump_max_basal">Max Basal on Pump</string>
|
<string name="medtronic_pump_max_basal">Max Basal on Pump (U/h)</string>
|
||||||
<string name="medtronic_pump_encoding">Medtronic Encoding</string>
|
<string name="medtronic_pump_encoding">Medtronic Encoding</string>
|
||||||
<string name="medtronic_pump_frequency_us_ca">US & Canada (916 MHz)</string>
|
<string name="medtronic_pump_frequency_us_ca">US & Canada (916 MHz)</string>
|
||||||
<string name="medtronic_pump_frequency_worldwide">Worldwide (868 Mhz)</string>
|
<string name="medtronic_pump_frequency_worldwide">Worldwide (868 Mhz)</string>
|
||||||
|
@ -1359,7 +1359,7 @@
|
||||||
<string name="rileylink_mac_address">RileyLink MAC Address</string>
|
<string name="rileylink_mac_address">RileyLink MAC Address</string>
|
||||||
<string name="medtronic_custom_action_wake_and_tune">Wake and Tune Up</string>
|
<string name="medtronic_custom_action_wake_and_tune">Wake and Tune Up</string>
|
||||||
<string name="medtronic_custom_action_clear_bolus_block">Clear Bolus Block</string>
|
<string name="medtronic_custom_action_clear_bolus_block">Clear Bolus Block</string>
|
||||||
<string name="medtronic_custom_action_reset_rileylink">Reset RileyLink</string>
|
<string name="medtronic_custom_action_reset_rileylink">Reset RileyLink Config</string>
|
||||||
<string name="medtronic_pump_battery_select">Battery Type (Power View)</string>
|
<string name="medtronic_pump_battery_select">Battery Type (Power View)</string>
|
||||||
<string name="medtronic_pump_battery_no">Not selected (Simple view)</string>
|
<string name="medtronic_pump_battery_no">Not selected (Simple view)</string>
|
||||||
<string name="medtronic_pump_battery_alkaline">Alkaline (Extended view)</string>
|
<string name="medtronic_pump_battery_alkaline">Alkaline (Extended view)</string>
|
||||||
|
@ -1444,8 +1444,8 @@
|
||||||
<string name="medtronic_error_pump_basal_profiles_not_enabled">Basal profiles are not enabled on pump.</string>
|
<string name="medtronic_error_pump_basal_profiles_not_enabled">Basal profiles are not enabled on pump.</string>
|
||||||
<string name="medtronic_error_pump_incorrect_basal_profile_selected">Basal profile set on pump is incorrect (must be STD).</string>
|
<string name="medtronic_error_pump_incorrect_basal_profile_selected">Basal profile set on pump is incorrect (must be STD).</string>
|
||||||
<string name="medtronic_error_pump_wrong_tbr_type_set">Wrong TBR type set on pump (must be Absolute).</string>
|
<string name="medtronic_error_pump_wrong_tbr_type_set">Wrong TBR type set on pump (must be Absolute).</string>
|
||||||
<string name="medtronic_error_pump_wrong_max_bolus_set" formatted="false">Wrong Max Bolus set on Pump (must be %.2f).</string>
|
<string name="medtronic_error_pump_wrong_max_bolus_set">Wrong Max Bolus set on Pump (must be %1$.2f).</string>
|
||||||
<string name="medtronic_error_pump_wrong_max_basal_set" formatted="false">Wrong Max Basal set on Pump (must be %.2f).</string>
|
<string name="medtronic_error_pump_wrong_max_basal_set">Wrong Max Basal set on Pump (must be %1$.2f).</string>
|
||||||
<string name="medtronic_error_operation_not_possible_no_configuration">Operation is not possible.\n\n You need to configure Medtronic Pump first, before you can use this operation.</string>
|
<string name="medtronic_error_operation_not_possible_no_configuration">Operation is not possible.\n\n You need to configure Medtronic Pump first, before you can use this operation.</string>
|
||||||
|
|
||||||
<string name="xxx">xxx</string>
|
<string name="xxx">xxx</string>
|
||||||
|
|
|
@ -1,19 +1,18 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.medtronic.comm;
|
package info.nightscout.androidaps.plugins.pump.medtronic.comm;
|
||||||
|
|
||||||
import java.util.List;
|
import android.util.Log;
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import uk.org.lidalia.slf4jtest.TestLogger;
|
import java.util.List;
|
||||||
import uk.org.lidalia.slf4jtest.TestLoggerFactory;
|
|
||||||
|
|
||||||
import android.util.Log;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.plugins.pump.common.utils.ByteUtil;
|
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.comm.history.RawHistoryPage;
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.comm.history.pump.MedtronicPumpHistoryDecoder;
|
import info.nightscout.androidaps.plugins.pump.medtronic.comm.history.pump.MedtronicPumpHistoryDecoder;
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.comm.history.pump.PumpHistoryEntry;
|
import info.nightscout.androidaps.plugins.pump.medtronic.comm.history.pump.PumpHistoryEntry;
|
||||||
|
import uk.org.lidalia.slf4jtest.TestLogger;
|
||||||
|
import uk.org.lidalia.slf4jtest.TestLoggerFactory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by andy on 3/10/19.
|
* Created by andy on 3/10/19.
|
||||||
|
@ -24,7 +23,7 @@ public class MedtronicHistoryDataUTest {
|
||||||
TestLogger LOGGER = TestLoggerFactory.getTestLogger(MedtronicHistoryDataUTest.class);
|
TestLogger LOGGER = TestLoggerFactory.getTestLogger(MedtronicHistoryDataUTest.class);
|
||||||
|
|
||||||
byte[] historyPageData = ByteUtil
|
byte[] historyPageData = ByteUtil
|
||||||
.createByteArrayFromString("16 00 12 EC 14 47 13 33 00 14 F2 14 47 13 00 16 01 14 F2 14 47 13 33 00 1C C9 15 47 13 00 16 00 1C C9 15 47 13 33 4E 31 D3 15 47 13 00 16 01 31 D3 15 47 13 33 00 1A F1 15 47 13 00 16 00 1A F1 15 47 13 33 50 1D F1 15 47 13 00 16 01 1D F1 15 47 13 33 50 11 D8 16 47 13 00 16 01 11 D8 16 47 13 33 50 31 FB 16 47 13 00 16 01 31 FB 16 47 13 33 50 12 E3 17 47 13 00 16 01 12 E3 17 47 13 33 00 1E FB 17 47 13 00 16 00 1E FB 17 47 13 33 D8 21 FB 17 47 13 00 16 01 21 FB 17 47 13 07 00 00 05 CC 27 93 6D 27 93 05 0C 00 E8 00 00 00 00 05 CC 05 CC 64 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0C 00 E8 00 00 00 33 00 36 C4 00 48 13 00 16 00 36 C4 00 48 13 33 D8 29 C9 00 48 13 00 16 01 29 C9 00 48 13 33 00 12 E7 00 48 13 00 16 00 12 E7 00 48 13 33 BC 19 C9 01 48 13 00 16 01 19 C9 01 48 13 33 00 26 CE 01 48 13 00 16 00 26 CE 01 48 13 33 44 29 CE 01 48 13 00 16 01 29 CE 01 48 13 33 00 13 D3 01 48 13 00 16 00 13 D3 01 48 13 33 64 31 F1 01 48 13 00 16 01 31 F1 01 48 13 33 00 0B F7 01 48 13 00 16 00 0B F7 01 48 13 33 00 12 D8 02 48 13 00 16 01 12 D8 02 48 13 33 00 10 F1 02 48 13 00 16 00 10 F1 02 48 13 33 00 30 C4 03 48 13 00 16 01 30 C4 03 48 13 33 00 04 CA 03 48 13 00 16 00 04 CA 03 48 13 33 00 2F D3 03 48 13 00 16 01 2F D3 03 48 13 33 00 30 D8 03 48 13 00 16 00 30 D8 03 48 13 33 00 13 E7 03 48 13 00 16 01 13 E7 03 48 13 33 00 2E FB 03 48 13 00 16 00 2E FB 03 48 13 19 00 00 C1 04 08 13 07 00 00 04 0C 28 93 6D 28 93 05 0C 00 E8 00 00 00 00 04 0C 04 0C 64 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0C 00 E8 00 00 00 06 3E 03 7A 19 DC 48 49 13 0C 3E 0C E6 08 09 13 07 00 00 01 E4 29 93 6D 29 93 05 0C 00 E8 00 00 00 00 01 E4 01 E4 64 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0C 00 E8 00 00 00 1A 00 13 D2 0D 0A 13 1A 01 28 D2 0D 0A 13 21 00 2A D8 0D 0A 13 03 00 00 00 0E 2D D9 2D 0A 13 33 98 26 DE 0D 4A 13 00 16 01 26 DE 0D 4A 13 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 5D 70");
|
.createByteArrayFromString("16 00 12 EC 14 47 13 33 00 14 F2 14 47 13 00 16 01 14 F2 14 47 13 33 00 1C C9 15 47 13 00 16 00 1C C9 15 47 13 33 4E 31 D3 15 47 13 00 16 01 31 D3 15 47 13 33 00 1A F1 15 47 13 00 16 00 1A F1 15 47 13 33 50 1D F1 15 47 13 00 16 01 1D F1 15 47 13 33 50 11 D8 16 47 13 00 16 01 11 D8 16 47 13 33 50 31 FB 16 47 13 00 16 01 31 FB 16 47 13 33 50 12 E3 17 47 13 00 16 01 12 E3 17 47 13 33 00 1E FB 17 47 13 00 16 00 1E FB 17 47 13 33 D8 21 FB 17 47 13 00 16 01 21 FB 17 47 13 07 00 00 05 CC 27 93 6D 27 93 05 0C 00 E8 00 00 00 00 05 CC 05 CC 64 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0C 00 E8 00 00 00 33 00 36 C4 00 48 13 00 16 00 36 C4 00 48 13 33 D8 29 C9 00 48 13 00 16 01 29 C9 00 48 13 33 00 12 E7 00 48 13 00 16 00 12 E7 00 48 13 33 BC 19 C9 01 48 13 00 16 01 19 C9 01 48 13 33 00 26 CE 01 48 13 00 16 00 26 CE 01 48 13 33 44 29 CE 01 48 13 00 16 01 29 CE 01 48 13 33 00 13 D3 01 48 13 00 16 00 13 D3 01 48 13 33 64 31 F1 01 48 13 00 16 01 31 F1 01 48 13 33 00 0B F7 01 48 13 00 16 00 0B F7 01 48 13 33 00 12 D8 02 48 13 00 16 01 12 D8 02 48 13 33 00 10 F1 02 48 13 00 16 00 10 F1 02 48 13 33 00 30 C4 03 48 13 00 16 01 30 C4 03 48 13 33 00 04 CA 03 48 13 00 16 00 04 CA 03 48 13 33 00 2F D3 03 48 13 00 16 01 2F D3 03 48 13 33 00 30 D8 03 48 13 00 16 00 30 D8 03 48 13 33 00 13 E7 03 48 13 00 16 01 13 E7 03 48 13 33 00 2E FB 03 48 13 00 16 00 2E FB 03 48 13 19 00 00 C1 04 08 13 07 00 00 04 0C 28 93 6D 28 93 05 0C 00 E8 00 00 00 00 04 0C 04 0C 64 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0C 00 E8 00 00 00 06 3E 03 7A 19 DC 48 49 13 0C 3E 0C E6 08 09 13 07 00 00 01 E4 29 93 6D 29 93 05 0C 00 E8 00 00 00 00 01 E4 01 E4 64 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0C 00 E8 00 00 00 1A 00 13 D2 0D 0A 13 1A 01 28 D2 0D 0A 13 21 00 2A D8 0D 0A 13 03 00 00 00 0E 2D D9 2D 0A 13 33 98 26 DE 0D 4A 13 00 16 01 26 DE 0D 4A 13 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 5D 70");
|
||||||
|
|
||||||
MedtronicPumpHistoryDecoder decoder = new MedtronicPumpHistoryDecoder();
|
MedtronicPumpHistoryDecoder decoder = new MedtronicPumpHistoryDecoder();
|
||||||
|
|
||||||
|
@ -66,8 +65,24 @@ public class MedtronicHistoryDataUTest {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testRussel() throws Exception {
|
||||||
|
byte[] historyPageData = ByteUtil
|
||||||
|
.createByteArrayFromString("06 15 04 F6 00 40 60 01 05 06 36 04 FE 00 40 60 01 05 06 2F 18 1A 00 40 20 C1 05 06 2F 0C 45 00 40 20 C1 05 06 2F 0C 56 00 40 20 C1 05 06 2F 0C 78 00 40 20 C1 05 06 2F 0C AD 00 40 20 C1 05 06 15 04 BA 00 40 40 A1 05 0C 15 0E 40 00 01 05 64 00 0D 44 00 01 05 17 00 14 44 00 01 05 18 00 00 44 00 01 05 21 00 07 44 00 01 05 21 00 0C 4E 00 01 05 07 00 00 00 00 01 85 6D 01 85 06 08 00 2B 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 08 00 2B 00 00 00 03 00 00 00 15 00 67 35 02 05 03 00 03 00 03 1C 67 15 02 05 07 00 00 00 40 02 85 6D 02 85 06 08 00 2B 00 00 00 00 00 40 00 40 64 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 08 00 2B 00 00 00 2C 78 39 5F 17 03 05 07 00 00 02 6C 03 85 6D 03 85 06 08 00 2B 00 00 00 00 02 6C 02 6C 64 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 08 00 2B 00 00 00 26 01 33 44 01 04 05 27 03 74 41 01 B2 07 28 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 29 74");
|
||||||
|
|
||||||
public void testBolus() throws Exception {
|
RawHistoryPage historyPage = new RawHistoryPage();
|
||||||
|
historyPage.appendData(historyPageData);
|
||||||
|
|
||||||
|
List<PumpHistoryEntry> pumpHistoryEntries = decoder.processPageAndCreateRecords(historyPage);
|
||||||
|
|
||||||
|
System.out.println("PumpHistoryEntries: " + pumpHistoryEntries.size());
|
||||||
|
|
||||||
|
Log.d("Test", "Log.d");
|
||||||
|
LOGGER.debug("Logger.debug");
|
||||||
|
|
||||||
|
for (PumpHistoryEntry pumpHistoryEntry : pumpHistoryEntries) {
|
||||||
|
Log.d("MedtronicHistoryDataUTest", pumpHistoryEntry.toString());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue