MDT refactor pass 12
This commit is contained in:
parent
6add8a8d86
commit
e21b1e4d3d
11 changed files with 60 additions and 77 deletions
|
@ -16,13 +16,11 @@ import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.data.Radi
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.data.RadioResponse;
|
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.data.RadioResponse;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.defs.RLMessageType;
|
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.defs.RLMessageType;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.defs.RileyLinkBLEError;
|
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.defs.RileyLinkBLEError;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.RileyLinkServiceData;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.tasks.ServiceTaskExecutor;
|
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.tasks.ServiceTaskExecutor;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.tasks.WakeAndTuneTask;
|
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.tasks.WakeAndTuneTask;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.utils.ByteUtil;
|
import info.nightscout.androidaps.plugins.pump.common.utils.ByteUtil;
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.defs.PumpDeviceState;
|
import info.nightscout.androidaps.plugins.pump.medtronic.defs.PumpDeviceState;
|
||||||
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.utils.sharedPreferences.SP;
|
import info.nightscout.androidaps.utils.sharedPreferences.SP;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -37,7 +35,6 @@ public abstract class RileyLinkCommunicationManager {
|
||||||
|
|
||||||
@Inject MedtronicPumpStatus medtronicPumpStatus;
|
@Inject MedtronicPumpStatus medtronicPumpStatus;
|
||||||
@Inject RileyLinkUtil rileyLinkUtil;
|
@Inject RileyLinkUtil rileyLinkUtil;
|
||||||
@Inject MedtronicUtil medtronicUtil;
|
|
||||||
|
|
||||||
|
|
||||||
private final int SCAN_TIMEOUT = 1500;
|
private final int SCAN_TIMEOUT = 1500;
|
||||||
|
@ -151,7 +148,7 @@ public abstract class RileyLinkCommunicationManager {
|
||||||
// **** FIXME: this wakeup doesn't seem to work well... must revisit
|
// **** FIXME: this wakeup doesn't seem to work well... must revisit
|
||||||
// receiverDeviceAwakeForMinutes = duration_minutes;
|
// receiverDeviceAwakeForMinutes = duration_minutes;
|
||||||
|
|
||||||
medtronicUtil.setPumpDeviceState(PumpDeviceState.WakingUp);
|
medtronicPumpStatus.setPumpDeviceState(PumpDeviceState.WakingUp);
|
||||||
|
|
||||||
if (force)
|
if (force)
|
||||||
nextWakeUpRequired = 0L;
|
nextWakeUpRequired = 0L;
|
||||||
|
|
|
@ -101,7 +101,7 @@ public class RileyLinkStatusActivity extends NoSplashAppCompatActivity {
|
||||||
// FIXME
|
// FIXME
|
||||||
this.connectedDevice.setText("???");
|
this.connectedDevice.setText("???");
|
||||||
// FIXME i18n
|
// FIXME i18n
|
||||||
this.connectionError.setText(rileyLinkServiceData.errorCode.name());
|
this.connectionError.setText(rileyLinkServiceData.rileyLinkError.name());
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -104,9 +104,9 @@ public class RileyLinkStatusGeneralFragment extends DaggerFragment implements Re
|
||||||
|
|
||||||
if (rileyLinkServiceData != null) {
|
if (rileyLinkServiceData != null) {
|
||||||
this.configuredAddress.setText(rileyLinkServiceData.rileylinkAddress);
|
this.configuredAddress.setText(rileyLinkServiceData.rileylinkAddress);
|
||||||
this.connectionError.setText(rileyLinkServiceData.errorCode == null ? //
|
this.connectionError.setText(rileyLinkServiceData.rileyLinkError == null ? //
|
||||||
"-"
|
"-"
|
||||||
: resourceHelper.gs(rileyLinkServiceData.errorCode.getResourceId(targetDevice)));
|
: resourceHelper.gs(rileyLinkServiceData.rileyLinkError.getResourceId(targetDevice)));
|
||||||
|
|
||||||
|
|
||||||
RileyLinkFirmwareVersion firmwareVersion = rileyLinkServiceData.versionCC110;
|
RileyLinkFirmwareVersion firmwareVersion = rileyLinkServiceData.versionCC110;
|
||||||
|
|
|
@ -25,6 +25,7 @@ import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLin
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.data.ServiceResult;
|
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.data.ServiceResult;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.data.ServiceTransport;
|
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.data.ServiceTransport;
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.defs.PumpDeviceState;
|
import info.nightscout.androidaps.plugins.pump.medtronic.defs.PumpDeviceState;
|
||||||
|
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 info.nightscout.androidaps.utils.sharedPreferences.SP;
|
import info.nightscout.androidaps.utils.sharedPreferences.SP;
|
||||||
|
|
||||||
|
@ -41,6 +42,7 @@ public abstract class RileyLinkService extends DaggerService {
|
||||||
@Inject protected RileyLinkUtil rileyLinkUtil;
|
@Inject protected RileyLinkUtil rileyLinkUtil;
|
||||||
@Inject protected MedtronicUtil medtronicUtil; // TODO should be avoided here as it's MDT
|
@Inject protected MedtronicUtil medtronicUtil; // TODO should be avoided here as it's MDT
|
||||||
@Inject protected RileyLinkServiceData rileyLinkServiceData;
|
@Inject protected RileyLinkServiceData rileyLinkServiceData;
|
||||||
|
@Inject protected MedtronicPumpStatus medtronicPumpStatus;
|
||||||
|
|
||||||
@NotNull protected RileyLinkBLE rileyLinkBLE; // android-bluetooth management, must be set in initRileyLinkServiceData
|
@NotNull protected RileyLinkBLE rileyLinkBLE; // android-bluetooth management, must be set in initRileyLinkServiceData
|
||||||
protected BluetoothAdapter bluetoothAdapter;
|
protected BluetoothAdapter bluetoothAdapter;
|
||||||
|
@ -204,7 +206,7 @@ public abstract class RileyLinkService extends DaggerService {
|
||||||
public void doTuneUpDevice() {
|
public void doTuneUpDevice() {
|
||||||
|
|
||||||
rileyLinkServiceData.setRileyLinkServiceState(RileyLinkServiceState.TuneUpDevice);
|
rileyLinkServiceData.setRileyLinkServiceState(RileyLinkServiceState.TuneUpDevice);
|
||||||
medtronicUtil.setPumpDeviceState(PumpDeviceState.Sleeping);
|
medtronicPumpStatus.setPumpDeviceState(PumpDeviceState.Sleeping);
|
||||||
|
|
||||||
double lastGoodFrequency = 0.0d;
|
double lastGoodFrequency = 0.0d;
|
||||||
|
|
||||||
|
@ -266,7 +268,7 @@ public abstract class RileyLinkService extends DaggerService {
|
||||||
|
|
||||||
public RileyLinkError getError() {
|
public RileyLinkError getError() {
|
||||||
if (rileyLinkServiceData != null)
|
if (rileyLinkServiceData != null)
|
||||||
return rileyLinkServiceData.errorCode;
|
return rileyLinkServiceData.rileyLinkError;
|
||||||
else
|
else
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,7 @@ public class RileyLinkServiceData {
|
||||||
@Inject RxBusWrapper rxBus;
|
@Inject RxBusWrapper rxBus;
|
||||||
|
|
||||||
boolean tuneUpDone = false;
|
boolean tuneUpDone = false;
|
||||||
public RileyLinkError errorCode;
|
public RileyLinkError rileyLinkError;
|
||||||
public RileyLinkServiceState rileyLinkServiceState = RileyLinkServiceState.NotStarted;
|
public RileyLinkServiceState rileyLinkServiceState = RileyLinkServiceState.NotStarted;
|
||||||
public String rileylinkAddress;
|
public String rileylinkAddress;
|
||||||
long lastTuneUpTime = 0L;
|
long lastTuneUpTime = 0L;
|
||||||
|
@ -70,7 +70,7 @@ public class RileyLinkServiceData {
|
||||||
if (set) {
|
if (set) {
|
||||||
|
|
||||||
rileyLinkServiceState = newState;
|
rileyLinkServiceState = newState;
|
||||||
this.errorCode = errorCode;
|
this.rileyLinkError = errorCode;
|
||||||
|
|
||||||
aapsLogger.info(LTag.PUMP, "RileyLink State Changed: {} {}", newState, errorCode == null ? "" : " - Error State: " + errorCode.name());
|
aapsLogger.info(LTag.PUMP, "RileyLink State Changed: {} {}", newState, errorCode == null ? "" : " - Error State: " + errorCode.name());
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,6 @@ import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
import info.nightscout.androidaps.logging.LTag
|
import info.nightscout.androidaps.logging.LTag
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||||
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.RileyLinkServiceState
|
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.defs.RileyLinkTargetDevice
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.dialog.RileyLinkStatusActivity
|
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.dialog.RileyLinkStatusActivity
|
||||||
|
@ -188,16 +187,11 @@ class MedtronicFragment : DaggerFragment() {
|
||||||
}
|
}
|
||||||
medtronic_rl_status.setTextColor(if (rileyLinkError != null) Color.RED else Color.WHITE)
|
medtronic_rl_status.setTextColor(if (rileyLinkError != null) Color.RED else Color.WHITE)
|
||||||
|
|
||||||
medtronicPumpStatus.rileyLinkError = checkStatusSet(medtronicPumpStatus.rileyLinkError, medtronicPumpPlugin.rileyLinkService?.error) as RileyLinkError?
|
|
||||||
|
|
||||||
medtronic_errors.text =
|
medtronic_errors.text =
|
||||||
medtronicPumpStatus.rileyLinkError?.let {
|
rileyLinkServiceData.rileyLinkError?.let {
|
||||||
resourceHelper.gs(it.getResourceId(RileyLinkTargetDevice.MedtronicPump))
|
resourceHelper.gs(it.getResourceId(RileyLinkTargetDevice.MedtronicPump))
|
||||||
} ?: "-"
|
} ?: "-"
|
||||||
|
|
||||||
medtronicPumpStatus.pumpDeviceState = checkStatusSet(medtronicPumpStatus.pumpDeviceState,
|
|
||||||
medtronicUtil.pumpDeviceState) as PumpDeviceState?
|
|
||||||
|
|
||||||
when (medtronicPumpStatus.pumpDeviceState) {
|
when (medtronicPumpStatus.pumpDeviceState) {
|
||||||
null,
|
null,
|
||||||
PumpDeviceState.Sleeping -> medtronic_pump_status.text = "{fa-bed} " // + pumpStatus.pumpDeviceState.name());
|
PumpDeviceState.Sleeping -> medtronic_pump_status.text = "{fa-bed} " // + pumpStatus.pumpDeviceState.name());
|
||||||
|
@ -239,17 +233,6 @@ class MedtronicFragment : DaggerFragment() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun checkStatusSet(object1: Any?, object2: Any?): Any? {
|
|
||||||
return if (object1 == null) {
|
|
||||||
object2
|
|
||||||
} else {
|
|
||||||
if (object1 != object2) {
|
|
||||||
object2
|
|
||||||
} else
|
|
||||||
object1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun displayNotConfiguredDialog() {
|
private fun displayNotConfiguredDialog() {
|
||||||
context?.let {
|
context?.let {
|
||||||
OKDialog.show(it, resourceHelper.gs(R.string.combo_warning),
|
OKDialog.show(it, resourceHelper.gs(R.string.combo_warning),
|
||||||
|
|
|
@ -110,10 +110,10 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
|
||||||
*/
|
*/
|
||||||
public boolean isDeviceReachable(boolean canPreventTuneUp) {
|
public boolean isDeviceReachable(boolean canPreventTuneUp) {
|
||||||
|
|
||||||
PumpDeviceState state = medtronicUtil.getPumpDeviceState();
|
PumpDeviceState state = medtronicPumpStatus.getPumpDeviceState();
|
||||||
|
|
||||||
if (state != PumpDeviceState.PumpUnreachable)
|
if (state != PumpDeviceState.PumpUnreachable)
|
||||||
medtronicUtil.setPumpDeviceState(PumpDeviceState.WakingUp);
|
medtronicPumpStatus.setPumpDeviceState(PumpDeviceState.WakingUp);
|
||||||
|
|
||||||
for (int retry = 0; retry < 5; retry++) {
|
for (int retry = 0; retry < 5; retry++) {
|
||||||
|
|
||||||
|
@ -129,7 +129,7 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
|
||||||
}
|
}
|
||||||
|
|
||||||
if (state != PumpDeviceState.PumpUnreachable)
|
if (state != PumpDeviceState.PumpUnreachable)
|
||||||
medtronicUtil.setPumpDeviceState(PumpDeviceState.PumpUnreachable);
|
medtronicPumpStatus.setPumpDeviceState(PumpDeviceState.PumpUnreachable);
|
||||||
|
|
||||||
if (!canPreventTuneUp) {
|
if (!canPreventTuneUp) {
|
||||||
|
|
||||||
|
@ -146,7 +146,7 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
|
||||||
|
|
||||||
private boolean connectToDevice() {
|
private boolean connectToDevice() {
|
||||||
|
|
||||||
PumpDeviceState state = medtronicUtil.getPumpDeviceState();
|
PumpDeviceState state = medtronicPumpStatus.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,
|
||||||
|
@ -187,9 +187,9 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
|
||||||
|
|
||||||
if (valid) {
|
if (valid) {
|
||||||
if (state == PumpDeviceState.PumpUnreachable)
|
if (state == PumpDeviceState.PumpUnreachable)
|
||||||
medtronicUtil.setPumpDeviceState(PumpDeviceState.WakingUp);
|
medtronicPumpStatus.setPumpDeviceState(PumpDeviceState.WakingUp);
|
||||||
else
|
else
|
||||||
medtronicUtil.setPumpDeviceState(PumpDeviceState.Sleeping);
|
medtronicPumpStatus.setPumpDeviceState(PumpDeviceState.Sleeping);
|
||||||
|
|
||||||
rememberLastGoodDeviceCommunicationTime();
|
rememberLastGoodDeviceCommunicationTime();
|
||||||
|
|
||||||
|
@ -197,7 +197,7 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if (state != PumpDeviceState.PumpUnreachable)
|
if (state != PumpDeviceState.PumpUnreachable)
|
||||||
medtronicUtil.setPumpDeviceState(PumpDeviceState.PumpUnreachable);
|
medtronicPumpStatus.setPumpDeviceState(PumpDeviceState.PumpUnreachable);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -312,7 +312,7 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
|
||||||
|
|
||||||
aapsLogger.debug(LTag.PUMPBTCOMM, "Current command: " + medtronicUtil.getCurrentCommand());
|
aapsLogger.debug(LTag.PUMPBTCOMM, "Current command: " + medtronicUtil.getCurrentCommand());
|
||||||
|
|
||||||
medtronicUtil.setPumpDeviceState(PumpDeviceState.Active);
|
medtronicPumpStatus.setPumpDeviceState(PumpDeviceState.Active);
|
||||||
boolean doneWithError = false;
|
boolean doneWithError = false;
|
||||||
|
|
||||||
for (int pageNumber = 0; pageNumber < 5; pageNumber++) {
|
for (int pageNumber = 0; pageNumber < 5; pageNumber++) {
|
||||||
|
@ -344,7 +344,7 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
|
||||||
}
|
}
|
||||||
|
|
||||||
if (failed) {
|
if (failed) {
|
||||||
medtronicUtil.setPumpDeviceState(PumpDeviceState.Sleeping);
|
medtronicPumpStatus.setPumpDeviceState(PumpDeviceState.Sleeping);
|
||||||
return pumpTotalResult;
|
return pumpTotalResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -435,7 +435,7 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
|
||||||
}
|
}
|
||||||
|
|
||||||
if (doneWithError) {
|
if (doneWithError) {
|
||||||
medtronicUtil.setPumpDeviceState(PumpDeviceState.Sleeping);
|
medtronicPumpStatus.setPumpDeviceState(PumpDeviceState.Sleeping);
|
||||||
return pumpTotalResult;
|
return pumpTotalResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -450,13 +450,13 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
|
||||||
aapsLogger.debug(LTag.PUMPBTCOMM, "getPumpHistory: Search status: Search finished: {}", pumpTotalResult.isSearchFinished());
|
aapsLogger.debug(LTag.PUMPBTCOMM, "getPumpHistory: Search status: Search finished: {}", pumpTotalResult.isSearchFinished());
|
||||||
|
|
||||||
if (pumpTotalResult.isSearchFinished()) {
|
if (pumpTotalResult.isSearchFinished()) {
|
||||||
medtronicUtil.setPumpDeviceState(PumpDeviceState.Sleeping);
|
medtronicPumpStatus.setPumpDeviceState(PumpDeviceState.Sleeping);
|
||||||
|
|
||||||
return pumpTotalResult;
|
return pumpTotalResult;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
medtronicUtil.setPumpDeviceState(PumpDeviceState.Sleeping);
|
medtronicPumpStatus.setPumpDeviceState(PumpDeviceState.Sleeping);
|
||||||
|
|
||||||
return pumpTotalResult;
|
return pumpTotalResult;
|
||||||
|
|
||||||
|
@ -520,7 +520,7 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
|
||||||
if (doWakeUpBeforeCommand)
|
if (doWakeUpBeforeCommand)
|
||||||
wakeUp(receiverDeviceAwakeForMinutes, false);
|
wakeUp(receiverDeviceAwakeForMinutes, false);
|
||||||
|
|
||||||
medtronicUtil.setPumpDeviceState(PumpDeviceState.Active);
|
medtronicPumpStatus.setPumpDeviceState(PumpDeviceState.Active);
|
||||||
|
|
||||||
// create message
|
// create message
|
||||||
PumpMessage msg;
|
PumpMessage msg;
|
||||||
|
@ -533,7 +533,7 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
|
||||||
// send and wait for response
|
// send and wait for response
|
||||||
PumpMessage response = sendAndListen(msg, timeoutMs);
|
PumpMessage response = sendAndListen(msg, timeoutMs);
|
||||||
|
|
||||||
medtronicUtil.setPumpDeviceState(PumpDeviceState.Sleeping);
|
medtronicPumpStatus.setPumpDeviceState(PumpDeviceState.Sleeping);
|
||||||
|
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
@ -655,7 +655,7 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
|
||||||
|
|
||||||
medtronicUtil.setCurrentCommand(commandType);
|
medtronicUtil.setCurrentCommand(commandType);
|
||||||
|
|
||||||
medtronicUtil.setPumpDeviceState(PumpDeviceState.Active);
|
medtronicPumpStatus.setPumpDeviceState(PumpDeviceState.Active);
|
||||||
|
|
||||||
for (int retries = 0; retries <= MAX_COMMAND_TRIES; retries++) {
|
for (int retries = 0; retries <= MAX_COMMAND_TRIES; retries++) {
|
||||||
|
|
||||||
|
@ -712,7 +712,7 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
|
||||||
aapsLogger.debug(LTag.PUMPBTCOMM, "Converted response for {} is {}.", commandType.name(), basalProfile);
|
aapsLogger.debug(LTag.PUMPBTCOMM, "Converted response for {} is {}.", commandType.name(), basalProfile);
|
||||||
|
|
||||||
medtronicUtil.setCurrentCommand(null);
|
medtronicUtil.setCurrentCommand(null);
|
||||||
medtronicUtil.setPumpDeviceState(PumpDeviceState.Sleeping);
|
medtronicPumpStatus.setPumpDeviceState(PumpDeviceState.Sleeping);
|
||||||
|
|
||||||
return basalProfile;
|
return basalProfile;
|
||||||
}
|
}
|
||||||
|
@ -724,7 +724,7 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
|
||||||
|
|
||||||
aapsLogger.warn(LTag.PUMPBTCOMM, "Error reading profile in max retries.");
|
aapsLogger.warn(LTag.PUMPBTCOMM, "Error reading profile in max retries.");
|
||||||
medtronicUtil.setCurrentCommand(null);
|
medtronicUtil.setCurrentCommand(null);
|
||||||
medtronicUtil.setPumpDeviceState(PumpDeviceState.Sleeping);
|
medtronicPumpStatus.setPumpDeviceState(PumpDeviceState.Sleeping);
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
|
|
|
@ -21,14 +21,12 @@ import javax.inject.Inject;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.activities.NoSplashAppCompatActivity;
|
import info.nightscout.androidaps.activities.NoSplashAppCompatActivity;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.defs.PumpHistoryEntryGroup;
|
import info.nightscout.androidaps.plugins.pump.common.defs.PumpHistoryEntryGroup;
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.MedtronicPumpPlugin;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.comm.history.pump.PumpHistoryEntry;
|
import info.nightscout.androidaps.plugins.pump.medtronic.comm.history.pump.PumpHistoryEntry;
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.data.MedtronicHistoryData;
|
import info.nightscout.androidaps.plugins.pump.medtronic.data.MedtronicHistoryData;
|
||||||
|
|
||||||
|
|
||||||
public class MedtronicHistoryActivity extends NoSplashAppCompatActivity {
|
public class MedtronicHistoryActivity extends NoSplashAppCompatActivity {
|
||||||
|
|
||||||
@Inject MedtronicPumpPlugin medtronicPumpPlugin;
|
|
||||||
@Inject MedtronicHistoryData medtronicHistoryData;
|
@Inject MedtronicHistoryData medtronicHistoryData;
|
||||||
|
|
||||||
Spinner historyTypeSpinner;
|
Spinner historyTypeSpinner;
|
||||||
|
|
|
@ -11,13 +11,17 @@ import java.util.Map;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.data.PumpStatus;
|
import info.nightscout.androidaps.plugins.pump.common.data.PumpStatus;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.defs.PumpType;
|
import info.nightscout.androidaps.plugins.pump.common.defs.PumpType;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkError;
|
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkUtil;
|
||||||
|
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.data.RLHistoryItem;
|
||||||
|
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkTargetDevice;
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.defs.BasalProfileStatus;
|
import info.nightscout.androidaps.plugins.pump.medtronic.defs.BasalProfileStatus;
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.defs.BatteryType;
|
import info.nightscout.androidaps.plugins.pump.medtronic.defs.BatteryType;
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.defs.MedtronicDeviceType;
|
import info.nightscout.androidaps.plugins.pump.medtronic.defs.MedtronicDeviceType;
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.defs.PumpDeviceState;
|
import info.nightscout.androidaps.plugins.pump.medtronic.defs.PumpDeviceState;
|
||||||
|
import info.nightscout.androidaps.plugins.pump.medtronic.events.EventMedtronicDeviceStatusChange;
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicConst;
|
import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicConst;
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper;
|
import info.nightscout.androidaps.utils.resources.ResourceHelper;
|
||||||
import info.nightscout.androidaps.utils.sharedPreferences.SP;
|
import info.nightscout.androidaps.utils.sharedPreferences.SP;
|
||||||
|
@ -31,6 +35,8 @@ public class MedtronicPumpStatus extends PumpStatus {
|
||||||
|
|
||||||
private final ResourceHelper resourceHelper;
|
private final ResourceHelper resourceHelper;
|
||||||
private final SP sp;
|
private final SP sp;
|
||||||
|
private final RileyLinkUtil rileyLinkUtil;
|
||||||
|
private final RxBusWrapper rxBus;
|
||||||
|
|
||||||
public String errorDescription = null;
|
public String errorDescription = null;
|
||||||
public String serialNumber;
|
public String serialNumber;
|
||||||
|
@ -39,8 +45,7 @@ public class MedtronicPumpStatus extends PumpStatus {
|
||||||
public Double maxBasal;
|
public Double maxBasal;
|
||||||
|
|
||||||
// statuses
|
// statuses
|
||||||
public RileyLinkError rileyLinkError;
|
private PumpDeviceState pumpDeviceState = PumpDeviceState.NeverContacted;
|
||||||
public PumpDeviceState pumpDeviceState = PumpDeviceState.NeverContacted;
|
|
||||||
public MedtronicDeviceType medtronicDeviceType = null;
|
public MedtronicDeviceType medtronicDeviceType = null;
|
||||||
public Date tempBasalStart;
|
public Date tempBasalStart;
|
||||||
public Double tempBasalAmount = 0.0d;
|
public Double tempBasalAmount = 0.0d;
|
||||||
|
@ -57,11 +62,15 @@ public class MedtronicPumpStatus extends PumpStatus {
|
||||||
@Inject
|
@Inject
|
||||||
public MedtronicPumpStatus(
|
public MedtronicPumpStatus(
|
||||||
ResourceHelper resourceHelper,
|
ResourceHelper resourceHelper,
|
||||||
SP sp
|
SP sp,
|
||||||
|
RxBusWrapper rxBus,
|
||||||
|
RileyLinkUtil rileyLinkUtil
|
||||||
) {
|
) {
|
||||||
super();
|
super();
|
||||||
this.resourceHelper = resourceHelper;
|
this.resourceHelper = resourceHelper;
|
||||||
this.sp = sp;
|
this.sp = sp;
|
||||||
|
this.rxBus = rxBus;
|
||||||
|
this.rileyLinkUtil = rileyLinkUtil;
|
||||||
initSettings();
|
initSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -155,4 +164,17 @@ public class MedtronicPumpStatus extends PumpStatus {
|
||||||
public String getErrorInfo() {
|
public String getErrorInfo() {
|
||||||
return (errorDescription == null) ? "-" : errorDescription;
|
return (errorDescription == null) ? "-" : errorDescription;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public PumpDeviceState getPumpDeviceState() {
|
||||||
|
return pumpDeviceState;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void setPumpDeviceState(PumpDeviceState pumpDeviceState) {
|
||||||
|
this.pumpDeviceState = pumpDeviceState;
|
||||||
|
|
||||||
|
rileyLinkUtil.getRileyLinkHistory().add(new RLHistoryItem(pumpDeviceState, RileyLinkTargetDevice.MedtronicPump));
|
||||||
|
|
||||||
|
rxBus.send(new EventMedtronicDeviceStatusChange(pumpDeviceState));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -162,7 +162,7 @@ public class RileyLinkMedtronicService extends RileyLinkService {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
medtronicUtil.setPumpDeviceState(PumpDeviceState.InvalidConfiguration);
|
medtronicPumpStatus.setPumpDeviceState(PumpDeviceState.InvalidConfiguration);
|
||||||
|
|
||||||
// LOG.info("setPumpIDString: saved pumpID " + idString);
|
// LOG.info("setPumpIDString: saved pumpID " + idString);
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,6 @@ import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotifi
|
||||||
import info.nightscout.androidaps.plugins.general.overview.notifications.Notification;
|
import info.nightscout.androidaps.plugins.general.overview.notifications.Notification;
|
||||||
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.data.RLHistoryItem;
|
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.data.RLHistoryItem;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkTargetDevice;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.RileyLinkServiceData;
|
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.RileyLinkServiceData;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.utils.ByteUtil;
|
import info.nightscout.androidaps.plugins.pump.common.utils.ByteUtil;
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.data.dto.ClockDTO;
|
import info.nightscout.androidaps.plugins.pump.medtronic.data.dto.ClockDTO;
|
||||||
|
@ -30,7 +29,7 @@ import info.nightscout.androidaps.plugins.pump.medtronic.data.dto.PumpSettingDTO
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.defs.MedtronicCommandType;
|
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.MedtronicDeviceType;
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.defs.MedtronicNotificationType;
|
import info.nightscout.androidaps.plugins.pump.medtronic.defs.MedtronicNotificationType;
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.defs.PumpDeviceState;
|
import info.nightscout.androidaps.plugins.pump.medtronic.driver.MedtronicPumpStatus;
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.events.EventMedtronicDeviceStatusChange;
|
import info.nightscout.androidaps.plugins.pump.medtronic.events.EventMedtronicDeviceStatusChange;
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper;
|
import info.nightscout.androidaps.utils.resources.ResourceHelper;
|
||||||
|
|
||||||
|
@ -43,7 +42,6 @@ public class MedtronicUtil {
|
||||||
|
|
||||||
private int ENVELOPE_SIZE = 4; // 0xA7 S1 S2 S3 CMD PARAM_COUNT [PARAMS]
|
private int ENVELOPE_SIZE = 4; // 0xA7 S1 S2 S3 CMD PARAM_COUNT [PARAMS]
|
||||||
private static boolean lowLevelDebug = true;
|
private static boolean lowLevelDebug = true;
|
||||||
private PumpDeviceState pumpDeviceState;
|
|
||||||
private MedtronicDeviceType medtronicPumpModel;
|
private MedtronicDeviceType medtronicPumpModel;
|
||||||
private MedtronicCommandType currentCommand;
|
private MedtronicCommandType currentCommand;
|
||||||
private Map<String, PumpSettingDTO> settings;
|
private Map<String, PumpSettingDTO> settings;
|
||||||
|
@ -51,24 +49,23 @@ public class MedtronicUtil {
|
||||||
private int doneBit = 1 << 7;
|
private int doneBit = 1 << 7;
|
||||||
private ClockDTO pumpTime;
|
private ClockDTO pumpTime;
|
||||||
public Gson gsonInstance = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create();
|
public Gson gsonInstance = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create();
|
||||||
public Gson gsonInstanceCore = new GsonBuilder().create();
|
|
||||||
|
|
||||||
private final AAPSLogger aapsLogger;
|
private final AAPSLogger aapsLogger;
|
||||||
private final RxBusWrapper rxBus;
|
private final RxBusWrapper rxBus;
|
||||||
private final RileyLinkUtil rileyLinkUtil;
|
private final RileyLinkUtil rileyLinkUtil;
|
||||||
private final RileyLinkServiceData rileyLinkServiceData;
|
private final MedtronicPumpStatus medtronicPumpStatus;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public MedtronicUtil(
|
public MedtronicUtil(
|
||||||
AAPSLogger aapsLogger,
|
AAPSLogger aapsLogger,
|
||||||
RxBusWrapper rxBus,
|
RxBusWrapper rxBus,
|
||||||
RileyLinkUtil rileyLinkUtil,
|
RileyLinkUtil rileyLinkUtil,
|
||||||
RileyLinkServiceData rileyLinkServiceData
|
MedtronicPumpStatus medtronicPumpStatus
|
||||||
) {
|
) {
|
||||||
this.aapsLogger = aapsLogger;
|
this.aapsLogger = aapsLogger;
|
||||||
this.rxBus = rxBus;
|
this.rxBus = rxBus;
|
||||||
this.rileyLinkUtil = rileyLinkUtil;
|
this.rileyLinkUtil = rileyLinkUtil;
|
||||||
this.rileyLinkServiceData = rileyLinkServiceData;
|
this.medtronicPumpStatus = medtronicPumpStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
public LocalTime getTimeFrom30MinInterval(int interval) {
|
public LocalTime getTimeFrom30MinInterval(int interval) {
|
||||||
|
@ -393,30 +390,14 @@ public class MedtronicUtil {
|
||||||
return lowLevelDebug;
|
return lowLevelDebug;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PumpDeviceState getPumpDeviceState() {
|
|
||||||
return pumpDeviceState;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void setPumpDeviceState(PumpDeviceState pumpDeviceState) {
|
|
||||||
this.pumpDeviceState = pumpDeviceState;
|
|
||||||
|
|
||||||
rileyLinkUtil.getRileyLinkHistory().add(new RLHistoryItem(pumpDeviceState, RileyLinkTargetDevice.MedtronicPump));
|
|
||||||
|
|
||||||
rxBus.send(new EventMedtronicDeviceStatusChange(pumpDeviceState));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public boolean isModelSet() {
|
public boolean isModelSet() {
|
||||||
return medtronicPumpModel != null;
|
return medtronicPumpModel != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public MedtronicDeviceType getMedtronicPumpModel() {
|
public MedtronicDeviceType getMedtronicPumpModel() {
|
||||||
return medtronicPumpModel;
|
return medtronicPumpModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void setMedtronicPumpModel(MedtronicDeviceType medtronicPumpModel) {
|
public void setMedtronicPumpModel(MedtronicDeviceType medtronicPumpModel) {
|
||||||
this.medtronicPumpModel = medtronicPumpModel;
|
this.medtronicPumpModel = medtronicPumpModel;
|
||||||
}
|
}
|
||||||
|
@ -445,7 +426,7 @@ public class MedtronicUtil {
|
||||||
setCurrentCommand(currentCommand);
|
setCurrentCommand(currentCommand);
|
||||||
}
|
}
|
||||||
|
|
||||||
rxBus.send(new EventMedtronicDeviceStatusChange(pumpDeviceState));
|
rxBus.send(new EventMedtronicDeviceStatusChange(medtronicPumpStatus.getPumpDeviceState()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue