move ConfigBuilder
This commit is contained in:
parent
8b7ceabaf3
commit
3427820eda
40 changed files with 185 additions and 174 deletions
|
@ -1,11 +1,9 @@
|
|||
package info.nightscout.plugins.sync.nsShared.events
|
||||
package info.nightscout.rx.events
|
||||
|
||||
import info.nightscout.interfaces.sync.NsClient
|
||||
import info.nightscout.rx.events.Event
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.Locale
|
||||
|
||||
class EventNSClientNewLog(val action: String, val logText: String, val version: NsClient.Version) : Event() {
|
||||
class EventNSClientNewLog(val action: String, val logText: String) : Event() {
|
||||
var date = System.currentTimeMillis()
|
||||
|
||||
private var timeFormat = SimpleDateFormat("HH:mm:ss", Locale.getDefault())
|
|
@ -54,6 +54,7 @@ import javax.inject.Singleton
|
|||
AutomationModule::class,
|
||||
ApsModule::class,
|
||||
ConfigurationModule::class,
|
||||
ConfigurationModule.Bindings::class,
|
||||
CoreModule::class,
|
||||
DatabaseModule::class,
|
||||
ImplementationModule::class,
|
||||
|
|
|
@ -9,7 +9,7 @@ import dagger.android.HasAndroidInjector
|
|||
import info.nightscout.androidaps.MainApp
|
||||
import info.nightscout.androidaps.implementations.ActivityNamesImpl
|
||||
import info.nightscout.androidaps.implementations.ConfigImpl
|
||||
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin
|
||||
import info.nightscout.configuration.configBuilder.ConfigBuilderPlugin
|
||||
import info.nightscout.implementation.profile.ProfileFunctionImpl
|
||||
import info.nightscout.androidaps.plugins.general.maintenance.ImportExportPrefsImpl
|
||||
import info.nightscout.androidaps.workflow.CalculationWorkflowImpl
|
||||
|
|
|
@ -3,7 +3,7 @@ package info.nightscout.androidaps.di
|
|||
import dagger.Module
|
||||
import dagger.android.ContributesAndroidInjector
|
||||
import info.nightscout.androidaps.activities.MyPreferenceFragment
|
||||
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderFragment
|
||||
import info.nightscout.configuration.configBuilder.ConfigBuilderFragment
|
||||
import info.nightscout.androidaps.plugins.general.maintenance.MaintenanceFragment
|
||||
import info.nightscout.androidaps.plugins.general.overview.OverviewFragment
|
||||
import info.nightscout.androidaps.plugins.general.overview.dialogs.EditQuickWizardDialog
|
||||
|
|
|
@ -8,7 +8,7 @@ import info.nightscout.androidaps.danaRKorean.DanaRKoreanPlugin
|
|||
import info.nightscout.androidaps.danaRv2.DanaRv2Plugin
|
||||
import info.nightscout.androidaps.danar.DanaRPlugin
|
||||
import info.nightscout.androidaps.plugin.general.openhumans.OpenHumansUploaderPlugin
|
||||
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin
|
||||
import info.nightscout.configuration.configBuilder.ConfigBuilderPlugin
|
||||
import info.nightscout.androidaps.plugins.general.maintenance.MaintenancePlugin
|
||||
import info.nightscout.androidaps.plugins.general.overview.OverviewPlugin
|
||||
import info.nightscout.androidaps.plugins.general.persistentNotification.PersistentNotificationPlugin
|
||||
|
|
|
@ -28,7 +28,7 @@ import info.nightscout.interfaces.plugin.PluginBase
|
|||
import info.nightscout.interfaces.profile.ProfileFunction
|
||||
import info.nightscout.interfaces.queue.Command
|
||||
import info.nightscout.interfaces.queue.CommandQueue
|
||||
import info.nightscout.plugins.configBuilder.RunningConfiguration
|
||||
import info.nightscout.interfaces.configBuilder.RunningConfiguration
|
||||
import info.nightscout.plugins.sync.nsclient.extensions.buildDeviceStatus
|
||||
import info.nightscout.rx.bus.RxBus
|
||||
import info.nightscout.rx.events.EventProfileSwitchChanged
|
||||
|
|
|
@ -37,11 +37,9 @@
|
|||
<string name="nav_resetdb">Reset Databases</string>
|
||||
<string name="reset_db_confirm">Do you really want to reset the databases?</string>
|
||||
<string name="nav_exit">Exit</string>
|
||||
<string name="description_config_builder">Used for configuring the active plugins</string>
|
||||
<string name="description_overview">Displays the current state of your loop and buttons for most common actions</string>
|
||||
<string name="description_persistent_notification">Shows an ongoing notification with a short overview of what your loop is doing</string>
|
||||
<string name="delta">Delta</string>
|
||||
<string name="configbuilder">Config Builder</string>
|
||||
<string name="overview">Overview</string>
|
||||
<string name="treatments">Treatments</string>
|
||||
<string name="constraints_violation">Constraints violation</string>
|
||||
|
@ -82,7 +80,6 @@
|
|||
<string name="wear">Wear</string>
|
||||
<string name="ongoingnotificaction">Ongoing Notification</string>
|
||||
<string name="old_data">OLD DATA</string>
|
||||
<string name="configbuilder_shortname">CONF</string>
|
||||
<string name="overview_shortname">HOME</string>
|
||||
<string name="treatments_shortname">TREAT</string>
|
||||
<string name="short_tabtitles">Shorten tab titles</string>
|
||||
|
@ -173,7 +170,6 @@
|
|||
<string name="key_keep_screen_on" translatable="false">keep_screen_on</string>
|
||||
<string name="remove_items">Remove items</string>
|
||||
<string name="sort_items">Sort items</string>
|
||||
<string name="allow_hardware_pump_text">Attention: If you activate and connect to a hardware pump, AAPS will copy the basal settings from the profile to the pump, overwriting the existing basal rate stored on the pump. Make sure you have the correct basal setting in AAPS. If you are not sure or don\'t want to overwrite the basal settings on your pump, press cancel and repeat switching to the pump at a later time.</string>
|
||||
<string name="error_adding_treatment_title">Treatment data incomplete</string>
|
||||
<string name="maintenance_settings">Maintenance Settings</string>
|
||||
<string name="maintenance_email">Email recipient</string>
|
||||
|
@ -229,7 +225,6 @@
|
|||
<string name="count_selected">%1$d selected</string>
|
||||
<string name="sort_label">Sort</string>
|
||||
<string name="graph_scale">Graph scale</string>
|
||||
<string name="a11y_open_settings">open settings</string>
|
||||
<string name="device_all">All</string>
|
||||
<string name="device_phone">Phone</string>
|
||||
<string name="device_watch">Watch</string>
|
||||
|
|
|
@ -21,7 +21,7 @@ import info.nightscout.interfaces.queue.CommandQueue
|
|||
import info.nightscout.interfaces.ui.ActivityNames
|
||||
import info.nightscout.plugins.aps.loop.LoopFragment
|
||||
import info.nightscout.plugins.aps.loop.LoopPlugin
|
||||
import info.nightscout.plugins.configBuilder.RunningConfiguration
|
||||
import info.nightscout.interfaces.configBuilder.RunningConfiguration
|
||||
import info.nightscout.plugins.pump.virtual.VirtualPumpPlugin
|
||||
import info.nightscout.rx.bus.RxBus
|
||||
import info.nightscout.shared.interfaces.ResourceHelper
|
||||
|
|
|
@ -6,6 +6,7 @@ import info.nightscout.androidaps.TestBase
|
|||
import info.nightscout.interfaces.logging.UserEntryLogger
|
||||
import info.nightscout.interfaces.plugin.ActivePlugin
|
||||
import info.nightscout.interfaces.pump.PumpSync
|
||||
import info.nightscout.configuration.configBuilder.ConfigBuilderPlugin
|
||||
import info.nightscout.rx.bus.RxBus
|
||||
import info.nightscout.shared.interfaces.ResourceHelper
|
||||
import info.nightscout.shared.sharedPreferences.SP
|
||||
|
|
|
@ -23,6 +23,7 @@ dependencies {
|
|||
// (ResourceHelper, AAPSLogger interface)
|
||||
implementation project(':app-wear-shared:shared')
|
||||
implementation project(':database:entities')
|
||||
implementation project(':core:ns-sdk')
|
||||
|
||||
api "androidx.appcompat:appcompat:$appcompat_version"
|
||||
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
package info.nightscout.interfaces.configBuilder
|
||||
|
||||
import info.nightscout.sdk.remotemodel.RemoteDeviceStatus
|
||||
import org.json.JSONObject
|
||||
|
||||
interface RunningConfiguration {
|
||||
|
||||
// called in AAPS mode only
|
||||
fun configuration(): JSONObject
|
||||
|
||||
// called in NSClient mode only
|
||||
fun apply(configuration: RemoteDeviceStatus.Configuration)
|
||||
}
|
|
@ -110,4 +110,6 @@ interface ActivePlugin {
|
|||
* List of all plugins of type
|
||||
*/
|
||||
fun getSpecificPluginsList(type: PluginType): ArrayList<PluginBase>
|
||||
|
||||
fun loadDefaults()
|
||||
}
|
|
@ -24,6 +24,8 @@
|
|||
<string name="mmol">mmol/l</string>
|
||||
<string name="save">Save</string>
|
||||
<string name="snooze">Snooze</string>
|
||||
<string name="virtual_pump">Virtual Pump</string>
|
||||
<string name="constraints">Constraints</string>
|
||||
|
||||
<!-- Pumps -->
|
||||
<string name="battery_label">Battery</string>
|
||||
|
|
|
@ -37,7 +37,7 @@ class PluginStore @Inject constructor(
|
|||
private var activeInsulinStore: Insulin? = null
|
||||
private var activeSensitivityStore: Sensitivity? = null
|
||||
|
||||
fun loadDefaults() {
|
||||
override fun loadDefaults() {
|
||||
verifySelectionInCategories()
|
||||
}
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@ dependencies {
|
|||
implementation project(':database:entities')
|
||||
implementation project(':core:core-main')
|
||||
implementation project(':core:interfaces')
|
||||
implementation project(':core:ns-sdk')
|
||||
implementation project(':core:utils')
|
||||
implementation project(':core:ui')
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package info.nightscout.androidaps.plugins.configBuilder
|
||||
package info.nightscout.configuration.configBuilder
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
|
@ -15,10 +15,9 @@ import android.widget.TextView
|
|||
import androidx.annotation.StringRes
|
||||
import androidx.core.content.ContextCompat
|
||||
import dagger.android.support.DaggerFragment
|
||||
import info.nightscout.androidaps.R
|
||||
import info.nightscout.androidaps.activities.PreferencesActivity
|
||||
import info.nightscout.androidaps.databinding.ConfigbuilderFragmentBinding
|
||||
import info.nightscout.androidaps.plugins.configBuilder.events.EventConfigBuilderUpdateGui
|
||||
import info.nightscout.configuration.R
|
||||
import info.nightscout.configuration.configBuilder.events.EventConfigBuilderUpdateGui
|
||||
import info.nightscout.configuration.databinding.ConfigbuilderFragmentBinding
|
||||
import info.nightscout.core.utils.fabric.FabricPrivacy
|
||||
import info.nightscout.interfaces.Config
|
||||
import info.nightscout.interfaces.plugin.ActivePlugin
|
||||
|
@ -26,12 +25,12 @@ import info.nightscout.interfaces.plugin.PluginBase
|
|||
import info.nightscout.interfaces.plugin.PluginType
|
||||
import info.nightscout.interfaces.protection.ProtectionCheck
|
||||
import info.nightscout.interfaces.protection.ProtectionCheck.Protection.PREFERENCES
|
||||
import info.nightscout.interfaces.ui.ActivityNames
|
||||
import info.nightscout.rx.AapsSchedulers
|
||||
import info.nightscout.rx.bus.RxBus
|
||||
import info.nightscout.rx.events.EventRebuildTabs
|
||||
import info.nightscout.shared.extensions.toVisibility
|
||||
import info.nightscout.shared.interfaces.ResourceHelper
|
||||
import info.nightscout.ui.activities.SingleFragmentActivity
|
||||
import io.reactivex.rxjava3.disposables.CompositeDisposable
|
||||
import io.reactivex.rxjava3.kotlin.plusAssign
|
||||
import javax.inject.Inject
|
||||
|
@ -47,6 +46,7 @@ class ConfigBuilderFragment : DaggerFragment() {
|
|||
@Inject lateinit var protectionCheck: ProtectionCheck
|
||||
@Inject lateinit var config: Config
|
||||
@Inject lateinit var ctx: Context
|
||||
@Inject lateinit var activityNames: ActivityNames
|
||||
|
||||
private var disposable: CompositeDisposable = CompositeDisposable()
|
||||
private val pluginViewHolders = ArrayList<PluginViewHolder>()
|
||||
|
@ -65,7 +65,7 @@ class ConfigBuilderFragment : DaggerFragment() {
|
|||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
val parentClass = this.activity?.let { it::class.java }
|
||||
inMenu = parentClass == SingleFragmentActivity::class.java
|
||||
inMenu = parentClass == activityNames.singleFragmentActivity
|
||||
updateProtectedUi()
|
||||
binding.unlock.setOnClickListener { queryProtection() }
|
||||
}
|
||||
|
@ -166,7 +166,7 @@ class ConfigBuilderFragment : DaggerFragment() {
|
|||
pluginPreferences.setOnClickListener {
|
||||
fragment.activity?.let { activity ->
|
||||
protectionCheck.queryProtection(activity, ProtectionCheck.Protection.PREFERENCES, {
|
||||
val i = Intent(ctx, PreferencesActivity::class.java)
|
||||
val i = Intent(ctx, activityNames.preferencesActivity)
|
||||
i.putExtra("id", plugin.preferencesId)
|
||||
fragment.startActivity(i)
|
||||
}, null)
|
|
@ -1,14 +1,13 @@
|
|||
package info.nightscout.androidaps.plugins.configBuilder
|
||||
package info.nightscout.configuration.configBuilder
|
||||
|
||||
import androidx.fragment.app.FragmentActivity
|
||||
import dagger.android.HasAndroidInjector
|
||||
import info.nightscout.androidaps.R
|
||||
import info.nightscout.androidaps.plugins.configBuilder.events.EventConfigBuilderUpdateGui
|
||||
import info.nightscout.configuration.R
|
||||
import info.nightscout.configuration.configBuilder.events.EventConfigBuilderUpdateGui
|
||||
import info.nightscout.core.ui.dialogs.OKDialog
|
||||
import info.nightscout.database.entities.UserEntry.Action
|
||||
import info.nightscout.database.entities.UserEntry.Sources
|
||||
import info.nightscout.database.entities.ValueWithUnit
|
||||
import info.nightscout.implementation.plugin.PluginStore
|
||||
import info.nightscout.interfaces.ConfigBuilder
|
||||
import info.nightscout.interfaces.aps.APS
|
||||
import info.nightscout.interfaces.aps.Sensitivity
|
||||
|
@ -52,14 +51,14 @@ class ConfigBuilderPlugin @Inject constructor(
|
|||
.alwaysEnabled(true)
|
||||
.alwaysVisible(false)
|
||||
.pluginIcon(R.drawable.ic_cogs)
|
||||
.pluginName(R.string.configbuilder)
|
||||
.shortName(R.string.configbuilder_shortname)
|
||||
.pluginName(R.string.config_builder)
|
||||
.shortName(R.string.config_builder_shortname)
|
||||
.description(R.string.description_config_builder),
|
||||
aapsLogger, rh, injector
|
||||
), ConfigBuilder {
|
||||
|
||||
override fun initialize() {
|
||||
(activePlugin as PluginStore).loadDefaults()
|
||||
activePlugin.loadDefaults()
|
||||
loadSettings()
|
||||
setAlwaysEnabledPluginsEnabled()
|
||||
rxBus.send(EventAppInitialized())
|
|
@ -1,19 +1,19 @@
|
|||
package info.nightscout.plugins.configBuilder
|
||||
package info.nightscout.configuration.configBuilder
|
||||
|
||||
import info.nightscout.core.events.EventNewNotification
|
||||
import info.nightscout.core.main.R
|
||||
import info.nightscout.interfaces.Config
|
||||
import info.nightscout.interfaces.ConfigBuilder
|
||||
import info.nightscout.interfaces.aps.Sensitivity
|
||||
import info.nightscout.interfaces.configBuilder.RunningConfiguration
|
||||
import info.nightscout.interfaces.insulin.Insulin
|
||||
import info.nightscout.interfaces.notifications.Notification
|
||||
import info.nightscout.interfaces.plugin.ActivePlugin
|
||||
import info.nightscout.interfaces.plugin.PluginType
|
||||
import info.nightscout.interfaces.pump.PumpSync
|
||||
import info.nightscout.interfaces.pump.defs.PumpType
|
||||
import info.nightscout.interfaces.sync.NsClient
|
||||
import info.nightscout.plugins.sync.nsShared.events.EventNSClientNewLog
|
||||
import info.nightscout.rx.bus.RxBus
|
||||
import info.nightscout.rx.events.EventNSClientNewLog
|
||||
import info.nightscout.rx.logging.AAPSLogger
|
||||
import info.nightscout.rx.logging.LTag
|
||||
import info.nightscout.sdk.remotemodel.RemoteDeviceStatus
|
||||
|
@ -25,7 +25,7 @@ import javax.inject.Inject
|
|||
import javax.inject.Singleton
|
||||
|
||||
@Singleton
|
||||
class RunningConfiguration @Inject constructor(
|
||||
class RunningConfigurationImpl @Inject constructor(
|
||||
private val activePlugin: ActivePlugin,
|
||||
private val configBuilder: ConfigBuilder,
|
||||
private val sp: SP,
|
||||
|
@ -34,13 +34,13 @@ class RunningConfiguration @Inject constructor(
|
|||
private val rh: ResourceHelper,
|
||||
private val rxBus: RxBus,
|
||||
private val pumpSync: PumpSync
|
||||
) {
|
||||
) : RunningConfiguration {
|
||||
|
||||
private var counter = 0
|
||||
private val every = 12 // Send only every 12 device status to save traffic
|
||||
|
||||
// called in AAPS mode only
|
||||
fun configuration(): JSONObject {
|
||||
override fun configuration(): JSONObject {
|
||||
val json = JSONObject()
|
||||
val pumpInterface = activePlugin.activePump
|
||||
|
||||
|
@ -67,11 +67,11 @@ class RunningConfiguration @Inject constructor(
|
|||
}
|
||||
|
||||
// called in NSClient mode only
|
||||
fun apply(configuration: RemoteDeviceStatus.Configuration, version: NsClient.Version) {
|
||||
override fun apply(configuration: RemoteDeviceStatus.Configuration) {
|
||||
assert(config.NSCLIENT)
|
||||
|
||||
configuration.version?.let {
|
||||
rxBus.send(EventNSClientNewLog("VERSION", "Received AndroidAPS version $it", version))
|
||||
rxBus.send(EventNSClientNewLog("VERSION", "Received AndroidAPS version $it"))
|
||||
if (config.VERSION_NAME.startsWith(it).not())
|
||||
rxBus.send(EventNewNotification(Notification(Notification.NSCLIENT_VERSION_DOES_NOT_MATCH, rh.gs(R.string.nsclient_version_does_not_match), Notification.NORMAL)))
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package info.nightscout.androidaps.plugins.configBuilder.events
|
||||
package info.nightscout.configuration.configBuilder.events
|
||||
|
||||
import info.nightscout.rx.events.EventUpdateGui
|
||||
|
|
@ -1,10 +1,20 @@
|
|||
package info.nightscout.configuration.di
|
||||
|
||||
import dagger.Binds
|
||||
import dagger.Module
|
||||
import info.nightscout.configuration.configBuilder.RunningConfigurationImpl
|
||||
import info.nightscout.interfaces.configBuilder.RunningConfiguration
|
||||
|
||||
@Module(
|
||||
includes = [
|
||||
SetupWizardModule::class
|
||||
]
|
||||
)
|
||||
open class ConfigurationModule
|
||||
open class ConfigurationModule {
|
||||
|
||||
@Module
|
||||
interface Bindings {
|
||||
|
||||
@Binds fun bindRunningConfiguration(runningConfigurationImpl: RunningConfigurationImpl): RunningConfiguration
|
||||
}
|
||||
}
|
|
@ -55,6 +55,11 @@
|
|||
<string name="summary_email_for_crash_report">This identification will attached to crash reports so we can contact you in urgent cases. It\'s optional.</string>
|
||||
<string name="identification">Identification (email, FB or Discord nick etc)</string>
|
||||
|
||||
<string name="apsmode_title">APS Mode</string>
|
||||
<string name="setupwizard_preferred_aps_mode">Preferred APS mode</string>
|
||||
|
||||
<!-- ConfigBuilder-->
|
||||
<string name="config_builder">Config Builder</string>
|
||||
<string name="configbuilder_pump">Pump</string>
|
||||
<string name="configbuilder_pump_description">Which pump would you like to use with AAPS?</string>
|
||||
<string name="configbuilder_profile">Profile</string>
|
||||
|
@ -71,9 +76,12 @@
|
|||
<string name="configbuilder_insulin_description">Which type of insulin are you using?</string>
|
||||
<string name="configbuilder_bgsource">BG Source</string>
|
||||
<string name="configbuilder_bgsource_description">Where should AAPS gain it\'s data from?</string>
|
||||
<string name="apsmode_title">APS Mode</string>
|
||||
<string name="setupwizard_preferred_aps_mode">Preferred APS mode</string>
|
||||
<string name="configbuilder_sensitivity">Sensitivity detection</string>
|
||||
<string name="configbuilder_sensitivity_description">Which sensitivity algorithm should be used?</string>
|
||||
<string name="config_builder_shortname">CONF</string>
|
||||
<string name="description_config_builder">Used for configuring the active plugins</string>
|
||||
<string name="allow_hardware_pump_text">Attention: If you activate and connect to a hardware pump, AAPS will copy the basal settings from the profile to the pump, overwriting the existing basal rate stored on the pump. Make sure you have the correct basal setting in AAPS. If you are not sure or don\'t want to overwrite the basal settings on your pump, press cancel and repeat switching to the pump at a later time.</string>
|
||||
<string name="a11y_open_settings">open settings</string>
|
||||
|
||||
|
||||
</resources>
|
|
@ -55,7 +55,7 @@ import info.nightscout.plugins.R
|
|||
import info.nightscout.plugins.aps.loop.events.EventLoopSetLastRunGui
|
||||
import info.nightscout.plugins.aps.loop.events.EventLoopUpdateGui
|
||||
import info.nightscout.plugins.aps.loop.events.EventNewOpenLoopNotification
|
||||
import info.nightscout.plugins.configBuilder.RunningConfiguration
|
||||
import info.nightscout.interfaces.configBuilder.RunningConfiguration
|
||||
import info.nightscout.plugins.pump.virtual.VirtualPumpPlugin
|
||||
import info.nightscout.plugins.sync.nsclient.extensions.buildDeviceStatus
|
||||
import info.nightscout.rx.AapsSchedulers
|
||||
|
|
|
@ -36,13 +36,11 @@ import info.nightscout.interfaces.Constants
|
|||
import info.nightscout.interfaces.XDripBroadcast
|
||||
import info.nightscout.interfaces.logging.UserEntryLogger
|
||||
import info.nightscout.interfaces.notifications.Notification
|
||||
import info.nightscout.interfaces.plugin.ActivePlugin
|
||||
import info.nightscout.interfaces.sync.NsClient
|
||||
import info.nightscout.plugins.R
|
||||
import info.nightscout.plugins.pump.virtual.VirtualPumpPlugin
|
||||
import info.nightscout.plugins.source.NSClientSourcePlugin
|
||||
import info.nightscout.plugins.sync.nsShared.events.EventNSClientNewLog
|
||||
import info.nightscout.rx.bus.RxBus
|
||||
import info.nightscout.rx.events.EventNSClientNewLog
|
||||
import info.nightscout.rx.logging.AAPSLogger
|
||||
import info.nightscout.rx.logging.LTag
|
||||
import info.nightscout.sdk.localmodel.treatment.NSBolus
|
||||
|
@ -69,7 +67,6 @@ class StoreDataForDb @Inject constructor(
|
|||
private val sp: SP,
|
||||
private val uel: UserEntryLogger,
|
||||
private val dateUtil: DateUtil,
|
||||
private val activePlugin: ActivePlugin,
|
||||
private val config: Config,
|
||||
private val nsClientSourcePlugin: NSClientSourcePlugin,
|
||||
private val xDripBroadcast: XDripBroadcast,
|
||||
|
@ -122,7 +119,7 @@ class StoreDataForDb @Inject constructor(
|
|||
else put(key, 1)
|
||||
|
||||
private fun storeGlucoseValuesToDb() {
|
||||
rxBus.send(EventNSClientNewLog("PROCESSING BG", "", activePlugin.activeNsClient?.version ?: NsClient.Version.V3))
|
||||
rxBus.send(EventNSClientNewLog("PROCESSING BG", ""))
|
||||
|
||||
if (glucoseValues.isNotEmpty())
|
||||
repository.runTransactionForResult(CgmSourceTransaction(glucoseValues, emptyList(), null))
|
||||
|
@ -154,11 +151,11 @@ class StoreDataForDb @Inject constructor(
|
|||
|
||||
sendLog("GlucoseValue", GlucoseValue::class.java.simpleName)
|
||||
SystemClock.sleep(pause)
|
||||
rxBus.send(EventNSClientNewLog("DONE BG", "", activePlugin.activeNsClient?.version ?: NsClient.Version.V3))
|
||||
rxBus.send(EventNSClientNewLog("DONE BG", ""))
|
||||
}
|
||||
|
||||
fun storeTreatmentsToDb() {
|
||||
rxBus.send(EventNSClientNewLog("PROCESSING TR", "", activePlugin.activeNsClient?.version ?: NsClient.Version.V3))
|
||||
rxBus.send(EventNSClientNewLog("PROCESSING TR", ""))
|
||||
|
||||
if (boluses.isNotEmpty())
|
||||
repository.runTransactionForResult(SyncNsBolusTransaction(boluses))
|
||||
|
@ -734,32 +731,32 @@ class StoreDataForDb @Inject constructor(
|
|||
SystemClock.sleep(pause)
|
||||
|
||||
uel.log(userEntries)
|
||||
rxBus.send(EventNSClientNewLog("DONE TR", "", activePlugin.activeNsClient?.version ?: NsClient.Version.V3))
|
||||
rxBus.send(EventNSClientNewLog("DONE TR", ""))
|
||||
}
|
||||
|
||||
private fun sendLog(item: String, clazz: String) {
|
||||
inserted[clazz]?.let {
|
||||
rxBus.send(EventNSClientNewLog("INSERT", "$item $it", activePlugin.activeNsClient?.version ?: NsClient.Version.V3))
|
||||
rxBus.send(EventNSClientNewLog("INSERT", "$item $it"))
|
||||
}
|
||||
inserted.remove(clazz)
|
||||
updated[clazz]?.let {
|
||||
rxBus.send(EventNSClientNewLog("UPDATE", "$item $it", activePlugin.activeNsClient?.version ?: NsClient.Version.V3))
|
||||
rxBus.send(EventNSClientNewLog("UPDATE", "$item $it"))
|
||||
}
|
||||
updated.remove(clazz)
|
||||
invalidated[clazz]?.let {
|
||||
rxBus.send(EventNSClientNewLog("INVALIDATE", "$item $it", activePlugin.activeNsClient?.version ?: NsClient.Version.V3))
|
||||
rxBus.send(EventNSClientNewLog("INVALIDATE", "$item $it"))
|
||||
}
|
||||
invalidated.remove(clazz)
|
||||
nsIdUpdated[clazz]?.let {
|
||||
rxBus.send(EventNSClientNewLog("NS_ID", "$item $it", activePlugin.activeNsClient?.version ?: NsClient.Version.V3))
|
||||
rxBus.send(EventNSClientNewLog("NS_ID", "$item $it"))
|
||||
}
|
||||
nsIdUpdated.remove(clazz)
|
||||
durationUpdated[clazz]?.let {
|
||||
rxBus.send(EventNSClientNewLog("DURATION", "$item $it", activePlugin.activeNsClient?.version ?: NsClient.Version.V3))
|
||||
rxBus.send(EventNSClientNewLog("DURATION", "$item $it"))
|
||||
}
|
||||
durationUpdated.remove(clazz)
|
||||
ended[clazz]?.let {
|
||||
rxBus.send(EventNSClientNewLog("CUT", "$item $it", activePlugin.activeNsClient?.version ?: NsClient.Version.V3))
|
||||
rxBus.send(EventNSClientNewLog("CUT", "$item $it"))
|
||||
}
|
||||
ended.remove(clazz)
|
||||
}
|
||||
|
|
|
@ -4,6 +4,6 @@ import android.content.Context
|
|||
import info.nightscout.interfaces.sync.NsClient
|
||||
import info.nightscout.rx.events.EventStatus
|
||||
|
||||
class EventNSClientStatus(var text: String, val version: NsClient.Version) : EventStatus() {
|
||||
class EventNSClientStatus(var text: String) : EventStatus() {
|
||||
override fun getStatus(context: Context): String = text
|
||||
}
|
|
@ -26,7 +26,6 @@ import info.nightscout.interfaces.sync.Sync
|
|||
import info.nightscout.interfaces.utils.HtmlHelper.fromHtml
|
||||
import info.nightscout.plugins.R
|
||||
import info.nightscout.plugins.sync.nsShared.NSClientFragment
|
||||
import info.nightscout.plugins.sync.nsShared.events.EventNSClientNewLog
|
||||
import info.nightscout.plugins.sync.nsShared.events.EventNSClientResend
|
||||
import info.nightscout.plugins.sync.nsShared.events.EventNSClientStatus
|
||||
import info.nightscout.plugins.sync.nsShared.events.EventNSClientUpdateGUI
|
||||
|
@ -37,6 +36,7 @@ import info.nightscout.rx.AapsSchedulers
|
|||
import info.nightscout.rx.bus.RxBus
|
||||
import info.nightscout.rx.events.EventAppExit
|
||||
import info.nightscout.rx.events.EventChargingState
|
||||
import info.nightscout.rx.events.EventNSClientNewLog
|
||||
import info.nightscout.rx.events.EventNetworkChange
|
||||
import info.nightscout.rx.events.EventPreferenceChange
|
||||
import info.nightscout.rx.events.EventSWSyncStatus
|
||||
|
@ -92,12 +92,10 @@ class NSClientPlugin @Inject constructor(
|
|||
.toObservable(EventNSClientStatus::class.java)
|
||||
.observeOn(aapsSchedulers.io)
|
||||
.subscribe({ event ->
|
||||
if (event.version == NsClient.Version.V1) {
|
||||
status = event.getStatus(context)
|
||||
rxBus.send(EventNSClientUpdateGUI())
|
||||
// Pass to setup wizard
|
||||
rxBus.send(EventSWSyncStatus(event.getStatus(context)))
|
||||
}
|
||||
}, fabricPrivacy::logException)
|
||||
disposable += rxBus
|
||||
.toObservable(EventNetworkChange::class.java)
|
||||
|
@ -115,7 +113,6 @@ class NSClientPlugin @Inject constructor(
|
|||
.toObservable(EventNSClientNewLog::class.java)
|
||||
.observeOn(aapsSchedulers.io)
|
||||
.subscribe({ event: EventNSClientNewLog ->
|
||||
if (event.version != NsClient.Version.V1) return@subscribe
|
||||
addToLog(event)
|
||||
aapsLogger.debug(LTag.NSCLIENT, event.action + " " + event.logText)
|
||||
}, fabricPrivacy::logException)
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
package info.nightscout.plugins.sync.nsclient.data
|
||||
|
||||
import info.nightscout.interfaces.Config
|
||||
import info.nightscout.interfaces.configBuilder.RunningConfiguration
|
||||
import info.nightscout.interfaces.nsclient.ProcessedDeviceStatusData
|
||||
import info.nightscout.interfaces.sync.NsClient
|
||||
import info.nightscout.interfaces.utils.HtmlHelper
|
||||
import info.nightscout.interfaces.utils.JsonHelper
|
||||
import info.nightscout.plugins.R
|
||||
import info.nightscout.plugins.configBuilder.RunningConfiguration
|
||||
import info.nightscout.sdk.remotemodel.RemoteDeviceStatus
|
||||
import info.nightscout.shared.sharedPreferences.SP
|
||||
import info.nightscout.shared.utils.DateUtil
|
||||
|
@ -75,7 +74,7 @@ class NSDeviceStatusHandler @Inject constructor(
|
|||
private val processedDeviceStatusData: ProcessedDeviceStatusData
|
||||
) {
|
||||
|
||||
fun handleNewData(deviceStatuses: Array<RemoteDeviceStatus>, version: NsClient.Version) {
|
||||
fun handleNewData(deviceStatuses: Array<RemoteDeviceStatus>) {
|
||||
var configurationDetected = false
|
||||
for (i in deviceStatuses.size - 1 downTo 0) {
|
||||
val nsDeviceStatus = deviceStatuses[i]
|
||||
|
@ -87,7 +86,7 @@ class NSDeviceStatusHandler @Inject constructor(
|
|||
if (config.NSCLIENT && !configurationDetected)
|
||||
nsDeviceStatus.configuration?.let {
|
||||
// copy configuration of Insulin and Sensitivity from main AAPS
|
||||
runningConfiguration.apply(it, version)
|
||||
runningConfiguration.apply(it)
|
||||
configurationDetected = true // pick only newest
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ import info.nightscout.interfaces.aps.Loop
|
|||
import info.nightscout.interfaces.iob.IobCobCalculator
|
||||
import info.nightscout.interfaces.profile.ProfileFunction
|
||||
import info.nightscout.interfaces.pump.Pump
|
||||
import info.nightscout.plugins.configBuilder.RunningConfiguration
|
||||
import info.nightscout.interfaces.configBuilder.RunningConfiguration
|
||||
import info.nightscout.plugins.sync.nsShared.extensions.json
|
||||
import info.nightscout.shared.utils.DateUtil
|
||||
import org.json.JSONObject
|
||||
|
|
|
@ -32,7 +32,7 @@ import info.nightscout.plugins.general.overview.notifications.NotificationWithAc
|
|||
import info.nightscout.plugins.profile.ProfilePlugin
|
||||
import info.nightscout.plugins.source.NSClientSourcePlugin
|
||||
import info.nightscout.plugins.sync.nsShared.StoreDataForDb
|
||||
import info.nightscout.plugins.sync.nsShared.events.EventNSClientNewLog
|
||||
import info.nightscout.rx.events.EventNSClientNewLog
|
||||
import info.nightscout.plugins.sync.nsShared.events.EventNSClientStatus
|
||||
import info.nightscout.plugins.sync.nsShared.events.EventNSClientUpdateGUI
|
||||
import info.nightscout.plugins.sync.nsclient.NSClientPlugin
|
||||
|
@ -210,13 +210,13 @@ class NSClientService : DaggerService(), NsClient.NSClientService {
|
|||
connectionStatus += ')'
|
||||
isConnected = true
|
||||
hasWriteAuth = ack.write && ack.writeTreatment
|
||||
rxBus.send(EventNSClientStatus(connectionStatus, NsClient.Version.V1))
|
||||
rxBus.send(EventNSClientNewLog("AUTH", connectionStatus, NsClient.Version.V1))
|
||||
rxBus.send(EventNSClientStatus(connectionStatus))
|
||||
rxBus.send(EventNSClientNewLog("AUTH", connectionStatus))
|
||||
if (!ack.write) {
|
||||
rxBus.send(EventNSClientNewLog("ERROR", "Write permission not granted ", NsClient.Version.V1))
|
||||
rxBus.send(EventNSClientNewLog("ERROR", "Write permission not granted "))
|
||||
}
|
||||
if (!ack.writeTreatment) {
|
||||
rxBus.send(EventNSClientNewLog("ERROR", "Write treatment permission not granted ", NsClient.Version.V1))
|
||||
rxBus.send(EventNSClientNewLog("ERROR", "Write treatment permission not granted "))
|
||||
}
|
||||
if (!hasWriteAuth) {
|
||||
val noWritePerm = Notification(Notification.NSCLIENT_NO_WRITE_PERMISSION, rh.gs(R.string.no_write_permission), Notification.URGENT)
|
||||
|
@ -241,19 +241,19 @@ class NSClientService : DaggerService(), NsClient.NSClientService {
|
|||
readPreferences()
|
||||
@Suppress("DEPRECATION")
|
||||
if (nsAPISecret != "") nsApiHashCode = Hashing.sha1().hashString(nsAPISecret, Charsets.UTF_8).toString()
|
||||
rxBus.send(EventNSClientStatus("Initializing", NsClient.Version.V1))
|
||||
rxBus.send(EventNSClientStatus("Initializing"))
|
||||
if (!nsClientPlugin.isAllowed) {
|
||||
rxBus.send(EventNSClientNewLog("NSCLIENT", nsClientPlugin.blockingReason, NsClient.Version.V1))
|
||||
rxBus.send(EventNSClientStatus(nsClientPlugin.blockingReason, NsClient.Version.V1))
|
||||
rxBus.send(EventNSClientNewLog("NSCLIENT", nsClientPlugin.blockingReason))
|
||||
rxBus.send(EventNSClientStatus(nsClientPlugin.blockingReason))
|
||||
} else if (sp.getBoolean(R.string.key_ns_client_paused, false)) {
|
||||
rxBus.send(EventNSClientNewLog("NSCLIENT", "paused", NsClient.Version.V1))
|
||||
rxBus.send(EventNSClientStatus("Paused", NsClient.Version.V1))
|
||||
rxBus.send(EventNSClientNewLog("NSCLIENT", "paused"))
|
||||
rxBus.send(EventNSClientStatus("Paused"))
|
||||
} else if (!nsEnabled) {
|
||||
rxBus.send(EventNSClientNewLog("NSCLIENT", "disabled", NsClient.Version.V1))
|
||||
rxBus.send(EventNSClientStatus("Disabled", NsClient.Version.V1))
|
||||
rxBus.send(EventNSClientNewLog("NSCLIENT", "disabled"))
|
||||
rxBus.send(EventNSClientStatus("Disabled"))
|
||||
} else if (nsURL != "" && (config.isEngineeringMode() || nsURL.lowercase(Locale.getDefault()).startsWith("https://"))) {
|
||||
try {
|
||||
rxBus.send(EventNSClientStatus("Connecting ...", NsClient.Version.V1))
|
||||
rxBus.send(EventNSClientStatus("Connecting ..."))
|
||||
val opt = IO.Options()
|
||||
opt.forceNew = true
|
||||
opt.reconnection = true
|
||||
|
@ -264,7 +264,7 @@ class NSClientService : DaggerService(), NsClient.NSClientService {
|
|||
socket.on(Socket.EVENT_CONNECT_ERROR, onError)
|
||||
socket.on(Socket.EVENT_CONNECT_TIMEOUT, onError)
|
||||
socket.on(Socket.EVENT_PING, onPing)
|
||||
rxBus.send(EventNSClientNewLog("NSCLIENT", "do connect", NsClient.Version.V1))
|
||||
rxBus.send(EventNSClientNewLog("NSCLIENT", "do connect"))
|
||||
socket.connect()
|
||||
socket.on("dataUpdate", onDataUpdate)
|
||||
socket.on("announcement", onAnnouncement)
|
||||
|
@ -273,25 +273,25 @@ class NSClientService : DaggerService(), NsClient.NSClientService {
|
|||
socket.on("clear_alarm", onClearAlarm)
|
||||
}
|
||||
} catch (e: URISyntaxException) {
|
||||
rxBus.send(EventNSClientNewLog("NSCLIENT", "Wrong URL syntax", NsClient.Version.V1))
|
||||
rxBus.send(EventNSClientStatus("Wrong URL syntax", NsClient.Version.V1))
|
||||
rxBus.send(EventNSClientNewLog("NSCLIENT", "Wrong URL syntax"))
|
||||
rxBus.send(EventNSClientStatus("Wrong URL syntax"))
|
||||
} catch (e: RuntimeException) {
|
||||
rxBus.send(EventNSClientNewLog("NSCLIENT", "Wrong URL syntax", NsClient.Version.V1))
|
||||
rxBus.send(EventNSClientStatus("Wrong URL syntax", NsClient.Version.V1))
|
||||
rxBus.send(EventNSClientNewLog("NSCLIENT", "Wrong URL syntax"))
|
||||
rxBus.send(EventNSClientStatus("Wrong URL syntax"))
|
||||
}
|
||||
} else if (nsURL.lowercase(Locale.getDefault()).startsWith("http://")) {
|
||||
rxBus.send(EventNSClientNewLog("NSCLIENT", "NS URL not encrypted", NsClient.Version.V1))
|
||||
rxBus.send(EventNSClientStatus("Not encrypted", NsClient.Version.V1))
|
||||
rxBus.send(EventNSClientNewLog("NSCLIENT", "NS URL not encrypted"))
|
||||
rxBus.send(EventNSClientStatus("Not encrypted"))
|
||||
} else {
|
||||
rxBus.send(EventNSClientNewLog("NSCLIENT", "No NS URL specified", NsClient.Version.V1))
|
||||
rxBus.send(EventNSClientStatus("Not configured", NsClient.Version.V1))
|
||||
rxBus.send(EventNSClientNewLog("NSCLIENT", "No NS URL specified"))
|
||||
rxBus.send(EventNSClientStatus("Not configured"))
|
||||
}
|
||||
}
|
||||
|
||||
private val onConnect = Emitter.Listener {
|
||||
connectCounter++
|
||||
val socketId = socket?.id() ?: "NULL"
|
||||
rxBus.send(EventNSClientNewLog("NSCLIENT", "connect #$connectCounter event. ID: $socketId", NsClient.Version.V1))
|
||||
rxBus.send(EventNSClientNewLog("NSCLIENT", "connect #$connectCounter event. ID: $socketId"))
|
||||
if (socket != null) sendAuthMessage(NSAuthAck(rxBus))
|
||||
watchdog()
|
||||
}
|
||||
|
@ -305,16 +305,16 @@ class NSClientService : DaggerService(), NsClient.NSClientService {
|
|||
reconnections.remove(r)
|
||||
}
|
||||
}
|
||||
rxBus.send(EventNSClientNewLog("WATCHDOG", "connections in last " + WATCHDOG_INTERVAL_MINUTES + " minutes: " + reconnections.size + "/" + WATCHDOG_MAX_CONNECTIONS, NsClient.Version.V1))
|
||||
rxBus.send(EventNSClientNewLog("WATCHDOG", "connections in last " + WATCHDOG_INTERVAL_MINUTES + " minutes: " + reconnections.size + "/" + WATCHDOG_MAX_CONNECTIONS))
|
||||
if (reconnections.size >= WATCHDOG_MAX_CONNECTIONS) {
|
||||
val n = Notification(Notification.NS_MALFUNCTION, rh.gs(R.string.ns_malfunction), Notification.URGENT)
|
||||
rxBus.send(EventNewNotification(n))
|
||||
rxBus.send(EventNSClientNewLog("WATCHDOG", "pausing for $WATCHDOG_RECONNECT_IN minutes", NsClient.Version.V1))
|
||||
rxBus.send(EventNSClientNewLog("WATCHDOG", "pausing for $WATCHDOG_RECONNECT_IN minutes"))
|
||||
nsClientPlugin.pause(true)
|
||||
rxBus.send(EventNSClientUpdateGUI())
|
||||
Thread {
|
||||
SystemClock.sleep(mins(WATCHDOG_RECONNECT_IN.toLong()).msecs())
|
||||
rxBus.send(EventNSClientNewLog("WATCHDOG", "re-enabling NSClient", NsClient.Version.V1))
|
||||
rxBus.send(EventNSClientNewLog("WATCHDOG", "re-enabling NSClient"))
|
||||
nsClientPlugin.pause(false)
|
||||
}.start()
|
||||
}
|
||||
|
@ -323,7 +323,7 @@ class NSClientService : DaggerService(), NsClient.NSClientService {
|
|||
|
||||
private val onDisconnect = Emitter.Listener { args ->
|
||||
aapsLogger.debug(LTag.NSCLIENT, "disconnect reason: {}", *args)
|
||||
rxBus.send(EventNSClientNewLog("NSCLIENT", "disconnect event", NsClient.Version.V1))
|
||||
rxBus.send(EventNSClientNewLog("NSCLIENT", "disconnect event"))
|
||||
}
|
||||
|
||||
@Synchronized fun destroy() {
|
||||
|
@ -335,7 +335,7 @@ class NSClientService : DaggerService(), NsClient.NSClientService {
|
|||
socket?.off("alarm")
|
||||
socket?.off("urgent_alarm")
|
||||
socket?.off("clear_alarm")
|
||||
rxBus.send(EventNSClientNewLog("NSCLIENT", "destroy", NsClient.Version.V1))
|
||||
rxBus.send(EventNSClientNewLog("NSCLIENT", "destroy"))
|
||||
isConnected = false
|
||||
hasWriteAuth = false
|
||||
socket?.disconnect()
|
||||
|
@ -354,7 +354,7 @@ class NSClientService : DaggerService(), NsClient.NSClientService {
|
|||
aapsLogger.error("Unhandled exception", e)
|
||||
return
|
||||
}
|
||||
rxBus.send(EventNSClientNewLog("AUTH", "requesting auth", NsClient.Version.V1))
|
||||
rxBus.send(EventNSClientNewLog("AUTH", "requesting auth"))
|
||||
socket?.emit("authorize", authMessage, ack)
|
||||
}
|
||||
|
||||
|
@ -370,10 +370,10 @@ class NSClientService : DaggerService(), NsClient.NSClientService {
|
|||
if (args.isNotEmpty() && args[0] != null) {
|
||||
msg = args[0].toString()
|
||||
}
|
||||
rxBus.send(EventNSClientNewLog("ERROR", msg, NsClient.Version.V1))
|
||||
rxBus.send(EventNSClientNewLog("ERROR", msg))
|
||||
}
|
||||
private val onPing = Emitter.Listener {
|
||||
rxBus.send(EventNSClientNewLog("PING", "received", NsClient.Version.V1))
|
||||
rxBus.send(EventNSClientNewLog("PING", "received"))
|
||||
// send data if there is something waiting
|
||||
resend("Ping received")
|
||||
}
|
||||
|
@ -443,7 +443,7 @@ class NSClientService : DaggerService(), NsClient.NSClientService {
|
|||
val data: JSONObject
|
||||
try {
|
||||
data = args[0] as JSONObject
|
||||
rxBus.send(EventNSClientNewLog("CLEARALARM", "received", NsClient.Version.V1))
|
||||
rxBus.send(EventNSClientNewLog("CLEARALARM", "received"))
|
||||
rxBus.send(EventDismissNotification(Notification.NS_ALARM))
|
||||
rxBus.send(EventDismissNotification(Notification.NS_URGENT_ALARM))
|
||||
aapsLogger.debug(LTag.NSCLIENT, data.toString())
|
||||
|
@ -462,19 +462,19 @@ class NSClientService : DaggerService(), NsClient.NSClientService {
|
|||
try {
|
||||
// delta means only increment/changes are coming
|
||||
val isDelta = data.has("delta")
|
||||
rxBus.send(EventNSClientNewLog("DATA", "Data packet #" + dataCounter++ + if (isDelta) " delta" else " full", NsClient.Version.V1))
|
||||
rxBus.send(EventNSClientNewLog("DATA", "Data packet #" + dataCounter++ + if (isDelta) " delta" else " full"))
|
||||
if (data.has("status")) {
|
||||
val status = data.getJSONObject("status")
|
||||
nsSettingsStatus.handleNewData(status)
|
||||
} else if (!isDelta) {
|
||||
rxBus.send(EventNSClientNewLog("ERROR", "Unsupported Nightscout version ", NsClient.Version.V1))
|
||||
rxBus.send(EventNSClientNewLog("ERROR", "Unsupported Nightscout version "))
|
||||
}
|
||||
if (data.has("profiles")) {
|
||||
val profiles = data.getJSONArray("profiles")
|
||||
if (profiles.length() > 0) {
|
||||
// take the newest
|
||||
val profileStoreJson = profiles[profiles.length() - 1] as JSONObject
|
||||
rxBus.send(EventNSClientNewLog("PROFILE", "profile received", NsClient.Version.V1))
|
||||
rxBus.send(EventNSClientNewLog("PROFILE", "profile received"))
|
||||
dataWorkerStorage.enqueue(
|
||||
OneTimeWorkRequest.Builder(ProfilePlugin.NSProfileWorker::class.java)
|
||||
.setInputData(dataWorkerStorage.storeInputData(profileStoreJson))
|
||||
|
@ -485,7 +485,7 @@ class NSClientService : DaggerService(), NsClient.NSClientService {
|
|||
if (data.has("treatments")) {
|
||||
val treatments = data.getJSONArray("treatments")
|
||||
val addedOrUpdatedTreatments = JSONArray()
|
||||
if (treatments.length() > 0) rxBus.send(EventNSClientNewLog("DATA", "received " + treatments.length() + " treatments", NsClient.Version.V1))
|
||||
if (treatments.length() > 0) rxBus.send(EventNSClientNewLog("DATA", "received " + treatments.length() + " treatments"))
|
||||
for (index in 0 until treatments.length()) {
|
||||
val jsonTreatment = treatments.getJSONObject(index)
|
||||
val action = safeGetStringAllowNull(jsonTreatment, "action", null)
|
||||
|
@ -510,13 +510,13 @@ class NSClientService : DaggerService(), NsClient.NSClientService {
|
|||
}.create()
|
||||
val devicestatuses = gson.fromJson(data.getString("devicestatus"), Array<RemoteDeviceStatus>::class.java)
|
||||
if (devicestatuses.isNotEmpty()) {
|
||||
rxBus.send(EventNSClientNewLog("DATA", "received " + devicestatuses.size + " device statuses", NsClient.Version.V1))
|
||||
nsDeviceStatusHandler.handleNewData(devicestatuses, NsClient.Version.V1)
|
||||
rxBus.send(EventNSClientNewLog("DATA", "received " + devicestatuses.size + " device statuses"))
|
||||
nsDeviceStatusHandler.handleNewData(devicestatuses)
|
||||
}
|
||||
}
|
||||
if (data.has("food")) {
|
||||
val foods = data.getJSONArray("food")
|
||||
if (foods.length() > 0) rxBus.send(EventNSClientNewLog("DATA", "received " + foods.length() + " foods", NsClient.Version.V1))
|
||||
if (foods.length() > 0) rxBus.send(EventNSClientNewLog("DATA", "received " + foods.length() + " foods"))
|
||||
dataWorkerStorage.enqueue(
|
||||
OneTimeWorkRequest.Builder(FoodPlugin.FoodWorker::class.java)
|
||||
.setInputData(dataWorkerStorage.storeInputData(foods))
|
||||
|
@ -525,7 +525,7 @@ class NSClientService : DaggerService(), NsClient.NSClientService {
|
|||
}
|
||||
if (data.has("mbgs")) {
|
||||
val mbgArray = data.getJSONArray("mbgs")
|
||||
if (mbgArray.length() > 0) rxBus.send(EventNSClientNewLog("DATA", "received " + mbgArray.length() + " mbgs", NsClient.Version.V1))
|
||||
if (mbgArray.length() > 0) rxBus.send(EventNSClientNewLog("DATA", "received " + mbgArray.length() + " mbgs"))
|
||||
dataWorkerStorage.enqueue(
|
||||
OneTimeWorkRequest.Builder(NSClientMbgWorker::class.java)
|
||||
.setInputData(dataWorkerStorage.storeInputData(mbgArray))
|
||||
|
@ -534,13 +534,13 @@ class NSClientService : DaggerService(), NsClient.NSClientService {
|
|||
}
|
||||
if (data.has("cals")) {
|
||||
val cals = data.getJSONArray("cals")
|
||||
if (cals.length() > 0) rxBus.send(EventNSClientNewLog("DATA", "received " + cals.length() + " cals", NsClient.Version.V1))
|
||||
if (cals.length() > 0) rxBus.send(EventNSClientNewLog("DATA", "received " + cals.length() + " cals"))
|
||||
// Calibrations ignored
|
||||
}
|
||||
if (data.has("sgvs")) {
|
||||
val sgvs = data.getJSONArray("sgvs")
|
||||
if (sgvs.length() > 0) {
|
||||
rxBus.send(EventNSClientNewLog("DATA", "received " + sgvs.length() + " sgvs", NsClient.Version.V1))
|
||||
rxBus.send(EventNSClientNewLog("DATA", "received " + sgvs.length() + " sgvs"))
|
||||
// Objective0
|
||||
sp.putBoolean(R.string.key_objectives_bg_is_available_in_ns, true)
|
||||
dataWorkerStorage
|
||||
|
@ -553,7 +553,7 @@ class NSClientService : DaggerService(), NsClient.NSClientService {
|
|||
.enqueue()
|
||||
}
|
||||
}
|
||||
rxBus.send(EventNSClientNewLog("LAST", dateUtil.dateAndTimeString(latestDateInReceivedData), NsClient.Version.V1))
|
||||
rxBus.send(EventNSClientNewLog("LAST", dateUtil.dateAndTimeString(latestDateInReceivedData)))
|
||||
} catch (e: JSONException) {
|
||||
aapsLogger.error("Unhandled exception", e)
|
||||
}
|
||||
|
@ -576,7 +576,7 @@ class NSClientService : DaggerService(), NsClient.NSClientService {
|
|||
rxBus.send(
|
||||
EventNSClientNewLog(
|
||||
"DBUPDATE $collection", "Sent " + originalObject.javaClass.simpleName + " " +
|
||||
"" + _id + " " + data + progress, NsClient.Version.V1
|
||||
"" + _id + " " + data + progress
|
||||
)
|
||||
)
|
||||
} catch (e: JSONException) {
|
||||
|
@ -591,7 +591,7 @@ class NSClientService : DaggerService(), NsClient.NSClientService {
|
|||
message.put("collection", collection)
|
||||
message.put("data", data)
|
||||
socket?.emit("dbAdd", message, NSAddAck(aapsLogger, rxBus, originalObject))
|
||||
rxBus.send(EventNSClientNewLog("DBADD $collection", "Sent " + originalObject.javaClass.simpleName + " " + data + " " + progress, NsClient.Version.V1))
|
||||
rxBus.send(EventNSClientNewLog("DBADD $collection", "Sent " + originalObject.javaClass.simpleName + " " + data + " " + progress))
|
||||
} catch (e: JSONException) {
|
||||
aapsLogger.error("Unhandled exception", e)
|
||||
}
|
||||
|
@ -600,7 +600,7 @@ class NSClientService : DaggerService(), NsClient.NSClientService {
|
|||
fun sendAlarmAck(alarmAck: AlarmAck) {
|
||||
if (!isConnected || !hasWriteAuth) return
|
||||
socket?.emit("ack", alarmAck.level, alarmAck.group, alarmAck.silenceTime)
|
||||
rxBus.send(EventNSClientNewLog("ALARMACK ", alarmAck.level.toString() + " " + alarmAck.group + " " + alarmAck.silenceTime, NsClient.Version.V1))
|
||||
rxBus.send(EventNSClientNewLog("ALARMACK ", alarmAck.level.toString() + " " + alarmAck.group + " " + alarmAck.silenceTime))
|
||||
}
|
||||
|
||||
fun resend(reason: String) {
|
||||
|
@ -616,9 +616,9 @@ class NSClientService : DaggerService(), NsClient.NSClientService {
|
|||
// "AndroidAPS:NSClientService_onDataUpdate")
|
||||
// wakeLock.acquire(mins(10).msecs())
|
||||
try {
|
||||
rxBus.send(EventNSClientNewLog("QUEUE", "Resend started: $reason", NsClient.Version.V1))
|
||||
rxBus.send(EventNSClientNewLog("QUEUE", "Resend started: $reason"))
|
||||
dataSyncSelector.doUpload()
|
||||
rxBus.send(EventNSClientNewLog("QUEUE", "Resend ended: $reason", NsClient.Version.V1))
|
||||
rxBus.send(EventNSClientNewLog("QUEUE", "Resend ended: $reason"))
|
||||
} finally {
|
||||
// if (wakeLock.isHeld) wakeLock.release()
|
||||
}
|
||||
|
@ -636,7 +636,7 @@ class NSClientService : DaggerService(), NsClient.NSClientService {
|
|||
val nsAlarm = NSAlarm(announcement)
|
||||
val notification: Notification = NotificationWithAction(injector, nsAlarm)
|
||||
rxBus.send(EventNewNotification(notification))
|
||||
rxBus.send(EventNSClientNewLog("ANNOUNCEMENT", safeGetString(announcement, "message", "received"), NsClient.Version.V1))
|
||||
rxBus.send(EventNSClientNewLog("ANNOUNCEMENT", safeGetString(announcement, "message", "received")))
|
||||
aapsLogger.debug(LTag.NSCLIENT, announcement.toString())
|
||||
}
|
||||
}
|
||||
|
@ -650,7 +650,7 @@ class NSClientService : DaggerService(), NsClient.NSClientService {
|
|||
val notification: Notification = NotificationWithAction(injector, nsAlarm)
|
||||
rxBus.send(EventNewNotification(notification))
|
||||
}
|
||||
rxBus.send(EventNSClientNewLog("ALARM", safeGetString(alarm, "message", "received"), NsClient.Version.V1))
|
||||
rxBus.send(EventNSClientNewLog("ALARM", safeGetString(alarm, "message", "received")))
|
||||
aapsLogger.debug(LTag.NSCLIENT, alarm.toString())
|
||||
}
|
||||
}
|
||||
|
@ -664,7 +664,7 @@ class NSClientService : DaggerService(), NsClient.NSClientService {
|
|||
val notification: Notification = NotificationWithAction(injector, nsAlarm)
|
||||
rxBus.send(EventNewNotification(notification))
|
||||
}
|
||||
rxBus.send(EventNSClientNewLog("URGENTALARM", safeGetString(alarm, "message", "received"), NsClient.Version.V1))
|
||||
rxBus.send(EventNSClientNewLog("URGENTALARM", safeGetString(alarm, "message", "received")))
|
||||
aapsLogger.debug(LTag.NSCLIENT, alarm.toString())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,12 +36,11 @@ import info.nightscout.interfaces.sync.DataSyncSelector.PairProfileSwitch
|
|||
import info.nightscout.interfaces.sync.DataSyncSelector.PairTemporaryBasal
|
||||
import info.nightscout.interfaces.sync.DataSyncSelector.PairTemporaryTarget
|
||||
import info.nightscout.interfaces.sync.DataSyncSelector.PairTherapyEvent
|
||||
import info.nightscout.interfaces.sync.NsClient
|
||||
import info.nightscout.plugins.R
|
||||
import info.nightscout.plugins.sync.nsShared.events.EventNSClientNewLog
|
||||
import info.nightscout.plugins.sync.nsclient.acks.NSAddAck
|
||||
import info.nightscout.rx.AapsSchedulers
|
||||
import info.nightscout.rx.bus.RxBus
|
||||
import info.nightscout.rx.events.EventNSClientNewLog
|
||||
import info.nightscout.rx.logging.AAPSLogger
|
||||
import info.nightscout.rx.logging.LTag
|
||||
import info.nightscout.shared.sharedPreferences.SP
|
||||
|
@ -83,7 +82,7 @@ class NSClientAddAckWorker(
|
|||
dataSyncSelector.confirmLastTempTargetsIdIfGreater(pair.updateRecordId)
|
||||
}
|
||||
.blockingGet()
|
||||
rxBus.send(EventNSClientNewLog("DBADD", "Acked TemporaryTarget " + pair.value.interfaceIDs.nightscoutId, NsClient.Version.V1))
|
||||
rxBus.send(EventNSClientNewLog("DBADD", "Acked TemporaryTarget " + pair.value.interfaceIDs.nightscoutId))
|
||||
// Send new if waiting
|
||||
dataSyncSelector.processChangedTempTargetsCompat()
|
||||
}
|
||||
|
@ -102,7 +101,7 @@ class NSClientAddAckWorker(
|
|||
dataSyncSelector.confirmLastGlucoseValueIdIfGreater(pair.updateRecordId)
|
||||
}
|
||||
.blockingGet()
|
||||
rxBus.send(EventNSClientNewLog("DBADD", "Acked GlucoseValue " + pair.value.interfaceIDs.nightscoutId, NsClient.Version.V1))
|
||||
rxBus.send(EventNSClientNewLog("DBADD", "Acked GlucoseValue " + pair.value.interfaceIDs.nightscoutId))
|
||||
// Send new if waiting
|
||||
dataSyncSelector.processChangedGlucoseValuesCompat()
|
||||
}
|
||||
|
@ -121,7 +120,7 @@ class NSClientAddAckWorker(
|
|||
dataSyncSelector.confirmLastFoodIdIfGreater(pair.updateRecordId)
|
||||
}
|
||||
.blockingGet()
|
||||
rxBus.send(EventNSClientNewLog("DBADD", "Acked Food " + pair.value.interfaceIDs.nightscoutId, NsClient.Version.V1))
|
||||
rxBus.send(EventNSClientNewLog("DBADD", "Acked Food " + pair.value.interfaceIDs.nightscoutId))
|
||||
// Send new if waiting
|
||||
dataSyncSelector.processChangedFoodsCompat()
|
||||
}
|
||||
|
@ -140,7 +139,7 @@ class NSClientAddAckWorker(
|
|||
dataSyncSelector.confirmLastTherapyEventIdIfGreater(pair.updateRecordId)
|
||||
}
|
||||
.blockingGet()
|
||||
rxBus.send(EventNSClientNewLog("DBADD", "Acked TherapyEvent " + pair.value.interfaceIDs.nightscoutId, NsClient.Version.V1))
|
||||
rxBus.send(EventNSClientNewLog("DBADD", "Acked TherapyEvent " + pair.value.interfaceIDs.nightscoutId))
|
||||
// Send new if waiting
|
||||
dataSyncSelector.processChangedTherapyEventsCompat()
|
||||
}
|
||||
|
@ -159,7 +158,7 @@ class NSClientAddAckWorker(
|
|||
dataSyncSelector.confirmLastBolusIdIfGreater(pair.updateRecordId)
|
||||
}
|
||||
.blockingGet()
|
||||
rxBus.send(EventNSClientNewLog("DBADD", "Acked Bolus " + pair.value.interfaceIDs.nightscoutId, NsClient.Version.V1))
|
||||
rxBus.send(EventNSClientNewLog("DBADD", "Acked Bolus " + pair.value.interfaceIDs.nightscoutId))
|
||||
// Send new if waiting
|
||||
dataSyncSelector.processChangedBolusesCompat()
|
||||
}
|
||||
|
@ -178,7 +177,7 @@ class NSClientAddAckWorker(
|
|||
dataSyncSelector.confirmLastCarbsIdIfGreater(pair.updateRecordId)
|
||||
}
|
||||
.blockingGet()
|
||||
rxBus.send(EventNSClientNewLog("DBADD", "Acked Carbs " + pair.value.interfaceIDs.nightscoutId, NsClient.Version.V1))
|
||||
rxBus.send(EventNSClientNewLog("DBADD", "Acked Carbs " + pair.value.interfaceIDs.nightscoutId))
|
||||
// Send new if waiting
|
||||
dataSyncSelector.processChangedCarbsCompat()
|
||||
}
|
||||
|
@ -197,7 +196,7 @@ class NSClientAddAckWorker(
|
|||
dataSyncSelector.confirmLastBolusCalculatorResultsIdIfGreater(pair.updateRecordId)
|
||||
}
|
||||
.blockingGet()
|
||||
rxBus.send(EventNSClientNewLog("DBADD", "Acked BolusCalculatorResult " + pair.value.interfaceIDs.nightscoutId, NsClient.Version.V1))
|
||||
rxBus.send(EventNSClientNewLog("DBADD", "Acked BolusCalculatorResult " + pair.value.interfaceIDs.nightscoutId))
|
||||
// Send new if waiting
|
||||
dataSyncSelector.processChangedBolusCalculatorResultsCompat()
|
||||
}
|
||||
|
@ -216,7 +215,7 @@ class NSClientAddAckWorker(
|
|||
dataSyncSelector.confirmLastTemporaryBasalIdIfGreater(pair.updateRecordId)
|
||||
}
|
||||
.blockingGet()
|
||||
rxBus.send(EventNSClientNewLog("DBADD", "Acked TemporaryBasal " + pair.value.interfaceIDs.nightscoutId, NsClient.Version.V1))
|
||||
rxBus.send(EventNSClientNewLog("DBADD", "Acked TemporaryBasal " + pair.value.interfaceIDs.nightscoutId))
|
||||
// Send new if waiting
|
||||
dataSyncSelector.processChangedTemporaryBasalsCompat()
|
||||
}
|
||||
|
@ -235,7 +234,7 @@ class NSClientAddAckWorker(
|
|||
dataSyncSelector.confirmLastExtendedBolusIdIfGreater(pair.updateRecordId)
|
||||
}
|
||||
.blockingGet()
|
||||
rxBus.send(EventNSClientNewLog("DBADD", "Acked ExtendedBolus " + pair.value.interfaceIDs.nightscoutId, NsClient.Version.V1))
|
||||
rxBus.send(EventNSClientNewLog("DBADD", "Acked ExtendedBolus " + pair.value.interfaceIDs.nightscoutId))
|
||||
// Send new if waiting
|
||||
dataSyncSelector.processChangedExtendedBolusesCompat()
|
||||
}
|
||||
|
@ -254,7 +253,7 @@ class NSClientAddAckWorker(
|
|||
dataSyncSelector.confirmLastProfileSwitchIdIfGreater(pair.updateRecordId)
|
||||
}
|
||||
.blockingGet()
|
||||
rxBus.send(EventNSClientNewLog("DBADD", "Acked ProfileSwitch " + pair.value.interfaceIDs.nightscoutId, NsClient.Version.V1))
|
||||
rxBus.send(EventNSClientNewLog("DBADD", "Acked ProfileSwitch " + pair.value.interfaceIDs.nightscoutId))
|
||||
// Send new if waiting
|
||||
dataSyncSelector.processChangedProfileSwitchesCompat()
|
||||
}
|
||||
|
@ -273,7 +272,7 @@ class NSClientAddAckWorker(
|
|||
dataSyncSelector.confirmLastEffectiveProfileSwitchIdIfGreater(pair.updateRecordId)
|
||||
}
|
||||
.blockingGet()
|
||||
rxBus.send(EventNSClientNewLog("DBADD", "Acked EffectiveProfileSwitch " + pair.value.interfaceIDs.nightscoutId, NsClient.Version.V1))
|
||||
rxBus.send(EventNSClientNewLog("DBADD", "Acked EffectiveProfileSwitch " + pair.value.interfaceIDs.nightscoutId))
|
||||
// Send new if waiting
|
||||
dataSyncSelector.processChangedEffectiveProfileSwitchesCompat()
|
||||
}
|
||||
|
@ -292,14 +291,14 @@ class NSClientAddAckWorker(
|
|||
dataSyncSelector.confirmLastDeviceStatusIdIfGreater(deviceStatus.id)
|
||||
}
|
||||
.blockingGet()
|
||||
rxBus.send(EventNSClientNewLog("DBADD", "Acked DeviceStatus " + deviceStatus.interfaceIDs.nightscoutId, NsClient.Version.V1))
|
||||
rxBus.send(EventNSClientNewLog("DBADD", "Acked DeviceStatus " + deviceStatus.interfaceIDs.nightscoutId))
|
||||
// Send new if waiting
|
||||
dataSyncSelector.processChangedDeviceStatusesCompat()
|
||||
}
|
||||
|
||||
is PairProfileStore -> {
|
||||
dataSyncSelector.confirmLastProfileStore(ack.originalObject.timestampSync)
|
||||
rxBus.send(EventNSClientNewLog("DBADD", "Acked ProfileStore " + ack.id, NsClient.Version.V1))
|
||||
rxBus.send(EventNSClientNewLog("DBADD", "Acked ProfileStore " + ack.id))
|
||||
}
|
||||
|
||||
is PairOfflineEvent -> {
|
||||
|
@ -316,7 +315,7 @@ class NSClientAddAckWorker(
|
|||
dataSyncSelector.confirmLastOfflineEventIdIfGreater(pair.updateRecordId)
|
||||
}
|
||||
.blockingGet()
|
||||
rxBus.send(EventNSClientNewLog("DBADD", "Acked OfflineEvent " + pair.value.interfaceIDs.nightscoutId, NsClient.Version.V1))
|
||||
rxBus.send(EventNSClientNewLog("DBADD", "Acked OfflineEvent " + pair.value.interfaceIDs.nightscoutId))
|
||||
// Send new if waiting
|
||||
dataSyncSelector.processChangedOfflineEventsCompat()
|
||||
}
|
||||
|
|
|
@ -20,11 +20,10 @@ import info.nightscout.interfaces.sync.DataSyncSelector.PairProfileSwitch
|
|||
import info.nightscout.interfaces.sync.DataSyncSelector.PairTemporaryBasal
|
||||
import info.nightscout.interfaces.sync.DataSyncSelector.PairTemporaryTarget
|
||||
import info.nightscout.interfaces.sync.DataSyncSelector.PairTherapyEvent
|
||||
import info.nightscout.interfaces.sync.NsClient
|
||||
import info.nightscout.plugins.sync.nsShared.events.EventNSClientNewLog
|
||||
import info.nightscout.plugins.sync.nsclient.acks.NSUpdateAck
|
||||
import info.nightscout.rx.AapsSchedulers
|
||||
import info.nightscout.rx.bus.RxBus
|
||||
import info.nightscout.rx.events.EventNSClientNewLog
|
||||
import info.nightscout.rx.logging.AAPSLogger
|
||||
import javax.inject.Inject
|
||||
|
||||
|
@ -51,7 +50,7 @@ class NSClientUpdateRemoveAckWorker(
|
|||
is PairTemporaryTarget -> {
|
||||
val pair = ack.originalObject
|
||||
dataSyncSelector.confirmLastTempTargetsIdIfGreater(pair.updateRecordId)
|
||||
rxBus.send(EventNSClientNewLog("DBUPDATE", "Acked TemporaryTarget" + ack._id, NsClient.Version.V1))
|
||||
rxBus.send(EventNSClientNewLog("DBUPDATE", "Acked TemporaryTarget" + ack._id))
|
||||
// Send new if waiting
|
||||
dataSyncSelector.processChangedTempTargetsCompat()
|
||||
ret = Result.success(workDataOf("ProcessedData" to pair.toString()))
|
||||
|
@ -60,7 +59,7 @@ class NSClientUpdateRemoveAckWorker(
|
|||
is PairGlucoseValue -> {
|
||||
val pair = ack.originalObject
|
||||
dataSyncSelector.confirmLastGlucoseValueIdIfGreater(pair.updateRecordId)
|
||||
rxBus.send(EventNSClientNewLog("DBUPDATE", "Acked GlucoseValue " + ack._id, NsClient.Version.V1))
|
||||
rxBus.send(EventNSClientNewLog("DBUPDATE", "Acked GlucoseValue " + ack._id))
|
||||
// Send new if waiting
|
||||
dataSyncSelector.processChangedGlucoseValuesCompat()
|
||||
ret = Result.success(workDataOf("ProcessedData" to pair.toString()))
|
||||
|
@ -69,7 +68,7 @@ class NSClientUpdateRemoveAckWorker(
|
|||
is PairFood -> {
|
||||
val pair = ack.originalObject
|
||||
dataSyncSelector.confirmLastFoodIdIfGreater(pair.updateRecordId)
|
||||
rxBus.send(EventNSClientNewLog("DBUPDATE", "Acked Food " + ack._id, NsClient.Version.V1))
|
||||
rxBus.send(EventNSClientNewLog("DBUPDATE", "Acked Food " + ack._id))
|
||||
// Send new if waiting
|
||||
dataSyncSelector.processChangedFoodsCompat()
|
||||
ret = Result.success(workDataOf("ProcessedData" to pair.toString()))
|
||||
|
@ -78,7 +77,7 @@ class NSClientUpdateRemoveAckWorker(
|
|||
is PairTherapyEvent -> {
|
||||
val pair = ack.originalObject
|
||||
dataSyncSelector.confirmLastTherapyEventIdIfGreater(pair.updateRecordId)
|
||||
rxBus.send(EventNSClientNewLog("DBUPDATE", "Acked TherapyEvent " + ack._id, NsClient.Version.V1))
|
||||
rxBus.send(EventNSClientNewLog("DBUPDATE", "Acked TherapyEvent " + ack._id))
|
||||
// Send new if waiting
|
||||
dataSyncSelector.processChangedTherapyEventsCompat()
|
||||
ret = Result.success(workDataOf("ProcessedData" to pair.toString()))
|
||||
|
@ -87,7 +86,7 @@ class NSClientUpdateRemoveAckWorker(
|
|||
is PairBolus -> {
|
||||
val pair = ack.originalObject
|
||||
dataSyncSelector.confirmLastBolusIdIfGreater(pair.updateRecordId)
|
||||
rxBus.send(EventNSClientNewLog("DBUPDATE", "Acked Bolus " + ack._id, NsClient.Version.V1))
|
||||
rxBus.send(EventNSClientNewLog("DBUPDATE", "Acked Bolus " + ack._id))
|
||||
// Send new if waiting
|
||||
dataSyncSelector.processChangedBolusesCompat()
|
||||
ret = Result.success(workDataOf("ProcessedData" to pair.toString()))
|
||||
|
@ -96,7 +95,7 @@ class NSClientUpdateRemoveAckWorker(
|
|||
is PairCarbs -> {
|
||||
val pair = ack.originalObject
|
||||
dataSyncSelector.confirmLastCarbsIdIfGreater(pair.updateRecordId)
|
||||
rxBus.send(EventNSClientNewLog("DBUPDATE", "Acked Carbs " + ack._id, NsClient.Version.V1))
|
||||
rxBus.send(EventNSClientNewLog("DBUPDATE", "Acked Carbs " + ack._id))
|
||||
// Send new if waiting
|
||||
dataSyncSelector.processChangedCarbsCompat()
|
||||
ret = Result.success(workDataOf("ProcessedData" to pair.toString()))
|
||||
|
@ -105,7 +104,7 @@ class NSClientUpdateRemoveAckWorker(
|
|||
is PairBolusCalculatorResult -> {
|
||||
val pair = ack.originalObject
|
||||
dataSyncSelector.confirmLastBolusCalculatorResultsIdIfGreater(pair.updateRecordId)
|
||||
rxBus.send(EventNSClientNewLog("DBUPDATE", "Acked BolusCalculatorResult " + ack._id, NsClient.Version.V1))
|
||||
rxBus.send(EventNSClientNewLog("DBUPDATE", "Acked BolusCalculatorResult " + ack._id))
|
||||
// Send new if waiting
|
||||
dataSyncSelector.processChangedBolusCalculatorResultsCompat()
|
||||
ret = Result.success(workDataOf("ProcessedData" to pair.toString()))
|
||||
|
@ -114,7 +113,7 @@ class NSClientUpdateRemoveAckWorker(
|
|||
is PairTemporaryBasal -> {
|
||||
val pair = ack.originalObject
|
||||
dataSyncSelector.confirmLastTemporaryBasalIdIfGreater(pair.updateRecordId)
|
||||
rxBus.send(EventNSClientNewLog("DBUPDATE", "Acked TemporaryBasal " + ack._id, NsClient.Version.V1))
|
||||
rxBus.send(EventNSClientNewLog("DBUPDATE", "Acked TemporaryBasal " + ack._id))
|
||||
// Send new if waiting
|
||||
dataSyncSelector.processChangedTemporaryBasalsCompat()
|
||||
ret = Result.success(workDataOf("ProcessedData" to pair.toString()))
|
||||
|
@ -123,7 +122,7 @@ class NSClientUpdateRemoveAckWorker(
|
|||
is PairExtendedBolus -> {
|
||||
val pair = ack.originalObject
|
||||
dataSyncSelector.confirmLastExtendedBolusIdIfGreater(pair.updateRecordId)
|
||||
rxBus.send(EventNSClientNewLog("DBUPDATE", "Acked ExtendedBolus " + ack._id, NsClient.Version.V1))
|
||||
rxBus.send(EventNSClientNewLog("DBUPDATE", "Acked ExtendedBolus " + ack._id))
|
||||
// Send new if waiting
|
||||
dataSyncSelector.processChangedExtendedBolusesCompat()
|
||||
ret = Result.success(workDataOf("ProcessedData" to pair.toString()))
|
||||
|
@ -132,7 +131,7 @@ class NSClientUpdateRemoveAckWorker(
|
|||
is PairProfileSwitch -> {
|
||||
val pair = ack.originalObject
|
||||
dataSyncSelector.confirmLastProfileSwitchIdIfGreater(pair.updateRecordId)
|
||||
rxBus.send(EventNSClientNewLog("DBUPDATE", "Acked ProfileSwitch " + ack._id, NsClient.Version.V1))
|
||||
rxBus.send(EventNSClientNewLog("DBUPDATE", "Acked ProfileSwitch " + ack._id))
|
||||
// Send new if waiting
|
||||
dataSyncSelector.processChangedProfileSwitchesCompat()
|
||||
ret = Result.success(workDataOf("ProcessedData" to pair.toString()))
|
||||
|
@ -141,7 +140,7 @@ class NSClientUpdateRemoveAckWorker(
|
|||
is PairEffectiveProfileSwitch -> {
|
||||
val pair = ack.originalObject
|
||||
dataSyncSelector.confirmLastEffectiveProfileSwitchIdIfGreater(pair.updateRecordId)
|
||||
rxBus.send(EventNSClientNewLog("DBUPDATE", "Acked EffectiveProfileSwitch " + ack._id, NsClient.Version.V1))
|
||||
rxBus.send(EventNSClientNewLog("DBUPDATE", "Acked EffectiveProfileSwitch " + ack._id))
|
||||
// Send new if waiting
|
||||
dataSyncSelector.processChangedEffectiveProfileSwitchesCompat()
|
||||
ret = Result.success(workDataOf("ProcessedData" to pair.toString()))
|
||||
|
@ -150,7 +149,7 @@ class NSClientUpdateRemoveAckWorker(
|
|||
is PairOfflineEvent -> {
|
||||
val pair = ack.originalObject
|
||||
dataSyncSelector.confirmLastOfflineEventIdIfGreater(pair.updateRecordId)
|
||||
rxBus.send(EventNSClientNewLog("DBUPDATE", "Acked OfflineEvent" + ack._id, NsClient.Version.V1))
|
||||
rxBus.send(EventNSClientNewLog("DBUPDATE", "Acked OfflineEvent" + ack._id))
|
||||
// Send new if waiting
|
||||
dataSyncSelector.processChangedOfflineEventsCompat()
|
||||
ret = Result.success(workDataOf("ProcessedData" to pair.toString()))
|
||||
|
|
|
@ -25,7 +25,6 @@ import info.nightscout.interfaces.sync.Sync
|
|||
import info.nightscout.interfaces.utils.HtmlHelper
|
||||
import info.nightscout.plugins.R
|
||||
import info.nightscout.plugins.sync.nsShared.NSClientFragment
|
||||
import info.nightscout.plugins.sync.nsShared.events.EventNSClientNewLog
|
||||
import info.nightscout.plugins.sync.nsShared.events.EventNSClientResend
|
||||
import info.nightscout.plugins.sync.nsShared.events.EventNSClientStatus
|
||||
import info.nightscout.plugins.sync.nsShared.events.EventNSClientUpdateGUI
|
||||
|
@ -39,6 +38,7 @@ import info.nightscout.plugins.sync.nsclientV3.workers.LoadStatusWorker
|
|||
import info.nightscout.rx.AapsSchedulers
|
||||
import info.nightscout.rx.bus.RxBus
|
||||
import info.nightscout.rx.events.EventChargingState
|
||||
import info.nightscout.rx.events.EventNSClientNewLog
|
||||
import info.nightscout.rx.events.EventNetworkChange
|
||||
import info.nightscout.rx.events.EventPreferenceChange
|
||||
import info.nightscout.rx.events.EventSWSyncStatus
|
||||
|
@ -145,12 +145,10 @@ class NSClientV3Plugin @Inject constructor(
|
|||
.toObservable(EventNSClientStatus::class.java)
|
||||
.observeOn(aapsSchedulers.io)
|
||||
.subscribe({ event ->
|
||||
if (event.version == NsClient.Version.V3) {
|
||||
status = event.getStatus(context)
|
||||
rxBus.send(EventNSClientUpdateGUI())
|
||||
// Pass to setup wizard
|
||||
rxBus.send(EventSWSyncStatus(event.getStatus(context)))
|
||||
}
|
||||
}, fabricPrivacy::logException)
|
||||
disposable += rxBus
|
||||
.toObservable(EventNetworkChange::class.java)
|
||||
|
@ -168,7 +166,6 @@ class NSClientV3Plugin @Inject constructor(
|
|||
.toObservable(EventNSClientNewLog::class.java)
|
||||
.observeOn(aapsSchedulers.io)
|
||||
.subscribe({ event ->
|
||||
if (event.version != NsClient.Version.V3) return@subscribe
|
||||
addToLog(event)
|
||||
aapsLogger.debug(LTag.NSCLIENT, event.action + " " + event.logText)
|
||||
}, fabricPrivacy::logException)
|
||||
|
@ -291,9 +288,9 @@ class NSClientV3Plugin @Inject constructor(
|
|||
|
||||
fun test() {
|
||||
if (workIsRunning(arrayOf(JOB_NAME)))
|
||||
rxBus.send(EventNSClientNewLog("RUN", "Already running", NsClient.Version.V3))
|
||||
rxBus.send(EventNSClientNewLog("RUN", "Already running"))
|
||||
else {
|
||||
rxBus.send(EventNSClientNewLog("RUN", "Starting next round", NsClient.Version.V3))
|
||||
rxBus.send(EventNSClientNewLog("RUN", "Starting next round"))
|
||||
WorkManager.getInstance(context)
|
||||
.beginUniqueWork(
|
||||
"NSCv3Load",
|
||||
|
|
|
@ -9,13 +9,12 @@ import androidx.work.WorkerParameters
|
|||
import androidx.work.workDataOf
|
||||
import dagger.android.HasAndroidInjector
|
||||
import info.nightscout.core.utils.receivers.DataWorkerStorage
|
||||
import info.nightscout.interfaces.sync.NsClient
|
||||
import info.nightscout.plugins.R
|
||||
import info.nightscout.plugins.source.NSClientSourcePlugin
|
||||
import info.nightscout.plugins.sync.nsShared.StoreDataForDb
|
||||
import info.nightscout.plugins.sync.nsShared.events.EventNSClientNewLog
|
||||
import info.nightscout.plugins.sync.nsclientV3.NSClientV3Plugin
|
||||
import info.nightscout.rx.bus.RxBus
|
||||
import info.nightscout.rx.events.EventNSClientNewLog
|
||||
import info.nightscout.rx.logging.AAPSLogger
|
||||
import info.nightscout.shared.sharedPreferences.SP
|
||||
import info.nightscout.shared.utils.DateUtil
|
||||
|
@ -52,8 +51,7 @@ class LoadBgWorker(
|
|||
rxBus.send(
|
||||
EventNSClientNewLog(
|
||||
"RCV",
|
||||
"${sgvs.size} SVGs from ${dateUtil.dateAndTimeAndSecondsString(nsClientV3Plugin.lastFetched.collections.entries)}",
|
||||
NsClient.Version.V3
|
||||
"${sgvs.size} SVGs from ${dateUtil.dateAndTimeAndSecondsString(nsClientV3Plugin.lastFetched.collections.entries)}"
|
||||
)
|
||||
)
|
||||
// Objective0
|
||||
|
@ -65,7 +63,7 @@ class LoadBgWorker(
|
|||
OneTimeWorkRequest.Builder(NSClientSourcePlugin.NSClientSourceWorker::class.java).setInputData(dataWorkerStorage.storeInputData(sgvs)).build()
|
||||
).then(OneTimeWorkRequest.Builder(LoadBgWorker::class.java).build()).enqueue()
|
||||
} else {
|
||||
rxBus.send(EventNSClientNewLog("END", "No SGVs from ${dateUtil.dateAndTimeAndSecondsString(nsClientV3Plugin.lastFetched.collections.entries)}", NsClient.Version.V3))
|
||||
rxBus.send(EventNSClientNewLog("END", "No SGVs from ${dateUtil.dateAndTimeAndSecondsString(nsClientV3Plugin.lastFetched.collections.entries)}"))
|
||||
WorkManager.getInstance(context)
|
||||
.beginUniqueWork(
|
||||
NSClientV3Plugin.JOB_NAME,
|
||||
|
@ -80,7 +78,7 @@ class LoadBgWorker(
|
|||
ret = Result.failure(workDataOf("Error" to error.toString()))
|
||||
}
|
||||
else {
|
||||
rxBus.send(EventNSClientNewLog("END", "No new SGVs from ${dateUtil.dateAndTimeAndSecondsString(nsClientV3Plugin.lastFetched.collections.entries)}", NsClient.Version.V3))
|
||||
rxBus.send(EventNSClientNewLog("END", "No new SGVs from ${dateUtil.dateAndTimeAndSecondsString(nsClientV3Plugin.lastFetched.collections.entries)}"))
|
||||
WorkManager.getInstance(context)
|
||||
.beginUniqueWork(
|
||||
NSClientV3Plugin.JOB_NAME,
|
||||
|
|
|
@ -6,11 +6,10 @@ import androidx.work.WorkerParameters
|
|||
import androidx.work.workDataOf
|
||||
import dagger.android.HasAndroidInjector
|
||||
import info.nightscout.core.utils.receivers.DataWorkerStorage
|
||||
import info.nightscout.interfaces.sync.NsClient
|
||||
import info.nightscout.plugins.sync.nsShared.events.EventNSClientNewLog
|
||||
import info.nightscout.plugins.sync.nsclient.data.NSDeviceStatusHandler
|
||||
import info.nightscout.plugins.sync.nsclientV3.NSClientV3Plugin
|
||||
import info.nightscout.rx.bus.RxBus
|
||||
import info.nightscout.rx.events.EventNSClientNewLog
|
||||
import info.nightscout.rx.logging.AAPSLogger
|
||||
import info.nightscout.shared.utils.DateUtil
|
||||
import info.nightscout.shared.utils.T
|
||||
|
@ -39,10 +38,10 @@ class LoadDeviceStatusWorker(
|
|||
val deviceStatuses = nsClientV3Plugin.nsAndroidClient.getDeviceStatusModifiedSince(from)
|
||||
aapsLogger.debug("DEVICESTATUSES: $deviceStatuses")
|
||||
if (deviceStatuses.isNotEmpty()) {
|
||||
rxBus.send(EventNSClientNewLog("RCV", "${deviceStatuses.size} DSs from ${dateUtil.dateAndTimeAndSecondsString(from)}", NsClient.Version.V3))
|
||||
nsDeviceStatusHandler.handleNewData(deviceStatuses.toTypedArray(), NsClient.Version.V3)
|
||||
rxBus.send(EventNSClientNewLog("RCV", "${deviceStatuses.size} DSs from ${dateUtil.dateAndTimeAndSecondsString(from)}"))
|
||||
nsDeviceStatusHandler.handleNewData(deviceStatuses.toTypedArray())
|
||||
} else {
|
||||
rxBus.send(EventNSClientNewLog("END", "No DSs from ${dateUtil.dateAndTimeAndSecondsString(from)}", NsClient.Version.V3))
|
||||
rxBus.send(EventNSClientNewLog("END", "No DSs from ${dateUtil.dateAndTimeAndSecondsString(from)}"))
|
||||
}
|
||||
} catch (error: Exception) {
|
||||
aapsLogger.error("Error: ", error)
|
||||
|
|
|
@ -9,11 +9,10 @@ import androidx.work.WorkerParameters
|
|||
import androidx.work.workDataOf
|
||||
import dagger.android.HasAndroidInjector
|
||||
import info.nightscout.core.utils.receivers.DataWorkerStorage
|
||||
import info.nightscout.interfaces.sync.NsClient
|
||||
import info.nightscout.plugins.sync.nsShared.StoreDataForDb
|
||||
import info.nightscout.plugins.sync.nsShared.events.EventNSClientNewLog
|
||||
import info.nightscout.plugins.sync.nsclientV3.NSClientV3Plugin
|
||||
import info.nightscout.rx.bus.RxBus
|
||||
import info.nightscout.rx.events.EventNSClientNewLog
|
||||
import info.nightscout.rx.logging.AAPSLogger
|
||||
import info.nightscout.shared.utils.DateUtil
|
||||
import kotlinx.coroutines.runBlocking
|
||||
|
@ -44,8 +43,7 @@ class LoadTreatmentsWorker(
|
|||
rxBus.send(
|
||||
EventNSClientNewLog(
|
||||
"RCV",
|
||||
"${treatments.size} TRs from ${dateUtil.dateAndTimeAndSecondsString(nsClientV3Plugin.lastFetched.collections.treatments)}",
|
||||
NsClient.Version.V3
|
||||
"${treatments.size} TRs from ${dateUtil.dateAndTimeAndSecondsString(nsClientV3Plugin.lastFetched.collections.treatments)}"
|
||||
)
|
||||
)
|
||||
// Schedule processing of fetched data and continue of loading
|
||||
|
@ -61,8 +59,7 @@ class LoadTreatmentsWorker(
|
|||
} else {
|
||||
rxBus.send(
|
||||
EventNSClientNewLog(
|
||||
"END", "No TRs from ${dateUtil.dateAndTimeAndSecondsString(nsClientV3Plugin.lastFetched.collections.treatments)}",
|
||||
NsClient.Version.V3
|
||||
"END", "No TRs from ${dateUtil.dateAndTimeAndSecondsString(nsClientV3Plugin.lastFetched.collections.treatments)}"
|
||||
)
|
||||
)
|
||||
storeDataForDb.storeTreatmentsToDb()
|
||||
|
@ -78,7 +75,7 @@ class LoadTreatmentsWorker(
|
|||
ret = Result.failure(workDataOf("Error" to error.toString()))
|
||||
}
|
||||
else {
|
||||
rxBus.send(EventNSClientNewLog("END", "No new TRs from ${dateUtil.dateAndTimeAndSecondsString(nsClientV3Plugin.lastFetched.collections.treatments)}", NsClient.Version.V3))
|
||||
rxBus.send(EventNSClientNewLog("END", "No new TRs from ${dateUtil.dateAndTimeAndSecondsString(nsClientV3Plugin.lastFetched.collections.treatments)}"))
|
||||
storeDataForDb.storeTreatmentsToDb()
|
||||
WorkManager.getInstance(context)
|
||||
.enqueueUniqueWork(
|
||||
|
|
|
@ -409,7 +409,6 @@
|
|||
<string name="virtual_pump_definition">Pump Definition</string>
|
||||
<string name="virtual_pump_pump_def">Bolus: Step=%1$s\nExtended Bolus: [Step=%2$s, Duration=%3$smin-%4$sh]\nBasal: Step=%5$s\nTBR: %6$s (by %7$s), Duration=%8$smin-%9$sh\n%10$s</string>
|
||||
|
||||
<string name="virtual_pump">Virtual Pump</string>
|
||||
<string name="virtual_pump_shortname">VPUMP</string>
|
||||
<string name="description_pump_virtual">Pump integration for pumps which don\'t have any driver yet (Open Loop)</string>
|
||||
<string name="virtual_pump_label">VIRTUAL PUMP</string>
|
||||
|
@ -537,7 +536,6 @@
|
|||
<string name="loop_aps_label">APS</string>
|
||||
<string name="request_label">Request</string>
|
||||
<string name="loop_constraints_processed_label">After processed constraints</string>
|
||||
<string name="constraints">Constraints</string>
|
||||
<string name="loop_tbr_request_time_label">Temp basal request time</string>
|
||||
<string name="loop_tbr_execution_time_label">Temp basal execution time</string>
|
||||
<string name="loop_tbr_set_by_pump_label">Temp basal set by pump</string>
|
||||
|
|
Loading…
Reference in a new issue