Medtronic 0.10.6:

- Fix Superbolus problem #138
- Fix Disconnect problem #136
- Fix Clear Bolus Block #137
- Fix problem with history DalyTotal515 (for RaulAC)
- Clean code from driver
- Fix RileyLink status, before Pump initialized #130
- Fixed basal profile rounding #134
This commit is contained in:
Andy Rozman 2019-06-15 19:52:20 +01:00
parent 85381af2fb
commit 00f141aa03
33 changed files with 448 additions and 803 deletions

View file

@ -105,7 +105,7 @@ android {
multiDexEnabled true multiDexEnabled true
versionCode 1500 versionCode 1500
// dev_version: 2.3.1-dev // dev_version: 2.3.1-dev
version "medtronic-0.10.5-SNAPSHOT" version "medtronic-0.10.6-SNAPSHOT"
buildConfigField "String", "VERSION", '"' + version + '"' buildConfigField "String", "VERSION", '"' + version + '"'
buildConfigField "String", "BUILDVERSION", '"' + generateGitBuild() + '-' + generateDate() + '"' buildConfigField "String", "BUILDVERSION", '"' + generateGitBuild() + '-' + generateDate() + '"'
buildConfigField "String", "HEAD", '"' + generateGitBuild() + '"' buildConfigField "String", "HEAD", '"' + generateGitBuild() + '"'

View file

@ -644,6 +644,17 @@ public class LoopPlugin extends PluginBase {
TreatmentsInterface activeTreatments = TreatmentsPlugin.getPlugin(); TreatmentsInterface activeTreatments = TreatmentsPlugin.getPlugin();
LoopPlugin.getPlugin().disconnectTo(System.currentTimeMillis() + durationInMinutes * 60 * 1000L); LoopPlugin.getPlugin().disconnectTo(System.currentTimeMillis() + durationInMinutes * 60 * 1000L);
if (pump.getPumpDescription().tempBasalStyle == PumpDescription.ABSOLUTE) {
ConfigBuilderPlugin.getPlugin().getCommandQueue().tempBasalAbsolute(0, durationInMinutes, true, profile, new Callback() {
@Override
public void run() {
if (!result.success) {
ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.gs(R.string.tempbasaldeliveryerror));
}
}
});
} else {
ConfigBuilderPlugin.getPlugin().getCommandQueue().tempBasalPercent(0, durationInMinutes, true, profile, new Callback() { ConfigBuilderPlugin.getPlugin().getCommandQueue().tempBasalPercent(0, durationInMinutes, true, profile, new Callback() {
@Override @Override
public void run() { public void run() {
@ -652,6 +663,8 @@ public class LoopPlugin extends PluginBase {
} }
} }
}); });
}
if (pump.getPumpDescription().isExtendedBolusCapable && activeTreatments.isInHistoryExtendedBoluslInProgress()) { if (pump.getPumpDescription().isExtendedBolusCapable && activeTreatments.isInHistoryExtendedBoluslInProgress()) {
ConfigBuilderPlugin.getPlugin().getCommandQueue().cancelExtended(new Callback() { ConfigBuilderPlugin.getPlugin().getCommandQueue().cancelExtended(new Callback() {
@Override @Override

View file

@ -853,6 +853,24 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
loopPlugin.superBolusTo(System.currentTimeMillis() + T.hours(2).msecs()); loopPlugin.superBolusTo(System.currentTimeMillis() + T.hours(2).msecs());
MainApp.bus().post(new EventRefreshOverview("WizardDialog")); MainApp.bus().post(new EventRefreshOverview("WizardDialog"));
} }
PumpInterface pump = ConfigBuilderPlugin.getPlugin().getActivePump();
if (pump.getPumpDescription().tempBasalStyle == PumpDescription.ABSOLUTE) {
ConfigBuilderPlugin.getPlugin().getCommandQueue().tempBasalAbsolute(0.0d, 120, true, profile, new Callback() {
@Override
public void run() {
if (!result.success) {
Intent i = new Intent(MainApp.instance(), ErrorHelperActivity.class);
i.putExtra("soundid", R.raw.boluserror);
i.putExtra("status", result.comment);
i.putExtra("title", MainApp.gs(R.string.tempbasaldeliveryerror));
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
MainApp.instance().startActivity(i);
}
}
});
} else {
ConfigBuilderPlugin.getPlugin().getCommandQueue().tempBasalPercent(0, 120, true, profile, new Callback() { ConfigBuilderPlugin.getPlugin().getCommandQueue().tempBasalPercent(0, 120, true, profile, new Callback() {
@Override @Override
public void run() { public void run() {
@ -867,6 +885,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
} }
}); });
} }
}
DetailedBolusInfo detailedBolusInfo = new DetailedBolusInfo(); DetailedBolusInfo detailedBolusInfo = new DetailedBolusInfo();
detailedBolusInfo.eventType = CareportalEvent.BOLUSWIZARD; detailedBolusInfo.eventType = CareportalEvent.BOLUSWIZARD;
detailedBolusInfo.insulin = finalInsulinAfterConstraints; detailedBolusInfo.insulin = finalInsulinAfterConstraints;

View file

@ -53,6 +53,7 @@ import info.nightscout.androidaps.events.EventFeatureRunning;
import info.nightscout.androidaps.events.EventRefreshOverview; import info.nightscout.androidaps.events.EventRefreshOverview;
import info.nightscout.androidaps.interfaces.Constraint; import info.nightscout.androidaps.interfaces.Constraint;
import info.nightscout.androidaps.interfaces.PluginType; import info.nightscout.androidaps.interfaces.PluginType;
import info.nightscout.androidaps.interfaces.PumpDescription;
import info.nightscout.androidaps.interfaces.PumpInterface; import info.nightscout.androidaps.interfaces.PumpInterface;
import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin; import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin;
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin; import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
@ -354,6 +355,25 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com
loopPlugin.superBolusTo(System.currentTimeMillis() + 2 * 60L * 60 * 1000); loopPlugin.superBolusTo(System.currentTimeMillis() + 2 * 60L * 60 * 1000);
MainApp.bus().post(new EventRefreshOverview("WizardDialog")); MainApp.bus().post(new EventRefreshOverview("WizardDialog"));
} }
PumpInterface pump = ConfigBuilderPlugin.getPlugin().getActivePump();
if (pump.getPumpDescription().tempBasalStyle == PumpDescription.ABSOLUTE) {
ConfigBuilderPlugin.getPlugin().getCommandQueue().tempBasalAbsolute(0.0d, 120, true, profile, new Callback() {
@Override
public void run() {
if (!result.success) {
Intent i = new Intent(MainApp.instance(), ErrorHelperActivity.class);
i.putExtra("soundid", R.raw.boluserror);
i.putExtra("status", result.comment);
i.putExtra("title", MainApp.gs(R.string.tempbasaldeliveryerror));
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
MainApp.instance().startActivity(i);
}
}
});
} else {
ConfigBuilderPlugin.getPlugin().getCommandQueue().tempBasalPercent(0, 120, true, profile, new Callback() { ConfigBuilderPlugin.getPlugin().getCommandQueue().tempBasalPercent(0, 120, true, profile, new Callback() {
@Override @Override
public void run() { public void run() {
@ -368,6 +388,7 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com
} }
}); });
} }
}
DetailedBolusInfo detailedBolusInfo = new DetailedBolusInfo(); DetailedBolusInfo detailedBolusInfo = new DetailedBolusInfo();
detailedBolusInfo.eventType = CareportalEvent.BOLUSWIZARD; detailedBolusInfo.eventType = CareportalEvent.BOLUSWIZARD;
detailedBolusInfo.insulin = finalInsulinAfterConstraints; detailedBolusInfo.insulin = finalInsulinAfterConstraints;

View file

