DanaR pumps lifecycle

This commit is contained in:
Milos Kozak 2018-03-31 10:36:57 +02:00
parent a30334f5d5
commit 1c6c5f85f7
4 changed files with 54 additions and 16 deletions

View file

@ -64,7 +64,7 @@ public abstract class AbstractDanaRPlugin extends PluginBase implements PumpInte
@Override
public void onStateChange(PluginType type, State oldState, State newState) {
// if pump profile was enabled need to switch to another too
if (type == PluginType.PUMP && newState == State.DISABLED && isProfileInterfaceEnabled) {
if (type == PluginType.PUMP && newState == State.ENABLED && newState == State.DISABLED && isProfileInterfaceEnabled) {
setPluginEnabled(PluginType.PROFILE, false);
NSProfilePlugin.getPlugin().setPluginEnabled(PluginType.PROFILE, true);
NSProfilePlugin.getPlugin().setFragmentVisible(PluginType.PROFILE, true);

View file

@ -46,11 +46,6 @@ public class DanaRPlugin extends AbstractDanaRPlugin {
log = LoggerFactory.getLogger(DanaRPlugin.class);
useExtendedBoluses = SP.getBoolean("danar_useextended", false);
Context context = MainApp.instance().getApplicationContext();
Intent intent = new Intent(context, DanaRExecutionService.class);
context.bindService(intent, mConnection, Context.BIND_AUTO_CREATE);
MainApp.bus().register(this);
pumpDescription.isBolusCapable = true;
pumpDescription.bolusStep = 0.05d;
@ -78,6 +73,22 @@ public class DanaRPlugin extends AbstractDanaRPlugin {
pumpDescription.storesCarbInfo = true;
}
@Override
protected void onStart() {
Context context = MainApp.instance().getApplicationContext();
Intent intent = new Intent(context, DanaRExecutionService.class);
context.bindService(intent, mConnection, Context.BIND_AUTO_CREATE);
MainApp.bus().register(this);
}
@Override
protected void onStop() {
Context context = MainApp.instance().getApplicationContext();
context.unbindService(mConnection);
MainApp.bus().unregister(this);
}
private ServiceConnection mConnection = new ServiceConnection() {
public void onServiceDisconnected(ComponentName name) {

View file

@ -26,6 +26,8 @@ import info.nightscout.androidaps.interfaces.PluginType;
import info.nightscout.androidaps.interfaces.PumpDescription;
import info.nightscout.androidaps.plugins.PumpDanaR.AbstractDanaRPlugin;
import info.nightscout.androidaps.plugins.PumpDanaRKorean.services.DanaRKoreanExecutionService;
import info.nightscout.androidaps.plugins.PumpDanaRS.events.EventDanaRSDeviceChange;
import info.nightscout.androidaps.plugins.PumpDanaRS.services.DanaRSService;
import info.nightscout.utils.Round;
import info.nightscout.utils.SP;
@ -47,11 +49,6 @@ public class DanaRKoreanPlugin extends AbstractDanaRPlugin {
log = LoggerFactory.getLogger(DanaRKoreanPlugin.class);
useExtendedBoluses = SP.getBoolean("danar_useextended", false);
Context context = MainApp.instance().getApplicationContext();
Intent intent = new Intent(context, DanaRKoreanExecutionService.class);
context.bindService(intent, mConnection, Context.BIND_AUTO_CREATE);
MainApp.bus().register(this);
pumpDescription.isBolusCapable = true;
pumpDescription.bolusStep = 0.1d;
@ -79,6 +76,22 @@ public class DanaRKoreanPlugin extends AbstractDanaRPlugin {
pumpDescription.storesCarbInfo = true;
}
@Override
protected void onStart() {
Context context = MainApp.instance().getApplicationContext();
Intent intent = new Intent(context, DanaRKoreanExecutionService.class);
context.bindService(intent, mConnection, Context.BIND_AUTO_CREATE);
MainApp.bus().register(this);
}
@Override
protected void onStop() {
Context context = MainApp.instance().getApplicationContext();
context.unbindService(mConnection);
MainApp.bus().unregister(this);
}
private ServiceConnection mConnection = new ServiceConnection() {
public void onServiceDisconnected(ComponentName name) {

View file

@ -23,6 +23,8 @@ import info.nightscout.androidaps.interfaces.Constraint;
import info.nightscout.androidaps.interfaces.PumpDescription;
import info.nightscout.androidaps.plugins.ConfigBuilder.DetailedBolusInfoStorage;
import info.nightscout.androidaps.plugins.PumpDanaR.AbstractDanaRPlugin;
import info.nightscout.androidaps.plugins.PumpDanaRS.events.EventDanaRSDeviceChange;
import info.nightscout.androidaps.plugins.PumpDanaRS.services.DanaRSService;
import info.nightscout.androidaps.plugins.PumpDanaRv2.services.DanaRv2ExecutionService;
import info.nightscout.utils.Round;
import info.nightscout.utils.SP;
@ -44,11 +46,6 @@ public class DanaRv2Plugin extends AbstractDanaRPlugin {
log = LoggerFactory.getLogger(DanaRv2Plugin.class);
useExtendedBoluses = false;
Context context = MainApp.instance().getApplicationContext();
Intent intent = new Intent(context, DanaRv2ExecutionService.class);
context.bindService(intent, mConnection, Context.BIND_AUTO_CREATE);
MainApp.bus().register(this);
pumpDescription.isBolusCapable = true;
pumpDescription.bolusStep = 0.05d;
@ -78,6 +75,23 @@ public class DanaRv2Plugin extends AbstractDanaRPlugin {
pumpDescription.storesCarbInfo = true;
}
@Override
protected void onStart() {
Context context = MainApp.instance().getApplicationContext();
Intent intent = new Intent(context, DanaRv2ExecutionService.class);
context.bindService(intent, mConnection, Context.BIND_AUTO_CREATE);
MainApp.bus().register(this);
}
@Override
protected void onStop() {
Context context = MainApp.instance().getApplicationContext();
context.unbindService(mConnection);
MainApp.bus().unregister(this);
}
private ServiceConnection mConnection = new ServiceConnection() {
public void onServiceDisconnected(ComponentName name) {