0.10.4-SNAPSHOT
- fixed Tune up - displaying power
This commit is contained in:
parent
86ffc3370a
commit
43c472da17
20 changed files with 149 additions and 210 deletions
|
@ -105,14 +105,14 @@ android {
|
|||
multiDexEnabled true
|
||||
versionCode 1500
|
||||
// dev_version: 2.3.1-dev
|
||||
version "medtronic-0.10.3-SNAPSHOT"
|
||||
version "medtronic-0.10.4-SNAPSHOT"
|
||||
buildConfigField "String", "VERSION", '"' + version + '"'
|
||||
buildConfigField "String", "BUILDVERSION", '"' + generateGitBuild() + '-' + generateDate() + '"'
|
||||
buildConfigField "String", "HEAD", '"' + generateGitBuild() + '"'
|
||||
buildConfigField "String", "REMOTE", '"' + generateGitRemote() + '"'
|
||||
buildConfigField "String", "DEV_VERSION", '"2.3.1-dev"'
|
||||
buildConfigField "String", "DEV_DATE", '"2.5.2019"'
|
||||
buildConfigField "String", "DEV_CHECKIN", '"75d469a9db4bad6c619de8d36006e935c12b6ff1"'
|
||||
buildConfigField "String", "DEV_DATE", '"31.5.2019"'
|
||||
buildConfigField "String", "DEV_CHECKIN", '"e61cbecb2e9f568f6216533034e75733fecb8a36"'
|
||||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
||||
// if you change minSdkVersion to less than 11, you need to change executeTask for wear
|
||||
|
||||
|
|
|
@ -156,7 +156,7 @@ public class MainApp extends Application {
|
|||
File engineeringModeSemaphore = new File(extFilesDir, "engineering_mode");
|
||||
|
||||
engineeringMode = engineeringModeSemaphore.exists() && engineeringModeSemaphore.isFile();
|
||||
devBranch = BuildConfig.VERSION.contains("-") || BuildConfig.VERSION.matches(".*[a-zA-Z]+.*");
|
||||
devBranch = BuildConfig.VERSION.contains("dev");
|
||||
|
||||
sBus = L.isEnabled(L.EVENTS) && devBranch ? new LoggingBus(ThreadEnforcer.ANY) : new Bus(ThreadEnforcer.ANY);
|
||||
|
||||
|
@ -186,11 +186,9 @@ public class MainApp extends Application {
|
|||
if (Config.PUMPDRIVERS) pluginsList.add(LocalInsightPlugin.getPlugin());
|
||||
pluginsList.add(CareportalPlugin.getPlugin());
|
||||
if (Config.PUMPDRIVERS) pluginsList.add(ComboPlugin.getPlugin());
|
||||
if (Config.PUMPDRIVERS) pluginsList.add(MedtronicPumpPlugin.getPlugin());
|
||||
if (Config.MDI) pluginsList.add(MDIPlugin.getPlugin());
|
||||
pluginsList.add(VirtualPumpPlugin.getPlugin());
|
||||
if (Config.PUMPDRIVERS && engineeringMode) {
|
||||
pluginsList.add(MedtronicPumpPlugin.getPlugin());
|
||||
}
|
||||
if (Config.APS) pluginsList.add(LoopPlugin.getPlugin());
|
||||
if (Config.APS) pluginsList.add(OpenAPSMAPlugin.getPlugin());
|
||||
if (Config.APS) pluginsList.add(OpenAPSAMAPlugin.getPlugin());
|
||||
|
|
|
@ -57,7 +57,7 @@ private fun checkVersion() = if (isConnected()) {
|
|||
val request = HttpGet("https://raw.githubusercontent.com/MilosKozak/AndroidAPS/master/app/build.gradle")
|
||||
val response: HttpResponse = DefaultHttpClient().execute(request)
|
||||
val version: String? = response.entity.content?.findVersion()
|
||||
compareWithCurrentVersion(version, BuildConfig.VERSION_NAME)
|
||||
compareWithCurrentVersion(version, BuildConfig.DEV_VERSION)
|
||||
} catch (e: IOException) {
|
||||
log.debug("Github master version check error: $e")
|
||||
}
|
||||
|
|
|
@ -30,6 +30,8 @@ public abstract class PumpStatus {
|
|||
public double reservoirRemainingUnits = 0d;
|
||||
public String reservoirFullUnits = "???";
|
||||
public int batteryRemaining = 0; // percent, so 0-100
|
||||
public Double batteryVoltage = null;
|
||||
|
||||
|
||||
// iob
|
||||
public String iob = null;
|
||||
|
@ -42,15 +44,7 @@ public abstract class PumpStatus {
|
|||
public ProfileStore profileStore;
|
||||
public String units; // Constants.MGDL or Constants.MMOL
|
||||
public PumpStatusType pumpStatusType = PumpStatusType.Running;
|
||||
// TODO maybe not needed anymore in 2.0
|
||||
public Double constraintBasalRateAbsolute;
|
||||
public Integer constraintBasalRatePercent;
|
||||
public Double constraintBolus;
|
||||
public Integer constraintCarbs;
|
||||
public Double constraintMaxIob;
|
||||
public Double[] basalsByHour;
|
||||
// public double remainUnits = 0;
|
||||
public int remainBattery = 0;
|
||||
public double currentBasal = 0;
|
||||
public int tempBasalInProgress = 0;
|
||||
public int tempBasalRatio = 0;
|
||||
|
@ -66,20 +60,6 @@ public abstract class PumpStatus {
|
|||
}
|
||||
|
||||
|
||||
// FIXME cleanup this is from RT2
|
||||
|
||||
// public long getTimeIndex() {
|
||||
// return (long) Math.ceil(time.getTime() / 60000d);
|
||||
// }
|
||||
//
|
||||
// public void setTimeIndex(long timeIndex) {
|
||||
// this.timeIndex = timeIndex;
|
||||
// }
|
||||
//
|
||||
// public long timeIndex;
|
||||
//
|
||||
// public Date time;
|
||||
|
||||
public abstract void initSettings();
|
||||
|
||||
|
||||
|
|
|
@ -237,8 +237,9 @@ public abstract class RileyLinkCommunicationManager {
|
|||
radioResponse.init(resp.getRaw());
|
||||
|
||||
if (radioResponse.isValid()) {
|
||||
sumRSSI += calculateRssi(radioResponse.rssi);
|
||||
trial.rssiList.add(radioResponse.rssi);
|
||||
int rssi = calculateRssi(radioResponse.rssi);
|
||||
sumRSSI += rssi;
|
||||
trial.rssiList.add(rssi);
|
||||
trial.successes++;
|
||||
} else {
|
||||
LOG.warn("Failed to parse radio response: " + ByteUtil.shortHexString(resp.getRaw()));
|
||||
|
@ -272,8 +273,7 @@ public abstract class RileyLinkCommunicationManager {
|
|||
FrequencyTrial one = results.trials.get(k);
|
||||
|
||||
stringBuilder.append(String.format("Scan Result[%s]: Freq=%s, avg RSSI = %s\n", "" + k, ""
|
||||
+ one.frequencyMHz, "" + one.averageRSSI + ", RSSIs =" + one.rssiList + ", averageRSSI_Old="
|
||||
+ one.averageRSSI2));
|
||||
+ one.frequencyMHz, "" + one.averageRSSI + ", RSSIs =" + one.rssiList));
|
||||
}
|
||||
|
||||
LOG.info(stringBuilder.toString());
|
||||
|
|
|
@ -72,15 +72,17 @@ public class RadioResponse {
|
|||
// This does not look like something valid heard from a RileyLink device
|
||||
return;
|
||||
}
|
||||
rssi = rxData[0];
|
||||
responseNumber = rxData[1];
|
||||
byte[] encodedPayload;
|
||||
|
||||
if (RileyLinkFirmwareVersion.isSameVersion(RileyLinkUtil.getRileyLinkServiceData().versionCC110,
|
||||
RileyLinkFirmwareVersion.Version2)) {
|
||||
encodedPayload = ByteUtil.substring(rxData, 3, rxData.length - 3);
|
||||
rssi = rxData[1];
|
||||
responseNumber = rxData[2];
|
||||
} else {
|
||||
encodedPayload = ByteUtil.substring(rxData, 2, rxData.length - 2);
|
||||
rssi = rxData[0];
|
||||
responseNumber = rxData[1];
|
||||
}
|
||||
|
||||
try {
|
||||
|
|
|
@ -10,6 +10,7 @@ import android.content.Intent;
|
|||
import android.graphics.Color;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.SystemClock;
|
||||
import android.text.Spanned;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
|
@ -34,11 +35,13 @@ import info.nightscout.androidaps.events.EventTempBasalChange;
|
|||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.androidaps.plugins.common.SubscriberFragment;
|
||||
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
|
||||
import info.nightscout.androidaps.plugins.general.overview.dialogs.MessageHelperActivity;
|
||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkUtil;
|
||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkError;
|
||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkServiceState;
|
||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkTargetDevice;
|
||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.dialog.RileyLinkStatusActivity;
|
||||
import info.nightscout.androidaps.plugins.pump.medtronic.defs.BatteryType;
|
||||
import info.nightscout.androidaps.plugins.pump.medtronic.defs.MedtronicCommandType;
|
||||
import info.nightscout.androidaps.plugins.pump.medtronic.defs.PumpDeviceState;
|
||||
import info.nightscout.androidaps.plugins.pump.medtronic.dialog.MedtronicHistoryActivity;
|
||||
|
@ -148,12 +151,22 @@ public class MedtronicFragment extends SubscriberFragment {
|
|||
|
||||
@OnClick(R.id.medtronic_history)
|
||||
void onHistoryClick() {
|
||||
startActivity(new Intent(getContext(), MedtronicHistoryActivity.class));
|
||||
if (MedtronicUtil.getPumpStatus().verifyConfiguration()) {
|
||||
startActivity(new Intent(getContext(), MedtronicHistoryActivity.class));
|
||||
} else {
|
||||
MedtronicUtil.displayNotConfiguredDialog();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@OnClick(R.id.medtronic_refresh)
|
||||
void onRefreshClick() {
|
||||
|
||||
if (!MedtronicUtil.getPumpStatus().verifyConfiguration()) {
|
||||
MedtronicUtil.displayNotConfiguredDialog();
|
||||
return;
|
||||
}
|
||||
|
||||
if (refreshButtonStatic != null)
|
||||
refreshButtonStatic.setEnabled(false);
|
||||
|
||||
|
@ -178,13 +191,17 @@ public class MedtronicFragment extends SubscriberFragment {
|
|||
|
||||
@OnClick(R.id.medtronic_stats)
|
||||
void onStatsClick() {
|
||||
startActivity(new Intent(getContext(), RileyLinkStatusActivity.class));
|
||||
if (MedtronicUtil.getPumpStatus().verifyConfiguration()) {
|
||||
startActivity(new Intent(getContext(), RileyLinkStatusActivity.class));
|
||||
} else {
|
||||
MedtronicUtil.displayNotConfiguredDialog();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Subscribe
|
||||
public void onStatusEvent(final EventPumpStatusChanged c) {
|
||||
|
||||
updateGUI();
|
||||
}
|
||||
|
||||
|
||||
|
@ -481,8 +498,12 @@ public class MedtronicFragment extends SubscriberFragment {
|
|||
}
|
||||
|
||||
// battery
|
||||
batteryView.setText("{fa-battery-" + (pumpStatus.batteryRemaining / 25) + "} " + pumpStatus.batteryRemaining + "%");
|
||||
SetWarnColor.setColorInverse(batteryView, pumpStatus.batteryRemaining, 51d, 26d);
|
||||
if (MedtronicUtil.getBatteryType()== BatteryType.None || pumpStatus.batteryVoltage==null) {
|
||||
batteryView.setText("{fa-battery-" + (pumpStatus.batteryRemaining / 25) + "} ");
|
||||
} else {
|
||||
batteryView.setText("{fa-battery-" + (pumpStatus.batteryRemaining / 25) + "} " + pumpStatus.batteryRemaining + "%" + String.format(" (%.2f V)", pumpStatus.batteryVoltage));
|
||||
}
|
||||
SetWarnColor.setColorInverse(batteryView, pumpStatus.batteryRemaining, 25d, 10d);
|
||||
|
||||
// reservoir
|
||||
reservoirView.setText(DecimalFormatter.to0Decimal(pumpStatus.reservoirRemainingUnits) + " / "
|
||||
|
|
|
@ -66,6 +66,7 @@ import info.nightscout.androidaps.plugins.pump.medtronic.defs.MedtronicCommandTy
|
|||
import info.nightscout.androidaps.plugins.pump.medtronic.defs.MedtronicCustomActionType;
|
||||
import info.nightscout.androidaps.plugins.pump.medtronic.defs.MedtronicNotificationType;
|
||||
import info.nightscout.androidaps.plugins.pump.medtronic.defs.MedtronicStatusRefreshType;
|
||||
import info.nightscout.androidaps.plugins.pump.medtronic.dialog.MedtronicHistoryActivity;
|
||||
import info.nightscout.androidaps.plugins.pump.medtronic.driver.MedtronicPumpStatus;
|
||||
import info.nightscout.androidaps.plugins.pump.medtronic.events.EventMedtronicPumpValuesChanged;
|
||||
import info.nightscout.androidaps.plugins.pump.medtronic.service.RileyLinkMedtronicService;
|
||||
|
@ -1415,9 +1416,13 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
|
|||
|
||||
switch (mcat) {
|
||||
|
||||
case WakeUpAndTune:
|
||||
ServiceTaskExecutor.startTask(new WakeAndTuneTask());
|
||||
break;
|
||||
case WakeUpAndTune: {
|
||||
if (MedtronicUtil.getPumpStatus().verifyConfiguration()) {
|
||||
ServiceTaskExecutor.startTask(new WakeAndTuneTask());
|
||||
} else {
|
||||
MedtronicUtil.displayNotConfiguredDialog();
|
||||
}
|
||||
} break;
|
||||
|
||||
case ClearBolusBlock: {
|
||||
this.busyTimestamps.clear();
|
||||
|
|
|
@ -175,17 +175,7 @@ public class MedtronicConverter {
|
|||
double d = (ByteUtil.toInt(rawData[1], rawData[2])*1.0d) / 100.0d;
|
||||
|
||||
batteryStatus.voltage = d;
|
||||
|
||||
// double perc = (d - BatteryType.Alkaline.lowVoltage) / (BatteryType.Alkaline.highVoltage -
|
||||
// BatteryType.Alkaline.lowVoltage);
|
||||
//
|
||||
// LOG.warn("Percent status: " + perc);
|
||||
// LOG.warn("Unknown status: " + rawData[0]);
|
||||
// LOG.warn("Full result: " + d);
|
||||
//
|
||||
// int percent = (int) (perc * 100.0d);
|
||||
|
||||
// return percent;
|
||||
batteryStatus.extendedDataReceived = true;
|
||||
}
|
||||
|
||||
return batteryStatus;
|
||||
|
|
|
@ -186,10 +186,8 @@ public class MedtronicPumpHistoryDecoder extends MedtronicHistoryDecoder<PumpHis
|
|||
|
||||
switch (entry.getEntryType()) {
|
||||
|
||||
// Valid entries, but not processed
|
||||
case ChangeBasalPattern:
|
||||
return RecordDecodeStatus.OK; // Not supported at the moment
|
||||
|
||||
// AAPS Implementation - Ignored entries
|
||||
case CalBGForPH:
|
||||
case ChangeRemoteId:
|
||||
case ClearAlarm:
|
||||
|
|
|
@ -1,26 +0,0 @@
|
|||
package info.nightscout.androidaps.plugins.pump.medtronic.comm.message;
|
||||
|
||||
/**
|
||||
* Created by geoff on 6/2/16.
|
||||
*/
|
||||
@Deprecated
|
||||
public class ButtonPressCarelinkMessageBody extends CarelinkLongMessageBody {
|
||||
|
||||
public static final byte BUTTON_EASY = 0x00;
|
||||
public static final byte BUTTON_ESC = 0x01;
|
||||
public static final byte BUTTON_ACT = 0x02;
|
||||
public static final byte BUTTON_UP = 0x03;
|
||||
public static final byte BUTTON_DOWN = 0x04;
|
||||
|
||||
|
||||
public ButtonPressCarelinkMessageBody(int which) {
|
||||
init(which);
|
||||
}
|
||||
|
||||
|
||||
public void init(int buttonType) {
|
||||
int numArgs = 1;
|
||||
super.init(new byte[] { (byte)numArgs, (byte)buttonType });
|
||||
}
|
||||
|
||||
}
|
|
@ -102,12 +102,13 @@ public class MedtronicUIPostprocessor {
|
|||
|
||||
pumpStatus.batteryRemaining = (batteryStatusDTO.getCalculatedPercent(pumpStatus.batteryType));
|
||||
|
||||
LOG.info("BatteryStatus: {}", batteryStatusDTO.toString());
|
||||
if (batteryStatusDTO.voltage!=null) {
|
||||
pumpStatus.batteryVoltage = batteryStatusDTO.voltage;
|
||||
}
|
||||
|
||||
if (isLogEnabled())
|
||||
LOG.info("BatteryStatus: {}", batteryStatusDTO.toString());
|
||||
|
||||
// if (batteryStatusDTO.batteryStatusType == BatteryStatusDTO.BatteryStatusType.Low)
|
||||
// pumpStatus.batteryRemaining = 18;
|
||||
// else
|
||||
// pumpStatus.batteryRemaining = 70;
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
|
@ -396,7 +396,8 @@ public class MedtronicHistoryData {
|
|||
|
||||
List<PumpHistoryEntry> tdds = filterTDDs(tddsIn);
|
||||
|
||||
LOG.error(getLogPrefix() + "TDDs found: {}.\n{}", tdds.size(), gsonPretty.toJson(tdds));
|
||||
if (isLogEnabled())
|
||||
LOG.debug(getLogPrefix() + "TDDs found: {}.\n{}", tdds.size(), gsonPretty.toJson(tdds));
|
||||
|
||||
List<TDD> tddsDb = databaseHelper.getTDDsForLastXDays(3);
|
||||
|
||||
|
@ -509,6 +510,12 @@ public class MedtronicHistoryData {
|
|||
|
||||
TempBasalPair tbr = (TempBasalPair) treatment.getDecodedDataEntry("Object");
|
||||
|
||||
if (!tbr.isCancelTBR()) {
|
||||
|
||||
} else {
|
||||
|
||||
}
|
||||
|
||||
boolean isPossibleCancel = false;
|
||||
|
||||
if (tbr.getInsulinRate() > 0.0d) {
|
||||
|
|
|
@ -12,8 +12,11 @@ public class BatteryStatusDTO {
|
|||
|
||||
@Expose
|
||||
public BatteryStatusType batteryStatusType;
|
||||
@Expose
|
||||
public Double voltage;
|
||||
|
||||
public boolean extendedDataReceived = false;
|
||||
|
||||
|
||||
public int getCalculatedPercent(BatteryType batteryType) {
|
||||
if (voltage==null || batteryType==BatteryType.None) {
|
||||
|
|
|
@ -4,6 +4,7 @@ import org.slf4j.Logger;
|
|||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.google.common.base.MoreObjects;
|
||||
import com.google.gson.annotations.Expose;
|
||||
|
||||
import info.nightscout.androidaps.db.TDD;
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
|
@ -40,8 +41,11 @@ public class DailyTotalsDTO {
|
|||
private Integer sensorCalcCount;
|
||||
private Integer sensorDataCount;
|
||||
|
||||
@Expose
|
||||
private Double insulinTotal = 0.0d;
|
||||
@Expose
|
||||
private Double insulinBasal = 0.0d;
|
||||
@Expose
|
||||
private Double insulinBolus = 0.0d;
|
||||
private Double insulinCarbs;
|
||||
|
||||
|
|
|
@ -1,111 +0,0 @@
|
|||
package info.nightscout.androidaps.plugins.pump.medtronic.data.dto;
|
||||
|
||||
import info.nightscout.androidaps.plugins.pump.common.utils.StringUtil;
|
||||
|
||||
/**
|
||||
* Application: GGC - GNU Gluco Control
|
||||
* Plug-in: Pump Tool (support for Pump devices)
|
||||
* <p>
|
||||
* See AUTHORS for copyright information.
|
||||
* <p>
|
||||
* This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public
|
||||
* License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later
|
||||
* version.
|
||||
* <p>
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
* <p>
|
||||
* You should have received a copy of the GNU General Public License along with this program; if not, write to the Free
|
||||
* Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
* <p>
|
||||
* Filename: BolusDTO Description: Bolus DTO
|
||||
* <p>
|
||||
* Author: Andy {andy@atech-software.com}
|
||||
*/
|
||||
@Deprecated
|
||||
public class TemporaryBasalRateDTO extends PumpTimeStampedRecord {
|
||||
|
||||
private Float amount;
|
||||
private TBRUnit unit = TBRUnit.Percent; // percent, U
|
||||
private Integer duration; // min
|
||||
|
||||
|
||||
// private ATechDate aTechDate;
|
||||
|
||||
public TemporaryBasalRateDTO() {
|
||||
// this.decimalPrecission = 2;
|
||||
}
|
||||
|
||||
|
||||
public Integer getDuration() {
|
||||
return duration;
|
||||
}
|
||||
|
||||
|
||||
public void setDuration(Integer duration) {
|
||||
this.duration = duration;
|
||||
}
|
||||
|
||||
|
||||
private String getDurationString() {
|
||||
int minutes = this.duration;
|
||||
|
||||
int h = minutes / 60;
|
||||
|
||||
minutes -= (h * 60);
|
||||
|
||||
return StringUtil.getLeadingZero(h, 2) + ":" + StringUtil.getLeadingZero(minutes, 2);
|
||||
}
|
||||
|
||||
|
||||
public String getValue() {
|
||||
float val = amount;
|
||||
String sign = "";
|
||||
|
||||
if (val < 0) {
|
||||
sign = "-";
|
||||
val *= -1;
|
||||
}
|
||||
|
||||
return String.format("TBR_VALUE=%s%s;TBR_UNIT=%s;DURATION=%s", sign, getFormattedDecimal(val), getUnit()
|
||||
.getDescription(), getDurationString());
|
||||
}
|
||||
|
||||
|
||||
public Float getAmount() {
|
||||
return amount;
|
||||
}
|
||||
|
||||
|
||||
public void setAmount(Float amount) {
|
||||
this.amount = amount;
|
||||
}
|
||||
|
||||
|
||||
public TBRUnit getUnit() {
|
||||
return unit;
|
||||
}
|
||||
|
||||
|
||||
public void setUnit(TBRUnit unit) {
|
||||
this.unit = unit;
|
||||
}
|
||||
|
||||
public enum TBRUnit {
|
||||
Percent("%"), //
|
||||
Unit("U");
|
||||
|
||||
String unit;
|
||||
|
||||
|
||||
TBRUnit(String unit) {
|
||||
this.unit = unit;
|
||||
}
|
||||
|
||||
|
||||
public String getDescription() {
|
||||
return unit;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -139,7 +139,7 @@ public class MedtronicPumpStatus extends PumpStatus {
|
|||
}
|
||||
|
||||
|
||||
public void verifyConfiguration() {
|
||||
public boolean verifyConfiguration() {
|
||||
try {
|
||||
|
||||
// FIXME don't reload information several times
|
||||
|
@ -155,11 +155,11 @@ public class MedtronicPumpStatus extends PumpStatus {
|
|||
|
||||
if (serialNr == null) {
|
||||
this.errorDescription = MainApp.gs(R.string.medtronic_error_serial_not_set);
|
||||
return;
|
||||
return false;
|
||||
} else {
|
||||
if (!serialNr.matches(regexSN)) {
|
||||
this.errorDescription = MainApp.gs(R.string.medtronic_error_serial_invalid);
|
||||
return;
|
||||
return false;
|
||||
} else {
|
||||
if (!serialNr.equals(this.serialNumber)) {
|
||||
this.serialNumber = serialNr;
|
||||
|
@ -172,13 +172,13 @@ public class MedtronicPumpStatus extends PumpStatus {
|
|||
|
||||
if (pumpType == null) {
|
||||
this.errorDescription = MainApp.gs(R.string.medtronic_error_pump_type_not_set);
|
||||
return;
|
||||
return false;
|
||||
} else {
|
||||
String pumpTypePart = pumpType.substring(0, 3);
|
||||
|
||||
if (!pumpTypePart.matches("[0-9]{3}")) {
|
||||
this.errorDescription = MainApp.gs(R.string.medtronic_error_pump_type_invalid);
|
||||
return;
|
||||
return false;
|
||||
} else {
|
||||
this.pumpType = medtronicPumpMap.get(pumpTypePart);
|
||||
this.medtronicDeviceType = medtronicDeviceTypeMap.get(pumpTypePart);
|
||||
|
@ -194,11 +194,11 @@ public class MedtronicPumpStatus extends PumpStatus {
|
|||
|
||||
if (pumpFrequency == null) {
|
||||
this.errorDescription = MainApp.gs(R.string.medtronic_error_pump_frequency_not_set);
|
||||
return;
|
||||
return false;
|
||||
} else {
|
||||
if (!pumpFrequency.equals(frequencies[0]) && !pumpFrequency.equals(frequencies[1])) {
|
||||
this.errorDescription = MainApp.gs(R.string.medtronic_error_pump_frequency_invalid);
|
||||
return;
|
||||
return false;
|
||||
} else {
|
||||
this.pumpFrequency = pumpFrequency;
|
||||
this.isFrequencyUS = pumpFrequency.equals(frequencies[0]);
|
||||
|
@ -222,7 +222,7 @@ public class MedtronicPumpStatus extends PumpStatus {
|
|||
if (isLogEnabled())
|
||||
LOG.debug("RileyLink address invalid: null");
|
||||
this.errorDescription = MainApp.gs(R.string.medtronic_error_rileylink_address_invalid);
|
||||
return;
|
||||
return false;
|
||||
} else {
|
||||
if (!rileyLinkAddress.matches(regexMac)) {
|
||||
this.errorDescription = MainApp.gs(R.string.medtronic_error_rileylink_address_invalid);
|
||||
|
@ -255,6 +255,10 @@ public class MedtronicPumpStatus extends PumpStatus {
|
|||
|
||||
String encodingTypeStr = SP.getString(MedtronicConst.Prefs.Encoding, null);
|
||||
|
||||
if (encodingTypeStr==null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
RileyLinkEncodingType newEncodingType = RileyLinkEncodingType.getByDescription(encodingTypeStr);
|
||||
|
||||
if (this.encodingType == null) {
|
||||
|
@ -266,17 +270,24 @@ public class MedtronicPumpStatus extends PumpStatus {
|
|||
|
||||
String batteryTypeStr = SP.getString(MedtronicConst.Prefs.BatteryType, null);
|
||||
|
||||
if (batteryTypeStr==null)
|
||||
return false;
|
||||
|
||||
BatteryType batteryType = BatteryType.getByDescription(batteryTypeStr);
|
||||
|
||||
if (this.batteryType != batteryType) {
|
||||
this.batteryType = batteryType;
|
||||
MedtronicUtil.setBatteryType(this.batteryType);
|
||||
}
|
||||
|
||||
reconfigureService();
|
||||
|
||||
return true;
|
||||
|
||||
} catch (Exception ex) {
|
||||
this.errorDescription = ex.getMessage();
|
||||
LOG.error("Error on Verification: " + ex.getMessage(), ex);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package info.nightscout.androidaps.plugins.pump.medtronic.util;
|
||||
|
||||
import android.content.Intent;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
|
||||
|
@ -14,7 +16,9 @@ import org.slf4j.Logger;
|
|||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.androidaps.plugins.general.overview.dialogs.MessageHelperActivity;
|
||||
import info.nightscout.androidaps.plugins.general.overview.events.EventDismissNotification;
|
||||
import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification;
|
||||
import info.nightscout.androidaps.plugins.general.overview.notifications.Notification;
|
||||
|
@ -27,6 +31,7 @@ import info.nightscout.androidaps.plugins.pump.medtronic.comm.MedtronicCommunica
|
|||
|
||||
import info.nightscout.androidaps.plugins.pump.medtronic.data.dto.ClockDTO;
|
||||
import info.nightscout.androidaps.plugins.pump.medtronic.data.dto.PumpSettingDTO;
|
||||
import info.nightscout.androidaps.plugins.pump.medtronic.defs.BatteryType;
|
||||
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.defs.MedtronicNotificationType;
|
||||
|
@ -57,6 +62,7 @@ public class MedtronicUtil extends RileyLinkUtil {
|
|||
public static Gson gsonInstance = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create();
|
||||
public static Gson gsonInstancePretty = new GsonBuilder().excludeFieldsWithoutExposeAnnotation()
|
||||
.setPrettyPrinting().create();
|
||||
private static BatteryType batteryType = BatteryType.None;
|
||||
|
||||
|
||||
public static Gson getGsonInstance() {
|
||||
|
@ -506,4 +512,27 @@ public class MedtronicUtil extends RileyLinkUtil {
|
|||
public static ClockDTO getPumpTime() {
|
||||
return MedtronicUtil.pumpTime;
|
||||
}
|
||||
|
||||
public static void setBatteryType(BatteryType batteryType) {
|
||||
MedtronicUtil.batteryType = batteryType;
|
||||
}
|
||||
|
||||
|
||||
public static BatteryType getBatteryType() {
|
||||
return MedtronicUtil.batteryType;
|
||||
}
|
||||
|
||||
|
||||
public static void displayNotConfiguredDialog() {
|
||||
new Thread(() -> {
|
||||
|
||||
Intent i = new Intent(MainApp.instance(), MessageHelperActivity.class);
|
||||
i.putExtra("status", MainApp.gs(R.string.medtronic_error_operation_not_possible_no_configuration));
|
||||
i.putExtra("title", MainApp.gs(R.string.combo_warning));
|
||||
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
MainApp.instance().startActivity(i);
|
||||
|
||||
}).start();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -290,7 +290,7 @@ public class TreatmentService extends OrmLiteBaseService<DatabaseHelper> {
|
|||
}
|
||||
|
||||
} catch (SQLException e) {
|
||||
log.error("Unhandled exception", e);
|
||||
log.error("Unhandled SQL exception: {}", e.getMessage(), e);
|
||||
}
|
||||
return new UpdateReturn(false, false);
|
||||
}
|
||||
|
|
|
@ -3,6 +3,8 @@ package info.nightscout.androidaps.plugins.pump.medtronic.comm.history.pump;
|
|||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* Created by andy on 4/9/19.
|
||||
*/
|
||||
|
@ -20,4 +22,29 @@ public class PumpHistoryEntryUTest {
|
|||
Assert.assertTrue(phe.isAfter(queryObject));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDatesTDD() {
|
||||
long[] data = { 1557010799726L,
|
||||
1557010799651L,
|
||||
1557010799393L,
|
||||
1557010799289L,
|
||||
1557010799109L,
|
||||
1556924400709L,
|
||||
1556924400521L,
|
||||
1556924400353L,
|
||||
1556924399948L,
|
||||
1556924399910L };
|
||||
|
||||
for (long datum : data) {
|
||||
Date d = new Date();
|
||||
d.setTime(datum);
|
||||
|
||||
System.out.println("Date: " + d);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue