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
versionCode 1500
// dev_version: 2.3.1-dev
version "medtronic-0.10.5-SNAPSHOT"
version "medtronic-0.10.6-SNAPSHOT"
buildConfigField "String", "VERSION", '"' + version + '"'
buildConfigField "String", "BUILDVERSION", '"' + generateGitBuild() + '-' + generateDate() + '"'
buildConfigField "String", "HEAD", '"' + generateGitBuild() + '"'

View file

@ -644,14 +644,27 @@ public class LoopPlugin extends PluginBase {
TreatmentsInterface activeTreatments = TreatmentsPlugin.getPlugin();
LoopPlugin.getPlugin().disconnectTo(System.currentTimeMillis() + durationInMinutes * 60 * 1000L);
ConfigBuilderPlugin.getPlugin().getCommandQueue().tempBasalPercent(0, durationInMinutes, true, profile, new Callback() {
@Override
public void run() {
if (!result.success) {
ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.gs(R.string.tempbasaldeliveryerror));
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() {
@Override
public void run() {
if (!result.success) {
ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.gs(R.string.tempbasaldeliveryerror));
}
}
});
}
if (pump.getPumpDescription().isExtendedBolusCapable && activeTreatments.isInHistoryExtendedBoluslInProgress()) {
ConfigBuilderPlugin.getPlugin().getCommandQueue().cancelExtended(new Callback() {
@Override

View file

@ -853,19 +853,38 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
loopPlugin.superBolusTo(System.currentTimeMillis() + T.hours(2).msecs());
MainApp.bus().post(new EventRefreshOverview("WizardDialog"));
}
ConfigBuilderPlugin.getPlugin().getCommandQueue().tempBasalPercent(0, 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);
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() {
@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);
}
}
});
}
}
DetailedBolusInfo detailedBolusInfo = new DetailedBolusInfo();
detailedBolusInfo.eventType = CareportalEvent.BOLUSWIZARD;

View file

@ -53,6 +53,7 @@ import info.nightscout.androidaps.events.EventFeatureRunning;
import info.nightscout.androidaps.events.EventRefreshOverview;
import info.nightscout.androidaps.interfaces.Constraint;
import info.nightscout.androidaps.interfaces.PluginType;
import info.nightscout.androidaps.interfaces.PumpDescription;
import info.nightscout.androidaps.interfaces.PumpInterface;
import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin;
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
@ -354,19 +355,39 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com
loopPlugin.superBolusTo(System.currentTimeMillis() + 2 * 60L * 60 * 1000);
MainApp.bus().post(new EventRefreshOverview("WizardDialog"));
}
ConfigBuilderPlugin.getPlugin().getCommandQueue().tempBasalPercent(0, 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);
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() {
@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);
}
}
});
}
}
DetailedBolusInfo detailedBolusInfo = new DetailedBolusInfo();
detailedBolusInfo.eventType = CareportalEvent.BOLUSWIZARD;

View file

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

View file

