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:
parent
85381af2fb
commit
00f141aa03
33 changed files with 448 additions and 803 deletions
|
@ -105,7 +105,7 @@ android {
|
||||||
multiDexEnabled true
|
multiDexEnabled true
|
||||||
versionCode 1500
|
versionCode 1500
|
||||||
// dev_version: 2.3.1-dev
|
// dev_version: 2.3.1-dev
|
||||||
version "medtronic-0.10.5-SNAPSHOT"
|
version "medtronic-0.10.6-SNAPSHOT"
|
||||||
buildConfigField "String", "VERSION", '"' + version + '"'
|
buildConfigField "String", "VERSION", '"' + version + '"'
|
||||||
buildConfigField "String", "BUILDVERSION", '"' + generateGitBuild() + '-' + generateDate() + '"'
|
buildConfigField "String", "BUILDVERSION", '"' + generateGitBuild() + '-' + generateDate() + '"'
|
||||||
buildConfigField "String", "HEAD", '"' + generateGitBuild() + '"'
|
buildConfigField "String", "HEAD", '"' + generateGitBuild() + '"'
|
||||||
|
|
|
@ -644,14 +644,27 @@ public class LoopPlugin extends PluginBase {
|
||||||
TreatmentsInterface activeTreatments = TreatmentsPlugin.getPlugin();
|
TreatmentsInterface activeTreatments = TreatmentsPlugin.getPlugin();
|
||||||
|
|
||||||
LoopPlugin.getPlugin().disconnectTo(System.currentTimeMillis() + durationInMinutes * 60 * 1000L);
|
LoopPlugin.getPlugin().disconnectTo(System.currentTimeMillis() + durationInMinutes * 60 * 1000L);
|
||||||
ConfigBuilderPlugin.getPlugin().getCommandQueue().tempBasalPercent(0, durationInMinutes, true, profile, new Callback() {
|
|
||||||
@Override
|
if (pump.getPumpDescription().tempBasalStyle == PumpDescription.ABSOLUTE) {
|
||||||
public void run() {
|
ConfigBuilderPlugin.getPlugin().getCommandQueue().tempBasalAbsolute(0, durationInMinutes, true, profile, new Callback() {
|
||||||
if (!result.success) {
|
@Override
|
||||||
ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.gs(R.string.tempbasaldeliveryerror));
|
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()) {
|
if (pump.getPumpDescription().isExtendedBolusCapable && activeTreatments.isInHistoryExtendedBoluslInProgress()) {
|
||||||
ConfigBuilderPlugin.getPlugin().getCommandQueue().cancelExtended(new Callback() {
|
ConfigBuilderPlugin.getPlugin().getCommandQueue().cancelExtended(new Callback() {
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -853,19 +853,38 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
loopPlugin.superBolusTo(System.currentTimeMillis() + T.hours(2).msecs());
|
loopPlugin.superBolusTo(System.currentTimeMillis() + T.hours(2).msecs());
|
||||||
MainApp.bus().post(new EventRefreshOverview("WizardDialog"));
|
MainApp.bus().post(new EventRefreshOverview("WizardDialog"));
|
||||||
}
|
}
|
||||||
ConfigBuilderPlugin.getPlugin().getCommandQueue().tempBasalPercent(0, 120, true, profile, new Callback() {
|
|
||||||
@Override
|
PumpInterface pump = ConfigBuilderPlugin.getPlugin().getActivePump();
|
||||||
public void run() {
|
|
||||||
if (!result.success) {
|
if (pump.getPumpDescription().tempBasalStyle == PumpDescription.ABSOLUTE) {
|
||||||
Intent i = new Intent(MainApp.instance(), ErrorHelperActivity.class);
|
ConfigBuilderPlugin.getPlugin().getCommandQueue().tempBasalAbsolute(0.0d, 120, true, profile, new Callback() {
|
||||||
i.putExtra("soundid", R.raw.boluserror);
|
@Override
|
||||||
i.putExtra("status", result.comment);
|
public void run() {
|
||||||
i.putExtra("title", MainApp.gs(R.string.tempbasaldeliveryerror));
|
if (!result.success) {
|
||||||
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
Intent i = new Intent(MainApp.instance(), ErrorHelperActivity.class);
|
||||||
MainApp.instance().startActivity(i);
|
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 detailedBolusInfo = new DetailedBolusInfo();
|
||||||
detailedBolusInfo.eventType = CareportalEvent.BOLUSWIZARD;
|
detailedBolusInfo.eventType = CareportalEvent.BOLUSWIZARD;
|
||||||
|
|
|
@ -53,6 +53,7 @@ import info.nightscout.androidaps.events.EventFeatureRunning;
|
||||||
import info.nightscout.androidaps.events.EventRefreshOverview;
|
import info.nightscout.androidaps.events.EventRefreshOverview;
|
||||||
import info.nightscout.androidaps.interfaces.Constraint;
|
import info.nightscout.androidaps.interfaces.Constraint;
|
||||||
import info.nightscout.androidaps.interfaces.PluginType;
|
import info.nightscout.androidaps.interfaces.PluginType;
|
||||||
|
import info.nightscout.androidaps.interfaces.PumpDescription;
|
||||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||||
import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin;
|
import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin;
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
|
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
|
||||||
|
@ -354,19 +355,39 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com
|
||||||
loopPlugin.superBolusTo(System.currentTimeMillis() + 2 * 60L * 60 * 1000);
|
loopPlugin.superBolusTo(System.currentTimeMillis() + 2 * 60L * 60 * 1000);
|
||||||
MainApp.bus().post(new EventRefreshOverview("WizardDialog"));
|
MainApp.bus().post(new EventRefreshOverview("WizardDialog"));
|
||||||
}
|
}
|
||||||
ConfigBuilderPlugin.getPlugin().getCommandQueue().tempBasalPercent(0, 120, true, profile, new Callback() {
|
|
||||||
@Override
|
PumpInterface pump = ConfigBuilderPlugin.getPlugin().getActivePump();
|
||||||
public void run() {
|
|
||||||
if (!result.success) {
|
if (pump.getPumpDescription().tempBasalStyle == PumpDescription.ABSOLUTE) {
|
||||||
Intent i = new Intent(MainApp.instance(), ErrorHelperActivity.class);
|
ConfigBuilderPlugin.getPlugin().getCommandQueue().tempBasalAbsolute(0.0d, 120, true, profile, new Callback() {
|
||||||
i.putExtra("soundid", R.raw.boluserror);
|
@Override
|
||||||
i.putExtra("status", result.comment);
|
public void run() {
|
||||||
i.putExtra("title", MainApp.gs(R.string.tempbasaldeliveryerror));
|
if (!result.success) {
|
||||||
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
Intent i = new Intent(MainApp.instance(), ErrorHelperActivity.class);
|
||||||
MainApp.instance().startActivity(i);
|
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 detailedBolusInfo = new DetailedBolusInfo();
|
||||||
detailedBolusInfo.eventType = CareportalEvent.BOLUSWIZARD;
|
detailedBolusInfo.eventType = CareportalEvent.BOLUSWIZARD;
|
||||||
|
|
|
@ -52,7 +52,7 @@ public class RFSpy {
|
||||||
private UUID responseCountUUID = UUID.fromString(GattAttributes.CHARA_RADIO_RESPONSE_COUNT);
|
private UUID responseCountUUID = UUID.fromString(GattAttributes.CHARA_RADIO_RESPONSE_COUNT);
|
||||||
private RileyLinkFirmwareVersion firmwareVersion;
|
private RileyLinkFirmwareVersion firmwareVersion;
|
||||||
private String bleVersion; // We don't use it so no need of sofisticated logic
|
private String bleVersion; // We don't use it so no need of sofisticated logic
|
||||||
double currentFrequencyMHz;
|
Double currentFrequencyMHz;
|
||||||
|
|
||||||
|
|
||||||
public RFSpy(RileyLinkBLE rileyLinkBle) {
|
public RFSpy(RileyLinkBLE rileyLinkBle) {
|
||||||
|
@ -415,7 +415,8 @@ public class RFSpy {
|
||||||
* Reset RileyLink Configuration (set all updateRegisters)
|
* Reset RileyLink Configuration (set all updateRegisters)
|
||||||
*/
|
*/
|
||||||
public void resetRileyLinkConfiguration() {
|
public void resetRileyLinkConfiguration() {
|
||||||
this.setBaseFrequency(this.currentFrequencyMHz);
|
if (this.currentFrequencyMHz != null)
|
||||||
|
this.setBaseFrequency(this.currentFrequencyMHz);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -120,9 +120,6 @@ public abstract class RileyLinkService extends Service {
|
||||||
public abstract RileyLinkCommunicationManager getDeviceCommunicationManager();
|
public abstract RileyLinkCommunicationManager getDeviceCommunicationManager();
|
||||||
|
|
||||||
|
|
||||||
public abstract boolean handleIncomingServiceTransport(Intent intent);
|
|
||||||
|
|
||||||
|
|
||||||
// Here is where the wake-lock begins:
|
// Here is where the wake-lock begins:
|
||||||
// We've received a service startCommand, we grab the lock.
|
// We've received a service startCommand, we grab the lock.
|
||||||
@Override
|
@Override
|
||||||
|
@ -175,7 +172,7 @@ public abstract class RileyLinkService extends Service {
|
||||||
} else {
|
} else {
|
||||||
if (isLogEnabled())
|
if (isLogEnabled())
|
||||||
LOG.warn("Disconnecting from old RL (" + rileyLinkServiceData.rileylinkAddress
|
LOG.warn("Disconnecting from old RL (" + rileyLinkServiceData.rileylinkAddress
|
||||||
+ "), reconnecting to new: " + deviceAddress);
|
+ "), reconnecting to new: " + deviceAddress);
|
||||||
|
|
||||||
rileyLinkBLE.disconnect();
|
rileyLinkBLE.disconnect();
|
||||||
// prolly need to shut down listening thread too?
|
// prolly need to shut down listening thread too?
|
||||||
|
@ -192,7 +189,7 @@ public abstract class RileyLinkService extends Service {
|
||||||
if (RileyLinkUtil.getServiceState() == RileyLinkServiceState.NotStarted) {
|
if (RileyLinkUtil.getServiceState() == RileyLinkServiceState.NotStarted) {
|
||||||
if (!bluetoothInit()) {
|
if (!bluetoothInit()) {
|
||||||
LOG.error("RileyLink can't get activated, Bluetooth is not functioning correctly. {}",
|
LOG.error("RileyLink can't get activated, Bluetooth is not functioning correctly. {}",
|
||||||
RileyLinkUtil.getError().name());
|
RileyLinkUtil.getError().name());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -238,7 +235,7 @@ public abstract class RileyLinkService extends Service {
|
||||||
if (newFrequency == 0.0d) {
|
if (newFrequency == 0.0d) {
|
||||||
// error tuning pump, pump not present ??
|
// error tuning pump, pump not present ??
|
||||||
RileyLinkUtil
|
RileyLinkUtil
|
||||||
.setServiceState(RileyLinkServiceState.PumpConnectorError, RileyLinkError.TuneUpOfDeviceFailed);
|
.setServiceState(RileyLinkServiceState.PumpConnectorError, RileyLinkError.TuneUpOfDeviceFailed);
|
||||||
} else {
|
} else {
|
||||||
getRileyLinkCommunicationManager().clearNotConnectedCount();
|
getRileyLinkCommunicationManager().clearNotConnectedCount();
|
||||||
RileyLinkUtil.setServiceState(RileyLinkServiceState.PumpConnectorReady);
|
RileyLinkUtil.setServiceState(RileyLinkServiceState.PumpConnectorReady);
|
||||||
|
@ -271,7 +268,7 @@ public abstract class RileyLinkService extends Service {
|
||||||
|
|
||||||
|
|
||||||
public void changeRileyLinkEncoding(RileyLinkEncodingType encodingType) {
|
public void changeRileyLinkEncoding(RileyLinkEncodingType encodingType) {
|
||||||
if (rfspy!=null) {
|
if (rfspy != null) {
|
||||||
rfspy.setRileyLinkEncoding(encodingType);
|
rfspy.setRileyLinkEncoding(encodingType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,16 +1,10 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.medtronic;
|
package info.nightscout.androidaps.plugins.pump.medtronic;
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.SystemClock;
|
|
||||||
import android.text.Spanned;
|
import android.text.Spanned;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
@ -19,14 +13,18 @@ import android.widget.Button;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import butterknife.BindView;
|
|
||||||
import butterknife.ButterKnife;
|
|
||||||
import butterknife.OnClick;
|
|
||||||
|
|
||||||
import com.crashlytics.android.Crashlytics;
|
import com.crashlytics.android.Crashlytics;
|
||||||
import com.joanzapata.iconify.widget.IconTextView;
|
import com.joanzapata.iconify.widget.IconTextView;
|
||||||
import com.squareup.otto.Subscribe;
|
import com.squareup.otto.Subscribe;
|
||||||
|
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
import butterknife.BindView;
|
||||||
|
import butterknife.ButterKnife;
|
||||||
|
import butterknife.OnClick;
|
||||||
import info.nightscout.androidaps.MainApp;
|
import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.events.EventExtendedBolusChange;
|
import info.nightscout.androidaps.events.EventExtendedBolusChange;
|
||||||
|
@ -35,7 +33,6 @@ import info.nightscout.androidaps.events.EventTempBasalChange;
|
||||||
import info.nightscout.androidaps.logging.L;
|
import info.nightscout.androidaps.logging.L;
|
||||||
import info.nightscout.androidaps.plugins.common.SubscriberFragment;
|
import info.nightscout.androidaps.plugins.common.SubscriberFragment;
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
|
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
|
||||||
import info.nightscout.androidaps.plugins.general.overview.dialogs.MessageHelperActivity;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkUtil;
|
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkUtil;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkError;
|
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkError;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkServiceState;
|
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkServiceState;
|
||||||
|
@ -239,8 +236,8 @@ public class MedtronicFragment extends SubscriberFragment {
|
||||||
|
|
||||||
private synchronized void setDeviceStatus(MedtronicPumpStatus pumpStatus) {
|
private synchronized void setDeviceStatus(MedtronicPumpStatus pumpStatus) {
|
||||||
|
|
||||||
pumpStatus.rileyLinkServiceState = (RileyLinkServiceState)checkStatusSet(pumpStatus.rileyLinkServiceState,
|
pumpStatus.rileyLinkServiceState = (RileyLinkServiceState) checkStatusSet(pumpStatus.rileyLinkServiceState,
|
||||||
RileyLinkUtil.getServiceState());
|
RileyLinkUtil.getServiceState());
|
||||||
|
|
||||||
if (pumpStatus.rileyLinkServiceState != null && rileyLinkStatus != null) {
|
if (pumpStatus.rileyLinkServiceState != null && rileyLinkStatus != null) {
|
||||||
|
|
||||||
|
@ -261,7 +258,7 @@ public class MedtronicFragment extends SubscriberFragment {
|
||||||
rileyLinkStatus.setText("{fa-bluetooth-b} " + getTranslation(resourceId));
|
rileyLinkStatus.setText("{fa-bluetooth-b} " + getTranslation(resourceId));
|
||||||
else
|
else
|
||||||
rileyLinkStatus.setText("{fa-bluetooth-b} "
|
rileyLinkStatus.setText("{fa-bluetooth-b} "
|
||||||
+ getTranslation(rileyLinkError.getResourceId(RileyLinkTargetDevice.MedtronicPump)));
|
+ getTranslation(rileyLinkError.getResourceId(RileyLinkTargetDevice.MedtronicPump)));
|
||||||
|
|
||||||
rileyLinkStatus.setTextColor(Color.RED);
|
rileyLinkStatus.setTextColor(Color.RED);
|
||||||
} else {
|
} 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 (errorsView != null) {
|
||||||
if (pumpStatus.rileyLinkError != null) {
|
if (pumpStatus.rileyLinkError != null) {
|
||||||
|
@ -279,8 +276,8 @@ public class MedtronicFragment extends SubscriberFragment {
|
||||||
errorsView.setText("-");
|
errorsView.setText("-");
|
||||||
}
|
}
|
||||||
|
|
||||||
pumpStatus.pumpDeviceState = (PumpDeviceState)checkStatusSet(pumpStatus.pumpDeviceState,
|
pumpStatus.pumpDeviceState = (PumpDeviceState) checkStatusSet(pumpStatus.pumpDeviceState,
|
||||||
MedtronicUtil.getPumpDeviceState());
|
MedtronicUtil.getPumpDeviceState());
|
||||||
|
|
||||||
if (pumpStatusIconView != null) {
|
if (pumpStatusIconView != null) {
|
||||||
|
|
||||||
|
@ -314,10 +311,10 @@ public class MedtronicFragment extends SubscriberFragment {
|
||||||
|
|
||||||
if (MedtronicUtil.frameNumber == null) {
|
if (MedtronicUtil.frameNumber == null) {
|
||||||
pumpStatusIconView.setText(MainApp.gs(
|
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 {
|
} else {
|
||||||
pumpStatusIconView.setText(MainApp.gs(resourceId, MedtronicUtil.pageNumber,
|
pumpStatusIconView.setText(MainApp.gs(resourceId, MedtronicUtil.pageNumber,
|
||||||
MedtronicUtil.frameNumber));
|
MedtronicUtil.frameNumber));
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
@ -331,9 +328,9 @@ public class MedtronicFragment extends SubscriberFragment {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
LOG.warn("Unknown pump state: " + pumpStatus.pumpDeviceState);
|
LOG.warn("Unknown pump state: " + pumpStatus.pumpDeviceState);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -421,7 +418,7 @@ public class MedtronicFragment extends SubscriberFragment {
|
||||||
return;
|
return;
|
||||||
|
|
||||||
localActivity = activity;
|
localActivity = activity;
|
||||||
MedtronicPumpPlugin plugin = (MedtronicPumpPlugin)MedtronicPumpPlugin.getPlugin();
|
MedtronicPumpPlugin plugin = (MedtronicPumpPlugin) MedtronicPumpPlugin.getPlugin();
|
||||||
MedtronicPumpStatus pumpStatus = MedtronicUtil.getPumpStatus();
|
MedtronicPumpStatus pumpStatus = MedtronicUtil.getPumpStatus();
|
||||||
|
|
||||||
setDeviceStatus(pumpStatus);
|
setDeviceStatus(pumpStatus);
|
||||||
|
@ -437,18 +434,18 @@ public class MedtronicFragment extends SubscriberFragment {
|
||||||
if (min < 60) {
|
if (min < 60) {
|
||||||
lastConnectionView.setText(MainApp.gs(R.string.minago, min));
|
lastConnectionView.setText(MainApp.gs(R.string.minago, min));
|
||||||
} else if (min < 1440) {
|
} else if (min < 1440) {
|
||||||
int h = (int)(min / 60);
|
int h = (int) (min / 60);
|
||||||
|
|
||||||
lastConnectionView.setText(MainApp.gq(R.plurals.objective_hours, h, h) + " "
|
lastConnectionView.setText(MainApp.gq(R.plurals.objective_hours, h, h) + " "
|
||||||
+ MainApp.gs(R.string.ago));
|
+ MainApp.gs(R.string.ago));
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
int h = (int)(min / 60);
|
int h = (int) (min / 60);
|
||||||
int d = h / 24;
|
int d = h / 24;
|
||||||
// h = h - (d * 24);
|
// h = h - (d * 24);
|
||||||
|
|
||||||
lastConnectionView.setText(MainApp.gq(R.plurals.objective_days, d, d) + " "
|
lastConnectionView.setText(MainApp.gq(R.plurals.objective_days, d, d) + " "
|
||||||
+ MainApp.gs(R.string.ago));
|
+ MainApp.gs(R.string.ago));
|
||||||
}
|
}
|
||||||
lastConnectionView.setTextColor(Color.RED);
|
lastConnectionView.setTextColor(Color.RED);
|
||||||
} else {
|
} else {
|
||||||
|
@ -478,12 +475,12 @@ public class MedtronicFragment extends SubscriberFragment {
|
||||||
|
|
||||||
// base basal rate
|
// base basal rate
|
||||||
basaBasalRateView.setText("(" + (pumpStatus.activeProfileName) + ") "
|
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 (ConfigBuilderPlugin.getPlugin().getActivePump().isFakingTempsByExtendedBoluses()) {
|
||||||
if (TreatmentsPlugin.getPlugin().isInHistoryRealTempBasalInProgress()) {
|
if (TreatmentsPlugin.getPlugin().isInHistoryRealTempBasalInProgress()) {
|
||||||
tempBasalView.setText(TreatmentsPlugin.getPlugin()
|
tempBasalView.setText(TreatmentsPlugin.getPlugin()
|
||||||
.getRealTempBasalFromHistory(System.currentTimeMillis()).toStringFull());
|
.getRealTempBasalFromHistory(System.currentTimeMillis()).toStringFull());
|
||||||
} else {
|
} else {
|
||||||
tempBasalView.setText("");
|
tempBasalView.setText("");
|
||||||
}
|
}
|
||||||
|
@ -491,14 +488,14 @@ public class MedtronicFragment extends SubscriberFragment {
|
||||||
// v2 plugin
|
// v2 plugin
|
||||||
if (TreatmentsPlugin.getPlugin().isTempBasalInProgress()) {
|
if (TreatmentsPlugin.getPlugin().isTempBasalInProgress()) {
|
||||||
tempBasalView.setText(TreatmentsPlugin.getPlugin()
|
tempBasalView.setText(TreatmentsPlugin.getPlugin()
|
||||||
.getTempBasalFromHistory(System.currentTimeMillis()).toStringFull());
|
.getTempBasalFromHistory(System.currentTimeMillis()).toStringFull());
|
||||||
} else {
|
} else {
|
||||||
tempBasalView.setText("");
|
tempBasalView.setText("");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// battery
|
// battery
|
||||||
if (MedtronicUtil.getBatteryType()== BatteryType.None || pumpStatus.batteryVoltage==null) {
|
if (MedtronicUtil.getBatteryType() == BatteryType.None || pumpStatus.batteryVoltage == null) {
|
||||||
batteryView.setText("{fa-battery-" + (pumpStatus.batteryRemaining / 25) + "} ");
|
batteryView.setText("{fa-battery-" + (pumpStatus.batteryRemaining / 25) + "} ");
|
||||||
} else {
|
} else {
|
||||||
batteryView.setText("{fa-battery-" + (pumpStatus.batteryRemaining / 25) + "} " + pumpStatus.batteryRemaining + "%" + String.format(" (%.2f V)", pumpStatus.batteryVoltage));
|
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
|
// reservoir
|
||||||
reservoirView.setText(DecimalFormatter.to0Decimal(pumpStatus.reservoirRemainingUnits) + " / "
|
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);
|
SetWarnColor.setColorInverse(reservoirView, pumpStatus.reservoirRemainingUnits, 50d, 20d);
|
||||||
|
|
||||||
errorsView.setText(pumpStatus.getErrorInfo());
|
errorsView.setText(pumpStatus.getErrorInfo());
|
||||||
|
|
|
@ -3,13 +3,11 @@ package info.nightscout.androidaps.plugins.pump.medtronic;
|
||||||
import android.content.ComponentName;
|
import android.content.ComponentName;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.ServiceConnection;
|
import android.content.ServiceConnection;
|
||||||
|
import android.os.Bundle;
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
import android.os.SystemClock;
|
import android.os.SystemClock;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
|
||||||
import com.google.gson.GsonBuilder;
|
|
||||||
|
|
||||||
import org.joda.time.LocalDateTime;
|
import org.joda.time.LocalDateTime;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
@ -24,6 +22,7 @@ import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.BuildConfig;
|
||||||
import info.nightscout.androidaps.MainApp;
|
import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.data.DetailedBolusInfo;
|
import info.nightscout.androidaps.data.DetailedBolusInfo;
|
||||||
|
@ -97,13 +96,9 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
|
||||||
private MedtronicCommunicationManager medtronicCommunicationManager;
|
private MedtronicCommunicationManager medtronicCommunicationManager;
|
||||||
private PumpHistoryEntry lastPumpHistoryEntry;
|
private PumpHistoryEntry lastPumpHistoryEntry;
|
||||||
|
|
||||||
public static Gson gsonInstance = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create();
|
|
||||||
public static Gson gsonInstancePretty = new GsonBuilder().excludeFieldsWithoutExposeAnnotation()
|
|
||||||
.setPrettyPrinting().create();
|
|
||||||
|
|
||||||
public static boolean isBusy = false;
|
public static boolean isBusy = false;
|
||||||
private List<Long> busyTimestamps = new ArrayList<>();
|
private List<Long> busyTimestamps = new ArrayList<>();
|
||||||
private boolean sendIdToFirebase = false;
|
private boolean sentIdToFirebase = false;
|
||||||
|
|
||||||
|
|
||||||
private MedtronicPumpPlugin() {
|
private MedtronicPumpPlugin() {
|
||||||
|
@ -117,12 +112,9 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
|
||||||
PumpType.Medtronic_522_722 // we default to most basic model, correct model from config is loaded later
|
PumpType.Medtronic_522_722 // we default to most basic model, correct model from config is loaded later
|
||||||
);
|
);
|
||||||
|
|
||||||
// TODO remove this later
|
|
||||||
displayConnectionMessages = false;
|
displayConnectionMessages = false;
|
||||||
|
|
||||||
medtronicHistoryData = new MedtronicHistoryData();
|
medtronicHistoryData = new MedtronicHistoryData();
|
||||||
// medtronicCommunicationManager = MedtronicCommunicationManager.getInstance();
|
|
||||||
// medtronicCommunicationManager.setDoWakeUpBeforeCommand(false);
|
|
||||||
|
|
||||||
serviceConnection = new ServiceConnection() {
|
serviceConnection = new ServiceConnection() {
|
||||||
|
|
||||||
|
@ -241,6 +233,8 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
|
||||||
.readStatus("Scheduled Status Refresh", null);
|
.readStatus("Scheduled Status Refresh", null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
clearBusyQueue();
|
||||||
}
|
}
|
||||||
|
|
||||||
} while (serviceRunning);
|
} while (serviceRunning);
|
||||||
|
@ -318,7 +312,11 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void clearBusyQueue() {
|
private synchronized void clearBusyQueue() {
|
||||||
|
|
||||||
|
if (busyTimestamps.size() == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Set<Long> deleteFromQueue = new HashSet<>();
|
Set<Long> deleteFromQueue = new HashSet<>();
|
||||||
|
|
||||||
|
@ -331,8 +329,7 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
|
||||||
|
|
||||||
if (deleteFromQueue.size() == busyTimestamps.size()) {
|
if (deleteFromQueue.size() == busyTimestamps.size()) {
|
||||||
busyTimestamps.clear();
|
busyTimestamps.clear();
|
||||||
this.customActionClearBolusBlock.setEnabled(false);
|
setEnableCustomAction(MedtronicCustomActionType.ClearBolusBlock, false);
|
||||||
refreshCustomActionsList();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (deleteFromQueue.size() > 0) {
|
if (deleteFromQueue.size() > 0) {
|
||||||
|
@ -541,7 +538,6 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
|
||||||
// read profile (once, later its controlled by isThisProfileSet method)
|
// read profile (once, later its controlled by isThisProfileSet method)
|
||||||
medtronicUIComm.executeCommand(MedtronicCommandType.GetBasalProfileSTD);
|
medtronicUIComm.executeCommand(MedtronicCommandType.GetBasalProfileSTD);
|
||||||
|
|
||||||
// TODO handle if tunning was needed (more than 5 timeouts)
|
|
||||||
int errorCount = medtronicUIComm.getInvalidResponsesCount();
|
int errorCount = medtronicUIComm.getInvalidResponsesCount();
|
||||||
|
|
||||||
if (errorCount >= 5) {
|
if (errorCount >= 5) {
|
||||||
|
@ -559,26 +555,15 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
|
||||||
pumpState = PumpDriverState.Initialized;
|
pumpState = PumpDriverState.Initialized;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!sendIdToFirebase) {
|
if (!sentIdToFirebase) {
|
||||||
|
Bundle params = new Bundle();
|
||||||
|
params.putString("version", BuildConfig.VERSION);
|
||||||
|
MainApp.getFirebaseAnalytics().logEvent("MedtronicPumpInit", params);
|
||||||
|
|
||||||
|
sentIdToFirebase = true;
|
||||||
sendIdToFirebase = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// FIXME andy!!!
|
|
||||||
// MainApp.getFirebaseAnalytics().logCustomEvent(FirebaseAnalytics.Event.SELECT_CONTENT, event);
|
|
||||||
//
|
|
||||||
// FabricPrivacy.getInstance().logCustom( //
|
|
||||||
// new CustomEvent("MedtronicInitializePump") //
|
|
||||||
// .putCustomAttribute("buildversion", BuildConfig.BUILDVERSION) //
|
|
||||||
// .putCustomAttribute("version", BuildConfig.VERSION));
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// MainApp.getFirebaseAnalytics().logEvent();
|
|
||||||
//
|
|
||||||
|
|
||||||
isInitialized = true;
|
isInitialized = true;
|
||||||
// this.pumpState = PumpDriverState.Initialized;
|
// this.pumpState = PumpDriverState.Initialized;
|
||||||
|
|
||||||
|
@ -598,6 +583,7 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
|
||||||
|
|
||||||
boolean invalid = false;
|
boolean invalid = false;
|
||||||
Double[] basalsByHour = getMDTPumpStatus().basalsByHour;
|
Double[] basalsByHour = getMDTPumpStatus().basalsByHour;
|
||||||
|
PumpType pumpType = getMDTPumpStatus().getPumpType();
|
||||||
|
|
||||||
if (isLoggingEnabled())
|
if (isLoggingEnabled())
|
||||||
LOG.debug("Current Basals (h): "
|
LOG.debug("Current Basals (h): "
|
||||||
|
@ -612,26 +598,26 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
|
||||||
|
|
||||||
for (Profile.BasalValue basalValue : profile.getBasalValues()) {
|
for (Profile.BasalValue basalValue : profile.getBasalValues()) {
|
||||||
|
|
||||||
|
double basalValueValue = pumpType.determineCorrectBasalSize(basalValue.value);
|
||||||
|
|
||||||
int hour = basalValue.timeAsSeconds / (60 * 60);
|
int hour = basalValue.timeAsSeconds / (60 * 60);
|
||||||
|
|
||||||
if (!MedtronicUtil.isSame(basalsByHour[hour], basalValue.value)) {
|
if (!MedtronicUtil.isSame(basalsByHour[hour], basalValueValue)) {
|
||||||
invalid = true;
|
invalid = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
stringBuilder.append(String.format(Locale.ENGLISH, "%.3f", basalValue.value));
|
stringBuilder.append(String.format(Locale.ENGLISH, "%.3f", basalValueValue));
|
||||||
stringBuilder.append(" ");
|
stringBuilder.append(" ");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isLoggingEnabled())
|
if (isLoggingEnabled()) {
|
||||||
LOG.debug(stringBuilder.toString());
|
LOG.debug(stringBuilder.toString());
|
||||||
|
|
||||||
if (!invalid) {
|
if (!invalid) {
|
||||||
if (isLoggingEnabled())
|
|
||||||
LOG.debug("Basal profile is same as AAPS one.");
|
LOG.debug("Basal profile is same as AAPS one.");
|
||||||
// basalProfileChanged = false;
|
} else {
|
||||||
} else {
|
|
||||||
if (isLoggingEnabled())
|
|
||||||
LOG.debug("Basal profile on Pump is different than the AAPS one.");
|
LOG.debug("Basal profile on Pump is different than the AAPS one.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return (!invalid);
|
return (!invalid);
|
||||||
|
@ -772,14 +758,13 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
|
||||||
incrementStatistics(detailedBolusInfo.isSMB ? MedtronicConst.Statistics.SMBBoluses
|
incrementStatistics(detailedBolusInfo.isSMB ? MedtronicConst.Statistics.SMBBoluses
|
||||||
: MedtronicConst.Statistics.StandardBoluses);
|
: MedtronicConst.Statistics.StandardBoluses);
|
||||||
|
|
||||||
// if (response)
|
|
||||||
{
|
|
||||||
int bolusTime = (int) (detailedBolusInfo.insulin * 42.0d);
|
|
||||||
long time = System.currentTimeMillis() + (bolusTime * 1000);
|
|
||||||
|
|
||||||
this.busyTimestamps.add(time);
|
// calculate time for bolus and set driver to busy for that time
|
||||||
setEnableCustomAction(MedtronicCustomActionType.ClearBolusBlock, true);
|
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) //
|
return new PumpEnactResult().success(true) //
|
||||||
.enacted(true) //
|
.enacted(true) //
|
||||||
|
@ -975,8 +960,8 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
|
||||||
|
|
||||||
private void readPumpHistory() {
|
private void readPumpHistory() {
|
||||||
|
|
||||||
if (isLoggingEnabled())
|
// if (isLoggingEnabled())
|
||||||
LOG.error(getLogPrefix() + "readPumpHistory WIP.");
|
// LOG.error(getLogPrefix() + "readPumpHistory WIP.");
|
||||||
|
|
||||||
readPumpHistoryLogic();
|
readPumpHistoryLogic();
|
||||||
|
|
||||||
|
@ -1131,7 +1116,7 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
|
||||||
switch (refreshType) {
|
switch (refreshType) {
|
||||||
|
|
||||||
case RemainingInsulin: {
|
case RemainingInsulin: {
|
||||||
Double remaining = pumpStatusLocal.reservoirRemainingUnits;
|
double remaining = pumpStatusLocal.reservoirRemainingUnits;
|
||||||
int min;
|
int min;
|
||||||
if (remaining > 50)
|
if (remaining > 50)
|
||||||
min = 4 * 60;
|
min = 4 * 60;
|
||||||
|
@ -1171,10 +1156,7 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
|
||||||
}
|
}
|
||||||
|
|
||||||
case GetData: {
|
case GetData: {
|
||||||
Map<MedtronicStatusRefreshType, Long> shallowCopy = new HashMap<>();
|
return new HashMap<>(statusRefreshMap);
|
||||||
|
|
||||||
shallowCopy.putAll(statusRefreshMap);
|
|
||||||
return shallowCopy;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.medtronic.comm;
|
package info.nightscout.androidaps.plugins.pump.medtronic.comm;
|
||||||
|
|
||||||
import java.util.List;
|
import android.content.Context;
|
||||||
import java.util.Map;
|
import android.os.SystemClock;
|
||||||
|
|
||||||
import org.joda.time.LocalDateTime;
|
import org.joda.time.LocalDateTime;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import android.content.Context;
|
import java.util.List;
|
||||||
import android.os.SystemClock;
|
import java.util.Map;
|
||||||
|
|
||||||
import info.nightscout.androidaps.logging.L;
|
import info.nightscout.androidaps.logging.L;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkCommunicationManager;
|
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkCommunicationManager;
|
||||||
|
@ -51,6 +51,7 @@ import info.nightscout.androidaps.utils.SP;
|
||||||
* Original file created by geoff on 5/30/16.
|
* Original file created by geoff on 5/30/16.
|
||||||
* <p>
|
* <p>
|
||||||
* Split into 2 implementations, so that we can split it by target device. - Andy
|
* Split into 2 implementations, so that we can split it by target device. - Andy
|
||||||
|
* This was mostly rewritten from Original version
|
||||||
*/
|
*/
|
||||||
public class MedtronicCommunicationManager extends RileyLinkCommunicationManager {
|
public class MedtronicCommunicationManager extends RileyLinkCommunicationManager {
|
||||||
|
|
||||||
|
@ -66,8 +67,6 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
|
||||||
|
|
||||||
private MedtronicPumpHistoryDecoder pumpHistoryDecoder;
|
private MedtronicPumpHistoryDecoder pumpHistoryDecoder;
|
||||||
private boolean doWakeUpBeforeCommand = true;
|
private boolean doWakeUpBeforeCommand = true;
|
||||||
private boolean firstConnection = true;
|
|
||||||
private boolean medtronicHistoryTesting = false; // TODO remove when not needed
|
|
||||||
|
|
||||||
|
|
||||||
public MedtronicCommunicationManager(Context context, RFSpy rfspy) {
|
public MedtronicCommunicationManager(Context context, RFSpy rfspy) {
|
||||||
|
@ -76,7 +75,7 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
|
||||||
this.medtronicConverter = new MedtronicConverter();
|
this.medtronicConverter = new MedtronicConverter();
|
||||||
this.pumpHistoryDecoder = new MedtronicPumpHistoryDecoder();
|
this.pumpHistoryDecoder = new MedtronicPumpHistoryDecoder();
|
||||||
MedtronicUtil.getPumpStatus().previousConnection = SP.getLong(
|
MedtronicUtil.getPumpStatus().previousConnection = SP.getLong(
|
||||||
RileyLinkConst.Prefs.LastGoodDeviceCommunicationTime, 0L);
|
RileyLinkConst.Prefs.LastGoodDeviceCommunicationTime, 0L);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -94,7 +93,7 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
|
||||||
@Override
|
@Override
|
||||||
public <E extends RLMessage> E createResponseMessage(byte[] payload, Class<E> clazz) {
|
public <E extends RLMessage> E createResponseMessage(byte[] payload, Class<E> clazz) {
|
||||||
PumpMessage pumpMessage = new PumpMessage(payload);
|
PumpMessage pumpMessage = new PumpMessage(payload);
|
||||||
return (E)pumpMessage;
|
return (E) pumpMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -156,8 +155,8 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
|
||||||
PumpDeviceState state = MedtronicUtil.getPumpDeviceState();
|
PumpDeviceState state = MedtronicUtil.getPumpDeviceState();
|
||||||
|
|
||||||
byte[] pumpMsgContent = createPumpMessageContent(RLMessageType.ReadSimpleData); // simple
|
byte[] pumpMsgContent = createPumpMessageContent(RLMessageType.ReadSimpleData); // simple
|
||||||
RFSpyResponse rfSpyResponse = rfspy.transmitThenReceive(new RadioPacket(pumpMsgContent), (byte)0, (byte)200,
|
RFSpyResponse rfSpyResponse = rfspy.transmitThenReceive(new RadioPacket(pumpMsgContent), (byte) 0, (byte) 200,
|
||||||
(byte)0, (byte)0, 25000, (byte)0);
|
(byte) 0, (byte) 0, 25000, (byte) 0);
|
||||||
if (isLogEnabled())
|
if (isLogEnabled())
|
||||||
LOG.info("wakeup: raw response is " + ByteUtil.shortHexString(rfSpyResponse.getRaw()));
|
LOG.info("wakeup: raw response is " + ByteUtil.shortHexString(rfSpyResponse.getRaw()));
|
||||||
|
|
||||||
|
@ -178,14 +177,14 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
|
||||||
if (!pumpResponse.isValid()) {
|
if (!pumpResponse.isValid()) {
|
||||||
if (isLogEnabled())
|
if (isLogEnabled())
|
||||||
LOG.warn("Response is invalid ! [interrupted={}, timeout={}]", rfSpyResponse.wasInterrupted(),
|
LOG.warn("Response is invalid ! [interrupted={}, timeout={}]", rfSpyResponse.wasInterrupted(),
|
||||||
rfSpyResponse.wasTimeout());
|
rfSpyResponse.wasTimeout());
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
// radioResponse.rssi;
|
// radioResponse.rssi;
|
||||||
Object dataResponse = medtronicConverter.convertResponse(MedtronicCommandType.PumpModel,
|
Object dataResponse = medtronicConverter.convertResponse(MedtronicCommandType.PumpModel,
|
||||||
pumpResponse.getRawContent());
|
pumpResponse.getRawContent());
|
||||||
|
|
||||||
MedtronicDeviceType pumpModel = (MedtronicDeviceType)dataResponse;
|
MedtronicDeviceType pumpModel = (MedtronicDeviceType) dataResponse;
|
||||||
boolean valid = (pumpModel != MedtronicDeviceType.Unknown_Device);
|
boolean valid = (pumpModel != MedtronicDeviceType.Unknown_Device);
|
||||||
|
|
||||||
if (MedtronicUtil.getMedtronicPumpModel() == null && valid) {
|
if (MedtronicUtil.getMedtronicPumpModel() == null && valid) {
|
||||||
|
@ -194,7 +193,7 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
|
||||||
|
|
||||||
if (isLogEnabled())
|
if (isLogEnabled())
|
||||||
LOG.debug("isDeviceReachable. PumpModel is {} - Valid: {} (rssi={})", pumpModel.name(), valid,
|
LOG.debug("isDeviceReachable. PumpModel is {} - Valid: {} (rssi={})", pumpModel.name(), valid,
|
||||||
radioResponse.rssi);
|
radioResponse.rssi);
|
||||||
|
|
||||||
if (valid) {
|
if (valid) {
|
||||||
if (state == PumpDeviceState.PumpUnreachable)
|
if (state == PumpDeviceState.PumpUnreachable)
|
||||||
|
@ -202,9 +201,6 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
|
||||||
else
|
else
|
||||||
MedtronicUtil.setPumpDeviceState(PumpDeviceState.Sleeping);
|
MedtronicUtil.setPumpDeviceState(PumpDeviceState.Sleeping);
|
||||||
|
|
||||||
// if (firstConnection)
|
|
||||||
// checkFirstConnectionTime();
|
|
||||||
|
|
||||||
rememberLastGoodDeviceCommunicationTime();
|
rememberLastGoodDeviceCommunicationTime();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -219,13 +215,13 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
|
||||||
} else {
|
} else {
|
||||||
if (isLogEnabled())
|
if (isLogEnabled())
|
||||||
LOG.warn("isDeviceReachable. Failed to parse radio response: "
|
LOG.warn("isDeviceReachable. Failed to parse radio response: "
|
||||||
+ ByteUtil.shortHexString(rfSpyResponse.getRaw()));
|
+ ByteUtil.shortHexString(rfSpyResponse.getRaw()));
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (RileyLinkCommunicationException e) {
|
} catch (RileyLinkCommunicationException e) {
|
||||||
if (isLogEnabled())
|
if (isLogEnabled())
|
||||||
LOG.warn("isDeviceReachable. Failed to decode radio response: "
|
LOG.warn("isDeviceReachable. Failed to decode radio response: "
|
||||||
+ ByteUtil.shortHexString(rfSpyResponse.getRaw()));
|
+ ByteUtil.shortHexString(rfSpyResponse.getRaw()));
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
@ -249,7 +245,7 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
|
||||||
LOG.debug("Run command with Args: ");
|
LOG.debug("Run command with Args: ");
|
||||||
|
|
||||||
PumpMessage rval;
|
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
|
// look for ack from short message
|
||||||
PumpMessage shortResponse = sendAndListen(shortMessage);
|
PumpMessage shortResponse = sendAndListen(shortMessage);
|
||||||
if (shortResponse.commandType == MedtronicCommandType.CommandACK) {
|
if (shortResponse.commandType == MedtronicCommandType.CommandACK) {
|
||||||
|
@ -269,7 +265,6 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private PumpMessage runCommandWithFrames(MedtronicCommandType commandType, List<List<Byte>> frames)
|
private PumpMessage runCommandWithFrames(MedtronicCommandType commandType, List<List<Byte>> frames)
|
||||||
throws RileyLinkCommunicationException {
|
throws RileyLinkCommunicationException {
|
||||||
|
|
||||||
|
@ -277,7 +272,7 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
|
||||||
LOG.debug("Run command with Frames: {}", commandType.name());
|
LOG.debug("Run command with Frames: {}", commandType.name());
|
||||||
|
|
||||||
PumpMessage rval = null;
|
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
|
// look for ack from short message
|
||||||
PumpMessage shortResponse = sendAndListen(shortMessage);
|
PumpMessage shortResponse = sendAndListen(shortMessage);
|
||||||
|
|
||||||
|
@ -311,7 +306,7 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
|
||||||
|
|
||||||
if (isLogEnabled())
|
if (isLogEnabled())
|
||||||
LOG.error("Run command with Frames FAILED (command={}, response={})", commandType.name(),
|
LOG.error("Run command with Frames FAILED (command={}, response={})", commandType.name(),
|
||||||
rval.toString());
|
rval.toString());
|
||||||
|
|
||||||
return new PumpMessage("No ACK after frame #" + frameNr);
|
return new PumpMessage("No ACK after frame #" + frameNr);
|
||||||
} else {
|
} else {
|
||||||
|
@ -330,7 +325,7 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
|
||||||
public PumpHistoryResult getPumpHistory(PumpHistoryEntry lastEntry, LocalDateTime targetDate) {
|
public PumpHistoryResult getPumpHistory(PumpHistoryEntry lastEntry, LocalDateTime targetDate) {
|
||||||
|
|
||||||
PumpHistoryResult pumpTotalResult = new PumpHistoryResult(lastEntry, targetDate == null ? null
|
PumpHistoryResult pumpTotalResult = new PumpHistoryResult(lastEntry, targetDate == null ? null
|
||||||
: DateTimeUtil.toATechDate(targetDate));
|
: DateTimeUtil.toATechDate(targetDate));
|
||||||
|
|
||||||
if (doWakeUpBeforeCommand)
|
if (doWakeUpBeforeCommand)
|
||||||
wakeUp(receiverDeviceAwakeForMinutes, false);
|
wakeUp(receiverDeviceAwakeForMinutes, false);
|
||||||
|
@ -341,12 +336,12 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
|
||||||
MedtronicUtil.setPumpDeviceState(PumpDeviceState.Active);
|
MedtronicUtil.setPumpDeviceState(PumpDeviceState.Active);
|
||||||
boolean doneWithError = false;
|
boolean doneWithError = false;
|
||||||
|
|
||||||
for (int pageNumber = 0; pageNumber < 16; pageNumber++) {
|
for (int pageNumber = 0; pageNumber < 5; pageNumber++) {
|
||||||
|
|
||||||
RawHistoryPage rawHistoryPage = new RawHistoryPage();
|
RawHistoryPage rawHistoryPage = new RawHistoryPage();
|
||||||
// wakeUp(receiverDeviceAwakeForMinutes, false);
|
// wakeUp(receiverDeviceAwakeForMinutes, false);
|
||||||
PumpMessage getHistoryMsg = makePumpMessage(MedtronicCommandType.GetHistoryData,
|
PumpMessage getHistoryMsg = makePumpMessage(MedtronicCommandType.GetHistoryData,
|
||||||
new GetHistoryPageCarelinkMessageBody(pageNumber));
|
new GetHistoryPageCarelinkMessageBody(pageNumber));
|
||||||
|
|
||||||
if (isLogEnabled())
|
if (isLogEnabled())
|
||||||
LOG.info("getPumpHistory: Page {}", pageNumber);
|
LOG.info("getPumpHistory: Page {}", pageNumber);
|
||||||
|
@ -380,7 +375,7 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
|
||||||
|
|
||||||
PumpMessage ackMsg = makePumpMessage(MedtronicCommandType.CommandACK, new PumpAckMessageBody());
|
PumpMessage ackMsg = makePumpMessage(MedtronicCommandType.CommandACK, new PumpAckMessageBody());
|
||||||
GetHistoryPageCarelinkMessageBody currentResponse = new GetHistoryPageCarelinkMessageBody(firstResponse
|
GetHistoryPageCarelinkMessageBody currentResponse = new GetHistoryPageCarelinkMessageBody(firstResponse
|
||||||
.getMessageBody().getTxData());
|
.getMessageBody().getTxData());
|
||||||
int expectedFrameNum = 1;
|
int expectedFrameNum = 1;
|
||||||
boolean done = false;
|
boolean done = false;
|
||||||
// while (expectedFrameNum == currentResponse.getFrameNumber()) {
|
// while (expectedFrameNum == currentResponse.getFrameNumber()) {
|
||||||
|
@ -390,7 +385,7 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
|
||||||
// examine current response for problems.
|
// examine current response for problems.
|
||||||
byte[] frameData = currentResponse.getFrameData();
|
byte[] frameData = currentResponse.getFrameData();
|
||||||
if ((frameData != null) && (frameData.length > 0)
|
if ((frameData != null) && (frameData.length > 0)
|
||||||
&& currentResponse.getFrameNumber() == expectedFrameNum) {
|
&& currentResponse.getFrameNumber() == expectedFrameNum) {
|
||||||
// success! got a frame.
|
// success! got a frame.
|
||||||
if (frameData.length != 64) {
|
if (frameData.length != 64) {
|
||||||
if (isLogEnabled())
|
if (isLogEnabled())
|
||||||
|
@ -402,7 +397,7 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
|
||||||
// RileyLinkMedtronicService.getInstance().announceProgress(((100 / 16) *
|
// RileyLinkMedtronicService.getInstance().announceProgress(((100 / 16) *
|
||||||
// currentResponse.getFrameNumber() + 1));
|
// currentResponse.getFrameNumber() + 1));
|
||||||
MedtronicUtil.setCurrentCommand(MedtronicCommandType.GetHistoryData, pageNumber,
|
MedtronicUtil.setCurrentCommand(MedtronicCommandType.GetHistoryData, pageNumber,
|
||||||
currentResponse.getFrameNumber());
|
currentResponse.getFrameNumber());
|
||||||
|
|
||||||
if (isLogEnabled())
|
if (isLogEnabled())
|
||||||
LOG.info("getPumpHistory: Got frame {} of Page {}", currentResponse.getFrameNumber(), pageNumber);
|
LOG.info("getPumpHistory: Got frame {} of Page {}", currentResponse.getFrameNumber(), pageNumber);
|
||||||
|
@ -419,7 +414,7 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
|
||||||
} else if (currentResponse.getFrameNumber() != expectedFrameNum) {
|
} else if (currentResponse.getFrameNumber() != expectedFrameNum) {
|
||||||
if (isLogEnabled())
|
if (isLogEnabled())
|
||||||
LOG.warn("Expected frame number {}, received {} (retrying)", expectedFrameNum,
|
LOG.warn("Expected frame number {}, received {} (retrying)", expectedFrameNum,
|
||||||
currentResponse.getFrameNumber());
|
currentResponse.getFrameNumber());
|
||||||
} else if (frameData.length == 0) {
|
} else if (frameData.length == 0) {
|
||||||
if (isLogEnabled())
|
if (isLogEnabled())
|
||||||
LOG.warn("Frame has zero length, retrying");
|
LOG.warn("Frame has zero length, retrying");
|
||||||
|
@ -428,8 +423,8 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
|
||||||
if (failures == 6) {
|
if (failures == 6) {
|
||||||
if (isLogEnabled())
|
if (isLogEnabled())
|
||||||
LOG.error(
|
LOG.error(
|
||||||
"getPumpHistory: 6 failures in attempting to download frame {} of page {}, giving up.",
|
"getPumpHistory: 6 failures in attempting to download frame {} of page {}, giving up.",
|
||||||
expectedFrameNum, pageNumber);
|
expectedFrameNum, pageNumber);
|
||||||
done = true; // failure completion.
|
done = true; // failure completion.
|
||||||
doneWithError = true;
|
doneWithError = true;
|
||||||
}
|
}
|
||||||
|
@ -462,7 +457,7 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
|
||||||
if (rawHistoryPage.getLength() != 1024) {
|
if (rawHistoryPage.getLength() != 1024) {
|
||||||
if (isLogEnabled())
|
if (isLogEnabled())
|
||||||
LOG.warn("getPumpHistory: short page. Expected length of 1024, found length of "
|
LOG.warn("getPumpHistory: short page. Expected length of 1024, found length of "
|
||||||
+ rawHistoryPage.getLength());
|
+ rawHistoryPage.getLength());
|
||||||
doneWithError = true;
|
doneWithError = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -472,8 +467,6 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
|
||||||
doneWithError = true;
|
doneWithError = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO handle error states
|
|
||||||
|
|
||||||
if (doneWithError) {
|
if (doneWithError) {
|
||||||
MedtronicUtil.setPumpDeviceState(PumpDeviceState.Sleeping);
|
MedtronicUtil.setPumpDeviceState(PumpDeviceState.Sleeping);
|
||||||
return pumpTotalResult;
|
return pumpTotalResult;
|
||||||
|
@ -482,12 +475,11 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
|
||||||
rawHistoryPage.dumpToDebug();
|
rawHistoryPage.dumpToDebug();
|
||||||
|
|
||||||
List<PumpHistoryEntry> medtronicHistoryEntries = pumpHistoryDecoder
|
List<PumpHistoryEntry> medtronicHistoryEntries = pumpHistoryDecoder
|
||||||
.processPageAndCreateRecords(rawHistoryPage);
|
.processPageAndCreateRecords(rawHistoryPage);
|
||||||
|
|
||||||
if (isLogEnabled())
|
if (isLogEnabled())
|
||||||
LOG.debug("getPumpHistory: Found {} history entries.", medtronicHistoryEntries.size());
|
LOG.debug("getPumpHistory: Found {} history entries.", medtronicHistoryEntries.size());
|
||||||
|
|
||||||
// PumpHistoryResult pumpHistoryResult = new PumpHistoryResult(lastEntry, targetDate);
|
|
||||||
pumpTotalResult.addHistoryEntries(medtronicHistoryEntries);
|
pumpTotalResult.addHistoryEntries(medtronicHistoryEntries);
|
||||||
|
|
||||||
if (isLogEnabled())
|
if (isLogEnabled())
|
||||||
|
@ -498,7 +490,6 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
|
||||||
|
|
||||||
return pumpTotalResult;
|
return pumpTotalResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MedtronicUtil.setPumpDeviceState(PumpDeviceState.Sleeping);
|
MedtronicUtil.setPumpDeviceState(PumpDeviceState.Sleeping);
|
||||||
|
@ -508,7 +499,6 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public String getErrorResponse() {
|
public String getErrorResponse() {
|
||||||
return this.errorMessage;
|
return this.errorMessage;
|
||||||
}
|
}
|
||||||
|
@ -519,7 +509,7 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case PowerOn:
|
case PowerOn:
|
||||||
return MedtronicUtil.buildCommandPayload(MedtronicCommandType.RFPowerOn, //
|
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:
|
case ReadSimpleData:
|
||||||
return MedtronicUtil.buildCommandPayload(MedtronicCommandType.PumpModel, null);
|
return MedtronicUtil.buildCommandPayload(MedtronicCommandType.PumpModel, null);
|
||||||
|
@ -530,12 +520,12 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
|
||||||
|
|
||||||
private PumpMessage makePumpMessage(MedtronicCommandType messageType, byte[] body) {
|
private PumpMessage makePumpMessage(MedtronicCommandType messageType, byte[] body) {
|
||||||
return makePumpMessage(messageType, body == null ? new CarelinkShortMessageBody()
|
return makePumpMessage(messageType, body == null ? new CarelinkShortMessageBody()
|
||||||
: new CarelinkShortMessageBody(body));
|
: new CarelinkShortMessageBody(body));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private PumpMessage makePumpMessage(MedtronicCommandType messageType) {
|
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));
|
response = sendAndGetResponse(commandType, bodyData, DEFAULT_TIMEOUT + (DEFAULT_TIMEOUT * retries));
|
||||||
|
|
||||||
String check = checkResponseContent(response, commandType.commandDescription,
|
String check = checkResponseContent(response, commandType.commandDescription,
|
||||||
commandType.expectedLength);
|
commandType.expectedLength);
|
||||||
|
|
||||||
if (check == null) {
|
if (check == null) {
|
||||||
|
|
||||||
|
@ -659,8 +649,8 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
String responseData = String.format(
|
String responseData = String.format(
|
||||||
"%s: Cannot return data. Data is too short [expected=%s, received=%s].", method, ""
|
"%s: Cannot return data. Data is too short [expected=%s, received=%s].", method, ""
|
||||||
+ expectedLength, "" + contents.length);
|
+ expectedLength, "" + contents.length);
|
||||||
|
|
||||||
if (isLogEnabled())
|
if (isLogEnabled())
|
||||||
LOG.warn(responseData);
|
LOG.warn(responseData);
|
||||||
|
@ -680,7 +670,7 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
|
||||||
|
|
||||||
Object responseObject = sendAndGetResponseWithCheck(MedtronicCommandType.GetRemainingInsulin);
|
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);
|
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;
|
errorMessage = check;
|
||||||
}
|
}
|
||||||
|
|
||||||
BasalProfile basalProfile = (BasalProfile)medtronicConverter.convertResponse(commandType, data);
|
BasalProfile basalProfile = (BasalProfile) medtronicConverter.convertResponse(commandType, data);
|
||||||
|
|
||||||
if (isLogEnabled())
|
if (isLogEnabled())
|
||||||
LOG.debug("Converted response for {} is {}.", commandType.name(), basalProfile);
|
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) {
|
private boolean checkIfWeHaveMoreData(MedtronicCommandType commandType, PumpMessage response, byte[] data) {
|
||||||
|
|
||||||
if (commandType == MedtronicCommandType.GetBasalProfileSTD || //
|
if (commandType == MedtronicCommandType.GetBasalProfileSTD || //
|
||||||
commandType == MedtronicCommandType.GetBasalProfileA || //
|
commandType == MedtronicCommandType.GetBasalProfileA || //
|
||||||
commandType == MedtronicCommandType.GetBasalProfileB) {
|
commandType == MedtronicCommandType.GetBasalProfileB) {
|
||||||
byte[] responseRaw = response.getRawContent();
|
byte[] responseRaw = response.getRawContent();
|
||||||
|
|
||||||
int last = responseRaw.length - 1;
|
int last = responseRaw.length - 1;
|
||||||
|
@ -824,7 +814,7 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
|
||||||
Object responseObject = sendAndGetResponseWithCheck(MedtronicCommandType.RealTimeClock);
|
Object responseObject = sendAndGetResponseWithCheck(MedtronicCommandType.RealTimeClock);
|
||||||
|
|
||||||
if (responseObject != null) {
|
if (responseObject != null) {
|
||||||
clockDTO.pumpTime = (LocalDateTime)responseObject;
|
clockDTO.pumpTime = (LocalDateTime) responseObject;
|
||||||
return clockDTO;
|
return clockDTO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -836,16 +826,16 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
|
||||||
|
|
||||||
Object responseObject = sendAndGetResponseWithCheck(MedtronicCommandType.ReadTemporaryBasal);
|
Object responseObject = sendAndGetResponseWithCheck(MedtronicCommandType.ReadTemporaryBasal);
|
||||||
|
|
||||||
return responseObject == null ? null : (TempBasalPair)responseObject;
|
return responseObject == null ? null : (TempBasalPair) responseObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public Map<String, PumpSettingDTO> getPumpSettings() {
|
public Map<String, PumpSettingDTO> getPumpSettings() {
|
||||||
|
|
||||||
Object responseObject = sendAndGetResponseWithCheck(MedtronicCommandType.getSettings(MedtronicUtil
|
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)
|
if (debugSetCommands)
|
||||||
LOG.debug("{}: Body - {}", commandType.getCommandDescription(),
|
LOG.debug("{}: Body - {}", commandType.getCommandDescription(),
|
||||||
HexDump.toHexStringDisplayable(body));
|
HexDump.toHexStringDisplayable(body));
|
||||||
|
|
||||||
PumpMessage msg = makePumpMessage(commandType, new CarelinkLongMessageBody(body));
|
PumpMessage msg = makePumpMessage(commandType, new CarelinkLongMessageBody(body));
|
||||||
|
|
||||||
|
@ -890,7 +880,7 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
|
||||||
if (pumpMessage.commandType == MedtronicCommandType.CommandACK) {
|
if (pumpMessage.commandType == MedtronicCommandType.CommandACK) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} 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) {
|
} catch (RileyLinkCommunicationException e) {
|
||||||
|
@ -912,7 +902,7 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
|
||||||
|
|
||||||
Object responseObject = sendAndGetResponseWithCheck(MedtronicCommandType.GetBatteryStatus);
|
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;
|
// PumpMessage responseMessage = null;
|
||||||
try {
|
try {
|
||||||
PumpMessage responseMessage = runCommandWithFrames(MedtronicCommandType.SetBasalProfileSTD,
|
PumpMessage responseMessage = runCommandWithFrames(MedtronicCommandType.SetBasalProfileSTD,
|
||||||
basalProfileFrames);
|
basalProfileFrames);
|
||||||
|
|
||||||
return responseMessage.commandType == MedtronicCommandType.CommandACK;
|
return responseMessage.commandType == MedtronicCommandType.CommandACK;
|
||||||
} catch (RileyLinkCommunicationException e) {
|
} catch (RileyLinkCommunicationException e) {
|
||||||
|
@ -934,7 +924,6 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
|
||||||
}
|
}
|
||||||
|
|
||||||
// LOG.debug("Set Basal Profile: {}", HexDump.toHexStringDisplayable(responseMessage.getRawContent()));
|
// LOG.debug("Set Basal Profile: {}", HexDump.toHexStringDisplayable(responseMessage.getRawContent()));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
@ -942,13 +931,6 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public PumpMessage cancelBolus() {
|
|
||||||
// ? maybe suspend and resume
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private boolean isLogEnabled() {
|
private boolean isLogEnabled() {
|
||||||
return L.isEnabled(L.PUMPCOMM);
|
return L.isEnabled(L.PUMPCOMM);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,14 +1,13 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.medtronic.comm;
|
package info.nightscout.androidaps.plugins.pump.medtronic.comm;
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import org.joda.time.IllegalFieldValueException;
|
import org.joda.time.IllegalFieldValueException;
|
||||||
import org.joda.time.LocalDateTime;
|
import org.joda.time.LocalDateTime;
|
||||||
import org.joda.time.LocalTime;
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import info.nightscout.androidaps.logging.L;
|
import info.nightscout.androidaps.logging.L;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.utils.ByteUtil;
|
import info.nightscout.androidaps.plugins.pump.common.utils.ByteUtil;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.utils.HexDump;
|
import info.nightscout.androidaps.plugins.pump.common.utils.HexDump;
|
||||||
|
@ -24,6 +23,7 @@ import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicUtil;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by andy on 5/9/18.
|
* Created by andy on 5/9/18.
|
||||||
|
* High level decoder for data returned through MedtroniUIComm
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class MedtronicConverter {
|
public class MedtronicConverter {
|
||||||
|
@ -37,7 +37,7 @@ public class MedtronicConverter {
|
||||||
|
|
||||||
if ((rawContent == null || rawContent.length < 1) && commandType != MedtronicCommandType.PumpModel) {
|
if ((rawContent == null || rawContent.length < 1) && commandType != MedtronicCommandType.PumpModel) {
|
||||||
LOG.warn("Content is empty or too short, no data to convert (type={},isNull={},length={})",
|
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;
|
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) {
|
private BatteryStatusDTO decodeBatteryStatus(byte[] rawData) {
|
||||||
// 00 7C 00 00
|
// 00 7C 00 00
|
||||||
|
|
||||||
|
@ -170,9 +135,7 @@ public class MedtronicConverter {
|
||||||
if (rawData.length > 1) {
|
if (rawData.length > 1) {
|
||||||
|
|
||||||
// if response in 3 bytes then we add additional information
|
// if response in 3 bytes then we add additional information
|
||||||
// double d = MedtronicUtil.makeUnsignedShort(rawData[2], rawData[1]) / 100.0d;
|
double d = (ByteUtil.toInt(rawData[1], rawData[2]) * 1.0d) / 100.0d;
|
||||||
|
|
||||||
double d = (ByteUtil.toInt(rawData[1], rawData[2])*1.0d) / 100.0d;
|
|
||||||
|
|
||||||
batteryStatus.voltage = d;
|
batteryStatus.voltage = d;
|
||||||
batteryStatus.extendedDataReceived = true;
|
batteryStatus.extendedDataReceived = true;
|
||||||
|
@ -187,7 +150,7 @@ public class MedtronicConverter {
|
||||||
|
|
||||||
this.pumpModel = MedtronicUtil.getMedtronicPumpModel();
|
this.pumpModel = MedtronicUtil.getMedtronicPumpModel();
|
||||||
|
|
||||||
int strokes = pumpModel==null ? 10 : pumpModel.getBolusStrokes();
|
int strokes = pumpModel == null ? 10 : pumpModel.getBolusStrokes();
|
||||||
|
|
||||||
if (strokes == 40) {
|
if (strokes == 40) {
|
||||||
startIdx = 2;
|
startIdx = 2;
|
||||||
|
@ -214,8 +177,8 @@ public class MedtronicConverter {
|
||||||
return pumpTime;
|
return pumpTime;
|
||||||
} catch (IllegalFieldValueException e) {
|
} catch (IllegalFieldValueException e) {
|
||||||
LOG.error(
|
LOG.error(
|
||||||
"decodeTime: Failed to parse pump time value: year=%d, month=%d, hours=%d, minutes=%d, seconds=%d",
|
"decodeTime: Failed to parse pump time value: year=%d, month=%d, hours=%d, minutes=%d, seconds=%d",
|
||||||
year, month, day, hours, minutes, seconds);
|
year, month, day, hours, minutes, seconds);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -239,26 +202,26 @@ public class MedtronicConverter {
|
||||||
|
|
||||||
if (rd[2] == 1) {
|
if (rd[2] == 1) {
|
||||||
addSettingToMap("PCFG_AUDIO_BOLUS_STEP_SIZE", "" + decodeBolusInsulin(ByteUtil.asUINT8(rd[3])),
|
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_VARIABLE_BOLUS_ENABLED", parseResultEnable(rd[4]), PumpConfigurationGroup.Bolus, map);
|
||||||
addSettingToMap("PCFG_MAX_BOLUS", "" + decodeMaxBolus(rd), PumpConfigurationGroup.Bolus, map);
|
addSettingToMap("PCFG_MAX_BOLUS", "" + decodeMaxBolus(rd), PumpConfigurationGroup.Bolus, map);
|
||||||
addSettingToMap(
|
addSettingToMap(
|
||||||
"PCFG_MAX_BASAL",
|
"PCFG_MAX_BASAL",
|
||||||
""
|
""
|
||||||
+ decodeBasalInsulin(ByteUtil.makeUnsignedShort(rd[getSettingIndexMaxBasal()],
|
+ decodeBasalInsulin(ByteUtil.makeUnsignedShort(rd[getSettingIndexMaxBasal()],
|
||||||
rd[getSettingIndexMaxBasal() + 1])), PumpConfigurationGroup.Basal, map);
|
rd[getSettingIndexMaxBasal() + 1])), PumpConfigurationGroup.Basal, map);
|
||||||
addSettingToMap("CFG_BASE_CLOCK_MODE", rd[getSettingIndexTimeDisplayFormat()] == 0 ? "12h" : "24h",
|
addSettingToMap("CFG_BASE_CLOCK_MODE", rd[getSettingIndexTimeDisplayFormat()] == 0 ? "12h" : "24h",
|
||||||
PumpConfigurationGroup.General, map);
|
PumpConfigurationGroup.General, map);
|
||||||
|
|
||||||
if (MedtronicDeviceType.isSameDevice(pumpModel, MedtronicDeviceType.Medtronic_523andHigher)) {
|
if (MedtronicDeviceType.isSameDevice(pumpModel, MedtronicDeviceType.Medtronic_523andHigher)) {
|
||||||
addSettingToMap("PCFG_INSULIN_CONCENTRATION", "" + (rd[9] == 0 ? 50 : 100), PumpConfigurationGroup.Insulin,
|
addSettingToMap("PCFG_INSULIN_CONCENTRATION", "" + (rd[9] == 0 ? 50 : 100), PumpConfigurationGroup.Insulin,
|
||||||
map);
|
map);
|
||||||
// LOG.debug("Insulin concentration: " + rd[9]);
|
// LOG.debug("Insulin concentration: " + rd[9]);
|
||||||
} else {
|
} else {
|
||||||
addSettingToMap("PCFG_INSULIN_CONCENTRATION", "" + (rd[9] != 0 ? 50 : 100), PumpConfigurationGroup.Insulin,
|
addSettingToMap("PCFG_INSULIN_CONCENTRATION", "" + (rd[9] != 0 ? 50 : 100), PumpConfigurationGroup.Insulin,
|
||||||
map);
|
map);
|
||||||
// LOG.debug("Insulin concentration: " + rd[9]);
|
// LOG.debug("Insulin concentration: " + rd[9]);
|
||||||
}
|
}
|
||||||
addSettingToMap("PCFG_BASAL_PROFILES_ENABLED", parseResultEnable(rd[10]), PumpConfigurationGroup.Basal, map);
|
addSettingToMap("PCFG_BASAL_PROFILES_ENABLED", parseResultEnable(rd[10]), PumpConfigurationGroup.Basal, map);
|
||||||
|
@ -313,10 +276,10 @@ public class MedtronicConverter {
|
||||||
Map<String, PumpSettingDTO> map = decodeSettings512(rd);
|
Map<String, PumpSettingDTO> map = decodeSettings512(rd);
|
||||||
|
|
||||||
addSettingToMap("PCFG_MM_RESERVOIR_WARNING_TYPE_TIME", rd[18] != 0 ? "PCFG_MM_RESERVOIR_WARNING_TYPE_TIME"
|
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]),
|
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);
|
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_CAPTURE_EVENT_ENABLE", parseResultEnable(rd[22]), PumpConfigurationGroup.Other, map);
|
||||||
addSettingToMap("PCFG_OTHER_DEVICE_ENABLE", parseResultEnable(rd[23]), 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,
|
addSettingToMap("PCFG_OTHER_DEVICE_PAIRED_STATE", parseResultEnable(rd[24]), PumpConfigurationGroup.Other,
|
||||||
map);
|
map);
|
||||||
}
|
}
|
||||||
|
|
||||||
return map;
|
return map;
|
||||||
|
@ -354,7 +317,7 @@ public class MedtronicConverter {
|
||||||
public void decodeInsulinActionSetting(byte[] ai, Map<String, PumpSettingDTO> map) {
|
public void decodeInsulinActionSetting(byte[] ai, Map<String, PumpSettingDTO> map) {
|
||||||
if (MedtronicDeviceType.isSameDevice(pumpModel, MedtronicDeviceType.Medtronic_512_712)) {
|
if (MedtronicDeviceType.isSameDevice(pumpModel, MedtronicDeviceType.Medtronic_512_712)) {
|
||||||
addSettingToMap("PCFG_INSULIN_ACTION_TYPE", (ai[17] != 0 ? "Regular" : "Fast"),
|
addSettingToMap("PCFG_INSULIN_ACTION_TYPE", (ai[17] != 0 ? "Regular" : "Fast"),
|
||||||
PumpConfigurationGroup.Insulin, map);
|
PumpConfigurationGroup.Insulin, map);
|
||||||
} else {
|
} else {
|
||||||
int i = ai[17];
|
int i = ai[17];
|
||||||
String s = "";
|
String s = "";
|
||||||
|
@ -374,13 +337,13 @@ public class MedtronicConverter {
|
||||||
|
|
||||||
|
|
||||||
public double decodeBasalInsulin(int i) {
|
public double decodeBasalInsulin(int i) {
|
||||||
return (double)i / (double)getStrokesPerUnit(true);
|
return (double) i / (double) getStrokesPerUnit(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public double decodeBolusInsulin(int i) {
|
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[]) {
|
public double decodeMaxBolus(byte ai[]) {
|
||||||
return is523orHigher() ? decodeBolusInsulin(ByteUtil.toInt(ai[5], ai[6])) : decodeBolusInsulin(ByteUtil
|
return is523orHigher() ? decodeBolusInsulin(ByteUtil.toInt(ai[5], ai[6])) : decodeBolusInsulin(ByteUtil
|
||||||
.asUINT8(ai[5]));
|
.asUINT8(ai[5]));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.medtronic.comm.history.pump;
|
package info.nightscout.androidaps.plugins.pump.medtronic.comm.history.pump;
|
||||||
|
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
@ -35,6 +37,7 @@ public class MedtronicPumpHistoryDecoder extends MedtronicHistoryDecoder<PumpHis
|
||||||
private PumpHistoryEntry tbrPreviousRecord;
|
private PumpHistoryEntry tbrPreviousRecord;
|
||||||
private PumpHistoryEntry changeTimeRecord;
|
private PumpHistoryEntry changeTimeRecord;
|
||||||
private MedtronicDeviceType deviceType;
|
private MedtronicDeviceType deviceType;
|
||||||
|
private static final String TAG = "MdtPumpHistoryDecoder";
|
||||||
|
|
||||||
|
|
||||||
public MedtronicPumpHistoryDecoder() {
|
public MedtronicPumpHistoryDecoder() {
|
||||||
|
@ -54,7 +57,7 @@ public class MedtronicPumpHistoryDecoder extends MedtronicHistoryDecoder<PumpHis
|
||||||
int elementStart = 0;
|
int elementStart = 0;
|
||||||
|
|
||||||
if (dataClear.size() == 0) {
|
if (dataClear.size() == 0) {
|
||||||
LOG.error("Empty page.");
|
Log.e(TAG, "Empty page.");
|
||||||
return outList;
|
return outList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,7 +75,7 @@ public class MedtronicPumpHistoryDecoder extends MedtronicHistoryDecoder<PumpHis
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
if (skipped != null) {
|
if (skipped != null) {
|
||||||
LOG.debug(" ... Skipped " + skipped);
|
Log.w(TAG, " ... Skipped " + skipped);
|
||||||
skipped = null;
|
skipped = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -142,16 +145,12 @@ public class MedtronicPumpHistoryDecoder extends MedtronicHistoryDecoder<PumpHis
|
||||||
|
|
||||||
RecordDecodeStatus decoded = decodeRecord(pe);
|
RecordDecodeStatus decoded = decodeRecord(pe);
|
||||||
|
|
||||||
if (decoded == RecordDecodeStatus.WIP) {
|
if ((decoded == RecordDecodeStatus.OK) || (decoded == RecordDecodeStatus.Ignored)) {
|
||||||
LOG.warn("#" + record + " " + decoded.getDescription() + " " + pe);
|
Log.i(TAG, "#" + record + " " + decoded.getDescription() + " " + pe);
|
||||||
|
} else {
|
||||||
|
Log.w(TAG, "#" + record + " " + decoded.getDescription() + " " + pe);
|
||||||
}
|
}
|
||||||
|
|
||||||
// if ((decoded == RecordDecodeStatus.OK) || (decoded == RecordDecodeStatus.Ignored)) {
|
|
||||||
// LOG.info("#" + record + " " + decoded.getDescription() + " " + pe);
|
|
||||||
// } else {
|
|
||||||
// LOG.warn("#" + record + " " + decoded.getDescription() + " " + pe);
|
|
||||||
// }
|
|
||||||
|
|
||||||
addToStatistics(pe, decoded, null);
|
addToStatistics(pe, decoded, null);
|
||||||
|
|
||||||
record++;
|
record++;
|
||||||
|
|
|
@ -8,7 +8,7 @@ import info.nightscout.androidaps.R;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This file was taken from GGC - GNU Gluco Control and modified/extended for AAPS.
|
* This file was taken from GGC - GNU Gluco Control and modified/extended for AAPS.
|
||||||
*
|
* <p>
|
||||||
* Author: Andy {andy.rozman@gmail.com}
|
* Author: Andy {andy.rozman@gmail.com}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -37,9 +37,9 @@ public enum PumpHistoryEntryGroup {
|
||||||
list = new ArrayList<>();
|
list = new ArrayList<>();
|
||||||
|
|
||||||
for (PumpHistoryEntryGroup pumpHistoryEntryGroup : values()) {
|
for (PumpHistoryEntryGroup pumpHistoryEntryGroup : values()) {
|
||||||
if (doNotTranslate) {
|
//if (doNotTranslate) {
|
||||||
pumpHistoryEntryGroup.translated = MainApp.gs(pumpHistoryEntryGroup.resourceId);
|
pumpHistoryEntryGroup.translated = MainApp.gs(pumpHistoryEntryGroup.resourceId);
|
||||||
}
|
//}
|
||||||
list.add(pumpHistoryEntryGroup);
|
list.add(pumpHistoryEntryGroup);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -120,7 +120,7 @@ public enum PumpHistoryEntryType // implements CodeEnum
|
||||||
BolusReminder(0x69, "Bolus Reminder", PumpHistoryEntryGroup.Configuration, 2, 5, 0), // Ian69
|
BolusReminder(0x69, "Bolus Reminder", PumpHistoryEntryGroup.Configuration, 2, 5, 0), // Ian69
|
||||||
DeleteAlarmClockTime(0x6a, "Delete Alarm Clock Time", PumpHistoryEntryGroup.Configuration, 2, 5, 7), // 14
|
DeleteAlarmClockTime(0x6a, "Delete Alarm Clock Time", PumpHistoryEntryGroup.Configuration, 2, 5, 7), // 14
|
||||||
|
|
||||||
DailyTotals515(0x6c, "Daily Totals (515)", PumpHistoryEntryGroup.Statistic, 1, 2, 33), // v4: 0,0,36. v5: 1,2,33
|
DailyTotals515(0x6c, "Daily Totals (515)", PumpHistoryEntryGroup.Statistic, 1, 2, 35), // v4: 0,0,36. v5: 1,2,33
|
||||||
DailyTotals522(0x6d, "Daily Totals (522)", PumpHistoryEntryGroup.Statistic, 1, 2, 41), //
|
DailyTotals522(0x6d, "Daily Totals (522)", PumpHistoryEntryGroup.Statistic, 1, 2, 41), //
|
||||||
DailyTotals523(0x6e, "Daily Totals (523)", PumpHistoryEntryGroup.Statistic, 1, 2, 49), // 1102014-03-17T00:00:00
|
DailyTotals523(0x6e, "Daily Totals (523)", PumpHistoryEntryGroup.Statistic, 1, 2, 49), // 1102014-03-17T00:00:00
|
||||||
ChangeCarbUnits((byte) 0x6f, "Change Carb Units", PumpHistoryEntryGroup.Configuration), //
|
ChangeCarbUnits((byte) 0x6f, "Change Carb Units", PumpHistoryEntryGroup.Configuration), //
|
||||||
|
|
|
@ -5,12 +5,6 @@ import info.nightscout.androidaps.plugins.pump.common.utils.HexDump;
|
||||||
/**
|
/**
|
||||||
* Created by geoff on 5/29/16.
|
* Created by geoff on 5/29/16.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Andy (4.6.2018): We probably need rewrite of this message body code. If there is no data sent, body is 00, which
|
|
||||||
// denotes,
|
|
||||||
// no parameters. If we have 3 parameters sent (1 2 3), the body would actually be length of 4, first byte being the
|
|
||||||
// length
|
|
||||||
// of the message, so the body would be 3 1 2 3. This is not done that way now.
|
|
||||||
public class MessageBody {
|
public class MessageBody {
|
||||||
|
|
||||||
public int getLength() {
|
public int getLength() {
|
||||||
|
@ -23,7 +17,7 @@ public class MessageBody {
|
||||||
|
|
||||||
|
|
||||||
public byte[] getTxData() {
|
public byte[] getTxData() {
|
||||||
return new byte[] {};
|
return new byte[]{};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@ public class PumpMessage implements RLMessage {
|
||||||
private static final Logger LOG = LoggerFactory.getLogger(L.PUMPCOMM);
|
private static final Logger LOG = LoggerFactory.getLogger(L.PUMPCOMM);
|
||||||
|
|
||||||
public PacketType packetType = PacketType.Carelink;
|
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 MedtronicCommandType commandType;
|
||||||
public Byte invalidCommandType;
|
public Byte invalidCommandType;
|
||||||
public MessageBody messageBody = new MessageBody();
|
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) {
|
public void init(PacketType packetType, byte[] address, MedtronicCommandType commandType, MessageBody messageBody) {
|
||||||
this.packetType = packetType;
|
this.packetType = packetType;
|
||||||
this.address = address;
|
this.address = address;
|
||||||
|
@ -80,14 +73,14 @@ public class PumpMessage implements RLMessage {
|
||||||
}
|
}
|
||||||
if (rxData.length > 5) {
|
if (rxData.length > 5) {
|
||||||
this.messageBody = MedtronicCommandType.constructMessageBody(commandType,
|
this.messageBody = MedtronicCommandType.constructMessageBody(commandType,
|
||||||
ByteUtil.substring(rxData, 5, rxData.length - 5));
|
ByteUtil.substring(rxData, 5, rxData.length - 5));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public byte[] getTxData() {
|
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, commandType.getCommandCode());
|
||||||
rval = ByteUtil.concat(rval, messageBody.getTxData());
|
rval = ByteUtil.concat(rval, messageBody.getTxData());
|
||||||
return rval;
|
return rval;
|
||||||
|
@ -95,7 +88,7 @@ public class PumpMessage implements RLMessage {
|
||||||
|
|
||||||
|
|
||||||
public byte[] getContents() {
|
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();
|
byte[] data = messageBody.getTxData();
|
||||||
|
|
||||||
int length = ByteUtil.asUINT8(data[0]); // length is not always correct so, we check whole array if we have
|
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;
|
int originalLength = length;
|
||||||
|
|
||||||
// check if displayed length is invalid
|
// check if displayed length is invalid
|
||||||
|
@ -132,9 +125,9 @@ public class PumpMessage implements RLMessage {
|
||||||
|
|
||||||
System.arraycopy(messageBody.getTxData(), 1, arrayOut, 0, length);
|
System.arraycopy(messageBody.getTxData(), 1, arrayOut, 0, length);
|
||||||
|
|
||||||
if (isLogEnabled())
|
// if (isLogEnabled())
|
||||||
LOG.debug("PumpMessage - Length: " + length + ", Original Length: " + originalLength + ", CommandType: "
|
// LOG.debug("PumpMessage - Length: " + length + ", Original Length: " + originalLength + ", CommandType: "
|
||||||
+ commandType);
|
// + commandType);
|
||||||
|
|
||||||
return arrayOut;
|
return arrayOut;
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,6 @@ import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicUtil;
|
||||||
/**
|
/**
|
||||||
* Created by andy on 6/14/18.
|
* Created by andy on 6/14/18.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class MedtronicUIComm {
|
public class MedtronicUIComm {
|
||||||
|
|
||||||
private static final Logger LOG = LoggerFactory.getLogger(L.PUMP);
|
private static final Logger LOG = LoggerFactory.getLogger(L.PUMP);
|
||||||
|
@ -68,10 +67,8 @@ public class MedtronicUIComm {
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
if (!task.isReceived()) {
|
if (!task.isReceived() && isLogEnabled()) {
|
||||||
if (isLogEnabled())
|
LOG.warn("Reply not received for " + commandType);
|
||||||
LOG.warn("Reply not received for " + commandType);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
task.postProcess(uiPostprocessor);
|
task.postProcess(uiPostprocessor);
|
||||||
|
|
|
@ -1,15 +1,13 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.medtronic.comm.ui;
|
package info.nightscout.androidaps.plugins.pump.medtronic.comm.ui;
|
||||||
|
|
||||||
import static info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicUtil.sendNotification;
|
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import org.joda.time.DateTimeZone;
|
import org.joda.time.DateTimeZone;
|
||||||
import org.joda.time.Duration;
|
import org.joda.time.Duration;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import info.nightscout.androidaps.logging.L;
|
import info.nightscout.androidaps.logging.L;
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.data.dto.BasalProfile;
|
import info.nightscout.androidaps.plugins.pump.medtronic.data.dto.BasalProfile;
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.data.dto.BatteryStatusDTO;
|
import info.nightscout.androidaps.plugins.pump.medtronic.data.dto.BatteryStatusDTO;
|
||||||
|
@ -21,6 +19,8 @@ import info.nightscout.androidaps.plugins.pump.medtronic.defs.MedtronicUIRespons
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.driver.MedtronicPumpStatus;
|
import info.nightscout.androidaps.plugins.pump.medtronic.driver.MedtronicPumpStatus;
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicUtil;
|
import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicUtil;
|
||||||
|
|
||||||
|
import static info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicUtil.sendNotification;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by andy on 6/15/18.
|
* Created by andy on 6/15/18.
|
||||||
*/
|
*/
|
||||||
|
@ -41,26 +41,21 @@ public class MedtronicUIPostprocessor {
|
||||||
// where responses won't be directly used
|
// where responses won't be directly used
|
||||||
public void postProcessData(MedtronicUITask uiTask) {
|
public void postProcessData(MedtronicUITask uiTask) {
|
||||||
|
|
||||||
// if (!uiTask.haveData()) {
|
|
||||||
// LOG.error("Error reading data [{}]: {}", uiTask.commandType, uiTask.errorDescription);
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
|
|
||||||
switch (uiTask.commandType) {
|
switch (uiTask.commandType) {
|
||||||
|
|
||||||
case SetBasalProfileSTD: {
|
case SetBasalProfileSTD: {
|
||||||
Boolean response = (Boolean)uiTask.returnData;
|
Boolean response = (Boolean) uiTask.returnData;
|
||||||
|
|
||||||
if (response) {
|
if (response) {
|
||||||
BasalProfile basalProfile = (BasalProfile)uiTask.getParameter(0);
|
BasalProfile basalProfile = (BasalProfile) uiTask.getParameter(0);
|
||||||
|
|
||||||
pumpStatus.basalsByHour = basalProfile.getProfilesByHour();
|
pumpStatus.basalsByHour = basalProfile.getProfilesByHour();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GetBasalProfileSTD: {
|
case GetBasalProfileSTD: {
|
||||||
BasalProfile basalProfile = (BasalProfile)uiTask.returnData;
|
BasalProfile basalProfile = (BasalProfile) uiTask.returnData;
|
||||||
|
|
||||||
Double[] profilesByHour = basalProfile.getProfilesByHour();
|
Double[] profilesByHour = basalProfile.getProfilesByHour();
|
||||||
|
|
||||||
|
@ -72,37 +67,37 @@ public class MedtronicUIPostprocessor {
|
||||||
uiTask.errorDescription = "No profile found.";
|
uiTask.errorDescription = "No profile found.";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SetBolus: {
|
case SetBolus: {
|
||||||
pumpStatus.lastBolusAmount = uiTask.getDoubleFromParameters(0);
|
pumpStatus.lastBolusAmount = uiTask.getDoubleFromParameters(0);
|
||||||
pumpStatus.lastBolusTime = new Date();
|
pumpStatus.lastBolusTime = new Date();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GetRemainingInsulin: {
|
case GetRemainingInsulin: {
|
||||||
pumpStatus.reservoirRemainingUnits = (Float)uiTask.returnData;
|
pumpStatus.reservoirRemainingUnits = (Float) uiTask.returnData;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CancelTBR: {
|
case CancelTBR: {
|
||||||
pumpStatus.tempBasalStart = null;
|
pumpStatus.tempBasalStart = null;
|
||||||
pumpStatus.tempBasalAmount = null;
|
pumpStatus.tempBasalAmount = null;
|
||||||
pumpStatus.tempBasalLength = null;
|
pumpStatus.tempBasalLength = null;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RealTimeClock: {
|
case RealTimeClock: {
|
||||||
processTime(uiTask);
|
processTime(uiTask);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GetBatteryStatus: {
|
case GetBatteryStatus: {
|
||||||
BatteryStatusDTO batteryStatusDTO = (BatteryStatusDTO)uiTask.returnData;
|
BatteryStatusDTO batteryStatusDTO = (BatteryStatusDTO) uiTask.returnData;
|
||||||
|
|
||||||
pumpStatus.batteryRemaining = (batteryStatusDTO.getCalculatedPercent(pumpStatus.batteryType));
|
pumpStatus.batteryRemaining = (batteryStatusDTO.getCalculatedPercent(pumpStatus.batteryType));
|
||||||
|
|
||||||
if (batteryStatusDTO.voltage!=null) {
|
if (batteryStatusDTO.voltage != null) {
|
||||||
pumpStatus.batteryVoltage = batteryStatusDTO.voltage;
|
pumpStatus.batteryVoltage = batteryStatusDTO.voltage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -110,7 +105,7 @@ public class MedtronicUIPostprocessor {
|
||||||
LOG.info("BatteryStatus: {}", batteryStatusDTO.toString());
|
LOG.info("BatteryStatus: {}", batteryStatusDTO.toString());
|
||||||
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PumpModel: {
|
case PumpModel: {
|
||||||
if (pumpStatus.medtronicDeviceType != MedtronicUtil.getMedtronicPumpModel()) {
|
if (pumpStatus.medtronicDeviceType != MedtronicUtil.getMedtronicPumpModel()) {
|
||||||
|
@ -119,13 +114,13 @@ public class MedtronicUIPostprocessor {
|
||||||
sendNotification(MedtronicNotificationType.PumpTypeNotSame);
|
sendNotification(MedtronicNotificationType.PumpTypeNotSame);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Settings_512:
|
case Settings_512:
|
||||||
case Settings: {
|
case Settings: {
|
||||||
postProcessSettings(uiTask);
|
postProcessSettings(uiTask);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// no postprocessing
|
// no postprocessing
|
||||||
|
|
||||||
|
@ -140,28 +135,28 @@ public class MedtronicUIPostprocessor {
|
||||||
|
|
||||||
private void processTime(MedtronicUITask uiTask) {
|
private void processTime(MedtronicUITask uiTask) {
|
||||||
|
|
||||||
ClockDTO clockDTO = (ClockDTO)uiTask.returnData;
|
ClockDTO clockDTO = (ClockDTO) uiTask.returnData;
|
||||||
|
|
||||||
Duration dur = new Duration(clockDTO.pumpTime.toDateTime(DateTimeZone.UTC),
|
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);
|
MedtronicUtil.setPumpTime(clockDTO);
|
||||||
|
|
||||||
if (isLogEnabled())
|
if (isLogEnabled())
|
||||||
LOG.debug("Pump Time: " + clockDTO.localDeviceTime + ", DeviceTime=" + clockDTO.pumpTime + //
|
LOG.debug("Pump Time: " + clockDTO.localDeviceTime + ", DeviceTime=" + clockDTO.pumpTime + //
|
||||||
", diff: " + dur.getStandardSeconds() + " s");
|
", diff: " + dur.getStandardSeconds() + " s");
|
||||||
|
|
||||||
if (dur.getStandardMinutes() >= 10) {
|
if (dur.getStandardMinutes() >= 10) {
|
||||||
if (isLogEnabled())
|
if (isLogEnabled())
|
||||||
LOG.warn("Pump clock needs update, pump time: " + clockDTO.pumpTime.toString("HH:mm:ss") + " (difference: "
|
LOG.warn("Pump clock needs update, pump time: " + clockDTO.pumpTime.toString("HH:mm:ss") + " (difference: "
|
||||||
+ dur.getStandardSeconds() + " s)");
|
+ dur.getStandardSeconds() + " s)");
|
||||||
sendNotification(MedtronicNotificationType.PumpWrongTimeUrgent);
|
sendNotification(MedtronicNotificationType.PumpWrongTimeUrgent);
|
||||||
} else if (dur.getStandardMinutes() >= 4) {
|
} else if (dur.getStandardMinutes() >= 4) {
|
||||||
if (isLogEnabled())
|
if (isLogEnabled())
|
||||||
LOG.warn("Pump clock needs update, pump time: " + clockDTO.pumpTime.toString("HH:mm:ss") + " (difference: "
|
LOG.warn("Pump clock needs update, pump time: " + clockDTO.pumpTime.toString("HH:mm:ss") + " (difference: "
|
||||||
+ dur.getStandardSeconds() + " s)");
|
+ dur.getStandardSeconds() + " s)");
|
||||||
sendNotification(MedtronicNotificationType.PumpWrongTimeNormal);
|
sendNotification(MedtronicNotificationType.PumpWrongTimeNormal);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -170,7 +165,7 @@ public class MedtronicUIPostprocessor {
|
||||||
|
|
||||||
private void postProcessSettings(MedtronicUITask uiTask) {
|
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);
|
MedtronicUtil.setSettings(settings);
|
||||||
|
|
||||||
|
|
|
@ -54,27 +54,27 @@ public class MedtronicUITask {
|
||||||
case PumpModel: {
|
case PumpModel: {
|
||||||
returnData = communicationManager.getPumpModel();
|
returnData = communicationManager.getPumpModel();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GetBasalProfileSTD: {
|
case GetBasalProfileSTD: {
|
||||||
returnData = communicationManager.getBasalProfile();
|
returnData = communicationManager.getBasalProfile();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GetRemainingInsulin: {
|
case GetRemainingInsulin: {
|
||||||
returnData = communicationManager.getRemainingInsulin();
|
returnData = communicationManager.getRemainingInsulin();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RealTimeClock: {
|
case RealTimeClock: {
|
||||||
returnData = communicationManager.getPumpTime();
|
returnData = communicationManager.getPumpTime();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GetBatteryStatus: {
|
case GetBatteryStatus: {
|
||||||
returnData = communicationManager.getRemainingBattery();
|
returnData = communicationManager.getRemainingBattery();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SetTemporaryBasal: {
|
case SetTemporaryBasal: {
|
||||||
TempBasalPair tbr = getTBRSettings();
|
TempBasalPair tbr = getTBRSettings();
|
||||||
|
@ -82,29 +82,19 @@ public class MedtronicUITask {
|
||||||
returnData = communicationManager.setTBR(tbr);
|
returnData = communicationManager.setTBR(tbr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ReadTemporaryBasal: {
|
case ReadTemporaryBasal: {
|
||||||
returnData = communicationManager.getTemporaryBasal();
|
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:
|
||||||
case Settings_512: {
|
case Settings_512: {
|
||||||
returnData = communicationManager.getPumpSettings();
|
returnData = communicationManager.getPumpSettings();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SetBolus: {
|
case SetBolus: {
|
||||||
Double amount = getDoubleFromParameters(0);
|
Double amount = getDoubleFromParameters(0);
|
||||||
|
@ -112,27 +102,26 @@ public class MedtronicUITask {
|
||||||
if (amount != null)
|
if (amount != null)
|
||||||
returnData = communicationManager.setBolus(amount);
|
returnData = communicationManager.setBolus(amount);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CancelTBR: {
|
case CancelTBR: {
|
||||||
// FIXME check if TBR is actually running
|
|
||||||
returnData = communicationManager.cancelTBR();
|
returnData = communicationManager.cancelTBR();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SetBasalProfileSTD:
|
case SetBasalProfileSTD:
|
||||||
case SetBasalProfileA: {
|
case SetBasalProfileA: {
|
||||||
BasalProfile profile = (BasalProfile)parameters[0];
|
BasalProfile profile = (BasalProfile) parameters[0];
|
||||||
|
|
||||||
returnData = communicationManager.setBasalProfile(profile);
|
returnData = communicationManager.setBasalProfile(profile);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GetHistoryData: {
|
case GetHistoryData: {
|
||||||
returnData = communicationManager.getPumpHistory((PumpHistoryEntry)parameters[0],
|
returnData = communicationManager.getPumpHistory((PumpHistoryEntry) parameters[0],
|
||||||
(LocalDateTime)parameters[1]);
|
(LocalDateTime) parameters[1]);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default: {
|
default: {
|
||||||
if (isLogEnabled())
|
if (isLogEnabled())
|
||||||
|
@ -156,26 +145,24 @@ public class MedtronicUITask {
|
||||||
|
|
||||||
|
|
||||||
private TempBasalPair getTBRSettings() {
|
private TempBasalPair getTBRSettings() {
|
||||||
TempBasalPair tempBasalPair = new TempBasalPair(getDoubleFromParameters(0), //
|
return new TempBasalPair(getDoubleFromParameters(0), //
|
||||||
false, //
|
false, //
|
||||||
getIntegerFromParameters(1));
|
getIntegerFromParameters(1));
|
||||||
|
|
||||||
return tempBasalPair;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private Float getFloatFromParameters(int index) {
|
private Float getFloatFromParameters(int index) {
|
||||||
return (Float)parameters[index];
|
return (Float) parameters[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public Double getDoubleFromParameters(int index) {
|
public Double getDoubleFromParameters(int index) {
|
||||||
return (Double)parameters[index];
|
return (Double) parameters[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public Integer getIntegerFromParameters(int 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) {
|
if (responseType == MedtronicUIResponseType.Invalid) {
|
||||||
statusChange = new EventMedtronicDeviceStatusChange(PumpDeviceState.ErrorWhenCommunicating,
|
statusChange = new EventMedtronicDeviceStatusChange(PumpDeviceState.ErrorWhenCommunicating,
|
||||||
"Unsupported command in MedtronicUITask");
|
"Unsupported command in MedtronicUITask");
|
||||||
MainApp.bus().post(statusChange);
|
MainApp.bus().post(statusChange);
|
||||||
} else if (responseType == MedtronicUIResponseType.Error) {
|
} else if (responseType == MedtronicUIResponseType.Error) {
|
||||||
statusChange = new EventMedtronicDeviceStatusChange(PumpDeviceState.ErrorWhenCommunicating,
|
statusChange = new EventMedtronicDeviceStatusChange(PumpDeviceState.ErrorWhenCommunicating,
|
||||||
errorDescription);
|
errorDescription);
|
||||||
MainApp.bus().post(statusChange);
|
MainApp.bus().post(statusChange);
|
||||||
} else {
|
} else {
|
||||||
MainApp.bus().post(new EventMedtronicPumpValuesChanged());
|
MainApp.bus().post(new EventMedtronicPumpValuesChanged());
|
||||||
|
|
|
@ -40,6 +40,7 @@ import info.nightscout.androidaps.plugins.pump.medtronic.data.dto.BolusWizardDTO
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.data.dto.ClockDTO;
|
import info.nightscout.androidaps.plugins.pump.medtronic.data.dto.ClockDTO;
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.data.dto.DailyTotalsDTO;
|
import info.nightscout.androidaps.plugins.pump.medtronic.data.dto.DailyTotalsDTO;
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.data.dto.TempBasalPair;
|
import info.nightscout.androidaps.plugins.pump.medtronic.data.dto.TempBasalPair;
|
||||||
|
import info.nightscout.androidaps.plugins.pump.medtronic.data.dto.TempBasalProcessDTO;
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.driver.MedtronicPumpStatus;
|
import info.nightscout.androidaps.plugins.pump.medtronic.driver.MedtronicPumpStatus;
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicConst;
|
import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicConst;
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicUtil;
|
import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicUtil;
|
||||||
|
@ -52,7 +53,7 @@ import info.nightscout.androidaps.utils.SP;
|
||||||
/**
|
/**
|
||||||
* Created by andy on 10/12/18.
|
* Created by andy on 10/12/18.
|
||||||
*/
|
*/
|
||||||
|
// TODO clean up this class (remove/comment logs)
|
||||||
public class MedtronicHistoryData {
|
public class MedtronicHistoryData {
|
||||||
|
|
||||||
private static final Logger LOG = LoggerFactory.getLogger(L.PUMP);
|
private static final Logger LOG = LoggerFactory.getLogger(L.PUMP);
|
||||||
|
@ -66,7 +67,8 @@ public class MedtronicHistoryData {
|
||||||
private Gson gsonPretty;
|
private Gson gsonPretty;
|
||||||
//private List<PumpHistoryEntry> fakeTBRs;
|
//private List<PumpHistoryEntry> fakeTBRs;
|
||||||
|
|
||||||
DatabaseHelper databaseHelper = MainApp.getDbHelper();
|
private DatabaseHelper databaseHelper = MainApp.getDbHelper();
|
||||||
|
private ClockDTO pumpTime;
|
||||||
|
|
||||||
|
|
||||||
public MedtronicHistoryData() {
|
public MedtronicHistoryData() {
|
||||||
|
@ -99,7 +101,7 @@ public class MedtronicHistoryData {
|
||||||
|
|
||||||
this.newHistory = newEntries;
|
this.newHistory = newEntries;
|
||||||
|
|
||||||
showLogs("List of history (before filtering): ", gsonPretty.toJson(this.newHistory));
|
showLogs("List of history (before filtering): [" + this.newHistory.size() + "]", gsonPretty.toJson(this.newHistory));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -176,7 +178,7 @@ public class MedtronicHistoryData {
|
||||||
|
|
||||||
if (isLogEnabled())
|
if (isLogEnabled())
|
||||||
LOG.debug("New History entries found: {}", this.newHistory.size());
|
LOG.debug("New History entries found: {}", this.newHistory.size());
|
||||||
showLogs("List of history (after filtering): ", gsonPretty.toJson(this.newHistory));
|
showLogs("List of history (after filtering): [" + this.newHistory.size() + "]", gsonPretty.toJson(this.newHistory));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -404,8 +406,6 @@ public class MedtronicHistoryData {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ClockDTO pumpTime;
|
|
||||||
|
|
||||||
|
|
||||||
private void processTDDs(List<PumpHistoryEntry> tddsIn) {
|
private void processTDDs(List<PumpHistoryEntry> tddsIn) {
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,5 @@ public class ClockDTO {
|
||||||
|
|
||||||
public LocalDateTime pumpTime;
|
public LocalDateTime pumpTime;
|
||||||
|
|
||||||
// public Duration timeDifference;
|
|
||||||
|
|
||||||
public int timeDifference; // s (pump -> local)
|
public int timeDifference; // s (pump -> local)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.medtronic.data.dto;
|
package info.nightscout.androidaps.plugins.pump.medtronic.data.dto;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import com.google.gson.annotations.Expose;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Locale;
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import com.google.gson.annotations.Expose;
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
import info.nightscout.androidaps.logging.L;
|
import info.nightscout.androidaps.logging.L;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.utils.ByteUtil;
|
import info.nightscout.androidaps.plugins.pump.common.utils.ByteUtil;
|
||||||
|
@ -112,20 +112,19 @@ public class TempBasalPair {
|
||||||
|
|
||||||
public byte[] getAsRawData() {
|
public byte[] getAsRawData() {
|
||||||
|
|
||||||
// TODO check if this works with 523 and higher
|
|
||||||
List<Byte> list = new ArrayList<Byte>();
|
List<Byte> list = new ArrayList<Byte>();
|
||||||
|
|
||||||
list.add((byte)5);
|
list.add((byte) 5);
|
||||||
|
|
||||||
byte[] insulinRate = MedtronicUtil.getBasalStrokes(this.insulinRate, true);
|
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); // ?
|
||||||
|
|
||||||
// list.add((byte) 0); // is_absolute
|
// list.add((byte) 0); // is_absolute
|
||||||
|
|
||||||
if (insulinRate.length == 1)
|
if (insulinRate.length == 1)
|
||||||
list.add((byte)0x00);
|
list.add((byte) 0x00);
|
||||||
else
|
else
|
||||||
list.add(insulinRate[0]);
|
list.add(insulinRate[0]);
|
||||||
|
|
||||||
|
@ -135,7 +134,7 @@ public class TempBasalPair {
|
||||||
list.add(timeMin); // 3 (time) - OK
|
list.add(timeMin); // 3 (time) - OK
|
||||||
|
|
||||||
if (insulinRate.length == 1)
|
if (insulinRate.length == 1)
|
||||||
list.add((byte)0x00);
|
list.add((byte) 0x00);
|
||||||
else
|
else
|
||||||
list.add(insulinRate[0]);
|
list.add(insulinRate[0]);
|
||||||
|
|
||||||
|
@ -145,7 +144,7 @@ public class TempBasalPair {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isCancelTBR() {
|
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
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "TempBasalPair [" + "Rate=" + insulinRate + ", DurationMinutes=" + durationMinutes + ", IsPercent="
|
return "TempBasalPair [" + "Rate=" + insulinRate + ", DurationMinutes=" + durationMinutes + ", IsPercent="
|
||||||
+ isPercent + "]";
|
+ isPercent + "]";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,16 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.medtronic.data.dto;
|
package info.nightscout.androidaps.plugins.pump.medtronic.data.dto;
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.plugins.pump.medtronic.comm.history.pump.PumpHistoryEntry;
|
||||||
|
|
||||||
public class TempBasalProcessDTO {
|
public class TempBasalProcessDTO {
|
||||||
|
|
||||||
|
public PumpHistoryEntry itemOne;
|
||||||
|
public PumpHistoryEntry itemTwo;
|
||||||
|
|
||||||
|
public Operation processOperation = Operation.None;
|
||||||
|
|
||||||
|
|
||||||
|
public static enum Operation {
|
||||||
static enum Operation {
|
|
||||||
None,
|
None,
|
||||||
Add,
|
Add,
|
||||||
Edit
|
Edit
|
||||||
|
|
|
@ -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)
|
* Taken from GNU Gluco Control diabetes management software (ggc.sourceforge.net)
|
||||||
*
|
* <p>
|
||||||
* Description: Medtronic Commands (Pump and CGMS) for all 512 and later models (just 5xx)
|
* Description: Medtronic Commands (Pump and CGMS) for all 512 and later models (just 5xx)
|
||||||
*
|
* <p>
|
||||||
* Link to original/unmodified file:
|
* Link to original/unmodified file:
|
||||||
* https://sourceforge.net/p/ggc/code/HEAD/tree/trunk/ggc-plugins/ggc-plugins-base/src/
|
* https://sourceforge.net/p/ggc/code/HEAD/tree/trunk/ggc-plugins/ggc-plugins-base/src/
|
||||||
* main/java/ggc/plugin/device/impl/minimed/enums/MinimedCommandType.java
|
* main/java/ggc/plugin/device/impl/minimed/enums/MinimedCommandType.java
|
||||||
*
|
* <p>
|
||||||
* A lot of stuff has been removed because it is not needed anymore (historical stuff from CareLink
|
* A lot of stuff has been removed because it is not needed anymore (historical stuff from CareLink
|
||||||
* and Carelink USB communication.
|
* and Carelink USB communication.
|
||||||
*
|
* <p>
|
||||||
* Author: Andy {andy@atech-software.com}
|
* Author: Andy {andy@atech-software.com}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// FIXME: AAPS - a lot of this can be removed. Do cleanup.
|
|
||||||
|
|
||||||
// Lot of stuff in here is legacy stuff for CareLink(1). We should remove it in
|
|
||||||
// future.
|
|
||||||
public enum MedtronicCommandType implements Serializable // , MinimedCommandTypeInterface
|
public enum MedtronicCommandType implements Serializable // , MinimedCommandTypeInterface
|
||||||
{
|
{
|
||||||
InvalidCommand(0, "Invalid Command", null, null, null), //
|
InvalidCommand(0, "Invalid Command", null, null), //
|
||||||
|
|
||||||
// Pump Responses (9)
|
// Pump Responses (9)
|
||||||
CommandACK(0x06, "ACK - Acknowledge", MinimedTargetType.ActionCommand, MedtronicDeviceType.All, MinimedCommandParameterType.NoParameters), //
|
CommandACK(0x06, "ACK - Acknowledge", MedtronicDeviceType.All, MinimedCommandParameterType.NoParameters), //
|
||||||
CommandNAK(0x15, "NAK - Not Acknowledged", MinimedTargetType.ActionCommand, MedtronicDeviceType.All, MinimedCommandParameterType.NoParameters), //
|
CommandNAK(0x15, "NAK - Not Acknowledged", MedtronicDeviceType.All, MinimedCommandParameterType.NoParameters), //
|
||||||
|
|
||||||
// All (8)
|
// All (8)
|
||||||
PushAck(91, "Push ACK", MinimedTargetType.ActionCommand, MedtronicDeviceType.All, MinimedCommandParameterType.FixedParameters, getByteArray(2)), //
|
PushAck(91, "Push ACK", MedtronicDeviceType.All, MinimedCommandParameterType.FixedParameters, getByteArray(2)), //
|
||||||
|
|
||||||
PushEsc(91, "Push Esc", MinimedTargetType.ActionCommand, MedtronicDeviceType.All, MinimedCommandParameterType.FixedParameters, getByteArray(1)), //
|
PushEsc(91, "Push Esc", MedtronicDeviceType.All, MinimedCommandParameterType.FixedParameters, getByteArray(1)), //
|
||||||
|
|
||||||
PushButton(0x5b, "Push Button", MinimedTargetType.ActionCommand, MedtronicDeviceType.All, MinimedCommandParameterType.NoParameters), // 91
|
PushButton(0x5b, "Push Button", MedtronicDeviceType.All, MinimedCommandParameterType.NoParameters), // 91
|
||||||
|
|
||||||
RFPowerOn(93, "RF Power On", MinimedTargetType.InitCommand, MedtronicDeviceType.All, MinimedCommandParameterType.FixedParameters, getByteArray(
|
RFPowerOn(93, "RF Power On", MedtronicDeviceType.All, MinimedCommandParameterType.FixedParameters, getByteArray(
|
||||||
1, 10)), //
|
1, 10)), //
|
||||||
|
|
||||||
RFPowerOff(93, "RF Power Off", MinimedTargetType.InitCommand, MedtronicDeviceType.All, MinimedCommandParameterType.FixedParameters, getByteArray(
|
RFPowerOff(93, "RF Power Off", MedtronicDeviceType.All, MinimedCommandParameterType.FixedParameters, getByteArray(
|
||||||
0, 0)), //
|
0, 0)), //
|
||||||
|
|
||||||
// SetSuspend(77, "Set Suspend", MinimedTargetType.InitCommand, MedtronicDeviceType.All,
|
// SetSuspend(77, "Set Suspend", MinimedTargetType.InitCommand, MedtronicDeviceType.All,
|
||||||
// MinimedCommandParameterType.FixedParameters, getByteArray(1)), //
|
// MinimedCommandParameterType.FixedParameters, getByteArray(1)), //
|
||||||
|
@ -55,13 +50,13 @@ public enum MedtronicCommandType implements Serializable // , MinimedCommandType
|
||||||
// CancelSuspend(77, "Cancel Suspend", MinimedTargetType.InitCommand, MedtronicDeviceType.All,
|
// CancelSuspend(77, "Cancel Suspend", MinimedTargetType.InitCommand, MedtronicDeviceType.All,
|
||||||
// MinimedCommandParameterType.FixedParameters, getByteArray(0)), //
|
// MinimedCommandParameterType.FixedParameters, getByteArray(0)), //
|
||||||
|
|
||||||
PumpState(131, "Pump State", MinimedTargetType.InitCommand, MedtronicDeviceType.All, MinimedCommandParameterType.NoParameters), //
|
PumpState(131, "Pump State", MedtronicDeviceType.All, MinimedCommandParameterType.NoParameters), //
|
||||||
|
|
||||||
ReadPumpErrorStatus(117, "Pump Error Status", MinimedTargetType.InitCommand, MedtronicDeviceType.All, MinimedCommandParameterType.NoParameters), //
|
ReadPumpErrorStatus(117, "Pump Error Status", MedtronicDeviceType.All, MinimedCommandParameterType.NoParameters), //
|
||||||
|
|
||||||
// 511 (InitCommand = 2, Config 7, Data = 1(+3)
|
// 511 (InitCommand = 2, Config 7, Data = 1(+3)
|
||||||
DetectBolus(75, "Detect Bolus", MinimedTargetType.InitCommand, MedtronicDeviceType.Medtronic_511, MinimedCommandParameterType.FixedParameters, getByteArray(
|
// DetectBolus(75, "Detect Bolus", MedtronicDeviceType.Medtronic_511, MinimedCommandParameterType.FixedParameters, getByteArray(
|
||||||
0, 0, 0)), //
|
// 0, 0, 0)), //
|
||||||
|
|
||||||
// RemoteControlIds(118, "Remote Control Ids", MinimedTargetType.PumpConfiguration_NA, MedtronicDeviceType.All,
|
// RemoteControlIds(118, "Remote Control Ids", MinimedTargetType.PumpConfiguration_NA, MedtronicDeviceType.All,
|
||||||
// MinimedCommandParameterType.NoParameters), //
|
// MinimedCommandParameterType.NoParameters), //
|
||||||
|
@ -73,26 +68,26 @@ public enum MedtronicCommandType implements Serializable // , MinimedCommandType
|
||||||
// MinimedCommandParameterType.NoParameters), // init
|
// MinimedCommandParameterType.NoParameters), // init
|
||||||
|
|
||||||
RealTimeClock(112, "Real Time Clock", MedtronicDeviceType.All, MinimedCommandParameterType.NoParameters, //
|
RealTimeClock(112, "Real Time Clock", MedtronicDeviceType.All, MinimedCommandParameterType.NoParameters, //
|
||||||
7, R.string.medtronic_cmd_desc_get_time), // 0x70
|
7, R.string.medtronic_cmd_desc_get_time), // 0x70
|
||||||
|
|
||||||
GetBatteryStatus(0x72, "Get Battery Status", MinimedTargetType.PumpConfiguration, MedtronicDeviceType.All, MinimedCommandParameterType.NoParameters), //
|
GetBatteryStatus(0x72, "Get Battery Status", MedtronicDeviceType.All, MinimedCommandParameterType.NoParameters), //
|
||||||
// GetBattery((byte) 0x72), //
|
// GetBattery((byte) 0x72), //
|
||||||
|
|
||||||
GetRemainingInsulin(0x73, "Read Remaining Insulin", MinimedTargetType.PumpConfiguration, MedtronicDeviceType.All, MinimedCommandParameterType.NoParameters, 2), // 115
|
GetRemainingInsulin(0x73, "Read Remaining Insulin", MedtronicDeviceType.All, MinimedCommandParameterType.NoParameters, 2), // 115
|
||||||
|
|
||||||
SetBolus(0x42, "Set Bolus", MedtronicDeviceType.All, MinimedCommandParameterType.NoParameters, //
|
SetBolus(0x42, "Set Bolus", MedtronicDeviceType.All, MinimedCommandParameterType.NoParameters, //
|
||||||
0, R.string.medtronic_cmd_desc_set_bolus), // 66
|
0, R.string.medtronic_cmd_desc_set_bolus), // 66
|
||||||
|
|
||||||
// 512
|
// 512
|
||||||
ReadTemporaryBasal(0x98, "Read Temporary Basal", MedtronicDeviceType.Medtronic_512andHigher, MinimedCommandParameterType.NoParameters, //
|
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, //
|
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
|
// 512 Config
|
||||||
PumpModel(141, "Pump Model", MedtronicDeviceType.Medtronic_512andHigher, MinimedCommandParameterType.NoParameters, //
|
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,
|
// BGTargets_512(140, "BG Targets", MinimedTargetType.PumpConfiguration, MedtronicDeviceType.Medtronic_512_712,
|
||||||
// MinimedCommandParameterType.NoParameters), //
|
// MinimedCommandParameterType.NoParameters), //
|
||||||
|
@ -104,7 +99,7 @@ public enum MedtronicCommandType implements Serializable // , MinimedCommandType
|
||||||
// MinimedCommandParameterType.NoParameters), //
|
// MinimedCommandParameterType.NoParameters), //
|
||||||
|
|
||||||
Settings_512(145, "Configuration", MedtronicDeviceType.Medtronic_512_712, 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,
|
// BGAlarmClocks(142, "BG Alarm Clocks", MinimedTargetType.PumpConfiguration,
|
||||||
// MedtronicDeviceType.Medtronic_512andHigher, MinimedCommandParameterType.NoParameters), //
|
// MedtronicDeviceType.Medtronic_512andHigher, MinimedCommandParameterType.NoParameters), //
|
||||||
|
@ -120,31 +115,31 @@ public enum MedtronicCommandType implements Serializable // , MinimedCommandType
|
||||||
|
|
||||||
// 512 Data
|
// 512 Data
|
||||||
GetHistoryData(128, "Get History", MedtronicDeviceType.Medtronic_512andHigher, MinimedCommandParameterType.SubCommands, //
|
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, //
|
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, //
|
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, //
|
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, //
|
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, //
|
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, //
|
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
|
// 515
|
||||||
PumpStatus(206, "Pump Status", MinimedTargetType.InitCommand, MedtronicDeviceType.Medtronic_515andHigher, MinimedCommandParameterType.NoParameters), // PumpConfiguration
|
PumpStatus(206, "Pump Status", MedtronicDeviceType.Medtronic_515andHigher, MinimedCommandParameterType.NoParameters), // PumpConfiguration
|
||||||
|
|
||||||
Settings(192, "Configuration", MedtronicDeviceType.Medtronic_515andHigher, MinimedCommandParameterType.NoParameters, //
|
Settings(192, "Configuration", MedtronicDeviceType.Medtronic_515andHigher, MinimedCommandParameterType.NoParameters, //
|
||||||
64, 1, 0, R.string.medtronic_cmd_desc_get_settings), //
|
64, 1, 0, R.string.medtronic_cmd_desc_get_settings), //
|
||||||
|
|
||||||
// 522
|
// 522
|
||||||
SensorSettings_522(153, "Sensor Configuration", MedtronicDeviceType.Medtronic_522andHigher, MinimedCommandParameterType.NoParameters), //
|
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), //
|
GlucoseHistory(154, "Glucose History", MedtronicDeviceType.Medtronic_522andHigher, MinimedCommandParameterType.SubCommands, 1024, 32, 0, null), //
|
||||||
|
|
||||||
// 523
|
// 523
|
||||||
SensorSettings(207, "Sensor Configuration", MinimedTargetType.CGMSConfiguration, MedtronicDeviceType.Medtronic_523andHigher, MinimedCommandParameterType.NoParameters), //
|
SensorSettings(207, "Sensor Configuration", MedtronicDeviceType.Medtronic_523andHigher, MinimedCommandParameterType.NoParameters), //
|
||||||
|
|
||||||
// 553
|
// 553
|
||||||
// 554
|
// 554
|
||||||
|
@ -177,7 +172,8 @@ public enum MedtronicCommandType implements Serializable // , MinimedCommandType
|
||||||
|
|
||||||
// Fake Commands
|
// Fake Commands
|
||||||
|
|
||||||
CancelTBR(), ;
|
CancelTBR(),
|
||||||
|
;
|
||||||
|
|
||||||
static Map<Byte, MedtronicCommandType> mapByCode;
|
static Map<Byte, MedtronicCommandType> mapByCode;
|
||||||
|
|
||||||
|
@ -206,7 +202,7 @@ public enum MedtronicCommandType implements Serializable // , MinimedCommandType
|
||||||
public MinimedCommandParameterType parameterType;
|
public MinimedCommandParameterType parameterType;
|
||||||
public int minimalBufferSizeToStartReading = 14;
|
public int minimalBufferSizeToStartReading = 14;
|
||||||
public int expectedLength = 0;
|
public int expectedLength = 0;
|
||||||
MinimedTargetType targetType;
|
//MinimedTargetType targetType;
|
||||||
MedtronicDeviceType devices;
|
MedtronicDeviceType devices;
|
||||||
private int recordLength = 64;
|
private int recordLength = 64;
|
||||||
|
|
||||||
|
@ -216,51 +212,43 @@ public enum MedtronicCommandType implements Serializable // , MinimedCommandType
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
MedtronicCommandType(int code, String description, MinimedTargetType targetType, MedtronicDeviceType devices,
|
// MedtronicCommandType(int code, String description, MedtronicDeviceType devices,
|
||||||
MinimedCommandParameterType parameterType) {
|
// MinimedCommandParameterType parameterType) {
|
||||||
this(code, description, targetType, devices, parameterType, 64, 1, 0, 0, 0, 0);
|
// this(code, description, devices, parameterType, 64, 1, 0, 0, 0, 0);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
MedtronicCommandType(int code, String description, MinimedTargetType targetType, MedtronicDeviceType devices,
|
// MedtronicCommandType(int code, String description, MedtronicDeviceType devices,
|
||||||
MinimedCommandParameterType parameterType, int expectedLength) {
|
// MinimedCommandParameterType parameterType, int expectedLength) {
|
||||||
this(code, description, targetType, devices, parameterType, 64, 1, 0, 0, 0, expectedLength);
|
// this(code, description, devices, parameterType, 64, 1, 0, 0, 0, expectedLength);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
MedtronicCommandType(int code, String description, MinimedTargetType targetType, MedtronicDeviceType devices,
|
// MedtronicCommandType(int code, String description, MedtronicDeviceType devices,
|
||||||
MinimedCommandParameterType parameterType, int recordLength, int maxRecords, int commandType) {
|
// MinimedCommandParameterType parameterType, int recordLength, int maxRecords, int commandType) {
|
||||||
this(code, description, targetType, devices, parameterType, recordLength, maxRecords, 0, 0, commandType, 0);
|
// this(code, description, devices, parameterType, recordLength, maxRecords, 0, 0, commandType, 0);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
MedtronicCommandType(int code, String description, MinimedTargetType targetType, MedtronicDeviceType devices,
|
// MedtronicCommandType(int code, String description, MedtronicDeviceType devices,
|
||||||
MinimedCommandParameterType parameterType, int recordLength, int maxRecords, int commandType,
|
// MinimedCommandParameterType parameterType, int recordLength, int maxRecords, int commandType,
|
||||||
int expectedLength) {
|
// int expectedLength) {
|
||||||
this(code, description, targetType, devices, parameterType, recordLength, maxRecords, 0, 0, commandType,
|
// this(code, description, devices, parameterType, recordLength, maxRecords, 0, 0, commandType,
|
||||||
expectedLength);
|
// expectedLength);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
MedtronicCommandType(int code, String description, MinimedTargetType targetType, MedtronicDeviceType devices,
|
MedtronicCommandType(int code, String description, MedtronicDeviceType devices,
|
||||||
MinimedCommandParameterType parameterType, byte[] cmd_params) {
|
MinimedCommandParameterType parameterType, byte[] cmd_params) {
|
||||||
this(code, description, targetType, devices, parameterType, 0, 1, 0, 0, 11, 0);
|
this(code, description, devices, parameterType, 0, 1, 0, 0, 11, 0);
|
||||||
|
|
||||||
this.commandParameters = cmd_params;
|
this.commandParameters = cmd_params;
|
||||||
this.commandParametersCount = cmd_params.length;
|
this.commandParametersCount = cmd_params.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// MedtronicCommandType(int code, String description, MinimedTargetType targetType, MedtronicDeviceType devices,
|
|
||||||
// MinimedCommandParameterType parameterType, byte[] cmd_params, int expectedLength) {
|
|
||||||
// this(code, description, targetType, devices, parameterType, 0, 1, 0, 0, 11, expectedLength);
|
|
||||||
//
|
|
||||||
// this.commandParameters = cmd_params;
|
|
||||||
// this.commandParametersCount = cmd_params.length;
|
|
||||||
// }
|
|
||||||
|
|
||||||
MedtronicCommandType(int code, String description, MedtronicDeviceType devices, //
|
MedtronicCommandType(int code, String description, MedtronicDeviceType devices, //
|
||||||
MinimedCommandParameterType parameterType) {
|
MinimedCommandParameterType parameterType) {
|
||||||
|
|
||||||
this(code, description, devices, parameterType, 64, 1, 0, null);
|
this(code, description, devices, parameterType, 64, 1, 0, null);
|
||||||
}
|
}
|
||||||
|
@ -268,31 +256,31 @@ public enum MedtronicCommandType implements Serializable // , MinimedCommandType
|
||||||
|
|
||||||
// NEW
|
// NEW
|
||||||
MedtronicCommandType(int code, String description, MedtronicDeviceType devices,
|
MedtronicCommandType(int code, String description, MedtronicDeviceType devices,
|
||||||
MinimedCommandParameterType parameterType, int recordLength, int maxRecords, int commandType) {
|
MinimedCommandParameterType parameterType, int recordLength, int maxRecords, int commandType) {
|
||||||
this(code, description, devices, parameterType, recordLength, maxRecords, 0, null);
|
this(code, description, devices, parameterType, recordLength, maxRecords, 0, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// NEW
|
// NEW
|
||||||
MedtronicCommandType(int code, String description, MedtronicDeviceType devices, //
|
MedtronicCommandType(int code, String description, MedtronicDeviceType devices, //
|
||||||
MinimedCommandParameterType parameterType, int expectedLength) {
|
MinimedCommandParameterType parameterType, int expectedLength) {
|
||||||
this(code, description, devices, parameterType, 64, 1, expectedLength, null);
|
this(code, description, devices, parameterType, 64, 1, expectedLength, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// NEW
|
// NEW
|
||||||
MedtronicCommandType(int code, String description, MedtronicDeviceType devices, //
|
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);
|
this(code, description, devices, parameterType, 64, 1, expectedLength, resourceId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// NEW
|
// NEW
|
||||||
MedtronicCommandType(int code, String description,
|
MedtronicCommandType(int code, String description,
|
||||||
MedtronicDeviceType devices, //
|
MedtronicDeviceType devices, //
|
||||||
MinimedCommandParameterType parameterType, int recordLength, int max_recs, int expectedLength,
|
MinimedCommandParameterType parameterType, int recordLength, int max_recs, int expectedLength,
|
||||||
Integer resourceId) {
|
Integer resourceId) {
|
||||||
this.commandCode = (byte)code;
|
this.commandCode = (byte) code;
|
||||||
this.commandDescription = description;
|
this.commandDescription = description;
|
||||||
this.devices = devices;
|
this.devices = devices;
|
||||||
this.recordLength = recordLength;
|
this.recordLength = recordLength;
|
||||||
|
@ -311,12 +299,12 @@ public enum MedtronicCommandType implements Serializable // , MinimedCommandType
|
||||||
|
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
MedtronicCommandType(int code, String description, MinimedTargetType targetType, MedtronicDeviceType devices, //
|
MedtronicCommandType(int code, String description, MedtronicDeviceType devices, //
|
||||||
MinimedCommandParameterType parameterType, int recordLength, int max_recs, int addy, //
|
MinimedCommandParameterType parameterType, int recordLength, int max_recs, int addy, //
|
||||||
int addy_len, int cmd_type, int expectedLength) {
|
int addy_len, int cmd_type, int expectedLength) {
|
||||||
this.commandCode = (byte)code;
|
this.commandCode = (byte) code;
|
||||||
this.commandDescription = description;
|
this.commandDescription = description;
|
||||||
this.targetType = targetType;
|
//this.targetType = targetType;
|
||||||
this.devices = devices;
|
this.devices = devices;
|
||||||
this.recordLength = recordLength;
|
this.recordLength = recordLength;
|
||||||
this.maxRecords = max_recs;
|
this.maxRecords = max_recs;
|
||||||
|
@ -349,7 +337,7 @@ public enum MedtronicCommandType implements Serializable // , MinimedCommandType
|
||||||
byte[] array = new byte[data.length];
|
byte[] array = new byte[data.length];
|
||||||
|
|
||||||
for (int i = 0; i < data.length; i++) {
|
for (int i = 0; i < data.length; i++) {
|
||||||
array[i] = (byte)data[i];
|
array[i] = (byte) data[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
return array;
|
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) {
|
public static MedtronicCommandType getByCode(byte code) {
|
||||||
if (mapByCode.containsKey(code)) {
|
if (mapByCode.containsKey(code)) {
|
||||||
return mapByCode.get(code);
|
return mapByCode.get(code);
|
||||||
|
@ -421,7 +383,7 @@ public enum MedtronicCommandType implements Serializable // , MinimedCommandType
|
||||||
*/
|
*/
|
||||||
public String getFullCommandDescription() {
|
public String getFullCommandDescription() {
|
||||||
return "Command [name=" + this.name() + ", id=" + this.commandCode + ",description=" + this.commandDescription
|
return "Command [name=" + this.name() + ", id=" + this.commandCode + ",description=" + this.commandDescription
|
||||||
+ "] ";
|
+ "] ";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -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, //
|
|
||||||
|
|
||||||
;
|
|
||||||
|
|
||||||
}
|
|
|
@ -11,7 +11,6 @@ public enum MedtronicCustomActionType implements CustomActionType {
|
||||||
WakeUpAndTune(), //
|
WakeUpAndTune(), //
|
||||||
ClearBolusBlock(), //
|
ClearBolusBlock(), //
|
||||||
ResetRileyLinkConfiguration(), //
|
ResetRileyLinkConfiguration(), //
|
||||||
|
|
||||||
;
|
;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -13,45 +13,38 @@ public enum MedtronicDeviceType {
|
||||||
Unknown_Device, //
|
Unknown_Device, //
|
||||||
|
|
||||||
// Pump
|
// Pump
|
||||||
// Medtronic_508_508c(null, null), //
|
Medtronic_511("511"), //
|
||||||
Medtronic_511(MedtronicConverterType.Pump511Converter, null, "511"), //
|
|
||||||
|
|
||||||
Medtronic_512(MedtronicConverterType.Pump512Converter, null, "512"), //
|
Medtronic_512("512"), //
|
||||||
Medtronic_712(MedtronicConverterType.Pump512Converter, null, "712"), //
|
Medtronic_712("712"), //
|
||||||
Medtronic_512_712(Medtronic_512, Medtronic_712), //
|
Medtronic_512_712(Medtronic_512, Medtronic_712), //
|
||||||
|
|
||||||
Medtronic_515(MedtronicConverterType.Pump515Converter, null, "515"), //
|
Medtronic_515("515"), //
|
||||||
Medtronic_715(MedtronicConverterType.Pump515Converter, null, "715"), //
|
Medtronic_715("715"), //
|
||||||
Medtronic_515_715(Medtronic_515, Medtronic_715), //
|
Medtronic_515_715(Medtronic_515, Medtronic_715), //
|
||||||
|
|
||||||
Medtronic_522(MedtronicConverterType.Pump515Converter, MedtronicConverterType.CGMS522Converter, "522"), //
|
Medtronic_522("522"), //
|
||||||
Medtronic_722(MedtronicConverterType.Pump515Converter, MedtronicConverterType.CGMS522Converter, "722"), //
|
Medtronic_722("722"), //
|
||||||
Medtronic_522_722(Medtronic_522, Medtronic_722), //
|
Medtronic_522_722(Medtronic_522, Medtronic_722), //
|
||||||
|
|
||||||
Medtronic_523_Revel(MedtronicConverterType.Pump523Converter, MedtronicConverterType.CGMS523Converter, "523"), //
|
Medtronic_523_Revel("523"), //
|
||||||
Medtronic_723_Revel(MedtronicConverterType.Pump523Converter, MedtronicConverterType.CGMS523Converter, "723"), //
|
Medtronic_723_Revel("723"), //
|
||||||
|
|
||||||
Medtronic_554_Veo(MedtronicConverterType.Pump523Converter, MedtronicConverterType.CGMS523Converter, "554"), //
|
Medtronic_554_Veo("554"), //
|
||||||
Medtronic_754_Veo(MedtronicConverterType.Pump523Converter, MedtronicConverterType.CGMS523Converter, "754"), //
|
Medtronic_754_Veo("754"), //
|
||||||
// Minimed_640G(MedtronicConverterType.Pump523Converter, MedtronicConverterType.CGMS523Converter, "640G", null),
|
|
||||||
|
|
||||||
Medtronic_512andHigher(Medtronic_512, Medtronic_712, Medtronic_515, Medtronic_715, Medtronic_522, Medtronic_722, //
|
Medtronic_512andHigher(Medtronic_512, Medtronic_712, Medtronic_515, Medtronic_715, Medtronic_522, Medtronic_722, //
|
||||||
Medtronic_523_Revel, Medtronic_723_Revel, Medtronic_554_Veo, Medtronic_754_Veo), //
|
Medtronic_523_Revel, Medtronic_723_Revel, Medtronic_554_Veo, Medtronic_754_Veo), //
|
||||||
|
|
||||||
Medtronic_515andHigher(Medtronic_515, Medtronic_715, Medtronic_522, Medtronic_722, Medtronic_523_Revel, Medtronic_723_Revel, //
|
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_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_523andHigher(Medtronic_523_Revel, Medtronic_723_Revel, Medtronic_554_Veo, //
|
||||||
Medtronic_754_Veo), //
|
Medtronic_754_Veo), //
|
||||||
|
|
||||||
// Medtronic_553andHigher(Medtronic_553_Revel, Medtronic_753_Revel, Medtronic_554_Veo, Medtronic_754_Veo), //
|
|
||||||
Medtronic_554andHigher(Medtronic_554_Veo, Medtronic_754_Veo), //
|
Medtronic_554andHigher(Medtronic_554_Veo, Medtronic_754_Veo), //
|
||||||
|
|
||||||
// CGMS
|
|
||||||
MedtronicCGMSGold(null, MedtronicConverterType.CGMS522Converter, null), //
|
|
||||||
|
|
||||||
MedtronicGuradianRealTime(null, MedtronicConverterType.CGMS522Converter, null), //
|
|
||||||
|
|
||||||
//
|
//
|
||||||
All;
|
All;
|
||||||
|
@ -71,21 +64,14 @@ public enum MedtronicDeviceType {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MedtronicConverterType pumpConverter;
|
|
||||||
MedtronicConverterType cgmsConverter;
|
|
||||||
private String pumpModel;
|
private String pumpModel;
|
||||||
|
|
||||||
// String smallReservoirPump;
|
|
||||||
// String bigReservoirPump;
|
|
||||||
private boolean isFamily;
|
private boolean isFamily;
|
||||||
private MedtronicDeviceType[] familyMembers = null;
|
private MedtronicDeviceType[] familyMembers = null;
|
||||||
|
|
||||||
|
|
||||||
MedtronicDeviceType(MedtronicConverterType pumpConverter, MedtronicConverterType cgmsConverter, String pumpModel) {
|
MedtronicDeviceType(String pumpModel) {
|
||||||
this.isFamily = false;
|
this.isFamily = false;
|
||||||
this.pumpConverter = pumpConverter;
|
|
||||||
this.cgmsConverter = cgmsConverter;
|
|
||||||
|
|
||||||
this.pumpModel = pumpModel;
|
this.pumpModel = pumpModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -134,16 +120,6 @@ public enum MedtronicDeviceType {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public MedtronicConverterType getCGMSConverterType() {
|
|
||||||
return cgmsConverter;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public MedtronicConverterType getPumpConverterType() {
|
|
||||||
return pumpConverter;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public boolean isLargerFormat() {
|
public boolean isLargerFormat() {
|
||||||
return isSameDevice(this, Medtronic_523andHigher);
|
return isSameDevice(this, Medtronic_523andHigher);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +0,0 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.medtronic.defs;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by andy on 6/14/18.
|
|
||||||
*/
|
|
||||||
|
|
||||||
public enum MedtronicUITaskType {
|
|
||||||
|
|
||||||
GetStatus;
|
|
||||||
|
|
||||||
}
|
|
|
@ -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() {
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -67,7 +67,7 @@ public class MedtronicHistoryActivity extends Activity {
|
||||||
List<PumpHistoryEntry> list = new ArrayList<>();
|
List<PumpHistoryEntry> list = new ArrayList<>();
|
||||||
list.addAll(MedtronicPumpPlugin.getPlugin().getMedtronicHistoryData().getAllHistory());
|
list.addAll(MedtronicPumpPlugin.getPlugin().getMedtronicHistoryData().getAllHistory());
|
||||||
|
|
||||||
LOG.debug("Items on full list: {}", list.size());
|
//LOG.debug("Items on full list: {}", list.size());
|
||||||
|
|
||||||
if (group == PumpHistoryEntryGroup.All) {
|
if (group == PumpHistoryEntryGroup.All) {
|
||||||
this.filteredHistoryList.addAll(list);
|
this.filteredHistoryList.addAll(list);
|
||||||
|
@ -84,7 +84,7 @@ public class MedtronicHistoryActivity extends Activity {
|
||||||
this.recyclerViewAdapter.notifyDataSetChanged();
|
this.recyclerViewAdapter.notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG.debug("Items on filtered list: {}", filteredHistoryList.size());
|
//LOG.debug("Items on filtered list: {}", filteredHistoryList.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -124,9 +124,9 @@ public class MedtronicHistoryActivity extends Activity {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.medtronic_history_activity);
|
setContentView(R.layout.medtronic_history_activity);
|
||||||
|
|
||||||
historyTypeSpinner = (Spinner)findViewById(R.id.medtronic_historytype);
|
historyTypeSpinner = (Spinner) findViewById(R.id.medtronic_historytype);
|
||||||
statusView = (TextView)findViewById(R.id.medtronic_historystatus);
|
statusView = (TextView) findViewById(R.id.medtronic_historystatus);
|
||||||
recyclerView = (RecyclerView)findViewById(R.id.medtronic_history_recyclerview);
|
recyclerView = (RecyclerView) findViewById(R.id.medtronic_history_recyclerview);
|
||||||
|
|
||||||
recyclerView.setHasFixedSize(true);
|
recyclerView.setHasFixedSize(true);
|
||||||
llm = new LinearLayoutManager(this);
|
llm = new LinearLayoutManager(this);
|
||||||
|
@ -148,7 +148,7 @@ public class MedtronicHistoryActivity extends Activity {
|
||||||
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
|
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
|
||||||
if (manualChange)
|
if (manualChange)
|
||||||
return;
|
return;
|
||||||
TypeList selected = (TypeList)historyTypeSpinner.getSelectedItem();
|
TypeList selected = (TypeList) historyTypeSpinner.getSelectedItem();
|
||||||
showingType = selected;
|
showingType = selected;
|
||||||
selectedGroup = selected.entryGroup;
|
selectedGroup = selected.entryGroup;
|
||||||
filterHistory(selectedGroup);
|
filterHistory(selectedGroup);
|
||||||
|
@ -218,7 +218,7 @@ public class MedtronicHistoryActivity extends Activity {
|
||||||
@Override
|
@Override
|
||||||
public HistoryViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) {
|
public HistoryViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) {
|
||||||
View v = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.medtronic_history_item, //
|
View v = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.medtronic_history_item, //
|
||||||
viewGroup, false);
|
viewGroup, false);
|
||||||
return new HistoryViewHolder(v);
|
return new HistoryViewHolder(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -256,9 +256,9 @@ public class MedtronicHistoryActivity extends Activity {
|
||||||
HistoryViewHolder(View itemView) {
|
HistoryViewHolder(View itemView) {
|
||||||
super(itemView);
|
super(itemView);
|
||||||
// cv = (CardView)itemView.findViewById(R.id.rileylink_history_item);
|
// cv = (CardView)itemView.findViewById(R.id.rileylink_history_item);
|
||||||
timeView = (TextView)itemView.findViewById(R.id.medtronic_history_time);
|
timeView = (TextView) itemView.findViewById(R.id.medtronic_history_time);
|
||||||
typeView = (TextView)itemView.findViewById(R.id.medtronic_history_source);
|
typeView = (TextView) itemView.findViewById(R.id.medtronic_history_source);
|
||||||
valueView = (TextView)itemView.findViewById(R.id.medtronic_history_description);
|
valueView = (TextView) itemView.findViewById(R.id.medtronic_history_description);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,5 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.medtronic.dialog;
|
package info.nightscout.androidaps.plugins.pump.medtronic.dialog;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
|
@ -12,6 +9,9 @@ import android.widget.BaseAdapter;
|
||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.dialog.RefreshableInterface;
|
import info.nightscout.androidaps.plugins.pump.common.dialog.RefreshableInterface;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.data.RLHistoryItem;
|
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.data.RLHistoryItem;
|
||||||
|
@ -19,10 +19,13 @@ import info.nightscout.androidaps.plugins.pump.common.utils.StringUtil;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by andy on 5/19/18.
|
* Created by andy on 5/19/18.
|
||||||
|
* <p>
|
||||||
|
* This is for 3rd tab, called Medtronic (in RileyLink stats), that should work similarly as the one in Loop.
|
||||||
|
* <p>
|
||||||
|
* Showing currently selected RL, speed of RL, ability to issue simple commands (getModel, tuneUp, gerProfile)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// FIXME needs to be implemented
|
// TODO needs to be implemented
|
||||||
@Deprecated
|
|
||||||
public class RileyLinkStatusDeviceMedtronic extends Fragment implements RefreshableInterface {
|
public class RileyLinkStatusDeviceMedtronic extends Fragment implements RefreshableInterface {
|
||||||
|
|
||||||
// @BindView(R.id.rileylink_history_list)
|
// @BindView(R.id.rileylink_history_list)
|
||||||
|
@ -45,7 +48,7 @@ public class RileyLinkStatusDeviceMedtronic extends Fragment implements Refresha
|
||||||
public void onStart() {
|
public void onStart() {
|
||||||
super.onStart();
|
super.onStart();
|
||||||
|
|
||||||
this.listView = (ListView)getActivity().findViewById(R.id.rileylink_history_list);
|
this.listView = (ListView) getActivity().findViewById(R.id.rileylink_history_list);
|
||||||
|
|
||||||
listView.setAdapter(adapter);
|
listView.setAdapter(adapter);
|
||||||
|
|
||||||
|
@ -136,12 +139,12 @@ public class RileyLinkStatusDeviceMedtronic extends Fragment implements Refresha
|
||||||
if (view == null) {
|
if (view == null) {
|
||||||
view = mInflator.inflate(R.layout.rileylink_status_device_item, null);
|
view = mInflator.inflate(R.layout.rileylink_status_device_item, null);
|
||||||
viewHolder = new RileyLinkStatusDeviceMedtronic.ViewHolder();
|
viewHolder = new RileyLinkStatusDeviceMedtronic.ViewHolder();
|
||||||
viewHolder.itemTime = (TextView)view.findViewById(R.id.rileylink_history_time);
|
viewHolder.itemTime = (TextView) view.findViewById(R.id.rileylink_history_time);
|
||||||
viewHolder.itemSource = (TextView)view.findViewById(R.id.rileylink_history_source);
|
viewHolder.itemSource = (TextView) view.findViewById(R.id.rileylink_history_source);
|
||||||
viewHolder.itemDescription = (TextView)view.findViewById(R.id.rileylink_history_description);
|
viewHolder.itemDescription = (TextView) view.findViewById(R.id.rileylink_history_description);
|
||||||
view.setTag(viewHolder);
|
view.setTag(viewHolder);
|
||||||
} else {
|
} else {
|
||||||
viewHolder = (RileyLinkStatusDeviceMedtronic.ViewHolder)view.getTag();
|
viewHolder = (RileyLinkStatusDeviceMedtronic.ViewHolder) view.getTag();
|
||||||
}
|
}
|
||||||
|
|
||||||
RLHistoryItem item = historyItemList.get(i);
|
RLHistoryItem item = historyItemList.get(i);
|
||||||
|
|
|
@ -199,11 +199,6 @@ public class RileyLinkMedtronicService extends RileyLinkService {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public boolean handleIncomingServiceTransport(Intent intent) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private boolean isLogEnabled() {
|
private boolean isLogEnabled() {
|
||||||
return L.isEnabled(L.PUMPCOMM);
|
return L.isEnabled(L.PUMPCOMM);
|
||||||
}
|
}
|
||||||
|
|
|
@ -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());
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -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);
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in a new issue