Events to RxBus
This commit is contained in:
parent
14dd29befd
commit
ada6e38f5f
66 changed files with 984 additions and 1026 deletions
|
@ -37,8 +37,10 @@ import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.data.Profile;
|
import info.nightscout.androidaps.data.Profile;
|
||||||
import info.nightscout.androidaps.db.TDD;
|
import info.nightscout.androidaps.db.TDD;
|
||||||
|
import info.nightscout.androidaps.events.EventExtendedBolusChange;
|
||||||
import info.nightscout.androidaps.events.EventPumpStatusChanged;
|
import info.nightscout.androidaps.events.EventPumpStatusChanged;
|
||||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||||
|
import info.nightscout.androidaps.plugins.bus.RxBus;
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
|
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctions;
|
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctions;
|
||||||
import info.nightscout.androidaps.plugins.pump.danaR.DanaRPlugin;
|
import info.nightscout.androidaps.plugins.pump.danaR.DanaRPlugin;
|
||||||
|
@ -49,11 +51,15 @@ import info.nightscout.androidaps.plugins.pump.danaRv2.DanaRv2Plugin;
|
||||||
import info.nightscout.androidaps.plugins.pump.insight.LocalInsightPlugin;
|
import info.nightscout.androidaps.plugins.pump.insight.LocalInsightPlugin;
|
||||||
import info.nightscout.androidaps.queue.Callback;
|
import info.nightscout.androidaps.queue.Callback;
|
||||||
import info.nightscout.androidaps.utils.DecimalFormatter;
|
import info.nightscout.androidaps.utils.DecimalFormatter;
|
||||||
|
import info.nightscout.androidaps.utils.FabricPrivacy;
|
||||||
import info.nightscout.androidaps.utils.SP;
|
import info.nightscout.androidaps.utils.SP;
|
||||||
import info.nightscout.androidaps.utils.SafeParse;
|
import info.nightscout.androidaps.utils.SafeParse;
|
||||||
|
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||||
|
import io.reactivex.disposables.CompositeDisposable;
|
||||||
|
|
||||||
public class TDDStatsActivity extends NoSplashActivity {
|
public class TDDStatsActivity extends NoSplashActivity {
|
||||||
private static Logger log = LoggerFactory.getLogger(TDDStatsActivity.class);
|
private static Logger log = LoggerFactory.getLogger(TDDStatsActivity.class);
|
||||||
|
private CompositeDisposable disposable = new CompositeDisposable();
|
||||||
|
|
||||||
TextView statusView, statsMessage, totalBaseBasal2;
|
TextView statusView, statsMessage, totalBaseBasal2;
|
||||||
EditText totalBaseBasal;
|
EditText totalBaseBasal;
|
||||||
|
@ -75,12 +81,18 @@ public class TDDStatsActivity extends NoSplashActivity {
|
||||||
protected void onResume() {
|
protected void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
MainApp.bus().register(this);
|
MainApp.bus().register(this);
|
||||||
|
disposable.add(RxBus.INSTANCE
|
||||||
|
.toObservable(EventPumpStatusChanged.class)
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.subscribe(event -> statusView.setText(event.getStatus()), FabricPrivacy::logException)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPause() {
|
protected void onPause() {
|
||||||
super.onPause();
|
super.onPause();
|
||||||
MainApp.bus().unregister(this);
|
MainApp.bus().unregister(this);
|
||||||
|
disposable.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -531,18 +543,6 @@ public class TDDStatsActivity extends NoSplashActivity {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
|
||||||
public void onStatusEvent(final EventPumpStatusChanged c) {
|
|
||||||
runOnUiThread(
|
|
||||||
new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
statusView.setText(c.textStatus());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static boolean isOldData(List<TDD> historyList) {
|
public static boolean isOldData(List<TDD> historyList) {
|
||||||
Object activePump = ConfigBuilderPlugin.getPlugin().getActivePump();
|
Object activePump = ConfigBuilderPlugin.getPlugin().getActivePump();
|
||||||
|
|
|
@ -243,7 +243,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
new java.util.TimerTask() {
|
new java.util.TimerTask() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
MainApp.bus().post(new EventRefreshOverview("resetDatabases"));
|
RxBus.INSTANCE.send(new EventRefreshOverview("resetDatabases"));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
3000
|
3000
|
||||||
|
@ -738,7 +738,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
public void run() {
|
public void run() {
|
||||||
if (L.isEnabled(L.DATABASE))
|
if (L.isEnabled(L.DATABASE))
|
||||||
log.debug("Firing EventTempTargetChange");
|
log.debug("Firing EventTempTargetChange");
|
||||||
MainApp.bus().post(new EventTempTargetChange());
|
RxBus.INSTANCE.send(new EventTempTargetChange());
|
||||||
scheduledTemTargetPost = null;
|
scheduledTemTargetPost = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1035,8 +1035,8 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
public void run() {
|
public void run() {
|
||||||
if (L.isEnabled(L.DATABASE))
|
if (L.isEnabled(L.DATABASE))
|
||||||
log.debug("Firing EventTempBasalChange");
|
log.debug("Firing EventTempBasalChange");
|
||||||
MainApp.bus().post(new EventReloadTempBasalData());
|
RxBus.INSTANCE.send(new EventReloadTempBasalData());
|
||||||
MainApp.bus().post(new EventTempBasalChange());
|
RxBus.INSTANCE.send(new EventTempBasalChange());
|
||||||
if (earliestDataChange != null)
|
if (earliestDataChange != null)
|
||||||
MainApp.bus().post(new EventNewHistoryData(earliestDataChange));
|
MainApp.bus().post(new EventNewHistoryData(earliestDataChange));
|
||||||
earliestDataChange = null;
|
earliestDataChange = null;
|
||||||
|
@ -1371,7 +1371,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
public void run() {
|
public void run() {
|
||||||
if (L.isEnabled(L.DATABASE))
|
if (L.isEnabled(L.DATABASE))
|
||||||
log.debug("Firing EventExtendedBolusChange");
|
log.debug("Firing EventExtendedBolusChange");
|
||||||
MainApp.bus().post(new EventReloadTreatmentData(new EventExtendedBolusChange()));
|
RxBus.INSTANCE.send(new EventReloadTreatmentData(new EventExtendedBolusChange()));
|
||||||
if (earliestDataChange != null)
|
if (earliestDataChange != null)
|
||||||
MainApp.bus().post(new EventNewHistoryData(earliestDataChange));
|
MainApp.bus().post(new EventNewHistoryData(earliestDataChange));
|
||||||
earliestDataChange = null;
|
earliestDataChange = null;
|
||||||
|
@ -1720,7 +1720,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
public void run() {
|
public void run() {
|
||||||
if (L.isEnabled(L.DATABASE))
|
if (L.isEnabled(L.DATABASE))
|
||||||
log.debug("Firing EventProfileNeedsUpdate");
|
log.debug("Firing EventProfileNeedsUpdate");
|
||||||
MainApp.bus().post(new EventReloadProfileSwitchData());
|
RxBus.INSTANCE.send(new EventReloadProfileSwitchData());
|
||||||
MainApp.bus().post(new EventProfileNeedsUpdate());
|
MainApp.bus().post(new EventProfileNeedsUpdate());
|
||||||
scheduledProfileSwitchEventPost = null;
|
scheduledProfileSwitchEventPost = null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +0,0 @@
|
||||||
package info.nightscout.androidaps.events;
|
|
||||||
|
|
||||||
public class EventCustomActionsChanged extends Event {
|
|
||||||
}
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
package info.nightscout.androidaps.events
|
||||||
|
|
||||||
|
class EventCustomActionsChanged : Event()
|
|
@ -1,8 +0,0 @@
|
||||||
package info.nightscout.androidaps.events;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by mike on 15.05.2017.
|
|
||||||
*/
|
|
||||||
|
|
||||||
public class EventExtendedBolusChange extends Event {
|
|
||||||
}
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
package info.nightscout.androidaps.events
|
||||||
|
|
||||||
|
class EventExtendedBolusChange : EventLoop()
|
|
@ -1,5 +0,0 @@
|
||||||
package info.nightscout.androidaps.events;
|
|
||||||
|
|
||||||
/** Supeclass for all events concerned with input or output into or from the LoopPlugin. */
|
|
||||||
public abstract class EventLoop extends Event {
|
|
||||||
}
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
package info.nightscout.androidaps.events
|
||||||
|
|
||||||
|
/** Supeclass for all events concerned with input or output into or from the LoopPlugin. */
|
||||||
|
abstract class EventLoop : Event()
|
|
@ -1,63 +0,0 @@
|
||||||
package info.nightscout.androidaps.events;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.MainApp;
|
|
||||||
import info.nightscout.androidaps.R;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by mike on 19.02.2017.
|
|
||||||
*/
|
|
||||||
|
|
||||||
public class EventPumpStatusChanged extends Event {
|
|
||||||
public static final int CONNECTING = 0;
|
|
||||||
public static final int CONNECTED = 1;
|
|
||||||
public static final int HANDSHAKING = 2;
|
|
||||||
public static final int PERFORMING = 3;
|
|
||||||
public static final int DISCONNECTING = 4;
|
|
||||||
public static final int DISCONNECTED = 5;
|
|
||||||
|
|
||||||
public int sStatus = DISCONNECTED;
|
|
||||||
public int sSecondsElapsed = 0;
|
|
||||||
public String sPerfomingAction = "";
|
|
||||||
|
|
||||||
public static String error = "";
|
|
||||||
|
|
||||||
public EventPumpStatusChanged(int status) {
|
|
||||||
sStatus = status;
|
|
||||||
sSecondsElapsed = 0;
|
|
||||||
error = "";
|
|
||||||
}
|
|
||||||
|
|
||||||
public EventPumpStatusChanged(int status, int secondsElapsed) {
|
|
||||||
sStatus = status;
|
|
||||||
sSecondsElapsed = secondsElapsed;
|
|
||||||
error = "";
|
|
||||||
}
|
|
||||||
|
|
||||||
public EventPumpStatusChanged(int status, String error) {
|
|
||||||
sStatus = status;
|
|
||||||
sSecondsElapsed = 0;
|
|
||||||
this.error = error;
|
|
||||||
}
|
|
||||||
|
|
||||||
public EventPumpStatusChanged(String action) {
|
|
||||||
sStatus = PERFORMING;
|
|
||||||
sSecondsElapsed = 0;
|
|
||||||
sPerfomingAction = action;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String textStatus() {
|
|
||||||
if (sStatus == CONNECTING)
|
|
||||||
return String.format(MainApp.gs(R.string.danar_history_connectingfor), sSecondsElapsed);
|
|
||||||
else if (sStatus == HANDSHAKING)
|
|
||||||
return MainApp.gs(R.string.handshaking);
|
|
||||||
else if (sStatus == CONNECTED)
|
|
||||||
return MainApp.gs(R.string.connected);
|
|
||||||
else if (sStatus == PERFORMING)
|
|
||||||
return sPerfomingAction;
|
|
||||||
else if (sStatus == DISCONNECTING)
|
|
||||||
return MainApp.gs(R.string.disconnecting);
|
|
||||||
else if (sStatus == DISCONNECTED)
|
|
||||||
return "";
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,62 @@
|
||||||
|
package info.nightscout.androidaps.events
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.MainApp
|
||||||
|
import info.nightscout.androidaps.R
|
||||||
|
|
||||||
|
class EventPumpStatusChanged : EventStatus {
|
||||||
|
|
||||||
|
enum class Status {
|
||||||
|
CONNECTING,
|
||||||
|
CONNECTED,
|
||||||
|
HANDSHAKING,
|
||||||
|
PERFORMING,
|
||||||
|
DISCONNECTING,
|
||||||
|
DISCONNECTED
|
||||||
|
}
|
||||||
|
|
||||||
|
var sStatus: Status = Status.DISCONNECTED
|
||||||
|
var sSecondsElapsed = 0
|
||||||
|
var sPerfomingAction = ""
|
||||||
|
var error = ""
|
||||||
|
|
||||||
|
constructor(status: Status) {
|
||||||
|
sStatus = status
|
||||||
|
sSecondsElapsed = 0
|
||||||
|
error = ""
|
||||||
|
}
|
||||||
|
|
||||||
|
constructor(status: Status, secondsElapsed: Int) {
|
||||||
|
sStatus = status
|
||||||
|
sSecondsElapsed = secondsElapsed
|
||||||
|
error = ""
|
||||||
|
}
|
||||||
|
|
||||||
|
constructor(status: Status, error: String) {
|
||||||
|
sStatus = status
|
||||||
|
sSecondsElapsed = 0
|
||||||
|
this.error = error
|
||||||
|
}
|
||||||
|
|
||||||
|
constructor(action: String) {
|
||||||
|
sStatus = Status.PERFORMING
|
||||||
|
sSecondsElapsed = 0
|
||||||
|
sPerfomingAction = action
|
||||||
|
}
|
||||||
|
|
||||||
|
// status for startup wizard
|
||||||
|
override fun getStatus(): String {
|
||||||
|
if (sStatus == Status.CONNECTING)
|
||||||
|
return String.format(MainApp.gs(R.string.danar_history_connectingfor), sSecondsElapsed)
|
||||||
|
else if (sStatus == Status.HANDSHAKING)
|
||||||
|
return MainApp.gs(R.string.handshaking)
|
||||||
|
else if (sStatus == Status.CONNECTED)
|
||||||
|
return MainApp.gs(R.string.connected)
|
||||||
|
else if (sStatus == Status.PERFORMING)
|
||||||
|
return sPerfomingAction
|
||||||
|
else if (sStatus == Status.DISCONNECTING)
|
||||||
|
return MainApp.gs(R.string.disconnecting)
|
||||||
|
else if (sStatus == Status.DISCONNECTED)
|
||||||
|
return ""
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,13 +0,0 @@
|
||||||
package info.nightscout.androidaps.events;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by mike on 16.06.2017.
|
|
||||||
*/
|
|
||||||
|
|
||||||
public class EventRefreshOverview extends Event {
|
|
||||||
public String from;
|
|
||||||
|
|
||||||
public EventRefreshOverview(String from) {
|
|
||||||
this.from = from;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
package info.nightscout.androidaps.events
|
||||||
|
|
||||||
|
class EventRefreshOverview(var from: String) : Event()
|
|
@ -1,8 +0,0 @@
|
||||||
package info.nightscout.androidaps.events;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by mike on 12.06.2017.
|
|
||||||
*/
|
|
||||||
|
|
||||||
public class EventReloadProfileSwitchData extends Event {
|
|
||||||
}
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
package info.nightscout.androidaps.events
|
||||||
|
|
||||||
|
class EventReloadProfileSwitchData : Event()
|
|
@ -1,8 +0,0 @@
|
||||||
package info.nightscout.androidaps.events;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by mike on 29.05.2017.
|
|
||||||
*/
|
|
||||||
|
|
||||||
public class EventReloadTempBasalData extends Event {
|
|
||||||
}
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
package info.nightscout.androidaps.events
|
||||||
|
|
||||||
|
class EventReloadTempBasalData : Event()
|
|
@ -1,13 +0,0 @@
|
||||||
package info.nightscout.androidaps.events;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by mike on 29.05.2017.
|
|
||||||
*/
|
|
||||||
|
|
||||||
public class EventReloadTreatmentData extends Event {
|
|
||||||
public Object next;
|
|
||||||
|
|
||||||
public EventReloadTreatmentData(Object next) {
|
|
||||||
this.next = next;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
package info.nightscout.androidaps.events
|
||||||
|
|
||||||
|
class EventReloadTreatmentData(var next: Event) : Event()
|
|
@ -0,0 +1,6 @@
|
||||||
|
package info.nightscout.androidaps.events
|
||||||
|
|
||||||
|
// pass string to startup wizard
|
||||||
|
abstract class EventStatus :Event() {
|
||||||
|
abstract fun getStatus() : String
|
||||||
|
}
|
|
@ -1,7 +0,0 @@
|
||||||
package info.nightscout.androidaps.events;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by mike on 05.06.2016.
|
|
||||||
*/
|
|
||||||
public class EventTempBasalChange extends EventLoop {
|
|
||||||
}
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
package info.nightscout.androidaps.events
|
||||||
|
|
||||||
|
class EventTempBasalChange : EventLoop()
|
|
@ -1,8 +0,0 @@
|
||||||
package info.nightscout.androidaps.events;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by mike on 13.01.2017.
|
|
||||||
*/
|
|
||||||
|
|
||||||
public class EventTempTargetChange extends Event {
|
|
||||||
}
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
package info.nightscout.androidaps.events
|
||||||
|
|
||||||
|
class EventTempTargetChange : Event()
|
|
@ -1,17 +0,0 @@
|
||||||
package info.nightscout.androidaps.events;
|
|
||||||
|
|
||||||
import androidx.annotation.Nullable;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.plugins.treatments.Treatment;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by mike on 04.06.2016.
|
|
||||||
*/
|
|
||||||
public class EventTreatmentChange extends EventLoop {
|
|
||||||
@Nullable
|
|
||||||
public final Treatment treatment;
|
|
||||||
|
|
||||||
public EventTreatmentChange(Treatment treatment) {
|
|
||||||
this.treatment = treatment;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
package info.nightscout.androidaps.events
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.plugins.treatments.Treatment
|
||||||
|
|
||||||
|
class EventTreatmentChange(val treatment: Treatment?) : EventLoop()
|
|
@ -62,12 +62,15 @@ import info.nightscout.androidaps.utils.FabricPrivacy;
|
||||||
import info.nightscout.androidaps.utils.SP;
|
import info.nightscout.androidaps.utils.SP;
|
||||||
import info.nightscout.androidaps.utils.T;
|
import info.nightscout.androidaps.utils.T;
|
||||||
import info.nightscout.androidaps.utils.ToastUtils;
|
import info.nightscout.androidaps.utils.ToastUtils;
|
||||||
|
import io.reactivex.disposables.CompositeDisposable;
|
||||||
|
import io.reactivex.schedulers.Schedulers;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by mike on 05.08.2016.
|
* Created by mike on 05.08.2016.
|
||||||
*/
|
*/
|
||||||
public class LoopPlugin extends PluginBase {
|
public class LoopPlugin extends PluginBase {
|
||||||
private static Logger log = LoggerFactory.getLogger(L.APS);
|
private static Logger log = LoggerFactory.getLogger(L.APS);
|
||||||
|
private CompositeDisposable disposable = new CompositeDisposable();
|
||||||
|
|
||||||
private static final String CHANNEL_ID = "AndroidAPS-Openloop";
|
private static final String CHANNEL_ID = "AndroidAPS-Openloop";
|
||||||
|
|
||||||
|
@ -119,6 +122,13 @@ public class LoopPlugin extends PluginBase {
|
||||||
MainApp.bus().register(this);
|
MainApp.bus().register(this);
|
||||||
createNotificationChannel();
|
createNotificationChannel();
|
||||||
super.onStart();
|
super.onStart();
|
||||||
|
disposable.add(RxBus.INSTANCE
|
||||||
|
.toObservable(EventTempTargetChange.class)
|
||||||
|
.observeOn(Schedulers.io())
|
||||||
|
.subscribe(event -> {
|
||||||
|
invoke("EventTempTargetChange", true);
|
||||||
|
}, FabricPrivacy::logException)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createNotificationChannel() {
|
private void createNotificationChannel() {
|
||||||
|
@ -135,8 +145,9 @@ public class LoopPlugin extends PluginBase {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStop() {
|
protected void onStop() {
|
||||||
super.onStop();
|
|
||||||
MainApp.bus().unregister(this);
|
MainApp.bus().unregister(this);
|
||||||
|
disposable.clear();
|
||||||
|
super.onStop();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -176,12 +187,6 @@ public class LoopPlugin extends PluginBase {
|
||||||
return loopSuspendedTill;
|
return loopSuspendedTill;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
|
||||||
public void onStatusEvent(final EventTempTargetChange ev) {
|
|
||||||
new Thread(() -> invoke("EventTempTargetChange", true)).start();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void suspendTo(long endTime) {
|
public void suspendTo(long endTime) {
|
||||||
loopSuspendedTill = endTime;
|
loopSuspendedTill = endTime;
|
||||||
isSuperBolus = false;
|
isSuperBolus = false;
|
||||||
|
|
|
@ -1,329 +0,0 @@
|
||||||
package info.nightscout.androidaps.plugins.general.actions;
|
|
||||||
|
|
||||||
|
|
||||||
import android.app.Activity;
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.graphics.drawable.Drawable;
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.view.LayoutInflater;
|
|
||||||
import android.view.View;
|
|
||||||
import android.view.ViewGroup;
|
|
||||||
import android.widget.LinearLayout;
|
|
||||||
|
|
||||||
import androidx.fragment.app.FragmentManager;
|
|
||||||
|
|
||||||
import com.squareup.otto.Subscribe;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.Config;
|
|
||||||
import info.nightscout.androidaps.MainApp;
|
|
||||||
import info.nightscout.androidaps.R;
|
|
||||||
import info.nightscout.androidaps.activities.HistoryBrowseActivity;
|
|
||||||
import info.nightscout.androidaps.activities.TDDStatsActivity;
|
|
||||||
import info.nightscout.androidaps.db.ExtendedBolus;
|
|
||||||
import info.nightscout.androidaps.db.TemporaryBasal;
|
|
||||||
import info.nightscout.androidaps.events.EventCustomActionsChanged;
|
|
||||||
import info.nightscout.androidaps.events.EventExtendedBolusChange;
|
|
||||||
import info.nightscout.androidaps.events.EventInitializationChanged;
|
|
||||||
import info.nightscout.androidaps.events.EventRefreshOverview;
|
|
||||||
import info.nightscout.androidaps.events.EventTempBasalChange;
|
|
||||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
|
||||||
import info.nightscout.androidaps.plugins.common.SubscriberFragment;
|
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
|
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctions;
|
|
||||||
import info.nightscout.androidaps.plugins.general.actions.defs.CustomAction;
|
|
||||||
import info.nightscout.androidaps.plugins.general.actions.dialogs.FillDialog;
|
|
||||||
import info.nightscout.androidaps.plugins.general.actions.dialogs.NewExtendedBolusDialog;
|
|
||||||
import info.nightscout.androidaps.plugins.general.actions.dialogs.NewTempBasalDialog;
|
|
||||||
import info.nightscout.androidaps.plugins.general.careportal.CareportalFragment;
|
|
||||||
import info.nightscout.androidaps.plugins.general.careportal.Dialogs.NewNSTreatmentDialog;
|
|
||||||
import info.nightscout.androidaps.plugins.general.careportal.OptionsToShow;
|
|
||||||
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin;
|
|
||||||
import info.nightscout.androidaps.utils.SP;
|
|
||||||
import info.nightscout.androidaps.utils.SingleClickButton;
|
|
||||||
|
|
||||||
public class ActionsFragment extends SubscriberFragment implements View.OnClickListener {
|
|
||||||
|
|
||||||
private View actionsFragmentView;
|
|
||||||
private SingleClickButton profileSwitch;
|
|
||||||
private SingleClickButton tempTarget;
|
|
||||||
private SingleClickButton extendedBolus;
|
|
||||||
private SingleClickButton extendedBolusCancel;
|
|
||||||
private SingleClickButton tempBasal;
|
|
||||||
private SingleClickButton tempBasalCancel;
|
|
||||||
private SingleClickButton fill;
|
|
||||||
private SingleClickButton tddStats;
|
|
||||||
private SingleClickButton history;
|
|
||||||
|
|
||||||
private Map<String, CustomAction> pumpCustomActions = new HashMap<>();
|
|
||||||
private List<SingleClickButton> pumpCustomButtons = new ArrayList<>();
|
|
||||||
|
|
||||||
public ActionsFragment() {
|
|
||||||
super();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
|
||||||
Bundle savedInstanceState) {
|
|
||||||
View view = inflater.inflate(R.layout.actions_fragment, container, false);
|
|
||||||
|
|
||||||
profileSwitch = view.findViewById(R.id.actions_profileswitch);
|
|
||||||
tempTarget = view.findViewById(R.id.actions_temptarget);
|
|
||||||
extendedBolus = view.findViewById(R.id.actions_extendedbolus);
|
|
||||||
extendedBolusCancel = view.findViewById(R.id.actions_extendedbolus_cancel);
|
|
||||||
tempBasal = view.findViewById(R.id.actions_settempbasal);
|
|
||||||
tempBasalCancel = view.findViewById(R.id.actions_canceltempbasal);
|
|
||||||
fill = view.findViewById(R.id.actions_fill);
|
|
||||||
tddStats = view.findViewById(R.id.actions_tddstats);
|
|
||||||
history = view.findViewById(R.id.actions_historybrowser);
|
|
||||||
|
|
||||||
profileSwitch.setOnClickListener(this);
|
|
||||||
tempTarget.setOnClickListener(this);
|
|
||||||
extendedBolus.setOnClickListener(this);
|
|
||||||
extendedBolusCancel.setOnClickListener(this);
|
|
||||||
tempBasal.setOnClickListener(this);
|
|
||||||
tempBasalCancel.setOnClickListener(this);
|
|
||||||
fill.setOnClickListener(this);
|
|
||||||
history.setOnClickListener(this);
|
|
||||||
tddStats.setOnClickListener(this);
|
|
||||||
|
|
||||||
actionsFragmentView = view;
|
|
||||||
|
|
||||||
updateGUI();
|
|
||||||
SP.putBoolean(R.string.key_objectiveuseactions, true);
|
|
||||||
return view;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Subscribe
|
|
||||||
public void onStatusEvent(final EventInitializationChanged ev) {
|
|
||||||
updateGUI();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Subscribe
|
|
||||||
public void onStatusEvent(final EventRefreshOverview ev) {
|
|
||||||
updateGUI();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Subscribe
|
|
||||||
public void onStatusEvent(final EventExtendedBolusChange ev) {
|
|
||||||
updateGUI();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Subscribe
|
|
||||||
public void onStatusEvent(final EventTempBasalChange ev) {
|
|
||||||
updateGUI();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Subscribe
|
|
||||||
public void onStatusEvent(final EventCustomActionsChanged ev) {
|
|
||||||
updateGUI();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void updateGUI() {
|
|
||||||
Activity activity = getActivity();
|
|
||||||
if (activity != null)
|
|
||||||
activity.runOnUiThread(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
if (ConfigBuilderPlugin.getPlugin().getActiveProfileInterface() != null && ConfigBuilderPlugin.getPlugin().getActiveProfileInterface().getProfile() != null) {
|
|
||||||
profileSwitch.setVisibility(View.VISIBLE);
|
|
||||||
} else {
|
|
||||||
profileSwitch.setVisibility(View.GONE);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ProfileFunctions.getInstance().getProfile() == null) {
|
|
||||||
tempTarget.setVisibility(View.GONE);
|
|
||||||
extendedBolus.setVisibility(View.GONE);
|
|
||||||
extendedBolusCancel.setVisibility(View.GONE);
|
|
||||||
tempBasal.setVisibility(View.GONE);
|
|
||||||
tempBasalCancel.setVisibility(View.GONE);
|
|
||||||
fill.setVisibility(View.GONE);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
final PumpInterface pump = ConfigBuilderPlugin.getPlugin().getActivePump();
|
|
||||||
final boolean basalprofileEnabled = MainApp.isEngineeringModeOrRelease()
|
|
||||||
&& pump.getPumpDescription().isSetBasalProfileCapable;
|
|
||||||
|
|
||||||
if (!basalprofileEnabled || !pump.isInitialized() || pump.isSuspended())
|
|
||||||
profileSwitch.setVisibility(View.GONE);
|
|
||||||
else
|
|
||||||
profileSwitch.setVisibility(View.VISIBLE);
|
|
||||||
|
|
||||||
if (!pump.getPumpDescription().isExtendedBolusCapable || !pump.isInitialized() || pump.isSuspended() || pump.isFakingTempsByExtendedBoluses()) {
|
|
||||||
extendedBolus.setVisibility(View.GONE);
|
|
||||||
extendedBolusCancel.setVisibility(View.GONE);
|
|
||||||
} else {
|
|
||||||
ExtendedBolus activeExtendedBolus = TreatmentsPlugin.getPlugin().getExtendedBolusFromHistory(System.currentTimeMillis());
|
|
||||||
if (activeExtendedBolus != null) {
|
|
||||||
extendedBolus.setVisibility(View.GONE);
|
|
||||||
extendedBolusCancel.setVisibility(View.VISIBLE);
|
|
||||||
extendedBolusCancel.setText(MainApp.gs(R.string.cancel) + " " + activeExtendedBolus.toString());
|
|
||||||
} else {
|
|
||||||
extendedBolus.setVisibility(View.VISIBLE);
|
|
||||||
extendedBolusCancel.setVisibility(View.GONE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (!pump.getPumpDescription().isTempBasalCapable || !pump.isInitialized() || pump.isSuspended()) {
|
|
||||||
tempBasal.setVisibility(View.GONE);
|
|
||||||
tempBasalCancel.setVisibility(View.GONE);
|
|
||||||
} else {
|
|
||||||
final TemporaryBasal activeTemp = TreatmentsPlugin.getPlugin().getTempBasalFromHistory(System.currentTimeMillis());
|
|
||||||
if (activeTemp != null) {
|
|
||||||
tempBasal.setVisibility(View.GONE);
|
|
||||||
tempBasalCancel.setVisibility(View.VISIBLE);
|
|
||||||
tempBasalCancel.setText(MainApp.gs(R.string.cancel) + " " + activeTemp.toStringShort());
|
|
||||||
} else {
|
|
||||||
tempBasal.setVisibility(View.VISIBLE);
|
|
||||||
tempBasalCancel.setVisibility(View.GONE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!pump.getPumpDescription().isRefillingCapable || !pump.isInitialized() || pump.isSuspended())
|
|
||||||
fill.setVisibility(View.GONE);
|
|
||||||
else
|
|
||||||
fill.setVisibility(View.VISIBLE);
|
|
||||||
|
|
||||||
if (!Config.APS)
|
|
||||||
tempTarget.setVisibility(View.GONE);
|
|
||||||
else
|
|
||||||
tempTarget.setVisibility(View.VISIBLE);
|
|
||||||
|
|
||||||
if (!pump.getPumpDescription().supportsTDDs)
|
|
||||||
tddStats.setVisibility(View.GONE);
|
|
||||||
else
|
|
||||||
tddStats.setVisibility(View.VISIBLE);
|
|
||||||
|
|
||||||
checkPumpCustomActions();
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
View.OnClickListener pumpCustomActionsListener = v -> {
|
|
||||||
|
|
||||||
SingleClickButton btn = (SingleClickButton) v;
|
|
||||||
|
|
||||||
CustomAction customAction = this.pumpCustomActions.get(btn.getText().toString());
|
|
||||||
|
|
||||||
ConfigBuilderPlugin.getPlugin().getActivePump().executeCustomAction(customAction.getCustomActionType());
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
private void checkPumpCustomActions() {
|
|
||||||
|
|
||||||
PumpInterface activePump = ConfigBuilderPlugin.getPlugin().getActivePump();
|
|
||||||
|
|
||||||
removePumpCustomActions();
|
|
||||||
|
|
||||||
if (activePump == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
List<CustomAction> customActions = activePump.getCustomActions();
|
|
||||||
|
|
||||||
if (customActions != null && customActions.size() > 0) {
|
|
||||||
|
|
||||||
LinearLayout ll = actionsFragmentView.findViewById(R.id.action_buttons_layout);
|
|
||||||
|
|
||||||
for (CustomAction customAction : customActions) {
|
|
||||||
|
|
||||||
if (!customAction.isEnabled())
|
|
||||||
continue;
|
|
||||||
|
|
||||||
SingleClickButton btn = new SingleClickButton(getContext(), null, android.R.attr.buttonStyle);
|
|
||||||
btn.setText(MainApp.gs(customAction.getName()));
|
|
||||||
|
|
||||||
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(
|
|
||||||
LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT, 0.5f);
|
|
||||||
layoutParams.setMargins(20, 8, 20, 8); // 10,3,10,3
|
|
||||||
|
|
||||||
btn.setLayoutParams(layoutParams);
|
|
||||||
btn.setOnClickListener(pumpCustomActionsListener);
|
|
||||||
|
|
||||||
Drawable top = getResources().getDrawable(customAction.getIconResourceId());
|
|
||||||
btn.setCompoundDrawablesWithIntrinsicBounds(null, top, null, null);
|
|
||||||
|
|
||||||
ll.addView(btn);
|
|
||||||
|
|
||||||
this.pumpCustomActions.put(MainApp.gs(customAction.getName()), customAction);
|
|
||||||
this.pumpCustomButtons.add(btn);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private void removePumpCustomActions() {
|
|
||||||
|
|
||||||
if (pumpCustomActions.size() == 0)
|
|
||||||
return;
|
|
||||||
|
|
||||||
LinearLayout ll = actionsFragmentView.findViewById(R.id.action_buttons_layout);
|
|
||||||
|
|
||||||
for (SingleClickButton customButton : pumpCustomButtons) {
|
|
||||||
ll.removeView(customButton);
|
|
||||||
}
|
|
||||||
|
|
||||||
pumpCustomButtons.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onClick(View view) {
|
|
||||||
FragmentManager manager = getFragmentManager();
|
|
||||||
switch (view.getId()) {
|
|
||||||
case R.id.actions_profileswitch:
|
|
||||||
NewNSTreatmentDialog newDialog = new NewNSTreatmentDialog();
|
|
||||||
final OptionsToShow profileswitch = CareportalFragment.PROFILESWITCH;
|
|
||||||
profileswitch.executeProfileSwitch = true;
|
|
||||||
newDialog.setOptions(profileswitch, R.string.careportal_profileswitch);
|
|
||||||
newDialog.show(manager, "NewNSTreatmentDialog");
|
|
||||||
break;
|
|
||||||
case R.id.actions_temptarget:
|
|
||||||
NewNSTreatmentDialog newTTDialog = new NewNSTreatmentDialog();
|
|
||||||
final OptionsToShow temptarget = CareportalFragment.TEMPTARGET;
|
|
||||||
temptarget.executeTempTarget = true;
|
|
||||||
newTTDialog.setOptions(temptarget, R.string.careportal_temporarytarget);
|
|
||||||
newTTDialog.show(manager, "NewNSTreatmentDialog");
|
|
||||||
break;
|
|
||||||
case R.id.actions_extendedbolus:
|
|
||||||
NewExtendedBolusDialog newExtendedDialog = new NewExtendedBolusDialog();
|
|
||||||
newExtendedDialog.show(manager, "NewExtendedDialog");
|
|
||||||
break;
|
|
||||||
case R.id.actions_extendedbolus_cancel:
|
|
||||||
if (TreatmentsPlugin.getPlugin().isInHistoryExtendedBoluslInProgress()) {
|
|
||||||
ConfigBuilderPlugin.getPlugin().getCommandQueue().cancelExtended(null);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case R.id.actions_canceltempbasal:
|
|
||||||
if (TreatmentsPlugin.getPlugin().isTempBasalInProgress()) {
|
|
||||||
ConfigBuilderPlugin.getPlugin().getCommandQueue().cancelTempBasal(true, null);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case R.id.actions_settempbasal:
|
|
||||||
NewTempBasalDialog newTempDialog = new NewTempBasalDialog();
|
|
||||||
newTempDialog.show(manager, "NewTempDialog");
|
|
||||||
break;
|
|
||||||
case R.id.actions_fill:
|
|
||||||
FillDialog fillDialog = new FillDialog();
|
|
||||||
fillDialog.show(manager, "FillDialog");
|
|
||||||
break;
|
|
||||||
case R.id.actions_historybrowser:
|
|
||||||
startActivity(new Intent(getContext(), HistoryBrowseActivity.class));
|
|
||||||
break;
|
|
||||||
case R.id.actions_tddstats:
|
|
||||||
startActivity(new Intent(getContext(), TDDStatsActivity.class));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,242 @@
|
||||||
|
package info.nightscout.androidaps.plugins.general.actions
|
||||||
|
|
||||||
|
|
||||||
|
import android.content.Intent
|
||||||
|
import android.os.Bundle
|
||||||
|
import android.view.LayoutInflater
|
||||||
|
import android.view.View
|
||||||
|
import android.view.ViewGroup
|
||||||
|
import android.widget.LinearLayout
|
||||||
|
import androidx.fragment.app.Fragment
|
||||||
|
import info.nightscout.androidaps.Config
|
||||||
|
import info.nightscout.androidaps.MainApp
|
||||||
|
import info.nightscout.androidaps.R
|
||||||
|
import info.nightscout.androidaps.activities.HistoryBrowseActivity
|
||||||
|
import info.nightscout.androidaps.activities.TDDStatsActivity
|
||||||
|
import info.nightscout.androidaps.events.*
|
||||||
|
import info.nightscout.androidaps.plugins.bus.RxBus
|
||||||
|
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin
|
||||||
|
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctions
|
||||||
|
import info.nightscout.androidaps.plugins.general.actions.defs.CustomAction
|
||||||
|
import info.nightscout.androidaps.plugins.general.actions.dialogs.FillDialog
|
||||||
|
import info.nightscout.androidaps.plugins.general.actions.dialogs.NewExtendedBolusDialog
|
||||||
|
import info.nightscout.androidaps.plugins.general.actions.dialogs.NewTempBasalDialog
|
||||||
|
import info.nightscout.androidaps.plugins.general.careportal.CareportalFragment
|
||||||
|
import info.nightscout.androidaps.plugins.general.careportal.Dialogs.NewNSTreatmentDialog
|
||||||
|
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin
|
||||||
|
import info.nightscout.androidaps.queue.Callback
|
||||||
|
import info.nightscout.androidaps.utils.*
|
||||||
|
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||||
|
import io.reactivex.disposables.CompositeDisposable
|
||||||
|
import kotlinx.android.synthetic.main.actions_fragment.*
|
||||||
|
import java.util.*
|
||||||
|
|
||||||
|
class ActionsFragment : Fragment() {
|
||||||
|
|
||||||
|
private var disposable: CompositeDisposable = CompositeDisposable()
|
||||||
|
|
||||||
|
private val pumpCustomActions = HashMap<String, CustomAction>()
|
||||||
|
private val pumpCustomButtons = ArrayList<SingleClickButton>()
|
||||||
|
|
||||||
|
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
|
||||||
|
savedInstanceState: Bundle?): View? {
|
||||||
|
return inflater.inflate(R.layout.actions_fragment, container, false)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
|
super.onViewCreated(view, savedInstanceState)
|
||||||
|
|
||||||
|
actions_profileswitch.setOnClickListener {
|
||||||
|
val newDialog = NewNSTreatmentDialog()
|
||||||
|
val profileSwitch = CareportalFragment.PROFILESWITCH
|
||||||
|
profileSwitch.executeProfileSwitch = true
|
||||||
|
newDialog.setOptions(profileSwitch, R.string.careportal_profileswitch)
|
||||||
|
fragmentManager?.let { newDialog.show(it, "NewNSTreatmentDialog") }
|
||||||
|
}
|
||||||
|
actions_temptarget.setOnClickListener {
|
||||||
|
val newTTDialog = NewNSTreatmentDialog()
|
||||||
|
val temptarget = CareportalFragment.TEMPTARGET
|
||||||
|
temptarget.executeTempTarget = true
|
||||||
|
newTTDialog.setOptions(temptarget, R.string.careportal_temporarytarget)
|
||||||
|
fragmentManager?.let { newTTDialog.show(it, "NewNSTreatmentDialog") }
|
||||||
|
}
|
||||||
|
actions_extendedbolus.setOnClickListener {
|
||||||
|
fragmentManager?.let { NewExtendedBolusDialog().show(it, "NewExtendedDialog") }
|
||||||
|
}
|
||||||
|
actions_extendedbolus_cancel.setOnClickListener {
|
||||||
|
if (TreatmentsPlugin.getPlugin().isInHistoryExtendedBoluslInProgress) {
|
||||||
|
ConfigBuilderPlugin.getPlugin().commandQueue.cancelExtended(object : Callback() {
|
||||||
|
override fun run() {
|
||||||
|
if (!result.success)
|
||||||
|
ToastUtils.showToastInUiThread(MainApp.instance().applicationContext, MainApp.gs(R.string.extendedbolusdeliveryerror))
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
actions_settempbasal.setOnClickListener { fragmentManager?.let { NewTempBasalDialog().show(it, "NewTempDialog") } }
|
||||||
|
actions_canceltempbasal.setOnClickListener {
|
||||||
|
if (TreatmentsPlugin.getPlugin().isTempBasalInProgress) {
|
||||||
|
ConfigBuilderPlugin.getPlugin().commandQueue.cancelTempBasal(true, object : Callback() {
|
||||||
|
override fun run() {
|
||||||
|
if (!result.success)
|
||||||
|
ToastUtils.showToastInUiThread(MainApp.instance().applicationContext, MainApp.gs(R.string.tempbasaldeliveryerror))
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
actions_fill.setOnClickListener { fragmentManager?.let { FillDialog().show(it, "FillDialog") } }
|
||||||
|
actions_historybrowser.setOnClickListener { startActivity(Intent(context, HistoryBrowseActivity::class.java)) }
|
||||||
|
actions_tddstats.setOnClickListener { startActivity(Intent(context, TDDStatsActivity::class.java)) }
|
||||||
|
|
||||||
|
SP.putBoolean(R.string.key_objectiveuseactions, true)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Synchronized
|
||||||
|
override fun onResume() {
|
||||||
|
super.onResume()
|
||||||
|
disposable += RxBus
|
||||||
|
.toObservable(EventInitializationChanged::class.java)
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.subscribe({
|
||||||
|
updateGui()
|
||||||
|
}, {
|
||||||
|
FabricPrivacy.logException(it)
|
||||||
|
})
|
||||||
|
disposable += RxBus
|
||||||
|
.toObservable(EventRefreshOverview::class.java)
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.subscribe({
|
||||||
|
updateGui()
|
||||||
|
}, {
|
||||||
|
FabricPrivacy.logException(it)
|
||||||
|
})
|
||||||
|
disposable += RxBus
|
||||||
|
.toObservable(EventExtendedBolusChange::class.java)
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.subscribe({
|
||||||
|
updateGui()
|
||||||
|
}, {
|
||||||
|
FabricPrivacy.logException(it)
|
||||||
|
})
|
||||||
|
disposable += RxBus
|
||||||
|
.toObservable(EventTempBasalChange::class.java)
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.subscribe({
|
||||||
|
updateGui()
|
||||||
|
}, {
|
||||||
|
FabricPrivacy.logException(it)
|
||||||
|
})
|
||||||
|
disposable += RxBus
|
||||||
|
.toObservable(EventCustomActionsChanged::class.java)
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.subscribe({
|
||||||
|
updateGui()
|
||||||
|
}, {
|
||||||
|
FabricPrivacy.logException(it)
|
||||||
|
})
|
||||||
|
updateGui()
|
||||||
|
}
|
||||||
|
|
||||||
|
@Synchronized
|
||||||
|
override fun onPause() {
|
||||||
|
super.onPause()
|
||||||
|
disposable.clear()
|
||||||
|
}
|
||||||
|
|
||||||
|
@Synchronized
|
||||||
|
fun updateGui() {
|
||||||
|
actions_profileswitch?.visibility =
|
||||||
|
if (ConfigBuilderPlugin.getPlugin().activeProfileInterface?.profile != null) View.VISIBLE
|
||||||
|
else View.GONE
|
||||||
|
|
||||||
|
if (ProfileFunctions.getInstance().profile == null) {
|
||||||
|
actions_temptarget?.visibility = View.GONE
|
||||||
|
actions_extendedbolus?.visibility = View.GONE
|
||||||
|
actions_extendedbolus_cancel?.visibility = View.GONE
|
||||||
|
actions_settempbasal?.visibility = View.GONE
|
||||||
|
actions_canceltempbasal?.visibility = View.GONE
|
||||||
|
actions_fill?.visibility = View.GONE
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
val pump = ConfigBuilderPlugin.getPlugin().activePump ?: return
|
||||||
|
val basalProfileEnabled = MainApp.isEngineeringModeOrRelease() && pump.pumpDescription.isSetBasalProfileCapable
|
||||||
|
|
||||||
|
actions_profileswitch?.visibility = if (!basalProfileEnabled || !pump.isInitialized || pump.isSuspended) View.GONE else View.VISIBLE
|
||||||
|
|
||||||
|
if (!pump.pumpDescription.isExtendedBolusCapable || !pump.isInitialized || pump.isSuspended || pump.isFakingTempsByExtendedBoluses) {
|
||||||
|
actions_extendedbolus?.visibility = View.GONE
|
||||||
|
actions_extendedbolus_cancel?.visibility = View.GONE
|
||||||
|
} else {
|
||||||
|
val activeExtendedBolus = TreatmentsPlugin.getPlugin().getExtendedBolusFromHistory(System.currentTimeMillis())
|
||||||
|
if (activeExtendedBolus != null) {
|
||||||
|
actions_extendedbolus?.visibility = View.GONE
|
||||||
|
actions_extendedbolus_cancel?.visibility = View.VISIBLE
|
||||||
|
actions_extendedbolus_cancel?.text = MainApp.gs(R.string.cancel) + " " + activeExtendedBolus.toString()
|
||||||
|
} else {
|
||||||
|
actions_extendedbolus?.visibility = View.VISIBLE
|
||||||
|
actions_extendedbolus_cancel?.visibility = View.GONE
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!pump.pumpDescription.isTempBasalCapable || !pump.isInitialized || pump.isSuspended) {
|
||||||
|
actions_settempbasal?.visibility = View.GONE
|
||||||
|
actions_canceltempbasal?.visibility = View.GONE
|
||||||
|
} else {
|
||||||
|
val activeTemp = TreatmentsPlugin.getPlugin().getTempBasalFromHistory(System.currentTimeMillis())
|
||||||
|
if (activeTemp != null) {
|
||||||
|
actions_settempbasal?.visibility = View.GONE
|
||||||
|
actions_canceltempbasal?.visibility = View.VISIBLE
|
||||||
|
actions_canceltempbasal?.text = MainApp.gs(R.string.cancel) + " " + activeTemp.toStringShort()
|
||||||
|
} else {
|
||||||
|
actions_settempbasal?.visibility = View.VISIBLE
|
||||||
|
actions_canceltempbasal?.visibility = View.GONE
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
actions_fill?.visibility =
|
||||||
|
if (!pump.pumpDescription.isRefillingCapable || !pump.isInitialized || pump.isSuspended) View.GONE
|
||||||
|
else View.VISIBLE
|
||||||
|
|
||||||
|
actions_temptarget?.visibility = if (!Config.APS) View.GONE else View.VISIBLE
|
||||||
|
actions_tddstats?.visibility = if (!pump.pumpDescription.supportsTDDs) View.GONE else View.VISIBLE
|
||||||
|
checkPumpCustomActions()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun checkPumpCustomActions() {
|
||||||
|
val activePump = ConfigBuilderPlugin.getPlugin().activePump ?: return
|
||||||
|
val customActions = activePump.customActions ?: return
|
||||||
|
removePumpCustomActions()
|
||||||
|
|
||||||
|
for (customAction in customActions) {
|
||||||
|
if (!customAction.isEnabled) continue
|
||||||
|
|
||||||
|
val btn = SingleClickButton(context, null, android.R.attr.buttonStyle)
|
||||||
|
btn.text = MainApp.gs(customAction.name)
|
||||||
|
|
||||||
|
val layoutParams = LinearLayout.LayoutParams(
|
||||||
|
LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT, 0.5f)
|
||||||
|
layoutParams.setMargins(20, 8, 20, 8) // 10,3,10,3
|
||||||
|
|
||||||
|
btn.layoutParams = layoutParams
|
||||||
|
btn.setOnClickListener { v ->
|
||||||
|
val b = v as SingleClickButton
|
||||||
|
val action = this.pumpCustomActions[b.text.toString()]
|
||||||
|
ConfigBuilderPlugin.getPlugin().activePump!!.executeCustomAction(action!!.customActionType)
|
||||||
|
}
|
||||||
|
|
||||||
|
val top = resources.getDrawable(customAction.iconResourceId)
|
||||||
|
btn.setCompoundDrawablesWithIntrinsicBounds(null, top, null, null)
|
||||||
|
|
||||||
|
action_buttons_layout?.addView(btn)
|
||||||
|
|
||||||
|
this.pumpCustomActions[MainApp.gs(customAction.name)] = customAction
|
||||||
|
this.pumpCustomButtons.add(btn)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun removePumpCustomActions() {
|
||||||
|
for (customButton in pumpCustomButtons) action_buttons_layout?.removeView(customButton)
|
||||||
|
pumpCustomButtons.clear()
|
||||||
|
}
|
||||||
|
}
|
|
@ -7,7 +7,7 @@ import info.nightscout.androidaps.interfaces.PluginType
|
||||||
|
|
||||||
object ActionsPlugin : PluginBase(PluginDescription()
|
object ActionsPlugin : PluginBase(PluginDescription()
|
||||||
.mainType(PluginType.GENERAL)
|
.mainType(PluginType.GENERAL)
|
||||||
.fragmentClass(ActionsFragment::class.java.name)
|
.fragmentClass(ActionsFragment::class.qualifiedName)
|
||||||
.pluginName(R.string.actions)
|
.pluginName(R.string.actions)
|
||||||
.shortName(R.string.actions_shortname)
|
.shortName(R.string.actions_shortname)
|
||||||
.description(R.string.description_actions))
|
.description(R.string.description_actions))
|
||||||
|
|
|
@ -35,11 +35,15 @@ import info.nightscout.androidaps.plugins.general.nsclient.events.EventNSClientN
|
||||||
import info.nightscout.androidaps.plugins.general.nsclient.events.EventNSClientStatus;
|
import info.nightscout.androidaps.plugins.general.nsclient.events.EventNSClientStatus;
|
||||||
import info.nightscout.androidaps.plugins.general.nsclient.events.EventNSClientUpdateGUI;
|
import info.nightscout.androidaps.plugins.general.nsclient.events.EventNSClientUpdateGUI;
|
||||||
import info.nightscout.androidaps.plugins.general.nsclient.services.NSClientService;
|
import info.nightscout.androidaps.plugins.general.nsclient.services.NSClientService;
|
||||||
|
import info.nightscout.androidaps.utils.FabricPrivacy;
|
||||||
import info.nightscout.androidaps.utils.SP;
|
import info.nightscout.androidaps.utils.SP;
|
||||||
import info.nightscout.androidaps.utils.ToastUtils;
|
import info.nightscout.androidaps.utils.ToastUtils;
|
||||||
|
import io.reactivex.disposables.CompositeDisposable;
|
||||||
|
import io.reactivex.schedulers.Schedulers;
|
||||||
|
|
||||||
public class NSClientPlugin extends PluginBase {
|
public class NSClientPlugin extends PluginBase {
|
||||||
private Logger log = LoggerFactory.getLogger(L.NSCLIENT);
|
private Logger log = LoggerFactory.getLogger(L.NSCLIENT);
|
||||||
|
private CompositeDisposable disposable = new CompositeDisposable();
|
||||||
|
|
||||||
static NSClientPlugin nsClientPlugin;
|
static NSClientPlugin nsClientPlugin;
|
||||||
|
|
||||||
|
@ -104,6 +108,14 @@ public class NSClientPlugin extends PluginBase {
|
||||||
super.onStart();
|
super.onStart();
|
||||||
|
|
||||||
nsClientReceiverDelegate.registerReceivers();
|
nsClientReceiverDelegate.registerReceivers();
|
||||||
|
disposable.add(RxBus.INSTANCE
|
||||||
|
.toObservable(EventNSClientStatus.class)
|
||||||
|
.observeOn(Schedulers.io())
|
||||||
|
.subscribe(event -> {
|
||||||
|
status = event.getStatus();
|
||||||
|
MainApp.bus().post(new EventNSClientUpdateGUI());
|
||||||
|
}, FabricPrivacy::logException)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -113,6 +125,7 @@ public class NSClientPlugin extends PluginBase {
|
||||||
context.unbindService(mConnection);
|
context.unbindService(mConnection);
|
||||||
|
|
||||||
nsClientReceiverDelegate.unregisterReceivers();
|
nsClientReceiverDelegate.unregisterReceivers();
|
||||||
|
disposable.clear();
|
||||||
super.onStop();
|
super.onStop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -164,12 +177,6 @@ public class NSClientPlugin extends PluginBase {
|
||||||
log.debug(ev.action + " " + ev.logText);
|
log.debug(ev.action + " " + ev.logText);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
|
||||||
public void onStatusEvent(final EventNSClientStatus ev) {
|
|
||||||
status = ev.status;
|
|
||||||
MainApp.bus().post(new EventNSClientUpdateGUI());
|
|
||||||
}
|
|
||||||
|
|
||||||
synchronized void clearLog() {
|
synchronized void clearLog() {
|
||||||
handler.post(() -> {
|
handler.post(() -> {
|
||||||
synchronized (listLog) {
|
synchronized (listLog) {
|
||||||
|
|
|
@ -1,18 +0,0 @@
|
||||||
package info.nightscout.androidaps.plugins.general.nsclient.events;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.events.Event;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by mike on 02.01.2016.
|
|
||||||
*/
|
|
||||||
public class EventNSClientStatus extends Event {
|
|
||||||
public String status = "";
|
|
||||||
|
|
||||||
public EventNSClientStatus(String status) {
|
|
||||||
this.status = status;
|
|
||||||
}
|
|
||||||
|
|
||||||
public EventNSClientStatus() {
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
package info.nightscout.androidaps.plugins.general.nsclient.events
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.events.EventStatus
|
||||||
|
|
||||||
|
class EventNSClientStatus(var text: String) : EventStatus() {
|
||||||
|
override fun getStatus(): String = text
|
||||||
|
}
|
|
@ -208,19 +208,19 @@ public class NSClientService extends Service {
|
||||||
if (!nsAPISecret.equals(""))
|
if (!nsAPISecret.equals(""))
|
||||||
nsAPIhashCode = Hashing.sha1().hashString(nsAPISecret, Charsets.UTF_8).toString();
|
nsAPIhashCode = Hashing.sha1().hashString(nsAPISecret, Charsets.UTF_8).toString();
|
||||||
|
|
||||||
MainApp.bus().post(new EventNSClientStatus("Initializing"));
|
RxBus.INSTANCE.send(new EventNSClientStatus("Initializing"));
|
||||||
if (!MainApp.getSpecificPlugin(NSClientPlugin.class).isAllowed()) {
|
if (!MainApp.getSpecificPlugin(NSClientPlugin.class).isAllowed()) {
|
||||||
MainApp.bus().post(new EventNSClientNewLog("NSCLIENT", "not allowed"));
|
MainApp.bus().post(new EventNSClientNewLog("NSCLIENT", "not allowed"));
|
||||||
MainApp.bus().post(new EventNSClientStatus("Not allowed"));
|
RxBus.INSTANCE.send(new EventNSClientStatus("Not allowed"));
|
||||||
} else if (MainApp.getSpecificPlugin(NSClientPlugin.class).paused) {
|
} else if (MainApp.getSpecificPlugin(NSClientPlugin.class).paused) {
|
||||||
MainApp.bus().post(new EventNSClientNewLog("NSCLIENT", "paused"));
|
MainApp.bus().post(new EventNSClientNewLog("NSCLIENT", "paused"));
|
||||||
MainApp.bus().post(new EventNSClientStatus("Paused"));
|
RxBus.INSTANCE.send(new EventNSClientStatus("Paused"));
|
||||||
} else if (!nsEnabled) {
|
} else if (!nsEnabled) {
|
||||||
MainApp.bus().post(new EventNSClientNewLog("NSCLIENT", "disabled"));
|
MainApp.bus().post(new EventNSClientNewLog("NSCLIENT", "disabled"));
|
||||||
MainApp.bus().post(new EventNSClientStatus("Disabled"));
|
RxBus.INSTANCE.send(new EventNSClientStatus("Disabled"));
|
||||||
} else if (!nsURL.equals("")) {
|
} else if (!nsURL.equals("")) {
|
||||||
try {
|
try {
|
||||||
MainApp.bus().post(new EventNSClientStatus("Connecting ..."));
|
RxBus.INSTANCE.send(new EventNSClientStatus("Connecting ..."));
|
||||||
IO.Options opt = new IO.Options();
|
IO.Options opt = new IO.Options();
|
||||||
opt.forceNew = true;
|
opt.forceNew = true;
|
||||||
opt.reconnection = true;
|
opt.reconnection = true;
|
||||||
|
@ -237,11 +237,11 @@ public class NSClientService extends Service {
|
||||||
mSocket.on("clear_alarm", onClearAlarm);
|
mSocket.on("clear_alarm", onClearAlarm);
|
||||||
} catch (URISyntaxException | RuntimeException e) {
|
} catch (URISyntaxException | RuntimeException e) {
|
||||||
MainApp.bus().post(new EventNSClientNewLog("NSCLIENT", "Wrong URL syntax"));
|
MainApp.bus().post(new EventNSClientNewLog("NSCLIENT", "Wrong URL syntax"));
|
||||||
MainApp.bus().post(new EventNSClientStatus("Wrong URL syntax"));
|
RxBus.INSTANCE.send(new EventNSClientStatus("Wrong URL syntax"));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
MainApp.bus().post(new EventNSClientNewLog("NSCLIENT", "No NS URL specified"));
|
MainApp.bus().post(new EventNSClientNewLog("NSCLIENT", "No NS URL specified"));
|
||||||
MainApp.bus().post(new EventNSClientStatus("Not configured"));
|
RxBus.INSTANCE.send(new EventNSClientStatus("Not configured"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -338,7 +338,7 @@ public class NSClientService extends Service {
|
||||||
connectionStatus += ')';
|
connectionStatus += ')';
|
||||||
isConnected = true;
|
isConnected = true;
|
||||||
hasWriteAuth = ack.write && ack.write_treatment;
|
hasWriteAuth = ack.write && ack.write_treatment;
|
||||||
MainApp.bus().post(new EventNSClientStatus(connectionStatus));
|
RxBus.INSTANCE.send(new EventNSClientStatus(connectionStatus));
|
||||||
MainApp.bus().post(new EventNSClientNewLog("AUTH", connectionStatus));
|
MainApp.bus().post(new EventNSClientNewLog("AUTH", connectionStatus));
|
||||||
if (!ack.write) {
|
if (!ack.write) {
|
||||||
MainApp.bus().post(new EventNSClientNewLog("ERROR", "Write permission not granted !!!!"));
|
MainApp.bus().post(new EventNSClientNewLog("ERROR", "Write permission not granted !!!!"));
|
||||||
|
|
|
@ -83,8 +83,11 @@ import info.nightscout.androidaps.logging.L;
|
||||||
import info.nightscout.androidaps.plugins.aps.loop.APSResult;
|
import info.nightscout.androidaps.plugins.aps.loop.APSResult;
|
||||||
import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin;
|
import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin;
|
||||||
import info.nightscout.androidaps.plugins.aps.loop.events.EventNewOpenLoopNotification;
|
import info.nightscout.androidaps.plugins.aps.loop.events.EventNewOpenLoopNotification;
|
||||||
|
import info.nightscout.androidaps.plugins.aps.openAPSMA.events.EventOpenAPSUpdateGui;
|
||||||
|
import info.nightscout.androidaps.plugins.bus.RxBus;
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
|
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctions;
|
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctions;
|
||||||
|
import info.nightscout.androidaps.plugins.general.automation.events.EventAutomationUpdateGui;
|
||||||
import info.nightscout.androidaps.plugins.general.careportal.CareportalFragment;
|
import info.nightscout.androidaps.plugins.general.careportal.CareportalFragment;
|
||||||
import info.nightscout.androidaps.plugins.general.careportal.Dialogs.NewNSTreatmentDialog;
|
import info.nightscout.androidaps.plugins.general.careportal.Dialogs.NewNSTreatmentDialog;
|
||||||
import info.nightscout.androidaps.plugins.general.careportal.OptionsToShow;
|
import info.nightscout.androidaps.plugins.general.careportal.OptionsToShow;
|
||||||
|
@ -113,18 +116,24 @@ import info.nightscout.androidaps.utils.BolusWizard;
|
||||||
import info.nightscout.androidaps.utils.DateUtil;
|
import info.nightscout.androidaps.utils.DateUtil;
|
||||||
import info.nightscout.androidaps.utils.DecimalFormatter;
|
import info.nightscout.androidaps.utils.DecimalFormatter;
|
||||||
import info.nightscout.androidaps.utils.DefaultValueHelper;
|
import info.nightscout.androidaps.utils.DefaultValueHelper;
|
||||||
|
import info.nightscout.androidaps.utils.FabricPrivacy;
|
||||||
import info.nightscout.androidaps.utils.OKDialog;
|
import info.nightscout.androidaps.utils.OKDialog;
|
||||||
import info.nightscout.androidaps.utils.Profiler;
|
import info.nightscout.androidaps.utils.Profiler;
|
||||||
import info.nightscout.androidaps.utils.SP;
|
import info.nightscout.androidaps.utils.SP;
|
||||||
import info.nightscout.androidaps.utils.SingleClickButton;
|
import info.nightscout.androidaps.utils.SingleClickButton;
|
||||||
import info.nightscout.androidaps.utils.T;
|
import info.nightscout.androidaps.utils.T;
|
||||||
import info.nightscout.androidaps.utils.ToastUtils;
|
import info.nightscout.androidaps.utils.ToastUtils;
|
||||||
|
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||||
|
import io.reactivex.disposables.CompositeDisposable;
|
||||||
|
import io.reactivex.schedulers.Schedulers;
|
||||||
|
|
||||||
import static info.nightscout.androidaps.utils.DateUtil.now;
|
import static info.nightscout.androidaps.utils.DateUtil.now;
|
||||||
|
|
||||||
public class OverviewFragment extends Fragment implements View.OnClickListener, View.OnLongClickListener {
|
public class OverviewFragment extends Fragment implements View.OnClickListener, View.OnLongClickListener {
|
||||||
private static Logger log = LoggerFactory.getLogger(L.OVERVIEW);
|
private static Logger log = LoggerFactory.getLogger(L.OVERVIEW);
|
||||||
|
|
||||||
|
private CompositeDisposable disposable = new CompositeDisposable();
|
||||||
|
|
||||||
TextView timeView;
|
TextView timeView;
|
||||||
TextView bgView;
|
TextView bgView;
|
||||||
TextView arrowView;
|
TextView arrowView;
|
||||||
|
@ -850,6 +859,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
public void onPause() {
|
public void onPause() {
|
||||||
super.onPause();
|
super.onPause();
|
||||||
MainApp.bus().unregister(this);
|
MainApp.bus().unregister(this);
|
||||||
|
disposable.clear();
|
||||||
sLoopHandler.removeCallbacksAndMessages(null);
|
sLoopHandler.removeCallbacksAndMessages(null);
|
||||||
unregisterForContextMenu(apsModeView);
|
unregisterForContextMenu(apsModeView);
|
||||||
unregisterForContextMenu(activeProfileView);
|
unregisterForContextMenu(activeProfileView);
|
||||||
|
@ -860,6 +870,42 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
MainApp.bus().register(this);
|
MainApp.bus().register(this);
|
||||||
|
disposable.add(RxBus.INSTANCE
|
||||||
|
.toObservable(EventRefreshOverview.class)
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.subscribe(eventOpenAPSUpdateGui -> scheduleUpdateGUI(eventOpenAPSUpdateGui.getFrom()),
|
||||||
|
FabricPrivacy::logException
|
||||||
|
));
|
||||||
|
disposable.add(RxBus.INSTANCE
|
||||||
|
.toObservable(EventExtendedBolusChange.class)
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.subscribe(event -> scheduleUpdateGUI("EventExtendedBolusChange"),
|
||||||
|
FabricPrivacy::logException
|
||||||
|
));
|
||||||
|
disposable.add(RxBus.INSTANCE
|
||||||
|
.toObservable(EventTempBasalChange.class)
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.subscribe(event -> scheduleUpdateGUI("EventTempBasalChange"),
|
||||||
|
FabricPrivacy::logException
|
||||||
|
));
|
||||||
|
disposable.add(RxBus.INSTANCE
|
||||||
|
.toObservable(EventTreatmentChange.class)
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.subscribe(event -> scheduleUpdateGUI("EventTreatmentChange"),
|
||||||
|
FabricPrivacy::logException
|
||||||
|
));
|
||||||
|
disposable.add(RxBus.INSTANCE
|
||||||
|
.toObservable(EventTempTargetChange.class)
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.subscribe(event -> scheduleUpdateGUI("EventTempTargetChange"),
|
||||||
|
FabricPrivacy::logException
|
||||||
|
));
|
||||||
|
disposable.add(RxBus.INSTANCE
|
||||||
|
.toObservable(EventPumpStatusChanged.class)
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.subscribe(event -> updatePumpStatus(event.getStatus()),
|
||||||
|
FabricPrivacy::logException
|
||||||
|
));
|
||||||
sRefreshLoop = () -> {
|
sRefreshLoop = () -> {
|
||||||
scheduleUpdateGUI("refreshLoop");
|
scheduleUpdateGUI("refreshLoop");
|
||||||
sLoopHandler.postDelayed(sRefreshLoop, 60 * 1000L);
|
sLoopHandler.postDelayed(sRefreshLoop, 60 * 1000L);
|
||||||
|
@ -881,36 +927,16 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
scheduleUpdateGUI("EventPreferenceChange");
|
scheduleUpdateGUI("EventPreferenceChange");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
|
||||||
public void onStatusEvent(final EventRefreshOverview ev) {
|
|
||||||
scheduleUpdateGUI(ev.from);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onStatusEvent(final EventAutosensCalculationFinished ev) {
|
public void onStatusEvent(final EventAutosensCalculationFinished ev) {
|
||||||
scheduleUpdateGUI("EventAutosensCalculationFinished");
|
scheduleUpdateGUI("EventAutosensCalculationFinished");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
|
||||||
public void onStatusEvent(final EventTreatmentChange ev) {
|
|
||||||
scheduleUpdateGUI("EventTreatmentChange");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onStatusEvent(final EventCareportalEventChange ev) {
|
public void onStatusEvent(final EventCareportalEventChange ev) {
|
||||||
scheduleUpdateGUI("EventCareportalEventChange");
|
scheduleUpdateGUI("EventCareportalEventChange");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
|
||||||
public void onStatusEvent(final EventTempBasalChange ev) {
|
|
||||||
scheduleUpdateGUI("EventTempBasalChange");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Subscribe
|
|
||||||
public void onStatusEvent(final EventExtendedBolusChange ev) {
|
|
||||||
scheduleUpdateGUI("EventExtendedBolusChange");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onStatusEvent(final EventNewOpenLoopNotification ev) {
|
public void onStatusEvent(final EventNewOpenLoopNotification ev) {
|
||||||
scheduleUpdateGUI("EventNewOpenLoopNotification");
|
scheduleUpdateGUI("EventNewOpenLoopNotification");
|
||||||
|
@ -921,23 +947,11 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
scheduleUpdateGUI("EventAcceptOpenLoopChange");
|
scheduleUpdateGUI("EventAcceptOpenLoopChange");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
|
||||||
public void onStatusEvent(final EventTempTargetChange ev) {
|
|
||||||
scheduleUpdateGUI("EventTempTargetChange");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onStatusEvent(final EventProfileNeedsUpdate ev) {
|
public void onStatusEvent(final EventProfileNeedsUpdate ev) {
|
||||||
scheduleUpdateGUI("EventProfileNeedsUpdate");
|
scheduleUpdateGUI("EventProfileNeedsUpdate");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
|
||||||
public void onStatusEvent(final EventPumpStatusChanged s) {
|
|
||||||
Activity activity = getActivity();
|
|
||||||
if (activity != null)
|
|
||||||
activity.runOnUiThread(() -> updatePumpStatus(s.textStatus()));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onStatusEvent(final EventIobCalculationProgress e) {
|
public void onStatusEvent(final EventIobCalculationProgress e) {
|
||||||
Activity activity = getActivity();
|
Activity activity = getActivity();
|
||||||
|
|
|
@ -45,7 +45,7 @@ object OverviewPlugin : PluginBase(PluginDescription()
|
||||||
.observeOn(Schedulers.io())
|
.observeOn(Schedulers.io())
|
||||||
.subscribe({ n ->
|
.subscribe({ n ->
|
||||||
if (notificationStore.add(n.notification))
|
if (notificationStore.add(n.notification))
|
||||||
MainApp.bus().post(EventRefreshOverview("EventNewNotification"))
|
RxBus.send(EventRefreshOverview("EventNewNotification"))
|
||||||
}, {
|
}, {
|
||||||
FabricPrivacy.logException(it)
|
FabricPrivacy.logException(it)
|
||||||
})
|
})
|
||||||
|
@ -54,7 +54,7 @@ object OverviewPlugin : PluginBase(PluginDescription()
|
||||||
.observeOn(Schedulers.io())
|
.observeOn(Schedulers.io())
|
||||||
.subscribe({ n ->
|
.subscribe({ n ->
|
||||||
if (notificationStore.remove(n.id))
|
if (notificationStore.remove(n.id))
|
||||||
MainApp.bus().post(EventRefreshOverview("EventDismissNotification"))
|
RxBus.send(EventRefreshOverview("EventDismissNotification"))
|
||||||
}, {
|
}, {
|
||||||
FabricPrivacy.logException(it)
|
FabricPrivacy.logException(it)
|
||||||
})
|
})
|
||||||
|
|
|
@ -23,12 +23,18 @@ import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.events.EventPumpStatusChanged;
|
import info.nightscout.androidaps.events.EventPumpStatusChanged;
|
||||||
import info.nightscout.androidaps.logging.L;
|
import info.nightscout.androidaps.logging.L;
|
||||||
|
import info.nightscout.androidaps.plugins.bus.RxBus;
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
|
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
|
||||||
import info.nightscout.androidaps.plugins.general.overview.events.EventDismissBolusprogressIfRunning;
|
import info.nightscout.androidaps.plugins.general.overview.events.EventDismissBolusprogressIfRunning;
|
||||||
import info.nightscout.androidaps.plugins.general.overview.events.EventOverviewBolusProgress;
|
import info.nightscout.androidaps.plugins.general.overview.events.EventOverviewBolusProgress;
|
||||||
|
import info.nightscout.androidaps.utils.FabricPrivacy;
|
||||||
|
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||||
|
import io.reactivex.disposables.CompositeDisposable;
|
||||||
|
|
||||||
public class BolusProgressDialog extends DialogFragment implements View.OnClickListener {
|
public class BolusProgressDialog extends DialogFragment implements View.OnClickListener {
|
||||||
private static Logger log = LoggerFactory.getLogger(L.UI);
|
private static Logger log = LoggerFactory.getLogger(L.UI);
|
||||||
|
private CompositeDisposable disposable = new CompositeDisposable();
|
||||||
|
|
||||||
Button stopButton;
|
Button stopButton;
|
||||||
TextView statusView;
|
TextView statusView;
|
||||||
TextView stopPressedView;
|
TextView stopPressedView;
|
||||||
|
@ -91,11 +97,12 @@ public class BolusProgressDialog extends DialogFragment implements View.OnClickL
|
||||||
if (L.isEnabled(L.UI))
|
if (L.isEnabled(L.UI))
|
||||||
log.debug("onResume running");
|
log.debug("onResume running");
|
||||||
}
|
}
|
||||||
try {
|
disposable.add(RxBus.INSTANCE
|
||||||
|
.toObservable(EventPumpStatusChanged.class)
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.subscribe(event -> statusView.setText(event.getStatus()), FabricPrivacy::logException)
|
||||||
|
);
|
||||||
MainApp.bus().register(this);
|
MainApp.bus().register(this);
|
||||||
} catch (IllegalArgumentException e) {
|
|
||||||
log.error("Already registered");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -121,11 +128,8 @@ public class BolusProgressDialog extends DialogFragment implements View.OnClickL
|
||||||
log.debug("onPause");
|
log.debug("onPause");
|
||||||
running = false;
|
running = false;
|
||||||
super.onPause();
|
super.onPause();
|
||||||
try {
|
|
||||||
MainApp.bus().unregister(this);
|
MainApp.bus().unregister(this);
|
||||||
} catch (IllegalArgumentException e) {
|
disposable.clear();
|
||||||
log.error("Already unregistered");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -176,16 +180,6 @@ public class BolusProgressDialog extends DialogFragment implements View.OnClickL
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
|
||||||
public void onStatusEvent(final EventPumpStatusChanged c) {
|
|
||||||
if (L.isEnabled(L.UI))
|
|
||||||
log.debug("EventPumpStatusChanged");
|
|
||||||
Activity activity = getActivity();
|
|
||||||
if (activity != null) {
|
|
||||||
activity.runOnUiThread(() -> statusView.setText(c.textStatus()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void scheduleDismiss() {
|
private void scheduleDismiss() {
|
||||||
if (L.isEnabled(L.UI))
|
if (L.isEnabled(L.UI))
|
||||||
log.debug("scheduleDismiss");
|
log.debug("scheduleDismiss");
|
||||||
|
|
|
@ -17,8 +17,6 @@ import androidx.core.app.TaskStackBuilder;
|
||||||
|
|
||||||
import com.squareup.otto.Subscribe;
|
import com.squareup.otto.Subscribe;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.Constants;
|
import info.nightscout.androidaps.Constants;
|
||||||
import info.nightscout.androidaps.MainActivity;
|
import info.nightscout.androidaps.MainActivity;
|
||||||
import info.nightscout.androidaps.MainApp;
|
import info.nightscout.androidaps.MainApp;
|
||||||
|
@ -37,6 +35,7 @@ import info.nightscout.androidaps.events.EventTreatmentChange;
|
||||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||||
import info.nightscout.androidaps.interfaces.PluginDescription;
|
import info.nightscout.androidaps.interfaces.PluginDescription;
|
||||||
import info.nightscout.androidaps.interfaces.PluginType;
|
import info.nightscout.androidaps.interfaces.PluginType;
|
||||||
|
import info.nightscout.androidaps.plugins.bus.RxBus;
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
|
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctions;
|
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctions;
|
||||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatus;
|
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatus;
|
||||||
|
@ -44,6 +43,9 @@ import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorP
|
||||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventAutosensCalculationFinished;
|
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventAutosensCalculationFinished;
|
||||||
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin;
|
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin;
|
||||||
import info.nightscout.androidaps.utils.DecimalFormatter;
|
import info.nightscout.androidaps.utils.DecimalFormatter;
|
||||||
|
import info.nightscout.androidaps.utils.FabricPrivacy;
|
||||||
|
import io.reactivex.disposables.CompositeDisposable;
|
||||||
|
import io.reactivex.schedulers.Schedulers;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by adrian on 23/12/16.
|
* Created by adrian on 23/12/16.
|
||||||
|
@ -51,6 +53,8 @@ import info.nightscout.androidaps.utils.DecimalFormatter;
|
||||||
|
|
||||||
public class PersistentNotificationPlugin extends PluginBase {
|
public class PersistentNotificationPlugin extends PluginBase {
|
||||||
|
|
||||||
|
private CompositeDisposable disposable = new CompositeDisposable();
|
||||||
|
|
||||||
private static PersistentNotificationPlugin plugin;
|
private static PersistentNotificationPlugin plugin;
|
||||||
private Notification notification;
|
private Notification notification;
|
||||||
|
|
||||||
|
@ -92,6 +96,30 @@ public class PersistentNotificationPlugin extends PluginBase {
|
||||||
super.onStart();
|
super.onStart();
|
||||||
createNotificationChannel(); // make sure channels exist before triggering updates through the bus
|
createNotificationChannel(); // make sure channels exist before triggering updates through the bus
|
||||||
MainApp.bus().register(this);
|
MainApp.bus().register(this);
|
||||||
|
disposable.add(RxBus.INSTANCE
|
||||||
|
.toObservable(EventRefreshOverview.class)
|
||||||
|
.observeOn(Schedulers.io())
|
||||||
|
.subscribe(event -> triggerNotificationUpdate(false),
|
||||||
|
FabricPrivacy::logException
|
||||||
|
));
|
||||||
|
disposable.add(RxBus.INSTANCE
|
||||||
|
.toObservable(EventExtendedBolusChange.class)
|
||||||
|
.observeOn(Schedulers.io())
|
||||||
|
.subscribe(event -> triggerNotificationUpdate(false),
|
||||||
|
FabricPrivacy::logException
|
||||||
|
));
|
||||||
|
disposable.add(RxBus.INSTANCE
|
||||||
|
.toObservable(EventTempBasalChange.class)
|
||||||
|
.observeOn(Schedulers.io())
|
||||||
|
.subscribe(event -> triggerNotificationUpdate(false),
|
||||||
|
FabricPrivacy::logException
|
||||||
|
));
|
||||||
|
disposable.add(RxBus.INSTANCE
|
||||||
|
.toObservable(EventTreatmentChange.class)
|
||||||
|
.observeOn(Schedulers.io())
|
||||||
|
.subscribe(event -> triggerNotificationUpdate(false),
|
||||||
|
FabricPrivacy::logException
|
||||||
|
));
|
||||||
triggerNotificationUpdate(true);
|
triggerNotificationUpdate(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -110,6 +138,7 @@ public class PersistentNotificationPlugin extends PluginBase {
|
||||||
@Override
|
@Override
|
||||||
protected void onStop() {
|
protected void onStop() {
|
||||||
MainApp.bus().unregister(this);
|
MainApp.bus().unregister(this);
|
||||||
|
disposable.clear();
|
||||||
MainApp.instance().stopService(new Intent(MainApp.instance(), DummyService.class));
|
MainApp.instance().stopService(new Intent(MainApp.instance(), DummyService.class));
|
||||||
super.onStop();
|
super.onStop();
|
||||||
}
|
}
|
||||||
|
@ -292,21 +321,6 @@ public class PersistentNotificationPlugin extends PluginBase {
|
||||||
triggerNotificationUpdate(false);
|
triggerNotificationUpdate(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
|
||||||
public void onStatusEvent(final EventTreatmentChange ev) {
|
|
||||||
triggerNotificationUpdate(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Subscribe
|
|
||||||
public void onStatusEvent(final EventTempBasalChange ev) {
|
|
||||||
triggerNotificationUpdate(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Subscribe
|
|
||||||
public void onStatusEvent(final EventExtendedBolusChange ev) {
|
|
||||||
triggerNotificationUpdate(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onStatusEvent(final EventAutosensCalculationFinished ev) {
|
public void onStatusEvent(final EventAutosensCalculationFinished ev) {
|
||||||
triggerNotificationUpdate(false);
|
triggerNotificationUpdate(false);
|
||||||
|
@ -322,9 +336,4 @@ public class PersistentNotificationPlugin extends PluginBase {
|
||||||
triggerNotificationUpdate(false);
|
triggerNotificationUpdate(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
|
||||||
public void onStatusEvent(final EventRefreshOverview ev) {
|
|
||||||
triggerNotificationUpdate(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -309,7 +309,7 @@ public class SmsCommunicatorPlugin extends PluginBase {
|
||||||
ConfigBuilderPlugin.getPlugin().getCommandQueue().cancelTempBasal(true, new Callback() {
|
ConfigBuilderPlugin.getPlugin().getCommandQueue().cancelTempBasal(true, new Callback() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
MainApp.bus().post(new EventRefreshOverview("SMS_LOOP_STOP"));
|
RxBus.INSTANCE.send(new EventRefreshOverview("SMS_LOOP_STOP"));
|
||||||
String reply = MainApp.gs(R.string.smscommunicator_loophasbeendisabled) + " " +
|
String reply = MainApp.gs(R.string.smscommunicator_loophasbeendisabled) + " " +
|
||||||
MainApp.gs(result.success ? R.string.smscommunicator_tempbasalcanceled : R.string.smscommunicator_tempbasalcancelfailed);
|
MainApp.gs(result.success ? R.string.smscommunicator_tempbasalcanceled : R.string.smscommunicator_tempbasalcancelfailed);
|
||||||
sendSMS(new Sms(receivedSms.phoneNumber, reply));
|
sendSMS(new Sms(receivedSms.phoneNumber, reply));
|
||||||
|
@ -326,7 +326,7 @@ public class SmsCommunicatorPlugin extends PluginBase {
|
||||||
if (loopPlugin != null && !loopPlugin.isEnabled(PluginType.LOOP)) {
|
if (loopPlugin != null && !loopPlugin.isEnabled(PluginType.LOOP)) {
|
||||||
loopPlugin.setPluginEnabled(PluginType.LOOP, true);
|
loopPlugin.setPluginEnabled(PluginType.LOOP, true);
|
||||||
sendSMS(new Sms(receivedSms.phoneNumber, R.string.smscommunicator_loophasbeenenabled));
|
sendSMS(new Sms(receivedSms.phoneNumber, R.string.smscommunicator_loophasbeenenabled));
|
||||||
MainApp.bus().post(new EventRefreshOverview("SMS_LOOP_START"));
|
RxBus.INSTANCE.send(new EventRefreshOverview("SMS_LOOP_START"));
|
||||||
} else {
|
} else {
|
||||||
sendSMS(new Sms(receivedSms.phoneNumber, R.string.smscommunicator_loopisenabled));
|
sendSMS(new Sms(receivedSms.phoneNumber, R.string.smscommunicator_loopisenabled));
|
||||||
}
|
}
|
||||||
|
@ -349,7 +349,7 @@ public class SmsCommunicatorPlugin extends PluginBase {
|
||||||
break;
|
break;
|
||||||
case "RESUME":
|
case "RESUME":
|
||||||
LoopPlugin.getPlugin().suspendTo(0);
|
LoopPlugin.getPlugin().suspendTo(0);
|
||||||
MainApp.bus().post(new EventRefreshOverview("SMS_LOOP_RESUME"));
|
RxBus.INSTANCE.send(new EventRefreshOverview("SMS_LOOP_RESUME"));
|
||||||
NSUpload.uploadOpenAPSOffline(0);
|
NSUpload.uploadOpenAPSOffline(0);
|
||||||
sendSMSToAllNumbers(new Sms(receivedSms.phoneNumber, R.string.smscommunicator_loopresumed));
|
sendSMSToAllNumbers(new Sms(receivedSms.phoneNumber, R.string.smscommunicator_loopresumed));
|
||||||
break;
|
break;
|
||||||
|
@ -376,7 +376,7 @@ public class SmsCommunicatorPlugin extends PluginBase {
|
||||||
if (result.success) {
|
if (result.success) {
|
||||||
LoopPlugin.getPlugin().suspendTo(System.currentTimeMillis() + anInteger * 60L * 1000);
|
LoopPlugin.getPlugin().suspendTo(System.currentTimeMillis() + anInteger * 60L * 1000);
|
||||||
NSUpload.uploadOpenAPSOffline(anInteger * 60);
|
NSUpload.uploadOpenAPSOffline(anInteger * 60);
|
||||||
MainApp.bus().post(new EventRefreshOverview("SMS_LOOP_SUSPENDED"));
|
RxBus.INSTANCE.send(new EventRefreshOverview("SMS_LOOP_SUSPENDED"));
|
||||||
String reply = MainApp.gs(R.string.smscommunicator_loopsuspended) + " " +
|
String reply = MainApp.gs(R.string.smscommunicator_loopsuspended) + " " +
|
||||||
MainApp.gs(result.success ? R.string.smscommunicator_tempbasalcanceled : R.string.smscommunicator_tempbasalcancelfailed);
|
MainApp.gs(result.success ? R.string.smscommunicator_tempbasalcanceled : R.string.smscommunicator_tempbasalcancelfailed);
|
||||||
sendSMSToAllNumbers(new Sms(receivedSms.phoneNumber, reply));
|
sendSMSToAllNumbers(new Sms(receivedSms.phoneNumber, reply));
|
||||||
|
|
|
@ -82,7 +82,34 @@ public class WearPlugin extends PluginBase {
|
||||||
.toObservable(EventOpenAPSUpdateGui.class)
|
.toObservable(EventOpenAPSUpdateGui.class)
|
||||||
.observeOn(Schedulers.io())
|
.observeOn(Schedulers.io())
|
||||||
.subscribe(eventOpenAPSUpdateGui -> sendDataToWatch(true, true, false),
|
.subscribe(eventOpenAPSUpdateGui -> sendDataToWatch(true, true, false),
|
||||||
error -> FabricPrivacy.logException(error)
|
FabricPrivacy::logException
|
||||||
|
));
|
||||||
|
disposable.add(RxBus.INSTANCE
|
||||||
|
.toObservable(EventExtendedBolusChange.class)
|
||||||
|
.observeOn(Schedulers.io())
|
||||||
|
.subscribe(eventOpenAPSUpdateGui -> sendDataToWatch(true, true, false),
|
||||||
|
FabricPrivacy::logException
|
||||||
|
));
|
||||||
|
disposable.add(RxBus.INSTANCE
|
||||||
|
.toObservable(EventTempBasalChange.class)
|
||||||
|
.observeOn(Schedulers.io())
|
||||||
|
.subscribe(eventOpenAPSUpdateGui -> sendDataToWatch(true, true, false),
|
||||||
|
FabricPrivacy::logException
|
||||||
|
));
|
||||||
|
disposable.add(RxBus.INSTANCE
|
||||||
|
.toObservable(EventTreatmentChange.class)
|
||||||
|
.observeOn(Schedulers.io())
|
||||||
|
.subscribe(eventOpenAPSUpdateGui -> sendDataToWatch(true, true, false),
|
||||||
|
FabricPrivacy::logException
|
||||||
|
));
|
||||||
|
disposable.add(RxBus.INSTANCE
|
||||||
|
.toObservable(EventRefreshOverview.class)
|
||||||
|
.observeOn(Schedulers.io())
|
||||||
|
.subscribe(event -> {
|
||||||
|
if (WatchUpdaterService.shouldReportLoopStatus(LoopPlugin.getPlugin().isEnabled(PluginType.LOOP)))
|
||||||
|
sendDataToWatch(true, false, false);
|
||||||
|
},
|
||||||
|
FabricPrivacy::logException
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -142,21 +169,6 @@ public class WearPlugin extends PluginBase {
|
||||||
sendDataToWatch(true, false, false);
|
sendDataToWatch(true, false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
|
||||||
public void onStatusEvent(final EventTreatmentChange ev) {
|
|
||||||
sendDataToWatch(true, true, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Subscribe
|
|
||||||
public void onStatusEvent(final EventTempBasalChange ev) {
|
|
||||||
sendDataToWatch(true, true, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Subscribe
|
|
||||||
public void onStatusEvent(final EventExtendedBolusChange ev) {
|
|
||||||
sendDataToWatch(true, true, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onStatusEvent(final EventAutosensCalculationFinished ev) {
|
public void onStatusEvent(final EventAutosensCalculationFinished ev) {
|
||||||
sendDataToWatch(true, true, true);
|
sendDataToWatch(true, true, true);
|
||||||
|
@ -167,14 +179,6 @@ public class WearPlugin extends PluginBase {
|
||||||
sendDataToWatch(false, true, false);
|
sendDataToWatch(false, true, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
|
||||||
public void onStatusEvent(final EventRefreshOverview ev) {
|
|
||||||
if (WatchUpdaterService.shouldReportLoopStatus(LoopPlugin.getPlugin().isEnabled(PluginType.LOOP))) {
|
|
||||||
sendDataToWatch(true, false, false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onStatusEvent(final EventOverviewBolusProgress ev) {
|
public void onStatusEvent(final EventOverviewBolusProgress ev) {
|
||||||
if (!ev.isSMB() || SP.getBoolean("wear_notifySMB", true)) {
|
if (!ev.isSMB() || SP.getBoolean("wear_notifySMB", true)) {
|
||||||
|
|
|
@ -5,6 +5,7 @@ import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
import com.squareup.otto.Subscribe;
|
import com.squareup.otto.Subscribe;
|
||||||
|
@ -26,12 +27,16 @@ import info.nightscout.androidaps.interfaces.PluginDescription;
|
||||||
import info.nightscout.androidaps.interfaces.PluginType;
|
import info.nightscout.androidaps.interfaces.PluginType;
|
||||||
import info.nightscout.androidaps.interfaces.TreatmentsInterface;
|
import info.nightscout.androidaps.interfaces.TreatmentsInterface;
|
||||||
import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin;
|
import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin;
|
||||||
|
import info.nightscout.androidaps.plugins.bus.RxBus;
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
|
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctions;
|
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctions;
|
||||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin;
|
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin;
|
||||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventAutosensCalculationFinished;
|
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventAutosensCalculationFinished;
|
||||||
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin;
|
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin;
|
||||||
import info.nightscout.androidaps.utils.DecimalFormatter;
|
import info.nightscout.androidaps.utils.DecimalFormatter;
|
||||||
|
import info.nightscout.androidaps.utils.FabricPrivacy;
|
||||||
|
import io.reactivex.disposables.CompositeDisposable;
|
||||||
|
import io.reactivex.schedulers.Schedulers;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by adrian on 17/11/16.
|
* Created by adrian on 17/11/16.
|
||||||
|
@ -39,6 +44,8 @@ import info.nightscout.androidaps.utils.DecimalFormatter;
|
||||||
|
|
||||||
public class StatuslinePlugin extends PluginBase {
|
public class StatuslinePlugin extends PluginBase {
|
||||||
|
|
||||||
|
private CompositeDisposable disposable = new CompositeDisposable();
|
||||||
|
|
||||||
private static StatuslinePlugin statuslinePlugin;
|
private static StatuslinePlugin statuslinePlugin;
|
||||||
|
|
||||||
public static StatuslinePlugin getPlugin() {
|
public static StatuslinePlugin getPlugin() {
|
||||||
|
@ -80,14 +87,42 @@ public class StatuslinePlugin extends PluginBase {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStart() {
|
protected void onStart() {
|
||||||
MainApp.bus().register(this);
|
|
||||||
super.onStart();
|
super.onStart();
|
||||||
|
MainApp.bus().register(this);
|
||||||
|
disposable.add(RxBus.INSTANCE
|
||||||
|
.toObservable(EventRefreshOverview.class)
|
||||||
|
.observeOn(Schedulers.io())
|
||||||
|
.subscribe(event -> {
|
||||||
|
if ((lastLoopStatus != LoopPlugin.getPlugin().isEnabled(PluginType.LOOP)))
|
||||||
|
sendStatus();
|
||||||
|
},
|
||||||
|
FabricPrivacy::logException
|
||||||
|
));
|
||||||
|
disposable.add(RxBus.INSTANCE
|
||||||
|
.toObservable(EventExtendedBolusChange.class)
|
||||||
|
.observeOn(Schedulers.io())
|
||||||
|
.subscribe(event -> sendStatus(),
|
||||||
|
FabricPrivacy::logException
|
||||||
|
));
|
||||||
|
disposable.add(RxBus.INSTANCE
|
||||||
|
.toObservable(EventTempBasalChange.class)
|
||||||
|
.observeOn(Schedulers.io())
|
||||||
|
.subscribe(event -> sendStatus(),
|
||||||
|
FabricPrivacy::logException
|
||||||
|
));
|
||||||
|
disposable.add(RxBus.INSTANCE
|
||||||
|
.toObservable(EventTreatmentChange.class)
|
||||||
|
.observeOn(Schedulers.io())
|
||||||
|
.subscribe(event -> sendStatus(),
|
||||||
|
FabricPrivacy::logException
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStop() {
|
protected void onStop() {
|
||||||
super.onStop();
|
super.onStop();
|
||||||
MainApp.bus().unregister(this);
|
MainApp.bus().unregister(this);
|
||||||
|
disposable.clear();
|
||||||
sendStatus();
|
sendStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -166,21 +201,6 @@ public class StatuslinePlugin extends PluginBase {
|
||||||
sendStatus();
|
sendStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
|
||||||
public void onStatusEvent(final EventTreatmentChange ev) {
|
|
||||||
sendStatus();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Subscribe
|
|
||||||
public void onStatusEvent(final EventTempBasalChange ev) {
|
|
||||||
sendStatus();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Subscribe
|
|
||||||
public void onStatusEvent(final EventExtendedBolusChange ev) {
|
|
||||||
sendStatus();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onStatusEvent(final EventAutosensCalculationFinished ev) {
|
public void onStatusEvent(final EventAutosensCalculationFinished ev) {
|
||||||
sendStatus();
|
sendStatus();
|
||||||
|
@ -196,12 +216,4 @@ public class StatuslinePlugin extends PluginBase {
|
||||||
sendStatus();
|
sendStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
|
||||||
public void onStatusEvent(final EventRefreshOverview ev) {
|
|
||||||
//Filter events where loop is (de)activated
|
|
||||||
if ((lastLoopStatus != LoopPlugin.getPlugin().isEnabled(PluginType.LOOP))) {
|
|
||||||
sendStatus();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -376,6 +376,7 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint
|
||||||
|
|
||||||
pump.initialized = true;
|
pump.initialized = true;
|
||||||
MainApp.bus().post(new EventInitializationChanged());
|
MainApp.bus().post(new EventInitializationChanged());
|
||||||
|
RxBus.INSTANCE.send(new EventInitializationChanged());
|
||||||
|
|
||||||
// show notification to check pump date if last bolus is older than 24 hours
|
// show notification to check pump date if last bolus is older than 24 hours
|
||||||
// or is in the future
|
// or is in the future
|
||||||
|
|
|
@ -87,6 +87,30 @@ class DanaRFragment : Fragment() {
|
||||||
.toObservable(EventDanaRNewStatus::class.java)
|
.toObservable(EventDanaRNewStatus::class.java)
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.subscribe({ updateGUI() }, { FabricPrivacy.logException(it) })
|
.subscribe({ updateGUI() }, { FabricPrivacy.logException(it) })
|
||||||
|
disposable += RxBus
|
||||||
|
.toObservable(EventExtendedBolusChange::class.java)
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.subscribe({ updateGUI() }, { FabricPrivacy.logException(it) })
|
||||||
|
disposable += RxBus
|
||||||
|
.toObservable(EventTempBasalChange::class.java)
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.subscribe({ updateGUI() }, { FabricPrivacy.logException(it) })
|
||||||
|
disposable += RxBus
|
||||||
|
.toObservable(EventPumpStatusChanged::class.java)
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.subscribe({
|
||||||
|
when {
|
||||||
|
it.sStatus == EventPumpStatusChanged.Status.CONNECTING -> danar_btconnection?.text = "{fa-bluetooth-b spin} " + it.sSecondsElapsed + "s"
|
||||||
|
it.sStatus == EventPumpStatusChanged.Status.CONNECTED -> danar_btconnection?.text = "{fa-bluetooth}"
|
||||||
|
it.sStatus == EventPumpStatusChanged.Status.DISCONNECTED -> danar_btconnection?.text = "{fa-bluetooth-b}"
|
||||||
|
}
|
||||||
|
if (it.getStatus() != "") {
|
||||||
|
dana_pumpstatus?.text = it.getStatus()
|
||||||
|
dana_pumpstatuslayout?.visibility = View.VISIBLE
|
||||||
|
} else {
|
||||||
|
dana_pumpstatuslayout?.visibility = View.GONE
|
||||||
|
}
|
||||||
|
}, { FabricPrivacy.logException(it) })
|
||||||
updateGUI()
|
updateGUI()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,33 +122,6 @@ class DanaRFragment : Fragment() {
|
||||||
loopHandler.removeCallbacks(refreshLoop)
|
loopHandler.removeCallbacks(refreshLoop)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
|
||||||
fun onStatusEvent(c: EventPumpStatusChanged) {
|
|
||||||
activity?.runOnUiThread {
|
|
||||||
when {
|
|
||||||
c.sStatus == EventPumpStatusChanged.CONNECTING -> danar_btconnection?.text = "{fa-bluetooth-b spin} " + c.sSecondsElapsed + "s"
|
|
||||||
c.sStatus == EventPumpStatusChanged.CONNECTED -> danar_btconnection?.text = "{fa-bluetooth}"
|
|
||||||
c.sStatus == EventPumpStatusChanged.DISCONNECTED -> danar_btconnection?.text = "{fa-bluetooth-b}"
|
|
||||||
}
|
|
||||||
if (c.textStatus() != "") {
|
|
||||||
dana_pumpstatus?.text = c.textStatus()
|
|
||||||
dana_pumpstatuslayout?.visibility = View.VISIBLE
|
|
||||||
} else {
|
|
||||||
dana_pumpstatuslayout?.visibility = View.GONE
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Subscribe
|
|
||||||
fun onStatusEvent(s: EventTempBasalChange) =
|
|
||||||
activity?.runOnUiThread { updateGUI() }
|
|
||||||
|
|
||||||
|
|
||||||
@Subscribe
|
|
||||||
fun onStatusEvent(s: EventExtendedBolusChange) =
|
|
||||||
activity?.runOnUiThread { updateGUI() }
|
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
fun onStatusEvent(s: EventQueueChanged) =
|
fun onStatusEvent(s: EventQueueChanged) =
|
||||||
activity?.runOnUiThread { updateGUI() }
|
activity?.runOnUiThread { updateGUI() }
|
||||||
|
|
|
@ -32,6 +32,7 @@ import info.nightscout.androidaps.db.DanaRHistoryRecord;
|
||||||
import info.nightscout.androidaps.events.EventPumpStatusChanged;
|
import info.nightscout.androidaps.events.EventPumpStatusChanged;
|
||||||
import info.nightscout.androidaps.interfaces.PluginType;
|
import info.nightscout.androidaps.interfaces.PluginType;
|
||||||
import info.nightscout.androidaps.logging.L;
|
import info.nightscout.androidaps.logging.L;
|
||||||
|
import info.nightscout.androidaps.plugins.bus.RxBus;
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
|
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctions;
|
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctions;
|
||||||
import info.nightscout.androidaps.plugins.pump.danaR.comm.RecordTypes;
|
import info.nightscout.androidaps.plugins.pump.danaR.comm.RecordTypes;
|
||||||
|
@ -41,10 +42,14 @@ import info.nightscout.androidaps.plugins.pump.danaRS.DanaRSPlugin;
|
||||||
import info.nightscout.androidaps.queue.Callback;
|
import info.nightscout.androidaps.queue.Callback;
|
||||||
import info.nightscout.androidaps.utils.DateUtil;
|
import info.nightscout.androidaps.utils.DateUtil;
|
||||||
import info.nightscout.androidaps.utils.DecimalFormatter;
|
import info.nightscout.androidaps.utils.DecimalFormatter;
|
||||||
|
import info.nightscout.androidaps.utils.FabricPrivacy;
|
||||||
import info.nightscout.androidaps.utils.ToastUtils;
|
import info.nightscout.androidaps.utils.ToastUtils;
|
||||||
|
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||||
|
import io.reactivex.disposables.CompositeDisposable;
|
||||||
|
|
||||||
public class DanaRHistoryActivity extends NoSplashActivity {
|
public class DanaRHistoryActivity extends NoSplashActivity {
|
||||||
private static Logger log = LoggerFactory.getLogger(L.PUMP);
|
private static Logger log = LoggerFactory.getLogger(L.PUMP);
|
||||||
|
private CompositeDisposable disposable = new CompositeDisposable();
|
||||||
|
|
||||||
static Profile profile = null;
|
static Profile profile = null;
|
||||||
|
|
||||||
|
@ -82,12 +87,18 @@ public class DanaRHistoryActivity extends NoSplashActivity {
|
||||||
protected void onResume() {
|
protected void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
MainApp.bus().register(this);
|
MainApp.bus().register(this);
|
||||||
|
disposable.add(RxBus.INSTANCE
|
||||||
|
.toObservable(EventPumpStatusChanged.class)
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.subscribe(event -> statusView.setText(event.getStatus()), FabricPrivacy::logException)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPause() {
|
protected void onPause() {
|
||||||
super.onPause();
|
super.onPause();
|
||||||
MainApp.bus().unregister(this);
|
MainApp.bus().unregister(this);
|
||||||
|
disposable.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -325,12 +336,4 @@ public class DanaRHistoryActivity extends NoSplashActivity {
|
||||||
() -> statusView.setText(s.message));
|
() -> statusView.setText(s.message));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
|
||||||
public void onStatusEvent(final EventPumpStatusChanged s) {
|
|
||||||
runOnUiThread(
|
|
||||||
() -> statusView.setText(s.textStatus())
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,7 @@ import info.nightscout.androidaps.data.Profile;
|
||||||
import info.nightscout.androidaps.data.PumpEnactResult;
|
import info.nightscout.androidaps.data.PumpEnactResult;
|
||||||
import info.nightscout.androidaps.events.EventPumpStatusChanged;
|
import info.nightscout.androidaps.events.EventPumpStatusChanged;
|
||||||
import info.nightscout.androidaps.logging.L;
|
import info.nightscout.androidaps.logging.L;
|
||||||
|
import info.nightscout.androidaps.plugins.bus.RxBus;
|
||||||
import info.nightscout.androidaps.plugins.pump.danaR.comm.MessageBase;
|
import info.nightscout.androidaps.plugins.pump.danaR.comm.MessageBase;
|
||||||
import info.nightscout.androidaps.plugins.pump.danaR.comm.MsgBolusStop;
|
import info.nightscout.androidaps.plugins.pump.danaR.comm.MsgBolusStop;
|
||||||
import info.nightscout.androidaps.plugins.pump.danaR.comm.MsgHistoryAlarm;
|
import info.nightscout.androidaps.plugins.pump.danaR.comm.MsgHistoryAlarm;
|
||||||
|
@ -105,7 +106,7 @@ public abstract class AbstractDanaRExecutionService extends Service {
|
||||||
if (mSerialIOThread != null) {
|
if (mSerialIOThread != null) {
|
||||||
mSerialIOThread.disconnect("BT disconnection broadcast");
|
mSerialIOThread.disconnect("BT disconnection broadcast");
|
||||||
}
|
}
|
||||||
MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.DISCONNECTED));
|
RxBus.INSTANCE.send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTED));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -135,7 +136,7 @@ public abstract class AbstractDanaRExecutionService extends Service {
|
||||||
|
|
||||||
public void finishHandshaking() {
|
public void finishHandshaking() {
|
||||||
mHandshakeInProgress = false;
|
mHandshakeInProgress = false;
|
||||||
MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.CONNECTED, 0));
|
RxBus.INSTANCE.send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.CONNECTED, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void disconnect(String from) {
|
public void disconnect(String from) {
|
||||||
|
@ -243,7 +244,7 @@ public abstract class AbstractDanaRExecutionService extends Service {
|
||||||
long timeToWholeMinute = (60000 - time % 60000);
|
long timeToWholeMinute = (60000 - time % 60000);
|
||||||
if (timeToWholeMinute > 59800 || timeToWholeMinute < 3000)
|
if (timeToWholeMinute > 59800 || timeToWholeMinute < 3000)
|
||||||
break;
|
break;
|
||||||
MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.waitingfortimesynchronization, (int) (timeToWholeMinute / 1000))));
|
RxBus.INSTANCE.send(new EventPumpStatusChanged(MainApp.gs(R.string.waitingfortimesynchronization, (int) (timeToWholeMinute / 1000))));
|
||||||
SystemClock.sleep(Math.min(timeToWholeMinute, 100));
|
SystemClock.sleep(Math.min(timeToWholeMinute, 100));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -127,7 +127,7 @@ public class DanaRExecutionService extends AbstractDanaRExecutionService {
|
||||||
}
|
}
|
||||||
mSerialIOThread = new SerialIOThread(mRfcommSocket, MessageHashTableR.INSTANCE);
|
mSerialIOThread = new SerialIOThread(mRfcommSocket, MessageHashTableR.INSTANCE);
|
||||||
mHandshakeInProgress = true;
|
mHandshakeInProgress = true;
|
||||||
MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.HANDSHAKING, 0));
|
RxBus.INSTANCE.send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.HANDSHAKING, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
mConnectionInProgress = false;
|
mConnectionInProgress = false;
|
||||||
|
@ -137,7 +137,7 @@ public class DanaRExecutionService extends AbstractDanaRExecutionService {
|
||||||
public void getPumpStatus() {
|
public void getPumpStatus() {
|
||||||
DanaRPump danaRPump = DanaRPump.getInstance();
|
DanaRPump danaRPump = DanaRPump.getInstance();
|
||||||
try {
|
try {
|
||||||
MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.gettingpumpstatus)));
|
RxBus.INSTANCE.send(new EventPumpStatusChanged(MainApp.gs(R.string.gettingpumpstatus)));
|
||||||
MsgStatus statusMsg = new MsgStatus();
|
MsgStatus statusMsg = new MsgStatus();
|
||||||
MsgStatusBasic statusBasicMsg = new MsgStatusBasic();
|
MsgStatusBasic statusBasicMsg = new MsgStatusBasic();
|
||||||
MsgStatusTempBasal tempStatusMsg = new MsgStatusTempBasal();
|
MsgStatusTempBasal tempStatusMsg = new MsgStatusTempBasal();
|
||||||
|
@ -153,11 +153,11 @@ public class DanaRExecutionService extends AbstractDanaRExecutionService {
|
||||||
|
|
||||||
mSerialIOThread.sendMessage(statusMsg);
|
mSerialIOThread.sendMessage(statusMsg);
|
||||||
mSerialIOThread.sendMessage(statusBasicMsg);
|
mSerialIOThread.sendMessage(statusBasicMsg);
|
||||||
MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.gettingtempbasalstatus)));
|
RxBus.INSTANCE.send(new EventPumpStatusChanged(MainApp.gs(R.string.gettingtempbasalstatus)));
|
||||||
mSerialIOThread.sendMessage(tempStatusMsg);
|
mSerialIOThread.sendMessage(tempStatusMsg);
|
||||||
MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.gettingextendedbolusstatus)));
|
RxBus.INSTANCE.send(new EventPumpStatusChanged(MainApp.gs(R.string.gettingextendedbolusstatus)));
|
||||||
mSerialIOThread.sendMessage(exStatusMsg);
|
mSerialIOThread.sendMessage(exStatusMsg);
|
||||||
MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.gettingbolusstatus)));
|
RxBus.INSTANCE.send(new EventPumpStatusChanged(MainApp.gs(R.string.gettingbolusstatus)));
|
||||||
|
|
||||||
long now = System.currentTimeMillis();
|
long now = System.currentTimeMillis();
|
||||||
danaRPump.lastConnection = now;
|
danaRPump.lastConnection = now;
|
||||||
|
@ -165,15 +165,15 @@ public class DanaRExecutionService extends AbstractDanaRExecutionService {
|
||||||
Profile profile = ProfileFunctions.getInstance().getProfile();
|
Profile profile = ProfileFunctions.getInstance().getProfile();
|
||||||
PumpInterface pump = ConfigBuilderPlugin.getPlugin().getActivePump();
|
PumpInterface pump = ConfigBuilderPlugin.getPlugin().getActivePump();
|
||||||
if (profile != null && Math.abs(danaRPump.currentBasal - profile.getBasal()) >= pump.getPumpDescription().basalStep) {
|
if (profile != null && Math.abs(danaRPump.currentBasal - profile.getBasal()) >= pump.getPumpDescription().basalStep) {
|
||||||
MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.gettingpumpsettings)));
|
RxBus.INSTANCE.send(new EventPumpStatusChanged(MainApp.gs(R.string.gettingpumpsettings)));
|
||||||
mSerialIOThread.sendMessage(new MsgSettingBasal());
|
mSerialIOThread.sendMessage(new MsgSettingBasal());
|
||||||
if (!pump.isThisProfileSet(profile) && !ConfigBuilderPlugin.getPlugin().getCommandQueue().isRunning(Command.CommandType.BASALPROFILE)) {
|
if (!pump.isThisProfileSet(profile) && !ConfigBuilderPlugin.getPlugin().getCommandQueue().isRunning(Command.CommandType.BASALPROFILE)) {
|
||||||
MainApp.bus().post(new EventProfileNeedsUpdate());
|
RxBus.INSTANCE.send(new EventProfileNeedsUpdate());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (danaRPump.lastSettingsRead + 60 * 60 * 1000L < now || !pump.isInitialized()) {
|
if (danaRPump.lastSettingsRead + 60 * 60 * 1000L < now || !pump.isInitialized()) {
|
||||||
MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.gettingpumpsettings)));
|
RxBus.INSTANCE.send(new EventPumpStatusChanged(MainApp.gs(R.string.gettingpumpsettings)));
|
||||||
mSerialIOThread.sendMessage(new MsgSettingShippingInfo());
|
mSerialIOThread.sendMessage(new MsgSettingShippingInfo());
|
||||||
mSerialIOThread.sendMessage(new MsgSettingActiveProfile());
|
mSerialIOThread.sendMessage(new MsgSettingActiveProfile());
|
||||||
mSerialIOThread.sendMessage(new MsgSettingMeal());
|
mSerialIOThread.sendMessage(new MsgSettingMeal());
|
||||||
|
@ -185,7 +185,7 @@ public class DanaRExecutionService extends AbstractDanaRExecutionService {
|
||||||
mSerialIOThread.sendMessage(new MsgSettingProfileRatios());
|
mSerialIOThread.sendMessage(new MsgSettingProfileRatios());
|
||||||
mSerialIOThread.sendMessage(new MsgSettingProfileRatiosAll());
|
mSerialIOThread.sendMessage(new MsgSettingProfileRatiosAll());
|
||||||
mSerialIOThread.sendMessage(new MsgSettingUserOptions());
|
mSerialIOThread.sendMessage(new MsgSettingUserOptions());
|
||||||
MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.gettingpumptime)));
|
RxBus.INSTANCE.send(new EventPumpStatusChanged(MainApp.gs(R.string.gettingpumptime)));
|
||||||
mSerialIOThread.sendMessage(new MsgSettingPumpTime());
|
mSerialIOThread.sendMessage(new MsgSettingPumpTime());
|
||||||
if (danaRPump.pumpTime == 0) {
|
if (danaRPump.pumpTime == 0) {
|
||||||
// initial handshake was not successfull
|
// initial handshake was not successfull
|
||||||
|
@ -194,6 +194,7 @@ public class DanaRExecutionService extends AbstractDanaRExecutionService {
|
||||||
danaRPump.lastSettingsRead = 0;
|
danaRPump.lastSettingsRead = 0;
|
||||||
RxBus.INSTANCE.send(new EventDanaRNewStatus());
|
RxBus.INSTANCE.send(new EventDanaRNewStatus());
|
||||||
MainApp.bus().post(new EventInitializationChanged());
|
MainApp.bus().post(new EventInitializationChanged());
|
||||||
|
RxBus.INSTANCE.send(new EventInitializationChanged());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
long timeDiff = (danaRPump.pumpTime - System.currentTimeMillis()) / 1000L;
|
long timeDiff = (danaRPump.pumpTime - System.currentTimeMillis()) / 1000L;
|
||||||
|
@ -211,6 +212,7 @@ public class DanaRExecutionService extends AbstractDanaRExecutionService {
|
||||||
|
|
||||||
RxBus.INSTANCE.send(new EventDanaRNewStatus());
|
RxBus.INSTANCE.send(new EventDanaRNewStatus());
|
||||||
MainApp.bus().post(new EventInitializationChanged());
|
MainApp.bus().post(new EventInitializationChanged());
|
||||||
|
RxBus.INSTANCE.send(new EventInitializationChanged());
|
||||||
NSUpload.uploadDeviceStatus();
|
NSUpload.uploadDeviceStatus();
|
||||||
if (danaRPump.dailyTotalUnits > danaRPump.maxDailyTotalUnits * Constants.dailyLimitWarning) {
|
if (danaRPump.dailyTotalUnits > danaRPump.maxDailyTotalUnits * Constants.dailyLimitWarning) {
|
||||||
if (L.isEnabled(L.PUMP))
|
if (L.isEnabled(L.PUMP))
|
||||||
|
@ -231,41 +233,41 @@ public class DanaRExecutionService extends AbstractDanaRExecutionService {
|
||||||
DanaRPump danaRPump = DanaRPump.getInstance();
|
DanaRPump danaRPump = DanaRPump.getInstance();
|
||||||
if (!isConnected()) return false;
|
if (!isConnected()) return false;
|
||||||
if (danaRPump.isTempBasalInProgress) {
|
if (danaRPump.isTempBasalInProgress) {
|
||||||
MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.stoppingtempbasal)));
|
RxBus.INSTANCE.send(new EventPumpStatusChanged(MainApp.gs(R.string.stoppingtempbasal)));
|
||||||
mSerialIOThread.sendMessage(new MsgSetTempBasalStop());
|
mSerialIOThread.sendMessage(new MsgSetTempBasalStop());
|
||||||
SystemClock.sleep(500);
|
SystemClock.sleep(500);
|
||||||
}
|
}
|
||||||
MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.settingtempbasal)));
|
RxBus.INSTANCE.send(new EventPumpStatusChanged(MainApp.gs(R.string.settingtempbasal)));
|
||||||
mSerialIOThread.sendMessage(new MsgSetTempBasalStart(percent, durationInHours));
|
mSerialIOThread.sendMessage(new MsgSetTempBasalStart(percent, durationInHours));
|
||||||
mSerialIOThread.sendMessage(new MsgStatusTempBasal());
|
mSerialIOThread.sendMessage(new MsgStatusTempBasal());
|
||||||
MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.DISCONNECTING));
|
RxBus.INSTANCE.send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTING));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean tempBasalStop() {
|
public boolean tempBasalStop() {
|
||||||
if (!isConnected()) return false;
|
if (!isConnected()) return false;
|
||||||
MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.stoppingtempbasal)));
|
RxBus.INSTANCE.send(new EventPumpStatusChanged(MainApp.gs(R.string.stoppingtempbasal)));
|
||||||
mSerialIOThread.sendMessage(new MsgSetTempBasalStop());
|
mSerialIOThread.sendMessage(new MsgSetTempBasalStop());
|
||||||
mSerialIOThread.sendMessage(new MsgStatusTempBasal());
|
mSerialIOThread.sendMessage(new MsgStatusTempBasal());
|
||||||
MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.DISCONNECTING));
|
RxBus.INSTANCE.send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTING));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean extendedBolus(double insulin, int durationInHalfHours) {
|
public boolean extendedBolus(double insulin, int durationInHalfHours) {
|
||||||
if (!isConnected()) return false;
|
if (!isConnected()) return false;
|
||||||
MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.settingextendedbolus)));
|
RxBus.INSTANCE.send(new EventPumpStatusChanged(MainApp.gs(R.string.settingextendedbolus)));
|
||||||
mSerialIOThread.sendMessage(new MsgSetExtendedBolusStart(insulin, (byte) (durationInHalfHours & 0xFF)));
|
mSerialIOThread.sendMessage(new MsgSetExtendedBolusStart(insulin, (byte) (durationInHalfHours & 0xFF)));
|
||||||
mSerialIOThread.sendMessage(new MsgStatusBolusExtended());
|
mSerialIOThread.sendMessage(new MsgStatusBolusExtended());
|
||||||
MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.DISCONNECTING));
|
RxBus.INSTANCE.send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTING));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean extendedBolusStop() {
|
public boolean extendedBolusStop() {
|
||||||
if (!isConnected()) return false;
|
if (!isConnected()) return false;
|
||||||
MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.stoppingextendedbolus)));
|
RxBus.INSTANCE.send(new EventPumpStatusChanged(MainApp.gs(R.string.stoppingextendedbolus)));
|
||||||
mSerialIOThread.sendMessage(new MsgSetExtendedBolusStop());
|
mSerialIOThread.sendMessage(new MsgSetExtendedBolusStop());
|
||||||
mSerialIOThread.sendMessage(new MsgStatusBolusExtended());
|
mSerialIOThread.sendMessage(new MsgStatusBolusExtended());
|
||||||
MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.DISCONNECTING));
|
RxBus.INSTANCE.send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTING));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -395,7 +397,7 @@ public class DanaRExecutionService extends AbstractDanaRExecutionService {
|
||||||
public boolean updateBasalsInPump(final Profile profile) {
|
public boolean updateBasalsInPump(final Profile profile) {
|
||||||
DanaRPump danaRPump = DanaRPump.getInstance();
|
DanaRPump danaRPump = DanaRPump.getInstance();
|
||||||
if (!isConnected()) return false;
|
if (!isConnected()) return false;
|
||||||
MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.updatingbasalrates)));
|
RxBus.INSTANCE.send(new EventPumpStatusChanged(MainApp.gs(R.string.updatingbasalrates)));
|
||||||
double[] basal = DanaRPump.getInstance().buildDanaRProfileRecord(profile);
|
double[] basal = DanaRPump.getInstance().buildDanaRProfileRecord(profile);
|
||||||
MsgSetBasalProfile msgSet = new MsgSetBasalProfile((byte) 0, basal);
|
MsgSetBasalProfile msgSet = new MsgSetBasalProfile((byte) 0, basal);
|
||||||
mSerialIOThread.sendMessage(msgSet);
|
mSerialIOThread.sendMessage(msgSet);
|
||||||
|
@ -403,7 +405,7 @@ public class DanaRExecutionService extends AbstractDanaRExecutionService {
|
||||||
mSerialIOThread.sendMessage(msgActivate);
|
mSerialIOThread.sendMessage(msgActivate);
|
||||||
danaRPump.lastSettingsRead = 0; // force read full settings
|
danaRPump.lastSettingsRead = 0; // force read full settings
|
||||||
getPumpStatus();
|
getPumpStatus();
|
||||||
MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.DISCONNECTING));
|
RxBus.INSTANCE.send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTING));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -132,7 +132,7 @@ public class DanaRKoreanExecutionService extends AbstractDanaRExecutionService {
|
||||||
}
|
}
|
||||||
mSerialIOThread = new SerialIOThread(mRfcommSocket, MessageHashTableRkorean.INSTANCE);
|
mSerialIOThread = new SerialIOThread(mRfcommSocket, MessageHashTableRkorean.INSTANCE);
|
||||||
mHandshakeInProgress = true;
|
mHandshakeInProgress = true;
|
||||||
MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.HANDSHAKING, 0));
|
RxBus.INSTANCE.send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.HANDSHAKING, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
mConnectionInProgress = false;
|
mConnectionInProgress = false;
|
||||||
|
@ -142,7 +142,7 @@ public class DanaRKoreanExecutionService extends AbstractDanaRExecutionService {
|
||||||
public void getPumpStatus() {
|
public void getPumpStatus() {
|
||||||
DanaRPump danaRPump = DanaRPump.getInstance();
|
DanaRPump danaRPump = DanaRPump.getInstance();
|
||||||
try {
|
try {
|
||||||
MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.gettingpumpstatus)));
|
RxBus.INSTANCE.send(new EventPumpStatusChanged(MainApp.gs(R.string.gettingpumpstatus)));
|
||||||
//MsgStatus_k statusMsg = new MsgStatus_k();
|
//MsgStatus_k statusMsg = new MsgStatus_k();
|
||||||
MsgStatusBasic_k statusBasicMsg = new MsgStatusBasic_k();
|
MsgStatusBasic_k statusBasicMsg = new MsgStatusBasic_k();
|
||||||
MsgStatusTempBasal tempStatusMsg = new MsgStatusTempBasal();
|
MsgStatusTempBasal tempStatusMsg = new MsgStatusTempBasal();
|
||||||
|
@ -158,11 +158,11 @@ public class DanaRKoreanExecutionService extends AbstractDanaRExecutionService {
|
||||||
|
|
||||||
//mSerialIOThread.sendMessage(statusMsg);
|
//mSerialIOThread.sendMessage(statusMsg);
|
||||||
mSerialIOThread.sendMessage(statusBasicMsg);
|
mSerialIOThread.sendMessage(statusBasicMsg);
|
||||||
MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.gettingtempbasalstatus)));
|
RxBus.INSTANCE.send(new EventPumpStatusChanged(MainApp.gs(R.string.gettingtempbasalstatus)));
|
||||||
mSerialIOThread.sendMessage(tempStatusMsg);
|
mSerialIOThread.sendMessage(tempStatusMsg);
|
||||||
MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.gettingextendedbolusstatus)));
|
RxBus.INSTANCE.send(new EventPumpStatusChanged(MainApp.gs(R.string.gettingextendedbolusstatus)));
|
||||||
mSerialIOThread.sendMessage(exStatusMsg);
|
mSerialIOThread.sendMessage(exStatusMsg);
|
||||||
MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.gettingbolusstatus)));
|
RxBus.INSTANCE.send(new EventPumpStatusChanged(MainApp.gs(R.string.gettingbolusstatus)));
|
||||||
|
|
||||||
long now = System.currentTimeMillis();
|
long now = System.currentTimeMillis();
|
||||||
danaRPump.lastConnection = now;
|
danaRPump.lastConnection = now;
|
||||||
|
@ -170,7 +170,7 @@ public class DanaRKoreanExecutionService extends AbstractDanaRExecutionService {
|
||||||
Profile profile = ProfileFunctions.getInstance().getProfile();
|
Profile profile = ProfileFunctions.getInstance().getProfile();
|
||||||
PumpInterface pump = ConfigBuilderPlugin.getPlugin().getActivePump();
|
PumpInterface pump = ConfigBuilderPlugin.getPlugin().getActivePump();
|
||||||
if (profile != null && Math.abs(danaRPump.currentBasal - profile.getBasal()) >= pump.getPumpDescription().basalStep) {
|
if (profile != null && Math.abs(danaRPump.currentBasal - profile.getBasal()) >= pump.getPumpDescription().basalStep) {
|
||||||
MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.gettingpumpsettings)));
|
RxBus.INSTANCE.send(new EventPumpStatusChanged(MainApp.gs(R.string.gettingpumpsettings)));
|
||||||
mSerialIOThread.sendMessage(new MsgSettingBasal());
|
mSerialIOThread.sendMessage(new MsgSettingBasal());
|
||||||
if (!pump.isThisProfileSet(profile) && !ConfigBuilderPlugin.getPlugin().getCommandQueue().isRunning(Command.CommandType.BASALPROFILE)) {
|
if (!pump.isThisProfileSet(profile) && !ConfigBuilderPlugin.getPlugin().getCommandQueue().isRunning(Command.CommandType.BASALPROFILE)) {
|
||||||
MainApp.bus().post(new EventProfileNeedsUpdate());
|
MainApp.bus().post(new EventProfileNeedsUpdate());
|
||||||
|
@ -178,7 +178,7 @@ public class DanaRKoreanExecutionService extends AbstractDanaRExecutionService {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (danaRPump.lastSettingsRead + 60 * 60 * 1000L < now || !pump.isInitialized()) {
|
if (danaRPump.lastSettingsRead + 60 * 60 * 1000L < now || !pump.isInitialized()) {
|
||||||
MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.gettingpumpsettings)));
|
RxBus.INSTANCE.send(new EventPumpStatusChanged(MainApp.gs(R.string.gettingpumpsettings)));
|
||||||
mSerialIOThread.sendMessage(new MsgSettingShippingInfo());
|
mSerialIOThread.sendMessage(new MsgSettingShippingInfo());
|
||||||
mSerialIOThread.sendMessage(new MsgSettingMeal());
|
mSerialIOThread.sendMessage(new MsgSettingMeal());
|
||||||
mSerialIOThread.sendMessage(new MsgSettingBasal_k());
|
mSerialIOThread.sendMessage(new MsgSettingBasal_k());
|
||||||
|
@ -186,7 +186,7 @@ public class DanaRKoreanExecutionService extends AbstractDanaRExecutionService {
|
||||||
mSerialIOThread.sendMessage(new MsgSettingMaxValues());
|
mSerialIOThread.sendMessage(new MsgSettingMaxValues());
|
||||||
mSerialIOThread.sendMessage(new MsgSettingGlucose());
|
mSerialIOThread.sendMessage(new MsgSettingGlucose());
|
||||||
mSerialIOThread.sendMessage(new MsgSettingProfileRatios());
|
mSerialIOThread.sendMessage(new MsgSettingProfileRatios());
|
||||||
MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.gettingpumptime)));
|
RxBus.INSTANCE.send(new EventPumpStatusChanged(MainApp.gs(R.string.gettingpumptime)));
|
||||||
mSerialIOThread.sendMessage(new MsgSettingPumpTime());
|
mSerialIOThread.sendMessage(new MsgSettingPumpTime());
|
||||||
if (danaRPump.pumpTime == 0) {
|
if (danaRPump.pumpTime == 0) {
|
||||||
// initial handshake was not successfull
|
// initial handshake was not successfull
|
||||||
|
@ -195,6 +195,7 @@ public class DanaRKoreanExecutionService extends AbstractDanaRExecutionService {
|
||||||
danaRPump.lastSettingsRead = 0;
|
danaRPump.lastSettingsRead = 0;
|
||||||
RxBus.INSTANCE.send(new EventDanaRNewStatus());
|
RxBus.INSTANCE.send(new EventDanaRNewStatus());
|
||||||
MainApp.bus().post(new EventInitializationChanged());
|
MainApp.bus().post(new EventInitializationChanged());
|
||||||
|
RxBus.INSTANCE.send(new EventInitializationChanged());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
long timeDiff = (danaRPump.pumpTime - System.currentTimeMillis()) / 1000L;
|
long timeDiff = (danaRPump.pumpTime - System.currentTimeMillis()) / 1000L;
|
||||||
|
@ -214,6 +215,7 @@ public class DanaRKoreanExecutionService extends AbstractDanaRExecutionService {
|
||||||
|
|
||||||
RxBus.INSTANCE.send(new EventDanaRNewStatus());
|
RxBus.INSTANCE.send(new EventDanaRNewStatus());
|
||||||
MainApp.bus().post(new EventInitializationChanged());
|
MainApp.bus().post(new EventInitializationChanged());
|
||||||
|
RxBus.INSTANCE.send(new EventInitializationChanged());
|
||||||
NSUpload.uploadDeviceStatus();
|
NSUpload.uploadDeviceStatus();
|
||||||
if (danaRPump.dailyTotalUnits > danaRPump.maxDailyTotalUnits * Constants.dailyLimitWarning) {
|
if (danaRPump.dailyTotalUnits > danaRPump.maxDailyTotalUnits * Constants.dailyLimitWarning) {
|
||||||
if (L.isEnabled(L.PUMP))
|
if (L.isEnabled(L.PUMP))
|
||||||
|
@ -234,41 +236,41 @@ public class DanaRKoreanExecutionService extends AbstractDanaRExecutionService {
|
||||||
DanaRPump danaRPump = DanaRPump.getInstance();
|
DanaRPump danaRPump = DanaRPump.getInstance();
|
||||||
if (!isConnected()) return false;
|
if (!isConnected()) return false;
|
||||||
if (danaRPump.isTempBasalInProgress) {
|
if (danaRPump.isTempBasalInProgress) {
|
||||||
MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.stoppingtempbasal)));
|
RxBus.INSTANCE.send(new EventPumpStatusChanged(MainApp.gs(R.string.stoppingtempbasal)));
|
||||||
mSerialIOThread.sendMessage(new MsgSetTempBasalStop());
|
mSerialIOThread.sendMessage(new MsgSetTempBasalStop());
|
||||||
SystemClock.sleep(500);
|
SystemClock.sleep(500);
|
||||||
}
|
}
|
||||||
MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.settingtempbasal)));
|
RxBus.INSTANCE.send(new EventPumpStatusChanged(MainApp.gs(R.string.settingtempbasal)));
|
||||||
mSerialIOThread.sendMessage(new MsgSetTempBasalStart(percent, durationInHours));
|
mSerialIOThread.sendMessage(new MsgSetTempBasalStart(percent, durationInHours));
|
||||||
mSerialIOThread.sendMessage(new MsgStatusTempBasal());
|
mSerialIOThread.sendMessage(new MsgStatusTempBasal());
|
||||||
MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.DISCONNECTING));
|
RxBus.INSTANCE.send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTING));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean tempBasalStop() {
|
public boolean tempBasalStop() {
|
||||||
if (!isConnected()) return false;
|
if (!isConnected()) return false;
|
||||||
MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.stoppingtempbasal)));
|
RxBus.INSTANCE.send(new EventPumpStatusChanged(MainApp.gs(R.string.stoppingtempbasal)));
|
||||||
mSerialIOThread.sendMessage(new MsgSetTempBasalStop());
|
mSerialIOThread.sendMessage(new MsgSetTempBasalStop());
|
||||||
mSerialIOThread.sendMessage(new MsgStatusTempBasal());
|
mSerialIOThread.sendMessage(new MsgStatusTempBasal());
|
||||||
MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.DISCONNECTING));
|
RxBus.INSTANCE.send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTING));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean extendedBolus(double insulin, int durationInHalfHours) {
|
public boolean extendedBolus(double insulin, int durationInHalfHours) {
|
||||||
if (!isConnected()) return false;
|
if (!isConnected()) return false;
|
||||||
MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.settingextendedbolus)));
|
RxBus.INSTANCE.send(new EventPumpStatusChanged(MainApp.gs(R.string.settingextendedbolus)));
|
||||||
mSerialIOThread.sendMessage(new MsgSetExtendedBolusStart(insulin, (byte) (durationInHalfHours & 0xFF)));
|
mSerialIOThread.sendMessage(new MsgSetExtendedBolusStart(insulin, (byte) (durationInHalfHours & 0xFF)));
|
||||||
mSerialIOThread.sendMessage(new MsgStatusBolusExtended());
|
mSerialIOThread.sendMessage(new MsgStatusBolusExtended());
|
||||||
MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.DISCONNECTING));
|
RxBus.INSTANCE.send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTING));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean extendedBolusStop() {
|
public boolean extendedBolusStop() {
|
||||||
if (!isConnected()) return false;
|
if (!isConnected()) return false;
|
||||||
MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.stoppingextendedbolus)));
|
RxBus.INSTANCE.send(new EventPumpStatusChanged(MainApp.gs(R.string.stoppingextendedbolus)));
|
||||||
mSerialIOThread.sendMessage(new MsgSetExtendedBolusStop());
|
mSerialIOThread.sendMessage(new MsgSetExtendedBolusStop());
|
||||||
mSerialIOThread.sendMessage(new MsgStatusBolusExtended());
|
mSerialIOThread.sendMessage(new MsgStatusBolusExtended());
|
||||||
MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.DISCONNECTING));
|
RxBus.INSTANCE.send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTING));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -336,13 +338,13 @@ public class DanaRKoreanExecutionService extends AbstractDanaRExecutionService {
|
||||||
public boolean updateBasalsInPump(final Profile profile) {
|
public boolean updateBasalsInPump(final Profile profile) {
|
||||||
DanaRPump danaRPump = DanaRPump.getInstance();
|
DanaRPump danaRPump = DanaRPump.getInstance();
|
||||||
if (!isConnected()) return false;
|
if (!isConnected()) return false;
|
||||||
MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.updatingbasalrates)));
|
RxBus.INSTANCE.send(new EventPumpStatusChanged(MainApp.gs(R.string.updatingbasalrates)));
|
||||||
double[] basal = DanaRPump.getInstance().buildDanaRProfileRecord(profile);
|
double[] basal = DanaRPump.getInstance().buildDanaRProfileRecord(profile);
|
||||||
MsgSetSingleBasalProfile msgSet = new MsgSetSingleBasalProfile(basal);
|
MsgSetSingleBasalProfile msgSet = new MsgSetSingleBasalProfile(basal);
|
||||||
mSerialIOThread.sendMessage(msgSet);
|
mSerialIOThread.sendMessage(msgSet);
|
||||||
danaRPump.lastSettingsRead = 0; // force read full settings
|
danaRPump.lastSettingsRead = 0; // force read full settings
|
||||||
getPumpStatus();
|
getPumpStatus();
|
||||||
MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.DISCONNECTING));
|
RxBus.INSTANCE.send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTING));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,7 @@ import info.nightscout.androidaps.db.Source;
|
||||||
import info.nightscout.androidaps.db.TemporaryBasal;
|
import info.nightscout.androidaps.db.TemporaryBasal;
|
||||||
import info.nightscout.androidaps.events.EventPumpStatusChanged;
|
import info.nightscout.androidaps.events.EventPumpStatusChanged;
|
||||||
import info.nightscout.androidaps.logging.L;
|
import info.nightscout.androidaps.logging.L;
|
||||||
|
import info.nightscout.androidaps.plugins.bus.RxBus;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.bolusInfo.DetailedBolusInfoStorage;
|
import info.nightscout.androidaps.plugins.pump.common.bolusInfo.DetailedBolusInfoStorage;
|
||||||
import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump;
|
import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump;
|
||||||
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin;
|
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin;
|
||||||
|
@ -223,7 +224,7 @@ public class DanaRS_Packet_APS_History_Events extends DanaRS_Packet {
|
||||||
if (datetime > lastEventTimeLoaded)
|
if (datetime > lastEventTimeLoaded)
|
||||||
lastEventTimeLoaded = datetime;
|
lastEventTimeLoaded = datetime;
|
||||||
|
|
||||||
MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.processinghistory) + ": " + status));
|
RxBus.INSTANCE.send(new EventPumpStatusChanged(MainApp.gs(R.string.processinghistory) + ": " + status));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -339,7 +339,7 @@ public class BLEComm {
|
||||||
close();
|
close();
|
||||||
isConnected = false;
|
isConnected = false;
|
||||||
isConnecting = false;
|
isConnecting = false;
|
||||||
MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.DISCONNECTED));
|
RxBus.INSTANCE.send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTED));
|
||||||
if (L.isEnabled(L.PUMPBTCOMM))
|
if (L.isEnabled(L.PUMPBTCOMM))
|
||||||
log.debug("Device was disconnected " + gatt.getDevice().getName());//Device was disconnected
|
log.debug("Device was disconnected " + gatt.getDevice().getName());//Device was disconnected
|
||||||
}
|
}
|
||||||
|
@ -452,7 +452,7 @@ public class BLEComm {
|
||||||
if (L.isEnabled(L.PUMPBTCOMM))
|
if (L.isEnabled(L.PUMPBTCOMM))
|
||||||
log.debug("<<<<< " + "ENCRYPTION__PUMP_CHECK (PUMP)" + " " + DanaRS_Packet.toHexString(inputBuffer));
|
log.debug("<<<<< " + "ENCRYPTION__PUMP_CHECK (PUMP)" + " " + DanaRS_Packet.toHexString(inputBuffer));
|
||||||
mSendQueue.clear();
|
mSendQueue.clear();
|
||||||
MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.DISCONNECTED, MainApp.gs(R.string.pumperror)));
|
RxBus.INSTANCE.send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTED, MainApp.gs(R.string.pumperror)));
|
||||||
NSUpload.uploadError(MainApp.gs(R.string.pumperror));
|
NSUpload.uploadError(MainApp.gs(R.string.pumperror));
|
||||||
Notification n = new Notification(Notification.PUMPERROR, MainApp.gs(R.string.pumperror), Notification.URGENT);
|
Notification n = new Notification(Notification.PUMPERROR, MainApp.gs(R.string.pumperror), Notification.URGENT);
|
||||||
RxBus.INSTANCE.send(new EventNewNotification(n));
|
RxBus.INSTANCE.send(new EventNewNotification(n));
|
||||||
|
@ -460,13 +460,13 @@ public class BLEComm {
|
||||||
if (L.isEnabled(L.PUMPBTCOMM))
|
if (L.isEnabled(L.PUMPBTCOMM))
|
||||||
log.debug("<<<<< " + "ENCRYPTION__PUMP_CHECK (BUSY)" + " " + DanaRS_Packet.toHexString(inputBuffer));
|
log.debug("<<<<< " + "ENCRYPTION__PUMP_CHECK (BUSY)" + " " + DanaRS_Packet.toHexString(inputBuffer));
|
||||||
mSendQueue.clear();
|
mSendQueue.clear();
|
||||||
MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.DISCONNECTED, MainApp.gs(R.string.pumpbusy)));
|
RxBus.INSTANCE.send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTED, MainApp.gs(R.string.pumpbusy)));
|
||||||
} else {
|
} else {
|
||||||
// ERROR in response, wrong serial number
|
// ERROR in response, wrong serial number
|
||||||
if (L.isEnabled(L.PUMPBTCOMM))
|
if (L.isEnabled(L.PUMPBTCOMM))
|
||||||
log.debug("<<<<< " + "ENCRYPTION__PUMP_CHECK (ERROR)" + " " + DanaRS_Packet.toHexString(inputBuffer));
|
log.debug("<<<<< " + "ENCRYPTION__PUMP_CHECK (ERROR)" + " " + DanaRS_Packet.toHexString(inputBuffer));
|
||||||
mSendQueue.clear();
|
mSendQueue.clear();
|
||||||
MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.DISCONNECTED, MainApp.gs(R.string.connectionerror)));
|
RxBus.INSTANCE.send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTED, MainApp.gs(R.string.connectionerror)));
|
||||||
SP.remove(MainApp.gs(R.string.key_danars_pairingkey) + DanaRSPlugin.mDeviceName);
|
SP.remove(MainApp.gs(R.string.key_danars_pairingkey) + DanaRSPlugin.mDeviceName);
|
||||||
Notification n = new Notification(Notification.WRONGSERIALNUMBER, MainApp.gs(R.string.wrongpassword), Notification.URGENT);
|
Notification n = new Notification(Notification.WRONGSERIALNUMBER, MainApp.gs(R.string.wrongpassword), Notification.URGENT);
|
||||||
RxBus.INSTANCE.send(new EventNewNotification(n));
|
RxBus.INSTANCE.send(new EventNewNotification(n));
|
||||||
|
@ -515,7 +515,7 @@ public class BLEComm {
|
||||||
if (L.isEnabled(L.PUMPBTCOMM))
|
if (L.isEnabled(L.PUMPBTCOMM))
|
||||||
log.debug("Pump user password: " + Integer.toHexString(pass));
|
log.debug("Pump user password: " + Integer.toHexString(pass));
|
||||||
|
|
||||||
MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.CONNECTED));
|
RxBus.INSTANCE.send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.CONNECTED));
|
||||||
isConnected = true;
|
isConnected = true;
|
||||||
isConnecting = false;
|
isConnecting = false;
|
||||||
if (L.isEnabled(L.PUMPBTCOMM))
|
if (L.isEnabled(L.PUMPBTCOMM))
|
||||||
|
|
|
@ -132,14 +132,14 @@ public class DanaRSService extends Service {
|
||||||
public void getPumpStatus() {
|
public void getPumpStatus() {
|
||||||
DanaRPump danaRPump = DanaRPump.getInstance();
|
DanaRPump danaRPump = DanaRPump.getInstance();
|
||||||
try {
|
try {
|
||||||
MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.gettingpumpstatus)));
|
RxBus.INSTANCE.send(new EventPumpStatusChanged(MainApp.gs(R.string.gettingpumpstatus)));
|
||||||
|
|
||||||
bleComm.sendMessage(new DanaRS_Packet_General_Initial_Screen_Information());
|
bleComm.sendMessage(new DanaRS_Packet_General_Initial_Screen_Information());
|
||||||
MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.gettingextendedbolusstatus)));
|
RxBus.INSTANCE.send(new EventPumpStatusChanged(MainApp.gs(R.string.gettingextendedbolusstatus)));
|
||||||
bleComm.sendMessage(new DanaRS_Packet_Bolus_Get_Extended_Bolus_State());
|
bleComm.sendMessage(new DanaRS_Packet_Bolus_Get_Extended_Bolus_State());
|
||||||
MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.gettingbolusstatus)));
|
RxBus.INSTANCE.send(new EventPumpStatusChanged(MainApp.gs(R.string.gettingbolusstatus)));
|
||||||
bleComm.sendMessage(new DanaRS_Packet_Bolus_Get_Step_Bolus_Information()); // last bolus, bolusStep, maxBolus
|
bleComm.sendMessage(new DanaRS_Packet_Bolus_Get_Step_Bolus_Information()); // last bolus, bolusStep, maxBolus
|
||||||
MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.gettingtempbasalstatus)));
|
RxBus.INSTANCE.send(new EventPumpStatusChanged(MainApp.gs(R.string.gettingtempbasalstatus)));
|
||||||
bleComm.sendMessage(new DanaRS_Packet_Basal_Get_Temporary_Basal_State());
|
bleComm.sendMessage(new DanaRS_Packet_Basal_Get_Temporary_Basal_State());
|
||||||
|
|
||||||
danaRPump.lastConnection = System.currentTimeMillis();
|
danaRPump.lastConnection = System.currentTimeMillis();
|
||||||
|
@ -147,14 +147,14 @@ public class DanaRSService extends Service {
|
||||||
Profile profile = ProfileFunctions.getInstance().getProfile();
|
Profile profile = ProfileFunctions.getInstance().getProfile();
|
||||||
PumpInterface pump = ConfigBuilderPlugin.getPlugin().getActivePump();
|
PumpInterface pump = ConfigBuilderPlugin.getPlugin().getActivePump();
|
||||||
if (profile != null && Math.abs(danaRPump.currentBasal - profile.getBasal()) >= pump.getPumpDescription().basalStep) {
|
if (profile != null && Math.abs(danaRPump.currentBasal - profile.getBasal()) >= pump.getPumpDescription().basalStep) {
|
||||||
MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.gettingpumpsettings)));
|
RxBus.INSTANCE.send(new EventPumpStatusChanged(MainApp.gs(R.string.gettingpumpsettings)));
|
||||||
bleComm.sendMessage(new DanaRS_Packet_Basal_Get_Basal_Rate()); // basal profile, basalStep, maxBasal
|
bleComm.sendMessage(new DanaRS_Packet_Basal_Get_Basal_Rate()); // basal profile, basalStep, maxBasal
|
||||||
if (!pump.isThisProfileSet(profile) && !ConfigBuilderPlugin.getPlugin().getCommandQueue().isRunning(Command.CommandType.BASALPROFILE)) {
|
if (!pump.isThisProfileSet(profile) && !ConfigBuilderPlugin.getPlugin().getCommandQueue().isRunning(Command.CommandType.BASALPROFILE)) {
|
||||||
MainApp.bus().post(new EventProfileNeedsUpdate());
|
MainApp.bus().post(new EventProfileNeedsUpdate());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.gettingpumptime)));
|
RxBus.INSTANCE.send(new EventPumpStatusChanged(MainApp.gs(R.string.gettingpumptime)));
|
||||||
bleComm.sendMessage(new DanaRS_Packet_Option_Get_Pump_Time());
|
bleComm.sendMessage(new DanaRS_Packet_Option_Get_Pump_Time());
|
||||||
|
|
||||||
long timeDiff = (danaRPump.pumpTime - System.currentTimeMillis()) / 1000L;
|
long timeDiff = (danaRPump.pumpTime - System.currentTimeMillis()) / 1000L;
|
||||||
|
@ -164,6 +164,7 @@ public class DanaRSService extends Service {
|
||||||
danaRPump.lastConnection = 0;
|
danaRPump.lastConnection = 0;
|
||||||
RxBus.INSTANCE.send(new EventDanaRNewStatus());
|
RxBus.INSTANCE.send(new EventDanaRNewStatus());
|
||||||
MainApp.bus().post(new EventInitializationChanged());
|
MainApp.bus().post(new EventInitializationChanged());
|
||||||
|
RxBus.INSTANCE.send(new EventInitializationChanged());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (L.isEnabled(L.PUMPCOMM))
|
if (L.isEnabled(L.PUMPCOMM))
|
||||||
|
@ -184,6 +185,7 @@ public class DanaRSService extends Service {
|
||||||
danaRPump.lastConnection = 0;
|
danaRPump.lastConnection = 0;
|
||||||
RxBus.INSTANCE.send(new EventDanaRNewStatus());
|
RxBus.INSTANCE.send(new EventDanaRNewStatus());
|
||||||
MainApp.bus().post(new EventInitializationChanged());
|
MainApp.bus().post(new EventInitializationChanged());
|
||||||
|
RxBus.INSTANCE.send(new EventInitializationChanged());
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
waitForWholeMinute(); // Dana can set only whole minute
|
waitForWholeMinute(); // Dana can set only whole minute
|
||||||
|
@ -198,7 +200,7 @@ public class DanaRSService extends Service {
|
||||||
|
|
||||||
long now = System.currentTimeMillis();
|
long now = System.currentTimeMillis();
|
||||||
if (danaRPump.lastSettingsRead + 60 * 60 * 1000L < now || !pump.isInitialized()) {
|
if (danaRPump.lastSettingsRead + 60 * 60 * 1000L < now || !pump.isInitialized()) {
|
||||||
MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.gettingpumpsettings)));
|
RxBus.INSTANCE.send(new EventPumpStatusChanged(MainApp.gs(R.string.gettingpumpsettings)));
|
||||||
bleComm.sendMessage(new DanaRS_Packet_General_Get_Shipping_Information()); // serial no
|
bleComm.sendMessage(new DanaRS_Packet_General_Get_Shipping_Information()); // serial no
|
||||||
bleComm.sendMessage(new DanaRS_Packet_General_Get_Pump_Check()); // firmware
|
bleComm.sendMessage(new DanaRS_Packet_General_Get_Pump_Check()); // firmware
|
||||||
bleComm.sendMessage(new DanaRS_Packet_Basal_Get_Profile_Number());
|
bleComm.sendMessage(new DanaRS_Packet_Basal_Get_Profile_Number());
|
||||||
|
@ -214,6 +216,7 @@ public class DanaRSService extends Service {
|
||||||
|
|
||||||
MainApp.bus().post(new EventDanaRNewStatus());
|
MainApp.bus().post(new EventDanaRNewStatus());
|
||||||
MainApp.bus().post(new EventInitializationChanged());
|
MainApp.bus().post(new EventInitializationChanged());
|
||||||
|
RxBus.INSTANCE.send(new EventInitializationChanged());
|
||||||
NSUpload.uploadDeviceStatus();
|
NSUpload.uploadDeviceStatus();
|
||||||
if (danaRPump.dailyTotalUnits > danaRPump.maxDailyTotalUnits * Constants.dailyLimitWarning) {
|
if (danaRPump.dailyTotalUnits > danaRPump.maxDailyTotalUnits * Constants.dailyLimitWarning) {
|
||||||
if (L.isEnabled(L.PUMPCOMM))
|
if (L.isEnabled(L.PUMPCOMM))
|
||||||
|
@ -278,7 +281,7 @@ public class DanaRSService extends Service {
|
||||||
if (!isConnected()) return false;
|
if (!isConnected()) return false;
|
||||||
if (BolusProgressDialog.stopPressed) return false;
|
if (BolusProgressDialog.stopPressed) return false;
|
||||||
|
|
||||||
MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.startingbolus)));
|
RxBus.INSTANCE.send(new EventPumpStatusChanged(MainApp.gs(R.string.startingbolus)));
|
||||||
bolusingTreatment = t;
|
bolusingTreatment = t;
|
||||||
final int preferencesSpeed = SP.getInt(R.string.key_danars_bolusspeed, 0);
|
final int preferencesSpeed = SP.getInt(R.string.key_danars_bolusspeed, 0);
|
||||||
DanaRS_Packet_Bolus_Set_Step_Bolus_Start start = new DanaRS_Packet_Bolus_Set_Step_Bolus_Start(insulin, preferencesSpeed);
|
DanaRS_Packet_Bolus_Set_Step_Bolus_Start start = new DanaRS_Packet_Bolus_Set_Step_Bolus_Start(insulin, preferencesSpeed);
|
||||||
|
@ -344,10 +347,10 @@ public class DanaRSService extends Service {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
// reread bolus status
|
// reread bolus status
|
||||||
MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.gettingbolusstatus)));
|
RxBus.INSTANCE.send(new EventPumpStatusChanged(MainApp.gs(R.string.gettingbolusstatus)));
|
||||||
bleComm.sendMessage(new DanaRS_Packet_Bolus_Get_Step_Bolus_Information()); // last bolus
|
bleComm.sendMessage(new DanaRS_Packet_Bolus_Get_Step_Bolus_Information()); // last bolus
|
||||||
bolusingEvent.percent = 100;
|
bolusingEvent.percent = 100;
|
||||||
MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.disconnecting)));
|
RxBus.INSTANCE.send(new EventPumpStatusChanged(MainApp.gs(R.string.disconnecting)));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return !start.failed;
|
return !start.failed;
|
||||||
|
@ -372,30 +375,30 @@ public class DanaRSService extends Service {
|
||||||
public boolean tempBasal(Integer percent, int durationInHours) {
|
public boolean tempBasal(Integer percent, int durationInHours) {
|
||||||
if (!isConnected()) return false;
|
if (!isConnected()) return false;
|
||||||
if (DanaRPump.getInstance().isTempBasalInProgress) {
|
if (DanaRPump.getInstance().isTempBasalInProgress) {
|
||||||
MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.stoppingtempbasal)));
|
RxBus.INSTANCE.send(new EventPumpStatusChanged(MainApp.gs(R.string.stoppingtempbasal)));
|
||||||
bleComm.sendMessage(new DanaRS_Packet_Basal_Set_Cancel_Temporary_Basal());
|
bleComm.sendMessage(new DanaRS_Packet_Basal_Set_Cancel_Temporary_Basal());
|
||||||
SystemClock.sleep(500);
|
SystemClock.sleep(500);
|
||||||
}
|
}
|
||||||
MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.settingtempbasal)));
|
RxBus.INSTANCE.send(new EventPumpStatusChanged(MainApp.gs(R.string.settingtempbasal)));
|
||||||
bleComm.sendMessage(new DanaRS_Packet_Basal_Set_Temporary_Basal(percent, durationInHours));
|
bleComm.sendMessage(new DanaRS_Packet_Basal_Set_Temporary_Basal(percent, durationInHours));
|
||||||
SystemClock.sleep(200);
|
SystemClock.sleep(200);
|
||||||
bleComm.sendMessage(new DanaRS_Packet_Basal_Get_Temporary_Basal_State());
|
bleComm.sendMessage(new DanaRS_Packet_Basal_Get_Temporary_Basal_State());
|
||||||
loadEvents();
|
loadEvents();
|
||||||
MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.DISCONNECTING));
|
RxBus.INSTANCE.send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTING));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean highTempBasal(Integer percent) {
|
public boolean highTempBasal(Integer percent) {
|
||||||
if (DanaRPump.getInstance().isTempBasalInProgress) {
|
if (DanaRPump.getInstance().isTempBasalInProgress) {
|
||||||
MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.stoppingtempbasal)));
|
RxBus.INSTANCE.send(new EventPumpStatusChanged(MainApp.gs(R.string.stoppingtempbasal)));
|
||||||
bleComm.sendMessage(new DanaRS_Packet_Basal_Set_Cancel_Temporary_Basal());
|
bleComm.sendMessage(new DanaRS_Packet_Basal_Set_Cancel_Temporary_Basal());
|
||||||
SystemClock.sleep(500);
|
SystemClock.sleep(500);
|
||||||
}
|
}
|
||||||
MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.settingtempbasal)));
|
RxBus.INSTANCE.send(new EventPumpStatusChanged(MainApp.gs(R.string.settingtempbasal)));
|
||||||
bleComm.sendMessage(new DanaRS_Packet_APS_Basal_Set_Temporary_Basal(percent));
|
bleComm.sendMessage(new DanaRS_Packet_APS_Basal_Set_Temporary_Basal(percent));
|
||||||
bleComm.sendMessage(new DanaRS_Packet_Basal_Get_Temporary_Basal_State());
|
bleComm.sendMessage(new DanaRS_Packet_Basal_Get_Temporary_Basal_State());
|
||||||
loadEvents();
|
loadEvents();
|
||||||
MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.DISCONNECTING));
|
RxBus.INSTANCE.send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTING));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -406,52 +409,52 @@ public class DanaRSService extends Service {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DanaRPump.getInstance().isTempBasalInProgress) {
|
if (DanaRPump.getInstance().isTempBasalInProgress) {
|
||||||
MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.stoppingtempbasal)));
|
RxBus.INSTANCE.send(new EventPumpStatusChanged(MainApp.gs(R.string.stoppingtempbasal)));
|
||||||
bleComm.sendMessage(new DanaRS_Packet_Basal_Set_Cancel_Temporary_Basal());
|
bleComm.sendMessage(new DanaRS_Packet_Basal_Set_Cancel_Temporary_Basal());
|
||||||
SystemClock.sleep(500);
|
SystemClock.sleep(500);
|
||||||
}
|
}
|
||||||
MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.settingtempbasal)));
|
RxBus.INSTANCE.send(new EventPumpStatusChanged(MainApp.gs(R.string.settingtempbasal)));
|
||||||
bleComm.sendMessage(new DanaRS_Packet_APS_Basal_Set_Temporary_Basal(percent, durationInMinutes == 15, durationInMinutes == 30));
|
bleComm.sendMessage(new DanaRS_Packet_APS_Basal_Set_Temporary_Basal(percent, durationInMinutes == 15, durationInMinutes == 30));
|
||||||
bleComm.sendMessage(new DanaRS_Packet_Basal_Get_Temporary_Basal_State());
|
bleComm.sendMessage(new DanaRS_Packet_Basal_Get_Temporary_Basal_State());
|
||||||
loadEvents();
|
loadEvents();
|
||||||
MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.DISCONNECTING));
|
RxBus.INSTANCE.send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTING));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean tempBasalStop() {
|
public boolean tempBasalStop() {
|
||||||
if (!isConnected()) return false;
|
if (!isConnected()) return false;
|
||||||
MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.stoppingtempbasal)));
|
RxBus.INSTANCE.send(new EventPumpStatusChanged(MainApp.gs(R.string.stoppingtempbasal)));
|
||||||
bleComm.sendMessage(new DanaRS_Packet_Basal_Set_Cancel_Temporary_Basal());
|
bleComm.sendMessage(new DanaRS_Packet_Basal_Set_Cancel_Temporary_Basal());
|
||||||
bleComm.sendMessage(new DanaRS_Packet_Basal_Get_Temporary_Basal_State());
|
bleComm.sendMessage(new DanaRS_Packet_Basal_Get_Temporary_Basal_State());
|
||||||
loadEvents();
|
loadEvents();
|
||||||
MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.DISCONNECTING));
|
RxBus.INSTANCE.send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTING));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean extendedBolus(Double insulin, int durationInHalfHours) {
|
public boolean extendedBolus(Double insulin, int durationInHalfHours) {
|
||||||
if (!isConnected()) return false;
|
if (!isConnected()) return false;
|
||||||
MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.settingextendedbolus)));
|
RxBus.INSTANCE.send(new EventPumpStatusChanged(MainApp.gs(R.string.settingextendedbolus)));
|
||||||
bleComm.sendMessage(new DanaRS_Packet_Bolus_Set_Extended_Bolus(insulin, durationInHalfHours));
|
bleComm.sendMessage(new DanaRS_Packet_Bolus_Set_Extended_Bolus(insulin, durationInHalfHours));
|
||||||
SystemClock.sleep(200);
|
SystemClock.sleep(200);
|
||||||
bleComm.sendMessage(new DanaRS_Packet_Bolus_Get_Extended_Bolus_State());
|
bleComm.sendMessage(new DanaRS_Packet_Bolus_Get_Extended_Bolus_State());
|
||||||
loadEvents();
|
loadEvents();
|
||||||
MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.DISCONNECTING));
|
RxBus.INSTANCE.send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTING));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean extendedBolusStop() {
|
public boolean extendedBolusStop() {
|
||||||
if (!isConnected()) return false;
|
if (!isConnected()) return false;
|
||||||
MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.stoppingextendedbolus)));
|
RxBus.INSTANCE.send(new EventPumpStatusChanged(MainApp.gs(R.string.stoppingextendedbolus)));
|
||||||
bleComm.sendMessage(new DanaRS_Packet_Bolus_Set_Extended_Bolus_Cancel());
|
bleComm.sendMessage(new DanaRS_Packet_Bolus_Set_Extended_Bolus_Cancel());
|
||||||
bleComm.sendMessage(new DanaRS_Packet_Bolus_Get_Extended_Bolus_State());
|
bleComm.sendMessage(new DanaRS_Packet_Bolus_Get_Extended_Bolus_State());
|
||||||
loadEvents();
|
loadEvents();
|
||||||
MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.DISCONNECTING));
|
RxBus.INSTANCE.send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTING));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean updateBasalsInPump(Profile profile) {
|
public boolean updateBasalsInPump(Profile profile) {
|
||||||
if (!isConnected()) return false;
|
if (!isConnected()) return false;
|
||||||
MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.updatingbasalrates)));
|
RxBus.INSTANCE.send(new EventPumpStatusChanged(MainApp.gs(R.string.updatingbasalrates)));
|
||||||
double[] basal = DanaRPump.getInstance().buildDanaRProfileRecord(profile);
|
double[] basal = DanaRPump.getInstance().buildDanaRProfileRecord(profile);
|
||||||
DanaRS_Packet_Basal_Set_Profile_Basal_Rate msgSet = new DanaRS_Packet_Basal_Set_Profile_Basal_Rate(0, basal);
|
DanaRS_Packet_Basal_Set_Profile_Basal_Rate msgSet = new DanaRS_Packet_Basal_Set_Profile_Basal_Rate(0, basal);
|
||||||
bleComm.sendMessage(msgSet);
|
bleComm.sendMessage(msgSet);
|
||||||
|
@ -459,7 +462,7 @@ public class DanaRSService extends Service {
|
||||||
bleComm.sendMessage(msgActivate);
|
bleComm.sendMessage(msgActivate);
|
||||||
DanaRPump.getInstance().lastSettingsRead = 0; // force read full settings
|
DanaRPump.getInstance().lastSettingsRead = 0; // force read full settings
|
||||||
getPumpStatus();
|
getPumpStatus();
|
||||||
MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.DISCONNECTING));
|
RxBus.INSTANCE.send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTING));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -543,7 +546,7 @@ public class DanaRSService extends Service {
|
||||||
long timeToWholeMinute = (60000 - time % 60000);
|
long timeToWholeMinute = (60000 - time % 60000);
|
||||||
if (timeToWholeMinute > 59800 || timeToWholeMinute < 300)
|
if (timeToWholeMinute > 59800 || timeToWholeMinute < 300)
|
||||||
break;
|
break;
|
||||||
MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.waitingfortimesynchronization, (int) (timeToWholeMinute / 1000))));
|
RxBus.INSTANCE.send(new EventPumpStatusChanged(MainApp.gs(R.string.waitingfortimesynchronization, (int) (timeToWholeMinute / 1000))));
|
||||||
SystemClock.sleep(Math.min(timeToWholeMinute, 100));
|
SystemClock.sleep(Math.min(timeToWholeMinute, 100));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@ import info.nightscout.androidaps.db.Source;
|
||||||
import info.nightscout.androidaps.db.TemporaryBasal;
|
import info.nightscout.androidaps.db.TemporaryBasal;
|
||||||
import info.nightscout.androidaps.events.EventPumpStatusChanged;
|
import info.nightscout.androidaps.events.EventPumpStatusChanged;
|
||||||
import info.nightscout.androidaps.logging.L;
|
import info.nightscout.androidaps.logging.L;
|
||||||
|
import info.nightscout.androidaps.plugins.bus.RxBus;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.bolusInfo.DetailedBolusInfoStorage;
|
import info.nightscout.androidaps.plugins.pump.common.bolusInfo.DetailedBolusInfoStorage;
|
||||||
import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump;
|
import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump;
|
||||||
import info.nightscout.androidaps.plugins.pump.danaR.comm.MessageBase;
|
import info.nightscout.androidaps.plugins.pump.danaR.comm.MessageBase;
|
||||||
|
@ -199,6 +200,6 @@ public class MsgHistoryEvents_v2 extends MessageBase {
|
||||||
if (datetime > lastEventTimeLoaded)
|
if (datetime > lastEventTimeLoaded)
|
||||||
lastEventTimeLoaded = datetime;
|
lastEventTimeLoaded = datetime;
|
||||||
|
|
||||||
MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.processinghistory) + ": " + status));
|
RxBus.INSTANCE.send(new EventPumpStatusChanged(MainApp.gs(R.string.processinghistory) + ": " + status));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -150,7 +150,7 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService {
|
||||||
}
|
}
|
||||||
mSerialIOThread = new SerialIOThread(mRfcommSocket, MessageHashTableRv2.INSTANCE);
|
mSerialIOThread = new SerialIOThread(mRfcommSocket, MessageHashTableRv2.INSTANCE);
|
||||||
mHandshakeInProgress = true;
|
mHandshakeInProgress = true;
|
||||||
MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.HANDSHAKING, 0));
|
RxBus.INSTANCE.send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.HANDSHAKING, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
mConnectionInProgress = false;
|
mConnectionInProgress = false;
|
||||||
|
@ -160,7 +160,7 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService {
|
||||||
public void getPumpStatus() {
|
public void getPumpStatus() {
|
||||||
DanaRPump danaRPump = DanaRPump.getInstance();
|
DanaRPump danaRPump = DanaRPump.getInstance();
|
||||||
try {
|
try {
|
||||||
MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.gettingpumpstatus)));
|
RxBus.INSTANCE.send(new EventPumpStatusChanged(MainApp.gs(R.string.gettingpumpstatus)));
|
||||||
MsgStatus statusMsg = new MsgStatus();
|
MsgStatus statusMsg = new MsgStatus();
|
||||||
MsgStatusBasic statusBasicMsg = new MsgStatusBasic();
|
MsgStatusBasic statusBasicMsg = new MsgStatusBasic();
|
||||||
MsgStatusTempBasal_v2 tempStatusMsg = new MsgStatusTempBasal_v2();
|
MsgStatusTempBasal_v2 tempStatusMsg = new MsgStatusTempBasal_v2();
|
||||||
|
@ -174,12 +174,12 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.gettingbolusstatus)));
|
RxBus.INSTANCE.send(new EventPumpStatusChanged(MainApp.gs(R.string.gettingbolusstatus)));
|
||||||
mSerialIOThread.sendMessage(statusMsg);
|
mSerialIOThread.sendMessage(statusMsg);
|
||||||
mSerialIOThread.sendMessage(statusBasicMsg);
|
mSerialIOThread.sendMessage(statusBasicMsg);
|
||||||
MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.gettingtempbasalstatus)));
|
RxBus.INSTANCE.send(new EventPumpStatusChanged(MainApp.gs(R.string.gettingtempbasalstatus)));
|
||||||
mSerialIOThread.sendMessage(tempStatusMsg);
|
mSerialIOThread.sendMessage(tempStatusMsg);
|
||||||
MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.gettingextendedbolusstatus)));
|
RxBus.INSTANCE.send(new EventPumpStatusChanged(MainApp.gs(R.string.gettingextendedbolusstatus)));
|
||||||
mSerialIOThread.sendMessage(exStatusMsg);
|
mSerialIOThread.sendMessage(exStatusMsg);
|
||||||
|
|
||||||
danaRPump.lastConnection = System.currentTimeMillis();
|
danaRPump.lastConnection = System.currentTimeMillis();
|
||||||
|
@ -187,14 +187,14 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService {
|
||||||
Profile profile = ProfileFunctions.getInstance().getProfile();
|
Profile profile = ProfileFunctions.getInstance().getProfile();
|
||||||
PumpInterface pump = ConfigBuilderPlugin.getPlugin().getActivePump();
|
PumpInterface pump = ConfigBuilderPlugin.getPlugin().getActivePump();
|
||||||
if (profile != null && Math.abs(danaRPump.currentBasal - profile.getBasal()) >= pump.getPumpDescription().basalStep) {
|
if (profile != null && Math.abs(danaRPump.currentBasal - profile.getBasal()) >= pump.getPumpDescription().basalStep) {
|
||||||
MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.gettingpumpsettings)));
|
RxBus.INSTANCE.send(new EventPumpStatusChanged(MainApp.gs(R.string.gettingpumpsettings)));
|
||||||
mSerialIOThread.sendMessage(new MsgSettingBasal());
|
mSerialIOThread.sendMessage(new MsgSettingBasal());
|
||||||
if (!pump.isThisProfileSet(profile) && !ConfigBuilderPlugin.getPlugin().getCommandQueue().isRunning(Command.CommandType.BASALPROFILE)) {
|
if (!pump.isThisProfileSet(profile) && !ConfigBuilderPlugin.getPlugin().getCommandQueue().isRunning(Command.CommandType.BASALPROFILE)) {
|
||||||
MainApp.bus().post(new EventProfileNeedsUpdate());
|
MainApp.bus().post(new EventProfileNeedsUpdate());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.gettingpumptime)));
|
RxBus.INSTANCE.send(new EventPumpStatusChanged(MainApp.gs(R.string.gettingpumptime)));
|
||||||
mSerialIOThread.sendMessage(new MsgSettingPumpTime());
|
mSerialIOThread.sendMessage(new MsgSettingPumpTime());
|
||||||
if (danaRPump.pumpTime == 0) {
|
if (danaRPump.pumpTime == 0) {
|
||||||
// initial handshake was not successfull
|
// initial handshake was not successfull
|
||||||
|
@ -203,6 +203,7 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService {
|
||||||
danaRPump.lastSettingsRead = 0;
|
danaRPump.lastSettingsRead = 0;
|
||||||
RxBus.INSTANCE.send(new EventDanaRNewStatus());
|
RxBus.INSTANCE.send(new EventDanaRNewStatus());
|
||||||
MainApp.bus().post(new EventInitializationChanged());
|
MainApp.bus().post(new EventInitializationChanged());
|
||||||
|
RxBus.INSTANCE.send(new EventInitializationChanged());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
long timeDiff = (danaRPump.pumpTime - System.currentTimeMillis()) / 1000L;
|
long timeDiff = (danaRPump.pumpTime - System.currentTimeMillis()) / 1000L;
|
||||||
|
@ -224,6 +225,7 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService {
|
||||||
danaRPump.lastConnection = 0;
|
danaRPump.lastConnection = 0;
|
||||||
RxBus.INSTANCE.send(new EventDanaRNewStatus());
|
RxBus.INSTANCE.send(new EventDanaRNewStatus());
|
||||||
MainApp.bus().post(new EventInitializationChanged());
|
MainApp.bus().post(new EventInitializationChanged());
|
||||||
|
RxBus.INSTANCE.send(new EventInitializationChanged());
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
waitForWholeMinute(); // Dana can set only whole minute
|
waitForWholeMinute(); // Dana can set only whole minute
|
||||||
|
@ -238,7 +240,7 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService {
|
||||||
|
|
||||||
long now = System.currentTimeMillis();
|
long now = System.currentTimeMillis();
|
||||||
if (danaRPump.lastSettingsRead + 60 * 60 * 1000L < now || !pump.isInitialized()) {
|
if (danaRPump.lastSettingsRead + 60 * 60 * 1000L < now || !pump.isInitialized()) {
|
||||||
MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.gettingpumpsettings)));
|
RxBus.INSTANCE.send(new EventPumpStatusChanged(MainApp.gs(R.string.gettingpumpsettings)));
|
||||||
mSerialIOThread.sendMessage(new MsgSettingShippingInfo());
|
mSerialIOThread.sendMessage(new MsgSettingShippingInfo());
|
||||||
mSerialIOThread.sendMessage(new MsgSettingActiveProfile());
|
mSerialIOThread.sendMessage(new MsgSettingActiveProfile());
|
||||||
mSerialIOThread.sendMessage(new MsgSettingMeal());
|
mSerialIOThread.sendMessage(new MsgSettingMeal());
|
||||||
|
@ -257,6 +259,7 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService {
|
||||||
|
|
||||||
RxBus.INSTANCE.send(new EventDanaRNewStatus());
|
RxBus.INSTANCE.send(new EventDanaRNewStatus());
|
||||||
MainApp.bus().post(new EventInitializationChanged());
|
MainApp.bus().post(new EventInitializationChanged());
|
||||||
|
RxBus.INSTANCE.send(new EventInitializationChanged());
|
||||||
NSUpload.uploadDeviceStatus();
|
NSUpload.uploadDeviceStatus();
|
||||||
if (danaRPump.dailyTotalUnits > danaRPump.maxDailyTotalUnits * Constants.dailyLimitWarning) {
|
if (danaRPump.dailyTotalUnits > danaRPump.maxDailyTotalUnits * Constants.dailyLimitWarning) {
|
||||||
if (L.isEnabled(L.PUMP))
|
if (L.isEnabled(L.PUMP))
|
||||||
|
@ -277,15 +280,15 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService {
|
||||||
DanaRPump danaRPump = DanaRPump.getInstance();
|
DanaRPump danaRPump = DanaRPump.getInstance();
|
||||||
if (!isConnected()) return false;
|
if (!isConnected()) return false;
|
||||||
if (danaRPump.isTempBasalInProgress) {
|
if (danaRPump.isTempBasalInProgress) {
|
||||||
MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.stoppingtempbasal)));
|
RxBus.INSTANCE.send(new EventPumpStatusChanged(MainApp.gs(R.string.stoppingtempbasal)));
|
||||||
mSerialIOThread.sendMessage(new MsgSetTempBasalStop());
|
mSerialIOThread.sendMessage(new MsgSetTempBasalStop());
|
||||||
SystemClock.sleep(500);
|
SystemClock.sleep(500);
|
||||||
}
|
}
|
||||||
MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.settingtempbasal)));
|
RxBus.INSTANCE.send(new EventPumpStatusChanged(MainApp.gs(R.string.settingtempbasal)));
|
||||||
mSerialIOThread.sendMessage(new MsgSetTempBasalStart(percent, durationInHours));
|
mSerialIOThread.sendMessage(new MsgSetTempBasalStart(percent, durationInHours));
|
||||||
mSerialIOThread.sendMessage(new MsgStatusTempBasal_v2());
|
mSerialIOThread.sendMessage(new MsgStatusTempBasal_v2());
|
||||||
loadEvents();
|
loadEvents();
|
||||||
MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.DISCONNECTING));
|
RxBus.INSTANCE.send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTING));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -293,15 +296,15 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService {
|
||||||
DanaRPump danaRPump = DanaRPump.getInstance();
|
DanaRPump danaRPump = DanaRPump.getInstance();
|
||||||
if (!isConnected()) return false;
|
if (!isConnected()) return false;
|
||||||
if (danaRPump.isTempBasalInProgress) {
|
if (danaRPump.isTempBasalInProgress) {
|
||||||
MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.stoppingtempbasal)));
|
RxBus.INSTANCE.send(new EventPumpStatusChanged(MainApp.gs(R.string.stoppingtempbasal)));
|
||||||
mSerialIOThread.sendMessage(new MsgSetTempBasalStop());
|
mSerialIOThread.sendMessage(new MsgSetTempBasalStop());
|
||||||
SystemClock.sleep(500);
|
SystemClock.sleep(500);
|
||||||
}
|
}
|
||||||
MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.settingtempbasal)));
|
RxBus.INSTANCE.send(new EventPumpStatusChanged(MainApp.gs(R.string.settingtempbasal)));
|
||||||
mSerialIOThread.sendMessage(new MsgSetAPSTempBasalStart_v2(percent));
|
mSerialIOThread.sendMessage(new MsgSetAPSTempBasalStart_v2(percent));
|
||||||
mSerialIOThread.sendMessage(new MsgStatusTempBasal_v2());
|
mSerialIOThread.sendMessage(new MsgStatusTempBasal_v2());
|
||||||
loadEvents();
|
loadEvents();
|
||||||
MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.DISCONNECTING));
|
RxBus.INSTANCE.send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTING));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -314,45 +317,45 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService {
|
||||||
|
|
||||||
if (!isConnected()) return false;
|
if (!isConnected()) return false;
|
||||||
if (danaRPump.isTempBasalInProgress) {
|
if (danaRPump.isTempBasalInProgress) {
|
||||||
MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.stoppingtempbasal)));
|
RxBus.INSTANCE.send(new EventPumpStatusChanged(MainApp.gs(R.string.stoppingtempbasal)));
|
||||||
mSerialIOThread.sendMessage(new MsgSetTempBasalStop());
|
mSerialIOThread.sendMessage(new MsgSetTempBasalStop());
|
||||||
SystemClock.sleep(500);
|
SystemClock.sleep(500);
|
||||||
}
|
}
|
||||||
MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.settingtempbasal)));
|
RxBus.INSTANCE.send(new EventPumpStatusChanged(MainApp.gs(R.string.settingtempbasal)));
|
||||||
mSerialIOThread.sendMessage(new MsgSetAPSTempBasalStart_v2(percent, durationInMinutes == 15, durationInMinutes == 30));
|
mSerialIOThread.sendMessage(new MsgSetAPSTempBasalStart_v2(percent, durationInMinutes == 15, durationInMinutes == 30));
|
||||||
mSerialIOThread.sendMessage(new MsgStatusTempBasal_v2());
|
mSerialIOThread.sendMessage(new MsgStatusTempBasal_v2());
|
||||||
loadEvents();
|
loadEvents();
|
||||||
MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.DISCONNECTING));
|
RxBus.INSTANCE.send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTING));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean tempBasalStop() {
|
public boolean tempBasalStop() {
|
||||||
if (!isConnected()) return false;
|
if (!isConnected()) return false;
|
||||||
MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.stoppingtempbasal)));
|
RxBus.INSTANCE.send(new EventPumpStatusChanged(MainApp.gs(R.string.stoppingtempbasal)));
|
||||||
mSerialIOThread.sendMessage(new MsgSetTempBasalStop());
|
mSerialIOThread.sendMessage(new MsgSetTempBasalStop());
|
||||||
mSerialIOThread.sendMessage(new MsgStatusTempBasal_v2());
|
mSerialIOThread.sendMessage(new MsgStatusTempBasal_v2());
|
||||||
loadEvents();
|
loadEvents();
|
||||||
MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.DISCONNECTING));
|
RxBus.INSTANCE.send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTING));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean extendedBolus(double insulin, int durationInHalfHours) {
|
public boolean extendedBolus(double insulin, int durationInHalfHours) {
|
||||||
if (!isConnected()) return false;
|
if (!isConnected()) return false;
|
||||||
MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.settingextendedbolus)));
|
RxBus.INSTANCE.send(new EventPumpStatusChanged(MainApp.gs(R.string.settingextendedbolus)));
|
||||||
mSerialIOThread.sendMessage(new MsgSetExtendedBolusStart(insulin, (byte) (durationInHalfHours & 0xFF)));
|
mSerialIOThread.sendMessage(new MsgSetExtendedBolusStart(insulin, (byte) (durationInHalfHours & 0xFF)));
|
||||||
mSerialIOThread.sendMessage(new MsgStatusBolusExtended_v2());
|
mSerialIOThread.sendMessage(new MsgStatusBolusExtended_v2());
|
||||||
loadEvents();
|
loadEvents();
|
||||||
MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.DISCONNECTING));
|
RxBus.INSTANCE.send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTING));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean extendedBolusStop() {
|
public boolean extendedBolusStop() {
|
||||||
if (!isConnected()) return false;
|
if (!isConnected()) return false;
|
||||||
MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.stoppingextendedbolus)));
|
RxBus.INSTANCE.send(new EventPumpStatusChanged(MainApp.gs(R.string.stoppingextendedbolus)));
|
||||||
mSerialIOThread.sendMessage(new MsgSetExtendedBolusStop());
|
mSerialIOThread.sendMessage(new MsgSetExtendedBolusStop());
|
||||||
mSerialIOThread.sendMessage(new MsgStatusBolusExtended_v2());
|
mSerialIOThread.sendMessage(new MsgStatusBolusExtended_v2());
|
||||||
loadEvents();
|
loadEvents();
|
||||||
MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.DISCONNECTING));
|
RxBus.INSTANCE.send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTING));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -360,7 +363,7 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService {
|
||||||
if (!isConnected()) return false;
|
if (!isConnected()) return false;
|
||||||
if (BolusProgressDialog.stopPressed) return false;
|
if (BolusProgressDialog.stopPressed) return false;
|
||||||
|
|
||||||
MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.startingbolus)));
|
RxBus.INSTANCE.send(new EventPumpStatusChanged(MainApp.gs(R.string.startingbolus)));
|
||||||
mBolusingTreatment = t;
|
mBolusingTreatment = t;
|
||||||
final int preferencesSpeed = SP.getInt(R.string.key_danars_bolusspeed, 0);
|
final int preferencesSpeed = SP.getInt(R.string.key_danars_bolusspeed, 0);
|
||||||
MessageBase start;
|
MessageBase start;
|
||||||
|
@ -428,10 +431,10 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
// load last bolus status
|
// load last bolus status
|
||||||
MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.gettingbolusstatus)));
|
RxBus.INSTANCE.send(new EventPumpStatusChanged(MainApp.gs(R.string.gettingbolusstatus)));
|
||||||
mSerialIOThread.sendMessage(new MsgStatus());
|
mSerialIOThread.sendMessage(new MsgStatus());
|
||||||
bolusingEvent.percent = 100;
|
bolusingEvent.percent = 100;
|
||||||
MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.disconnecting)));
|
RxBus.INSTANCE.send(new EventPumpStatusChanged(MainApp.gs(R.string.disconnecting)));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return !start.failed;
|
return !start.failed;
|
||||||
|
@ -496,7 +499,7 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService {
|
||||||
public boolean updateBasalsInPump(final Profile profile) {
|
public boolean updateBasalsInPump(final Profile profile) {
|
||||||
DanaRPump danaRPump = DanaRPump.getInstance();
|
DanaRPump danaRPump = DanaRPump.getInstance();
|
||||||
if (!isConnected()) return false;
|
if (!isConnected()) return false;
|
||||||
MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.updatingbasalrates)));
|
RxBus.INSTANCE.send(new EventPumpStatusChanged(MainApp.gs(R.string.updatingbasalrates)));
|
||||||
double[] basal = DanaRPump.getInstance().buildDanaRProfileRecord(profile);
|
double[] basal = DanaRPump.getInstance().buildDanaRProfileRecord(profile);
|
||||||
MsgSetBasalProfile msgSet = new MsgSetBasalProfile((byte) 0, basal);
|
MsgSetBasalProfile msgSet = new MsgSetBasalProfile((byte) 0, basal);
|
||||||
mSerialIOThread.sendMessage(msgSet);
|
mSerialIOThread.sendMessage(msgSet);
|
||||||
|
@ -504,7 +507,7 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService {
|
||||||
mSerialIOThread.sendMessage(msgActivate);
|
mSerialIOThread.sendMessage(msgActivate);
|
||||||
danaRPump.lastSettingsRead = 0; // force read full settings
|
danaRPump.lastSettingsRead = 0; // force read full settings
|
||||||
getPumpStatus();
|
getPumpStatus();
|
||||||
MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.DISCONNECTING));
|
RxBus.INSTANCE.send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTING));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -147,8 +147,10 @@ public class LocalInsightPlugin extends PluginBase implements PumpInterface, Con
|
||||||
} else if (binder instanceof InsightAlertService.LocalBinder) {
|
} else if (binder instanceof InsightAlertService.LocalBinder) {
|
||||||
alertService = ((InsightAlertService.LocalBinder) binder).getService();
|
alertService = ((InsightAlertService.LocalBinder) binder).getService();
|
||||||
}
|
}
|
||||||
if (connectionService != null && alertService != null)
|
if (connectionService != null && alertService != null) {
|
||||||
MainApp.bus().post(new EventInitializationChanged());
|
MainApp.bus().post(new EventInitializationChanged());
|
||||||
|
RxBus.INSTANCE.send(new EventInitializationChanged());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -424,7 +426,7 @@ public class LocalInsightPlugin extends PluginBase implements PumpInterface, Con
|
||||||
lastUpdated = System.currentTimeMillis();
|
lastUpdated = System.currentTimeMillis();
|
||||||
new Handler(Looper.getMainLooper()).post(() -> {
|
new Handler(Looper.getMainLooper()).post(() -> {
|
||||||
MainApp.bus().post(new EventLocalInsightUpdateGUI());
|
MainApp.bus().post(new EventLocalInsightUpdateGUI());
|
||||||
MainApp.bus().post(new EventRefreshOverview("LocalInsightPlugin::fetchStatus"));
|
RxBus.INSTANCE.send(new EventRefreshOverview("LocalInsightPlugin::fetchStatus"));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1164,7 +1166,7 @@ public class LocalInsightPlugin extends PluginBase implements PumpInterface, Con
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("Exception while reading history", e);
|
log.error("Exception while reading history", e);
|
||||||
}
|
}
|
||||||
new Handler(Looper.getMainLooper()).post(() -> MainApp.bus().post(new EventRefreshOverview("LocalInsightPlugin::readHistory")));
|
new Handler(Looper.getMainLooper()).post(() -> RxBus.INSTANCE.send(new EventRefreshOverview("LocalInsightPlugin::readHistory")));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void processHistoryEvents(String serial, List<HistoryEvent> historyEvents) {
|
private void processHistoryEvents(String serial, List<HistoryEvent> historyEvents) {
|
||||||
|
@ -1599,7 +1601,7 @@ public class LocalInsightPlugin extends PluginBase implements PumpInterface, Con
|
||||||
activeTBR = null;
|
activeTBR = null;
|
||||||
activeBoluses = null;
|
activeBoluses = null;
|
||||||
tbrOverNotificationBlock = null;
|
tbrOverNotificationBlock = null;
|
||||||
new Handler(Looper.getMainLooper()).post(() -> MainApp.bus().post(new EventRefreshOverview("LocalInsightPlugin::onStateChanged")));
|
new Handler(Looper.getMainLooper()).post(() -> RxBus.INSTANCE.send(new EventRefreshOverview("LocalInsightPlugin::onStateChanged")));
|
||||||
}
|
}
|
||||||
new Handler(Looper.getMainLooper()).post(() -> MainApp.bus().post(new EventLocalInsightUpdateGUI()));
|
new Handler(Looper.getMainLooper()).post(() -> MainApp.bus().post(new EventLocalInsightUpdateGUI()));
|
||||||
}
|
}
|
||||||
|
|
|
@ -122,6 +122,14 @@ class MedtronicFragment : Fragment() {
|
||||||
.toObservable(EventMedtronicPumpValuesChanged::class.java)
|
.toObservable(EventMedtronicPumpValuesChanged::class.java)
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.subscribe({ updateGUI() }, { FabricPrivacy.logException(it) })
|
.subscribe({ updateGUI() }, { FabricPrivacy.logException(it) })
|
||||||
|
disposable += RxBus
|
||||||
|
.toObservable(EventExtendedBolusChange::class.java)
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.subscribe({ updateGUI() }, { FabricPrivacy.logException(it) })
|
||||||
|
disposable += RxBus
|
||||||
|
.toObservable(EventTempBasalChange::class.java)
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.subscribe({ updateGUI() }, { FabricPrivacy.logException(it) })
|
||||||
disposable += RxBus
|
disposable += RxBus
|
||||||
.toObservable(EventMedtronicPumpConfigurationChanged::class.java)
|
.toObservable(EventMedtronicPumpConfigurationChanged::class.java)
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
@ -131,6 +139,10 @@ class MedtronicFragment : Fragment() {
|
||||||
MedtronicUtil.getPumpStatus().verifyConfiguration()
|
MedtronicUtil.getPumpStatus().verifyConfiguration()
|
||||||
updateGUI()
|
updateGUI()
|
||||||
}, { FabricPrivacy.logException(it) })
|
}, { FabricPrivacy.logException(it) })
|
||||||
|
disposable += RxBus
|
||||||
|
.toObservable(EventPumpStatusChanged::class.java)
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.subscribe({ updateGUI() }, { FabricPrivacy.logException(it) })
|
||||||
|
|
||||||
updateGUI()
|
updateGUI()
|
||||||
}
|
}
|
||||||
|
@ -143,21 +155,6 @@ class MedtronicFragment : Fragment() {
|
||||||
loopHandler.removeCallbacks(refreshLoop)
|
loopHandler.removeCallbacks(refreshLoop)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
|
||||||
fun onStatusEvent(c: EventPumpStatusChanged) {
|
|
||||||
activity?.runOnUiThread { updateGUI() }
|
|
||||||
}
|
|
||||||
|
|
||||||
@Subscribe
|
|
||||||
fun onStatusEvent(s: EventTempBasalChange) {
|
|
||||||
activity?.runOnUiThread { updateGUI() }
|
|
||||||
}
|
|
||||||
|
|
||||||
@Subscribe
|
|
||||||
fun onStatusEvent(s: EventExtendedBolusChange) {
|
|
||||||
activity?.runOnUiThread { updateGUI() }
|
|
||||||
}
|
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
fun onStatusEvent(s: EventQueueChanged) {
|
fun onStatusEvent(s: EventQueueChanged) {
|
||||||
activity?.runOnUiThread { updateGUI() }
|
activity?.runOnUiThread { updateGUI() }
|
||||||
|
|
|
@ -1080,7 +1080,7 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
|
||||||
private void finishAction(String overviewKey) {
|
private void finishAction(String overviewKey) {
|
||||||
|
|
||||||
if (overviewKey != null)
|
if (overviewKey != null)
|
||||||
MainApp.bus().post(new EventRefreshOverview(overviewKey));
|
RxBus.INSTANCE.send(new EventRefreshOverview(overviewKey));
|
||||||
|
|
||||||
triggerUIChange();
|
triggerUIChange();
|
||||||
|
|
||||||
|
@ -1603,7 +1603,7 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
|
||||||
}
|
}
|
||||||
|
|
||||||
private void refreshCustomActionsList() {
|
private void refreshCustomActionsList() {
|
||||||
MainApp.bus().post(new EventCustomActionsChanged());
|
RxBus.INSTANCE.send(new EventCustomActionsChanged());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -38,6 +38,7 @@ import info.nightscout.androidaps.events.EventNsTreatment;
|
||||||
import info.nightscout.androidaps.events.EventReloadTreatmentData;
|
import info.nightscout.androidaps.events.EventReloadTreatmentData;
|
||||||
import info.nightscout.androidaps.events.EventTreatmentChange;
|
import info.nightscout.androidaps.events.EventTreatmentChange;
|
||||||
import info.nightscout.androidaps.logging.L;
|
import info.nightscout.androidaps.logging.L;
|
||||||
|
import info.nightscout.androidaps.plugins.bus.RxBus;
|
||||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventNewHistoryData;
|
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventNewHistoryData;
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicUtil;
|
import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicUtil;
|
||||||
import info.nightscout.androidaps.utils.JsonHelper;
|
import info.nightscout.androidaps.utils.JsonHelper;
|
||||||
|
@ -181,6 +182,7 @@ public class TreatmentService extends OrmLiteBaseService<DatabaseHelper> {
|
||||||
if (L.isEnabled(L.DATATREATMENTS))
|
if (L.isEnabled(L.DATATREATMENTS))
|
||||||
log.debug("Firing EventReloadTreatmentData");
|
log.debug("Firing EventReloadTreatmentData");
|
||||||
MainApp.bus().post(event);
|
MainApp.bus().post(event);
|
||||||
|
RxBus.INSTANCE.send(event);
|
||||||
if (DatabaseHelper.earliestDataChange != null) {
|
if (DatabaseHelper.earliestDataChange != null) {
|
||||||
if (L.isEnabled(L.DATATREATMENTS))
|
if (L.isEnabled(L.DATATREATMENTS))
|
||||||
log.debug("Firing EventNewHistoryData");
|
log.debug("Firing EventNewHistoryData");
|
||||||
|
|
|
@ -1,19 +1,18 @@
|
||||||
package info.nightscout.androidaps.plugins.treatments;
|
package info.nightscout.androidaps.plugins.treatments;
|
||||||
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import androidx.fragment.app.Fragment;
|
|
||||||
import androidx.fragment.app.FragmentTransaction;
|
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import com.squareup.otto.Subscribe;
|
import androidx.fragment.app.Fragment;
|
||||||
|
import androidx.fragment.app.FragmentTransaction;
|
||||||
|
|
||||||
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;
|
||||||
import info.nightscout.androidaps.plugins.common.SubscriberFragment;
|
import info.nightscout.androidaps.plugins.bus.RxBus;
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
|
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
|
||||||
import info.nightscout.androidaps.plugins.treatments.fragments.TreatmentsBolusFragment;
|
import info.nightscout.androidaps.plugins.treatments.fragments.TreatmentsBolusFragment;
|
||||||
import info.nightscout.androidaps.plugins.treatments.fragments.TreatmentsCareportalFragment;
|
import info.nightscout.androidaps.plugins.treatments.fragments.TreatmentsCareportalFragment;
|
||||||
|
@ -22,8 +21,12 @@ import info.nightscout.androidaps.plugins.treatments.fragments.TreatmentsProfile
|
||||||
import info.nightscout.androidaps.plugins.treatments.fragments.TreatmentsTempTargetFragment;
|
import info.nightscout.androidaps.plugins.treatments.fragments.TreatmentsTempTargetFragment;
|
||||||
import info.nightscout.androidaps.plugins.treatments.fragments.TreatmentsTemporaryBasalsFragment;
|
import info.nightscout.androidaps.plugins.treatments.fragments.TreatmentsTemporaryBasalsFragment;
|
||||||
import info.nightscout.androidaps.utils.FabricPrivacy;
|
import info.nightscout.androidaps.utils.FabricPrivacy;
|
||||||
|
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||||
|
import io.reactivex.disposables.CompositeDisposable;
|
||||||
|
|
||||||
|
public class TreatmentsFragment extends Fragment implements View.OnClickListener {
|
||||||
|
private CompositeDisposable disposable = new CompositeDisposable();
|
||||||
|
|
||||||
public class TreatmentsFragment extends SubscriberFragment implements View.OnClickListener {
|
|
||||||
TextView treatmentsTab;
|
TextView treatmentsTab;
|
||||||
TextView extendedBolusesTab;
|
TextView extendedBolusesTab;
|
||||||
TextView tempBasalsTab;
|
TextView tempBasalsTab;
|
||||||
|
@ -34,7 +37,6 @@ public class TreatmentsFragment extends SubscriberFragment implements View.OnCli
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
Bundle savedInstanceState) {
|
Bundle savedInstanceState) {
|
||||||
try {
|
|
||||||
View view = inflater.inflate(R.layout.treatments_fragment, container, false);
|
View view = inflater.inflate(R.layout.treatments_fragment, container, false);
|
||||||
|
|
||||||
treatmentsTab = (TextView) view.findViewById(R.id.treatments_treatments);
|
treatmentsTab = (TextView) view.findViewById(R.id.treatments_treatments);
|
||||||
|
@ -54,12 +56,23 @@ public class TreatmentsFragment extends SubscriberFragment implements View.OnCli
|
||||||
setBackgroundColorOnSelected(treatmentsTab);
|
setBackgroundColorOnSelected(treatmentsTab);
|
||||||
|
|
||||||
return view;
|
return view;
|
||||||
} catch (Exception e) {
|
|
||||||
FabricPrivacy.logException(e);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
@Override
|
||||||
|
public synchronized void onResume() {
|
||||||
|
super.onResume();
|
||||||
|
disposable.add(RxBus.INSTANCE
|
||||||
|
.toObservable(EventExtendedBolusChange.class)
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.subscribe(event -> updateGui(), FabricPrivacy::logException)
|
||||||
|
);
|
||||||
|
updateGui();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public synchronized void onPause() {
|
||||||
|
super.onPause();
|
||||||
|
disposable.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -111,13 +124,7 @@ public class TreatmentsFragment extends SubscriberFragment implements View.OnCli
|
||||||
selected.setBackgroundColor(MainApp.gc(R.color.tabBgColorSelected));
|
selected.setBackgroundColor(MainApp.gc(R.color.tabBgColorSelected));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
private void updateGui() {
|
||||||
public void onStatusEvent(final EventExtendedBolusChange ev) {
|
|
||||||
updateGUI();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void updateGUI() {
|
|
||||||
if (ConfigBuilderPlugin.getPlugin().getActivePump().getPumpDescription().isExtendedBolusCapable
|
if (ConfigBuilderPlugin.getPlugin().getActivePump().getPumpDescription().isExtendedBolusCapable
|
||||||
|| TreatmentsPlugin.getPlugin().getExtendedBolusesFromHistory().size() > 0) {
|
|| TreatmentsPlugin.getPlugin().getExtendedBolusesFromHistory().size() > 0) {
|
||||||
extendedBolusesTab.setVisibility(View.VISIBLE);
|
extendedBolusesTab.setVisibility(View.VISIBLE);
|
||||||
|
|
|
@ -6,7 +6,6 @@ import android.os.Bundle;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
import com.google.firebase.analytics.FirebaseAnalytics;
|
import com.google.firebase.analytics.FirebaseAnalytics;
|
||||||
import com.squareup.otto.Subscribe;
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
@ -59,6 +58,8 @@ import info.nightscout.androidaps.utils.DateUtil;
|
||||||
import info.nightscout.androidaps.utils.FabricPrivacy;
|
import info.nightscout.androidaps.utils.FabricPrivacy;
|
||||||
import info.nightscout.androidaps.utils.SP;
|
import info.nightscout.androidaps.utils.SP;
|
||||||
import info.nightscout.androidaps.utils.T;
|
import info.nightscout.androidaps.utils.T;
|
||||||
|
import io.reactivex.disposables.CompositeDisposable;
|
||||||
|
import io.reactivex.schedulers.Schedulers;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by mike on 05.08.2016.
|
* Created by mike on 05.08.2016.
|
||||||
|
@ -66,6 +67,8 @@ import info.nightscout.androidaps.utils.T;
|
||||||
public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface {
|
public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface {
|
||||||
private Logger log = LoggerFactory.getLogger(L.DATATREATMENTS);
|
private Logger log = LoggerFactory.getLogger(L.DATATREATMENTS);
|
||||||
|
|
||||||
|
private CompositeDisposable disposable = new CompositeDisposable();
|
||||||
|
|
||||||
private static TreatmentsPlugin treatmentsPlugin;
|
private static TreatmentsPlugin treatmentsPlugin;
|
||||||
|
|
||||||
public static TreatmentsPlugin getPlugin() {
|
public static TreatmentsPlugin getPlugin() {
|
||||||
|
@ -106,11 +109,48 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface
|
||||||
initializeTempTargetData();
|
initializeTempTargetData();
|
||||||
initializeProfileSwitchData();
|
initializeProfileSwitchData();
|
||||||
super.onStart();
|
super.onStart();
|
||||||
|
disposable.add(RxBus.INSTANCE
|
||||||
|
.toObservable(EventReloadTreatmentData.class)
|
||||||
|
.observeOn(Schedulers.io())
|
||||||
|
.subscribe(event -> {
|
||||||
|
if (L.isEnabled(L.DATATREATMENTS))
|
||||||
|
log.debug("EventReloadTreatmentData");
|
||||||
|
initializeTreatmentData();
|
||||||
|
initializeExtendedBolusData();
|
||||||
|
updateTotalIOBTreatments();
|
||||||
|
RxBus.INSTANCE.send(event.getNext());
|
||||||
|
},
|
||||||
|
FabricPrivacy::logException
|
||||||
|
));
|
||||||
|
disposable.add(RxBus.INSTANCE
|
||||||
|
.toObservable(EventReloadProfileSwitchData.class)
|
||||||
|
.observeOn(Schedulers.io())
|
||||||
|
.subscribe(event -> initializeProfileSwitchData(),
|
||||||
|
FabricPrivacy::logException
|
||||||
|
));
|
||||||
|
disposable.add(RxBus.INSTANCE
|
||||||
|
.toObservable(EventTempTargetChange.class)
|
||||||
|
.observeOn(Schedulers.io())
|
||||||
|
.subscribe(event -> initializeTempTargetData(),
|
||||||
|
FabricPrivacy::logException
|
||||||
|
));
|
||||||
|
disposable.add(RxBus.INSTANCE
|
||||||
|
.toObservable(EventReloadTempBasalData.class)
|
||||||
|
.observeOn(Schedulers.io())
|
||||||
|
.subscribe(event -> {
|
||||||
|
if (L.isEnabled(L.DATATREATMENTS))
|
||||||
|
log.debug("EventReloadTempBasalData");
|
||||||
|
initializeTempBasalData();
|
||||||
|
updateTotalIOBTempBasals();
|
||||||
|
},
|
||||||
|
FabricPrivacy::logException
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStop() {
|
protected void onStop() {
|
||||||
MainApp.bus().register(this);
|
MainApp.bus().register(this);
|
||||||
|
disposable.clear();
|
||||||
super.onStop();
|
super.onStop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -387,25 +427,6 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface
|
||||||
return getExtendedBolusFromHistory(System.currentTimeMillis()) != null; //TODO: crosscheck here
|
return getExtendedBolusFromHistory(System.currentTimeMillis()) != null; //TODO: crosscheck here
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
|
||||||
public void onStatusEvent(final EventReloadTreatmentData ev) {
|
|
||||||
if (L.isEnabled(L.DATATREATMENTS))
|
|
||||||
log.debug("EventReloadTreatmentData");
|
|
||||||
initializeTreatmentData();
|
|
||||||
initializeExtendedBolusData();
|
|
||||||
updateTotalIOBTreatments();
|
|
||||||
MainApp.bus().post(ev.next);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Subscribe
|
|
||||||
@SuppressWarnings("unused")
|
|
||||||
public void onStatusEvent(final EventReloadTempBasalData ev) {
|
|
||||||
if (L.isEnabled(L.DATATREATMENTS))
|
|
||||||
log.debug("EventReloadTempBasalData");
|
|
||||||
initializeTempBasalData();
|
|
||||||
updateTotalIOBTempBasals();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IobTotal getLastCalculationTempBasals() {
|
public IobTotal getLastCalculationTempBasals() {
|
||||||
return lastTempBasalsCalculation;
|
return lastTempBasalsCalculation;
|
||||||
|
@ -681,13 +702,6 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface
|
||||||
return oldestTime;
|
return oldestTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TempTargets
|
|
||||||
@Subscribe
|
|
||||||
@SuppressWarnings("unused")
|
|
||||||
public void onStatusEvent(final EventTempTargetChange ev) {
|
|
||||||
initializeTempTargetData();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public TempTarget getTempTargetFromHistory() {
|
public TempTarget getTempTargetFromHistory() {
|
||||||
|
@ -718,13 +732,6 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface
|
||||||
NSUpload.uploadTempTarget(tempTarget);
|
NSUpload.uploadTempTarget(tempTarget);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Profile Switch
|
|
||||||
@Subscribe
|
|
||||||
@SuppressWarnings("unused")
|
|
||||||
public void onStatusEvent(final EventReloadProfileSwitchData ev) {
|
|
||||||
initializeProfileSwitchData();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Nullable
|
@Nullable
|
||||||
public ProfileSwitch getProfileSwitchFromHistory(long time) {
|
public ProfileSwitch getProfileSwitchFromHistory(long time) {
|
||||||
|
|
|
@ -14,6 +14,7 @@ import android.widget.TextView;
|
||||||
import androidx.appcompat.app.AlertDialog;
|
import androidx.appcompat.app.AlertDialog;
|
||||||
import androidx.cardview.widget.CardView;
|
import androidx.cardview.widget.CardView;
|
||||||
import androidx.core.content.ContextCompat;
|
import androidx.core.content.ContextCompat;
|
||||||
|
import androidx.fragment.app.Fragment;
|
||||||
import androidx.fragment.app.FragmentManager;
|
import androidx.fragment.app.FragmentManager;
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
@ -28,7 +29,7 @@ import info.nightscout.androidaps.data.Iob;
|
||||||
import info.nightscout.androidaps.data.Profile;
|
import info.nightscout.androidaps.data.Profile;
|
||||||
import info.nightscout.androidaps.db.Source;
|
import info.nightscout.androidaps.db.Source;
|
||||||
import info.nightscout.androidaps.events.EventTreatmentChange;
|
import info.nightscout.androidaps.events.EventTreatmentChange;
|
||||||
import info.nightscout.androidaps.plugins.common.SubscriberFragment;
|
import info.nightscout.androidaps.plugins.bus.RxBus;
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctions;
|
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctions;
|
||||||
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload;
|
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload;
|
||||||
import info.nightscout.androidaps.plugins.general.nsclient.UploadQueue;
|
import info.nightscout.androidaps.plugins.general.nsclient.UploadQueue;
|
||||||
|
@ -39,11 +40,16 @@ import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin;
|
||||||
import info.nightscout.androidaps.plugins.treatments.dialogs.WizardInfoDialog;
|
import info.nightscout.androidaps.plugins.treatments.dialogs.WizardInfoDialog;
|
||||||
import info.nightscout.androidaps.utils.DateUtil;
|
import info.nightscout.androidaps.utils.DateUtil;
|
||||||
import info.nightscout.androidaps.utils.DecimalFormatter;
|
import info.nightscout.androidaps.utils.DecimalFormatter;
|
||||||
|
import info.nightscout.androidaps.utils.FabricPrivacy;
|
||||||
import info.nightscout.androidaps.utils.SP;
|
import info.nightscout.androidaps.utils.SP;
|
||||||
|
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||||
|
import io.reactivex.disposables.CompositeDisposable;
|
||||||
|
|
||||||
import static info.nightscout.androidaps.utils.DateUtil.now;
|
import static info.nightscout.androidaps.utils.DateUtil.now;
|
||||||
|
|
||||||
public class TreatmentsBolusFragment extends SubscriberFragment implements View.OnClickListener {
|
public class TreatmentsBolusFragment extends Fragment implements View.OnClickListener {
|
||||||
|
private CompositeDisposable disposable = new CompositeDisposable();
|
||||||
|
|
||||||
RecyclerView recyclerView;
|
RecyclerView recyclerView;
|
||||||
LinearLayoutManager llm;
|
LinearLayoutManager llm;
|
||||||
|
|
||||||
|
@ -162,7 +168,7 @@ public class TreatmentsBolusFragment extends SubscriberFragment implements View.
|
||||||
}
|
}
|
||||||
TreatmentsPlugin.getPlugin().getService().delete(treatment);
|
TreatmentsPlugin.getPlugin().getService().delete(treatment);
|
||||||
}
|
}
|
||||||
updateGUI();
|
updateGui();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
builder.setNegativeButton(MainApp.gs(R.string.cancel), null);
|
builder.setNegativeButton(MainApp.gs(R.string.cancel), null);
|
||||||
|
@ -213,7 +219,6 @@ public class TreatmentsBolusFragment extends SubscriberFragment implements View.
|
||||||
|
|
||||||
context = getContext();
|
context = getContext();
|
||||||
|
|
||||||
updateGUI();
|
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -248,7 +253,7 @@ public class TreatmentsBolusFragment extends SubscriberFragment implements View.
|
||||||
}
|
}
|
||||||
TreatmentsPlugin.getPlugin().getService().delete(treatment);
|
TreatmentsPlugin.getPlugin().getService().delete(treatment);
|
||||||
}
|
}
|
||||||
updateGUI();
|
updateGui();
|
||||||
});
|
});
|
||||||
builder.setNegativeButton(MainApp.gs(R.string.cancel), null);
|
builder.setNegativeButton(MainApp.gs(R.string.cancel), null);
|
||||||
builder.show();
|
builder.show();
|
||||||
|
@ -256,18 +261,29 @@ public class TreatmentsBolusFragment extends SubscriberFragment implements View.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Override
|
||||||
public void onStatusEvent(final EventTreatmentChange ev) {
|
public synchronized void onResume() {
|
||||||
updateGUI();
|
super.onResume();
|
||||||
|
disposable.add(RxBus.INSTANCE
|
||||||
|
.toObservable(EventTreatmentChange.class)
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.subscribe(event -> updateGui(), FabricPrivacy::logException)
|
||||||
|
);
|
||||||
|
updateGui();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public synchronized void onPause() {
|
||||||
|
super.onPause();
|
||||||
|
disposable.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onStatusEvent(final EventAutosensCalculationFinished ev) {
|
public void onStatusEvent(final EventAutosensCalculationFinished ev) {
|
||||||
updateGUI();
|
updateGui();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
private void updateGui() {
|
||||||
protected void updateGUI() {
|
|
||||||
Activity activity = getActivity();
|
Activity activity = getActivity();
|
||||||
if (activity != null)
|
if (activity != null)
|
||||||
activity.runOnUiThread(() -> {
|
activity.runOnUiThread(() -> {
|
||||||
|
|
|
@ -5,16 +5,18 @@ import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.graphics.Paint;
|
import android.graphics.Paint;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import androidx.core.content.ContextCompat;
|
|
||||||
import androidx.appcompat.app.AlertDialog;
|
|
||||||
import androidx.cardview.widget.CardView;
|
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import androidx.appcompat.app.AlertDialog;
|
||||||
|
import androidx.cardview.widget.CardView;
|
||||||
|
import androidx.core.content.ContextCompat;
|
||||||
|
import androidx.fragment.app.Fragment;
|
||||||
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
import com.squareup.otto.Subscribe;
|
import com.squareup.otto.Subscribe;
|
||||||
|
|
||||||
import info.nightscout.androidaps.MainApp;
|
import info.nightscout.androidaps.MainApp;
|
||||||
|
@ -24,16 +26,21 @@ import info.nightscout.androidaps.data.IobTotal;
|
||||||
import info.nightscout.androidaps.db.ExtendedBolus;
|
import info.nightscout.androidaps.db.ExtendedBolus;
|
||||||
import info.nightscout.androidaps.db.Source;
|
import info.nightscout.androidaps.db.Source;
|
||||||
import info.nightscout.androidaps.events.EventExtendedBolusChange;
|
import info.nightscout.androidaps.events.EventExtendedBolusChange;
|
||||||
import info.nightscout.androidaps.plugins.common.SubscriberFragment;
|
import info.nightscout.androidaps.plugins.bus.RxBus;
|
||||||
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload;
|
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload;
|
||||||
import info.nightscout.androidaps.plugins.general.nsclient.UploadQueue;
|
import info.nightscout.androidaps.plugins.general.nsclient.UploadQueue;
|
||||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventAutosensCalculationFinished;
|
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventAutosensCalculationFinished;
|
||||||
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin;
|
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin;
|
||||||
import info.nightscout.androidaps.utils.DateUtil;
|
import info.nightscout.androidaps.utils.DateUtil;
|
||||||
import info.nightscout.androidaps.utils.DecimalFormatter;
|
import info.nightscout.androidaps.utils.DecimalFormatter;
|
||||||
|
import info.nightscout.androidaps.utils.FabricPrivacy;
|
||||||
|
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||||
|
import io.reactivex.disposables.CompositeDisposable;
|
||||||
|
|
||||||
|
|
||||||
public class TreatmentsExtendedBolusesFragment extends SubscriberFragment {
|
public class TreatmentsExtendedBolusesFragment extends Fragment {
|
||||||
|
private CompositeDisposable disposable = new CompositeDisposable();
|
||||||
|
|
||||||
RecyclerView recyclerView;
|
RecyclerView recyclerView;
|
||||||
LinearLayoutManager llm;
|
LinearLayoutManager llm;
|
||||||
|
|
||||||
|
@ -173,30 +180,35 @@ public class TreatmentsExtendedBolusesFragment extends SubscriberFragment {
|
||||||
|
|
||||||
context = getContext();
|
context = getContext();
|
||||||
|
|
||||||
updateGUI();
|
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Override
|
||||||
public void onStatusEvent(final EventExtendedBolusChange ev) {
|
public synchronized void onResume() {
|
||||||
updateGUI();
|
super.onResume();
|
||||||
|
disposable.add(RxBus.INSTANCE
|
||||||
|
.toObservable(EventExtendedBolusChange.class)
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.subscribe(event -> updateGui(), FabricPrivacy::logException)
|
||||||
|
);
|
||||||
|
updateGui();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public synchronized void onPause() {
|
||||||
|
super.onPause();
|
||||||
|
disposable.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onStatusEvent(final EventAutosensCalculationFinished ev) {
|
public void onStatusEvent(final EventAutosensCalculationFinished ev) {
|
||||||
updateGUI();
|
updateGui();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
private void updateGui() {
|
||||||
protected void updateGUI() {
|
|
||||||
Activity activity = getActivity();
|
Activity activity = getActivity();
|
||||||
if (activity != null && recyclerView != null)
|
if (activity != null && recyclerView != null)
|
||||||
activity.runOnUiThread(new Runnable() {
|
activity.runOnUiThread(() -> recyclerView.swapAdapter(new RecyclerViewAdapter(TreatmentsPlugin.getPlugin().getExtendedBolusesFromHistory()), false));
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
recyclerView.swapAdapter(new RecyclerViewAdapter(TreatmentsPlugin.getPlugin().getExtendedBolusesFromHistory()), false);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,18 +14,17 @@ import android.widget.TextView;
|
||||||
import androidx.appcompat.app.AlertDialog;
|
import androidx.appcompat.app.AlertDialog;
|
||||||
import androidx.cardview.widget.CardView;
|
import androidx.cardview.widget.CardView;
|
||||||
import androidx.core.content.ContextCompat;
|
import androidx.core.content.ContextCompat;
|
||||||
|
import androidx.fragment.app.Fragment;
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
import com.squareup.otto.Subscribe;
|
|
||||||
|
|
||||||
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.Intervals;
|
import info.nightscout.androidaps.data.Intervals;
|
||||||
import info.nightscout.androidaps.db.Source;
|
import info.nightscout.androidaps.db.Source;
|
||||||
import info.nightscout.androidaps.db.TempTarget;
|
import info.nightscout.androidaps.db.TempTarget;
|
||||||
import info.nightscout.androidaps.events.EventTempTargetChange;
|
import info.nightscout.androidaps.events.EventTempTargetChange;
|
||||||
import info.nightscout.androidaps.plugins.common.SubscriberFragment;
|
import info.nightscout.androidaps.plugins.bus.RxBus;
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctions;
|
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctions;
|
||||||
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload;
|
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload;
|
||||||
import info.nightscout.androidaps.plugins.general.nsclient.UploadQueue;
|
import info.nightscout.androidaps.plugins.general.nsclient.UploadQueue;
|
||||||
|
@ -33,13 +32,17 @@ import info.nightscout.androidaps.plugins.general.nsclient.events.EventNSClientR
|
||||||
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin;
|
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin;
|
||||||
import info.nightscout.androidaps.utils.DateUtil;
|
import info.nightscout.androidaps.utils.DateUtil;
|
||||||
import info.nightscout.androidaps.utils.DecimalFormatter;
|
import info.nightscout.androidaps.utils.DecimalFormatter;
|
||||||
|
import info.nightscout.androidaps.utils.FabricPrivacy;
|
||||||
import info.nightscout.androidaps.utils.SP;
|
import info.nightscout.androidaps.utils.SP;
|
||||||
|
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||||
|
import io.reactivex.disposables.CompositeDisposable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by mike on 13/01/17.
|
* Created by mike on 13/01/17.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class TreatmentsTempTargetFragment extends SubscriberFragment implements View.OnClickListener {
|
public class TreatmentsTempTargetFragment extends Fragment implements View.OnClickListener {
|
||||||
|
private CompositeDisposable disposable = new CompositeDisposable();
|
||||||
|
|
||||||
RecyclerView recyclerView;
|
RecyclerView recyclerView;
|
||||||
LinearLayoutManager llm;
|
LinearLayoutManager llm;
|
||||||
|
@ -184,10 +187,26 @@ public class TreatmentsTempTargetFragment extends SubscriberFragment implements
|
||||||
if (nsUploadOnly)
|
if (nsUploadOnly)
|
||||||
refreshFromNS.setVisibility(View.GONE);
|
refreshFromNS.setVisibility(View.GONE);
|
||||||
|
|
||||||
updateGUI();
|
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public synchronized void onResume() {
|
||||||
|
super.onResume();
|
||||||
|
disposable.add(RxBus.INSTANCE
|
||||||
|
.toObservable(EventTempTargetChange.class)
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.subscribe(event -> updateGui(), FabricPrivacy::logException)
|
||||||
|
);
|
||||||
|
updateGui();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public synchronized void onPause() {
|
||||||
|
super.onPause();
|
||||||
|
disposable.clear();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
switch (view.getId()) {
|
switch (view.getId()) {
|
||||||
|
@ -208,20 +227,7 @@ public class TreatmentsTempTargetFragment extends SubscriberFragment implements
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
private void updateGui() {
|
||||||
public void onStatusEvent(final EventTempTargetChange ev) {
|
|
||||||
updateGUI();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void updateGUI() {
|
|
||||||
Activity activity = getActivity();
|
|
||||||
if (activity != null)
|
|
||||||
activity.runOnUiThread(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
recyclerView.swapAdapter(new RecyclerViewAdapter(TreatmentsPlugin.getPlugin().getTempTargetsFromHistory()), false);
|
recyclerView.swapAdapter(new RecyclerViewAdapter(TreatmentsPlugin.getPlugin().getTempTargetsFromHistory()), false);
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,17 +4,19 @@ import android.app.Activity;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.graphics.Paint;
|
import android.graphics.Paint;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
import androidx.core.content.ContextCompat;
|
|
||||||
import androidx.appcompat.app.AlertDialog;
|
|
||||||
import androidx.cardview.widget.CardView;
|
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.appcompat.app.AlertDialog;
|
||||||
|
import androidx.cardview.widget.CardView;
|
||||||
|
import androidx.core.content.ContextCompat;
|
||||||
|
import androidx.fragment.app.Fragment;
|
||||||
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
import com.squareup.otto.Subscribe;
|
import com.squareup.otto.Subscribe;
|
||||||
|
|
||||||
import info.nightscout.androidaps.MainApp;
|
import info.nightscout.androidaps.MainApp;
|
||||||
|
@ -25,7 +27,7 @@ import info.nightscout.androidaps.data.Profile;
|
||||||
import info.nightscout.androidaps.db.Source;
|
import info.nightscout.androidaps.db.Source;
|
||||||
import info.nightscout.androidaps.db.TemporaryBasal;
|
import info.nightscout.androidaps.db.TemporaryBasal;
|
||||||
import info.nightscout.androidaps.events.EventTempBasalChange;
|
import info.nightscout.androidaps.events.EventTempBasalChange;
|
||||||
import info.nightscout.androidaps.plugins.common.SubscriberFragment;
|
import info.nightscout.androidaps.plugins.bus.RxBus;
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctions;
|
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctions;
|
||||||
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload;
|
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload;
|
||||||
import info.nightscout.androidaps.plugins.general.nsclient.UploadQueue;
|
import info.nightscout.androidaps.plugins.general.nsclient.UploadQueue;
|
||||||
|
@ -33,9 +35,14 @@ import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventAutos
|
||||||
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin;
|
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin;
|
||||||
import info.nightscout.androidaps.utils.DateUtil;
|
import info.nightscout.androidaps.utils.DateUtil;
|
||||||
import info.nightscout.androidaps.utils.DecimalFormatter;
|
import info.nightscout.androidaps.utils.DecimalFormatter;
|
||||||
|
import info.nightscout.androidaps.utils.FabricPrivacy;
|
||||||
|
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||||
|
import io.reactivex.disposables.CompositeDisposable;
|
||||||
|
|
||||||
|
|
||||||
public class TreatmentsTemporaryBasalsFragment extends SubscriberFragment {
|
public class TreatmentsTemporaryBasalsFragment extends Fragment {
|
||||||
|
private CompositeDisposable disposable = new CompositeDisposable();
|
||||||
|
|
||||||
RecyclerView recyclerView;
|
RecyclerView recyclerView;
|
||||||
LinearLayoutManager llm;
|
LinearLayoutManager llm;
|
||||||
|
|
||||||
|
@ -199,22 +206,32 @@ public class TreatmentsTemporaryBasalsFragment extends SubscriberFragment {
|
||||||
|
|
||||||
context = getContext();
|
context = getContext();
|
||||||
|
|
||||||
updateGUI();
|
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Override
|
||||||
public void onStatusEvent(final EventTempBasalChange ignored) {
|
public synchronized void onResume() {
|
||||||
updateGUI();
|
super.onResume();
|
||||||
|
disposable.add(RxBus.INSTANCE
|
||||||
|
.toObservable(EventTempBasalChange.class)
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.subscribe(event -> updateGui(), FabricPrivacy::logException)
|
||||||
|
);
|
||||||
|
updateGui();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public synchronized void onPause() {
|
||||||
|
super.onPause();
|
||||||
|
disposable.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onStatusEvent(final EventAutosensCalculationFinished ignored) {
|
public void onStatusEvent(final EventAutosensCalculationFinished ignored) {
|
||||||
updateGUI();
|
updateGui();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
private void updateGui() {
|
||||||
protected void updateGUI() {
|
|
||||||
Activity activity = getActivity();
|
Activity activity = getActivity();
|
||||||
if (activity != null)
|
if (activity != null)
|
||||||
activity.runOnUiThread(() -> {
|
activity.runOnUiThread(() -> {
|
||||||
|
|
|
@ -14,6 +14,7 @@ import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.events.EventPumpStatusChanged;
|
import info.nightscout.androidaps.events.EventPumpStatusChanged;
|
||||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||||
import info.nightscout.androidaps.logging.L;
|
import info.nightscout.androidaps.logging.L;
|
||||||
|
import info.nightscout.androidaps.plugins.bus.RxBus;
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
|
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
|
||||||
import info.nightscout.androidaps.plugins.general.overview.events.EventDismissBolusprogressIfRunning;
|
import info.nightscout.androidaps.plugins.general.overview.events.EventDismissBolusprogressIfRunning;
|
||||||
import info.nightscout.androidaps.queue.events.EventQueueChanged;
|
import info.nightscout.androidaps.queue.events.EventQueueChanged;
|
||||||
|
@ -60,7 +61,7 @@ public class QueueThread extends Thread {
|
||||||
if (pump == null) {
|
if (pump == null) {
|
||||||
if (L.isEnabled(L.PUMPQUEUE))
|
if (L.isEnabled(L.PUMPQUEUE))
|
||||||
log.debug("pump == null");
|
log.debug("pump == null");
|
||||||
MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.pumpNotInitialized)));
|
RxBus.INSTANCE.send(new EventPumpStatusChanged(MainApp.gs(R.string.pumpNotInitialized)));
|
||||||
SystemClock.sleep(1000);
|
SystemClock.sleep(1000);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -68,7 +69,7 @@ public class QueueThread extends Thread {
|
||||||
|
|
||||||
if (!pump.isConnected() && secondsElapsed > Constants.PUMP_MAX_CONNECTION_TIME_IN_SECONDS) {
|
if (!pump.isConnected() && secondsElapsed > Constants.PUMP_MAX_CONNECTION_TIME_IN_SECONDS) {
|
||||||
MainApp.bus().post(new EventDismissBolusprogressIfRunning(null));
|
MainApp.bus().post(new EventDismissBolusprogressIfRunning(null));
|
||||||
MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.connectiontimedout)));
|
RxBus.INSTANCE.send(new EventPumpStatusChanged(MainApp.gs(R.string.connectiontimedout)));
|
||||||
if (L.isEnabled(L.PUMPQUEUE))
|
if (L.isEnabled(L.PUMPQUEUE))
|
||||||
log.debug("timed out");
|
log.debug("timed out");
|
||||||
pump.stopConnecting();
|
pump.stopConnecting();
|
||||||
|
@ -100,9 +101,9 @@ public class QueueThread extends Thread {
|
||||||
queue.clear();
|
queue.clear();
|
||||||
if (L.isEnabled(L.PUMPQUEUE))
|
if (L.isEnabled(L.PUMPQUEUE))
|
||||||
log.debug("no connection possible");
|
log.debug("no connection possible");
|
||||||
MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.DISCONNECTING));
|
RxBus.INSTANCE.send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTING));
|
||||||
pump.disconnect("Queue empty");
|
pump.disconnect("Queue empty");
|
||||||
MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.DISCONNECTED));
|
RxBus.INSTANCE.send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTED));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -110,7 +111,7 @@ public class QueueThread extends Thread {
|
||||||
if (pump.isHandshakeInProgress()) {
|
if (pump.isHandshakeInProgress()) {
|
||||||
if (L.isEnabled(L.PUMPQUEUE))
|
if (L.isEnabled(L.PUMPQUEUE))
|
||||||
log.debug("handshaking " + secondsElapsed);
|
log.debug("handshaking " + secondsElapsed);
|
||||||
MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.HANDSHAKING, (int) secondsElapsed));
|
RxBus.INSTANCE.send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.HANDSHAKING, (int) secondsElapsed));
|
||||||
SystemClock.sleep(100);
|
SystemClock.sleep(100);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -118,7 +119,7 @@ public class QueueThread extends Thread {
|
||||||
if (pump.isConnecting()) {
|
if (pump.isConnecting()) {
|
||||||
if (L.isEnabled(L.PUMPQUEUE))
|
if (L.isEnabled(L.PUMPQUEUE))
|
||||||
log.debug("connecting " + secondsElapsed);
|
log.debug("connecting " + secondsElapsed);
|
||||||
MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.CONNECTING, (int) secondsElapsed));
|
RxBus.INSTANCE.send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.CONNECTING, (int) secondsElapsed));
|
||||||
SystemClock.sleep(1000);
|
SystemClock.sleep(1000);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -126,7 +127,7 @@ public class QueueThread extends Thread {
|
||||||
if (!pump.isConnected()) {
|
if (!pump.isConnected()) {
|
||||||
if (L.isEnabled(L.PUMPQUEUE))
|
if (L.isEnabled(L.PUMPQUEUE))
|
||||||
log.debug("connect");
|
log.debug("connect");
|
||||||
MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.CONNECTING, (int) secondsElapsed));
|
RxBus.INSTANCE.send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.CONNECTING, (int) secondsElapsed));
|
||||||
pump.connect("Connection needed");
|
pump.connect("Connection needed");
|
||||||
SystemClock.sleep(1000);
|
SystemClock.sleep(1000);
|
||||||
continue;
|
continue;
|
||||||
|
@ -161,9 +162,9 @@ public class QueueThread extends Thread {
|
||||||
waitingForDisconnect = true;
|
waitingForDisconnect = true;
|
||||||
if (L.isEnabled(L.PUMPQUEUE))
|
if (L.isEnabled(L.PUMPQUEUE))
|
||||||
log.debug("queue empty. disconnect");
|
log.debug("queue empty. disconnect");
|
||||||
MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.DISCONNECTING));
|
RxBus.INSTANCE.send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTING));
|
||||||
pump.disconnect("Queue empty");
|
pump.disconnect("Queue empty");
|
||||||
MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.DISCONNECTED));
|
RxBus.INSTANCE.send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTED));
|
||||||
if (L.isEnabled(L.PUMPQUEUE))
|
if (L.isEnabled(L.PUMPQUEUE))
|
||||||
log.debug("disconnected");
|
log.debug("disconnected");
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -186,15 +186,9 @@ public class SWDefinition {
|
||||||
.label(R.string.nsclientinternal_secret_dialogtitle)
|
.label(R.string.nsclientinternal_secret_dialogtitle)
|
||||||
.comment(R.string.nsclientinternal_secret_dialogmessage))
|
.comment(R.string.nsclientinternal_secret_dialogmessage))
|
||||||
.add(new SWBreak())
|
.add(new SWBreak())
|
||||||
.add(new SWEventListener(this)
|
.add(new SWEventListener(this, EventNSClientStatus.class)
|
||||||
.label(R.string.status)
|
.label(R.string.status)
|
||||||
.initialStatus(NSClientPlugin.getPlugin().status)
|
.initialStatus(NSClientPlugin.getPlugin().status)
|
||||||
.listener(new Object() {
|
|
||||||
@Subscribe
|
|
||||||
public void onEventNSClientStatus(EventNSClientStatus event) {
|
|
||||||
MainApp.bus().post(new EventSWLabel(event.status));
|
|
||||||
}
|
|
||||||
})
|
|
||||||
)
|
)
|
||||||
.add(new SWBreak())
|
.add(new SWBreak())
|
||||||
.validator(() -> NSClientPlugin.getPlugin().nsClientService != null && NSClientService.isConnected && NSClientService.hasWriteAuth)
|
.validator(() -> NSClientPlugin.getPlugin().nsClientService != null && NSClientService.isConnected && NSClientService.hasWriteAuth)
|
||||||
|
@ -328,14 +322,7 @@ public class SWDefinition {
|
||||||
.text(R.string.readstatus)
|
.text(R.string.readstatus)
|
||||||
.action(() -> ConfigBuilderPlugin.getPlugin().getCommandQueue().readStatus("Clicked connect to pump", null))
|
.action(() -> ConfigBuilderPlugin.getPlugin().getCommandQueue().readStatus("Clicked connect to pump", null))
|
||||||
.visibility(() -> ConfigBuilderPlugin.getPlugin().getActivePump() != null))
|
.visibility(() -> ConfigBuilderPlugin.getPlugin().getActivePump() != null))
|
||||||
.add(new SWEventListener(this)
|
.add(new SWEventListener(this, EventPumpStatusChanged.class))
|
||||||
.listener(new Object() {
|
|
||||||
@Subscribe
|
|
||||||
public void onEventPumpStatusChanged(EventPumpStatusChanged event) {
|
|
||||||
MainApp.bus().post(new EventSWLabel(event.textStatus()));
|
|
||||||
}
|
|
||||||
})
|
|
||||||
)
|
|
||||||
.validator(() -> ConfigBuilderPlugin.getPlugin().getActivePump() != null && ConfigBuilderPlugin.getPlugin().getActivePump().isInitialized());
|
.validator(() -> ConfigBuilderPlugin.getPlugin().getActivePump() != null && ConfigBuilderPlugin.getPlugin().getActivePump().isInitialized());
|
||||||
|
|
||||||
private SWScreen screenAps = new SWScreen(R.string.configbuilder_aps)
|
private SWScreen screenAps = new SWScreen(R.string.configbuilder_aps)
|
||||||
|
|
|
@ -1,33 +1,42 @@
|
||||||
package info.nightscout.androidaps.setupwizard;
|
package info.nightscout.androidaps.setupwizard;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.view.View;
|
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import com.squareup.otto.Subscribe;
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import info.nightscout.androidaps.MainApp;
|
import info.nightscout.androidaps.MainApp;
|
||||||
|
import info.nightscout.androidaps.events.EventStatus;
|
||||||
|
import info.nightscout.androidaps.plugins.bus.RxBus;
|
||||||
import info.nightscout.androidaps.setupwizard.elements.SWItem;
|
import info.nightscout.androidaps.setupwizard.elements.SWItem;
|
||||||
import info.nightscout.androidaps.setupwizard.events.EventSWLabel;
|
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||||
|
import io.reactivex.disposables.CompositeDisposable;
|
||||||
|
|
||||||
|
|
||||||
public class SWEventListener extends SWItem {
|
public class SWEventListener extends SWItem {
|
||||||
private static Logger log = LoggerFactory.getLogger(SWEventListener.class);
|
private static Logger log = LoggerFactory.getLogger(SWEventListener.class);
|
||||||
|
private CompositeDisposable disposable = new CompositeDisposable();
|
||||||
|
|
||||||
private int textLabel = 0;
|
private int textLabel = 0;
|
||||||
private String status = "";
|
private String status = "";
|
||||||
TextView textView;
|
TextView textView;
|
||||||
Object listener;
|
|
||||||
SWDefinition definition;
|
SWDefinition definition;
|
||||||
|
|
||||||
SWEventListener(SWDefinition definition) {
|
SWEventListener(SWDefinition definition, Class clazz) {
|
||||||
super(Type.LISTENER);
|
super(Type.LISTENER);
|
||||||
this.definition = definition;
|
this.definition = definition;
|
||||||
MainApp.bus().register(this);
|
disposable.add(RxBus.INSTANCE
|
||||||
|
.toObservable(clazz)
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.subscribe(event -> {
|
||||||
|
status = ((EventStatus) event).getStatus();
|
||||||
|
if (textView != null)
|
||||||
|
textView.setText((textLabel != 0 ? MainApp.gs(textLabel) : "") + " " + status);
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public SWEventListener label(int newLabel) {
|
public SWEventListener label(int newLabel) {
|
||||||
|
@ -35,16 +44,11 @@ public class SWEventListener extends SWItem {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public SWEventListener initialStatus(String status) {
|
SWEventListener initialStatus(String status) {
|
||||||
this.status = status;
|
this.status = status;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public SWEventListener listener(Object listener) {
|
|
||||||
this.listener = listener;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void generateDialog(LinearLayout layout) {
|
public void generateDialog(LinearLayout layout) {
|
||||||
Context context = layout.getContext();
|
Context context = layout.getContext();
|
||||||
|
@ -53,20 +57,5 @@ public class SWEventListener extends SWItem {
|
||||||
textView.setId(layout.generateViewId());
|
textView.setId(layout.generateViewId());
|
||||||
textView.setText((textLabel != 0 ? MainApp.gs(textLabel) : "") + " " + status);
|
textView.setText((textLabel != 0 ? MainApp.gs(textLabel) : "") + " " + status);
|
||||||
layout.addView(textView);
|
layout.addView(textView);
|
||||||
if (listener != null)
|
|
||||||
try {
|
|
||||||
MainApp.bus().register(listener);
|
|
||||||
} catch (Exception ignored) {}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
|
||||||
public void onEventSWLabel(final EventSWLabel l) {
|
|
||||||
status = l.label;
|
|
||||||
if (definition != null && definition.getActivity() != null)
|
|
||||||
definition.getActivity().runOnUiThread(() -> {
|
|
||||||
if (textView != null)
|
|
||||||
textView.setText((textLabel != 0 ? MainApp.gs(textLabel) : "") + " " + status);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,17 +26,22 @@ import info.nightscout.androidaps.activities.NoSplashAppCompatActivity;
|
||||||
import info.nightscout.androidaps.events.EventProfileNeedsUpdate;
|
import info.nightscout.androidaps.events.EventProfileNeedsUpdate;
|
||||||
import info.nightscout.androidaps.events.EventProfileStoreChanged;
|
import info.nightscout.androidaps.events.EventProfileStoreChanged;
|
||||||
import info.nightscout.androidaps.events.EventPumpStatusChanged;
|
import info.nightscout.androidaps.events.EventPumpStatusChanged;
|
||||||
|
import info.nightscout.androidaps.plugins.bus.RxBus;
|
||||||
import info.nightscout.androidaps.plugins.general.nsclient.events.EventNSClientStatus;
|
import info.nightscout.androidaps.plugins.general.nsclient.events.EventNSClientStatus;
|
||||||
import info.nightscout.androidaps.setupwizard.elements.SWItem;
|
import info.nightscout.androidaps.setupwizard.elements.SWItem;
|
||||||
import info.nightscout.androidaps.setupwizard.events.EventSWUpdate;
|
import info.nightscout.androidaps.setupwizard.events.EventSWUpdate;
|
||||||
import info.nightscout.androidaps.utils.AndroidPermission;
|
import info.nightscout.androidaps.utils.AndroidPermission;
|
||||||
|
import info.nightscout.androidaps.utils.FabricPrivacy;
|
||||||
import info.nightscout.androidaps.utils.LocaleHelper;
|
import info.nightscout.androidaps.utils.LocaleHelper;
|
||||||
import info.nightscout.androidaps.utils.OKDialog;
|
import info.nightscout.androidaps.utils.OKDialog;
|
||||||
import info.nightscout.androidaps.utils.SP;
|
import info.nightscout.androidaps.utils.SP;
|
||||||
|
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||||
|
import io.reactivex.disposables.CompositeDisposable;
|
||||||
|
|
||||||
public class SetupWizardActivity extends NoSplashAppCompatActivity {
|
public class SetupWizardActivity extends NoSplashAppCompatActivity {
|
||||||
//logging
|
//logging
|
||||||
private static Logger log = LoggerFactory.getLogger(SetupWizardActivity.class);
|
private static Logger log = LoggerFactory.getLogger(SetupWizardActivity.class);
|
||||||
|
private CompositeDisposable disposable = new CompositeDisposable();
|
||||||
|
|
||||||
ScrollView scrollView;
|
ScrollView scrollView;
|
||||||
|
|
||||||
|
@ -84,6 +89,7 @@ public class SetupWizardActivity extends NoSplashAppCompatActivity {
|
||||||
public void onPause() {
|
public void onPause() {
|
||||||
super.onPause();
|
super.onPause();
|
||||||
MainApp.bus().unregister(this);
|
MainApp.bus().unregister(this);
|
||||||
|
disposable.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -91,6 +97,16 @@ public class SetupWizardActivity extends NoSplashAppCompatActivity {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
MainApp.bus().register(this);
|
MainApp.bus().register(this);
|
||||||
swDefinition.setActivity(this);
|
swDefinition.setActivity(this);
|
||||||
|
disposable.add(RxBus.INSTANCE
|
||||||
|
.toObservable(EventPumpStatusChanged.class)
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.subscribe(event -> updateButtons(), FabricPrivacy::logException)
|
||||||
|
);
|
||||||
|
disposable.add(RxBus.INSTANCE
|
||||||
|
.toObservable(EventNSClientStatus.class)
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.subscribe(event -> updateButtons(), FabricPrivacy::logException)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
|
@ -100,16 +116,6 @@ public class SetupWizardActivity extends NoSplashAppCompatActivity {
|
||||||
updateButtons();
|
updateButtons();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
|
||||||
public void onEventNSClientStatus(EventNSClientStatus ignored) {
|
|
||||||
updateButtons();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Subscribe
|
|
||||||
public void onEventPumpStatusChanged(EventPumpStatusChanged ignored) {
|
|
||||||
updateButtons();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onEventProfileStoreChanged(EventProfileStoreChanged ignored) {
|
public void onEventProfileStoreChanged(EventProfileStoreChanged ignored) {
|
||||||
updateButtons();
|
updateButtons();
|
||||||
|
|
|
@ -17,6 +17,7 @@ import info.nightscout.androidaps.interfaces.PumpDescription
|
||||||
import info.nightscout.androidaps.interfaces.PumpInterface
|
import info.nightscout.androidaps.interfaces.PumpInterface
|
||||||
import info.nightscout.androidaps.logging.L
|
import info.nightscout.androidaps.logging.L
|
||||||
import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin
|
import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin
|
||||||
|
import info.nightscout.androidaps.plugins.bus.RxBus
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin
|
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctions
|
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctions
|
||||||
import info.nightscout.androidaps.plugins.general.overview.dialogs.ErrorHelperActivity
|
import info.nightscout.androidaps.plugins.general.overview.dialogs.ErrorHelperActivity
|
||||||
|
@ -284,7 +285,7 @@ class BolusWizard @JvmOverloads constructor(val profile: Profile,
|
||||||
val loopPlugin = LoopPlugin.getPlugin()
|
val loopPlugin = LoopPlugin.getPlugin()
|
||||||
if (loopPlugin.isEnabled(PluginType.LOOP)) {
|
if (loopPlugin.isEnabled(PluginType.LOOP)) {
|
||||||
loopPlugin.superBolusTo(System.currentTimeMillis() + 2 * 60L * 60 * 1000)
|
loopPlugin.superBolusTo(System.currentTimeMillis() + 2 * 60L * 60 * 1000)
|
||||||
MainApp.bus().post(EventRefreshOverview("WizardDialog"))
|
RxBus.send(EventRefreshOverview("WizardDialog"))
|
||||||
}
|
}
|
||||||
|
|
||||||
val pump1 = ConfigBuilderPlugin.getPlugin().activePump
|
val pump1 = ConfigBuilderPlugin.getPlugin().activePump
|
||||||
|
|
Loading…
Reference in a new issue