@ -120,9 +120,6 @@ public abstract class RileyLinkService extends Service {
public abstract RileyLinkCommunicationManager getDeviceCommunicationManager();
public abstract boolean handleIncomingServiceTransport(Intent intent);
// Here is where the wake-lock begins:
// We've received a service startCommand, we grab the lock.
@Override
@ -175,7 +172,7 @@ public abstract class RileyLinkService extends Service {
} else {
if (isLogEnabled())
LOG.warn("Disconnecting from old RL (" + rileyLinkServiceData.rileylinkAddress
+ "), reconnecting to new: " + deviceAddress);
+ "), reconnecting to new: " + deviceAddress);
rileyLinkBLE.disconnect();
// prolly need to shut down listening thread too?
@ -192,7 +189,7 @@ public abstract class RileyLinkService extends Service {
if (RileyLinkUtil.getServiceState() == RileyLinkServiceState.NotStarted) {
if (!bluetoothInit()) {
LOG.error("RileyLink can't get activated, Bluetooth is not functioning correctly. {}",
RileyLinkUtil.getError().name());
RileyLinkUtil.getError().name());
return false;
}
}
@ -238,7 +235,7 @@ public abstract class RileyLinkService extends Service {
if (newFrequency == 0.0d) {
// error tuning pump, pump not present ??
RileyLinkUtil
.setServiceState(RileyLinkServiceState.PumpConnectorError, RileyLinkError.TuneUpOfDeviceFailed);
.setServiceState(RileyLinkServiceState.PumpConnectorError, RileyLinkError.TuneUpOfDeviceFailed);
} else {
getRileyLinkCommunicationManager().clearNotConnectedCount();
RileyLinkUtil.setServiceState(RileyLinkServiceState.PumpConnectorReady);
@ -271,7 +268,7 @@ public abstract class RileyLinkService extends Service {
public void changeRileyLinkEncoding(RileyLinkEncodingType encodingType) {
if (rfspy!=null) {
if (rfspy != null) {
rfspy.setRileyLinkEncoding(encodingType);
}
}

View file

@ -1,16 +1,10 @@
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.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.os.Handler;
import android.os.SystemClock;
import android.text.Spanned;
import android.view.LayoutInflater;
import android.view.View;
@ -19,14 +13,18 @@ import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.TextView;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import com.crashlytics.android.Crashlytics;
import com.joanzapata.iconify.widget.IconTextView;
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.R;
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.plugins.common.SubscriberFragment;
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.defs.RileyLinkError;
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkServiceState;
@ -239,8 +236,8 @@ public class MedtronicFragment extends SubscriberFragment {
private synchronized void setDeviceStatus(MedtronicPumpStatus pumpStatus) {
pumpStatus.rileyLinkServiceState = (RileyLinkServiceState)checkStatusSet(pumpStatus.rileyLinkServiceState,
RileyLinkUtil.getServiceState());
pumpStatus.rileyLinkServiceState = (RileyLinkServiceState) checkStatusSet(pumpStatus.rileyLinkServiceState,
RileyLinkUtil.getServiceState());
if (pumpStatus.rileyLinkServiceState != null && rileyLinkStatus != null) {
@ -261,7 +258,7 @@ public class MedtronicFragment extends SubscriberFragment {
rileyLinkStatus.setText("{fa-bluetooth-b} " + getTranslation(resourceId));
else
rileyLinkStatus.setText("{fa-bluetooth-b} "
+ getTranslation(rileyLinkError.getResourceId(RileyLinkTargetDevice.MedtronicPump)));
+ getTranslation(rileyLinkError.getResourceId(RileyLinkTargetDevice.MedtronicPump)));
rileyLinkStatus.setTextColor(Color.RED);
} else {
@ -269,7 +266,7 @@ public class MedtronicFragment extends SubscriberFragment {
}
}
pumpStatus.rileyLinkError = (RileyLinkError)checkStatusSet(pumpStatus.rileyLinkError, RileyLinkUtil.getError());
pumpStatus.rileyLinkError = (RileyLinkError) checkStatusSet(pumpStatus.rileyLinkError, RileyLinkUtil.getError());
if (errorsView != null) {
if (pumpStatus.rileyLinkError != null) {
@ -279,8 +276,8 @@ public class MedtronicFragment extends SubscriberFragment {
errorsView.setText("-");
}
pumpStatus.pumpDeviceState = (PumpDeviceState)checkStatusSet(pumpStatus.pumpDeviceState,
MedtronicUtil.getPumpDeviceState());
pumpStatus.pumpDeviceState = (PumpDeviceState) checkStatusSet(pumpStatus.pumpDeviceState,
MedtronicUtil.getPumpDeviceState());
if (pumpStatusIconView != null) {
@ -314,10 +311,10 @@ public class MedtronicFragment extends SubscriberFragment {
if (MedtronicUtil.frameNumber == null) {
pumpStatusIconView.setText(MainApp.gs(
R.string.medtronic_cmd_desc_get_history_request, MedtronicUtil.pageNumber));
R.string.medtronic_cmd_desc_get_history_request, MedtronicUtil.pageNumber));
} else {
pumpStatusIconView.setText(MainApp.gs(resourceId, MedtronicUtil.pageNumber,
MedtronicUtil.frameNumber));
MedtronicUtil.frameNumber));
}
} else {
@ -331,9 +328,9 @@ public class MedtronicFragment extends SubscriberFragment {
}
}
break;
break;
default:
default:
LOG.warn("Unknown pump state: " + pumpStatus.pumpDeviceState);
}
} else {
@ -421,7 +418,7 @@ public class MedtronicFragment extends SubscriberFragment {
return;
localActivity = activity;
MedtronicPumpPlugin plugin = (MedtronicPumpPlugin)MedtronicPumpPlugin.getPlugin();
MedtronicPumpPlugin plugin = (MedtronicPumpPlugin) MedtronicPumpPlugin.getPlugin();
MedtronicPumpStatus pumpStatus = MedtronicUtil.getPumpStatus();
setDeviceStatus(pumpStatus);
@ -437,18 +434,18 @@ public class MedtronicFragment extends SubscriberFragment {
if (min < 60) {
lastConnectionView.setText(MainApp.gs(R.string.minago, min));
} else if (min < 1440) {
int h = (int)(min / 60);
int h = (int) (min / 60);
lastConnectionView.setText(MainApp.gq(R.plurals.objective_hours, h, h) + " "
+ MainApp.gs(R.string.ago));
+ MainApp.gs(R.string.ago));
} else {
int h = (int)(min / 60);
int h = (int) (min / 60);
int d = h / 24;
// h = h - (d * 24);
lastConnectionView.setText(MainApp.gq(R.plurals.objective_days, d, d) + " "
+ MainApp.gs(R.string.ago));
+ MainApp.gs(R.string.ago));
}
lastConnectionView.setTextColor(Color.RED);
} else {
@ -478,12 +475,12 @@ public class MedtronicFragment extends SubscriberFragment {
// base basal rate
basaBasalRateView.setText("(" + (pumpStatus.activeProfileName) + ") "
+ MainApp.gs(R.string.pump_basebasalrate, plugin.getBaseBasalRate()));
+ MainApp.gs(R.string.pump_basebasalrate, plugin.getBaseBasalRate()));
if (ConfigBuilderPlugin.getPlugin().getActivePump().isFakingTempsByExtendedBoluses()) {
if (TreatmentsPlugin.getPlugin().isInHistoryRealTempBasalInProgress()) {
tempBasalView.setText(TreatmentsPlugin.getPlugin()
.getRealTempBasalFromHistory(System.currentTimeMillis()).toStringFull());
.getRealTempBasalFromHistory(System.currentTimeMillis()).toStringFull());
} else {
tempBasalView.setText("");
}
@ -491,14 +488,14 @@ public class MedtronicFragment extends SubscriberFragment {
// v2 plugin
if (TreatmentsPlugin.getPlugin().isTempBasalInProgress()) {
tempBasalView.setText(TreatmentsPlugin.getPlugin()
.getTempBasalFromHistory(System.currentTimeMillis()).toStringFull());
.getTempBasalFromHistory(System.currentTimeMillis()).toStringFull());
} else {
tempBasalView.setText("");
}
}
// battery
if (MedtronicUtil.getBatteryType()== BatteryType.None || pumpStatus.batteryVoltage==null) {
if (MedtronicUtil.getBatteryType() == BatteryType.None || pumpStatus.batteryVoltage == null) {
batteryView.setText("{fa-battery-" + (pumpStatus.batteryRemaining / 25) + "} ");
} else {
batteryView.setText("{fa-battery-" + (pumpStatus.batteryRemaining / 25) + "} " + pumpStatus.batteryRemaining + "%" + String.format(" (%.2f V)", pumpStatus.batteryVoltage));
@ -507,7 +504,7 @@ public class MedtronicFragment extends SubscriberFragment {
// reservoir
reservoirView.setText(DecimalFormatter.to0Decimal(pumpStatus.reservoirRemainingUnits) + " / "
+ pumpStatus.reservoirFullUnits + " " + MainApp.gs(R.string.insulin_unit_shortname));
+ pumpStatus.reservoirFullUnits + " " + MainApp.gs(R.string.insulin_unit_shortname));
SetWarnColor.setColorInverse(reservoirView, pumpStatus.reservoirRemainingUnits, 50d, 20d);
errorsView.setText(pumpStatus.getErrorInfo());

View file

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

View file

@ -1,14 +1,14 @@
package info.nightscout.androidaps.plugins.pump.medtronic.comm;
import java.util.List;
import java.util.Map;
import android.content.Context;
import android.os.SystemClock;
import org.joda.time.LocalDateTime;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import android.content.Context;
import android.os.SystemClock;
import java.util.List;
import java.util.Map;
import info.nightscout.androidaps.logging.L;
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.
* <p>
* 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 {
@ -66,8 +67,6 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
private MedtronicPumpHistoryDecoder pumpHistoryDecoder;
private boolean doWakeUpBeforeCommand = true;
private boolean firstConnection = true;
private boolean medtronicHistoryTesting = false; // TODO remove when not needed
public MedtronicCommunicationManager(Context context, RFSpy rfspy) {
@ -76,7 +75,7 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
this.medtronicConverter = new MedtronicConverter();
this.pumpHistoryDecoder = new MedtronicPumpHistoryDecoder();
MedtronicUtil.getPumpStatus().previousConnection = SP.getLong(
RileyLinkConst.Prefs.LastGoodDeviceCommunicationTime, 0L);
RileyLinkConst.Prefs.LastGoodDeviceCommunicationTime, 0L);
}
@ -94,7 +93,7 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
@Override
public <E extends RLMessage> E createResponseMessage(byte[] payload, Class<E> clazz) {
PumpMessage pumpMessage = new PumpMessage(payload);
return (E)pumpMessage;
return (E) pumpMessage;
}
@ -156,8 +155,8 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
PumpDeviceState state = MedtronicUtil.getPumpDeviceState();
byte[] pumpMsgContent = createPumpMessageContent(RLMessageType.ReadSimpleData); // simple
RFSpyResponse rfSpyResponse = rfspy.transmitThenReceive(new RadioPacket(pumpMsgContent), (byte)0, (byte)200,
(byte)0, (byte)0, 25000, (byte)0);
RFSpyResponse rfSpyResponse = rfspy.transmitThenReceive(new RadioPacket(pumpMsgContent), (byte) 0, (byte) 200,
(byte) 0, (byte) 0, 25000, (byte) 0);
if (isLogEnabled())
LOG.info("wakeup: raw response is " + ByteUtil.shortHexString(rfSpyResponse.getRaw()));
@ -178,14 +177,14 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
if (!pumpResponse.isValid()) {
if (isLogEnabled())
LOG.warn("Response is invalid ! [interrupted={}, timeout={}]", rfSpyResponse.wasInterrupted(),
rfSpyResponse.wasTimeout());
rfSpyResponse.wasTimeout());
} else {
// radioResponse.rssi;
Object dataResponse = medtronicConverter.convertResponse(MedtronicCommandType.PumpModel,
pumpResponse.getRawContent());
pumpResponse.getRawContent());
MedtronicDeviceType pumpModel = (MedtronicDeviceType)dataResponse;
MedtronicDeviceType pumpModel = (MedtronicDeviceType) dataResponse;
boolean valid = (pumpModel != MedtronicDeviceType.Unknown_Device);
if (MedtronicUtil.getMedtronicPumpModel() == null && valid) {
@ -194,7 +193,7 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
if (isLogEnabled())
LOG.debug("isDeviceReachable. PumpModel is {} - Valid: {} (rssi={})", pumpModel.name(), valid,
radioResponse.rssi);
radioResponse.rssi);
if (valid) {
if (state == PumpDeviceState.PumpUnreachable)
@ -202,9 +201,6 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
else
MedtronicUtil.setPumpDeviceState(PumpDeviceState.Sleeping);
// if (firstConnection)
// checkFirstConnectionTime();
rememberLastGoodDeviceCommunicationTime();
return true;
@ -219,13 +215,13 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
} else {
if (isLogEnabled())
LOG.warn("isDeviceReachable. Failed to parse radio response: "
+ ByteUtil.shortHexString(rfSpyResponse.getRaw()));
+ ByteUtil.shortHexString(rfSpyResponse.getRaw()));
}
} catch (RileyLinkCommunicationException e) {
if (isLogEnabled())
LOG.warn("isDeviceReachable. Failed to decode radio response: "
+ ByteUtil.shortHexString(rfSpyResponse.getRaw()));
+ ByteUtil.shortHexString(rfSpyResponse.getRaw()));
}
} else {
@ -249,7 +245,7 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
LOG.debug("Run command with Args: ");
PumpMessage rval;
PumpMessage shortMessage = makePumpMessage(msg.commandType, new CarelinkShortMessageBody(new byte[] { 0 }));
PumpMessage shortMessage = makePumpMessage(msg.commandType, new CarelinkShortMessageBody(new byte[]{0}));
// look for ack from short message
PumpMessage shortResponse = sendAndListen(shortMessage);
if (shortResponse.commandType == MedtronicCommandType.CommandACK) {
@ -269,7 +265,6 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
}
private PumpMessage runCommandWithFrames(MedtronicCommandType commandType, List<List<Byte>> frames)
throws RileyLinkCommunicationException {
@ -277,7 +272,7 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
LOG.debug("Run command with Frames: {}", commandType.name());
PumpMessage rval = null;
PumpMessage shortMessage = makePumpMessage(commandType, new CarelinkShortMessageBody(new byte[] { 0 }));
PumpMessage shortMessage = makePumpMessage(commandType, new CarelinkShortMessageBody(new byte[]{0}));
// look for ack from short message
PumpMessage shortResponse = sendAndListen(shortMessage);
@ -311,7 +306,7 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
if (isLogEnabled())
LOG.error("Run command with Frames FAILED (command={}, response={})", commandType.name(),
rval.toString());
rval.toString());
return new PumpMessage("No ACK after frame #" + frameNr);
} else {
@ -330,7 +325,7 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
public PumpHistoryResult getPumpHistory(PumpHistoryEntry lastEntry, LocalDateTime targetDate) {
PumpHistoryResult pumpTotalResult = new PumpHistoryResult(lastEntry, targetDate == null ? null
: DateTimeUtil.toATechDate(targetDate));
: DateTimeUtil.toATechDate(targetDate));
if (doWakeUpBeforeCommand)
wakeUp(receiverDeviceAwakeForMinutes, false);
@ -341,12 +336,12 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
MedtronicUtil.setPumpDeviceState(PumpDeviceState.Active);
boolean doneWithError = false;
for (int pageNumber = 0; pageNumber < 16; pageNumber++) {
for (int pageNumber = 0; pageNumber < 5; pageNumber++) {
RawHistoryPage rawHistoryPage = new RawHistoryPage();
// wakeUp(receiverDeviceAwakeForMinutes, false);
PumpMessage getHistoryMsg = makePumpMessage(MedtronicCommandType.GetHistoryData,
new GetHistoryPageCarelinkMessageBody(pageNumber));
new GetHistoryPageCarelinkMessageBody(pageNumber));
if (isLogEnabled())
LOG.info("getPumpHistory: Page {}", pageNumber);
@ -380,7 +375,7 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
PumpMessage ackMsg = makePumpMessage(MedtronicCommandType.CommandACK, new PumpAckMessageBody());
GetHistoryPageCarelinkMessageBody currentResponse = new GetHistoryPageCarelinkMessageBody(firstResponse
.getMessageBody().getTxData());
.getMessageBody().getTxData());
int expectedFrameNum = 1;
boolean done = false;
// while (expectedFrameNum == currentResponse.getFrameNumber()) {
@ -390,7 +385,7 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
// examine current response for problems.
byte[] frameData = currentResponse.getFrameData();
if ((frameData != null) && (frameData.length > 0)
&& currentResponse.getFrameNumber() == expectedFrameNum) {
&& currentResponse.getFrameNumber() == expectedFrameNum) {
// success! got a frame.
if (frameData.length != 64) {
if (isLogEnabled())
@ -402,7 +397,7 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
// RileyLinkMedtronicService.getInstance().announceProgress(((100 / 16) *
// currentResponse.getFrameNumber() + 1));
MedtronicUtil.setCurrentCommand(MedtronicCommandType.GetHistoryData, pageNumber,
currentResponse.getFrameNumber());
currentResponse.getFrameNumber());
if (isLogEnabled())
LOG.info("getPumpHistory: Got frame {} of Page {}", currentResponse.getFrameNumber(), pageNumber);
@ -419,7 +414,7 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
} else if (currentResponse.getFrameNumber() != expectedFrameNum) {
if (isLogEnabled())
LOG.warn("Expected frame number {}, received {} (retrying)", expectedFrameNum,
currentResponse.getFrameNumber());
currentResponse.getFrameNumber());
} else if (frameData.length == 0) {
if (isLogEnabled())
LOG.warn("Frame has zero length, retrying");
@ -428,8 +423,8 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
if (failures == 6) {
if (isLogEnabled())
LOG.error(
"getPumpHistory: 6 failures in attempting to download frame {} of page {}, giving up.",
expectedFrameNum, pageNumber);
"getPumpHistory: 6 failures in attempting to download frame {} of page {}, giving up.",
expectedFrameNum, pageNumber);
done = true; // failure completion.
doneWithError = true;
}
@ -462,7 +457,7 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
if (rawHistoryPage.getLength() != 1024) {
if (isLogEnabled())
LOG.warn("getPumpHistory: short page. Expected length of 1024, found length of "
+ rawHistoryPage.getLength());
+ rawHistoryPage.getLength());
doneWithError = true;
}
@ -472,8 +467,6 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
doneWithError = true;
}
// TODO handle error states
if (doneWithError) {
MedtronicUtil.setPumpDeviceState(PumpDeviceState.Sleeping);
return pumpTotalResult;
@ -482,12 +475,11 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
rawHistoryPage.dumpToDebug();
List<PumpHistoryEntry> medtronicHistoryEntries = pumpHistoryDecoder
.processPageAndCreateRecords(rawHistoryPage);
.processPageAndCreateRecords(rawHistoryPage);
if (isLogEnabled())
LOG.debug("getPumpHistory: Found {} history entries.", medtronicHistoryEntries.size());
// PumpHistoryResult pumpHistoryResult = new PumpHistoryResult(lastEntry, targetDate);
pumpTotalResult.addHistoryEntries(medtronicHistoryEntries);
if (isLogEnabled())
@ -498,7 +490,6 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
return pumpTotalResult;
}
}
MedtronicUtil.setPumpDeviceState(PumpDeviceState.Sleeping);
@ -508,7 +499,6 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
}
public String getErrorResponse() {
return this.errorMessage;
}
@ -519,7 +509,7 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
switch (type) {
case PowerOn:
return MedtronicUtil.buildCommandPayload(MedtronicCommandType.RFPowerOn, //
new byte[] { 2, 1, (byte)receiverDeviceAwakeForMinutes }); // maybe this is better FIXME
new byte[]{2, 1, (byte) receiverDeviceAwakeForMinutes}); // maybe this is better FIXME
case ReadSimpleData:
return MedtronicUtil.buildCommandPayload(MedtronicCommandType.PumpModel, null);
@ -530,12 +520,12 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
private PumpMessage makePumpMessage(MedtronicCommandType messageType, byte[] body) {
return makePumpMessage(messageType, body == null ? new CarelinkShortMessageBody()
: new CarelinkShortMessageBody(body));
: new CarelinkShortMessageBody(body));
}
private PumpMessage makePumpMessage(MedtronicCommandType messageType) {
return makePumpMessage(messageType, (byte[])null);
return makePumpMessage(messageType, (byte[]) null);
}
@ -615,7 +605,7 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
response = sendAndGetResponse(commandType, bodyData, DEFAULT_TIMEOUT + (DEFAULT_TIMEOUT * retries));
String check = checkResponseContent(response, commandType.commandDescription,
commandType.expectedLength);
commandType.expectedLength);
if (check == null) {
@ -659,8 +649,8 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
} else {
String responseData = String.format(
"%s: Cannot return data. Data is too short [expected=%s, received=%s].", method, ""
+ expectedLength, "" + contents.length);
"%s: Cannot return data. Data is too short [expected=%s, received=%s].", method, ""
+ expectedLength, "" + contents.length);
if (isLogEnabled())
LOG.warn(responseData);
@ -680,7 +670,7 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
Object responseObject = sendAndGetResponseWithCheck(MedtronicCommandType.GetRemainingInsulin);
return responseObject == null ? null : (Float)responseObject;
return responseObject == null ? null : (Float) responseObject;
}
@ -688,7 +678,7 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
Object responseObject = sendAndGetResponseWithCheck(MedtronicCommandType.PumpModel);
return responseObject == null ? null : (MedtronicDeviceType)responseObject;
return responseObject == null ? null : (MedtronicDeviceType) responseObject;
}
@ -763,7 +753,7 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
errorMessage = check;
}
BasalProfile basalProfile = (BasalProfile)medtronicConverter.convertResponse(commandType, data);
BasalProfile basalProfile = (BasalProfile) medtronicConverter.convertResponse(commandType, data);
if (isLogEnabled())
LOG.debug("Converted response for {} is {}.", commandType.name(), basalProfile);
@ -792,8 +782,8 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
private boolean checkIfWeHaveMoreData(MedtronicCommandType commandType, PumpMessage response, byte[] data) {
if (commandType == MedtronicCommandType.GetBasalProfileSTD || //
commandType == MedtronicCommandType.GetBasalProfileA || //
commandType == MedtronicCommandType.GetBasalProfileB) {
commandType == MedtronicCommandType.GetBasalProfileA || //
commandType == MedtronicCommandType.GetBasalProfileB) {
byte[] responseRaw = response.getRawContent();
int last = responseRaw.length - 1;
@ -824,7 +814,7 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
Object responseObject = sendAndGetResponseWithCheck(MedtronicCommandType.RealTimeClock);
if (responseObject != null) {
clockDTO.pumpTime = (LocalDateTime)responseObject;
clockDTO.pumpTime = (LocalDateTime) responseObject;
return clockDTO;
}
@ -836,16 +826,16 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
Object responseObject = sendAndGetResponseWithCheck(MedtronicCommandType.ReadTemporaryBasal);
return responseObject == null ? null : (TempBasalPair)responseObject;
return responseObject == null ? null : (TempBasalPair) responseObject;
}
public Map<String, PumpSettingDTO> getPumpSettings() {
Object responseObject = sendAndGetResponseWithCheck(MedtronicCommandType.getSettings(MedtronicUtil
.getMedtronicPumpModel()));
.getMedtronicPumpModel()));
return responseObject == null ? null : (Map<String, PumpSettingDTO>)responseObject;
return responseObject == null ? null : (Map<String, PumpSettingDTO>) responseObject;
}
@ -878,7 +868,7 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
if (debugSetCommands)
LOG.debug("{}: Body - {}", commandType.getCommandDescription(),
HexDump.toHexStringDisplayable(body));
HexDump.toHexStringDisplayable(body));
PumpMessage msg = makePumpMessage(commandType, new CarelinkLongMessageBody(body));
@ -890,7 +880,7 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
if (pumpMessage.commandType == MedtronicCommandType.CommandACK) {
return true;
} else {
LOG.warn("We received non-ACK response from pump: {}" , pumpMessage.getResponseContent());
LOG.warn("We received non-ACK response from pump: {}", pumpMessage.getResponseContent());
}
} catch (RileyLinkCommunicationException e) {
@ -912,7 +902,7 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
Object responseObject = sendAndGetResponseWithCheck(MedtronicCommandType.GetBatteryStatus);
return responseObject == null ? null : (BatteryStatusDTO)responseObject;
return responseObject == null ? null : (BatteryStatusDTO) responseObject;
}
@ -925,7 +915,7 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
// PumpMessage responseMessage = null;
try {
PumpMessage responseMessage = runCommandWithFrames(MedtronicCommandType.SetBasalProfileSTD,
basalProfileFrames);
basalProfileFrames);
return responseMessage.commandType == MedtronicCommandType.CommandACK;
} catch (RileyLinkCommunicationException e) {
@ -934,7 +924,6 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
}
// LOG.debug("Set Basal Profile: {}", HexDump.toHexStringDisplayable(responseMessage.getRawContent()));
}
return false;
@ -942,13 +931,6 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
}
public PumpMessage cancelBolus() {
// ? maybe suspend and resume
return null;
}
private boolean isLogEnabled() {
return L.isEnabled(L.PUMPCOMM);
}

