From 5a446c9ab51a015203a2f9ca8bb7e63429f9411b Mon Sep 17 00:00:00 2001 From: Johannes Mockenhaupt Date: Sat, 14 Oct 2017 15:24:41 +0200 Subject: [PATCH 01/13] Log posted events. --- .../info/nightscout/androidaps/Config.java | 1 + .../nightscout/androidaps/LoggingBus.java | 22 +++++++++++++++++++ .../info/nightscout/androidaps/MainApp.java | 4 +++- 3 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 app/src/main/java/info/nightscout/androidaps/LoggingBus.java diff --git a/app/src/main/java/info/nightscout/androidaps/Config.java b/app/src/main/java/info/nightscout/androidaps/Config.java index abda0ca941..6bbc908188 100644 --- a/app/src/main/java/info/nightscout/androidaps/Config.java +++ b/app/src/main/java/info/nightscout/androidaps/Config.java @@ -40,6 +40,7 @@ public class Config { public static final boolean logPumpActions = true; public static final boolean logCongigBuilderActions = true; public static final boolean logAutosensData = false; + public static final boolean logEvents = true; // DanaR specific public static final boolean logDanaBTComm = true; diff --git a/app/src/main/java/info/nightscout/androidaps/LoggingBus.java b/app/src/main/java/info/nightscout/androidaps/LoggingBus.java new file mode 100644 index 0000000000..8b5664b511 --- /dev/null +++ b/app/src/main/java/info/nightscout/androidaps/LoggingBus.java @@ -0,0 +1,22 @@ +package info.nightscout.androidaps; + +import com.squareup.otto.Bus; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +class LoggingBus extends Bus { + private static Logger log = LoggerFactory.getLogger(LoggingBus.class); + + private final Bus delegate; + + public LoggingBus(Bus bus) { + delegate = bus; + } + + @Override + public void post(Object event) { + log.debug("Event posted: " + event); + super.post(event); + } +} diff --git a/app/src/main/java/info/nightscout/androidaps/MainApp.java b/app/src/main/java/info/nightscout/androidaps/MainApp.java index 209adfe1c4..3392a0193a 100644 --- a/app/src/main/java/info/nightscout/androidaps/MainApp.java +++ b/app/src/main/java/info/nightscout/androidaps/MainApp.java @@ -104,7 +104,9 @@ public class MainApp extends Application { log.info("Version: " + BuildConfig.VERSION_NAME); log.info("BuildVersion: " + BuildConfig.BUILDVERSION); - sBus = new Bus(ThreadEnforcer.ANY); + Bus bus = new Bus(ThreadEnforcer.ANY); + sBus = Config.logEvents ? new LoggingBus(bus) : bus; + sInstance = this; sResources = getResources(); From 8ad223e5e1b46322afb3083d68be59338181f399 Mon Sep 17 00:00:00 2001 From: Johannes Mockenhaupt Date: Sat, 14 Oct 2017 15:31:03 +0200 Subject: [PATCH 02/13] Add base event class. --- app/build.gradle | 1 + .../java/info/nightscout/androidaps/events/Event.java | 10 ++++++++++ 2 files changed, 11 insertions(+) create mode 100644 app/src/main/java/info/nightscout/androidaps/events/Event.java diff --git a/app/build.gradle b/app/build.gradle index 30158bf591..6d877e80a4 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -150,6 +150,7 @@ dependencies { compile('com.github.tony19:logback-android-classic:1.1.1-6') { exclude group: 'com.google.android', module: 'android' } + compile 'org.apache.commons:commons-lang3:3.6' compile 'org.slf4j:slf4j-api:1.7.12' compile 'com.jjoe64:graphview:4.0.1' compile 'com.eclipsesource.j2v8:j2v8:3.1.6@aar' diff --git a/app/src/main/java/info/nightscout/androidaps/events/Event.java b/app/src/main/java/info/nightscout/androidaps/events/Event.java new file mode 100644 index 0000000000..dc35856253 --- /dev/null +++ b/app/src/main/java/info/nightscout/androidaps/events/Event.java @@ -0,0 +1,10 @@ +package info.nightscout.androidaps.events; + +import org.apache.commons.lang3.builder.ReflectionToStringBuilder; + +abstract class Event { + @Override + public String toString() { + return ReflectionToStringBuilder.toString(this); + } +} From 302ed695643d5d9d03f709b0564a3b425f8dd35b Mon Sep 17 00:00:00 2001 From: Johannes Mockenhaupt Date: Sat, 14 Oct 2017 16:06:01 +0200 Subject: [PATCH 03/13] Let event classes extend Event(UpdageGui) classes. --- .../info/nightscout/androidaps/LoggingBus.java | 14 +++++++++++++- .../info/nightscout/androidaps/events/Event.java | 2 +- .../nightscout/androidaps/events/EventAppExit.java | 2 +- .../androidaps/events/EventBolusRequested.java | 2 +- .../events/EventCareportalEventChange.java | 2 +- .../events/EventConfigBuilderChange.java | 2 +- .../events/EventExtendedBolusChange.java | 2 +- .../events/EventFoodDatabaseChanged.java | 2 +- .../events/EventInitializationChanged.java | 2 +- .../nightscout/androidaps/events/EventNewBG.java | 2 +- .../androidaps/events/EventNewBasalProfile.java | 2 +- .../androidaps/events/EventPreferenceChange.java | 2 +- .../events/EventProfileSwitchChange.java | 2 +- .../androidaps/events/EventPumpStatusChanged.java | 2 +- .../androidaps/events/EventRefreshGui.java | 2 +- .../androidaps/events/EventRefreshOverview.java | 2 +- .../events/EventReloadProfileSwitchData.java | 2 +- .../events/EventReloadTempBasalData.java | 2 +- .../events/EventReloadTreatmentData.java | 2 +- .../androidaps/events/EventTempBasalChange.java | 2 +- .../androidaps/events/EventTempTargetChange.java | 2 +- .../androidaps/events/EventTreatmentChange.java | 2 +- .../androidaps/events/EventUpdateGui.java | 4 ++++ .../events/EventAutosensCalculationFinished.java | 4 +++- .../events/EventNewHistoryData.java | 4 +++- .../Loop/events/EventLoopSetLastRunGui.java | 4 +++- .../plugins/Loop/events/EventLoopUpdateGui.java | 4 +++- .../Loop/events/EventNewOpenLoopNotification.java | 4 +++- .../plugins/NSClientInternal/acks/NSAddAck.java | 4 ++-- .../plugins/NSClientInternal/acks/NSAuthAck.java | 3 ++- .../plugins/NSClientInternal/acks/NSUpdateAck.java | 3 ++- .../events/EventNSClientNewLog.java | 10 +++------- .../events/EventNSClientRestart.java | 4 +++- .../events/EventNSClientStatus.java | 4 +++- .../events/EventNSClientUpdateGUI.java | 4 +++- .../OpenAPSMA/events/EventOpenAPSUpdateGui.java | 4 +++- .../events/EventOpenAPSUpdateResultGui.java | 4 +++- .../events/EventDismissBolusprogressIfRunning.java | 3 ++- .../Overview/events/EventDismissNotification.java | 4 +++- .../Overview/events/EventNewNotification.java | 3 ++- .../events/EventOverviewBolusProgress.java | 3 ++- .../Overview/events/EventQuickWizardChange.java | 4 +++- .../plugins/Overview/events/EventSetWakeLock.java | 4 +++- .../ProfileNS/events/EventNSProfileUpdateGUI.java | 4 +++- .../PumpDanaR/events/EventDanaRBolusStart.java | 4 +++- .../PumpDanaR/events/EventDanaRNewStatus.java | 4 +++- .../PumpDanaR/events/EventDanaRSyncStatus.java | 4 +++- .../events/EventVirtualPumpUpdateGui.java | 4 +++- .../SmsCommunicator/events/EventNewSMS.java | 4 +++- .../events/EventSmsCommunicatorUpdateGui.java | 4 +++- 50 files changed, 113 insertions(+), 56 deletions(-) create mode 100644 app/src/main/java/info/nightscout/androidaps/events/EventUpdateGui.java diff --git a/app/src/main/java/info/nightscout/androidaps/LoggingBus.java b/app/src/main/java/info/nightscout/androidaps/LoggingBus.java index 8b5664b511..249e273c3d 100644 --- a/app/src/main/java/info/nightscout/androidaps/LoggingBus.java +++ b/app/src/main/java/info/nightscout/androidaps/LoggingBus.java @@ -1,10 +1,13 @@ package info.nightscout.androidaps; import com.squareup.otto.Bus; +import com.squareup.otto.DeadEvent; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import info.nightscout.androidaps.events.Event; + class LoggingBus extends Bus { private static Logger log = LoggerFactory.getLogger(LoggingBus.class); @@ -16,7 +19,16 @@ class LoggingBus extends Bus { @Override public void post(Object event) { + if (event instanceof DeadEvent) { + log.debug("Event has no receiver:" + ((DeadEvent) event).event + ", source: " + ((DeadEvent) event).source); + return; + } + + if (!(event instanceof Event)) { + log.error("Posted event not an event class: " + event.getClass()); + } + log.debug("Event posted: " + event); - super.post(event); + delegate.post(event); } } diff --git a/app/src/main/java/info/nightscout/androidaps/events/Event.java b/app/src/main/java/info/nightscout/androidaps/events/Event.java index dc35856253..1bbbf8971a 100644 --- a/app/src/main/java/info/nightscout/androidaps/events/Event.java +++ b/app/src/main/java/info/nightscout/androidaps/events/Event.java @@ -2,7 +2,7 @@ package info.nightscout.androidaps.events; import org.apache.commons.lang3.builder.ReflectionToStringBuilder; -abstract class Event { +public abstract class Event { @Override public String toString() { return ReflectionToStringBuilder.toString(this); diff --git a/app/src/main/java/info/nightscout/androidaps/events/EventAppExit.java b/app/src/main/java/info/nightscout/androidaps/events/EventAppExit.java index 0f23643fef..9ce91a9a39 100644 --- a/app/src/main/java/info/nightscout/androidaps/events/EventAppExit.java +++ b/app/src/main/java/info/nightscout/androidaps/events/EventAppExit.java @@ -3,5 +3,5 @@ package info.nightscout.androidaps.events; /** * Created by mike on 07.07.2016. */ -public class EventAppExit { +public class EventAppExit extends Event { } diff --git a/app/src/main/java/info/nightscout/androidaps/events/EventBolusRequested.java b/app/src/main/java/info/nightscout/androidaps/events/EventBolusRequested.java index 1f41119b4b..cb727758bb 100644 --- a/app/src/main/java/info/nightscout/androidaps/events/EventBolusRequested.java +++ b/app/src/main/java/info/nightscout/androidaps/events/EventBolusRequested.java @@ -4,7 +4,7 @@ package info.nightscout.androidaps.events; * Created by adrian on 07/02/17. */ -public class EventBolusRequested { +public class EventBolusRequested extends Event { private double amount; public EventBolusRequested (double amount){ diff --git a/app/src/main/java/info/nightscout/androidaps/events/EventCareportalEventChange.java b/app/src/main/java/info/nightscout/androidaps/events/EventCareportalEventChange.java index d86fe679fb..9b47ed39cb 100644 --- a/app/src/main/java/info/nightscout/androidaps/events/EventCareportalEventChange.java +++ b/app/src/main/java/info/nightscout/androidaps/events/EventCareportalEventChange.java @@ -4,5 +4,5 @@ package info.nightscout.androidaps.events; * Created by mike on 25.05.2017. */ -public class EventCareportalEventChange { +public class EventCareportalEventChange extends Event { } diff --git a/app/src/main/java/info/nightscout/androidaps/events/EventConfigBuilderChange.java b/app/src/main/java/info/nightscout/androidaps/events/EventConfigBuilderChange.java index 38331ca581..ad5f558fe8 100644 --- a/app/src/main/java/info/nightscout/androidaps/events/EventConfigBuilderChange.java +++ b/app/src/main/java/info/nightscout/androidaps/events/EventConfigBuilderChange.java @@ -4,5 +4,5 @@ package info.nightscout.androidaps.events; * Created by mike on 17.02.2017. */ -public class EventConfigBuilderChange { +public class EventConfigBuilderChange extends Event { } diff --git a/app/src/main/java/info/nightscout/androidaps/events/EventExtendedBolusChange.java b/app/src/main/java/info/nightscout/androidaps/events/EventExtendedBolusChange.java index 78dee60388..8881b0ecc1 100644 --- a/app/src/main/java/info/nightscout/androidaps/events/EventExtendedBolusChange.java +++ b/app/src/main/java/info/nightscout/androidaps/events/EventExtendedBolusChange.java @@ -4,5 +4,5 @@ package info.nightscout.androidaps.events; * Created by mike on 15.05.2017. */ -public class EventExtendedBolusChange { +public class EventExtendedBolusChange extends Event { } diff --git a/app/src/main/java/info/nightscout/androidaps/events/EventFoodDatabaseChanged.java b/app/src/main/java/info/nightscout/androidaps/events/EventFoodDatabaseChanged.java index 075993c530..48e6be3a14 100644 --- a/app/src/main/java/info/nightscout/androidaps/events/EventFoodDatabaseChanged.java +++ b/app/src/main/java/info/nightscout/androidaps/events/EventFoodDatabaseChanged.java @@ -4,5 +4,5 @@ package info.nightscout.androidaps.events; * Created by mike on 20.09.2017. */ -public class EventFoodDatabaseChanged { +public class EventFoodDatabaseChanged extends Event { } diff --git a/app/src/main/java/info/nightscout/androidaps/events/EventInitializationChanged.java b/app/src/main/java/info/nightscout/androidaps/events/EventInitializationChanged.java index e9a9ce511d..f2bef1d3d0 100644 --- a/app/src/main/java/info/nightscout/androidaps/events/EventInitializationChanged.java +++ b/app/src/main/java/info/nightscout/androidaps/events/EventInitializationChanged.java @@ -4,5 +4,5 @@ package info.nightscout.androidaps.events; * Created by mike on 13.12.2016. */ -public class EventInitializationChanged { +public class EventInitializationChanged extends Event { } diff --git a/app/src/main/java/info/nightscout/androidaps/events/EventNewBG.java b/app/src/main/java/info/nightscout/androidaps/events/EventNewBG.java index 2d6454406a..eb304a81b2 100644 --- a/app/src/main/java/info/nightscout/androidaps/events/EventNewBG.java +++ b/app/src/main/java/info/nightscout/androidaps/events/EventNewBG.java @@ -3,5 +3,5 @@ package info.nightscout.androidaps.events; /** * Created by mike on 05.06.2016. */ -public class EventNewBG { +public class EventNewBG extends Event { } diff --git a/app/src/main/java/info/nightscout/androidaps/events/EventNewBasalProfile.java b/app/src/main/java/info/nightscout/androidaps/events/EventNewBasalProfile.java index 1309625b98..f26a310b6b 100644 --- a/app/src/main/java/info/nightscout/androidaps/events/EventNewBasalProfile.java +++ b/app/src/main/java/info/nightscout/androidaps/events/EventNewBasalProfile.java @@ -3,5 +3,5 @@ package info.nightscout.androidaps.events; /** * Created by mike on 04.06.2016. */ -public class EventNewBasalProfile { +public class EventNewBasalProfile extends Event { } diff --git a/app/src/main/java/info/nightscout/androidaps/events/EventPreferenceChange.java b/app/src/main/java/info/nightscout/androidaps/events/EventPreferenceChange.java index 76da0a4e67..f99cb54568 100644 --- a/app/src/main/java/info/nightscout/androidaps/events/EventPreferenceChange.java +++ b/app/src/main/java/info/nightscout/androidaps/events/EventPreferenceChange.java @@ -5,7 +5,7 @@ import info.nightscout.androidaps.MainApp; /** * Created by mike on 19.06.2016. */ -public class EventPreferenceChange { +public class EventPreferenceChange extends Event { public String changedKey; public EventPreferenceChange(String key) { changedKey = key; diff --git a/app/src/main/java/info/nightscout/androidaps/events/EventProfileSwitchChange.java b/app/src/main/java/info/nightscout/androidaps/events/EventProfileSwitchChange.java index 476a571d70..7bab9d4518 100644 --- a/app/src/main/java/info/nightscout/androidaps/events/EventProfileSwitchChange.java +++ b/app/src/main/java/info/nightscout/androidaps/events/EventProfileSwitchChange.java @@ -4,5 +4,5 @@ package info.nightscout.androidaps.events; * Created by mike on 02.06.2017. */ -public class EventProfileSwitchChange { +public class EventProfileSwitchChange extends Event { } diff --git a/app/src/main/java/info/nightscout/androidaps/events/EventPumpStatusChanged.java b/app/src/main/java/info/nightscout/androidaps/events/EventPumpStatusChanged.java index 3cfe7cc6a7..52c3183821 100644 --- a/app/src/main/java/info/nightscout/androidaps/events/EventPumpStatusChanged.java +++ b/app/src/main/java/info/nightscout/androidaps/events/EventPumpStatusChanged.java @@ -7,7 +7,7 @@ import info.nightscout.androidaps.R; * Created by mike on 19.02.2017. */ -public class EventPumpStatusChanged { +public class EventPumpStatusChanged extends Event { public static final int CONNECTING = 0; public static final int CONNECTED = 1; public static final int PERFORMING = 2; diff --git a/app/src/main/java/info/nightscout/androidaps/events/EventRefreshGui.java b/app/src/main/java/info/nightscout/androidaps/events/EventRefreshGui.java index f20dfb9329..1dae34d2af 100644 --- a/app/src/main/java/info/nightscout/androidaps/events/EventRefreshGui.java +++ b/app/src/main/java/info/nightscout/androidaps/events/EventRefreshGui.java @@ -3,5 +3,5 @@ package info.nightscout.androidaps.events; /** * Created by mike on 13.06.2016. */ -public class EventRefreshGui { +public class EventRefreshGui extends Event { } diff --git a/app/src/main/java/info/nightscout/androidaps/events/EventRefreshOverview.java b/app/src/main/java/info/nightscout/androidaps/events/EventRefreshOverview.java index bf14f5f585..2ba78fa9ec 100644 --- a/app/src/main/java/info/nightscout/androidaps/events/EventRefreshOverview.java +++ b/app/src/main/java/info/nightscout/androidaps/events/EventRefreshOverview.java @@ -4,7 +4,7 @@ package info.nightscout.androidaps.events; * Created by mike on 16.06.2017. */ -public class EventRefreshOverview { +public class EventRefreshOverview extends Event { public String from; public EventRefreshOverview(String from) { diff --git a/app/src/main/java/info/nightscout/androidaps/events/EventReloadProfileSwitchData.java b/app/src/main/java/info/nightscout/androidaps/events/EventReloadProfileSwitchData.java index 20073a7cf0..212e8856d9 100644 --- a/app/src/main/java/info/nightscout/androidaps/events/EventReloadProfileSwitchData.java +++ b/app/src/main/java/info/nightscout/androidaps/events/EventReloadProfileSwitchData.java @@ -4,5 +4,5 @@ package info.nightscout.androidaps.events; * Created by mike on 12.06.2017. */ -public class EventReloadProfileSwitchData { +public class EventReloadProfileSwitchData extends Event { } diff --git a/app/src/main/java/info/nightscout/androidaps/events/EventReloadTempBasalData.java b/app/src/main/java/info/nightscout/androidaps/events/EventReloadTempBasalData.java index 38b1b86186..80125cbb4a 100644 --- a/app/src/main/java/info/nightscout/androidaps/events/EventReloadTempBasalData.java +++ b/app/src/main/java/info/nightscout/androidaps/events/EventReloadTempBasalData.java @@ -4,5 +4,5 @@ package info.nightscout.androidaps.events; * Created by mike on 29.05.2017. */ -public class EventReloadTempBasalData { +public class EventReloadTempBasalData extends Event { } diff --git a/app/src/main/java/info/nightscout/androidaps/events/EventReloadTreatmentData.java b/app/src/main/java/info/nightscout/androidaps/events/EventReloadTreatmentData.java index d4ea0d3f70..0ba9b95ad7 100644 --- a/app/src/main/java/info/nightscout/androidaps/events/EventReloadTreatmentData.java +++ b/app/src/main/java/info/nightscout/androidaps/events/EventReloadTreatmentData.java @@ -4,7 +4,7 @@ package info.nightscout.androidaps.events; * Created by mike on 29.05.2017. */ -public class EventReloadTreatmentData { +public class EventReloadTreatmentData extends Event { public Object next; public EventReloadTreatmentData(Object next) { diff --git a/app/src/main/java/info/nightscout/androidaps/events/EventTempBasalChange.java b/app/src/main/java/info/nightscout/androidaps/events/EventTempBasalChange.java index 5d8f961e75..8efd1d46e2 100644 --- a/app/src/main/java/info/nightscout/androidaps/events/EventTempBasalChange.java +++ b/app/src/main/java/info/nightscout/androidaps/events/EventTempBasalChange.java @@ -3,5 +3,5 @@ package info.nightscout.androidaps.events; /** * Created by mike on 05.06.2016. */ -public class EventTempBasalChange { +public class EventTempBasalChange extends Event { } diff --git a/app/src/main/java/info/nightscout/androidaps/events/EventTempTargetChange.java b/app/src/main/java/info/nightscout/androidaps/events/EventTempTargetChange.java index d0ef42d830..4e3bf5c5f8 100644 --- a/app/src/main/java/info/nightscout/androidaps/events/EventTempTargetChange.java +++ b/app/src/main/java/info/nightscout/androidaps/events/EventTempTargetChange.java @@ -4,5 +4,5 @@ package info.nightscout.androidaps.events; * Created by mike on 13.01.2017. */ -public class EventTempTargetChange { +public class EventTempTargetChange extends Event { } diff --git a/app/src/main/java/info/nightscout/androidaps/events/EventTreatmentChange.java b/app/src/main/java/info/nightscout/androidaps/events/EventTreatmentChange.java index a8597189bc..dd5eb519e3 100644 --- a/app/src/main/java/info/nightscout/androidaps/events/EventTreatmentChange.java +++ b/app/src/main/java/info/nightscout/androidaps/events/EventTreatmentChange.java @@ -3,5 +3,5 @@ package info.nightscout.androidaps.events; /** * Created by mike on 04.06.2016. */ -public class EventTreatmentChange { +public class EventTreatmentChange extends Event { } diff --git a/app/src/main/java/info/nightscout/androidaps/events/EventUpdateGui.java b/app/src/main/java/info/nightscout/androidaps/events/EventUpdateGui.java new file mode 100644 index 0000000000..5edb7b7a9a --- /dev/null +++ b/app/src/main/java/info/nightscout/androidaps/events/EventUpdateGui.java @@ -0,0 +1,4 @@ +package info.nightscout.androidaps.events; + +public abstract class EventUpdateGui extends Event { +} diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/IobCobCalculator/events/EventAutosensCalculationFinished.java b/app/src/main/java/info/nightscout/androidaps/plugins/IobCobCalculator/events/EventAutosensCalculationFinished.java index f2977c90c5..c94021e185 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/IobCobCalculator/events/EventAutosensCalculationFinished.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/IobCobCalculator/events/EventAutosensCalculationFinished.java @@ -1,8 +1,10 @@ package info.nightscout.androidaps.plugins.IobCobCalculator.events; +import info.nightscout.androidaps.events.Event; + /** * Created by mike on 30.04.2017. */ -public class EventAutosensCalculationFinished { +public class EventAutosensCalculationFinished extends Event { } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/IobCobCalculator/events/EventNewHistoryData.java b/app/src/main/java/info/nightscout/androidaps/plugins/IobCobCalculator/events/EventNewHistoryData.java index 7499fad383..8814741099 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/IobCobCalculator/events/EventNewHistoryData.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/IobCobCalculator/events/EventNewHistoryData.java @@ -1,10 +1,12 @@ package info.nightscout.androidaps.plugins.IobCobCalculator.events; +import info.nightscout.androidaps.events.Event; + /** * Created by mike on 26.04.2017. */ -public class EventNewHistoryData { +public class EventNewHistoryData extends Event { public long time = 0; public EventNewHistoryData(long time) { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Loop/events/EventLoopSetLastRunGui.java b/app/src/main/java/info/nightscout/androidaps/plugins/Loop/events/EventLoopSetLastRunGui.java index 7baf556546..1ef5dc4c94 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Loop/events/EventLoopSetLastRunGui.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Loop/events/EventLoopSetLastRunGui.java @@ -1,9 +1,11 @@ package info.nightscout.androidaps.plugins.Loop.events; +import info.nightscout.androidaps.events.EventUpdateGui; + /** * Created by mike on 05.08.2016. */ -public class EventLoopSetLastRunGui { +public class EventLoopSetLastRunGui extends EventUpdateGui { public String text = null; public EventLoopSetLastRunGui(String text) { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Loop/events/EventLoopUpdateGui.java b/app/src/main/java/info/nightscout/androidaps/plugins/Loop/events/EventLoopUpdateGui.java index d671b3bd64..d4417dbb12 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Loop/events/EventLoopUpdateGui.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Loop/events/EventLoopUpdateGui.java @@ -1,7 +1,9 @@ package info.nightscout.androidaps.plugins.Loop.events; +import info.nightscout.androidaps.events.EventUpdateGui; + /** * Created by mike on 05.08.2016. */ -public class EventLoopUpdateGui { +public class EventLoopUpdateGui extends EventUpdateGui { } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Loop/events/EventNewOpenLoopNotification.java b/app/src/main/java/info/nightscout/androidaps/plugins/Loop/events/EventNewOpenLoopNotification.java index 7a6184e406..001d11661e 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Loop/events/EventNewOpenLoopNotification.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Loop/events/EventNewOpenLoopNotification.java @@ -1,7 +1,9 @@ package info.nightscout.androidaps.plugins.Loop.events; +import info.nightscout.androidaps.events.Event; + /** * Created by mike on 07.08.2016. */ -public class EventNewOpenLoopNotification { +public class EventNewOpenLoopNotification extends Event { } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/acks/NSAddAck.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/acks/NSAddAck.java index 709c53f6d4..e90dce3bec 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/acks/NSAddAck.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/acks/NSAddAck.java @@ -7,14 +7,14 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import info.nightscout.androidaps.MainApp; +import info.nightscout.androidaps.events.Event; import info.nightscout.androidaps.plugins.NSClientInternal.events.EventNSClientRestart; -import info.nightscout.androidaps.plugins.NSClientInternal.services.NSClientService; import io.socket.client.Ack; /** * Created by mike on 29.12.2015. */ -public class NSAddAck implements Ack { +public class NSAddAck extends Event implements Ack { private static Logger log = LoggerFactory.getLogger(NSAddAck.class); public String _id = null; public String nsClientID = null; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/acks/NSAuthAck.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/acks/NSAuthAck.java index 3c3b173173..56055351d9 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/acks/NSAuthAck.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/acks/NSAuthAck.java @@ -3,13 +3,14 @@ package info.nightscout.androidaps.plugins.NSClientInternal.acks; import org.json.JSONObject; import info.nightscout.androidaps.MainApp; +import info.nightscout.androidaps.events.Event; import info.nightscout.androidaps.plugins.NSClientInternal.events.EventNSClientNewLog; import io.socket.client.Ack; /** * Created by mike on 02.01.2016. */ -public class NSAuthAck implements Ack{ +public class NSAuthAck extends Event implements Ack{ public boolean read = false; public boolean write = false; public boolean write_treatment = false; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/acks/NSUpdateAck.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/acks/NSUpdateAck.java index 5aef754d8c..2bf520da64 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/acks/NSUpdateAck.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/acks/NSUpdateAck.java @@ -6,12 +6,13 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import info.nightscout.androidaps.MainApp; +import info.nightscout.androidaps.events.Event; import io.socket.client.Ack; /** * Created by mike on 21.02.2016. */ -public class NSUpdateAck implements Ack { +public class NSUpdateAck extends Event implements Ack { private static Logger log = LoggerFactory.getLogger(NSUpdateAck.class); public boolean result = false; public String _id = null; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/events/EventNSClientNewLog.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/events/EventNSClientNewLog.java index 7caafbd28a..82b11a812d 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/events/EventNSClientNewLog.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/events/EventNSClientNewLog.java @@ -1,19 +1,15 @@ package info.nightscout.androidaps.plugins.NSClientInternal.events; -import android.text.Html; -import android.text.Spanned; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import java.text.SimpleDateFormat; import java.util.Date; +import info.nightscout.androidaps.events.Event; + /** * Created by mike on 15.02.2017. */ -public class EventNSClientNewLog { +public class EventNSClientNewLog extends Event { public Date date = new Date(); public String action; public String logText; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/events/EventNSClientRestart.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/events/EventNSClientRestart.java index 9bf90be31b..b968878da8 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/events/EventNSClientRestart.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/events/EventNSClientRestart.java @@ -1,8 +1,10 @@ package info.nightscout.androidaps.plugins.NSClientInternal.events; +import info.nightscout.androidaps.events.Event; + /** * Created by mike on 15.02.2017. */ -public class EventNSClientRestart { +public class EventNSClientRestart extends Event { } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/events/EventNSClientStatus.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/events/EventNSClientStatus.java index 6a1c721535..977c0e31fc 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/events/EventNSClientStatus.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/events/EventNSClientStatus.java @@ -1,9 +1,11 @@ package info.nightscout.androidaps.plugins.NSClientInternal.events; +import info.nightscout.androidaps.events.Event; + /** * Created by mike on 02.01.2016. */ -public class EventNSClientStatus { +public class EventNSClientStatus extends Event { public String status = ""; public EventNSClientStatus(String status) { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/events/EventNSClientUpdateGUI.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/events/EventNSClientUpdateGUI.java index 8f00bd3424..dd78d2cd28 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/events/EventNSClientUpdateGUI.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/events/EventNSClientUpdateGUI.java @@ -1,8 +1,10 @@ package info.nightscout.androidaps.plugins.NSClientInternal.events; +import info.nightscout.androidaps.events.EventUpdateGui; + /** * Created by mike on 17.02.2017. */ -public class EventNSClientUpdateGUI { +public class EventNSClientUpdateGUI extends EventUpdateGui { } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSMA/events/EventOpenAPSUpdateGui.java b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSMA/events/EventOpenAPSUpdateGui.java index 65b3b49d53..40f3c31973 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSMA/events/EventOpenAPSUpdateGui.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSMA/events/EventOpenAPSUpdateGui.java @@ -1,7 +1,9 @@ package info.nightscout.androidaps.plugins.OpenAPSMA.events; +import info.nightscout.androidaps.events.EventUpdateGui; + /** * Created by mike on 05.08.2016. */ -public class EventOpenAPSUpdateGui { +public class EventOpenAPSUpdateGui extends EventUpdateGui { } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSMA/events/EventOpenAPSUpdateResultGui.java b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSMA/events/EventOpenAPSUpdateResultGui.java index 2aa2365eff..e65cdd2c57 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSMA/events/EventOpenAPSUpdateResultGui.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSMA/events/EventOpenAPSUpdateResultGui.java @@ -1,9 +1,11 @@ package info.nightscout.androidaps.plugins.OpenAPSMA.events; +import info.nightscout.androidaps.events.EventUpdateGui; + /** * Created by mike on 05.08.2016. */ -public class EventOpenAPSUpdateResultGui { +public class EventOpenAPSUpdateResultGui extends EventUpdateGui { public String text = null; public EventOpenAPSUpdateResultGui(String text) { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/events/EventDismissBolusprogressIfRunning.java b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/events/EventDismissBolusprogressIfRunning.java index 9d8435eaf1..af336cd74c 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/events/EventDismissBolusprogressIfRunning.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/events/EventDismissBolusprogressIfRunning.java @@ -1,12 +1,13 @@ package info.nightscout.androidaps.plugins.Overview.events; import info.nightscout.androidaps.data.PumpEnactResult; +import info.nightscout.androidaps.events.Event; /** * Created by adrian on 20/02/17. */ -public class EventDismissBolusprogressIfRunning { +public class EventDismissBolusprogressIfRunning extends Event { public final PumpEnactResult result; public EventDismissBolusprogressIfRunning(PumpEnactResult result) { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/events/EventDismissNotification.java b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/events/EventDismissNotification.java index f2414e2a4e..1fa71febbe 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/events/EventDismissNotification.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/events/EventDismissNotification.java @@ -1,10 +1,12 @@ package info.nightscout.androidaps.plugins.Overview.events; +import info.nightscout.androidaps.events.Event; + /** * Created by mike on 03.12.2016. */ -public class EventDismissNotification { +public class EventDismissNotification extends Event { public int id; public EventDismissNotification(int did) { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/events/EventNewNotification.java b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/events/EventNewNotification.java index 8a80019f3e..59ad1a335d 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/events/EventNewNotification.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/events/EventNewNotification.java @@ -1,12 +1,13 @@ package info.nightscout.androidaps.plugins.Overview.events; +import info.nightscout.androidaps.events.Event; import info.nightscout.androidaps.plugins.Overview.Notification; /** * Created by mike on 03.12.2016. */ -public class EventNewNotification { +public class EventNewNotification extends Event { public Notification notification; public EventNewNotification(Notification n) { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/events/EventOverviewBolusProgress.java b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/events/EventOverviewBolusProgress.java index 0882032362..e0fd53a1fd 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/events/EventOverviewBolusProgress.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/events/EventOverviewBolusProgress.java @@ -4,8 +4,9 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import info.nightscout.androidaps.db.Treatment; +import info.nightscout.androidaps.events.Event; -public class EventOverviewBolusProgress { +public class EventOverviewBolusProgress extends Event { private static Logger log = LoggerFactory.getLogger(EventOverviewBolusProgress.class); public String status = ""; public Treatment t = null; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/events/EventQuickWizardChange.java b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/events/EventQuickWizardChange.java index 1a9923f606..b72c2548e2 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/events/EventQuickWizardChange.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/events/EventQuickWizardChange.java @@ -1,8 +1,10 @@ package info.nightscout.androidaps.plugins.Overview.events; +import info.nightscout.androidaps.events.Event; + /** * Created by mike on 20.10.2016. */ -public class EventQuickWizardChange { +public class EventQuickWizardChange extends Event { } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/events/EventSetWakeLock.java b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/events/EventSetWakeLock.java index 519341172d..49ccf9fbfb 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/events/EventSetWakeLock.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/events/EventSetWakeLock.java @@ -1,10 +1,12 @@ package info.nightscout.androidaps.plugins.Overview.events; +import info.nightscout.androidaps.events.Event; + /** * Created by mike on 02.07.2017. */ -public class EventSetWakeLock { +public class EventSetWakeLock extends Event { public boolean lock = false; public EventSetWakeLock(boolean val) { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/ProfileNS/events/EventNSProfileUpdateGUI.java b/app/src/main/java/info/nightscout/androidaps/plugins/ProfileNS/events/EventNSProfileUpdateGUI.java index 7bb5df792f..d24c59e511 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/ProfileNS/events/EventNSProfileUpdateGUI.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/ProfileNS/events/EventNSProfileUpdateGUI.java @@ -1,7 +1,9 @@ package info.nightscout.androidaps.plugins.ProfileNS.events; +import info.nightscout.androidaps.events.EventUpdateGui; + /** * Created by mike on 05.08.2016. */ -public class EventNSProfileUpdateGUI { +public class EventNSProfileUpdateGUI extends EventUpdateGui { } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/events/EventDanaRBolusStart.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/events/EventDanaRBolusStart.java index 8217b51432..9e3af48fb2 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/events/EventDanaRBolusStart.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/events/EventDanaRBolusStart.java @@ -1,7 +1,9 @@ package info.nightscout.androidaps.plugins.PumpDanaR.events; +import info.nightscout.androidaps.events.Event; + /** * Created by mike on 03.08.2016. */ -public class EventDanaRBolusStart { +public class EventDanaRBolusStart extends Event { } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/events/EventDanaRNewStatus.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/events/EventDanaRNewStatus.java index a04f27f2d6..55b0ab0998 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/events/EventDanaRNewStatus.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/events/EventDanaRNewStatus.java @@ -1,7 +1,9 @@ package info.nightscout.androidaps.plugins.PumpDanaR.events; +import info.nightscout.androidaps.events.Event; + /** * Created by mike on 08.07.2016. */ -public class EventDanaRNewStatus { +public class EventDanaRNewStatus extends Event { } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/events/EventDanaRSyncStatus.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/events/EventDanaRSyncStatus.java index b64cf22748..4e3f28de9d 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/events/EventDanaRSyncStatus.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/events/EventDanaRSyncStatus.java @@ -1,9 +1,11 @@ package info.nightscout.androidaps.plugins.PumpDanaR.events; +import info.nightscout.androidaps.events.Event; + /** * Created by mike on 20.07.2016. */ -public class EventDanaRSyncStatus { +public class EventDanaRSyncStatus extends Event { public String message; public EventDanaRSyncStatus() { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpVirtual/events/EventVirtualPumpUpdateGui.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpVirtual/events/EventVirtualPumpUpdateGui.java index 110e0f4a56..e035ea3aba 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpVirtual/events/EventVirtualPumpUpdateGui.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpVirtual/events/EventVirtualPumpUpdateGui.java @@ -1,7 +1,9 @@ package info.nightscout.androidaps.plugins.PumpVirtual.events; +import info.nightscout.androidaps.events.EventUpdateGui; + /** * Created by mike on 05.08.2016. */ -public class EventVirtualPumpUpdateGui { +public class EventVirtualPumpUpdateGui extends EventUpdateGui { } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/SmsCommunicator/events/EventNewSMS.java b/app/src/main/java/info/nightscout/androidaps/plugins/SmsCommunicator/events/EventNewSMS.java index 2b890fb59c..dfaebb3942 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/SmsCommunicator/events/EventNewSMS.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/SmsCommunicator/events/EventNewSMS.java @@ -2,10 +2,12 @@ package info.nightscout.androidaps.plugins.SmsCommunicator.events; import android.os.Bundle; +import info.nightscout.androidaps.events.Event; + /** * Created by mike on 13.07.2016. */ -public class EventNewSMS { +public class EventNewSMS extends Event { public Bundle bundle; public EventNewSMS(Bundle bundle) { this.bundle = bundle; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/SmsCommunicator/events/EventSmsCommunicatorUpdateGui.java b/app/src/main/java/info/nightscout/androidaps/plugins/SmsCommunicator/events/EventSmsCommunicatorUpdateGui.java index 7c1d480e72..02956a5d67 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/SmsCommunicator/events/EventSmsCommunicatorUpdateGui.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/SmsCommunicator/events/EventSmsCommunicatorUpdateGui.java @@ -1,7 +1,9 @@ package info.nightscout.androidaps.plugins.SmsCommunicator.events; +import info.nightscout.androidaps.events.EventUpdateGui; + /** * Created by mike on 05.08.2016. */ -public class EventSmsCommunicatorUpdateGui { +public class EventSmsCommunicatorUpdateGui extends EventUpdateGui { } From 3e24a6069db661195b738cc50489d2eeb3c00557 Mon Sep 17 00:00:00 2001 From: Johannes Mockenhaupt Date: Sat, 14 Oct 2017 16:11:19 +0200 Subject: [PATCH 04/13] Remove dead NSPingAck class. --- .../NSClientInternal/acks/NSPingAck.java | 44 ------------------- 1 file changed, 44 deletions(-) delete mode 100644 app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/acks/NSPingAck.java diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/acks/NSPingAck.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/acks/NSPingAck.java deleted file mode 100644 index 1ec6e3991c..0000000000 --- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/acks/NSPingAck.java +++ /dev/null @@ -1,44 +0,0 @@ -package info.nightscout.androidaps.plugins.NSClientInternal.acks; - -import android.os.SystemClock; - -import org.json.JSONException; -import org.json.JSONObject; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import io.socket.client.Ack; - -/** - * Created by mike on 29.12.2015. - */ -public class NSPingAck implements Ack { - private static Logger log = LoggerFactory.getLogger(NSPingAck.class); - - public long mills = 0; - public boolean received = false; - public boolean auth_received = false; - public boolean read = false; - public boolean write = false; - public boolean write_treatment = false; - - public void call(Object...args) { - JSONObject response = (JSONObject)args[0]; - mills = response.optLong("mills"); - if (response.has("authorization")) { - auth_received = true; - try { - JSONObject authorization = response.getJSONObject("authorization"); - read = authorization.optBoolean("read"); - write = authorization.optBoolean("write"); - write_treatment = authorization.optBoolean("write_treatment"); - } catch (JSONException e) { - log.error("Unhandled exception", e); - } - } - received = true; - synchronized(this) { - this.notify(); - } - } -} From 9d10563bd984946cb487b2d130bff0a85a64a33d Mon Sep 17 00:00:00 2001 From: Johannes Mockenhaupt Date: Sat, 14 Oct 2017 16:19:36 +0200 Subject: [PATCH 05/13] Group events in type hierarchy related to the LoopPlugin. --- .../main/java/info/nightscout/androidaps/events/Event.java | 1 + .../java/info/nightscout/androidaps/events/EventLoop.java | 5 +++++ .../java/info/nightscout/androidaps/events/EventNewBG.java | 2 +- .../nightscout/androidaps/events/EventTempBasalChange.java | 2 +- .../nightscout/androidaps/events/EventTreatmentChange.java | 2 +- .../info/nightscout/androidaps/events/EventUpdateGui.java | 1 + .../events/EventAutosensCalculationFinished.java | 4 ++-- 7 files changed, 12 insertions(+), 5 deletions(-) create mode 100644 app/src/main/java/info/nightscout/androidaps/events/EventLoop.java diff --git a/app/src/main/java/info/nightscout/androidaps/events/Event.java b/app/src/main/java/info/nightscout/androidaps/events/Event.java index 1bbbf8971a..77d1215362 100644 --- a/app/src/main/java/info/nightscout/androidaps/events/Event.java +++ b/app/src/main/java/info/nightscout/androidaps/events/Event.java @@ -2,6 +2,7 @@ package info.nightscout.androidaps.events; import org.apache.commons.lang3.builder.ReflectionToStringBuilder; +/** Base class for all events posted on the event bus. */ public abstract class Event { @Override public String toString() { diff --git a/app/src/main/java/info/nightscout/androidaps/events/EventLoop.java b/app/src/main/java/info/nightscout/androidaps/events/EventLoop.java new file mode 100644 index 0000000000..d694d52537 --- /dev/null +++ b/app/src/main/java/info/nightscout/androidaps/events/EventLoop.java @@ -0,0 +1,5 @@ +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 { +} diff --git a/app/src/main/java/info/nightscout/androidaps/events/EventNewBG.java b/app/src/main/java/info/nightscout/androidaps/events/EventNewBG.java index eb304a81b2..2fb9919b00 100644 --- a/app/src/main/java/info/nightscout/androidaps/events/EventNewBG.java +++ b/app/src/main/java/info/nightscout/androidaps/events/EventNewBG.java @@ -3,5 +3,5 @@ package info.nightscout.androidaps.events; /** * Created by mike on 05.06.2016. */ -public class EventNewBG extends Event { +public class EventNewBG extends EventLoop { } diff --git a/app/src/main/java/info/nightscout/androidaps/events/EventTempBasalChange.java b/app/src/main/java/info/nightscout/androidaps/events/EventTempBasalChange.java index 8efd1d46e2..73660bb00e 100644 --- a/app/src/main/java/info/nightscout/androidaps/events/EventTempBasalChange.java +++ b/app/src/main/java/info/nightscout/androidaps/events/EventTempBasalChange.java @@ -3,5 +3,5 @@ package info.nightscout.androidaps.events; /** * Created by mike on 05.06.2016. */ -public class EventTempBasalChange extends Event { +public class EventTempBasalChange extends EventLoop { } diff --git a/app/src/main/java/info/nightscout/androidaps/events/EventTreatmentChange.java b/app/src/main/java/info/nightscout/androidaps/events/EventTreatmentChange.java index dd5eb519e3..439d9a7124 100644 --- a/app/src/main/java/info/nightscout/androidaps/events/EventTreatmentChange.java +++ b/app/src/main/java/info/nightscout/androidaps/events/EventTreatmentChange.java @@ -3,5 +3,5 @@ package info.nightscout.androidaps.events; /** * Created by mike on 04.06.2016. */ -public class EventTreatmentChange extends Event { +public class EventTreatmentChange extends EventLoop { } diff --git a/app/src/main/java/info/nightscout/androidaps/events/EventUpdateGui.java b/app/src/main/java/info/nightscout/androidaps/events/EventUpdateGui.java index 5edb7b7a9a..3471d2e851 100644 --- a/app/src/main/java/info/nightscout/androidaps/events/EventUpdateGui.java +++ b/app/src/main/java/info/nightscout/androidaps/events/EventUpdateGui.java @@ -1,4 +1,5 @@ package info.nightscout.androidaps.events; +/** Base class for events to update the UI, mostly a specific tab. */ public abstract class EventUpdateGui extends Event { } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/IobCobCalculator/events/EventAutosensCalculationFinished.java b/app/src/main/java/info/nightscout/androidaps/plugins/IobCobCalculator/events/EventAutosensCalculationFinished.java index c94021e185..ea73915436 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/IobCobCalculator/events/EventAutosensCalculationFinished.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/IobCobCalculator/events/EventAutosensCalculationFinished.java @@ -1,10 +1,10 @@ package info.nightscout.androidaps.plugins.IobCobCalculator.events; -import info.nightscout.androidaps.events.Event; +import info.nightscout.androidaps.events.EventLoop; /** * Created by mike on 30.04.2017. */ -public class EventAutosensCalculationFinished extends Event { +public class EventAutosensCalculationFinished extends EventLoop { } From d83009648235e8654647413611f1b0750e8868d0 Mon Sep 17 00:00:00 2001 From: Johannes Mockenhaupt Date: Sat, 14 Oct 2017 16:29:33 +0200 Subject: [PATCH 06/13] Better log messages for events. --- .../main/java/info/nightscout/androidaps/events/Event.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/src/main/java/info/nightscout/androidaps/events/Event.java b/app/src/main/java/info/nightscout/androidaps/events/Event.java index 77d1215362..864d55d6f7 100644 --- a/app/src/main/java/info/nightscout/androidaps/events/Event.java +++ b/app/src/main/java/info/nightscout/androidaps/events/Event.java @@ -1,9 +1,14 @@ package info.nightscout.androidaps.events; import org.apache.commons.lang3.builder.ReflectionToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; /** Base class for all events posted on the event bus. */ public abstract class Event { + static { + ReflectionToStringBuilder.setDefaultStyle(ToStringStyle.SHORT_PREFIX_STYLE); + } + @Override public String toString() { return ReflectionToStringBuilder.toString(this); From a6ae3ddd2d443700c18d88c948f9baa8d91b910d Mon Sep 17 00:00:00 2001 From: Johannes Mockenhaupt Date: Sat, 14 Oct 2017 16:49:41 +0200 Subject: [PATCH 07/13] Debug: wider thread column in log to improve readability. --- app/src/main/assets/logback.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/assets/logback.xml b/app/src/main/assets/logback.xml index c34ff08b80..d089eb7f64 100644 --- a/app/src/main/assets/logback.xml +++ b/app/src/main/assets/logback.xml @@ -15,7 +15,7 @@ 120 - %d{HH:mm:ss.SSS} [%thread] %-5level [%file:%line]: %msg%n + %d{HH:mm:ss.SSS} [%-40thread] %-5level [%file:%line]: %msg%n @@ -24,7 +24,7 @@ %logger{0} - [%thread] %-5level [%file:%line]: %msg%n + [%-40thread] %-5level [%file:%line]: %msg%n From 9a1d7fd512d27f7371a312947d863edb9b9311f8 Mon Sep 17 00:00:00 2001 From: Johannes Mockenhaupt Date: Sat, 14 Oct 2017 16:54:21 +0200 Subject: [PATCH 08/13] Log source of event. --- .../main/java/info/nightscout/androidaps/LoggingBus.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/src/main/java/info/nightscout/androidaps/LoggingBus.java b/app/src/main/java/info/nightscout/androidaps/LoggingBus.java index 249e273c3d..390ee5b7e7 100644 --- a/app/src/main/java/info/nightscout/androidaps/LoggingBus.java +++ b/app/src/main/java/info/nightscout/androidaps/LoggingBus.java @@ -29,6 +29,14 @@ class LoggingBus extends Bus { } log.debug("Event posted: " + event); + try { + StackTraceElement caller = new Throwable().getStackTrace()[1]; + String className = caller.getClassName(); + className = className.substring(className.lastIndexOf(".") + 1); + log.debug(" source: " + className + "." + caller.getMethodName() + ":" + caller.getLineNumber()); + } catch (RuntimeException e) { + log.debug(" source: "); + } delegate.post(event); } } From 785a8f21deff99b468af99b1a3586131d41f9fe2 Mon Sep 17 00:00:00 2001 From: Johannes Mockenhaupt Date: Sat, 14 Oct 2017 17:24:01 +0200 Subject: [PATCH 09/13] Log receivers of event. --- .../java/com/squareup/otto/LoggingBus.java | 57 +++++++++++++++++++ .../nightscout/androidaps/LoggingBus.java | 42 -------------- .../info/nightscout/androidaps/MainApp.java | 4 +- 3 files changed, 59 insertions(+), 44 deletions(-) create mode 100644 app/src/main/java/com/squareup/otto/LoggingBus.java delete mode 100644 app/src/main/java/info/nightscout/androidaps/LoggingBus.java diff --git a/app/src/main/java/com/squareup/otto/LoggingBus.java b/app/src/main/java/com/squareup/otto/LoggingBus.java new file mode 100644 index 0000000000..6fa53a60f9 --- /dev/null +++ b/app/src/main/java/com/squareup/otto/LoggingBus.java @@ -0,0 +1,57 @@ +package com.squareup.otto; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.lang.reflect.Field; +import java.lang.reflect.Method; + +import info.nightscout.androidaps.events.Event; + +public class LoggingBus extends Bus { + private static Logger log = LoggerFactory.getLogger(LoggingBus.class); + + public LoggingBus(ThreadEnforcer enforcer) { + super(enforcer); + } + + @Override + public void post(Object event) { + if (event instanceof DeadEvent) { + log.debug("Event has no receiver: " + ((DeadEvent) event).event + ", source: " + ((DeadEvent) event).source); + return; + } + + if (!(event instanceof Event)) { + log.error("Posted event not an event class: " + event.getClass()); + } + + log.debug("<<< " + event); + try { + StackTraceElement caller = new Throwable().getStackTrace()[1]; + String className = caller.getClassName(); + className = className.substring(className.lastIndexOf(".") + 1); + log.debug(" source: " + className + "." + caller.getMethodName() + ":" + caller.getLineNumber()); + } catch (RuntimeException e) { + log.debug(" source: "); + } + + super.post(event); + } + + @Override + protected void dispatch(Object event, EventHandler wrapper) { + try { + log.debug(">>> " + event); + Field methodField = wrapper.getClass().getDeclaredField("method"); + methodField.setAccessible(true); + Method targcetMethod = (Method) methodField.get(wrapper); + String className = targcetMethod.getDeclaringClass().getSimpleName(); + String methodName = targcetMethod.getName(); + log.debug(" receiver: " + className + "." + methodName); + } catch (ReflectiveOperationException e) { + log.debug(" receiver: "); + } + super.dispatch(event, wrapper); + } +} diff --git a/app/src/main/java/info/nightscout/androidaps/LoggingBus.java b/app/src/main/java/info/nightscout/androidaps/LoggingBus.java deleted file mode 100644 index 390ee5b7e7..0000000000 --- a/app/src/main/java/info/nightscout/androidaps/LoggingBus.java +++ /dev/null @@ -1,42 +0,0 @@ -package info.nightscout.androidaps; - -import com.squareup.otto.Bus; -import com.squareup.otto.DeadEvent; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import info.nightscout.androidaps.events.Event; - -class LoggingBus extends Bus { - private static Logger log = LoggerFactory.getLogger(LoggingBus.class); - - private final Bus delegate; - - public LoggingBus(Bus bus) { - delegate = bus; - } - - @Override - public void post(Object event) { - if (event instanceof DeadEvent) { - log.debug("Event has no receiver:" + ((DeadEvent) event).event + ", source: " + ((DeadEvent) event).source); - return; - } - - if (!(event instanceof Event)) { - log.error("Posted event not an event class: " + event.getClass()); - } - - log.debug("Event posted: " + event); - try { - StackTraceElement caller = new Throwable().getStackTrace()[1]; - String className = caller.getClassName(); - className = className.substring(className.lastIndexOf(".") + 1); - log.debug(" source: " + className + "." + caller.getMethodName() + ":" + caller.getLineNumber()); - } catch (RuntimeException e) { - log.debug(" source: "); - } - delegate.post(event); - } -} diff --git a/app/src/main/java/info/nightscout/androidaps/MainApp.java b/app/src/main/java/info/nightscout/androidaps/MainApp.java index 3392a0193a..bd9b57c9ae 100644 --- a/app/src/main/java/info/nightscout/androidaps/MainApp.java +++ b/app/src/main/java/info/nightscout/androidaps/MainApp.java @@ -13,6 +13,7 @@ import com.crashlytics.android.answers.Answers; import com.crashlytics.android.answers.CustomEvent; import com.j256.ormlite.android.apptools.OpenHelperManager; import com.squareup.otto.Bus; +import com.squareup.otto.LoggingBus; import com.squareup.otto.ThreadEnforcer; import org.slf4j.Logger; @@ -104,8 +105,7 @@ public class MainApp extends Application { log.info("Version: " + BuildConfig.VERSION_NAME); log.info("BuildVersion: " + BuildConfig.BUILDVERSION); - Bus bus = new Bus(ThreadEnforcer.ANY); - sBus = Config.logEvents ? new LoggingBus(bus) : bus; + sBus = Config.logEvents ? new LoggingBus(ThreadEnforcer.ANY) : new Bus(ThreadEnforcer.ANY); sInstance = this; sResources = getResources(); From 82dd8c2c5e4ecf00d98eb851d919143e9eecef39 Mon Sep 17 00:00:00 2001 From: Johannes Mockenhaupt Date: Sat, 14 Oct 2017 18:07:12 +0200 Subject: [PATCH 10/13] Log summary after 10s, then every 60s. --- .../java/com/squareup/otto/LoggingBus.java | 32 ++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/squareup/otto/LoggingBus.java b/app/src/main/java/com/squareup/otto/LoggingBus.java index 6fa53a60f9..044911363d 100644 --- a/app/src/main/java/com/squareup/otto/LoggingBus.java +++ b/app/src/main/java/com/squareup/otto/LoggingBus.java @@ -5,12 +5,24 @@ import org.slf4j.LoggerFactory; import java.lang.reflect.Field; import java.lang.reflect.Method; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; import info.nightscout.androidaps.events.Event; +/** Logs events has they're being posted to and dispatched from the event bus. + * + * A summary of references between sender and event and event and receiver is printed + * after 10s (after startup) and then again every 60s. + * */ public class LoggingBus extends Bus { private static Logger log = LoggerFactory.getLogger(LoggingBus.class); + private static long everyMinute = System.currentTimeMillis() + 10 * 1000; + private Map> event2Receiver = new HashMap<>(); + public LoggingBus(ThreadEnforcer enforcer) { super(enforcer); } @@ -48,10 +60,28 @@ public class LoggingBus extends Bus { Method targcetMethod = (Method) methodField.get(wrapper); String className = targcetMethod.getDeclaringClass().getSimpleName(); String methodName = targcetMethod.getName(); - log.debug(" receiver: " + className + "." + methodName); + String receiverMethod = className + "." + methodName; + log.debug(" receiver: " + receiverMethod); + + String key = event.getClass().getSimpleName(); + if (!event2Receiver.containsKey(key)) event2Receiver.put(key, new HashSet()); + event2Receiver.get(key).add(receiverMethod); } catch (ReflectiveOperationException e) { log.debug(" receiver: "); } + + if (everyMinute < System.currentTimeMillis()) { + log.debug("***************** The story so far ****************"); + for (Map.Entry> stringSetEntry : event2Receiver.entrySet()) { + log.debug(" " + stringSetEntry.getKey()); + for (String s : stringSetEntry.getValue()) { + log.debug(" -> " + s); + } + } + log.debug("***************************************************"); + everyMinute = System.currentTimeMillis() + 60 * 1000; + } + super.dispatch(event, wrapper); } } From e5cb5386e361ec3cd6fd65ba4c394a286e1a4065 Mon Sep 17 00:00:00 2001 From: Johannes Mockenhaupt Date: Fri, 20 Oct 2017 01:50:42 +0200 Subject: [PATCH 11/13] Disable event logging by default. --- app/src/main/java/info/nightscout/androidaps/Config.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/info/nightscout/androidaps/Config.java b/app/src/main/java/info/nightscout/androidaps/Config.java index 6bbc908188..0ccb932e57 100644 --- a/app/src/main/java/info/nightscout/androidaps/Config.java +++ b/app/src/main/java/info/nightscout/androidaps/Config.java @@ -40,7 +40,7 @@ public class Config { public static final boolean logPumpActions = true; public static final boolean logCongigBuilderActions = true; public static final boolean logAutosensData = false; - public static final boolean logEvents = true; + public static final boolean logEvents = false; // DanaR specific public static final boolean logDanaBTComm = true; From 79316bf94803ddcce31560bab960a230f7430775 Mon Sep 17 00:00:00 2001 From: Johannes Mockenhaupt Date: Sat, 21 Oct 2017 15:00:47 +0200 Subject: [PATCH 12/13] Revert "Debug: wider thread column in log to improve readability." This reverts commit 5fe2d19e6363c4efcaad90fe5aa627b58d230cd1. --- app/src/main/assets/logback.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/assets/logback.xml b/app/src/main/assets/logback.xml index d089eb7f64..c34ff08b80 100644 --- a/app/src/main/assets/logback.xml +++ b/app/src/main/assets/logback.xml @@ -15,7 +15,7 @@ 120 - %d{HH:mm:ss.SSS} [%-40thread] %-5level [%file:%line]: %msg%n + %d{HH:mm:ss.SSS} [%thread] %-5level [%file:%line]: %msg%n @@ -24,7 +24,7 @@ %logger{0} - [%-40thread] %-5level [%file:%line]: %msg%n + [%thread] %-5level [%file:%line]: %msg%n From 91df07ca8f3a2ea8905029f759935bab5436420f Mon Sep 17 00:00:00 2001 From: Johannes Mockenhaupt Date: Sat, 21 Oct 2017 15:02:53 +0200 Subject: [PATCH 13/13] Cleanup. --- app/src/main/java/com/squareup/otto/LoggingBus.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/com/squareup/otto/LoggingBus.java b/app/src/main/java/com/squareup/otto/LoggingBus.java index 044911363d..3417e7dd41 100644 --- a/app/src/main/java/com/squareup/otto/LoggingBus.java +++ b/app/src/main/java/com/squareup/otto/LoggingBus.java @@ -14,7 +14,7 @@ import info.nightscout.androidaps.events.Event; /** Logs events has they're being posted to and dispatched from the event bus. * - * A summary of references between sender and event and event and receiver is printed + * A summary of event-receiver calls that occurred so far is logged * after 10s (after startup) and then again every 60s. * */ public class LoggingBus extends Bus { @@ -57,9 +57,9 @@ public class LoggingBus extends Bus { log.debug(">>> " + event); Field methodField = wrapper.getClass().getDeclaredField("method"); methodField.setAccessible(true); - Method targcetMethod = (Method) methodField.get(wrapper); - String className = targcetMethod.getDeclaringClass().getSimpleName(); - String methodName = targcetMethod.getName(); + Method targetMethod = (Method) methodField.get(wrapper); + String className = targetMethod.getDeclaringClass().getSimpleName(); + String methodName = targetMethod.getName(); String receiverMethod = className + "." + methodName; log.debug(" receiver: " + receiverMethod); @@ -71,14 +71,14 @@ public class LoggingBus extends Bus { } if (everyMinute < System.currentTimeMillis()) { - log.debug("***************** The story so far ****************"); + log.debug("***************** Event -> receiver pairings seen so far ****************"); for (Map.Entry> stringSetEntry : event2Receiver.entrySet()) { log.debug(" " + stringSetEntry.getKey()); for (String s : stringSetEntry.getValue()) { log.debug(" -> " + s); } } - log.debug("***************************************************"); + log.debug("*************************************************************************"); everyMinute = System.currentTimeMillis() + 60 * 1000; }