@ -52,7 +52,7 @@ public class RFSpy {
private UUID responseCountUUID = UUID.fromString(GattAttributes.CHARA_RADIO_RESPONSE_COUNT); private UUID responseCountUUID = UUID.fromString(GattAttributes.CHARA_RADIO_RESPONSE_COUNT);
private RileyLinkFirmwareVersion firmwareVersion; private RileyLinkFirmwareVersion firmwareVersion;
private String bleVersion; // We don't use it so no need of sofisticated logic private String bleVersion; // We don't use it so no need of sofisticated logic
double currentFrequencyMHz; Double currentFrequencyMHz;
public RFSpy(RileyLinkBLE rileyLinkBle) { public RFSpy(RileyLinkBLE rileyLinkBle) {
@ -415,6 +415,7 @@ public class RFSpy {
* Reset RileyLink Configuration (set all updateRegisters) * Reset RileyLink Configuration (set all updateRegisters)
*/ */
public void resetRileyLinkConfiguration() { public void resetRileyLinkConfiguration() {
if (this.currentFrequencyMHz != null)
this.setBaseFrequency(this.currentFrequencyMHz); this.setBaseFrequency(this.currentFrequencyMHz);
} }

View file

@ -120,9 +120,6 @@ public abstract class RileyLinkService extends Service {
public abstract RileyLinkCommunicationManager getDeviceCommunicationManager(); public abstract RileyLinkCommunicationManager getDeviceCommunicationManager();
public abstract boolean handleIncomingServiceTransport(Intent intent);
// Here is where the wake-lock begins: // Here is where the wake-lock begins:
// We've received a service startCommand, we grab the lock. // We've received a service startCommand, we grab the lock.
@Override @Override

View file

@ -1,16 +1,10 @@
package info.nightscout.androidaps.plugins.pump.medtronic; package info.nightscout.androidaps.plugins.pump.medtronic;
import java.util.Date;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import android.app.Activity; import android.app.Activity;
import android.content.Intent; import android.content.Intent;
import android.graphics.Color; import android.graphics.Color;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
import android.os.SystemClock;
import android.text.Spanned; import android.text.Spanned;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
@ -19,14 +13,18 @@ import android.widget.Button;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import android.widget.TextView; import android.widget.TextView;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import com.crashlytics.android.Crashlytics; import com.crashlytics.android.Crashlytics;
import com.joanzapata.iconify.widget.IconTextView; import com.joanzapata.iconify.widget.IconTextView;
import com.squareup.otto.Subscribe; import com.squareup.otto.Subscribe;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Date;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R; import info.nightscout.androidaps.R;
import info.nightscout.androidaps.events.EventExtendedBolusChange; import info.nightscout.androidaps.events.EventExtendedBolusChange;
@ -35,7 +33,6 @@ import info.nightscout.androidaps.events.EventTempBasalChange;
import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.common.SubscriberFragment; import info.nightscout.androidaps.plugins.common.SubscriberFragment;
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin; import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
import info.nightscout.androidaps.plugins.general.overview.dialogs.MessageHelperActivity;
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkUtil; import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkUtil;
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkError; import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkError;
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkServiceState; import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkServiceState;

View file

@ -3,13 +3,11 @@ package info.nightscout.androidaps.plugins.pump.medtronic;
import android.content.ComponentName; import android.content.ComponentName;
import android.content.Intent; import android.content.Intent;
import android.content.ServiceConnection; import android.content.ServiceConnection;
import android.os.Bundle;
import android.os.IBinder; import android.os.IBinder;
import android.os.SystemClock; import android.os.SystemClock;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import org.joda.time.LocalDateTime; import org.joda.time.LocalDateTime;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -24,6 +22,7 @@ import java.util.Locale;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import info.nightscout.androidaps.BuildConfig;
import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R; import info.nightscout.androidaps.R;
import info.nightscout.androidaps.data.DetailedBolusInfo; import info.nightscout.androidaps.data.DetailedBolusInfo;
@ -97,13 +96,9 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
private MedtronicCommunicationManager medtronicCommunicationManager; private MedtronicCommunicationManager medtronicCommunicationManager;
private PumpHistoryEntry lastPumpHistoryEntry; private PumpHistoryEntry lastPumpHistoryEntry;
public static Gson gsonInstance = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create();
public static Gson gsonInstancePretty = new GsonBuilder().excludeFieldsWithoutExposeAnnotation()
.setPrettyPrinting().create();
public static boolean isBusy = false; public static boolean isBusy = false;
private List<Long> busyTimestamps = new ArrayList<>(); private List<Long> busyTimestamps = new ArrayList<>();
private boolean sendIdToFirebase = false; private boolean sentIdToFirebase = false;
private MedtronicPumpPlugin() { private MedtronicPumpPlugin() {
@ -117,12 +112,9 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
PumpType.Medtronic_522_722 // we default to most basic model, correct model from config is loaded later PumpType.Medtronic_522_722 // we default to most basic model, correct model from config is loaded later
); );
// TODO remove this later
displayConnectionMessages = false; displayConnectionMessages = false;
medtronicHistoryData = new MedtronicHistoryData(); medtronicHistoryData = new MedtronicHistoryData();
// medtronicCommunicationManager = MedtronicCommunicationManager.getInstance();
// medtronicCommunicationManager.setDoWakeUpBeforeCommand(false);
serviceConnection = new ServiceConnection() { serviceConnection = new ServiceConnection() {
@ -241,6 +233,8 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
.readStatus("Scheduled Status Refresh", null); .readStatus("Scheduled Status Refresh", null);
} }
} }
clearBusyQueue();
} }
} while (serviceRunning); } while (serviceRunning);
@ -318,7 +312,11 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
} }
private void clearBusyQueue() { private synchronized void clearBusyQueue() {
if (busyTimestamps.size() == 0) {
return;
}
Set<Long> deleteFromQueue = new HashSet<>(); Set<Long> deleteFromQueue = new HashSet<>();
@ -331,8 +329,7 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
if (deleteFromQueue.size() == busyTimestamps.size()) { if (deleteFromQueue.size() == busyTimestamps.size()) {
busyTimestamps.clear(); busyTimestamps.clear();
this.customActionClearBolusBlock.setEnabled(false); setEnableCustomAction(MedtronicCustomActionType.ClearBolusBlock, false);
refreshCustomActionsList();
} }
if (deleteFromQueue.size() > 0) { if (deleteFromQueue.size() > 0) {
@ -541,7 +538,6 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
// read profile (once, later its controlled by isThisProfileSet method) // read profile (once, later its controlled by isThisProfileSet method)
medtronicUIComm.executeCommand(MedtronicCommandType.GetBasalProfileSTD); medtronicUIComm.executeCommand(MedtronicCommandType.GetBasalProfileSTD);
// TODO handle if tunning was needed (more than 5 timeouts)
int errorCount = medtronicUIComm.getInvalidResponsesCount(); int errorCount = medtronicUIComm.getInvalidResponsesCount();
if (errorCount >= 5) { if (errorCount >= 5) {
@ -559,26 +555,15 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
pumpState = PumpDriverState.Initialized; pumpState = PumpDriverState.Initialized;
} }
if (!sendIdToFirebase) { if (!sentIdToFirebase) {
Bundle params = new Bundle();
params.putString("version", BuildConfig.VERSION);
MainApp.getFirebaseAnalytics().logEvent("MedtronicPumpInit", params);
sentIdToFirebase = true;
sendIdToFirebase = true;
} }
// FIXME andy!!!
// MainApp.getFirebaseAnalytics().logCustomEvent(FirebaseAnalytics.Event.SELECT_CONTENT, event);
//
// FabricPrivacy.getInstance().logCustom( //
// new CustomEvent("MedtronicInitializePump") //
// .putCustomAttribute("buildversion", BuildConfig.BUILDVERSION) //
// .putCustomAttribute("version", BuildConfig.VERSION));
//
//
//
// MainApp.getFirebaseAnalytics().logEvent();
//
isInitialized = true; isInitialized = true;
// this.pumpState = PumpDriverState.Initialized; // this.pumpState = PumpDriverState.Initialized;
@ -598,6 +583,7 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
boolean invalid = false; boolean invalid = false;
Double[] basalsByHour = getMDTPumpStatus().basalsByHour; Double[] basalsByHour = getMDTPumpStatus().basalsByHour;
PumpType pumpType = getMDTPumpStatus().getPumpType();
if (isLoggingEnabled()) if (isLoggingEnabled())
LOG.debug("Current Basals (h): " LOG.debug("Current Basals (h): "
@ -612,27 +598,27 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
for (Profile.BasalValue basalValue : profile.getBasalValues()) { for (Profile.BasalValue basalValue : profile.getBasalValues()) {
double basalValueValue = pumpType.determineCorrectBasalSize(basalValue.value);
int hour = basalValue.timeAsSeconds / (60 * 60); int hour = basalValue.timeAsSeconds / (60 * 60);
if (!MedtronicUtil.isSame(basalsByHour[hour], basalValue.value)) { if (!MedtronicUtil.isSame(basalsByHour[hour], basalValueValue)) {
invalid = true; invalid = true;
} }
stringBuilder.append(String.format(Locale.ENGLISH, "%.3f", basalValue.value)); stringBuilder.append(String.format(Locale.ENGLISH, "%.3f", basalValueValue));
stringBuilder.append(" "); stringBuilder.append(" ");
} }
if (isLoggingEnabled()) if (isLoggingEnabled()) {
LOG.debug(stringBuilder.toString()); LOG.debug(stringBuilder.toString());
if (!invalid) { if (!invalid) {
if (isLoggingEnabled())
LOG.debug("Basal profile is same as AAPS one."); LOG.debug("Basal profile is same as AAPS one.");
// basalProfileChanged = false;
} else { } else {
if (isLoggingEnabled())
LOG.debug("Basal profile on Pump is different than the AAPS one."); LOG.debug("Basal profile on Pump is different than the AAPS one.");
} }
}
return (!invalid); return (!invalid);
} }
@ -772,14 +758,13 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
incrementStatistics(detailedBolusInfo.isSMB ? MedtronicConst.Statistics.SMBBoluses incrementStatistics(detailedBolusInfo.isSMB ? MedtronicConst.Statistics.SMBBoluses
: MedtronicConst.Statistics.StandardBoluses); : MedtronicConst.Statistics.StandardBoluses);
// if (response)
{ // calculate time for bolus and set driver to busy for that time
int bolusTime = (int) (detailedBolusInfo.insulin * 42.0d); int bolusTime = (int) (detailedBolusInfo.insulin * 42.0d);
long time = System.currentTimeMillis() + (bolusTime * 1000); long time = System.currentTimeMillis() + (bolusTime * 1000);
this.busyTimestamps.add(time); this.busyTimestamps.add(time);
setEnableCustomAction(MedtronicCustomActionType.ClearBolusBlock, true); setEnableCustomAction(MedtronicCustomActionType.ClearBolusBlock, true);
}
return new PumpEnactResult().success(true) // return new PumpEnactResult().success(true) //
.enacted(true) // .enacted(true) //
@ -975,8 +960,8 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
private void readPumpHistory() { private void readPumpHistory() {
if (isLoggingEnabled()) // if (isLoggingEnabled())
LOG.error(getLogPrefix() + "readPumpHistory WIP."); // LOG.error(getLogPrefix() + "readPumpHistory WIP.");
readPumpHistoryLogic(); readPumpHistoryLogic();
@ -1131,7 +1116,7 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
switch (refreshType) { switch (refreshType) {
case RemainingInsulin: { case RemainingInsulin: {
Double remaining = pumpStatusLocal.reservoirRemainingUnits; double remaining = pumpStatusLocal.reservoirRemainingUnits;
int min; int min;
if (remaining > 50) if (remaining > 50)
min = 4 * 60; min = 4 * 60;
@ -1171,10 +1156,7 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
} }
case GetData: { case GetData: {
Map<MedtronicStatusRefreshType, Long> shallowCopy = new HashMap<>(); return new HashMap<>(statusRefreshMap);
shallowCopy.putAll(statusRefreshMap);
return shallowCopy;
} }
default: default:

View file

@ -1,14 +1,14 @@
package info.nightscout.androidaps.plugins.pump.medtronic.comm; package info.nightscout.androidaps.plugins.pump.medtronic.comm;
import java.util.List; import android.content.Context;
import java.util.Map; import android.os.SystemClock;
import org.joda.time.LocalDateTime; import org.joda.time.LocalDateTime;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import android.content.Context; import java.util.List;
import android.os.SystemClock; import java.util.Map;
import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkCommunicationManager; import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkCommunicationManager;
@ -51,6 +51,7 @@ import info.nightscout.androidaps.utils.SP;
* Original file created by geoff on 5/30/16. * Original file created by geoff on 5/30/16.
* <p> * <p>
* Split into 2 implementations, so that we can split it by target device. - Andy * Split into 2 implementations, so that we can split it by target device. - Andy
* This was mostly rewritten from Original version
*/ */
public class MedtronicCommunicationManager extends RileyLinkCommunicationManager { public class MedtronicCommunicationManager extends RileyLinkCommunicationManager {
@ -66,8 +67,6 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
private MedtronicPumpHistoryDecoder pumpHistoryDecoder; private MedtronicPumpHistoryDecoder pumpHistoryDecoder;
private boolean doWakeUpBeforeCommand = true; private boolean doWakeUpBeforeCommand = true;
private boolean firstConnection = true;
private boolean medtronicHistoryTesting = false; // TODO remove when not needed
public MedtronicCommunicationManager(Context context, RFSpy rfspy) { public MedtronicCommunicationManager(Context context, RFSpy rfspy) {
@ -202,9 +201,6 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
else else
MedtronicUtil.setPumpDeviceState(PumpDeviceState.Sleeping); MedtronicUtil.setPumpDeviceState(PumpDeviceState.Sleeping);
// if (firstConnection)
// checkFirstConnectionTime();
rememberLastGoodDeviceCommunicationTime(); rememberLastGoodDeviceCommunicationTime();
return true; return true;
@ -269,7 +265,6 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
} }
private PumpMessage runCommandWithFrames(MedtronicCommandType commandType, List<List<Byte>> frames) private PumpMessage runCommandWithFrames(MedtronicCommandType commandType, List<List<Byte>> frames)
throws RileyLinkCommunicationException { throws RileyLinkCommunicationException {
@ -341,7 +336,7 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
MedtronicUtil.setPumpDeviceState(PumpDeviceState.Active); MedtronicUtil.setPumpDeviceState(PumpDeviceState.Active);
boolean doneWithError = false; boolean doneWithError = false;
for (int pageNumber = 0; pageNumber < 16; pageNumber++) { for (int pageNumber = 0; pageNumber < 5; pageNumber++) {
RawHistoryPage rawHistoryPage = new RawHistoryPage(); RawHistoryPage rawHistoryPage = new RawHistoryPage();
// wakeUp(receiverDeviceAwakeForMinutes, false); // wakeUp(receiverDeviceAwakeForMinutes, false);
@ -472,8 +467,6 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
doneWithError = true; doneWithError = true;
} }
// TODO handle error states
if (doneWithError) { if (doneWithError) {
MedtronicUtil.setPumpDeviceState(PumpDeviceState.Sleeping); MedtronicUtil.setPumpDeviceState(PumpDeviceState.Sleeping);
return pumpTotalResult; return pumpTotalResult;
@ -487,7 +480,6 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
if (isLogEnabled()) if (isLogEnabled())
LOG.debug("getPumpHistory: Found {} history entries.", medtronicHistoryEntries.size()); LOG.debug("getPumpHistory: Found {} history entries.", medtronicHistoryEntries.size());
// PumpHistoryResult pumpHistoryResult = new PumpHistoryResult(lastEntry, targetDate);
pumpTotalResult.addHistoryEntries(medtronicHistoryEntries); pumpTotalResult.addHistoryEntries(medtronicHistoryEntries);
if (isLogEnabled()) if (isLogEnabled())
@ -498,7 +490,6 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
return pumpTotalResult; return pumpTotalResult;
} }
} }
MedtronicUtil.setPumpDeviceState(PumpDeviceState.Sleeping); MedtronicUtil.setPumpDeviceState(PumpDeviceState.Sleeping);
@ -508,7 +499,6 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
} }
public String getErrorResponse() { public String getErrorResponse() {
return this.errorMessage; return this.errorMessage;
} }
@ -934,7 +924,6 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
} }
// LOG.debug("Set Basal Profile: {}", HexDump.toHexStringDisplayable(responseMessage.getRawContent())); // LOG.debug("Set Basal Profile: {}", HexDump.toHexStringDisplayable(responseMessage.getRawContent()));
} }
return false; return false;
@ -942,13 +931,6 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
} }
public PumpMessage cancelBolus() {
// ? maybe suspend and resume
return null;
}
private boolean isLogEnabled() { private boolean isLogEnabled() {
return L.isEnabled(L.PUMPCOMM); return L.isEnabled(L.PUMPCOMM);
} }

View file

@ -1,14 +1,13 @@
package info.nightscout.androidaps.plugins.pump.medtronic.comm; package info.nightscout.androidaps.plugins.pump.medtronic.comm;
import java.util.HashMap;
import java.util.Map;
import org.joda.time.IllegalFieldValueException; import org.joda.time.IllegalFieldValueException;
import org.joda.time.LocalDateTime; import org.joda.time.LocalDateTime;
import org.joda.time.LocalTime;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.util.HashMap;
import java.util.Map;
import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.pump.common.utils.ByteUtil; import info.nightscout.androidaps.plugins.pump.common.utils.ByteUtil;
import info.nightscout.androidaps.plugins.pump.common.utils.HexDump; import info.nightscout.androidaps.plugins.pump.common.utils.HexDump;
@ -24,6 +23,7 @@ import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicUtil;
/** /**
* Created by andy on 5/9/18. * Created by andy on 5/9/18.
* High level decoder for data returned through MedtroniUIComm
*/ */
public class MedtronicConverter { public class MedtronicConverter {
@ -117,41 +117,6 @@ public class MedtronicConverter {
} }
protected BasalProfile decodeProfile2(byte[] rep) {
// byte rep[] = minimedReply.getRawData();
// String profile = getProfileName(minimedReply);
BasalProfile basalProfile = new BasalProfile();
// 0x12 0x00 0x00 0x16 0x00 0x11 0x00
if ((rep.length >= 3) && (rep[2] == 0x3F)) {
// String i18value = i18nControl.getMessage("NOT_SET");
// writeSetting(key, i18value, i18value, PumpConfigurationGroup.Basal);
return null;
}
int time_x;
double vald;
for (int i = 0; i < rep.length; i += 3) {
vald = MedtronicUtil.decodeBasalInsulin(rep[i + 1], rep[i]);
time_x = rep[i + 2];
LocalTime atd = MedtronicUtil.getTimeFrom30MinInterval(time_x);
if ((i != 0) && (time_x == 0)) {
break;
}
}
return basalProfile;
}
private BatteryStatusDTO decodeBatteryStatus(byte[] rawData) { private BatteryStatusDTO decodeBatteryStatus(byte[] rawData) {
// 00 7C 00 00 // 00 7C 00 00
@ -170,8 +135,6 @@ public class MedtronicConverter {
if (rawData.length > 1) { if (rawData.length > 1) {
// if response in 3 bytes then we add additional information // if response in 3 bytes then we add additional information
// double d = MedtronicUtil.makeUnsignedShort(rawData[2], rawData[1]) / 100.0d;
double d = (ByteUtil.toInt(rawData[1], rawData[2]) * 1.0d) / 100.0d; double d = (ByteUtil.toInt(rawData[1], rawData[2]) * 1.0d) / 100.0d;
batteryStatus.voltage = d; batteryStatus.voltage = d;

View file

@ -1,5 +1,7 @@
package info.nightscout.androidaps.plugins.pump.medtronic.comm.history.pump; package info.nightscout.androidaps.plugins.pump.medtronic.comm.history.pump;
import android.util.Log;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -35,6 +37,7 @@ public class MedtronicPumpHistoryDecoder extends MedtronicHistoryDecoder<PumpHis
private PumpHistoryEntry tbrPreviousRecord; private PumpHistoryEntry tbrPreviousRecord;
private PumpHistoryEntry changeTimeRecord; private PumpHistoryEntry changeTimeRecord;
private MedtronicDeviceType deviceType; private MedtronicDeviceType deviceType;
private static final String TAG = "MdtPumpHistoryDecoder";
public MedtronicPumpHistoryDecoder() { public MedtronicPumpHistoryDecoder() {
@ -54,7 +57,7 @@ public class MedtronicPumpHistoryDecoder extends MedtronicHistoryDecoder<PumpHis
int elementStart = 0; int elementStart = 0;
if (dataClear.size() == 0) { if (dataClear.size() == 0) {
LOG.error("Empty page."); Log.e(TAG, "Empty page.");
return outList; return outList;
} }
@ -72,7 +75,7 @@ public class MedtronicPumpHistoryDecoder extends MedtronicHistoryDecoder<PumpHis
continue; continue;
} else { } else {
if (skipped != null) { if (skipped != null) {
LOG.debug(" ... Skipped " + skipped); Log.w(TAG, " ... Skipped " + skipped);
skipped = null; skipped = null;
} }
} }
@ -142,16 +145,12 @@ public class MedtronicPumpHistoryDecoder extends MedtronicHistoryDecoder<PumpHis
RecordDecodeStatus decoded = decodeRecord(pe); RecordDecodeStatus decoded = decodeRecord(pe);
if (decoded == RecordDecodeStatus.WIP) { if ((decoded == RecordDecodeStatus.OK) || (decoded == RecordDecodeStatus.Ignored)) {
LOG.warn("#" + record + " " + decoded.getDescription() + " " + pe); Log.i(TAG, "#" + record + " " + decoded.getDescription() + " " + pe);
} else {
Log.w(TAG, "#" + record + " " + decoded.getDescription() + " " + pe);
} }
// if ((decoded == RecordDecodeStatus.OK) || (decoded == RecordDecodeStatus.Ignored)) {
// LOG.info("#" + record + " " + decoded.getDescription() + " " + pe);
// } else {
// LOG.warn("#" + record + " " + decoded.getDescription() + " " + pe);
// }
addToStatistics(pe, decoded, null); addToStatistics(pe, decoded, null);
record++; record++;

View file

@ -8,7 +8,7 @@ import info.nightscout.androidaps.R;
/** /**
* This file was taken from GGC - GNU Gluco Control and modified/extended for AAPS. * This file was taken from GGC - GNU Gluco Control and modified/extended for AAPS.
* * <p>
* Author: Andy {andy.rozman@gmail.com} * Author: Andy {andy.rozman@gmail.com}
*/ */
@ -37,9 +37,9 @@ public enum PumpHistoryEntryGroup {
list = new ArrayList<>(); list = new ArrayList<>();
for (PumpHistoryEntryGroup pumpHistoryEntryGroup : values()) { for (PumpHistoryEntryGroup pumpHistoryEntryGroup : values()) {
if (doNotTranslate) { //if (doNotTranslate) {
pumpHistoryEntryGroup.translated = MainApp.gs(pumpHistoryEntryGroup.resourceId); pumpHistoryEntryGroup.translated = MainApp.gs(pumpHistoryEntryGroup.resourceId);
} //}
list.add(pumpHistoryEntryGroup); list.add(pumpHistoryEntryGroup);
} }
} }

View file

@ -120,7 +120,7 @@ public enum PumpHistoryEntryType // implements CodeEnum
BolusReminder(0x69, "Bolus Reminder", PumpHistoryEntryGroup.Configuration, 2, 5, 0), // Ian69 BolusReminder(0x69, "Bolus Reminder", PumpHistoryEntryGroup.Configuration, 2, 5, 0), // Ian69
DeleteAlarmClockTime(0x6a, "Delete Alarm Clock Time", PumpHistoryEntryGroup.Configuration, 2, 5, 7), // 14 DeleteAlarmClockTime(0x6a, "Delete Alarm Clock Time", PumpHistoryEntryGroup.Configuration, 2, 5, 7), // 14
DailyTotals515(0x6c, "Daily Totals (515)", PumpHistoryEntryGroup.Statistic, 1, 2, 33), // v4: 0,0,36. v5: 1,2,33 DailyTotals515(0x6c, "Daily Totals (515)", PumpHistoryEntryGroup.Statistic, 1, 2, 35), // v4: 0,0,36. v5: 1,2,33
DailyTotals522(0x6d, "Daily Totals (522)", PumpHistoryEntryGroup.Statistic, 1, 2, 41), // DailyTotals522(0x6d, "Daily Totals (522)", PumpHistoryEntryGroup.Statistic, 1, 2, 41), //
DailyTotals523(0x6e, "Daily Totals (523)", PumpHistoryEntryGroup.Statistic, 1, 2, 49), // 1102014-03-17T00:00:00 DailyTotals523(0x6e, "Daily Totals (523)", PumpHistoryEntryGroup.Statistic, 1, 2, 49), // 1102014-03-17T00:00:00
ChangeCarbUnits((byte) 0x6f, "Change Carb Units", PumpHistoryEntryGroup.Configuration), // ChangeCarbUnits((byte) 0x6f, "Change Carb Units", PumpHistoryEntryGroup.Configuration), //

View file

@ -5,12 +5,6 @@ import info.nightscout.androidaps.plugins.pump.common.utils.HexDump;
/** /**
* Created by geoff on 5/29/16. * Created by geoff on 5/29/16.
*/ */
// Andy (4.6.2018): We probably need rewrite of this message body code. If there is no data sent, body is 00, which
// denotes,
// no parameters. If we have 3 parameters sent (1 2 3), the body would actually be length of 4, first byte being the
// length
// of the message, so the body would be 3 1 2 3. This is not done that way now.
public class MessageBody { public class MessageBody {
public int getLength() { public int getLength() {

View file

@ -46,13 +46,6 @@ public class PumpMessage implements RLMessage {
} }
// public void init(PacketType packetType, byte[] address, MessageType messageType, MessageBody messageBody) {
// this.packetType = packetType;
// this.address = address;
// this.messageType = messageType;
// this.messageBody = messageBody;
// }
public void init(PacketType packetType, byte[] address, MedtronicCommandType commandType, MessageBody messageBody) { public void init(PacketType packetType, byte[] address, MedtronicCommandType commandType, MessageBody messageBody) {
this.packetType = packetType; this.packetType = packetType;
this.address = address; this.address = address;
@ -132,9 +125,9 @@ public class PumpMessage implements RLMessage {
System.arraycopy(messageBody.getTxData(), 1, arrayOut, 0, length); System.arraycopy(messageBody.getTxData(), 1, arrayOut, 0, length);
if (isLogEnabled()) // if (isLogEnabled())
LOG.debug("PumpMessage - Length: " + length + ", Original Length: " + originalLength + ", CommandType: " // LOG.debug("PumpMessage - Length: " + length + ", Original Length: " + originalLength + ", CommandType: "
+ commandType); // + commandType);
return arrayOut; return arrayOut;
} }

View file

@ -13,7 +13,6 @@ import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicUtil;
/** /**
* Created by andy on 6/14/18. * Created by andy on 6/14/18.
*/ */
public class MedtronicUIComm { public class MedtronicUIComm {
private static final Logger LOG = LoggerFactory.getLogger(L.PUMP); private static final Logger LOG = LoggerFactory.getLogger(L.PUMP);
@ -68,10 +67,8 @@ public class MedtronicUIComm {
// } // }
// } // }
if (!task.isReceived()) { if (!task.isReceived() && isLogEnabled()) {
if (isLogEnabled())
LOG.warn("Reply not received for " + commandType); LOG.warn("Reply not received for " + commandType);
} }
task.postProcess(uiPostprocessor); task.postProcess(uiPostprocessor);

View file

@ -1,15 +1,13 @@
package info.nightscout.androidaps.plugins.pump.medtronic.comm.ui; package info.nightscout.androidaps.plugins.pump.medtronic.comm.ui;
import static info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicUtil.sendNotification;
import java.util.Date;
import java.util.Map;
import org.joda.time.DateTimeZone; import org.joda.time.DateTimeZone;
import org.joda.time.Duration; import org.joda.time.Duration;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.util.Date;
import java.util.Map;
import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.pump.medtronic.data.dto.BasalProfile; import info.nightscout.androidaps.plugins.pump.medtronic.data.dto.BasalProfile;
import info.nightscout.androidaps.plugins.pump.medtronic.data.dto.BatteryStatusDTO; import info.nightscout.androidaps.plugins.pump.medtronic.data.dto.BatteryStatusDTO;
@ -21,6 +19,8 @@ import info.nightscout.androidaps.plugins.pump.medtronic.defs.MedtronicUIRespons
import info.nightscout.androidaps.plugins.pump.medtronic.driver.MedtronicPumpStatus; import info.nightscout.androidaps.plugins.pump.medtronic.driver.MedtronicPumpStatus;
import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicUtil; import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicUtil;
import static info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicUtil.sendNotification;
/** /**
* Created by andy on 6/15/18. * Created by andy on 6/15/18.
*/ */
@ -41,11 +41,6 @@ public class MedtronicUIPostprocessor {
// where responses won't be directly used // where responses won't be directly used
public void postProcessData(MedtronicUITask uiTask) { public void postProcessData(MedtronicUITask uiTask) {
// if (!uiTask.haveData()) {
// LOG.error("Error reading data [{}]: {}", uiTask.commandType, uiTask.errorDescription);
// return;
// }
switch (uiTask.commandType) { switch (uiTask.commandType) {
case SetBasalProfileSTD: { case SetBasalProfileSTD: {

View file

@ -89,16 +89,6 @@ public class MedtronicUITask {
} }
break; break;
// case PumpState: {
// // TODO maybe remove this, data returned is almost useless
// returnData = communicationManager.getPumpState();
// }
// break;
// case "RefreshData.GetBolus": {
// returnData = communicationManager.getBolusStatus();
// }
// break;
case Settings: case Settings:
case Settings_512: { case Settings_512: {
@ -115,7 +105,6 @@ public class MedtronicUITask {
break; break;
case CancelTBR: { case CancelTBR: {
// FIXME check if TBR is actually running
returnData = communicationManager.cancelTBR(); returnData = communicationManager.cancelTBR();
} }
break; break;
@ -156,11 +145,9 @@ public class MedtronicUITask {
private TempBasalPair getTBRSettings() { private TempBasalPair getTBRSettings() {
TempBasalPair tempBasalPair = new TempBasalPair(getDoubleFromParameters(0), // return new TempBasalPair(getDoubleFromParameters(0), //
false, // false, //
getIntegerFromParameters(1)); getIntegerFromParameters(1));
return tempBasalPair;
} }

View file

@ -40,6 +40,7 @@ import info.nightscout.androidaps.plugins.pump.medtronic.data.dto.BolusWizardDTO
import info.nightscout.androidaps.plugins.pump.medtronic.data.dto.ClockDTO; import info.nightscout.androidaps.plugins.pump.medtronic.data.dto.ClockDTO;
import info.nightscout.androidaps.plugins.pump.medtronic.data.dto.DailyTotalsDTO; import info.nightscout.androidaps.plugins.pump.medtronic.data.dto.DailyTotalsDTO;
import info.nightscout.androidaps.plugins.pump.medtronic.data.dto.TempBasalPair; import info.nightscout.androidaps.plugins.pump.medtronic.data.dto.TempBasalPair;
import info.nightscout.androidaps.plugins.pump.medtronic.data.dto.TempBasalProcessDTO;
import info.nightscout.androidaps.plugins.pump.medtronic.driver.MedtronicPumpStatus; import info.nightscout.androidaps.plugins.pump.medtronic.driver.MedtronicPumpStatus;
import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicConst; import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicConst;
import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicUtil; import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicUtil;
@ -52,7 +53,7 @@ import info.nightscout.androidaps.utils.SP;
/** /**
* Created by andy on 10/12/18. * Created by andy on 10/12/18.
*/ */
// TODO clean up this class (remove/comment logs)
public class MedtronicHistoryData { public class MedtronicHistoryData {
private static final Logger LOG = LoggerFactory.getLogger(L.PUMP); private static final Logger LOG = LoggerFactory.getLogger(L.PUMP);
@ -66,7 +67,8 @@ public class MedtronicHistoryData {
private Gson gsonPretty; private Gson gsonPretty;
//private List<PumpHistoryEntry> fakeTBRs; //private List<PumpHistoryEntry> fakeTBRs;
DatabaseHelper databaseHelper = MainApp.getDbHelper(); private DatabaseHelper databaseHelper = MainApp.getDbHelper();
private ClockDTO pumpTime;
public MedtronicHistoryData() { public MedtronicHistoryData() {
@ -99,7 +101,7 @@ public class MedtronicHistoryData {
this.newHistory = newEntries; this.newHistory = newEntries;
showLogs("List of history (before filtering): ", gsonPretty.toJson(this.newHistory)); showLogs("List of history (before filtering): [" + this.newHistory.size() + "]", gsonPretty.toJson(this.newHistory));
} }
@ -176,7 +178,7 @@ public class MedtronicHistoryData {
if (isLogEnabled()) if (isLogEnabled())
LOG.debug("New History entries found: {}", this.newHistory.size()); LOG.debug("New History entries found: {}", this.newHistory.size());
showLogs("List of history (after filtering): ", gsonPretty.toJson(this.newHistory)); showLogs("List of history (after filtering): [" + this.newHistory.size() + "]", gsonPretty.toJson(this.newHistory));
} }
@ -404,8 +406,6 @@ public class MedtronicHistoryData {
} }
} }
ClockDTO pumpTime;
private void processTDDs(List<PumpHistoryEntry> tddsIn) { private void processTDDs(List<PumpHistoryEntry> tddsIn) {

View file

@ -12,7 +12,5 @@ public class ClockDTO {
public LocalDateTime pumpTime; public LocalDateTime pumpTime;
// public Duration timeDifference;
public int timeDifference; // s (pump -> local) public int timeDifference; // s (pump -> local)
} }

View file

@ -1,13 +1,13 @@
package info.nightscout.androidaps.plugins.pump.medtronic.data.dto; package info.nightscout.androidaps.plugins.pump.medtronic.data.dto;
import java.util.ArrayList; import com.google.gson.annotations.Expose;
import java.util.List;
import java.util.Locale;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import com.google.gson.annotations.Expose; import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.pump.common.utils.ByteUtil; import info.nightscout.androidaps.plugins.pump.common.utils.ByteUtil;
@ -112,7 +112,6 @@ public class TempBasalPair {
public byte[] getAsRawData() { public byte[] getAsRawData() {
// TODO check if this works with 523 and higher
List<Byte> list = new ArrayList<Byte>(); List<Byte> list = new ArrayList<Byte>();
list.add((byte) 5); list.add((byte) 5);

View file

@ -1,11 +1,16 @@
package info.nightscout.androidaps.plugins.pump.medtronic.data.dto; package info.nightscout.androidaps.plugins.pump.medtronic.data.dto;
import info.nightscout.androidaps.plugins.pump.medtronic.comm.history.pump.PumpHistoryEntry;
public class TempBasalProcessDTO { public class TempBasalProcessDTO {
public PumpHistoryEntry itemOne;
public PumpHistoryEntry itemTwo;
public Operation processOperation = Operation.None;
public static enum Operation {
static enum Operation {
None, None,
Add, Add,
Edit Edit

View file

@ -11,42 +11,37 @@ import info.nightscout.androidaps.plugins.pump.medtronic.comm.message.UnknownMes
/** /**
* Taken from GNU Gluco Control diabetes management software (ggc.sourceforge.net) * Taken from GNU Gluco Control diabetes management software (ggc.sourceforge.net)
* * <p>
* Description: Medtronic Commands (Pump and CGMS) for all 512 and later models (just 5xx) * Description: Medtronic Commands (Pump and CGMS) for all 512 and later models (just 5xx)
* * <p>
* Link to original/unmodified file: * Link to original/unmodified file:
* https://sourceforge.net/p/ggc/code/HEAD/tree/trunk/ggc-plugins/ggc-plugins-base/src/ * https://sourceforge.net/p/ggc/code/HEAD/tree/trunk/ggc-plugins/ggc-plugins-base/src/
* main/java/ggc/plugin/device/impl/minimed/enums/MinimedCommandType.java * main/java/ggc/plugin/device/impl/minimed/enums/MinimedCommandType.java
* * <p>
* A lot of stuff has been removed because it is not needed anymore (historical stuff from CareLink * A lot of stuff has been removed because it is not needed anymore (historical stuff from CareLink
* and Carelink USB communication. * and Carelink USB communication.
* * <p>
* Author: Andy {andy@atech-software.com} * Author: Andy {andy@atech-software.com}
*/ */
// FIXME: AAPS - a lot of this can be removed. Do cleanup.
// Lot of stuff in here is legacy stuff for CareLink(1). We should remove it in
// future.
public enum MedtronicCommandType implements Serializable // , MinimedCommandTypeInterface public enum MedtronicCommandType implements Serializable // , MinimedCommandTypeInterface
{ {
InvalidCommand(0, "Invalid Command", null, null, null), // InvalidCommand(0, "Invalid Command", null, null), //
// Pump Responses (9) // Pump Responses (9)
CommandACK(0x06, "ACK - Acknowledge", MinimedTargetType.ActionCommand, MedtronicDeviceType.All, MinimedCommandParameterType.NoParameters), // CommandACK(0x06, "ACK - Acknowledge", MedtronicDeviceType.All, MinimedCommandParameterType.NoParameters), //
CommandNAK(0x15, "NAK - Not Acknowledged", MinimedTargetType.ActionCommand, MedtronicDeviceType.All, MinimedCommandParameterType.NoParameters), // CommandNAK(0x15, "NAK - Not Acknowledged", MedtronicDeviceType.All, MinimedCommandParameterType.NoParameters), //
// All (8) // All (8)
PushAck(91, "Push ACK", MinimedTargetType.ActionCommand, MedtronicDeviceType.All, MinimedCommandParameterType.FixedParameters, getByteArray(2)), // PushAck(91, "Push ACK", MedtronicDeviceType.All, MinimedCommandParameterType.FixedParameters, getByteArray(2)), //
PushEsc(91, "Push Esc", MinimedTargetType.ActionCommand, MedtronicDeviceType.All, MinimedCommandParameterType.FixedParameters, getByteArray(1)), // PushEsc(91, "Push Esc", MedtronicDeviceType.All, MinimedCommandParameterType.FixedParameters, getByteArray(1)), //
PushButton(0x5b, "Push Button", MinimedTargetType.ActionCommand, MedtronicDeviceType.All, MinimedCommandParameterType.NoParameters), // 91 PushButton(0x5b, "Push Button", MedtronicDeviceType.All, MinimedCommandParameterType.NoParameters), // 91
RFPowerOn(93, "RF Power On", MinimedTargetType.InitCommand, MedtronicDeviceType.All, MinimedCommandParameterType.FixedParameters, getByteArray( RFPowerOn(93, "RF Power On", MedtronicDeviceType.All, MinimedCommandParameterType.FixedParameters, getByteArray(
1, 10)), // 1, 10)), //
RFPowerOff(93, "RF Power Off", MinimedTargetType.InitCommand, MedtronicDeviceType.All, MinimedCommandParameterType.FixedParameters, getByteArray( RFPowerOff(93, "RF Power Off", MedtronicDeviceType.All, MinimedCommandParameterType.FixedParameters, getByteArray(
0, 0)), // 0, 0)), //
// SetSuspend(77, "Set Suspend", MinimedTargetType.InitCommand, MedtronicDeviceType.All, // SetSuspend(77, "Set Suspend", MinimedTargetType.InitCommand, MedtronicDeviceType.All,
@ -55,13 +50,13 @@ public enum MedtronicCommandType implements Serializable // , MinimedCommandType
// CancelSuspend(77, "Cancel Suspend", MinimedTargetType.InitCommand, MedtronicDeviceType.All, // CancelSuspend(77, "Cancel Suspend", MinimedTargetType.InitCommand, MedtronicDeviceType.All,
// MinimedCommandParameterType.FixedParameters, getByteArray(0)), // // MinimedCommandParameterType.FixedParameters, getByteArray(0)), //
PumpState(131, "Pump State", MinimedTargetType.InitCommand, MedtronicDeviceType.All, MinimedCommandParameterType.NoParameters), // PumpState(131, "Pump State", MedtronicDeviceType.All, MinimedCommandParameterType.NoParameters), //
ReadPumpErrorStatus(117, "Pump Error Status", MinimedTargetType.InitCommand, MedtronicDeviceType.All, MinimedCommandParameterType.NoParameters), // ReadPumpErrorStatus(117, "Pump Error Status", MedtronicDeviceType.All, MinimedCommandParameterType.NoParameters), //
// 511 (InitCommand = 2, Config 7, Data = 1(+3) // 511 (InitCommand = 2, Config 7, Data = 1(+3)
DetectBolus(75, "Detect Bolus", MinimedTargetType.InitCommand, MedtronicDeviceType.Medtronic_511, MinimedCommandParameterType.FixedParameters, getByteArray( // DetectBolus(75, "Detect Bolus", MedtronicDeviceType.Medtronic_511, MinimedCommandParameterType.FixedParameters, getByteArray(
0, 0, 0)), // // 0, 0, 0)), //
// RemoteControlIds(118, "Remote Control Ids", MinimedTargetType.PumpConfiguration_NA, MedtronicDeviceType.All, // RemoteControlIds(118, "Remote Control Ids", MinimedTargetType.PumpConfiguration_NA, MedtronicDeviceType.All,
// MinimedCommandParameterType.NoParameters), // // MinimedCommandParameterType.NoParameters), //
@ -75,10 +70,10 @@ public enum MedtronicCommandType implements Serializable // , MinimedCommandType
RealTimeClock(112, "Real Time Clock", MedtronicDeviceType.All, MinimedCommandParameterType.NoParameters, // RealTimeClock(112, "Real Time Clock", MedtronicDeviceType.All, MinimedCommandParameterType.NoParameters, //
7, R.string.medtronic_cmd_desc_get_time), // 0x70 7, R.string.medtronic_cmd_desc_get_time), // 0x70
GetBatteryStatus(0x72, "Get Battery Status", MinimedTargetType.PumpConfiguration, MedtronicDeviceType.All, MinimedCommandParameterType.NoParameters), // GetBatteryStatus(0x72, "Get Battery Status", MedtronicDeviceType.All, MinimedCommandParameterType.NoParameters), //
// GetBattery((byte) 0x72), // // GetBattery((byte) 0x72), //
GetRemainingInsulin(0x73, "Read Remaining Insulin", MinimedTargetType.PumpConfiguration, MedtronicDeviceType.All, MinimedCommandParameterType.NoParameters, 2), // 115 GetRemainingInsulin(0x73, "Read Remaining Insulin", MedtronicDeviceType.All, MinimedCommandParameterType.NoParameters, 2), // 115
SetBolus(0x42, "Set Bolus", MedtronicDeviceType.All, MinimedCommandParameterType.NoParameters, // SetBolus(0x42, "Set Bolus", MedtronicDeviceType.All, MinimedCommandParameterType.NoParameters, //
0, R.string.medtronic_cmd_desc_set_bolus), // 66 0, R.string.medtronic_cmd_desc_set_bolus), // 66
@ -141,7 +136,7 @@ public enum MedtronicCommandType implements Serializable // , MinimedCommandType
64, 3, 192, R.string.medtronic_cmd_desc_set_basal_profile), // 49 64, 3, 192, R.string.medtronic_cmd_desc_set_basal_profile), // 49
// 515 // 515
PumpStatus(206, "Pump Status", MinimedTargetType.InitCommand, MedtronicDeviceType.Medtronic_515andHigher, MinimedCommandParameterType.NoParameters), // PumpConfiguration PumpStatus(206, "Pump Status", MedtronicDeviceType.Medtronic_515andHigher, MinimedCommandParameterType.NoParameters), // PumpConfiguration
Settings(192, "Configuration", MedtronicDeviceType.Medtronic_515andHigher, MinimedCommandParameterType.NoParameters, // Settings(192, "Configuration", MedtronicDeviceType.Medtronic_515andHigher, MinimedCommandParameterType.NoParameters, //
64, 1, 0, R.string.medtronic_cmd_desc_get_settings), // 64, 1, 0, R.string.medtronic_cmd_desc_get_settings), //
@ -152,7 +147,7 @@ public enum MedtronicCommandType implements Serializable // , MinimedCommandType
GlucoseHistory(154, "Glucose History", MedtronicDeviceType.Medtronic_522andHigher, MinimedCommandParameterType.SubCommands, 1024, 32, 0, null), // GlucoseHistory(154, "Glucose History", MedtronicDeviceType.Medtronic_522andHigher, MinimedCommandParameterType.SubCommands, 1024, 32, 0, null), //
// 523 // 523
SensorSettings(207, "Sensor Configuration", MinimedTargetType.CGMSConfiguration, MedtronicDeviceType.Medtronic_523andHigher, MinimedCommandParameterType.NoParameters), // SensorSettings(207, "Sensor Configuration", MedtronicDeviceType.Medtronic_523andHigher, MinimedCommandParameterType.NoParameters), //
// 553 // 553
// 554 // 554
@ -177,7 +172,8 @@ public enum MedtronicCommandType implements Serializable // , MinimedCommandType
// Fake Commands // Fake Commands
CancelTBR(), ; CancelTBR(),
;
static Map<Byte, MedtronicCommandType> mapByCode; static Map<Byte, MedtronicCommandType> mapByCode;
@ -206,7 +202,7 @@ public enum MedtronicCommandType implements Serializable // , MinimedCommandType
public MinimedCommandParameterType parameterType; public MinimedCommandParameterType parameterType;
public int minimalBufferSizeToStartReading = 14; public int minimalBufferSizeToStartReading = 14;
public int expectedLength = 0; public int expectedLength = 0;
MinimedTargetType targetType; //MinimedTargetType targetType;
MedtronicDeviceType devices; MedtronicDeviceType devices;
private int recordLength = 64; private int recordLength = 64;
@ -216,49 +212,41 @@ public enum MedtronicCommandType implements Serializable // , MinimedCommandType
} }
MedtronicCommandType(int code, String description, MinimedTargetType targetType, MedtronicDeviceType devices, // MedtronicCommandType(int code, String description, MedtronicDeviceType devices,
MinimedCommandParameterType parameterType) { // MinimedCommandParameterType parameterType) {
this(code, description, targetType, devices, parameterType, 64, 1, 0, 0, 0, 0); // this(code, description, devices, parameterType, 64, 1, 0, 0, 0, 0);
} // }
//
//
MedtronicCommandType(int code, String description, MinimedTargetType targetType, MedtronicDeviceType devices, // MedtronicCommandType(int code, String description, MedtronicDeviceType devices,
MinimedCommandParameterType parameterType, int expectedLength) { // MinimedCommandParameterType parameterType, int expectedLength) {
this(code, description, targetType, devices, parameterType, 64, 1, 0, 0, 0, expectedLength); // this(code, description, devices, parameterType, 64, 1, 0, 0, 0, expectedLength);
} // }
//
//
MedtronicCommandType(int code, String description, MinimedTargetType targetType, MedtronicDeviceType devices, // MedtronicCommandType(int code, String description, MedtronicDeviceType devices,
MinimedCommandParameterType parameterType, int recordLength, int maxRecords, int commandType) { // MinimedCommandParameterType parameterType, int recordLength, int maxRecords, int commandType) {
this(code, description, targetType, devices, parameterType, recordLength, maxRecords, 0, 0, commandType, 0); // this(code, description, devices, parameterType, recordLength, maxRecords, 0, 0, commandType, 0);
} // }
//
//
MedtronicCommandType(int code, String description, MinimedTargetType targetType, MedtronicDeviceType devices, // MedtronicCommandType(int code, String description, MedtronicDeviceType devices,
MinimedCommandParameterType parameterType, int recordLength, int maxRecords, int commandType, // MinimedCommandParameterType parameterType, int recordLength, int maxRecords, int commandType,
int expectedLength) { // int expectedLength) {
this(code, description, targetType, devices, parameterType, recordLength, maxRecords, 0, 0, commandType, // this(code, description, devices, parameterType, recordLength, maxRecords, 0, 0, commandType,
expectedLength); // expectedLength);
} // }
//
//
MedtronicCommandType(int code, String description, MinimedTargetType targetType, MedtronicDeviceType devices, MedtronicCommandType(int code, String description, MedtronicDeviceType devices,
MinimedCommandParameterType parameterType, byte[] cmd_params) { MinimedCommandParameterType parameterType, byte[] cmd_params) {
this(code, description, targetType, devices, parameterType, 0, 1, 0, 0, 11, 0); this(code, description, devices, parameterType, 0, 1, 0, 0, 11, 0);
this.commandParameters = cmd_params; this.commandParameters = cmd_params;
this.commandParametersCount = cmd_params.length; this.commandParametersCount = cmd_params.length;
} }
// MedtronicCommandType(int code, String description, MinimedTargetType targetType, MedtronicDeviceType devices,
// MinimedCommandParameterType parameterType, byte[] cmd_params, int expectedLength) {
// this(code, description, targetType, devices, parameterType, 0, 1, 0, 0, 11, expectedLength);
//
// this.commandParameters = cmd_params;
// this.commandParametersCount = cmd_params.length;
// }
MedtronicCommandType(int code, String description, MedtronicDeviceType devices, // MedtronicCommandType(int code, String description, MedtronicDeviceType devices, //
MinimedCommandParameterType parameterType) { MinimedCommandParameterType parameterType) {
@ -311,12 +299,12 @@ public enum MedtronicCommandType implements Serializable // , MinimedCommandType
@Deprecated @Deprecated
MedtronicCommandType(int code, String description, MinimedTargetType targetType, MedtronicDeviceType devices, // MedtronicCommandType(int code, String description, MedtronicDeviceType devices, //
MinimedCommandParameterType parameterType, int recordLength, int max_recs, int addy, // MinimedCommandParameterType parameterType, int recordLength, int max_recs, int addy, //
int addy_len, int cmd_type, int expectedLength) { int addy_len, int cmd_type, int expectedLength) {
this.commandCode = (byte) code; this.commandCode = (byte) code;
this.commandDescription = description; this.commandDescription = description;
this.targetType = targetType; //this.targetType = targetType;
this.devices = devices; this.devices = devices;
this.recordLength = recordLength; this.recordLength = recordLength;
this.maxRecords = max_recs; this.maxRecords = max_recs;
@ -361,32 +349,6 @@ public enum MedtronicCommandType implements Serializable // , MinimedCommandType
} }
public static MedtronicCommandType getDetectBolus(MedtronicDeviceType device) {
if (device == MedtronicDeviceType.Medtronic_511) {
return MedtronicCommandType.DetectBolus;
} else {
return MedtronicCommandType.SetTemporaryBasal;
}
}
// public static List<MedtronicCommandType> getCommands(MedtronicDeviceType device, MinimedTargetType targetType)
// {
// List<MedtronicCommandType> commands = new ArrayList<MedtronicCommandType>();
//
// for (MedtronicCommandType mct : values())
// {
//
// if ((mct.targetType == targetType)
// && ((MedtronicDeviceType.isSameDevice(device, mct.devices)) || mct.devices == MedtronicDeviceType.All))
// {
// commands.add(mct);
// }
// }
//
// return commands;
// }
public static MedtronicCommandType getByCode(byte code) { public static MedtronicCommandType getByCode(byte code) {
if (mapByCode.containsKey(code)) { if (mapByCode.containsKey(code)) {
return mapByCode.get(code); return mapByCode.get(code);

View file

@ -1,20 +0,0 @@
package info.nightscout.androidaps.plugins.pump.medtronic.defs;
/**
* Taken from GNU Gluco Control diabetes management software (ggc.sourceforge.net)
* <p>
* Author: Andy {andy@atech-software.com}
*/
public enum MedtronicConverterType {
Pump511Converter, //
Pump512Converter, //
Pump515Converter, //
Pump523Converter, //
CGMS522Converter, //
CGMS523Converter, //
;
}

View file

@ -11,7 +11,6 @@ public enum MedtronicCustomActionType implements CustomActionType {
WakeUpAndTune(), // WakeUpAndTune(), //
ClearBolusBlock(), // ClearBolusBlock(), //
ResetRileyLinkConfiguration(), // ResetRileyLinkConfiguration(), //
; ;
@Override @Override

View file

@ -13,27 +13,25 @@ public enum MedtronicDeviceType {
Unknown_Device, // Unknown_Device, //
// Pump // Pump
// Medtronic_508_508c(null, null), // Medtronic_511("511"), //
Medtronic_511(MedtronicConverterType.Pump511Converter, null, "511"), //
Medtronic_512(MedtronicConverterType.Pump512Converter, null, "512"), // Medtronic_512("512"), //
Medtronic_712(MedtronicConverterType.Pump512Converter, null, "712"), // Medtronic_712("712"), //
Medtronic_512_712(Medtronic_512, Medtronic_712), // Medtronic_512_712(Medtronic_512, Medtronic_712), //
Medtronic_515(MedtronicConverterType.Pump515Converter, null, "515"), // Medtronic_515("515"), //
Medtronic_715(MedtronicConverterType.Pump515Converter, null, "715"), // Medtronic_715("715"), //
Medtronic_515_715(Medtronic_515, Medtronic_715), // Medtronic_515_715(Medtronic_515, Medtronic_715), //
Medtronic_522(MedtronicConverterType.Pump515Converter, MedtronicConverterType.CGMS522Converter, "522"), // Medtronic_522("522"), //
Medtronic_722(MedtronicConverterType.Pump515Converter, MedtronicConverterType.CGMS522Converter, "722"), // Medtronic_722("722"), //
Medtronic_522_722(Medtronic_522, Medtronic_722), // Medtronic_522_722(Medtronic_522, Medtronic_722), //
Medtronic_523_Revel(MedtronicConverterType.Pump523Converter, MedtronicConverterType.CGMS523Converter, "523"), // Medtronic_523_Revel("523"), //
Medtronic_723_Revel(MedtronicConverterType.Pump523Converter, MedtronicConverterType.CGMS523Converter, "723"), // Medtronic_723_Revel("723"), //
Medtronic_554_Veo(MedtronicConverterType.Pump523Converter, MedtronicConverterType.CGMS523Converter, "554"), // Medtronic_554_Veo("554"), //
Medtronic_754_Veo(MedtronicConverterType.Pump523Converter, MedtronicConverterType.CGMS523Converter, "754"), // Medtronic_754_Veo("754"), //
// Minimed_640G(MedtronicConverterType.Pump523Converter, MedtronicConverterType.CGMS523Converter, "640G", null),
Medtronic_512andHigher(Medtronic_512, Medtronic_712, Medtronic_515, Medtronic_715, Medtronic_522, Medtronic_722, // Medtronic_512andHigher(Medtronic_512, Medtronic_712, Medtronic_515, Medtronic_715, Medtronic_522, Medtronic_722, //
Medtronic_523_Revel, Medtronic_723_Revel, Medtronic_554_Veo, Medtronic_754_Veo), // Medtronic_523_Revel, Medtronic_723_Revel, Medtronic_554_Veo, Medtronic_754_Veo), //
@ -45,13 +43,8 @@ public enum MedtronicDeviceType {
Medtronic_523andHigher(Medtronic_523_Revel, Medtronic_723_Revel, Medtronic_554_Veo, // Medtronic_523andHigher(Medtronic_523_Revel, Medtronic_723_Revel, Medtronic_554_Veo, //
Medtronic_754_Veo), // Medtronic_754_Veo), //
// Medtronic_553andHigher(Medtronic_553_Revel, Medtronic_753_Revel, Medtronic_554_Veo, Medtronic_754_Veo), //
Medtronic_554andHigher(Medtronic_554_Veo, Medtronic_754_Veo), // Medtronic_554andHigher(Medtronic_554_Veo, Medtronic_754_Veo), //
// CGMS
MedtronicCGMSGold(null, MedtronicConverterType.CGMS522Converter, null), //
MedtronicGuradianRealTime(null, MedtronicConverterType.CGMS522Converter, null), //
// //
All; All;
@ -71,21 +64,14 @@ public enum MedtronicDeviceType {
} }
MedtronicConverterType pumpConverter;
MedtronicConverterType cgmsConverter;
private String pumpModel; private String pumpModel;
// String smallReservoirPump;
// String bigReservoirPump;
private boolean isFamily; private boolean isFamily;
private MedtronicDeviceType[] familyMembers = null; private MedtronicDeviceType[] familyMembers = null;
MedtronicDeviceType(MedtronicConverterType pumpConverter, MedtronicConverterType cgmsConverter, String pumpModel) { MedtronicDeviceType(String pumpModel) {
this.isFamily = false; this.isFamily = false;
this.pumpConverter = pumpConverter;
this.cgmsConverter = cgmsConverter;
this.pumpModel = pumpModel; this.pumpModel = pumpModel;
} }
@ -134,16 +120,6 @@ public enum MedtronicDeviceType {
} }
public MedtronicConverterType getCGMSConverterType() {
return cgmsConverter;
}
public MedtronicConverterType getPumpConverterType() {
return pumpConverter;
}
public boolean isLargerFormat() { public boolean isLargerFormat() {
return isSameDevice(this, Medtronic_523andHigher); return isSameDevice(this, Medtronic_523andHigher);
} }

View file

@ -1,11 +0,0 @@
package info.nightscout.androidaps.plugins.pump.medtronic.defs;
/**
* Created by andy on 6/14/18.
*/
public enum MedtronicUITaskType {
GetStatus;
}

View file

@ -1,34 +0,0 @@
package info.nightscout.androidaps.plugins.pump.medtronic.defs;
/**
* Taken from GNU Gluco Control diabetes management software (ggc.sourceforge.net)
* <p>
* Author: Andy {andy@atech-software.com}
*/
public enum MinimedTargetType {
ActionCommand, //
InitCommand,
PumpConfiguration, //
PumpData, //
PumpSetData, //
PumpConfiguration_NA, //
PumpData_NA, //
PumpDataAndConfiguration, //
CGMSConfiguration, //
CGMSData, //
BaseCommand, //
Pump, //
CGMS, //
CGMSData_NA, //
CGMSConfiguration_NA;
MinimedTargetType() {
}
}

View file

@ -67,7 +67,7 @@ public class MedtronicHistoryActivity extends Activity {
List<PumpHistoryEntry> list = new ArrayList<>(); List<PumpHistoryEntry> list = new ArrayList<>();
list.addAll(MedtronicPumpPlugin.getPlugin().getMedtronicHistoryData().getAllHistory()); list.addAll(MedtronicPumpPlugin.getPlugin().getMedtronicHistoryData().getAllHistory());
LOG.debug("Items on full list: {}", list.size()); //LOG.debug("Items on full list: {}", list.size());
if (group == PumpHistoryEntryGroup.All) { if (group == PumpHistoryEntryGroup.All) {
this.filteredHistoryList.addAll(list); this.filteredHistoryList.addAll(list);
@ -84,7 +84,7 @@ public class MedtronicHistoryActivity extends Activity {
this.recyclerViewAdapter.notifyDataSetChanged(); this.recyclerViewAdapter.notifyDataSetChanged();
} }
LOG.debug("Items on filtered list: {}", filteredHistoryList.size()); //LOG.debug("Items on filtered list: {}", filteredHistoryList.size());
} }

View file

@ -1,8 +1,5 @@
package info.nightscout.androidaps.plugins.pump.medtronic.dialog; package info.nightscout.androidaps.plugins.pump.medtronic.dialog;
import java.util.ArrayList;
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.view.LayoutInflater; import android.view.LayoutInflater;
@ -12,6 +9,9 @@ import android.widget.BaseAdapter;
import android.widget.ListView; import android.widget.ListView;
import android.widget.TextView; import android.widget.TextView;
import java.util.ArrayList;
import java.util.List;
import info.nightscout.androidaps.R; import info.nightscout.androidaps.R;
import info.nightscout.androidaps.plugins.pump.common.dialog.RefreshableInterface; import info.nightscout.androidaps.plugins.pump.common.dialog.RefreshableInterface;
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.data.RLHistoryItem; import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.data.RLHistoryItem;
@ -19,10 +19,13 @@ import info.nightscout.androidaps.plugins.pump.common.utils.StringUtil;
/** /**
* Created by andy on 5/19/18. * Created by andy on 5/19/18.
* <p>
* This is for 3rd tab, called Medtronic (in RileyLink stats), that should work similarly as the one in Loop.
* <p>
* Showing currently selected RL, speed of RL, ability to issue simple commands (getModel, tuneUp, gerProfile)
*/ */
// FIXME needs to be implemented // TODO needs to be implemented
@Deprecated
public class RileyLinkStatusDeviceMedtronic extends Fragment implements RefreshableInterface { public class RileyLinkStatusDeviceMedtronic extends Fragment implements RefreshableInterface {
// @BindView(R.id.rileylink_history_list) // @BindView(R.id.rileylink_history_list)

View file

@ -199,11 +199,6 @@ public class RileyLinkMedtronicService extends RileyLinkService {
} }
public boolean handleIncomingServiceTransport(Intent intent) {
return false;
}
private boolean isLogEnabled() { private boolean isLogEnabled() {
return L.isEnabled(L.PUMPCOMM); return L.isEnabled(L.PUMPCOMM);
} }

View file

@ -1,82 +0,0 @@
package info.nightscout.androidaps.plugins.pump.medtronic.service.data;
import org.joda.time.LocalDateTime;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import android.os.Bundle;
import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.data.ServiceResult;
import info.nightscout.androidaps.plugins.pump.medtronic.defs.MedtronicCommandType;
/**
* Created by geoff on 6/25/16.
*/
public class MedtronicPumpResult extends ServiceResult {
private static final Logger LOG = LoggerFactory.getLogger(L.PUMPCOMM);
public MedtronicPumpResult(MedtronicCommandType commandType) {
map.putString("ServiceMessageType", commandType.name());
}
@Override
public void init() {
}
public void addParameter(String parameter, String value) {
map.putString(parameter, value);
}
public void addParameter(String parameter, Float value) {
map.putFloat(parameter, value);
}
public void setError() {
map.putBoolean("Error", true);
}
public void addParameter(String key, LocalDateTime time) {
DateTimeFormatter fmt = DateTimeFormat.forStyle("FF");
map.putString(key, fmt.print(time));
}
public LocalDateTime getTimeParameter(String key) {
LocalDateTime rval = new LocalDateTime(1900, 1, 1, 1, 1);
Bundle map = getMap();
if (map != null) {
String timeString = map.getString(key);
if (timeString != null) {
DateTimeFormatter fmt = DateTimeFormat.forStyle("FF");
try {
rval = fmt.parseLocalDateTime(timeString);
} catch (IllegalArgumentException e) {
LOG.error("getTime: failed to parse time from '" + timeString + "'");
}
}
}
return rval;
}
public Float getFloatParameter(String key) {
return map.getFloat(key, 0.0f);
}
// This can be overridden by subclasses -- essentially it allows
// casting from the base class to the subclass.
public void initFromServiceResult(ServiceResult serviceResult) {
setMap(serviceResult.getMap());
}
}

View file

@ -1,85 +0,0 @@
package info.nightscout.androidaps.plugins.pump.medtronic.service.tasks;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.data.ServiceTransport;
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.tasks.PumpTask;
import info.nightscout.androidaps.plugins.pump.medtronic.comm.MedtronicCommunicationManager;
import info.nightscout.androidaps.plugins.pump.medtronic.data.dto.ClockDTO;
import info.nightscout.androidaps.plugins.pump.medtronic.defs.MedtronicCommandType;
import info.nightscout.androidaps.plugins.pump.medtronic.defs.MedtronicDeviceType;
import info.nightscout.androidaps.plugins.pump.medtronic.service.RileyLinkMedtronicService;
import info.nightscout.androidaps.plugins.pump.medtronic.service.data.MedtronicPumpResult;
/**
* Created by geoff on 7/9/16.
*/
public class MedtronicPumpTask extends PumpTask {
private static final Logger LOG = LoggerFactory.getLogger(L.PUMPCOMM);
MedtronicCommandType commandType;
Object[] parameters;
public MedtronicPumpTask(MedtronicCommandType commandType, Object... parameters) {
this.commandType = commandType;
this.parameters = parameters;
}
public MedtronicPumpTask(ServiceTransport transport) {
super(transport);
}
@Override
public void run() {
MedtronicCommunicationManager communicationManager = RileyLinkMedtronicService.getCommunicationManager();
MedtronicPumpResult medtronicPumpResult = new MedtronicPumpResult(commandType);
switch (commandType) {
case GetRemainingInsulin:
Float remainingInsulin = communicationManager.getRemainingInsulin();
if (remainingInsulin == null) {
medtronicPumpResult.setError();
} else {
medtronicPumpResult.addParameter("RemainingInsulin", remainingInsulin);
}
case PumpModel: {
MedtronicDeviceType pumpModel = communicationManager.getPumpModel();
if (pumpModel == MedtronicDeviceType.Unknown_Device) {
medtronicPumpResult.setError();
} else {
medtronicPumpResult.addParameter("PumpModel", pumpModel.name());
}
}
break;
case RealTimeClock: {
ClockDTO pumpResponse = communicationManager.getPumpTime();
if (pumpResponse != null) {
LOG.info("ReadPumpClock: " + pumpResponse.pumpTime.toString("HH:mm:ss"));
medtronicPumpResult.addParameter("PumpTime", pumpResponse.pumpTime);
} else {
LOG.warn("handleServiceCommand(" + mTransport.getOriginalCommandName() + ") pumpResponse is null");
medtronicPumpResult.setError();
}
}
break;
default:
LOG.error("Type {} is NOT supported.");
break;
}
getServiceTransport().setServiceResult(medtronicPumpResult);
}
}