View file

@ -1,14 +1,13 @@
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.LocalDateTime;
import org.joda.time.LocalTime;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.HashMap;
import java.util.Map;
import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.pump.common.utils.ByteUtil;
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.
* High level decoder for data returned through MedtroniUIComm
*/
public class MedtronicConverter {
@ -37,7 +37,7 @@ public class MedtronicConverter {
if ((rawContent == null || rawContent.length < 1) && commandType != MedtronicCommandType.PumpModel) {
LOG.warn("Content is empty or too short, no data to convert (type={},isNull={},length={})",
commandType.name(), rawContent == null, rawContent == null ? "-" : rawContent.length);
commandType.name(), rawContent == null, rawContent == null ? "-" : rawContent.length);
return null;
}
@ -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) {
// 00 7C 00 00
@ -170,9 +135,7 @@ public class MedtronicConverter {
if (rawData.length > 1) {
// 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.extendedDataReceived = true;
@ -187,7 +150,7 @@ public class MedtronicConverter {
this.pumpModel = MedtronicUtil.getMedtronicPumpModel();
int strokes = pumpModel==null ? 10 : pumpModel.getBolusStrokes();
int strokes = pumpModel == null ? 10 : pumpModel.getBolusStrokes();
if (strokes == 40) {
startIdx = 2;
@ -214,8 +177,8 @@ public class MedtronicConverter {
return pumpTime;
} catch (IllegalFieldValueException e) {
LOG.error(
"decodeTime: Failed to parse pump time value: year=%d, month=%d, hours=%d, minutes=%d, seconds=%d",
year, month, day, hours, minutes, seconds);
"decodeTime: Failed to parse pump time value: year=%d, month=%d, hours=%d, minutes=%d, seconds=%d",
year, month, day, hours, minutes, seconds);
return null;
}
@ -239,26 +202,26 @@ public class MedtronicConverter {
if (rd[2] == 1) {
addSettingToMap("PCFG_AUDIO_BOLUS_STEP_SIZE", "" + decodeBolusInsulin(ByteUtil.asUINT8(rd[3])),
PumpConfigurationGroup.Bolus, map);
PumpConfigurationGroup.Bolus, map);
}
addSettingToMap("PCFG_VARIABLE_BOLUS_ENABLED", parseResultEnable(rd[4]), PumpConfigurationGroup.Bolus, map);
addSettingToMap("PCFG_MAX_BOLUS", "" + decodeMaxBolus(rd), PumpConfigurationGroup.Bolus, map);
addSettingToMap(
"PCFG_MAX_BASAL",
""
+ decodeBasalInsulin(ByteUtil.makeUnsignedShort(rd[getSettingIndexMaxBasal()],
rd[getSettingIndexMaxBasal() + 1])), PumpConfigurationGroup.Basal, map);
"PCFG_MAX_BASAL",
""
+ decodeBasalInsulin(ByteUtil.makeUnsignedShort(rd[getSettingIndexMaxBasal()],
rd[getSettingIndexMaxBasal() + 1])), PumpConfigurationGroup.Basal, map);
addSettingToMap("CFG_BASE_CLOCK_MODE", rd[getSettingIndexTimeDisplayFormat()] == 0 ? "12h" : "24h",
PumpConfigurationGroup.General, map);
PumpConfigurationGroup.General, map);
if (MedtronicDeviceType.isSameDevice(pumpModel, MedtronicDeviceType.Medtronic_523andHigher)) {
addSettingToMap("PCFG_INSULIN_CONCENTRATION", "" + (rd[9] == 0 ? 50 : 100), PumpConfigurationGroup.Insulin,
map);
map);
// LOG.debug("Insulin concentration: " + rd[9]);
} else {
addSettingToMap("PCFG_INSULIN_CONCENTRATION", "" + (rd[9] != 0 ? 50 : 100), PumpConfigurationGroup.Insulin,
map);
map);
// LOG.debug("Insulin concentration: " + rd[9]);
}
addSettingToMap("PCFG_BASAL_PROFILES_ENABLED", parseResultEnable(rd[10]), PumpConfigurationGroup.Basal, map);
@ -313,10 +276,10 @@ public class MedtronicConverter {
Map<String, PumpSettingDTO> map = decodeSettings512(rd);
addSettingToMap("PCFG_MM_RESERVOIR_WARNING_TYPE_TIME", rd[18] != 0 ? "PCFG_MM_RESERVOIR_WARNING_TYPE_TIME"
: "PCFG_MM_RESERVOIR_WARNING_TYPE_UNITS", PumpConfigurationGroup.Other, map);
: "PCFG_MM_RESERVOIR_WARNING_TYPE_UNITS", PumpConfigurationGroup.Other, map);
addSettingToMap("PCFG_MM_SRESERVOIR_WARNING_POINT", "" + ByteUtil.asUINT8(rd[19]),
PumpConfigurationGroup.Other, map);
PumpConfigurationGroup.Other, map);
addSettingToMap("CFG_MM_KEYPAD_LOCKED", parseResultEnable(rd[20]), PumpConfigurationGroup.Other, map);
@ -326,7 +289,7 @@ public class MedtronicConverter {
addSettingToMap("PCFG_CAPTURE_EVENT_ENABLE", parseResultEnable(rd[22]), PumpConfigurationGroup.Other, map);
addSettingToMap("PCFG_OTHER_DEVICE_ENABLE", parseResultEnable(rd[23]), PumpConfigurationGroup.Other, map);
addSettingToMap("PCFG_OTHER_DEVICE_PAIRED_STATE", parseResultEnable(rd[24]), PumpConfigurationGroup.Other,
map);
map);
}
return map;
@ -354,7 +317,7 @@ public class MedtronicConverter {
public void decodeInsulinActionSetting(byte[] ai, Map<String, PumpSettingDTO> map) {
if (MedtronicDeviceType.isSameDevice(pumpModel, MedtronicDeviceType.Medtronic_512_712)) {
addSettingToMap("PCFG_INSULIN_ACTION_TYPE", (ai[17] != 0 ? "Regular" : "Fast"),
PumpConfigurationGroup.Insulin, map);
PumpConfigurationGroup.Insulin, map);
} else {
int i = ai[17];
String s = "";
@ -374,13 +337,13 @@ public class MedtronicConverter {
public double decodeBasalInsulin(int i) {
return (double)i / (double)getStrokesPerUnit(true);
return (double) i / (double) getStrokesPerUnit(true);
}
public double decodeBolusInsulin(int i) {
return (double)i / (double)getStrokesPerUnit(false);
return (double) i / (double) getStrokesPerUnit(false);
}
@ -396,7 +359,7 @@ public class MedtronicConverter {
public double decodeMaxBolus(byte ai[]) {
return is523orHigher() ? decodeBolusInsulin(ByteUtil.toInt(ai[5], ai[6])) : decodeBolusInsulin(ByteUtil
.asUINT8(ai[5]));
.asUINT8(ai[5]));
}

View file

@ -1,5 +1,7 @@
package info.nightscout.androidaps.plugins.pump.medtronic.comm.history.pump;
import android.util.Log;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -35,6 +37,7 @@ public class MedtronicPumpHistoryDecoder extends MedtronicHistoryDecoder<PumpHis
private PumpHistoryEntry tbrPreviousRecord;
private PumpHistoryEntry changeTimeRecord;
private MedtronicDeviceType deviceType;
private static final String TAG = "MdtPumpHistoryDecoder";
public MedtronicPumpHistoryDecoder() {
@ -54,7 +57,7 @@ public class MedtronicPumpHistoryDecoder extends MedtronicHistoryDecoder<PumpHis
int elementStart = 0;
if (dataClear.size() == 0) {
LOG.error("Empty page.");
Log.e(TAG, "Empty page.");
return outList;
}
@ -72,7 +75,7 @@ public class MedtronicPumpHistoryDecoder extends MedtronicHistoryDecoder<PumpHis
continue;
} else {
if (skipped != null) {
LOG.debug(" ... Skipped " + skipped);
Log.w(TAG, " ... Skipped " + skipped);
skipped = null;
}
}
@ -142,16 +145,12 @@ public class MedtronicPumpHistoryDecoder extends MedtronicHistoryDecoder<PumpHis
RecordDecodeStatus decoded = decodeRecord(pe);
if (decoded == RecordDecodeStatus.WIP) {
LOG.warn("#" + record + " " + decoded.getDescription() + " " + pe);
if ((decoded == RecordDecodeStatus.OK) || (decoded == RecordDecodeStatus.Ignored)) {
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);
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.
*
* <p>
* Author: Andy {andy.rozman@gmail.com}
*/
@ -37,9 +37,9 @@ public enum PumpHistoryEntryGroup {
list = new ArrayList<>();
for (PumpHistoryEntryGroup pumpHistoryEntryGroup : values()) {
if (doNotTranslate) {
pumpHistoryEntryGroup.translated = MainApp.gs(pumpHistoryEntryGroup.resourceId);
}
//if (doNotTranslate) {
pumpHistoryEntryGroup.translated = MainApp.gs(pumpHistoryEntryGroup.resourceId);
//}
list.add(pumpHistoryEntryGroup);
}
}

View file

@ -120,7 +120,7 @@ public enum PumpHistoryEntryType // implements CodeEnum
BolusReminder(0x69, "Bolus Reminder", PumpHistoryEntryGroup.Configuration, 2, 5, 0), // Ian69
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), //
DailyTotals523(0x6e, "Daily Totals (523)", PumpHistoryEntryGroup.Statistic, 1, 2, 49), // 1102014-03-17T00:00:00
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.
*/
// 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 int getLength() {
@ -23,7 +17,7 @@ public class MessageBody {
public byte[] getTxData() {
return new byte[] {};
return new byte[]{};
}

View file

@ -19,7 +19,7 @@ public class PumpMessage implements RLMessage {
private static final Logger LOG = LoggerFactory.getLogger(L.PUMPCOMM);
public PacketType packetType = PacketType.Carelink;
public byte[] address = new byte[] { 0, 0, 0 };
public byte[] address = new byte[]{0, 0, 0};
public MedtronicCommandType commandType;
public Byte invalidCommandType;
public MessageBody messageBody = new MessageBody();
@ -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) {
this.packetType = packetType;
this.address = address;
@ -80,14 +73,14 @@ public class PumpMessage implements RLMessage {
}
if (rxData.length > 5) {
this.messageBody = MedtronicCommandType.constructMessageBody(commandType,
ByteUtil.substring(rxData, 5, rxData.length - 5));
ByteUtil.substring(rxData, 5, rxData.length - 5));
}
}
@Override
public byte[] getTxData() {
byte[] rval = ByteUtil.concat(new byte[] { (byte)packetType.getValue() }, address);
byte[] rval = ByteUtil.concat(new byte[]{(byte) packetType.getValue()}, address);
rval = ByteUtil.concat(rval, commandType.getCommandCode());
rval = ByteUtil.concat(rval, messageBody.getTxData());
return rval;
@ -95,7 +88,7 @@ public class PumpMessage implements RLMessage {
public byte[] getContents() {
return ByteUtil.concat(new byte[] { commandType.getCommandCode() }, messageBody.getTxData());
return ByteUtil.concat(new byte[]{commandType.getCommandCode()}, messageBody.getTxData());
}
@ -108,7 +101,7 @@ public class PumpMessage implements RLMessage {
byte[] data = messageBody.getTxData();
int length = ByteUtil.asUINT8(data[0]); // length is not always correct so, we check whole array if we have
// data, after length
// data, after length
int originalLength = length;
// check if displayed length is invalid
@ -132,9 +125,9 @@ public class PumpMessage implements RLMessage {
System.arraycopy(messageBody.getTxData(), 1, arrayOut, 0, length);
if (isLogEnabled())
LOG.debug("PumpMessage - Length: " + length + ", Original Length: " + originalLength + ", CommandType: "
+ commandType);
// if (isLogEnabled())
// LOG.debug("PumpMessage - Length: " + length + ", Original Length: " + originalLength + ", CommandType: "
// + commandType);
return arrayOut;
}

View file

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

View file

@ -1,15 +1,13 @@
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.Duration;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Date;
import java.util.Map;
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.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.util.MedtronicUtil;
import static info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicUtil.sendNotification;
/**
* Created by andy on 6/15/18.
*/
@ -41,26 +41,21 @@ public class MedtronicUIPostprocessor {
// where responses won't be directly used
public void postProcessData(MedtronicUITask uiTask) {
// if (!uiTask.haveData()) {
// LOG.error("Error reading data [{}]: {}", uiTask.commandType, uiTask.errorDescription);
// return;
// }
switch (uiTask.commandType) {
case SetBasalProfileSTD: {
Boolean response = (Boolean)uiTask.returnData;
Boolean response = (Boolean) uiTask.returnData;
if (response) {
BasalProfile basalProfile = (BasalProfile)uiTask.getParameter(0);
BasalProfile basalProfile = (BasalProfile) uiTask.getParameter(0);
pumpStatus.basalsByHour = basalProfile.getProfilesByHour();
}
}
break;
break;
case GetBasalProfileSTD: {
BasalProfile basalProfile = (BasalProfile)uiTask.returnData;
BasalProfile basalProfile = (BasalProfile) uiTask.returnData;
Double[] profilesByHour = basalProfile.getProfilesByHour();
@ -72,37 +67,37 @@ public class MedtronicUIPostprocessor {
uiTask.errorDescription = "No profile found.";
}
}
break;
break;
case SetBolus: {
pumpStatus.lastBolusAmount = uiTask.getDoubleFromParameters(0);
pumpStatus.lastBolusTime = new Date();
}
break;
break;
case GetRemainingInsulin: {
pumpStatus.reservoirRemainingUnits = (Float)uiTask.returnData;
pumpStatus.reservoirRemainingUnits = (Float) uiTask.returnData;
}
break;
break;
case CancelTBR: {
pumpStatus.tempBasalStart = null;
pumpStatus.tempBasalAmount = null;
pumpStatus.tempBasalLength = null;
}
break;
break;
case RealTimeClock: {
processTime(uiTask);
}
break;
break;
case GetBatteryStatus: {
BatteryStatusDTO batteryStatusDTO = (BatteryStatusDTO)uiTask.returnData;
BatteryStatusDTO batteryStatusDTO = (BatteryStatusDTO) uiTask.returnData;
pumpStatus.batteryRemaining = (batteryStatusDTO.getCalculatedPercent(pumpStatus.batteryType));
if (batteryStatusDTO.voltage!=null) {
if (batteryStatusDTO.voltage != null) {
pumpStatus.batteryVoltage = batteryStatusDTO.voltage;
}
@ -110,7 +105,7 @@ public class MedtronicUIPostprocessor {
LOG.info("BatteryStatus: {}", batteryStatusDTO.toString());
}
break;
break;
case PumpModel: {
if (pumpStatus.medtronicDeviceType != MedtronicUtil.getMedtronicPumpModel()) {
@ -119,13 +114,13 @@ public class MedtronicUIPostprocessor {
sendNotification(MedtronicNotificationType.PumpTypeNotSame);
}
}
break;
break;
case Settings_512:
case Settings: {
postProcessSettings(uiTask);
}
break;
break;
// no postprocessing
@ -140,28 +135,28 @@ public class MedtronicUIPostprocessor {
private void processTime(MedtronicUITask uiTask) {
ClockDTO clockDTO = (ClockDTO)uiTask.returnData;
ClockDTO clockDTO = (ClockDTO) uiTask.returnData;
Duration dur = new Duration(clockDTO.pumpTime.toDateTime(DateTimeZone.UTC),
clockDTO.localDeviceTime.toDateTime(DateTimeZone.UTC));
clockDTO.localDeviceTime.toDateTime(DateTimeZone.UTC));
clockDTO.timeDifference = (int)dur.getStandardSeconds();
clockDTO.timeDifference = (int) dur.getStandardSeconds();
MedtronicUtil.setPumpTime(clockDTO);
if (isLogEnabled())
LOG.debug("Pump Time: " + clockDTO.localDeviceTime + ", DeviceTime=" + clockDTO.pumpTime + //
", diff: " + dur.getStandardSeconds() + " s");
", diff: " + dur.getStandardSeconds() + " s");
if (dur.getStandardMinutes() >= 10) {
if (isLogEnabled())
LOG.warn("Pump clock needs update, pump time: " + clockDTO.pumpTime.toString("HH:mm:ss") + " (difference: "
+ dur.getStandardSeconds() + " s)");
+ dur.getStandardSeconds() + " s)");
sendNotification(MedtronicNotificationType.PumpWrongTimeUrgent);
} else if (dur.getStandardMinutes() >= 4) {
if (isLogEnabled())
LOG.warn("Pump clock needs update, pump time: " + clockDTO.pumpTime.toString("HH:mm:ss") + " (difference: "
+ dur.getStandardSeconds() + " s)");
+ dur.getStandardSeconds() + " s)");
sendNotification(MedtronicNotificationType.PumpWrongTimeNormal);
}
@ -170,7 +165,7 @@ public class MedtronicUIPostprocessor {
private void postProcessSettings(MedtronicUITask uiTask) {
Map<String, PumpSettingDTO> settings = (Map<String, PumpSettingDTO>)uiTask.returnData;
Map<String, PumpSettingDTO> settings = (Map<String, PumpSettingDTO>) uiTask.returnData;
MedtronicUtil.setSettings(settings);

View file

@ -54,27 +54,27 @@ public class MedtronicUITask {
case PumpModel: {
returnData = communicationManager.getPumpModel();
}
break;
break;
case GetBasalProfileSTD: {
returnData = communicationManager.getBasalProfile();
}
break;
break;
case GetRemainingInsulin: {
returnData = communicationManager.getRemainingInsulin();
}
break;
break;
case RealTimeClock: {
returnData = communicationManager.getPumpTime();
}
break;
break;
case GetBatteryStatus: {
returnData = communicationManager.getRemainingBattery();
}
break;
break;
case SetTemporaryBasal: {
TempBasalPair tbr = getTBRSettings();
@ -82,29 +82,19 @@ public class MedtronicUITask {
returnData = communicationManager.setTBR(tbr);
}
}
break;
break;
case ReadTemporaryBasal: {
returnData = communicationManager.getTemporaryBasal();
}
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_512: {
returnData = communicationManager.getPumpSettings();
}
break;
break;
case SetBolus: {
Double amount = getDoubleFromParameters(0);
@ -112,27 +102,26 @@ public class MedtronicUITask {
if (amount != null)
returnData = communicationManager.setBolus(amount);
}
break;
break;
case CancelTBR: {
// FIXME check if TBR is actually running
returnData = communicationManager.cancelTBR();
}
break;
break;
case SetBasalProfileSTD:
case SetBasalProfileA: {
BasalProfile profile = (BasalProfile)parameters[0];
BasalProfile profile = (BasalProfile) parameters[0];
returnData = communicationManager.setBasalProfile(profile);
}
break;
break;
case GetHistoryData: {
returnData = communicationManager.getPumpHistory((PumpHistoryEntry)parameters[0],
(LocalDateTime)parameters[1]);
returnData = communicationManager.getPumpHistory((PumpHistoryEntry) parameters[0],
(LocalDateTime) parameters[1]);
}
break;
break;
default: {
if (isLogEnabled())
@ -156,26 +145,24 @@ public class MedtronicUITask {
private TempBasalPair getTBRSettings() {
TempBasalPair tempBasalPair = new TempBasalPair(getDoubleFromParameters(0), //
false, //
getIntegerFromParameters(1));
return tempBasalPair;
return new TempBasalPair(getDoubleFromParameters(0), //
false, //
getIntegerFromParameters(1));
}
private Float getFloatFromParameters(int index) {
return (Float)parameters[index];
return (Float) parameters[index];
}
public Double getDoubleFromParameters(int index) {
return (Double)parameters[index];
return (Double) parameters[index];
}
public Integer getIntegerFromParameters(int index) {
return (Integer)parameters[index];
return (Integer) parameters[index];
}
@ -201,11 +188,11 @@ public class MedtronicUITask {
if (responseType == MedtronicUIResponseType.Invalid) {
statusChange = new EventMedtronicDeviceStatusChange(PumpDeviceState.ErrorWhenCommunicating,
"Unsupported command in MedtronicUITask");
"Unsupported command in MedtronicUITask");
MainApp.bus().post(statusChange);
} else if (responseType == MedtronicUIResponseType.Error) {
statusChange = new EventMedtronicDeviceStatusChange(PumpDeviceState.ErrorWhenCommunicating,
errorDescription);
errorDescription);
MainApp.bus().post(statusChange);
} else {
MainApp.bus().post(new EventMedtronicPumpValuesChanged());

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.DailyTotalsDTO;
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.util.MedtronicConst;
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.
*/
// TODO clean up this class (remove/comment logs)
public class MedtronicHistoryData {
private static final Logger LOG = LoggerFactory.getLogger(L.PUMP);
@ -66,7 +67,8 @@ public class MedtronicHistoryData {
private Gson gsonPretty;
//private List<PumpHistoryEntry> fakeTBRs;
DatabaseHelper databaseHelper = MainApp.getDbHelper();
private DatabaseHelper databaseHelper = MainApp.getDbHelper();
private ClockDTO pumpTime;
public MedtronicHistoryData() {
@ -99,7 +101,7 @@ public class MedtronicHistoryData {
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())
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) {

View file

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

View file

@ -1,13 +1,13 @@
package info.nightscout.androidaps.plugins.pump.medtronic.data.dto;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import com.google.gson.annotations.Expose;
import org.slf4j.Logger;
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.plugins.pump.common.utils.ByteUtil;
@ -112,20 +112,19 @@ public class TempBasalPair {
public byte[] getAsRawData() {
// TODO check if this works with 523 and higher
List<Byte> list = new ArrayList<Byte>();
list.add((byte)5);
list.add((byte) 5);
byte[] insulinRate = MedtronicUtil.getBasalStrokes(this.insulinRate, true);
byte timeMin = (byte)MedtronicUtil.getIntervalFromMinutes(durationMinutes);
byte timeMin = (byte) MedtronicUtil.getIntervalFromMinutes(durationMinutes);
// list.add((byte) 0); // ?
// list.add((byte) 0); // is_absolute
if (insulinRate.length == 1)
list.add((byte)0x00);
list.add((byte) 0x00);
else
list.add(insulinRate[0]);
@ -135,7 +134,7 @@ public class TempBasalPair {
list.add(timeMin); // 3 (time) - OK
if (insulinRate.length == 1)
list.add((byte)0x00);
list.add((byte) 0x00);
else
list.add(insulinRate[0]);
@ -145,7 +144,7 @@ public class TempBasalPair {
}
public boolean isCancelTBR() {
return (MedtronicUtil.isSame(insulinRate, 0.0d) && durationMinutes==0);
return (MedtronicUtil.isSame(insulinRate, 0.0d) && durationMinutes == 0);
}
@ -165,6 +164,6 @@ public class TempBasalPair {
@Override
public String toString() {
return "TempBasalPair [" + "Rate=" + insulinRate + ", DurationMinutes=" + durationMinutes + ", IsPercent="
+ isPercent + "]";
+ isPercent + "]";
}
}

View file

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

View file

@ -11,43 +11,38 @@ import info.nightscout.androidaps.plugins.pump.medtronic.comm.message.UnknownMes
/**
* 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)
*
* <p>
* Link to original/unmodified file:
* 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
*
* <p>
* A lot of stuff has been removed because it is not needed anymore (historical stuff from CareLink
* and Carelink USB communication.
*
* <p>
* 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
{
InvalidCommand(0, "Invalid Command", null, null, null), //
InvalidCommand(0, "Invalid Command", null, null), //
// Pump Responses (9)
CommandACK(0x06, "ACK - Acknowledge", MinimedTargetType.ActionCommand, MedtronicDeviceType.All, MinimedCommandParameterType.NoParameters), //
CommandNAK(0x15, "NAK - Not Acknowledged", MinimedTargetType.ActionCommand, MedtronicDeviceType.All, MinimedCommandParameterType.NoParameters), //
CommandACK(0x06, "ACK - Acknowledge", MedtronicDeviceType.All, MinimedCommandParameterType.NoParameters), //
CommandNAK(0x15, "NAK - Not Acknowledged", MedtronicDeviceType.All, MinimedCommandParameterType.NoParameters), //
// 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(
1, 10)), //
RFPowerOn(93, "RF Power On", MedtronicDeviceType.All, MinimedCommandParameterType.FixedParameters, getByteArray(
1, 10)), //
RFPowerOff(93, "RF Power Off", MinimedTargetType.InitCommand, MedtronicDeviceType.All, MinimedCommandParameterType.FixedParameters, getByteArray(
0, 0)), //
RFPowerOff(93, "RF Power Off", MedtronicDeviceType.All, MinimedCommandParameterType.FixedParameters, getByteArray(
0, 0)), //
// SetSuspend(77, "Set Suspend", MinimedTargetType.InitCommand, MedtronicDeviceType.All,
// MinimedCommandParameterType.FixedParameters, getByteArray(1)), //
@ -55,13 +50,13 @@ public enum MedtronicCommandType implements Serializable // , MinimedCommandType
// CancelSuspend(77, "Cancel Suspend", MinimedTargetType.InitCommand, MedtronicDeviceType.All,
// 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)
DetectBolus(75, "Detect Bolus", MinimedTargetType.InitCommand, MedtronicDeviceType.Medtronic_511, MinimedCommandParameterType.FixedParameters, getByteArray(
0, 0, 0)), //
// DetectBolus(75, "Detect Bolus", MedtronicDeviceType.Medtronic_511, MinimedCommandParameterType.FixedParameters, getByteArray(
// 0, 0, 0)), //
// RemoteControlIds(118, "Remote Control Ids", MinimedTargetType.PumpConfiguration_NA, MedtronicDeviceType.All,
// MinimedCommandParameterType.NoParameters), //
@ -73,26 +68,26 @@ public enum MedtronicCommandType implements Serializable // , MinimedCommandType
// MinimedCommandParameterType.NoParameters), // init
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), //
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, //
0, R.string.medtronic_cmd_desc_set_bolus), // 66
0, R.string.medtronic_cmd_desc_set_bolus), // 66
// 512
ReadTemporaryBasal(0x98, "Read Temporary Basal", MedtronicDeviceType.Medtronic_512andHigher, MinimedCommandParameterType.NoParameters, //
5, R.string.medtronic_cmd_desc_get_tbr), // 152
5, R.string.medtronic_cmd_desc_get_tbr), // 152
SetTemporaryBasal(76, "Set Temporay Basal", MedtronicDeviceType.Medtronic_512andHigher, MinimedCommandParameterType.NoParameters, //
0, R.string.medtronic_cmd_desc_set_tbr),
0, R.string.medtronic_cmd_desc_set_tbr),
// 512 Config
PumpModel(141, "Pump Model", MedtronicDeviceType.Medtronic_512andHigher, MinimedCommandParameterType.NoParameters, //
5, R.string.medtronic_cmd_desc_get_model), // 0x8D
5, R.string.medtronic_cmd_desc_get_model), // 0x8D
// BGTargets_512(140, "BG Targets", MinimedTargetType.PumpConfiguration, MedtronicDeviceType.Medtronic_512_712,
// MinimedCommandParameterType.NoParameters), //
@ -104,7 +99,7 @@ public enum MedtronicCommandType implements Serializable // , MinimedCommandType
// MinimedCommandParameterType.NoParameters), //
Settings_512(145, "Configuration", MedtronicDeviceType.Medtronic_512_712, MinimedCommandParameterType.NoParameters, //
64, 1, 0, R.string.medtronic_cmd_desc_get_settings), //
64, 1, 0, R.string.medtronic_cmd_desc_get_settings), //
// BGAlarmClocks(142, "BG Alarm Clocks", MinimedTargetType.PumpConfiguration,
// MedtronicDeviceType.Medtronic_512andHigher, MinimedCommandParameterType.NoParameters), //
@ -120,31 +115,31 @@ public enum MedtronicCommandType implements Serializable // , MinimedCommandType
// 512 Data
GetHistoryData(128, "Get History", MedtronicDeviceType.Medtronic_512andHigher, MinimedCommandParameterType.SubCommands, //
1024, 16, 1024, R.string.medtronic_cmd_desc_get_history), // 0x80
1024, 16, 1024, R.string.medtronic_cmd_desc_get_history), // 0x80
GetBasalProfileSTD(146, "Get Profile Standard", MedtronicDeviceType.Medtronic_512andHigher, MinimedCommandParameterType.NoParameters, //
64, 3, 192, R.string.medtronic_cmd_desc_get_basal_profile), // 146
64, 3, 192, R.string.medtronic_cmd_desc_get_basal_profile), // 146
GetBasalProfileA(147, "Get Profile A", MedtronicDeviceType.Medtronic_512andHigher, MinimedCommandParameterType.NoParameters, //
64, 3, 192, R.string.medtronic_cmd_desc_get_basal_profile),
64, 3, 192, R.string.medtronic_cmd_desc_get_basal_profile),
GetBasalProfileB(148, "Get Profile B", MedtronicDeviceType.Medtronic_512andHigher, MinimedCommandParameterType.NoParameters, //
64, 3, 192, R.string.medtronic_cmd_desc_get_basal_profile), // 148
64, 3, 192, R.string.medtronic_cmd_desc_get_basal_profile), // 148
SetBasalProfileSTD(0x6f, "Set Profile Standard", MedtronicDeviceType.Medtronic_512andHigher, MinimedCommandParameterType.NoParameters, //
64, 3, 192, R.string.medtronic_cmd_desc_set_basal_profile), // 111
64, 3, 192, R.string.medtronic_cmd_desc_set_basal_profile), // 111
SetBasalProfileA(0x30, "Set Profile A", MedtronicDeviceType.Medtronic_512andHigher, MinimedCommandParameterType.NoParameters, //
64, 3, 192, R.string.medtronic_cmd_desc_set_basal_profile), // 48
64, 3, 192, R.string.medtronic_cmd_desc_set_basal_profile), // 48
SetBasalProfileB(0x31, "Set Profile B", MedtronicDeviceType.Medtronic_512andHigher, MinimedCommandParameterType.NoParameters, //
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
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, //
64, 1, 0, R.string.medtronic_cmd_desc_get_settings), //
64, 1, 0, R.string.medtronic_cmd_desc_get_settings), //
// 522
SensorSettings_522(153, "Sensor Configuration", MedtronicDeviceType.Medtronic_522andHigher, MinimedCommandParameterType.NoParameters), //
@ -152,7 +147,7 @@ public enum MedtronicCommandType implements Serializable // , MinimedCommandType
GlucoseHistory(154, "Glucose History", MedtronicDeviceType.Medtronic_522andHigher, MinimedCommandParameterType.SubCommands, 1024, 32, 0, null), //
// 523
SensorSettings(207, "Sensor Configuration", MinimedTargetType.CGMSConfiguration, MedtronicDeviceType.Medtronic_523andHigher, MinimedCommandParameterType.NoParameters), //
SensorSettings(207, "Sensor Configuration", MedtronicDeviceType.Medtronic_523andHigher, MinimedCommandParameterType.NoParameters), //
// 553
// 554
@ -177,7 +172,8 @@ public enum MedtronicCommandType implements Serializable // , MinimedCommandType
// Fake Commands
CancelTBR(), ;
CancelTBR(),
;
static Map<Byte, MedtronicCommandType> mapByCode;
@ -206,7 +202,7 @@ public enum MedtronicCommandType implements Serializable // , MinimedCommandType
public MinimedCommandParameterType parameterType;
public int minimalBufferSizeToStartReading = 14;
public int expectedLength = 0;
MinimedTargetType targetType;
//MinimedTargetType targetType;
MedtronicDeviceType devices;
private int recordLength = 64;
@ -216,51 +212,43 @@ public enum MedtronicCommandType implements Serializable // , MinimedCommandType
}
MedtronicCommandType(int code, String description, MinimedTargetType targetType, MedtronicDeviceType devices,
MinimedCommandParameterType parameterType) {
this(code, description, targetType, devices, parameterType, 64, 1, 0, 0, 0, 0);
}
MedtronicCommandType(int code, String description, MinimedTargetType targetType, MedtronicDeviceType devices,
MinimedCommandParameterType parameterType, int expectedLength) {
this(code, description, targetType, devices, parameterType, 64, 1, 0, 0, 0, expectedLength);
}
MedtronicCommandType(int code, String description, MinimedTargetType targetType, MedtronicDeviceType devices,
MinimedCommandParameterType parameterType, int recordLength, int maxRecords, int commandType) {
this(code, description, targetType, devices, parameterType, recordLength, maxRecords, 0, 0, commandType, 0);
}
MedtronicCommandType(int code, String description, MinimedTargetType targetType, MedtronicDeviceType devices,
MinimedCommandParameterType parameterType, int recordLength, int maxRecords, int commandType,
int expectedLength) {
this(code, description, targetType, devices, parameterType, recordLength, maxRecords, 0, 0, commandType,
expectedLength);
}
MedtronicCommandType(int code, String description, MinimedTargetType targetType, MedtronicDeviceType devices,
MinimedCommandParameterType parameterType, byte[] cmd_params) {
this(code, description, targetType, devices, parameterType, 0, 1, 0, 0, 11, 0);
// MedtronicCommandType(int code, String description, MedtronicDeviceType devices,
// MinimedCommandParameterType parameterType) {
// this(code, description, devices, parameterType, 64, 1, 0, 0, 0, 0);
// }
//
//
// MedtronicCommandType(int code, String description, MedtronicDeviceType devices,
// MinimedCommandParameterType parameterType, int expectedLength) {
// this(code, description, devices, parameterType, 64, 1, 0, 0, 0, expectedLength);
// }
//
//
// MedtronicCommandType(int code, String description, MedtronicDeviceType devices,
// MinimedCommandParameterType parameterType, int recordLength, int maxRecords, int commandType) {
// this(code, description, devices, parameterType, recordLength, maxRecords, 0, 0, commandType, 0);
// }
//
//
// MedtronicCommandType(int code, String description, MedtronicDeviceType devices,
// MinimedCommandParameterType parameterType, int recordLength, int maxRecords, int commandType,
// int expectedLength) {
// this(code, description, devices, parameterType, recordLength, maxRecords, 0, 0, commandType,
// expectedLength);
// }
//
//
MedtronicCommandType(int code, String description, MedtronicDeviceType devices,
MinimedCommandParameterType parameterType, byte[] cmd_params) {
this(code, description, devices, parameterType, 0, 1, 0, 0, 11, 0);
this.commandParameters = cmd_params;
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, //
MinimedCommandParameterType parameterType) {
MinimedCommandParameterType parameterType) {
this(code, description, devices, parameterType, 64, 1, 0, null);
}
@ -268,31 +256,31 @@ public enum MedtronicCommandType implements Serializable // , MinimedCommandType
// NEW
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, devices, parameterType, recordLength, maxRecords, 0, null);
}
// NEW
MedtronicCommandType(int code, String description, MedtronicDeviceType devices, //
MinimedCommandParameterType parameterType, int expectedLength) {
MinimedCommandParameterType parameterType, int expectedLength) {
this(code, description, devices, parameterType, 64, 1, expectedLength, null);
}
// NEW
MedtronicCommandType(int code, String description, MedtronicDeviceType devices, //
MinimedCommandParameterType parameterType, int expectedLength, int resourceId) {
MinimedCommandParameterType parameterType, int expectedLength, int resourceId) {
this(code, description, devices, parameterType, 64, 1, expectedLength, resourceId);
}
// NEW
MedtronicCommandType(int code, String description,
MedtronicDeviceType devices, //
MinimedCommandParameterType parameterType, int recordLength, int max_recs, int expectedLength,
Integer resourceId) {
this.commandCode = (byte)code;
MedtronicDeviceType devices, //
MinimedCommandParameterType parameterType, int recordLength, int max_recs, int expectedLength,
Integer resourceId) {
this.commandCode = (byte) code;
this.commandDescription = description;
this.devices = devices;
this.recordLength = recordLength;
@ -311,12 +299,12 @@ public enum MedtronicCommandType implements Serializable // , MinimedCommandType
@Deprecated
MedtronicCommandType(int code, String description, MinimedTargetType targetType, MedtronicDeviceType devices, //
MinimedCommandParameterType parameterType, int recordLength, int max_recs, int addy, //
int addy_len, int cmd_type, int expectedLength) {
this.commandCode = (byte)code;
MedtronicCommandType(int code, String description, MedtronicDeviceType devices, //
MinimedCommandParameterType parameterType, int recordLength, int max_recs, int addy, //
int addy_len, int cmd_type, int expectedLength) {
this.commandCode = (byte) code;
this.commandDescription = description;
this.targetType = targetType;
//this.targetType = targetType;
this.devices = devices;
this.recordLength = recordLength;
this.maxRecords = max_recs;
@ -349,7 +337,7 @@ public enum MedtronicCommandType implements Serializable // , MinimedCommandType
byte[] array = new byte[data.length];
for (int i = 0; i < data.length; i++) {
array[i] = (byte)data[i];
array[i] = (byte) data[i];
}
return array;
@ -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) {
if (mapByCode.containsKey(code)) {
return mapByCode.get(code);
@ -421,7 +383,7 @@ public enum MedtronicCommandType implements Serializable // , MinimedCommandType
*/
public String getFullCommandDescription() {
return "Command [name=" + this.name() + ", id=" + this.commandCode + ",description=" + this.commandDescription
+ "] ";
+ "] ";
}

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(), //
ClearBolusBlock(), //
ResetRileyLinkConfiguration(), //
;
@Override

View file

@ -13,45 +13,38 @@ public enum MedtronicDeviceType {
Unknown_Device, //
// Pump
// Medtronic_508_508c(null, null), //
Medtronic_511(MedtronicConverterType.Pump511Converter, null, "511"), //
Medtronic_511("511"), //
Medtronic_512(MedtronicConverterType.Pump512Converter, null, "512"), //
Medtronic_712(MedtronicConverterType.Pump512Converter, null, "712"), //
Medtronic_512("512"), //
Medtronic_712("712"), //
Medtronic_512_712(Medtronic_512, Medtronic_712), //
Medtronic_515(MedtronicConverterType.Pump515Converter, null, "515"), //
Medtronic_715(MedtronicConverterType.Pump515Converter, null, "715"), //
Medtronic_515("515"), //
Medtronic_715("715"), //
Medtronic_515_715(Medtronic_515, Medtronic_715), //
Medtronic_522(MedtronicConverterType.Pump515Converter, MedtronicConverterType.CGMS522Converter, "522"), //
Medtronic_722(MedtronicConverterType.Pump515Converter, MedtronicConverterType.CGMS522Converter, "722"), //
Medtronic_522("522"), //
Medtronic_722("722"), //
Medtronic_522_722(Medtronic_522, Medtronic_722), //
Medtronic_523_Revel(MedtronicConverterType.Pump523Converter, MedtronicConverterType.CGMS523Converter, "523"), //
Medtronic_723_Revel(MedtronicConverterType.Pump523Converter, MedtronicConverterType.CGMS523Converter, "723"), //
Medtronic_523_Revel("523"), //
Medtronic_723_Revel("723"), //
Medtronic_554_Veo(MedtronicConverterType.Pump523Converter, MedtronicConverterType.CGMS523Converter, "554"), //
Medtronic_754_Veo(MedtronicConverterType.Pump523Converter, MedtronicConverterType.CGMS523Converter, "754"), //
// Minimed_640G(MedtronicConverterType.Pump523Converter, MedtronicConverterType.CGMS523Converter, "640G", null),
Medtronic_554_Veo("554"), //
Medtronic_754_Veo("754"), //
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), //
Medtronic_515andHigher(Medtronic_515, Medtronic_715, Medtronic_522, Medtronic_722, Medtronic_523_Revel, Medtronic_723_Revel, //
Medtronic_554_Veo, Medtronic_754_Veo), //
Medtronic_554_Veo, Medtronic_754_Veo), //
Medtronic_522andHigher(Medtronic_522, Medtronic_722, Medtronic_523_Revel, Medtronic_723_Revel, //
Medtronic_554_Veo, Medtronic_754_Veo), //
Medtronic_554_Veo, Medtronic_754_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), //
// CGMS
MedtronicCGMSGold(null, MedtronicConverterType.CGMS522Converter, null), //
MedtronicGuradianRealTime(null, MedtronicConverterType.CGMS522Converter, null), //
//
All;
@ -71,21 +64,14 @@ public enum MedtronicDeviceType {
}
MedtronicConverterType pumpConverter;
MedtronicConverterType cgmsConverter;
private String pumpModel;
// String smallReservoirPump;
// String bigReservoirPump;
private boolean isFamily;
private MedtronicDeviceType[] familyMembers = null;
MedtronicDeviceType(MedtronicConverterType pumpConverter, MedtronicConverterType cgmsConverter, String pumpModel) {
MedtronicDeviceType(String pumpModel) {
this.isFamily = false;
this.pumpConverter = pumpConverter;
this.cgmsConverter = cgmsConverter;
this.pumpModel = pumpModel;
}
@ -134,16 +120,6 @@ public enum MedtronicDeviceType {
}
public MedtronicConverterType getCGMSConverterType() {
return cgmsConverter;
}
public MedtronicConverterType getPumpConverterType() {
return pumpConverter;
}
public boolean isLargerFormat() {
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.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) {
this.filteredHistoryList.addAll(list);
@ -84,7 +84,7 @@ public class MedtronicHistoryActivity extends Activity {
this.recyclerViewAdapter.notifyDataSetChanged();
}
LOG.debug("Items on filtered list: {}", filteredHistoryList.size());
//LOG.debug("Items on filtered list: {}", filteredHistoryList.size());
}
@ -124,9 +124,9 @@ public class MedtronicHistoryActivity extends Activity {
super.onCreate(savedInstanceState);
setContentView(R.layout.medtronic_history_activity);
historyTypeSpinner = (Spinner)findViewById(R.id.medtronic_historytype);
statusView = (TextView)findViewById(R.id.medtronic_historystatus);
recyclerView = (RecyclerView)findViewById(R.id.medtronic_history_recyclerview);
historyTypeSpinner = (Spinner) findViewById(R.id.medtronic_historytype);
statusView = (TextView) findViewById(R.id.medtronic_historystatus);
recyclerView = (RecyclerView) findViewById(R.id.medtronic_history_recyclerview);
recyclerView.setHasFixedSize(true);
llm = new LinearLayoutManager(this);
@ -148,7 +148,7 @@ public class MedtronicHistoryActivity extends Activity {
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
if (manualChange)
return;
TypeList selected = (TypeList)historyTypeSpinner.getSelectedItem();
TypeList selected = (TypeList) historyTypeSpinner.getSelectedItem();
showingType = selected;
selectedGroup = selected.entryGroup;
filterHistory(selectedGroup);
@ -218,7 +218,7 @@ public class MedtronicHistoryActivity extends Activity {
@Override
public HistoryViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) {
View v = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.medtronic_history_item, //
viewGroup, false);
viewGroup, false);
return new HistoryViewHolder(v);
}
@ -256,9 +256,9 @@ public class MedtronicHistoryActivity extends Activity {
HistoryViewHolder(View itemView) {
super(itemView);
// cv = (CardView)itemView.findViewById(R.id.rileylink_history_item);
timeView = (TextView)itemView.findViewById(R.id.medtronic_history_time);
typeView = (TextView)itemView.findViewById(R.id.medtronic_history_source);
valueView = (TextView)itemView.findViewById(R.id.medtronic_history_description);
timeView = (TextView) itemView.findViewById(R.id.medtronic_history_time);
typeView = (TextView) itemView.findViewById(R.id.medtronic_history_source);
valueView = (TextView) itemView.findViewById(R.id.medtronic_history_description);
}
}
}

View file

@ -1,8 +1,5 @@
package info.nightscout.androidaps.plugins.pump.medtronic.dialog;
import java.util.ArrayList;
import java.util.List;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
@ -12,6 +9,9 @@ import android.widget.BaseAdapter;
import android.widget.ListView;
import android.widget.TextView;
import java.util.ArrayList;
import java.util.List;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.plugins.pump.common.dialog.RefreshableInterface;
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.
* <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
@Deprecated
// TODO needs to be implemented
public class RileyLinkStatusDeviceMedtronic extends Fragment implements RefreshableInterface {
// @BindView(R.id.rileylink_history_list)
@ -45,7 +48,7 @@ public class RileyLinkStatusDeviceMedtronic extends Fragment implements Refresha
public void 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);
@ -136,12 +139,12 @@ public class RileyLinkStatusDeviceMedtronic extends Fragment implements Refresha
if (view == null) {
view = mInflator.inflate(R.layout.rileylink_status_device_item, null);
viewHolder = new RileyLinkStatusDeviceMedtronic.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);
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 = (RileyLinkStatusDeviceMedtronic.ViewHolder)view.getTag();
viewHolder = (RileyLinkStatusDeviceMedtronic.ViewHolder) view.getTag();
}
RLHistoryItem item = historyItemList.get(i);

View file

@ -199,11 +199,6 @@ public class RileyLinkMedtronicService extends RileyLinkService {
}
public boolean handleIncomingServiceTransport(Intent intent) {
return false;
}
private boolean isLogEnabled() {
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);
}
}