- refactored commands, removed version out of it
- finished Medtronic History Dialog (middle button) - refactored Set/Get Basal functionality
This commit is contained in:
parent
78abf7299a
commit
72eae6e6b8
|
@ -19,6 +19,7 @@ import info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.ble.RileyLinkB
|
||||||
import info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.ble.data.encoding.Encoding4b6b;
|
import info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.ble.data.encoding.Encoding4b6b;
|
||||||
import info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.ble.data.encoding.Encoding4b6bGeoff;
|
import info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.ble.data.encoding.Encoding4b6bGeoff;
|
||||||
import info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.ble.defs.RileyLinkEncodingType;
|
import info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.ble.defs.RileyLinkEncodingType;
|
||||||
|
import info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.ble.defs.RileyLinkFirmwareVersion;
|
||||||
import info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.ble.defs.RileyLinkTargetFrequency;
|
import info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.ble.defs.RileyLinkTargetFrequency;
|
||||||
import info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.data.BleAdvertisedData;
|
import info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.data.BleAdvertisedData;
|
||||||
import info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.data.RLHistoryItem;
|
import info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.data.RLHistoryItem;
|
||||||
|
@ -32,7 +33,6 @@ import info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.service.data.S
|
||||||
import info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.service.data.ServiceTransport;
|
import info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.service.data.ServiceTransport;
|
||||||
import info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.service.tasks.ServiceTask;
|
import info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.service.tasks.ServiceTask;
|
||||||
import info.nightscout.androidaps.plugins.PumpCommon.ui.RileyLinkSelectPreference;
|
import info.nightscout.androidaps.plugins.PumpCommon.ui.RileyLinkSelectPreference;
|
||||||
import info.nightscout.androidaps.plugins.PumpMedtronic.defs.MedtronicDeviceType;
|
|
||||||
import info.nightscout.androidaps.plugins.PumpMedtronic.events.EventMedtronicDeviceStatusChange;
|
import info.nightscout.androidaps.plugins.PumpMedtronic.events.EventMedtronicDeviceStatusChange;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -52,7 +52,7 @@ public class RileyLinkUtil {
|
||||||
// private static MedtronicPumpStatus medtronicPumpStatus;
|
// private static MedtronicPumpStatus medtronicPumpStatus;
|
||||||
private static RileyLinkService rileyLinkService;
|
private static RileyLinkService rileyLinkService;
|
||||||
// private static RileyLinkIPCConnection rileyLinkIPCConnection;
|
// private static RileyLinkIPCConnection rileyLinkIPCConnection;
|
||||||
private static MedtronicDeviceType medtronicPumpModel;
|
// private static MedtronicDeviceType medtronicPumpModel;
|
||||||
// BAD dependencies in Classes: RileyLinkService
|
// BAD dependencies in Classes: RileyLinkService
|
||||||
private static RileyLinkTargetFrequency rileyLinkTargetFrequency;
|
private static RileyLinkTargetFrequency rileyLinkTargetFrequency;
|
||||||
|
|
||||||
|
@ -62,6 +62,7 @@ public class RileyLinkUtil {
|
||||||
private static RileyLinkEncodingType encoding;
|
private static RileyLinkEncodingType encoding;
|
||||||
private static RileyLinkSelectPreference rileyLinkSelectPreference;
|
private static RileyLinkSelectPreference rileyLinkSelectPreference;
|
||||||
private static Encoding4b6b encoding4b6b;
|
private static Encoding4b6b encoding4b6b;
|
||||||
|
private static RileyLinkFirmwareVersion firmwareVersion;
|
||||||
|
|
||||||
|
|
||||||
public static void setContext(Context contextIn) {
|
public static void setContext(Context contextIn) {
|
||||||
|
@ -329,4 +330,14 @@ public class RileyLinkUtil {
|
||||||
public static Encoding4b6b getEncoding4b6b() {
|
public static Encoding4b6b getEncoding4b6b() {
|
||||||
return RileyLinkUtil.encoding4b6b;
|
return RileyLinkUtil.encoding4b6b;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static void setFirmwareVersion(RileyLinkFirmwareVersion firmwareVersion) {
|
||||||
|
RileyLinkUtil.firmwareVersion = firmwareVersion;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static RileyLinkFirmwareVersion getFirmwareVersion() {
|
||||||
|
return firmwareVersion;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,8 +10,8 @@ import android.os.SystemClock;
|
||||||
import info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.RileyLinkUtil;
|
import info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.RileyLinkUtil;
|
||||||
import info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.ble.command.RileyLinkCommand;
|
import info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.ble.command.RileyLinkCommand;
|
||||||
import info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.ble.command.SendAndListen;
|
import info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.ble.command.SendAndListen;
|
||||||
|
import info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.ble.command.SetHardwareEncoding;
|
||||||
import info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.ble.command.SetPreamble;
|
import info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.ble.command.SetPreamble;
|
||||||
import info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.ble.command.SetSoftwareEncoding;
|
|
||||||
import info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.ble.command.UpdateRegister;
|
import info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.ble.command.UpdateRegister;
|
||||||
import info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.ble.data.GattAttributes;
|
import info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.ble.data.GattAttributes;
|
||||||
import info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.ble.data.RFSpyResponse;
|
import info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.ble.data.RFSpyResponse;
|
||||||
|
@ -83,6 +83,7 @@ public class RFSpy {
|
||||||
public void initializeRileyLink() {
|
public void initializeRileyLink() {
|
||||||
bleVersion = getVersion();
|
bleVersion = getVersion();
|
||||||
firmwareVersion = getFirmwareVersion();
|
firmwareVersion = getFirmwareVersion();
|
||||||
|
RileyLinkUtil.setFirmwareVersion(firmwareVersion);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -286,16 +287,15 @@ public class RFSpy {
|
||||||
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(firmwareVersion, sendChannel, repeatCount, delay_ms, listenChannel,
|
SendAndListen command = new SendAndListen(sendChannel, repeatCount, delay_ms, listenChannel, timeout_ms,
|
||||||
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(firmwareVersion, reg, (byte)val),
|
RFSpyResponse resp = writeToData(new UpdateRegister(reg, (byte)val), EXPECTED_MAX_BLUETOOTH_LATENCY_MS);
|
||||||
EXPECTED_MAX_BLUETOOTH_LATENCY_MS);
|
|
||||||
return resp;
|
return resp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -397,7 +397,7 @@ public class RFSpy {
|
||||||
private RFSpyResponse setPreamble(int preamble) {
|
private RFSpyResponse setPreamble(int preamble) {
|
||||||
RFSpyResponse resp = null;
|
RFSpyResponse resp = null;
|
||||||
try {
|
try {
|
||||||
resp = writeToData(new SetPreamble(firmwareVersion, preamble), EXPECTED_MAX_BLUETOOTH_LATENCY_MS);
|
resp = writeToData(new SetPreamble(preamble), EXPECTED_MAX_BLUETOOTH_LATENCY_MS);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.toString();
|
e.toString();
|
||||||
}
|
}
|
||||||
|
@ -406,8 +406,7 @@ public class RFSpy {
|
||||||
|
|
||||||
|
|
||||||
private RFSpyResponse setSoftwareEncoding(RileyLinkEncodingType encoding) {
|
private RFSpyResponse setSoftwareEncoding(RileyLinkEncodingType encoding) {
|
||||||
RFSpyResponse resp = writeToData(new SetSoftwareEncoding(firmwareVersion, encoding),
|
RFSpyResponse resp = writeToData(new SetHardwareEncoding(encoding), EXPECTED_MAX_BLUETOOTH_LATENCY_MS);
|
||||||
EXPECTED_MAX_BLUETOOTH_LATENCY_MS);
|
|
||||||
return resp;
|
return resp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,11 @@
|
||||||
package info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.ble.command;
|
package info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.ble.command;
|
||||||
|
|
||||||
import info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.ble.defs.RileyLinkCommandType;
|
import info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.ble.defs.RileyLinkCommandType;
|
||||||
import info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.ble.defs.RileyLinkFirmwareVersion;
|
|
||||||
|
|
||||||
public class GetVersion extends RileyLinkCommand {
|
public class GetVersion extends RileyLinkCommand {
|
||||||
|
|
||||||
public GetVersion(RileyLinkFirmwareVersion version) {
|
public GetVersion() {
|
||||||
super(version);
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,15 +1,10 @@
|
||||||
package info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.ble.command;
|
package info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.ble.command;
|
||||||
|
|
||||||
import info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.ble.defs.RileyLinkCommandType;
|
import info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.ble.defs.RileyLinkCommandType;
|
||||||
import info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.ble.defs.RileyLinkFirmwareVersion;
|
|
||||||
|
|
||||||
public abstract class RileyLinkCommand {
|
public abstract class RileyLinkCommand {
|
||||||
|
|
||||||
protected RileyLinkFirmwareVersion version;
|
public RileyLinkCommand() {
|
||||||
|
|
||||||
|
|
||||||
public RileyLinkCommand(RileyLinkFirmwareVersion version) {
|
|
||||||
this.version = version;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@ package info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.ble.command;
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.RileyLinkUtil;
|
||||||
import info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.ble.data.RadioPacket;
|
import info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.ble.data.RadioPacket;
|
||||||
import info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.ble.defs.RileyLinkCommandType;
|
import info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.ble.defs.RileyLinkCommandType;
|
||||||
import info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.ble.defs.RileyLinkFirmwareVersion;
|
import info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.ble.defs.RileyLinkFirmwareVersion;
|
||||||
|
@ -20,21 +21,20 @@ public class SendAndListen extends RileyLinkCommand {
|
||||||
private RadioPacket packetToSend;
|
private RadioPacket packetToSend;
|
||||||
|
|
||||||
|
|
||||||
public SendAndListen(RileyLinkFirmwareVersion version, byte sendChannel, byte repeatCount,
|
public SendAndListen(byte sendChannel, byte repeatCount, byte delayBetweenPackets_ms, byte listenChannel,
|
||||||
byte delayBetweenPackets_ms, byte listenChannel, int timeout_ms, byte retryCount, RadioPacket packetToSend
|
int timeout_ms, byte retryCount, RadioPacket packetToSend
|
||||||
|
|
||||||
) {
|
) {
|
||||||
this(version, sendChannel, repeatCount, delayBetweenPackets_ms, listenChannel, timeout_ms, retryCount, null,
|
this(sendChannel, repeatCount, delayBetweenPackets_ms, listenChannel, timeout_ms, retryCount, null,
|
||||||
packetToSend);
|
packetToSend);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public SendAndListen(RileyLinkFirmwareVersion version, byte sendChannel, byte repeatCount,
|
public SendAndListen(byte sendChannel, byte repeatCount, int delayBetweenPackets_ms, byte listenChannel,
|
||||||
int delayBetweenPackets_ms, byte listenChannel, int timeout_ms, byte retryCount,
|
int timeout_ms, byte retryCount, Integer preambleExtension_ms, RadioPacket packetToSend
|
||||||
Integer preambleExtension_ms, RadioPacket packetToSend
|
|
||||||
|
|
||||||
) {
|
) {
|
||||||
super(version);
|
super();
|
||||||
this.sendChannel = sendChannel;
|
this.sendChannel = sendChannel;
|
||||||
this.repeatCount = repeatCount;
|
this.repeatCount = repeatCount;
|
||||||
this.delayBetweenPackets_ms = delayBetweenPackets_ms;
|
this.delayBetweenPackets_ms = delayBetweenPackets_ms;
|
||||||
|
@ -55,7 +55,8 @@ public class SendAndListen extends RileyLinkCommand {
|
||||||
@Override
|
@Override
|
||||||
public byte[] getRaw() {
|
public byte[] getRaw() {
|
||||||
|
|
||||||
boolean isPacketV2 = this.version.isSameVersion(RileyLinkFirmwareVersion.Version2AndHigher);
|
boolean isPacketV2 = RileyLinkUtil.getFirmwareVersion().isSameVersion(
|
||||||
|
RileyLinkFirmwareVersion.Version2AndHigher);
|
||||||
|
|
||||||
ArrayList<Byte> bytes = new ArrayList<Byte>();
|
ArrayList<Byte> bytes = new ArrayList<Byte>();
|
||||||
bytes.add(this.getCommandType().code);
|
bytes.add(this.getCommandType().code);
|
||||||
|
|
|
@ -2,22 +2,21 @@ package info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.ble.command;
|
||||||
|
|
||||||
import info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.ble.defs.RileyLinkCommandType;
|
import info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.ble.defs.RileyLinkCommandType;
|
||||||
import info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.ble.defs.RileyLinkEncodingType;
|
import info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.ble.defs.RileyLinkEncodingType;
|
||||||
import info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.ble.defs.RileyLinkFirmwareVersion;
|
|
||||||
|
|
||||||
public class SetSoftwareEncoding extends RileyLinkCommand {
|
public class SetHardwareEncoding extends RileyLinkCommand {
|
||||||
|
|
||||||
private final RileyLinkEncodingType encoding;
|
private final RileyLinkEncodingType encoding;
|
||||||
|
|
||||||
|
|
||||||
public SetSoftwareEncoding(RileyLinkFirmwareVersion version, RileyLinkEncodingType encoding) {
|
public SetHardwareEncoding(RileyLinkEncodingType encoding) {
|
||||||
super(version);
|
super();
|
||||||
this.encoding = encoding;
|
this.encoding = encoding;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RileyLinkCommandType getCommandType() {
|
public RileyLinkCommandType getCommandType() {
|
||||||
return RileyLinkCommandType.SetSWEncoding;
|
return RileyLinkCommandType.SetHardwareEncoding;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,7 @@ import java.nio.ByteBuffer;
|
||||||
|
|
||||||
import org.apache.commons.lang3.NotImplementedException;
|
import org.apache.commons.lang3.NotImplementedException;
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.RileyLinkUtil;
|
||||||
import info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.ble.defs.RileyLinkCommandType;
|
import info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.ble.defs.RileyLinkCommandType;
|
||||||
import info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.ble.defs.RileyLinkFirmwareVersion;
|
import info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.ble.defs.RileyLinkFirmwareVersion;
|
||||||
|
|
||||||
|
@ -12,10 +13,11 @@ public class SetPreamble extends RileyLinkCommand {
|
||||||
private int preamble;
|
private int preamble;
|
||||||
|
|
||||||
|
|
||||||
public SetPreamble(RileyLinkFirmwareVersion version, int preamble) throws Exception {
|
public SetPreamble(int preamble) throws Exception {
|
||||||
super(version);
|
super();
|
||||||
if (!this.version.isSameVersion(RileyLinkFirmwareVersion.Version2AndHigher)) { // this command was not supported
|
|
||||||
// before 2.0
|
// this command was not supported before 2.0
|
||||||
|
if (!RileyLinkUtil.getFirmwareVersion().isSameVersion(RileyLinkFirmwareVersion.Version2AndHigher)) {
|
||||||
throw new NotImplementedException("Old firmware does not support SetPreamble command");
|
throw new NotImplementedException("Old firmware does not support SetPreamble command");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,6 @@ package info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.ble.command;
|
||||||
|
|
||||||
import info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.ble.defs.CC111XRegister;
|
import info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.ble.defs.CC111XRegister;
|
||||||
import info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.ble.defs.RileyLinkCommandType;
|
import info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.ble.defs.RileyLinkCommandType;
|
||||||
import info.nightscout.androidaps.plugins.PumpCommon.hw.rileylink.ble.defs.RileyLinkFirmwareVersion;
|
|
||||||
|
|
||||||
public class UpdateRegister extends RileyLinkCommand {
|
public class UpdateRegister extends RileyLinkCommand {
|
||||||
|
|
||||||
|
@ -10,8 +9,8 @@ public class UpdateRegister extends RileyLinkCommand {
|
||||||
byte registerValue;
|
byte registerValue;
|
||||||
|
|
||||||
|
|
||||||
public UpdateRegister(RileyLinkFirmwareVersion version, CC111XRegister register, byte registerValue) {
|
public UpdateRegister(CC111XRegister register, byte registerValue) {
|
||||||
super(version);
|
super();
|
||||||
this.register = register;
|
this.register = register;
|
||||||
this.registerValue = registerValue;
|
this.registerValue = registerValue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,9 +14,9 @@ public enum RileyLinkCommandType {
|
||||||
UpdateRegister(6), //
|
UpdateRegister(6), //
|
||||||
Reset(7), //
|
Reset(7), //
|
||||||
Led(8),
|
Led(8),
|
||||||
ReadRegister(8),
|
ReadRegister(9),
|
||||||
SetModeRegisters(10),
|
SetModeRegisters(10),
|
||||||
SetSWEncoding(11),
|
SetHardwareEncoding(11),
|
||||||
SetPreamble(12),
|
SetPreamble(12),
|
||||||
ResetRadioConfig(13),
|
ResetRadioConfig(13),
|
||||||
GetStatistics(14), ;
|
GetStatistics(14), ;
|
||||||
|
|
|
@ -5,11 +5,11 @@ import java.util.List;
|
||||||
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
|
import android.support.v7.widget.LinearLayoutManager;
|
||||||
|
import android.support.v7.widget.RecyclerView;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.BaseAdapter;
|
|
||||||
import android.widget.ListView;
|
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
|
@ -26,16 +26,31 @@ import info.nightscout.androidaps.plugins.PumpMedtronic.defs.PumpDeviceState;
|
||||||
public class RileyLinkStatusHistory extends Fragment implements RefreshableInterface {
|
public class RileyLinkStatusHistory extends Fragment implements RefreshableInterface {
|
||||||
|
|
||||||
// @BindView(R.id.rileylink_history_list)
|
// @BindView(R.id.rileylink_history_list)
|
||||||
ListView listView;
|
// ListView listView;
|
||||||
|
|
||||||
RileyLinkHistoryListAdapter adapter;
|
RecyclerView recyclerView;
|
||||||
|
RecyclerViewAdapter recyclerViewAdapter;
|
||||||
|
|
||||||
|
// RileyLinkHistoryListAdapter adapter;
|
||||||
|
|
||||||
|
LinearLayoutManager llm;
|
||||||
|
List<RLHistoryItem> filteredHistoryList = new ArrayList<>();
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
View rootView = inflater.inflate(R.layout.rileylink_status_history, container, false);
|
View rootView = inflater.inflate(R.layout.rileylink_status_history, container, false);
|
||||||
|
|
||||||
adapter = new RileyLinkHistoryListAdapter();
|
// adapter = new RileyLinkHistoryListAdapter();
|
||||||
|
|
||||||
|
recyclerView = (RecyclerView)rootView.findViewById(R.id.rileylink_history_list);
|
||||||
|
|
||||||
|
recyclerView.setHasFixedSize(true);
|
||||||
|
llm = new LinearLayoutManager(getActivity().getApplicationContext());
|
||||||
|
recyclerView.setLayoutManager(llm);
|
||||||
|
|
||||||
|
recyclerViewAdapter = new RecyclerViewAdapter(filteredHistoryList);
|
||||||
|
recyclerView.setAdapter(recyclerViewAdapter);
|
||||||
|
|
||||||
return rootView;
|
return rootView;
|
||||||
}
|
}
|
||||||
|
@ -45,9 +60,9 @@ public class RileyLinkStatusHistory extends Fragment implements RefreshableInter
|
||||||
public void onStart() {
|
public void onStart() {
|
||||||
super.onStart();
|
super.onStart();
|
||||||
|
|
||||||
this.listView = (ListView)getActivity().findViewById(R.id.rileylink_history_list);
|
// this.listView = (ListView)getActivity().findViewById(R.id.rileylink_history_list);
|
||||||
|
|
||||||
listView.setAdapter(adapter);
|
// listView.setAdapter(adapter);
|
||||||
|
|
||||||
refreshData();
|
refreshData();
|
||||||
}
|
}
|
||||||
|
@ -55,49 +70,38 @@ public class RileyLinkStatusHistory extends Fragment implements RefreshableInter
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void refreshData() {
|
public void refreshData() {
|
||||||
adapter.addItemsAndClean(RileyLinkUtil.getRileyLinkHistory());
|
recyclerViewAdapter.addItemsAndClean(RileyLinkUtil.getRileyLinkHistory());
|
||||||
}
|
}
|
||||||
|
|
||||||
static class ViewHolder {
|
// static class ViewHolder {
|
||||||
|
//
|
||||||
|
// TextView itemTime;
|
||||||
|
// TextView itemSource;
|
||||||
|
// TextView itemDescription;
|
||||||
|
// }
|
||||||
|
|
||||||
TextView itemTime;
|
public static class RecyclerViewAdapter extends RecyclerView.Adapter<RecyclerViewAdapter.HistoryViewHolder> {
|
||||||
TextView itemSource;
|
|
||||||
TextView itemDescription;
|
|
||||||
}
|
|
||||||
|
|
||||||
private class RileyLinkHistoryListAdapter extends BaseAdapter {
|
List<RLHistoryItem> historyList;
|
||||||
|
|
||||||
private List<RLHistoryItem> historyItemList;
|
|
||||||
private LayoutInflater mInflator;
|
|
||||||
|
|
||||||
|
|
||||||
public RileyLinkHistoryListAdapter() {
|
RecyclerViewAdapter(List<RLHistoryItem> historyList) {
|
||||||
super();
|
this.historyList = historyList;
|
||||||
historyItemList = new ArrayList<>();
|
|
||||||
mInflator = RileyLinkStatusHistory.this.getLayoutInflater();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void addItem(RLHistoryItem item) {
|
public void setHistoryList(List<RLHistoryItem> historyList) {
|
||||||
if (!historyItemList.contains(item)) {
|
this.historyList = historyList;
|
||||||
historyItemList.add(item);
|
|
||||||
notifyDataSetChanged();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public RLHistoryItem getHistoryItem(int position) {
|
|
||||||
return historyItemList.get(position);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void addItemsAndClean(List<RLHistoryItem> items) {
|
public void addItemsAndClean(List<RLHistoryItem> items) {
|
||||||
this.historyItemList.clear();
|
this.historyList.clear();
|
||||||
|
|
||||||
for (RLHistoryItem item : items) {
|
for (RLHistoryItem item : items) {
|
||||||
|
|
||||||
if (!historyItemList.contains(item) && isValidItem(item)) {
|
if (!historyList.contains(item) && isValidItem(item)) {
|
||||||
historyItemList.add(item);
|
historyList.add(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -121,52 +125,156 @@ public class RileyLinkStatusHistory extends Fragment implements RefreshableInter
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void clear() {
|
@Override
|
||||||
historyItemList.clear();
|
public RecyclerViewAdapter.HistoryViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) {
|
||||||
notifyDataSetChanged();
|
View v = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.rileylink_status_history_item, //
|
||||||
|
viewGroup, false);
|
||||||
|
return new RecyclerViewAdapter.HistoryViewHolder(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getCount() {
|
public void onBindViewHolder(RecyclerViewAdapter.HistoryViewHolder holder, int position) {
|
||||||
return historyItemList.size();
|
RLHistoryItem item = historyList.get(position);
|
||||||
|
|
||||||
|
if (item != null) {
|
||||||
|
holder.timeView.setText(StringUtil.toDateTimeString(item.getDateTime()));
|
||||||
|
holder.typeView.setText(item.getSource().getDesc());
|
||||||
|
holder.valueView.setText(item.getDescription());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object getItem(int i) {
|
public int getItemCount() {
|
||||||
return historyItemList.get(i);
|
return historyList.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getItemId(int i) {
|
public void onAttachedToRecyclerView(RecyclerView recyclerView) {
|
||||||
return i;
|
super.onAttachedToRecyclerView(recyclerView);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static class HistoryViewHolder extends RecyclerView.ViewHolder {
|
||||||
|
|
||||||
@Override
|
TextView timeView;
|
||||||
public View getView(int i, View view, ViewGroup viewGroup) {
|
TextView typeView;
|
||||||
RileyLinkStatusHistory.ViewHolder viewHolder;
|
TextView valueView;
|
||||||
// General ListView optimization code.
|
|
||||||
if (view == null) {
|
|
||||||
view = mInflator.inflate(R.layout.rileylink_status_history_item, null);
|
HistoryViewHolder(View itemView) {
|
||||||
viewHolder = new RileyLinkStatusHistory.ViewHolder();
|
super(itemView);
|
||||||
viewHolder.itemTime = (TextView)view.findViewById(R.id.rileylink_history_time);
|
|
||||||
viewHolder.itemSource = (TextView)view.findViewById(R.id.rileylink_history_source);
|
timeView = (TextView)itemView.findViewById(R.id.rileylink_history_time);
|
||||||
viewHolder.itemDescription = (TextView)view.findViewById(R.id.rileylink_history_description);
|
typeView = (TextView)itemView.findViewById(R.id.rileylink_history_source);
|
||||||
view.setTag(viewHolder);
|
valueView = (TextView)itemView.findViewById(R.id.rileylink_history_description);
|
||||||
} else {
|
|
||||||
viewHolder = (RileyLinkStatusHistory.ViewHolder)view.getTag();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
RLHistoryItem item = historyItemList.get(i);
|
|
||||||
viewHolder.itemTime.setText(StringUtil.toDateTimeString(item.getDateTime()));
|
|
||||||
viewHolder.itemSource.setText(item.getSource().getDesc()); // for now
|
|
||||||
viewHolder.itemDescription.setText(item.getDescription());
|
|
||||||
|
|
||||||
return view;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// private class RileyLinkHistoryListAdapter extends BaseAdapter {
|
||||||
|
//
|
||||||
|
// private List<RLHistoryItem> historyItemList;
|
||||||
|
// private LayoutInflater mInflator;
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// public RileyLinkHistoryListAdapter() {
|
||||||
|
// super();
|
||||||
|
// historyItemList = new ArrayList<>();
|
||||||
|
// mInflator = RileyLinkStatusHistory.this.getLayoutInflater();
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// public void addItem(RLHistoryItem item) {
|
||||||
|
// if (!historyItemList.contains(item)) {
|
||||||
|
// historyItemList.add(item);
|
||||||
|
// notifyDataSetChanged();
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// public RLHistoryItem getHistoryItem(int position) {
|
||||||
|
// return historyItemList.get(position);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// public void addItemsAndClean(List<RLHistoryItem> items) {
|
||||||
|
// this.historyItemList.clear();
|
||||||
|
//
|
||||||
|
// for (RLHistoryItem item : items) {
|
||||||
|
//
|
||||||
|
// if (!historyItemList.contains(item) && isValidItem(item)) {
|
||||||
|
// historyItemList.add(item);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// notifyDataSetChanged();
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// private boolean isValidItem(RLHistoryItem item) {
|
||||||
|
//
|
||||||
|
// PumpDeviceState pumpState = item.getPumpDeviceState();
|
||||||
|
//
|
||||||
|
// if ((pumpState != null) && //
|
||||||
|
// (pumpState == PumpDeviceState.Sleeping || //
|
||||||
|
// pumpState == PumpDeviceState.Active || //
|
||||||
|
// pumpState == PumpDeviceState.WakingUp //
|
||||||
|
// ))
|
||||||
|
// return false;
|
||||||
|
//
|
||||||
|
// return true;
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// public void clear() {
|
||||||
|
// historyItemList.clear();
|
||||||
|
// notifyDataSetChanged();
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// @Override
|
||||||
|
// public int getCount() {
|
||||||
|
// return historyItemList.size();
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// @Override
|
||||||
|
// public Object getItem(int i) {
|
||||||
|
// return historyItemList.get(i);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// @Override
|
||||||
|
// public long getItemId(int i) {
|
||||||
|
// return i;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// @Override
|
||||||
|
// public View getView(int i, View view, ViewGroup viewGroup) {
|
||||||
|
// RileyLinkStatusHistory.ViewHolder viewHolder;
|
||||||
|
// // General ListView optimization code.
|
||||||
|
// if (view == null) {
|
||||||
|
// view = mInflator.inflate(R.layout.rileylink_status_history_item, null);
|
||||||
|
// viewHolder = new RileyLinkStatusHistory.ViewHolder();
|
||||||
|
// viewHolder.itemTime = (TextView)view.findViewById(R.id.rileylink_history_time);
|
||||||
|
// viewHolder.itemSource = (TextView)view.findViewById(R.id.rileylink_history_source);
|
||||||
|
// viewHolder.itemDescription = (TextView)view.findViewById(R.id.rileylink_history_description);
|
||||||
|
// view.setTag(viewHolder);
|
||||||
|
// } else {
|
||||||
|
// viewHolder = (RileyLinkStatusHistory.ViewHolder)view.getTag();
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// RLHistoryItem item = historyItemList.get(i);
|
||||||
|
// viewHolder.itemTime.setText(StringUtil.toDateTimeString(item.getDateTime()));
|
||||||
|
// viewHolder.itemSource.setText(item.getSource().getDesc()); // for now
|
||||||
|
// viewHolder.itemDescription.setText(item.getDescription());
|
||||||
|
//
|
||||||
|
// return view;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1092,11 +1092,17 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
|
||||||
// targetDate = lastPumpHistoryEntry.atechDateTime;
|
// targetDate = lastPumpHistoryEntry.atechDateTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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");
|
||||||
|
|
||||||
PumpHistoryResult historyResult = (PumpHistoryResult)responseTask2.returnData;
|
PumpHistoryResult historyResult = (PumpHistoryResult)responseTask2.returnData;
|
||||||
|
|
||||||
|
LOG.debug("HST: History Result: {}", historyResult.toString());
|
||||||
|
|
||||||
PumpHistoryEntry latestEntry = historyResult.getLatestEntry();
|
PumpHistoryEntry latestEntry = historyResult.getLatestEntry();
|
||||||
|
|
||||||
if (isLoggingEnabled())
|
if (isLoggingEnabled())
|
||||||
|
@ -1108,6 +1114,9 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
|
||||||
this.lastPumpHistoryEntry = latestEntry;
|
this.lastPumpHistoryEntry = latestEntry;
|
||||||
SP.putLong(MedtronicConst.Statistics.LastPumpHistoryEntry, latestEntry.atechDateTime);
|
SP.putLong(MedtronicConst.Statistics.LastPumpHistoryEntry, latestEntry.atechDateTime);
|
||||||
|
|
||||||
|
LOG.debug("HST: History: valid={}, unprocessed={}", historyResult.validEntries.size(),
|
||||||
|
historyResult.unprocessedEntries.size());
|
||||||
|
|
||||||
this.medtronicHistoryData.addNewHistory(historyResult);
|
this.medtronicHistoryData.addNewHistory(historyResult);
|
||||||
this.medtronicHistoryData.filterNewEntries();
|
this.medtronicHistoryData.filterNewEntries();
|
||||||
|
|
||||||
|
|
|
@ -97,7 +97,7 @@ public abstract class MedtronicHistoryEntry implements MedtronicHistoryEntryInte
|
||||||
|
|
||||||
|
|
||||||
public String getDateTimeString() {
|
public String getDateTimeString() {
|
||||||
return this.DT;
|
return this.DT == null ? "Unknown" : this.DT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@ package info.nightscout.androidaps.plugins.PumpMedtronic.comm.history.pump;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.joda.time.LocalDateTime;
|
import org.joda.time.LocalDateTime;
|
||||||
|
@ -489,16 +490,25 @@ public class MedtronicPumpHistoryDecoder extends MedtronicHistoryDecoder {
|
||||||
|
|
||||||
System.out.println("" + totals.toString());
|
System.out.println("" + totals.toString());
|
||||||
|
|
||||||
|
// FIXME displayable
|
||||||
|
|
||||||
return RecordDecodeStatus.WIP;
|
return RecordDecodeStatus.WIP;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private RecordDecodeStatus decodeBasalProfile(PumpHistoryEntry entry) {
|
private RecordDecodeStatus decodeBasalProfile(PumpHistoryEntry entry) {
|
||||||
|
|
||||||
BasalProfile basalProfile = new BasalProfile(entry.getBody());
|
// LOG.debug("decodeBasalProfile: {}", entry);
|
||||||
|
|
||||||
|
BasalProfile basalProfile = new BasalProfile();
|
||||||
|
basalProfile.setRawDataFromHistory(entry.getBody());
|
||||||
|
|
||||||
|
// LOG.debug("decodeBasalProfile BasalProfile: {}", basalProfile);
|
||||||
|
|
||||||
entry.addDecodedData("Object", basalProfile);
|
entry.addDecodedData("Object", basalProfile);
|
||||||
|
|
||||||
|
// FIXME displayable ??
|
||||||
|
|
||||||
return RecordDecodeStatus.OK;
|
return RecordDecodeStatus.OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -526,14 +536,17 @@ public class MedtronicPumpHistoryDecoder extends MedtronicHistoryDecoder {
|
||||||
|
|
||||||
// writeData(PumpBaseType.Event, PumpEventType.DateTimeChanged, timeChange, entry.getATechDate());
|
// writeData(PumpBaseType.Event, PumpEventType.DateTimeChanged, timeChange, entry.getATechDate());
|
||||||
|
|
||||||
|
entry.setDisplayableValue(entry.getDateTimeString());
|
||||||
|
|
||||||
this.changeTimeRecord = null;
|
this.changeTimeRecord = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// FIXME
|
|
||||||
private void decodeBatteryActivity(PumpHistoryEntry entry) {
|
private void decodeBatteryActivity(PumpHistoryEntry entry) {
|
||||||
// this.writeData(PumpBaseType.Event, entry.getHead()[0] == 0 ? PumpEventType.BatteryRemoved :
|
// this.writeData(PumpBaseType.Event, entry.getHead()[0] == 0 ? PumpEventType.BatteryRemoved :
|
||||||
// PumpEventType.BatteryReplaced, entry.getATechDate());
|
// PumpEventType.BatteryReplaced, entry.getATechDate());
|
||||||
|
|
||||||
|
entry.setDisplayableValue(entry.getHead()[0] == 0 ? "Battery Removed" : "Battery Replaced");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -543,12 +556,18 @@ public class MedtronicPumpHistoryDecoder extends MedtronicHistoryDecoder {
|
||||||
(int)entry.getHead()[3], ByteUtil.BitConversion.BIG_ENDIAN) * 0.025f;
|
(int)entry.getHead()[3], ByteUtil.BitConversion.BIG_ENDIAN) * 0.025f;
|
||||||
|
|
||||||
entry.addDecodedData("Totals", totals);
|
entry.addDecodedData("Totals", totals);
|
||||||
|
entry.setDisplayableValue(getFormattedValue(totals, 3));
|
||||||
|
|
||||||
// this.writeData(PumpBaseType.Report, PumpReport.InsulinTotalDay, getFormattedFloat(totals, 2),
|
// this.writeData(PumpBaseType.Report, PumpReport.InsulinTotalDay, getFormattedFloat(totals, 2),
|
||||||
// entry.getATechDate());
|
// entry.getATechDate());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private String getFormattedValue(float value, int decimals) {
|
||||||
|
return String.format(Locale.ENGLISH, "%." + decimals + "f", value);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// FIXME
|
// FIXME
|
||||||
private RecordDecodeStatus decodeBasalProfileStart(PumpHistoryEntry entry) {
|
private RecordDecodeStatus decodeBasalProfileStart(PumpHistoryEntry entry) {
|
||||||
byte[] body = entry.getBody();
|
byte[] body = entry.getBody();
|
||||||
|
@ -570,6 +589,7 @@ public class MedtronicPumpHistoryDecoder extends MedtronicHistoryDecoder {
|
||||||
// writeData(PumpBaseType.Basal, PumpBasalType.ValueChange, getFormattedFloat(rate, 3),
|
// writeData(PumpBaseType.Basal, PumpBasalType.ValueChange, getFormattedFloat(rate, 3),
|
||||||
// entry.getATechDate());
|
// entry.getATechDate());
|
||||||
entry.addDecodedData("Value", getFormattedFloat(rate, 3));
|
entry.addDecodedData("Value", getFormattedFloat(rate, 3));
|
||||||
|
entry.setDisplayableValue(getFormattedFloat(rate, 3));
|
||||||
return RecordDecodeStatus.OK;
|
return RecordDecodeStatus.OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -617,7 +637,7 @@ public class MedtronicPumpHistoryDecoder extends MedtronicHistoryDecoder {
|
||||||
|
|
||||||
dto.atechDateTime = entry.atechDateTime;
|
dto.atechDateTime = entry.atechDateTime;
|
||||||
entry.addDecodedData("Object", dto);
|
entry.addDecodedData("Object", dto);
|
||||||
// entry.setHistoryEntryDetails(dto);
|
entry.setDisplayableValue(dto.toString());
|
||||||
|
|
||||||
// this.writeData(PumpBaseType.Event, PumpEventType.BolusWizard, dto.getValue(), entry.getATechDate());
|
// this.writeData(PumpBaseType.Event, PumpEventType.BolusWizard, dto.getValue(), entry.getATechDate());
|
||||||
|
|
||||||
|
@ -626,9 +646,15 @@ public class MedtronicPumpHistoryDecoder extends MedtronicHistoryDecoder {
|
||||||
|
|
||||||
// FIXME
|
// FIXME
|
||||||
private void decodeLowReservoir(PumpHistoryEntry entry) {
|
private void decodeLowReservoir(PumpHistoryEntry entry) {
|
||||||
float amount = (getUnsignedInt(entry.getHead()[0]) * 1.0f / 10.0f);
|
float amount = (getUnsignedInt(entry.getHead()[0]) * 1.0f / 10.0f) * 2;
|
||||||
|
|
||||||
|
// LOG.debug("LowReservoir: rawData={}", entry.getRawData());
|
||||||
|
|
||||||
|
// LOG.debug("LowReservoir: {}, object={}", entry.getHead()[0], entry);
|
||||||
// this.writeData(PumpBaseType.Event, PumpEventType.ReservoirLowDesc, getFormattedFloat(amount, 1),
|
// this.writeData(PumpBaseType.Event, PumpEventType.ReservoirLowDesc, getFormattedFloat(amount, 1),
|
||||||
// entry.getATechDate());
|
// entry.getATechDate());
|
||||||
|
entry.setDisplayableValue(getFormattedValue(amount, 1));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -640,6 +666,9 @@ public class MedtronicPumpHistoryDecoder extends MedtronicHistoryDecoder {
|
||||||
entry.addDecodedData("Amount", amount);
|
entry.addDecodedData("Amount", amount);
|
||||||
entry.addDecodedData("FixedAmount", fixed);
|
entry.addDecodedData("FixedAmount", fixed);
|
||||||
|
|
||||||
|
entry.setDisplayableValue("Amount=" + getFormattedValue(amount, 2) + ", Fixed Amount="
|
||||||
|
+ getFormattedValue(fixed, 2));
|
||||||
|
|
||||||
// amount = (double) (asUINT8(data[4]) << 2) / 40.0;
|
// amount = (double) (asUINT8(data[4]) << 2) / 40.0;
|
||||||
// programmedAmount = (double) (asUINT8(data[2]) << 2) / 40.0;
|
// programmedAmount = (double) (asUINT8(data[2]) << 2) / 40.0;
|
||||||
// primeType = programmedAmount == 0 ? "manual" : "fixed";
|
// primeType = programmedAmount == 0 ? "manual" : "fixed";
|
||||||
|
@ -700,6 +729,7 @@ public class MedtronicPumpHistoryDecoder extends MedtronicHistoryDecoder {
|
||||||
}
|
}
|
||||||
|
|
||||||
entry.addDecodedData("Object", bolus);
|
entry.addDecodedData("Object", bolus);
|
||||||
|
entry.setDisplayableValue(bolus.getDisplayableValue());
|
||||||
|
|
||||||
bolusHistory.put(dateTime, bolus);
|
bolusHistory.put(dateTime, bolus);
|
||||||
|
|
||||||
|
@ -745,12 +775,13 @@ public class MedtronicPumpHistoryDecoder extends MedtronicHistoryDecoder {
|
||||||
// );
|
// );
|
||||||
|
|
||||||
entry.addDecodedData("Object", tbr);
|
entry.addDecodedData("Object", tbr);
|
||||||
|
entry.setDisplayableValue(tbr.getDescription());
|
||||||
|
|
||||||
entry.addDecodedData("Rate 1: ", tbrRate.getHead()[0] * 0.025);
|
// entry.addDecodedData("Rate 1: ", tbrRate.getHead()[0] * 0.025);
|
||||||
entry.addDecodedData("Rate 2: ", ByteUtil.asUINT8(tbrRate.getHead()[0]) * 0.025d);
|
// entry.addDecodedData("Rate 2: ", ByteUtil.asUINT8(tbrRate.getHead()[0]) * 0.025d);
|
||||||
entry.addDecodedData("Rate 1.b: ", tbrRate.getHead()[0]);
|
// entry.addDecodedData("Rate 1.b: ", tbrRate.getHead()[0]);
|
||||||
entry.addDecodedData("Rate 2.b: ", ByteUtil.asUINT8(tbrRate.getHead()[0]));
|
// entry.addDecodedData("Rate 2.b: ", ByteUtil.asUINT8(tbrRate.getHead()[0]));
|
||||||
entry.addDecodedData("Rate 3: ", (ByteUtil.asUINT8(tbrRate.getHead()[0])) / 40.0d);
|
// entry.addDecodedData("Rate 3: ", (ByteUtil.asUINT8(tbrRate.getHead()[0])) / 40.0d);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -131,19 +131,30 @@ public class PumpHistoryEntry extends MedtronicHistoryEntry {
|
||||||
// }
|
// }
|
||||||
|
|
||||||
public boolean isAfter(long atechDateTime) {
|
public boolean isAfter(long atechDateTime) {
|
||||||
return atechDateTime > this.atechDateTime;
|
return atechDateTime < this.atechDateTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Comparator implements java.util.Comparator<PumpHistoryEntry> {
|
|
||||||
|
|
||||||
@Override
|
public void setDisplayableValue(String displayableValue) {
|
||||||
public int compare(PumpHistoryEntry o1, PumpHistoryEntry o2) {
|
this.displayableValue = displayableValue;
|
||||||
return (int)(o2.atechDateTime - o1.atechDateTime);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public String getDisplayableValue() {
|
public String getDisplayableValue() {
|
||||||
return displayableValue;
|
return displayableValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static class Comparator implements java.util.Comparator<PumpHistoryEntry> {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int compare(PumpHistoryEntry o1, PumpHistoryEntry o2) {
|
||||||
|
int data = (int)(o2.atechDateTime - o1.atechDateTime);
|
||||||
|
|
||||||
|
if (data != 0)
|
||||||
|
return data;
|
||||||
|
|
||||||
|
return o2.getEntryType().getCode() - o1.getEntryType().getCode();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ package info.nightscout.androidaps.plugins.PumpMedtronic.comm.history.pump;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -26,12 +27,17 @@ public enum PumpHistoryEntryGroup {
|
||||||
private int resourceId;
|
private int resourceId;
|
||||||
private String translated;
|
private String translated;
|
||||||
|
|
||||||
|
public static boolean doNotTranslate = false;
|
||||||
|
|
||||||
private static List<PumpHistoryEntryGroup> list;
|
private static List<PumpHistoryEntryGroup> list;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
list = new ArrayList<>();
|
list = new ArrayList<>();
|
||||||
|
|
||||||
for (PumpHistoryEntryGroup pumpHistoryEntryGroup : values()) {
|
for (PumpHistoryEntryGroup pumpHistoryEntryGroup : values()) {
|
||||||
|
if (doNotTranslate) {
|
||||||
|
pumpHistoryEntryGroup.translated = MainApp.gs(pumpHistoryEntryGroup.resourceId);
|
||||||
|
}
|
||||||
list.add(pumpHistoryEntryGroup);
|
list.add(pumpHistoryEntryGroup);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -53,6 +59,11 @@ public enum PumpHistoryEntryGroup {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public String getTranslated() {
|
||||||
|
return translated;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return this.translated;
|
return this.translated;
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,13 +42,14 @@ public enum PumpHistoryEntryType // implements CodeEnum
|
||||||
|
|
||||||
Prime(0x03, "Prime", PumpHistoryEntryGroup.Prime, 5, 5, 0), //
|
Prime(0x03, "Prime", PumpHistoryEntryGroup.Prime, 5, 5, 0), //
|
||||||
|
|
||||||
/**/EventUnknown_MM522_0x05((byte)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, "ResultTotals", PumpHistoryEntryGroup.Statistic, 5, 2, 0), // V1: 5/5/41 V2: 5,2,3 V3, 5,2,0
|
EndResultTotals(0x07, "End Result Totals", PumpHistoryEntryGroup.Statistic, 5, 2, 0), // V1: 5/5/41 V2: 5,2,3 V3,
|
||||||
// V5: 7/10(523)
|
// 5,2,0
|
||||||
ChangeBasalProfile_OldProfile(0x08, PumpHistoryEntryGroup.Basal, 2, 5, 145), // // V1: 2,5,42 V2:2,5,145; V4: V5
|
// V1: 2,5,42; V2:2,5,145; V5: 7/10(523)
|
||||||
ChangeBasalProfile_NewProfile(0x09, PumpHistoryEntryGroup.Basal, 2, 5, 145), //
|
ChangeBasalProfile_OldProfile(0x08, "Change Basal Profile (Old)", PumpHistoryEntryGroup.Basal, 2, 5, 145),
|
||||||
/**/EventUnknown_MM512_0x10(0x10, PumpHistoryEntryGroup.Unknown), // 29, 5, 0
|
ChangeBasalProfile_NewProfile(0x09, "Change Basal Profile (New)", PumpHistoryEntryGroup.Basal, 2, 5, 145), //
|
||||||
|
/**/EventUnknown_MM512_0x10(0x10, "Unknown Event 0x10", PumpHistoryEntryGroup.Unknown), // 29, 5, 0
|
||||||
CalBGForPH(0x0a, "BG Capture", PumpHistoryEntryGroup.Glucose), //
|
CalBGForPH(0x0a, "BG Capture", PumpHistoryEntryGroup.Glucose), //
|
||||||
SensorAlert(0x0b, "Sensor Alert", PumpHistoryEntryGroup.Alarm, 3, 5, 0), // Ian08
|
SensorAlert(0x0b, "Sensor Alert", PumpHistoryEntryGroup.Alarm, 3, 5, 0), // Ian08
|
||||||
ClearAlarm(0x0c, "Clear Alarm", PumpHistoryEntryGroup.Alarm, 2, 5, 0), // 2,5,4
|
ClearAlarm(0x0c, "Clear Alarm", PumpHistoryEntryGroup.Alarm, 2, 5, 0), // 2,5,4
|
||||||
|
@ -56,7 +57,7 @@ public enum PumpHistoryEntryType // implements CodeEnum
|
||||||
// Andy0d(0x0d, "Unknown", 2, 5, 0),
|
// Andy0d(0x0d, "Unknown", 2, 5, 0),
|
||||||
|
|
||||||
ChangeBasalPattern(0x14, "Change Basal Pattern", PumpHistoryEntryGroup.Basal), //
|
ChangeBasalPattern(0x14, "Change Basal Pattern", PumpHistoryEntryGroup.Basal), //
|
||||||
TempBasalDuration(0x16, "TempBasalDuration", PumpHistoryEntryGroup.Basal), //
|
TempBasalDuration(0x16, "TBR Duration", PumpHistoryEntryGroup.Basal), //
|
||||||
ChangeTime(0x17, "Change Time", PumpHistoryEntryGroup.Configuration), //
|
ChangeTime(0x17, "Change Time", PumpHistoryEntryGroup.Configuration), //
|
||||||
NewTimeSet(0x18, "New Time Set", PumpHistoryEntryGroup.Notification), //
|
NewTimeSet(0x18, "New Time Set", PumpHistoryEntryGroup.Notification), //
|
||||||
LowBattery(0x19, "LowBattery", PumpHistoryEntryGroup.Notification), //
|
LowBattery(0x19, "LowBattery", PumpHistoryEntryGroup.Notification), //
|
||||||
|
@ -69,96 +70,99 @@ public enum PumpHistoryEntryType // implements CodeEnum
|
||||||
Rewind(0x21, "Rewind", PumpHistoryEntryGroup.Prime), //
|
Rewind(0x21, "Rewind", PumpHistoryEntryGroup.Prime), //
|
||||||
ClearSettings(0x22, "Clear Settings", PumpHistoryEntryGroup.Configuration), // 8?
|
ClearSettings(0x22, "Clear Settings", PumpHistoryEntryGroup.Configuration), // 8?
|
||||||
ChangeChildBlockEnable(0x23, "Change Child Block Enable", PumpHistoryEntryGroup.Configuration), // 8?
|
ChangeChildBlockEnable(0x23, "Change Child Block Enable", PumpHistoryEntryGroup.Configuration), // 8?
|
||||||
ChangeMaxBolus(0x24, PumpHistoryEntryGroup.Configuration), // 8?
|
ChangeMaxBolus(0x24, "Change Max Bolus", PumpHistoryEntryGroup.Configuration), // 8?
|
||||||
/**/EventUnknown_MM522_0x25(0x25, PumpHistoryEntryGroup.Unknown), // 8?
|
/**/EventUnknown_MM522_0x25(0x25, "Unknown Event 0x25", PumpHistoryEntryGroup.Unknown), // 8?
|
||||||
ToggleRemote(0x26, "EnableDisableRemote", PumpHistoryEntryGroup.Configuration, 2, 5, 14), // 2, 5, 14 V6:2,5,14
|
ToggleRemote(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, PumpHistoryEntryGroup.Configuration), //
|
ChangeMaxBasal(0x2c, "Change Max Basal", PumpHistoryEntryGroup.Configuration), //
|
||||||
BolusWizardEnabled(0x2d, PumpHistoryEntryGroup.Configuration), // V3 ?
|
BolusWizardEnabled(0x2d, "Bolus Wizard Enabled", PumpHistoryEntryGroup.Configuration), // V3 ?
|
||||||
/**/EventUnknown_MM512_0x2e(0x2e, PumpHistoryEntryGroup.Unknown), //
|
/**/EventUnknown_MM512_0x2e(0x2e, "Unknown Event 0x2e", PumpHistoryEntryGroup.Unknown), //
|
||||||
/**/BolusWizard512(0x2f, PumpHistoryEntryGroup.Configuration), //
|
/**/BolusWizard512(0x2f, "Bolus Wizard (512)", PumpHistoryEntryGroup.Configuration), //
|
||||||
UnabsorbedInsulin512(0x30, PumpHistoryEntryGroup.Statistic), //
|
UnabsorbedInsulin512(0x30, "Unabsorbed Insulin (512)", PumpHistoryEntryGroup.Statistic), //
|
||||||
ChangeBGReminderOffset(0x31, PumpHistoryEntryGroup.Configuration), //
|
ChangeBGReminderOffset(0x31, "Change BG Reminder Offset", PumpHistoryEntryGroup.Configuration), //
|
||||||
ChangeAlarmClockTime(0x32, PumpHistoryEntryGroup.Configuration), //
|
ChangeAlarmClockTime(0x32, "Change Alarm Clock Time", PumpHistoryEntryGroup.Configuration), //
|
||||||
TempBasalRate(0x33, "Temp Basal Rate", PumpHistoryEntryGroup.Basal, 2, 5, 1), //
|
TempBasalRate(0x33, "TBR Rate", PumpHistoryEntryGroup.Basal, 2, 5, 1), //
|
||||||
LowReservoir(0x34, PumpHistoryEntryGroup.Notification), //
|
LowReservoir(0x34, "Low Reservoir", PumpHistoryEntryGroup.Notification), //
|
||||||
ChangeAlarmClock(0x35, "Change Alarm Clock", PumpHistoryEntryGroup.Configuration), //
|
ChangeAlarmClock(0x35, "Change Alarm Clock", PumpHistoryEntryGroup.Configuration), //
|
||||||
ChangeMeterId(0x36, PumpHistoryEntryGroup.Configuration), //
|
ChangeMeterId(0x36, "Change Meter ID", PumpHistoryEntryGroup.Configuration), //
|
||||||
/**/EventUnknown_MM512_0x37(0x37, PumpHistoryEntryGroup.Unknown), // V:MM512
|
/**/EventUnknown_MM512_0x37(0x37, "Unknown Event 0x37", PumpHistoryEntryGroup.Unknown), // V:MM512
|
||||||
/**/EventUnknown_MM512_0x38(0x38, PumpHistoryEntryGroup.Unknown), //
|
/**/EventUnknown_MM512_0x38(0x38, "Unknown Event 0x38", PumpHistoryEntryGroup.Unknown), //
|
||||||
BGReceived512(0x39, PumpHistoryEntryGroup.Glucose), //
|
BGReceived512(0x39, "BG Received (512)", PumpHistoryEntryGroup.Glucose), //
|
||||||
SensorStatus(0x3b, PumpHistoryEntryGroup.Glucose), //
|
SensorStatus(0x3b, "Sensor Status", PumpHistoryEntryGroup.Glucose), //
|
||||||
ChangeParadigmID(0x3c, 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
|
||||||
|
|
||||||
BGReceived(0x3f, "BG Received", PumpHistoryEntryGroup.Glucose, 2, 5, 3), // Ian3F
|
BGReceived(0x3f, "BG Received", PumpHistoryEntryGroup.Glucose, 2, 5, 3), // Ian3F
|
||||||
JournalEntryMealMarker(0x40, PumpHistoryEntryGroup.Bolus, 2, 5, 2), //
|
JournalEntryMealMarker(0x40, "Meal Marker", PumpHistoryEntryGroup.Bolus, 2, 5, 2), //
|
||||||
JournalEntryExerciseMarker(0x41, PumpHistoryEntryGroup.Bolus, 2, 5, 1), // ?? JournalEntryExerciseMarkerPumpEvent
|
JournalEntryExerciseMarker(0x41, "Exercise Marker", PumpHistoryEntryGroup.Bolus, 2, 5, 1), // ??
|
||||||
JournalEntryInsulinMarker(0x42, PumpHistoryEntryGroup.Bolus, 2, 5, 1), // ?? InsulinMarkerEvent
|
// JournalEntryExerciseMarkerPumpEvent
|
||||||
JournalEntryOtherMarker(0x43, PumpHistoryEntryGroup.Bolus), //
|
JournalEntryInsulinMarker(0x42, "Insulin Marker", PumpHistoryEntryGroup.Bolus, 2, 5, 1), // ?? InsulinMarkerEvent
|
||||||
EnableSensorAutoCal(0x44, PumpHistoryEntryGroup.Glucose), //
|
JournalEntryOtherMarker(0x43, "Other Marker", PumpHistoryEntryGroup.Bolus), //
|
||||||
/**/EventUnknown_MM522_0x45(0x45, PumpHistoryEntryGroup.Unknown, 2, 5, 1), //
|
EnableSensorAutoCal(0x44, "Enable Sensor AutoCal", PumpHistoryEntryGroup.Glucose), //
|
||||||
/**/EventUnknown_MM522_0x46(0x46, PumpHistoryEntryGroup.Unknown, 2, 5, 1), //
|
/**/EventUnknown_MM522_0x45(0x45, "Unknown Event 0x45", PumpHistoryEntryGroup.Unknown, 2, 5, 1), //
|
||||||
/**/EventUnknown_MM522_0x47(0x47, PumpHistoryEntryGroup.Unknown, 2, 5, 1), //
|
/**/EventUnknown_MM522_0x46(0x46, "Unknown Event 0x46", PumpHistoryEntryGroup.Unknown, 2, 5, 1), //
|
||||||
/**/EventUnknown_MM522_0x48(0x48, PumpHistoryEntryGroup.Unknown, 2, 5, 1), //
|
/**/EventUnknown_MM522_0x47(0x47, "Unknown Event 0x47", PumpHistoryEntryGroup.Unknown, 2, 5, 1), //
|
||||||
/**/EventUnknown_MM522_0x49(0x49, PumpHistoryEntryGroup.Unknown, 2, 5, 1), //
|
/**/EventUnknown_MM522_0x48(0x48, "Unknown Event 0x48", PumpHistoryEntryGroup.Unknown, 2, 5, 1), //
|
||||||
/**/EventUnknown_MM522_0x4a(0x4a, PumpHistoryEntryGroup.Unknown, 2, 5, 1), //
|
/**/EventUnknown_MM522_0x49(0x49, "Unknown Event 0x49", PumpHistoryEntryGroup.Unknown, 2, 5, 1), //
|
||||||
/**/EventUnknown_MM522_0x4b(0x4b, PumpHistoryEntryGroup.Unknown, 2, 5, 1), //
|
/**/EventUnknown_MM522_0x4a(0x4a, "Unknown Event 0x4a", PumpHistoryEntryGroup.Unknown, 2, 5, 1), //
|
||||||
/**/EventUnknown_MM522_0x4c(0x4c, PumpHistoryEntryGroup.Unknown, 2, 5, 1), //
|
/**/EventUnknown_MM522_0x4b(0x4b, "Unknown Event 0x4b", PumpHistoryEntryGroup.Unknown, 2, 5, 1), //
|
||||||
/**/EventUnknown_0x4d(0x4d, PumpHistoryEntryGroup.Unknown), // V5: 512: 7, 522: 8 ????NS
|
/**/EventUnknown_MM522_0x4c(0x4c, "Unknown Event 0x4c", PumpHistoryEntryGroup.Unknown, 2, 5, 1), //
|
||||||
/**/EventUnknown_MM512_0x4e(0x4e, PumpHistoryEntryGroup.Unknown), // /**/
|
/**/EventUnknown_0x4d(0x4d, "Unknown Event 0x4d", PumpHistoryEntryGroup.Unknown), // V5: 512: 7, 522: 8 ????NS
|
||||||
ChangeBolusWizardSetup(0x4f, PumpHistoryEntryGroup.Configuration, 2, 5, 32), //
|
/**/EventUnknown_MM512_0x4e(0x4e, "Unknown Event 0x4e", PumpHistoryEntryGroup.Unknown), // /**/
|
||||||
ChangeSensorSetup2(0x50, PumpHistoryEntryGroup.Configuration, 2, 5, 30), // Ian50
|
ChangeBolusWizardSetup(0x4f, "Bolus Wizard Setup", PumpHistoryEntryGroup.Configuration, 2, 5, 32), //
|
||||||
/**/Sensor51(0x51, PumpHistoryEntryGroup.Unknown), //
|
ChangeSensorSetup2(0x50, "Sensor Setup2", PumpHistoryEntryGroup.Configuration, 2, 5, 30), // Ian50
|
||||||
/**/Sensor52(0x52, PumpHistoryEntryGroup.Unknown), //
|
/**/Sensor51(0x51, "Unknown Event 0x51", PumpHistoryEntryGroup.Unknown), //
|
||||||
ChangeSensorAlarmSilenceConfig(0x53, PumpHistoryEntryGroup.Configuration, 2, 5, 1), // 8 -
|
/**/Sensor52(0x52, "Unknown Event 0x52", PumpHistoryEntryGroup.Unknown), //
|
||||||
|
ChangeSensorAlarmSilenceConfig(0x53, "Sensor Alarm Silence Config", PumpHistoryEntryGroup.Configuration, 2, 5, 1), // 8
|
||||||
|
// -
|
||||||
// ChangeSensorAlarmSilenceConfig
|
// ChangeSensorAlarmSilenceConfig
|
||||||
/**/Sensor54(0x54, PumpHistoryEntryGroup.Unknown), // Ian54
|
/**/Sensor54(0x54, "Unknown Event 0x54", PumpHistoryEntryGroup.Unknown), // Ian54
|
||||||
/**/Sensor55(0x55, PumpHistoryEntryGroup.Unknown), //
|
/**/Sensor55(0x55, "Unknown Event 0x55", PumpHistoryEntryGroup.Unknown), //
|
||||||
ChangeSensorRateOfChangeAlertSetup(0x56, PumpHistoryEntryGroup.Configuration, 2, 5, 5), // 12
|
ChangeSensorRateOfChangeAlertSetup(0x56, "Sensor Rate Of Change Alert Setup", PumpHistoryEntryGroup.Configuration, 2, 5, 5), // 12
|
||||||
// ChangeSensorRateOfChangeAlertSetup
|
// ChangeSensorRateOfChangeAlertSetup
|
||||||
ChangeBolusScrollStepSize(0x57, 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, "BolusWizard", PumpHistoryEntryGroup.Configuration, 2, 5, 117), // V2: 522+[B=143]
|
BolusWizardChange(0x5a, "Bolus Wizard Change", PumpHistoryEntryGroup.Configuration, 2, 5, 117), // V2: 522+[B=143]
|
||||||
BolusWizardBolusEstimate(0x5b, "BolusWizardBolusEstimate", PumpHistoryEntryGroup.Configuration, 2, 5, 13), // 15 //
|
BolusWizardBolusEstimate(0x5b, "Bolus Wizard Estimate", PumpHistoryEntryGroup.Configuration, 2, 5, 13), // 15 //
|
||||||
UnabsorbedInsulin(0x5c, "UnabsorbedInsulinBolus", PumpHistoryEntryGroup.Statistic, 5, 0, 0), // head[1] -> body
|
UnabsorbedInsulin(0x5c, "Unabsorbed Insulin", PumpHistoryEntryGroup.Statistic, 5, 0, 0), // head[1] -> body
|
||||||
// length
|
// length
|
||||||
SaveSettings(0x5d, PumpHistoryEntryGroup.Configuration), //
|
SaveSettings(0x5d, "Save Settings", PumpHistoryEntryGroup.Configuration), //
|
||||||
ChangeVariableBolus(0x5e, 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, PumpHistoryEntryGroup.Configuration), // questionable60
|
ChangeBGReminderEnable(0x60, "BG Reminder Enable", PumpHistoryEntryGroup.Configuration), // questionable60
|
||||||
ChangeAlarmClockEnable(0x61, PumpHistoryEntryGroup.Configuration), //
|
ChangeAlarmClockEnable(0x61, "Alarm Clock Enable", PumpHistoryEntryGroup.Configuration), //
|
||||||
ChangeTempBasalType((byte)0x62, PumpHistoryEntryGroup.Configuration), // ChangeTempBasalTypePumpEvent
|
ChangeTempBasalType((byte)0x62, "Change Basal Type", PumpHistoryEntryGroup.Configuration), // ChangeTempBasalTypePumpEvent
|
||||||
ChangeAlarmNotifyMode(0x63, PumpHistoryEntryGroup.Configuration), //
|
ChangeAlarmNotifyMode(0x63, "Change Alarm Notify Mode", PumpHistoryEntryGroup.Configuration), //
|
||||||
ChangeTimeFormat(0x64, PumpHistoryEntryGroup.Configuration), //
|
ChangeTimeFormat(0x64, "Change Time Format", PumpHistoryEntryGroup.Configuration), //
|
||||||
ChangeReservoirWarningTime((byte)0x65, PumpHistoryEntryGroup.Configuration), //
|
ChangeReservoirWarningTime((byte)0x65, "Change Reservoir Warning Time", PumpHistoryEntryGroup.Configuration), //
|
||||||
ChangeBolusReminderEnable(0x66, PumpHistoryEntryGroup.Configuration, 2, 5, 2), // 9
|
ChangeBolusReminderEnable(0x66, "Change Bolus Reminder Enable", PumpHistoryEntryGroup.Configuration, 2, 5, 2), // 9
|
||||||
ChangeBolusReminderTime((byte)0x67, PumpHistoryEntryGroup.Configuration, 2, 5, 2), // 9
|
ChangeBolusReminderTime((byte)0x67, "Change Bolus Reminder Time", PumpHistoryEntryGroup.Configuration, 2, 5, 2), // 9
|
||||||
DeleteBolusReminderTime((byte)0x68, PumpHistoryEntryGroup.Configuration, 2, 5, 2), // 9
|
DeleteBolusReminderTime((byte)0x68, "Delete Bolus Reminder Time", PumpHistoryEntryGroup.Configuration, 2, 5, 2), // 9
|
||||||
BolusReminder(0x69, 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, 0, 0, 36), //
|
DailyTotals515(0x6c, "Daily Totals (515)", PumpHistoryEntryGroup.Statistic, 0, 0, 36), //
|
||||||
DailyTotals522(0x6d, "Daily Totals 522", PumpHistoryEntryGroup.Statistic, 1, 2, 41), // // hack1(0x6d, "hack1", 46,
|
DailyTotals522(0x6d, "Daily Totals (522)", PumpHistoryEntryGroup.Statistic, 1, 2, 41), // // hack1(0x6d, "hack1",
|
||||||
|
// 46,
|
||||||
// 5, 0), // 1,2,41
|
// 5, 0), // 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, PumpHistoryEntryGroup.Configuration), //
|
ChangeCarbUnits((byte)0x6f, "Change Carb Units", PumpHistoryEntryGroup.Configuration), //
|
||||||
/**/EventUnknown_MM522_0x70((byte)0x70, PumpHistoryEntryGroup.Unknown, 2, 5, 1), //
|
/**/EventUnknown_MM522_0x70((byte)0x70, "Unknown Event 0x70", PumpHistoryEntryGroup.Unknown, 2, 5, 1), //
|
||||||
|
|
||||||
BasalProfileStart(0x7b, PumpHistoryEntryGroup.Basal, 2, 5, 3), // // 722
|
BasalProfileStart(0x7b, "Basal Profile Start", PumpHistoryEntryGroup.Basal, 2, 5, 3), // // 722
|
||||||
ChangeWatchdogEnable((byte)0x7c, PumpHistoryEntryGroup.Configuration), //
|
ChangeWatchdogEnable((byte)0x7c, "Change Watchdog Enable", PumpHistoryEntryGroup.Configuration), //
|
||||||
ChangeOtherDeviceID((byte)0x7d, PumpHistoryEntryGroup.Configuration, 2, 5, 30), //
|
ChangeOtherDeviceID((byte)0x7d, "Change Other Device ID", PumpHistoryEntryGroup.Configuration, 2, 5, 30), //
|
||||||
|
|
||||||
ChangeWatchdogMarriageProfile(0x81, PumpHistoryEntryGroup.Configuration, 2, 5, 5), // 12
|
ChangeWatchdogMarriageProfile(0x81, "Change Watchdog Marriage Profile", PumpHistoryEntryGroup.Configuration, 2, 5, 5), // 12
|
||||||
DeleteOtherDeviceID(0x82, PumpHistoryEntryGroup.Configuration, 2, 5, 5), //
|
DeleteOtherDeviceID(0x82, "Delete Other Device ID", PumpHistoryEntryGroup.Configuration, 2, 5, 5), //
|
||||||
ChangeCaptureEventEnable(0x83, PumpHistoryEntryGroup.Configuration), //
|
ChangeCaptureEventEnable(0x83, "Change Capture Event Enable", PumpHistoryEntryGroup.Configuration), //
|
||||||
|
|
||||||
/**/EventUnknown_MM512_0x88(0x88, PumpHistoryEntryGroup.Unknown), //
|
/**/EventUnknown_MM512_0x88(0x88, "Unknown Event 0x88", PumpHistoryEntryGroup.Unknown), //
|
||||||
|
|
||||||
/**/EventUnknown_MM512_0x94(0x94, PumpHistoryEntryGroup.Unknown), //
|
/**/EventUnknown_MM512_0x94(0x94, "Unknown Event 0x94", PumpHistoryEntryGroup.Unknown), //
|
||||||
// IanA8(0xA8, "xx", 10, 5, 0), //
|
// IanA8(0xA8, "xx", 10, 5, 0), //
|
||||||
|
|
||||||
// Andy90(0x90, "Unknown", 7, 5, 0),
|
// Andy90(0x90, "Unknown", 7, 5, 0),
|
||||||
|
@ -169,14 +173,14 @@ public enum PumpHistoryEntryType // implements CodeEnum
|
||||||
// head[1],
|
// head[1],
|
||||||
// body[49] op[0x6e]
|
// body[49] op[0x6e]
|
||||||
|
|
||||||
/**/EventUnknown_MM522_0xE8(0xe8, PumpHistoryEntryGroup.Unknown, 2, 5, 25), //
|
/**/EventUnknown_MM522_0xE8(0xe8, "Unknown Event 0xE8", PumpHistoryEntryGroup.Unknown, 2, 5, 25), //
|
||||||
|
|
||||||
ReadOtherDevicesIDs(0xf0, "", PumpHistoryEntryGroup.Configuration), // ?
|
ReadOtherDevicesIDs(0xf0, "Read Other Devices IDs", PumpHistoryEntryGroup.Configuration), // ?
|
||||||
ReadCaptureEventEnabled(0xf1, PumpHistoryEntryGroup.Configuration), // ?
|
ReadCaptureEventEnabled(0xf1, "Read Capture Event Enabled", PumpHistoryEntryGroup.Configuration), // ?
|
||||||
ChangeCaptureEventEnable2(0xf2, PumpHistoryEntryGroup.Configuration), // ?
|
ChangeCaptureEventEnable2(0xf2, "Change Capture Event Enable2", PumpHistoryEntryGroup.Configuration), // ?
|
||||||
ReadOtherDevicesStatus(0xf3, PumpHistoryEntryGroup.Configuration), // ?
|
ReadOtherDevicesStatus(0xf3, "Read Other Devices Status", PumpHistoryEntryGroup.Configuration), // ?
|
||||||
|
|
||||||
TempBasalCombined(0xfe, "TempBasalCombined", PumpHistoryEntryGroup.Basal), //
|
TempBasalCombined(0xfe, "TBR", PumpHistoryEntryGroup.Basal), //
|
||||||
UnknownBasePacket(0xff, "Unknown Base Packet", PumpHistoryEntryGroup.Unknown);
|
UnknownBasePacket(0xff, "Unknown Base Packet", PumpHistoryEntryGroup.Unknown);
|
||||||
|
|
||||||
private static Map<Integer, PumpHistoryEntryType> opCodeMap = new HashMap<Integer, PumpHistoryEntryType>();
|
private static Map<Integer, PumpHistoryEntryType> opCodeMap = new HashMap<Integer, PumpHistoryEntryType>();
|
||||||
|
@ -204,51 +208,21 @@ public enum PumpHistoryEntryType // implements CodeEnum
|
||||||
private PumpHistoryEntryGroup group = PumpHistoryEntryGroup.Unknown;
|
private PumpHistoryEntryGroup group = PumpHistoryEntryGroup.Unknown;
|
||||||
|
|
||||||
|
|
||||||
// @Deprecated
|
|
||||||
// PumpHistoryEntryType(int opCode, String name) {
|
|
||||||
// this(opCode, name, 2, 5, 0);
|
|
||||||
// }
|
|
||||||
|
|
||||||
PumpHistoryEntryType(int opCode, String name, PumpHistoryEntryGroup group) {
|
PumpHistoryEntryType(int opCode, String name, PumpHistoryEntryGroup group) {
|
||||||
this(opCode, name, group, 2, 5, 0);
|
this(opCode, name, group, 2, 5, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// @Deprecated
|
|
||||||
// PumpHistoryEntryType(int opCode) {
|
|
||||||
// this(opCode, null, null, 2, 5, 0);
|
|
||||||
// }
|
|
||||||
|
|
||||||
PumpHistoryEntryType(int opCode, PumpHistoryEntryGroup group) {
|
PumpHistoryEntryType(int opCode, PumpHistoryEntryGroup group) {
|
||||||
this(opCode, null, group, 2, 5, 0);
|
this(opCode, null, group, 2, 5, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// @Deprecated
|
|
||||||
// PumpHistoryEntryType(int opCode, int head, int date, int body) {
|
|
||||||
// this(opCode, null, null, head, date, body);
|
|
||||||
// }
|
|
||||||
|
|
||||||
PumpHistoryEntryType(int opCode, PumpHistoryEntryGroup group, int head, int date, int body) {
|
PumpHistoryEntryType(int opCode, PumpHistoryEntryGroup group, int head, int date, int body) {
|
||||||
this(opCode, null, group, head, date, body);
|
this(opCode, null, group, head, date, body);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// @Deprecated
|
|
||||||
// PumpHistoryEntryType(int opCode, String name, int head, DateFormat dateFormat, int body) {
|
|
||||||
// this(opCode, name, head, dateFormat.getLength(), body);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// @Deprecated
|
|
||||||
// PumpHistoryEntryType(int opCode, String name, int head, int date, int body) {
|
|
||||||
// this.opCode = (byte)opCode;
|
|
||||||
// this.description = name;
|
|
||||||
// this.headLength = head;
|
|
||||||
// this.dateLength = date;
|
|
||||||
// this.bodyLength = body;
|
|
||||||
// this.totalLength = (head + date + body);
|
|
||||||
// }
|
|
||||||
|
|
||||||
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;
|
||||||
|
|
|
@ -25,7 +25,7 @@ public class PumpHistoryResult {
|
||||||
private PumpHistoryEntry searchEntry = null;
|
private PumpHistoryEntry searchEntry = null;
|
||||||
private Long searchDate = null;
|
private Long searchDate = null;
|
||||||
private SearchType searchType = SearchType.None;
|
private SearchType searchType = SearchType.None;
|
||||||
private List<PumpHistoryEntry> unprocessedEntries;
|
public List<PumpHistoryEntry> unprocessedEntries;
|
||||||
public List<PumpHistoryEntry> validEntries;
|
public List<PumpHistoryEntry> validEntries;
|
||||||
|
|
||||||
|
|
||||||
|
@ -60,32 +60,41 @@ public class PumpHistoryResult {
|
||||||
|
|
||||||
switch (searchType) {
|
switch (searchType) {
|
||||||
case None:
|
case None:
|
||||||
|
LOG.debug("PE. None search");
|
||||||
|
// clearOrPrepareList();
|
||||||
this.validEntries.addAll(this.unprocessedEntries);
|
this.validEntries.addAll(this.unprocessedEntries);
|
||||||
// this.unprocessedEntries = null;
|
// this.unprocessedEntries
|
||||||
|
// = null;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LastEntry: {
|
case LastEntry: {
|
||||||
if (this.validEntries == null)
|
LOG.debug("PE. Last entry search");
|
||||||
this.validEntries = new ArrayList<>();
|
|
||||||
|
// clearOrPrepareList();
|
||||||
|
|
||||||
Collections.sort(this.unprocessedEntries, new PumpHistoryEntry.Comparator());
|
Collections.sort(this.unprocessedEntries, new PumpHistoryEntry.Comparator());
|
||||||
|
|
||||||
LOG.debug("PumpHistoryResult. Search entry date: " + searchEntry.atechDateTime);
|
LOG.debug("PE. PumpHistoryResult. Search entry date: " + searchEntry.atechDateTime);
|
||||||
|
|
||||||
|
Long date = searchEntry.atechDateTime;
|
||||||
|
|
||||||
for (PumpHistoryEntry unprocessedEntry : unprocessedEntries) {
|
for (PumpHistoryEntry unprocessedEntry : unprocessedEntries) {
|
||||||
|
|
||||||
if (unprocessedEntry.equals(searchEntry)) {
|
if (unprocessedEntry.equals(searchEntry)) {
|
||||||
|
LOG.debug("PE. Item found {}.", unprocessedEntry);
|
||||||
searchFinished = true;
|
searchFinished = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LOG.debug("PE. Entry {} added.", unprocessedEntry);
|
||||||
this.validEntries.add(unprocessedEntry);
|
this.validEntries.add(unprocessedEntry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Date: {
|
case Date: {
|
||||||
if (this.validEntries == null)
|
LOG.debug("PE. Date search");
|
||||||
this.validEntries = new ArrayList<>();
|
|
||||||
|
// clearOrPrepareList();
|
||||||
|
|
||||||
for (PumpHistoryEntry unprocessedEntry : unprocessedEntries) {
|
for (PumpHistoryEntry unprocessedEntry : unprocessedEntries) {
|
||||||
if (unprocessedEntry.isAfter(this.searchDate)) {
|
if (unprocessedEntry.isAfter(this.searchDate)) {
|
||||||
|
@ -106,6 +115,27 @@ public class PumpHistoryResult {
|
||||||
|
|
||||||
} // switch
|
} // switch
|
||||||
|
|
||||||
|
LOG.debug("PE. Valid Entries: {}", validEntries);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void clearOrPrepareList() {
|
||||||
|
if (this.validEntries == null)
|
||||||
|
this.validEntries = new ArrayList<>();
|
||||||
|
else
|
||||||
|
this.validEntries.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
return "PumpHistoryResult [unprocessed=" + unprocessedEntries.size() + //
|
||||||
|
", valid=" + validEntries.size() + //
|
||||||
|
", searchEntry=" + searchEntry + //
|
||||||
|
", searchDate=" + searchDate + //
|
||||||
|
", searchType=" + searchType + //
|
||||||
|
", searchFinished=" + searchFinished + //
|
||||||
|
"]";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -54,6 +54,7 @@ public class MedtronicHistoryData {
|
||||||
* @param result PumpHistoryResult instance
|
* @param result PumpHistoryResult instance
|
||||||
*/
|
*/
|
||||||
public void addNewHistory(PumpHistoryResult result) {
|
public void addNewHistory(PumpHistoryResult result) {
|
||||||
|
|
||||||
this.newHistory = result.getValidEntries();
|
this.newHistory = result.getValidEntries();
|
||||||
|
|
||||||
showLogs("List of history (before filtering): ", MedtronicPumpPlugin.gsonInstance.toJson(this.newHistory));
|
showLogs("List of history (before filtering): ", MedtronicPumpPlugin.gsonInstance.toJson(this.newHistory));
|
||||||
|
@ -86,6 +87,8 @@ public class MedtronicHistoryData {
|
||||||
|
|
||||||
for (PumpHistoryEntry pumpHistoryEntry : newHistory) {
|
for (PumpHistoryEntry pumpHistoryEntry : newHistory) {
|
||||||
|
|
||||||
|
if (!this.allHistory.contains(pumpHistoryEntry)) {
|
||||||
|
|
||||||
PumpHistoryEntryType type = pumpHistoryEntry.getEntryType();
|
PumpHistoryEntryType type = pumpHistoryEntry.getEntryType();
|
||||||
|
|
||||||
// if (PumpHistoryEntryType.isAAPSRelevantEntry(type)) {
|
// if (PumpHistoryEntryType.isAAPSRelevantEntry(type)) {
|
||||||
|
@ -106,6 +109,8 @@ public class MedtronicHistoryData {
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
TBRs = processTBRs(TBRs);
|
TBRs = processTBRs(TBRs);
|
||||||
|
|
||||||
newHistory2.addAll(TBRs);
|
newHistory2.addAll(TBRs);
|
||||||
|
@ -130,7 +135,7 @@ public class MedtronicHistoryData {
|
||||||
if (filteredListByLastRecord.size() == 0)
|
if (filteredListByLastRecord.size() == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
List<PumpHistoryEntry> outList = new ArrayList<>();
|
// List<PumpHistoryEntry> outList = new ArrayList<>();
|
||||||
|
|
||||||
// if (allHistory.size() > OLD_HISTORY_SIZE) {
|
// if (allHistory.size() > OLD_HISTORY_SIZE) {
|
||||||
// for (int i = 0; i < OLD_HISTORY_SIZE; i++) {
|
// for (int i = 0; i < OLD_HISTORY_SIZE; i++) {
|
||||||
|
@ -144,14 +149,21 @@ public class MedtronicHistoryData {
|
||||||
|
|
||||||
LOG.debug("All History records (before): " + allHistory.size());
|
LOG.debug("All History records (before): " + allHistory.size());
|
||||||
|
|
||||||
outList.addAll(this.allHistory);
|
for (PumpHistoryEntry pumpHistoryEntry : filteredListByLastRecord) {
|
||||||
outList.addAll(filteredListByLastRecord);
|
|
||||||
|
|
||||||
this.allHistory.clear();
|
if (!this.allHistory.contains(pumpHistoryEntry)) {
|
||||||
|
this.allHistory.add(pumpHistoryEntry);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
this.allHistory.addAll(outList);
|
// outList.addAll(this.allHistory);
|
||||||
|
// outList.addAll(filteredListByLastRecord);
|
||||||
this.sort(this.allHistory);
|
//
|
||||||
|
// this.allHistory.clear();
|
||||||
|
//
|
||||||
|
// this.allHistory.addAll(outList);
|
||||||
|
//
|
||||||
|
// this.sort(this.allHistory);
|
||||||
|
|
||||||
LOG.debug("All History records (after): " + allHistory.size());
|
LOG.debug("All History records (after): " + allHistory.size());
|
||||||
|
|
||||||
|
|
|
@ -87,6 +87,32 @@ public class BasalProfile {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public boolean setRawDataFromHistory(byte[] data) {
|
||||||
|
if (data == null) {
|
||||||
|
LOG.error("setRawData: buffer is null!");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
mRawData = new byte[MAX_RAW_DATA_SIZE];
|
||||||
|
int item = 0;
|
||||||
|
|
||||||
|
for (int i = 0; i < data.length - 2; i += 3) {
|
||||||
|
|
||||||
|
if ((data[i] == 0) && (data[i + 1] == 0) && (data[i + 2] == 0)) {
|
||||||
|
mRawData[i] = 0;
|
||||||
|
mRawData[i + 1] = 0;
|
||||||
|
mRawData[i + 2] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
mRawData[i] = data[i + 1];
|
||||||
|
mRawData[i + 1] = data[i + 2];
|
||||||
|
mRawData[i + 2] = data[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public void dumpBasalProfile() {
|
public void dumpBasalProfile() {
|
||||||
LOG.debug("Basal Profile entries:");
|
LOG.debug("Basal Profile entries:");
|
||||||
List<BasalProfileEntry> entries = getEntries();
|
List<BasalProfileEntry> entries = getEntries();
|
||||||
|
|
|
@ -120,6 +120,17 @@ public class BolusDTO extends PumpTimeStampedRecord {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public String getDisplayableValue() {
|
||||||
|
String value = getValue();
|
||||||
|
|
||||||
|
value = value.replace("AMOUNT_SQUARE=", "Amount Square: ");
|
||||||
|
value = value.replace("AMOUNT=", "Amount: ");
|
||||||
|
value = value.replace("DURATION=", "Duration: ");
|
||||||
|
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public Float getImmediateAmount() {
|
public Float getImmediateAmount() {
|
||||||
return immediateAmount;
|
return immediateAmount;
|
||||||
}
|
}
|
||||||
|
|
|
@ -146,9 +146,9 @@ public class TempBasalPair {
|
||||||
public String getDescription() {
|
public String getDescription() {
|
||||||
|
|
||||||
if (isPercent) {
|
if (isPercent) {
|
||||||
return String.format(Locale.ENGLISH, "Rate=%.0f%%, Duration=%d min", insulinRate, durationMinutes);
|
return String.format(Locale.ENGLISH, "Rate: %.0f%%, Duration: %d min", insulinRate, durationMinutes);
|
||||||
} else {
|
} else {
|
||||||
return String.format(Locale.ENGLISH, "Rate=%.3f U, Duration=%d min", insulinRate, durationMinutes);
|
return String.format(Locale.ENGLISH, "Rate: %.3f U, Duration: %d min", insulinRate, durationMinutes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ import android.app.Activity;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.HandlerThread;
|
import android.os.HandlerThread;
|
||||||
import android.support.v7.widget.CardView;
|
import android.os.SystemClock;
|
||||||
import android.support.v7.widget.LinearLayoutManager;
|
import android.support.v7.widget.LinearLayoutManager;
|
||||||
import android.support.v7.widget.RecyclerView;
|
import android.support.v7.widget.RecyclerView;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
|
@ -23,11 +23,7 @@ import android.widget.TextView;
|
||||||
|
|
||||||
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.Profile;
|
|
||||||
import info.nightscout.androidaps.interfaces.PluginType;
|
|
||||||
import info.nightscout.androidaps.logging.L;
|
import info.nightscout.androidaps.logging.L;
|
||||||
import info.nightscout.androidaps.plugins.PumpDanaRKorean.DanaRKoreanPlugin;
|
|
||||||
import info.nightscout.androidaps.plugins.PumpDanaRS.DanaRSPlugin;
|
|
||||||
import info.nightscout.androidaps.plugins.PumpMedtronic.MedtronicPumpPlugin;
|
import info.nightscout.androidaps.plugins.PumpMedtronic.MedtronicPumpPlugin;
|
||||||
import info.nightscout.androidaps.plugins.PumpMedtronic.comm.history.pump.PumpHistoryEntry;
|
import info.nightscout.androidaps.plugins.PumpMedtronic.comm.history.pump.PumpHistoryEntry;
|
||||||
import info.nightscout.androidaps.plugins.PumpMedtronic.comm.history.pump.PumpHistoryEntryGroup;
|
import info.nightscout.androidaps.plugins.PumpMedtronic.comm.history.pump.PumpHistoryEntryGroup;
|
||||||
|
@ -38,44 +34,28 @@ public class MedtronicHistoryActivity extends Activity {
|
||||||
|
|
||||||
private Handler mHandler;
|
private Handler mHandler;
|
||||||
|
|
||||||
static Profile profile = null;
|
// static Profile profile = null;
|
||||||
|
|
||||||
Spinner historyTypeSpinner;
|
Spinner historyTypeSpinner;
|
||||||
TextView statusView;
|
TextView statusView;
|
||||||
// Button reloadButton;
|
|
||||||
// Button syncButton;
|
|
||||||
RecyclerView recyclerView;
|
RecyclerView recyclerView;
|
||||||
LinearLayoutManager llm;
|
LinearLayoutManager llm;
|
||||||
|
|
||||||
static PumpHistoryEntryGroup showingType = PumpHistoryEntryGroup.All;
|
static TypeList showingType = null;
|
||||||
// List<PumpHistoryEntry> fullHistoryList = null;
|
static PumpHistoryEntryGroup selectedGroup = PumpHistoryEntryGroup.All;
|
||||||
List<PumpHistoryEntry> filteredHistoryList = new ArrayList<>();
|
List<PumpHistoryEntry> filteredHistoryList = new ArrayList<>();
|
||||||
|
|
||||||
|
RecyclerViewAdapter recyclerViewAdapter;
|
||||||
|
boolean manualChange = false;
|
||||||
|
|
||||||
|
List<TypeList> typeListFull;
|
||||||
|
|
||||||
// public static class TypeList {
|
|
||||||
//
|
|
||||||
// public byte type;
|
|
||||||
// String name;
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// TypeList(byte type, String name) {
|
|
||||||
// this.type = type;
|
|
||||||
// this.name = name;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public String toString() {
|
|
||||||
// return name;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
public MedtronicHistoryActivity() {
|
public MedtronicHistoryActivity() {
|
||||||
super();
|
super();
|
||||||
HandlerThread mHandlerThread = new HandlerThread(MedtronicHistoryActivity.class.getSimpleName());
|
HandlerThread mHandlerThread = new HandlerThread(MedtronicHistoryActivity.class.getSimpleName());
|
||||||
mHandlerThread.start();
|
mHandlerThread.start();
|
||||||
// this.fullHistoryList = MedtronicPumpPlugin.getPlugin().getMedtronicHistoryData().getAllHistory();
|
filterHistory(PumpHistoryEntryGroup.All);
|
||||||
filterHistory(this.showingType);
|
|
||||||
this.mHandler = new Handler(mHandlerThread.getLooper());
|
this.mHandler = new Handler(mHandlerThread.getLooper());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -99,6 +79,11 @@ public class MedtronicHistoryActivity extends Activity {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.recyclerViewAdapter != null) {
|
||||||
|
this.recyclerViewAdapter.setHistoryList(this.filteredHistoryList);
|
||||||
|
this.recyclerViewAdapter.notifyDataSetChanged();
|
||||||
|
}
|
||||||
|
|
||||||
LOG.debug("Items on filtered list: {}", filteredHistoryList.size());
|
LOG.debug("Items on filtered list: {}", filteredHistoryList.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -107,7 +92,23 @@ public class MedtronicHistoryActivity extends Activity {
|
||||||
protected void onResume() {
|
protected void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
MainApp.bus().register(this);
|
MainApp.bus().register(this);
|
||||||
filterHistory(showingType);
|
filterHistory(selectedGroup);
|
||||||
|
setHistoryTypeSpinner();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void setHistoryTypeSpinner() {
|
||||||
|
this.manualChange = true;
|
||||||
|
|
||||||
|
for (int i = 0; i < typeListFull.size(); i++) {
|
||||||
|
if (typeListFull.get(i).entryGroup == selectedGroup) {
|
||||||
|
historyTypeSpinner.setSelection(i);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SystemClock.sleep(200);
|
||||||
|
this.manualChange = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -125,58 +126,75 @@ public class MedtronicHistoryActivity extends Activity {
|
||||||
|
|
||||||
historyTypeSpinner = (Spinner)findViewById(R.id.medtronic_historytype);
|
historyTypeSpinner = (Spinner)findViewById(R.id.medtronic_historytype);
|
||||||
statusView = (TextView)findViewById(R.id.medtronic_historystatus);
|
statusView = (TextView)findViewById(R.id.medtronic_historystatus);
|
||||||
// reloadButton = (Button)findViewById(R.id.medtronic_historyreload);
|
|
||||||
// syncButton = (Button)findViewById(R.id.medtronic_historysync);
|
|
||||||
recyclerView = (RecyclerView)findViewById(R.id.medtronic_history_recyclerview);
|
recyclerView = (RecyclerView)findViewById(R.id.medtronic_history_recyclerview);
|
||||||
|
|
||||||
recyclerView.setHasFixedSize(true);
|
recyclerView.setHasFixedSize(true);
|
||||||
llm = new LinearLayoutManager(this);
|
llm = new LinearLayoutManager(this);
|
||||||
recyclerView.setLayoutManager(llm);
|
recyclerView.setLayoutManager(llm);
|
||||||
|
|
||||||
RecyclerViewAdapter adapter = new RecyclerViewAdapter(filteredHistoryList);
|
recyclerViewAdapter = new RecyclerViewAdapter(filteredHistoryList);
|
||||||
recyclerView.setAdapter(adapter);
|
recyclerView.setAdapter(recyclerViewAdapter);
|
||||||
|
|
||||||
statusView.setVisibility(View.GONE);
|
statusView.setVisibility(View.GONE);
|
||||||
|
|
||||||
boolean isKorean = DanaRKoreanPlugin.getPlugin().isEnabled(PluginType.PUMP);
|
typeListFull = getTypeList(PumpHistoryEntryGroup.getList());
|
||||||
boolean isRS = DanaRSPlugin.getPlugin().isEnabled(PluginType.PUMP);
|
|
||||||
|
|
||||||
// Types
|
ArrayAdapter<TypeList> spinnerAdapter = new ArrayAdapter<>(this, R.layout.spinner_centered, typeListFull);
|
||||||
|
|
||||||
// ArrayList<TypeList> typeList = new ArrayList<>();
|
|
||||||
// typeList.add(new TypeList(RecordTypes.RECORD_TYPE_ALARM, MainApp.gs(R.string.danar_history_alarm)));
|
|
||||||
// typeList.add(new TypeList(RecordTypes.RECORD_TYPE_BASALHOUR, MainApp.gs(R.string.danar_history_basalhours)));
|
|
||||||
// typeList.add(new TypeList(RecordTypes.RECORD_TYPE_BOLUS, MainApp.gs(R.string.danar_history_bolus)));
|
|
||||||
// typeList.add(new TypeList(RecordTypes.RECORD_TYPE_CARBO, MainApp.gs(R.string.danar_history_carbohydrates)));
|
|
||||||
// typeList.add(new TypeList(RecordTypes.RECORD_TYPE_DAILY, MainApp.gs(R.string.danar_history_dailyinsulin)));
|
|
||||||
// typeList.add(new TypeList(RecordTypes.RECORD_TYPE_GLUCOSE, MainApp.gs(R.string.danar_history_glucose)));
|
|
||||||
// typeList.add(new TypeList(RecordTypes.RECORD_TYPE_ERROR, MainApp.gs(R.string.danar_history_errors)));
|
|
||||||
// typeList.add(new TypeList(RecordTypes.RECORD_TYPE_PRIME, MainApp.gs(R.string.danar_history_prime)));
|
|
||||||
// typeList.add(new TypeList(RecordTypes.RECORD_TYPE_REFILL, MainApp.gs(R.string.danar_history_refill)));
|
|
||||||
// typeList.add(new TypeList(RecordTypes.RECORD_TYPE_SUSPEND, MainApp.gs(R.string.danar_history_syspend)));
|
|
||||||
|
|
||||||
ArrayAdapter<PumpHistoryEntryGroup> spinnerAdapter = new ArrayAdapter<>(this, R.layout.spinner_centered,
|
|
||||||
PumpHistoryEntryGroup.getList());
|
|
||||||
historyTypeSpinner.setAdapter(spinnerAdapter);
|
historyTypeSpinner.setAdapter(spinnerAdapter);
|
||||||
|
|
||||||
historyTypeSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
historyTypeSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
|
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
|
||||||
PumpHistoryEntryGroup selected = (PumpHistoryEntryGroup)historyTypeSpinner.getSelectedItem();
|
if (manualChange)
|
||||||
|
return;
|
||||||
|
TypeList selected = (TypeList)historyTypeSpinner.getSelectedItem();
|
||||||
showingType = selected;
|
showingType = selected;
|
||||||
filterHistory(selected);
|
selectedGroup = selected.entryGroup;
|
||||||
|
filterHistory(selectedGroup);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onNothingSelected(AdapterView<?> parent) {
|
public void onNothingSelected(AdapterView<?> parent) {
|
||||||
filterHistory(showingType);
|
if (manualChange)
|
||||||
|
return;
|
||||||
|
filterHistory(PumpHistoryEntryGroup.All);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private List<TypeList> getTypeList(List<PumpHistoryEntryGroup> list) {
|
||||||
|
|
||||||
|
ArrayList<TypeList> typeList = new ArrayList<>();
|
||||||
|
|
||||||
|
for (PumpHistoryEntryGroup pumpHistoryEntryGroup : list) {
|
||||||
|
typeList.add(new TypeList(pumpHistoryEntryGroup));
|
||||||
|
}
|
||||||
|
|
||||||
|
return typeList;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class TypeList {
|
||||||
|
|
||||||
|
PumpHistoryEntryGroup entryGroup;
|
||||||
|
String name;
|
||||||
|
|
||||||
|
|
||||||
|
TypeList(PumpHistoryEntryGroup entryGroup) {
|
||||||
|
this.entryGroup = entryGroup;
|
||||||
|
this.name = entryGroup.getTranslated();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static class RecyclerViewAdapter extends RecyclerView.Adapter<RecyclerViewAdapter.HistoryViewHolder> {
|
public static class RecyclerViewAdapter extends RecyclerView.Adapter<RecyclerViewAdapter.HistoryViewHolder> {
|
||||||
|
|
||||||
List<PumpHistoryEntry> historyList;
|
List<PumpHistoryEntry> historyList;
|
||||||
|
@ -187,9 +205,19 @@ public class MedtronicHistoryActivity extends Activity {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void setHistoryList(List<PumpHistoryEntry> historyList) {
|
||||||
|
// this.historyList.clear();
|
||||||
|
// this.historyList.addAll(historyList);
|
||||||
|
|
||||||
|
this.historyList = historyList;
|
||||||
|
|
||||||
|
// this.notifyDataSetChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public HistoryViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) {
|
public HistoryViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) {
|
||||||
View v = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.rileylink_status_history_item, //
|
View v = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.medtronic_history_item, //
|
||||||
viewGroup, false);
|
viewGroup, false);
|
||||||
return new HistoryViewHolder(v);
|
return new HistoryViewHolder(v);
|
||||||
}
|
}
|
||||||
|
@ -199,10 +227,12 @@ public class MedtronicHistoryActivity extends Activity {
|
||||||
public void onBindViewHolder(HistoryViewHolder holder, int position) {
|
public void onBindViewHolder(HistoryViewHolder holder, int position) {
|
||||||
PumpHistoryEntry record = historyList.get(position);
|
PumpHistoryEntry record = historyList.get(position);
|
||||||
|
|
||||||
|
if (record != null) {
|
||||||
holder.timeView.setText(record.getDateTimeString());
|
holder.timeView.setText(record.getDateTimeString());
|
||||||
holder.typeView.setText(record.getEntryType().getDescription());
|
holder.typeView.setText(record.getEntryType().getDescription());
|
||||||
holder.valueView.setText(record.getDisplayableValue());
|
holder.valueView.setText(record.getDisplayableValue());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -218,7 +248,6 @@ public class MedtronicHistoryActivity extends Activity {
|
||||||
|
|
||||||
static class HistoryViewHolder extends RecyclerView.ViewHolder {
|
static class HistoryViewHolder extends RecyclerView.ViewHolder {
|
||||||
|
|
||||||
CardView cv;
|
|
||||||
TextView timeView;
|
TextView timeView;
|
||||||
TextView typeView;
|
TextView typeView;
|
||||||
TextView valueView;
|
TextView valueView;
|
||||||
|
@ -227,9 +256,9 @@ public class MedtronicHistoryActivity extends Activity {
|
||||||
HistoryViewHolder(View itemView) {
|
HistoryViewHolder(View itemView) {
|
||||||
super(itemView);
|
super(itemView);
|
||||||
// cv = (CardView)itemView.findViewById(R.id.rileylink_history_item);
|
// cv = (CardView)itemView.findViewById(R.id.rileylink_history_item);
|
||||||
timeView = (TextView)itemView.findViewById(R.id.rileylink_history_time);
|
timeView = (TextView)itemView.findViewById(R.id.medtronic_history_time);
|
||||||
typeView = (TextView)itemView.findViewById(R.id.rileylink_history_source);
|
typeView = (TextView)itemView.findViewById(R.id.medtronic_history_source);
|
||||||
valueView = (TextView)itemView.findViewById(R.id.rileylink_history_description);
|
valueView = (TextView)itemView.findViewById(R.id.medtronic_history_description);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,7 @@
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:background="@drawable/pillborder"
|
android:background="@drawable/pillborder"
|
||||||
android:gravity="center_horizontal"
|
android:gravity="center_horizontal"
|
||||||
android:text="DanaR History" />
|
android:text="@string/medtronic_pump_history" />
|
||||||
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
@ -54,7 +54,6 @@
|
||||||
android:id="@+id/medtronic_history_recyclerview"
|
android:id="@+id/medtronic_history_recyclerview"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="fill_parent"
|
android:layout_height="fill_parent"
|
||||||
|
|
||||||
android:layout_below="@+id/medtronic_historystatus" />
|
android:layout_below="@+id/medtronic_historystatus" />
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
34
app/src/main/res/layout/medtronic_history_item.xml
Normal file
34
app/src/main/res/layout/medtronic_history_item.xml
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="40dp"
|
||||||
|
android:id="@+id/medtronic_history_item"
|
||||||
|
android:paddingLeft="20dp">
|
||||||
|
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/medtronic_history_time"
|
||||||
|
android:layout_width="88dp"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:text="Date"
|
||||||
|
android:textSize="12dp" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/medtronic_history_source"
|
||||||
|
android:layout_width="132dp"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:text="Source"
|
||||||
|
android:textSize="12dp" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/medtronic_history_description"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:text="Description"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:textSize="12dp" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
|
@ -10,12 +10,20 @@
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<ListView
|
<TextView
|
||||||
|
android:id="@+id/rileylink_historystatus"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="10px"
|
||||||
|
android:layout_below="@id/medtronic_historytop"
|
||||||
|
android:layout_gravity="center_horizontal"
|
||||||
|
android:gravity="center_horizontal" />
|
||||||
|
|
||||||
|
<android.support.v7.widget.RecyclerView
|
||||||
android:id="@+id/rileylink_history_list"
|
android:id="@+id/rileylink_history_list"
|
||||||
tools:layout_editor_absoluteX="8dp"
|
android:layout_width="match_parent"
|
||||||
tools:layout_editor_absoluteY="8dp" />
|
android:layout_height="fill_parent"
|
||||||
|
android:layout_below="@+id/rileylink_historystatus" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
</android.support.constraint.ConstraintLayout>
|
</android.support.constraint.ConstraintLayout>
|
|
@ -3,7 +3,7 @@
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="40dp"
|
android:layout_height="40dp"
|
||||||
android:id="@+id/rileylink_history_item"
|
android:id="@+id/rileylink_status_history_item"
|
||||||
android:paddingLeft="20dp">
|
android:paddingLeft="20dp">
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1331,6 +1331,7 @@
|
||||||
<string name="medtronic_history_group_statistic">Statistics</string>
|
<string name="medtronic_history_group_statistic">Statistics</string>
|
||||||
<string name="medtronic_history_group_unknown">Unknowns</string>
|
<string name="medtronic_history_group_unknown">Unknowns</string>
|
||||||
<string name="medtronic_history_group_all">All</string>
|
<string name="medtronic_history_group_all">All</string>
|
||||||
|
<string name="medtronic_pump_history">Medtronic Pump History</string>
|
||||||
|
|
||||||
|
|
||||||
<!-- MDT Pump Status -->
|
<!-- MDT Pump Status -->
|
||||||
|
|
|
@ -47,6 +47,25 @@ public class MedtronicPumpHistoryDecoderUTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// @Test
|
||||||
|
public void decodeLowAmount() {
|
||||||
|
byte[] data = new byte[] { 52, -12, 22, -81, 46, 3, 19 };
|
||||||
|
|
||||||
|
PumpHistoryEntryGroup.doNotTranslate = true;
|
||||||
|
PumpHistoryEntryType entryType = PumpHistoryEntryType.getByCode(52);
|
||||||
|
|
||||||
|
PumpHistoryEntry phe = new PumpHistoryEntry();
|
||||||
|
phe.setEntryType(entryType);
|
||||||
|
phe.setData(ByteUtil.getListFromByteArray(data), false);
|
||||||
|
|
||||||
|
decoder.decodeRecord(phe);
|
||||||
|
|
||||||
|
System.out.println("Record: " + phe);
|
||||||
|
System.out.println("Record: " + phe.getDisplayableValue());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// @Test
|
// @Test
|
||||||
public void decodeDailyTotals522() {
|
public void decodeDailyTotals522() {
|
||||||
// PumpHistoryRecord [type=DailyTotals522 [109, 0x6D], DT: 01.11.2018 00:00:00, length=1,2,41(44), data={Raw
|
// PumpHistoryRecord [type=DailyTotals522 [109, 0x6D], DT: 01.11.2018 00:00:00, length=1,2,41(44), data={Raw
|
||||||
|
|
|
@ -143,4 +143,29 @@ public class BasalProfileUTest {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testProfileFromHistory() {
|
||||||
|
MedtronicUtil.setPumpStatus(new MedtronicPumpStatus(new PumpDescription()));
|
||||||
|
MedtronicUtil.getPumpStatus().pumpType = PumpType.Medtronic_522_722;
|
||||||
|
|
||||||
|
byte[] data = {
|
||||||
|
0, 72, 0, 2, 64, 0, 4, 56, 0, 6, 58, 0, 8, 58, 0, 10, 58, 0, 12, 50, 0, 14, 50, 0, 16, 38, 0, 18, 38, 0,
|
||||||
|
20, 46, 0, 22, 46, 0, 24, 50, 0, 26, 38, 0, 28, 38, 0, 30, 38, 0, 32, 26, 0, 34, 26, 0, 36, 26, 0, 38, 26,
|
||||||
|
0, 40, 26, 0, 42, 20, 0, 44, 20, 0, 46, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
|
||||||
|
|
||||||
|
BasalProfile basalProfile = new BasalProfile();
|
||||||
|
basalProfile.setRawDataFromHistory(data);
|
||||||
|
|
||||||
|
Double[] profilesByHour = basalProfile.getProfilesByHour();
|
||||||
|
|
||||||
|
System.out.println("Basals by hour: "
|
||||||
|
+ (profilesByHour == null ? "null" : BasalProfile.getProfilesByHourToString(profilesByHour)));
|
||||||
|
|
||||||
|
// 1.800 1.600 1.400 1.450 1.450 1.450 1.250 1.250 0.950 0.950 1.150 1.150 1.250 0.950 0.950 0.950 0.650 0.650
|
||||||
|
// 0.650 0.650 0.650 0.500 0.500 0.500
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue