virtual pump lifecycle
This commit is contained in:
parent
b0f8ab9922
commit
b7950322c8
|
@ -2,6 +2,8 @@ package info.nightscout.androidaps.plugins.PumpVirtual;
|
|||
|
||||
import android.os.SystemClock;
|
||||
|
||||
import com.squareup.otto.Subscribe;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
import org.slf4j.Logger;
|
||||
|
@ -17,6 +19,7 @@ import info.nightscout.androidaps.data.PumpEnactResult;
|
|||
import info.nightscout.androidaps.db.ExtendedBolus;
|
||||
import info.nightscout.androidaps.db.Source;
|
||||
import info.nightscout.androidaps.db.TemporaryBasal;
|
||||
import info.nightscout.androidaps.events.EventPreferenceChange;
|
||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||
import info.nightscout.androidaps.interfaces.PluginDescription;
|
||||
import info.nightscout.androidaps.interfaces.PluginType;
|
||||
|
@ -115,6 +118,23 @@ public class VirtualPumpPlugin extends PluginBase implements PumpInterface {
|
|||
pumpDescription.is30minBasalRatesCapable = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStart() {
|
||||
super.onStart();
|
||||
refreshConfiguration();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStop() {
|
||||
MainApp.bus().unregister(this);
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onStatusEvent(final EventPreferenceChange s) {
|
||||
if (s.isChanged(R.string.key_virtualpump_type))
|
||||
refreshConfiguration();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFakingTempsByExtendedBoluses() {
|
||||
return (Config.NSCLIENT) && fromNSAreCommingFakedExtendedBoluses;
|
||||
|
@ -419,24 +439,24 @@ public class VirtualPumpPlugin extends PluginBase implements PumpInterface {
|
|||
return "Virtual Pump";
|
||||
}
|
||||
|
||||
public PumpType getPumpType()
|
||||
{
|
||||
public PumpType getPumpType() {
|
||||
return pumpType;
|
||||
}
|
||||
|
||||
|
||||
public void refreshConfiguration()
|
||||
{
|
||||
public void refreshConfiguration() {
|
||||
String pumptype = SP.getString(R.string.key_virtualpump_type, "Generic AAPS");
|
||||
|
||||
PumpType pumpTypeNew = PumpType.getByDescription(pumptype);
|
||||
|
||||
log.debug("Pump in configuration: {}, PumpType object: {}", pumptype, pumpTypeNew);
|
||||
if (L.isEnabled(L.PUMP))
|
||||
log.debug("Pump in configuration: {}, PumpType object: {}", pumptype, pumpTypeNew);
|
||||
|
||||
if (pumpType == pumpTypeNew)
|
||||
return;
|
||||
|
||||
log.debug("New pump configuration found ({}), changing from previous ({})", pumpTypeNew, pumpType);
|
||||
if (L.isEnabled(L.PUMP))
|
||||
log.debug("New pump configuration found ({}), changing from previous ({})", pumpTypeNew, pumpType);
|
||||
|
||||
// reset
|
||||
pumpDescription.resetSettings();
|
||||
|
|
|
@ -45,11 +45,11 @@ public class VirtualPumpPluginUTest {
|
|||
|
||||
|
||||
@Test
|
||||
public void getPumpType() throws Exception {
|
||||
public void getPumpType() {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void refreshConfiguration() throws Exception {
|
||||
public void refreshConfiguration() {
|
||||
|
||||
when(SP.getString(R.string.key_virtualpump_type, "Generic AAPS")).thenReturn("Accu-Chek Combo");
|
||||
|
||||
|
@ -60,7 +60,7 @@ public class VirtualPumpPluginUTest {
|
|||
|
||||
|
||||
@Test
|
||||
public void refreshConfigurationTwice() throws Exception {
|
||||
public void refreshConfigurationTwice() {
|
||||
|
||||
when(SP.getString(R.string.key_virtualpump_type, "Generic AAPS")).thenReturn("Accu-Chek Combo");
|
||||
|
||||
|
|
Loading…
Reference in a new issue