Merge branch 'dev' of https://github.com/MilosKozak/AndroidAPS into dev
This commit is contained in:
commit
ddc259648d
8 changed files with 76 additions and 34 deletions
|
@ -49,7 +49,8 @@ class HistoryBrowseActivity : NoSplashAppCompatActivity() {
|
||||||
@Inject lateinit var resourceHelper: ResourceHelper
|
@Inject lateinit var resourceHelper: ResourceHelper
|
||||||
@Inject lateinit var profileFunction: ProfileFunction
|
@Inject lateinit var profileFunction: ProfileFunction
|
||||||
@Inject lateinit var defaultValueHelper: DefaultValueHelper
|
@Inject lateinit var defaultValueHelper: DefaultValueHelper
|
||||||
@Inject lateinit var iobCobStaticCalculatorPlugin: IobCobStaticCalculatorPlugin
|
@Inject lateinit var iobCobCalculatorPluginHistory: IobCobCalculatorPluginHistory
|
||||||
|
@Inject lateinit var treatmentsPluginHistory: TreatmentsPluginHistory
|
||||||
@Inject lateinit var activePlugin: ActivePluginProvider
|
@Inject lateinit var activePlugin: ActivePluginProvider
|
||||||
@Inject lateinit var buildHelper: BuildHelper
|
@Inject lateinit var buildHelper: BuildHelper
|
||||||
@Inject lateinit var fabricPrivacy: FabricPrivacy
|
@Inject lateinit var fabricPrivacy: FabricPrivacy
|
||||||
|
@ -148,7 +149,7 @@ class HistoryBrowseActivity : NoSplashAppCompatActivity() {
|
||||||
public override fun onPause() {
|
public override fun onPause() {
|
||||||
super.onPause()
|
super.onPause()
|
||||||
disposable.clear()
|
disposable.clear()
|
||||||
iobCobStaticCalculatorPlugin.stopCalculation("onPause")
|
iobCobCalculatorPluginHistory.stopCalculation("onPause")
|
||||||
}
|
}
|
||||||
|
|
||||||
public override fun onResume() {
|
public override fun onResume() {
|
||||||
|
@ -157,7 +158,7 @@ class HistoryBrowseActivity : NoSplashAppCompatActivity() {
|
||||||
.toObservable(EventAutosensCalculationFinished::class.java)
|
.toObservable(EventAutosensCalculationFinished::class.java)
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.subscribe({ event: EventAutosensCalculationFinished ->
|
.subscribe({ event: EventAutosensCalculationFinished ->
|
||||||
// catch only events from iobCobStaticCalculatorPlugin
|
// catch only events from iobCobCalculatorPluginHistory
|
||||||
if (event.cause === eventCustomCalculationFinished) {
|
if (event.cause === eventCustomCalculationFinished) {
|
||||||
aapsLogger.debug(LTag.AUTOSENS, "EventAutosensCalculationFinished")
|
aapsLogger.debug(LTag.AUTOSENS, "EventAutosensCalculationFinished")
|
||||||
updateGUI("EventAutosensCalculationFinished")
|
updateGUI("EventAutosensCalculationFinished")
|
||||||
|
@ -220,10 +221,11 @@ class HistoryBrowseActivity : NoSplashAppCompatActivity() {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun runCalculation(from: String) {
|
private fun runCalculation(from: String) {
|
||||||
|
treatmentsPluginHistory.initializeData(start - T.hours(8).msecs())
|
||||||
val end = start + T.hours(rangeToDisplay.toLong()).msecs()
|
val end = start + T.hours(rangeToDisplay.toLong()).msecs()
|
||||||
iobCobStaticCalculatorPlugin.stopCalculation(from)
|
iobCobCalculatorPluginHistory.stopCalculation(from)
|
||||||
iobCobStaticCalculatorPlugin.clearCache()
|
iobCobCalculatorPluginHistory.clearCache()
|
||||||
iobCobStaticCalculatorPlugin.runCalculation(from, end, true, false, eventCustomCalculationFinished)
|
iobCobCalculatorPluginHistory.runCalculation(from, end, true, false, eventCustomCalculationFinished)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Synchronized
|
@Synchronized
|
||||||
|
@ -242,7 +244,7 @@ class HistoryBrowseActivity : NoSplashAppCompatActivity() {
|
||||||
|
|
||||||
GlobalScope.launch(Dispatchers.Main) {
|
GlobalScope.launch(Dispatchers.Main) {
|
||||||
historybrowse_bggraph ?: return@launch
|
historybrowse_bggraph ?: return@launch
|
||||||
val graphData = GraphData(injector, historybrowse_bggraph, iobCobStaticCalculatorPlugin)
|
val graphData = GraphData(injector, historybrowse_bggraph, iobCobCalculatorPluginHistory, treatmentsPluginHistory)
|
||||||
val secondaryGraphsData: ArrayList<GraphData> = ArrayList()
|
val secondaryGraphsData: ArrayList<GraphData> = ArrayList()
|
||||||
|
|
||||||
// do preparation in different thread
|
// do preparation in different thread
|
||||||
|
@ -279,7 +281,7 @@ class HistoryBrowseActivity : NoSplashAppCompatActivity() {
|
||||||
|
|
||||||
// ------------------ 2nd graph
|
// ------------------ 2nd graph
|
||||||
for (g in 0 until secondaryGraphs.size) {
|
for (g in 0 until secondaryGraphs.size) {
|
||||||
val secondGraphData = GraphData(injector, secondaryGraphs[g], iobCobStaticCalculatorPlugin)
|
val secondGraphData = GraphData(injector, secondaryGraphs[g], iobCobCalculatorPluginHistory, treatmentsPluginHistory)
|
||||||
var useIobForScale = false
|
var useIobForScale = false
|
||||||
var useCobForScale = false
|
var useCobForScale = false
|
||||||
var useDevForScale = false
|
var useDevForScale = false
|
||||||
|
|
|
@ -9,7 +9,6 @@ import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorP
|
||||||
import info.nightscout.androidaps.plugins.sensitivity.SensitivityAAPSPlugin
|
import info.nightscout.androidaps.plugins.sensitivity.SensitivityAAPSPlugin
|
||||||
import info.nightscout.androidaps.plugins.sensitivity.SensitivityOref1Plugin
|
import info.nightscout.androidaps.plugins.sensitivity.SensitivityOref1Plugin
|
||||||
import info.nightscout.androidaps.plugins.sensitivity.SensitivityWeightedAveragePlugin
|
import info.nightscout.androidaps.plugins.sensitivity.SensitivityWeightedAveragePlugin
|
||||||
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin
|
|
||||||
import info.nightscout.androidaps.utils.DateUtil
|
import info.nightscout.androidaps.utils.DateUtil
|
||||||
import info.nightscout.androidaps.utils.FabricPrivacy
|
import info.nightscout.androidaps.utils.FabricPrivacy
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
|
@ -18,7 +17,7 @@ import javax.inject.Inject
|
||||||
import javax.inject.Singleton
|
import javax.inject.Singleton
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
class IobCobStaticCalculatorPlugin @Inject constructor(
|
class IobCobCalculatorPluginHistory @Inject constructor(
|
||||||
injector: HasAndroidInjector,
|
injector: HasAndroidInjector,
|
||||||
aapsLogger: AAPSLogger,
|
aapsLogger: AAPSLogger,
|
||||||
rxBus: RxBusWrapper,
|
rxBus: RxBusWrapper,
|
||||||
|
@ -26,14 +25,14 @@ class IobCobStaticCalculatorPlugin @Inject constructor(
|
||||||
resourceHelper: ResourceHelper,
|
resourceHelper: ResourceHelper,
|
||||||
profileFunction: ProfileFunction,
|
profileFunction: ProfileFunction,
|
||||||
activePlugin: ActivePluginProvider,
|
activePlugin: ActivePluginProvider,
|
||||||
treatmentsPlugin: TreatmentsPlugin,
|
treatmentsPluginHistory: TreatmentsPluginHistory,
|
||||||
sensitivityOref1Plugin: SensitivityOref1Plugin,
|
sensitivityOref1Plugin: SensitivityOref1Plugin,
|
||||||
sensitivityAAPSPlugin: SensitivityAAPSPlugin,
|
sensitivityAAPSPlugin: SensitivityAAPSPlugin,
|
||||||
sensitivityWeightedAveragePlugin: SensitivityWeightedAveragePlugin,
|
sensitivityWeightedAveragePlugin: SensitivityWeightedAveragePlugin,
|
||||||
fabricPrivacy: FabricPrivacy,
|
fabricPrivacy: FabricPrivacy,
|
||||||
dateUtil: DateUtil
|
dateUtil: DateUtil
|
||||||
) : IobCobCalculatorPlugin(injector, aapsLogger, rxBus, sp, resourceHelper, profileFunction,
|
) : IobCobCalculatorPlugin(injector, aapsLogger, rxBus, sp, resourceHelper, profileFunction,
|
||||||
activePlugin, treatmentsPlugin, sensitivityOref1Plugin, sensitivityAAPSPlugin, sensitivityWeightedAveragePlugin, fabricPrivacy, dateUtil) {
|
activePlugin, treatmentsPluginHistory, sensitivityOref1Plugin, sensitivityAAPSPlugin, sensitivityWeightedAveragePlugin, fabricPrivacy, dateUtil) {
|
||||||
|
|
||||||
override fun onStart() { // do not attach to rxbus
|
override fun onStart() { // do not attach to rxbus
|
||||||
}
|
}
|
|
@ -0,0 +1,41 @@
|
||||||
|
package info.nightscout.androidaps.historyBrowser
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import dagger.android.HasAndroidInjector
|
||||||
|
import info.nightscout.androidaps.interfaces.ActivePluginProvider
|
||||||
|
import info.nightscout.androidaps.interfaces.ProfileFunction
|
||||||
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||||
|
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload
|
||||||
|
import info.nightscout.androidaps.plugins.treatments.TreatmentService
|
||||||
|
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin
|
||||||
|
import info.nightscout.androidaps.utils.DateUtil
|
||||||
|
import info.nightscout.androidaps.utils.FabricPrivacy
|
||||||
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
|
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
||||||
|
import javax.inject.Inject
|
||||||
|
import javax.inject.Singleton
|
||||||
|
|
||||||
|
@Singleton
|
||||||
|
class TreatmentsPluginHistory @Inject constructor(
|
||||||
|
injector: HasAndroidInjector,
|
||||||
|
aapsLogger: AAPSLogger,
|
||||||
|
rxBus: RxBusWrapper,
|
||||||
|
resourceHelper: ResourceHelper,
|
||||||
|
context: Context,
|
||||||
|
sp: SP,
|
||||||
|
profileFunction: ProfileFunction,
|
||||||
|
activePlugin: ActivePluginProvider,
|
||||||
|
nsUpload: NSUpload,
|
||||||
|
fabricPrivacy: FabricPrivacy, dateUtil: DateUtil
|
||||||
|
) : TreatmentsPlugin(injector, aapsLogger, rxBus, resourceHelper, context, sp, profileFunction, activePlugin, nsUpload, fabricPrivacy, dateUtil) {
|
||||||
|
|
||||||
|
init {
|
||||||
|
onStart()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onStart() {
|
||||||
|
service = TreatmentService(injector)
|
||||||
|
initializeData(range())
|
||||||
|
}
|
||||||
|
}
|
|
@ -18,9 +18,9 @@ import info.nightscout.androidaps.events.*
|
||||||
import info.nightscout.androidaps.historyBrowser.HistoryBrowseActivity
|
import info.nightscout.androidaps.historyBrowser.HistoryBrowseActivity
|
||||||
import info.nightscout.androidaps.interfaces.ActivePluginProvider
|
import info.nightscout.androidaps.interfaces.ActivePluginProvider
|
||||||
import info.nightscout.androidaps.interfaces.CommandQueueProvider
|
import info.nightscout.androidaps.interfaces.CommandQueueProvider
|
||||||
|
import info.nightscout.androidaps.interfaces.ProfileFunction
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||||
import info.nightscout.androidaps.interfaces.ProfileFunction
|
|
||||||
import info.nightscout.androidaps.plugins.general.actions.defs.CustomAction
|
import info.nightscout.androidaps.plugins.general.actions.defs.CustomAction
|
||||||
import info.nightscout.androidaps.plugins.general.overview.StatusLightHandler
|
import info.nightscout.androidaps.plugins.general.overview.StatusLightHandler
|
||||||
import info.nightscout.androidaps.queue.Callback
|
import info.nightscout.androidaps.queue.Callback
|
||||||
|
@ -192,17 +192,15 @@ class ActionsFragment : DaggerFragment() {
|
||||||
|
|
||||||
@Synchronized
|
@Synchronized
|
||||||
fun updateGui() {
|
fun updateGui() {
|
||||||
actions_profileswitch?.visibility = (activePlugin.activeProfileInterface.profile != null).toVisibility()
|
|
||||||
|
|
||||||
val profile = profileFunction.getProfile()
|
val profile = profileFunction.getProfile()
|
||||||
val pump = activePlugin.activePump
|
val pump = activePlugin.activePump
|
||||||
|
|
||||||
actions_temptarget?.visibility = (profile != null).toVisibility()
|
actions_profileswitch?.visibility = (
|
||||||
actions_historybrowser.visibility = (profile != null).toVisibility()
|
activePlugin.activeProfileInterface.profile != null &&
|
||||||
|
pump.pumpDescription.isSetBasalProfileCapable &&
|
||||||
val basalProfileEnabled = buildHelper.isEngineeringModeOrRelease() && pump.pumpDescription.isSetBasalProfileCapable
|
pump.isInitialized &&
|
||||||
|
!pump.isSuspended).toVisibility()
|
||||||
actions_profileswitch?.visibility = if (!basalProfileEnabled || !pump.isInitialized || pump.isSuspended) View.GONE else View.VISIBLE
|
|
||||||
|
|
||||||
if (!pump.pumpDescription.isExtendedBolusCapable || !pump.isInitialized || pump.isSuspended || pump.isFakingTempsByExtendedBoluses) {
|
if (!pump.pumpDescription.isExtendedBolusCapable || !pump.isInitialized || pump.isSuspended || pump.isFakingTempsByExtendedBoluses) {
|
||||||
actions_extendedbolus?.visibility = View.GONE
|
actions_extendedbolus?.visibility = View.GONE
|
||||||
|
@ -236,12 +234,11 @@ class ActionsFragment : DaggerFragment() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
actions_fill?.visibility =
|
actions_historybrowser.visibility = (profile != null).toVisibility()
|
||||||
if (!pump.pumpDescription.isRefillingCapable || !pump.isInitialized || pump.isSuspended) View.GONE
|
actions_fill?.visibility = (pump.pumpDescription.isRefillingCapable && pump.isInitialized && !pump.isSuspended).toVisibility()
|
||||||
else View.VISIBLE
|
actions_temptarget?.visibility = (profile != null && config.APS).toVisibility()
|
||||||
|
|
||||||
actions_temptarget?.visibility = config.APS.toVisibility()
|
|
||||||
actions_tddstats?.visibility = pump.pumpDescription.supportsTDDs.toVisibility()
|
actions_tddstats?.visibility = pump.pumpDescription.supportsTDDs.toVisibility()
|
||||||
|
|
||||||
statusLightHandler.updateStatusLights(careportal_canulaage, careportal_insulinage, null, careportal_sensorage, careportal_pbage, null)
|
statusLightHandler.updateStatusLights(careportal_canulaage, careportal_insulinage, null, careportal_sensorage, careportal_pbage, null)
|
||||||
checkPumpCustomActions()
|
checkPumpCustomActions()
|
||||||
}
|
}
|
||||||
|
|
|
@ -771,7 +771,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
|
||||||
// ****** GRAPH *******
|
// ****** GRAPH *******
|
||||||
GlobalScope.launch(Dispatchers.Main) {
|
GlobalScope.launch(Dispatchers.Main) {
|
||||||
overview_bggraph ?: return@launch
|
overview_bggraph ?: return@launch
|
||||||
val graphData = GraphData(injector, overview_bggraph, iobCobCalculatorPlugin)
|
val graphData = GraphData(injector, overview_bggraph, iobCobCalculatorPlugin, treatmentsPlugin)
|
||||||
val secondaryGraphsData: ArrayList<GraphData> = ArrayList()
|
val secondaryGraphsData: ArrayList<GraphData> = ArrayList()
|
||||||
|
|
||||||
// do preparation in different thread
|
// do preparation in different thread
|
||||||
|
@ -834,7 +834,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
|
||||||
|
|
||||||
// ------------------ 2nd graph
|
// ------------------ 2nd graph
|
||||||
for (g in 0 until secondaryGraphs.size) {
|
for (g in 0 until secondaryGraphs.size) {
|
||||||
val secondGraphData = GraphData(injector, secondaryGraphs[g], iobCobCalculatorPlugin)
|
val secondGraphData = GraphData(injector, secondaryGraphs[g], iobCobCalculatorPlugin, treatmentsPlugin)
|
||||||
var useIobForScale = false
|
var useIobForScale = false
|
||||||
var useCobForScale = false
|
var useCobForScale = false
|
||||||
var useDevForScale = false
|
var useDevForScale = false
|
||||||
|
|
|
@ -34,7 +34,13 @@ import kotlin.math.abs
|
||||||
import kotlin.math.max
|
import kotlin.math.max
|
||||||
import kotlin.math.min
|
import kotlin.math.min
|
||||||
|
|
||||||
class GraphData(injector: HasAndroidInjector, private val graph: GraphView, private val iobCobCalculatorPlugin: IobCobCalculatorPlugin) {
|
class GraphData(
|
||||||
|
injector: HasAndroidInjector,
|
||||||
|
private val graph: GraphView,
|
||||||
|
private val iobCobCalculatorPlugin: IobCobCalculatorPlugin,
|
||||||
|
private val treatmentsPlugin: TreatmentsInterface
|
||||||
|
|
||||||
|
) {
|
||||||
|
|
||||||
// IobCobCalculatorPlugin Cannot be injected: HistoryBrowser
|
// IobCobCalculatorPlugin Cannot be injected: HistoryBrowser
|
||||||
@Inject lateinit var aapsLogger: AAPSLogger
|
@Inject lateinit var aapsLogger: AAPSLogger
|
||||||
|
@ -42,8 +48,6 @@ class GraphData(injector: HasAndroidInjector, private val graph: GraphView, priv
|
||||||
@Inject lateinit var resourceHelper: ResourceHelper
|
@Inject lateinit var resourceHelper: ResourceHelper
|
||||||
@Inject lateinit var activePlugin: ActivePluginProvider
|
@Inject lateinit var activePlugin: ActivePluginProvider
|
||||||
|
|
||||||
private val treatmentsPlugin: TreatmentsInterface
|
|
||||||
|
|
||||||
var maxY = Double.MIN_VALUE
|
var maxY = Double.MIN_VALUE
|
||||||
private var minY = Double.MAX_VALUE
|
private var minY = Double.MAX_VALUE
|
||||||
private var bgReadingsArray: List<BgReading>? = null
|
private var bgReadingsArray: List<BgReading>? = null
|
||||||
|
@ -53,7 +57,6 @@ class GraphData(injector: HasAndroidInjector, private val graph: GraphView, priv
|
||||||
init {
|
init {
|
||||||
injector.androidInjector().inject(this)
|
injector.androidInjector().inject(this)
|
||||||
units = profileFunction.getUnits()
|
units = profileFunction.getUnits()
|
||||||
treatmentsPlugin = activePlugin.activeTreatments
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Suppress("UNUSED_PARAMETER")
|
@Suppress("UNUSED_PARAMETER")
|
||||||
|
|
|
@ -86,7 +86,7 @@ class ActionStringHandler @Inject constructor(
|
||||||
var rMessage = ""
|
var rMessage = ""
|
||||||
var rAction = ""
|
var rAction = ""
|
||||||
// do the parsing and check constraints
|
// do the parsing and check constraints
|
||||||
val act = actionString.split("\\s+").toTypedArray()
|
val act = actionString.split("\\s+".toRegex()).toTypedArray()
|
||||||
if ("fillpreset" == act[0]) { ///////////////////////////////////// PRIME/FILL
|
if ("fillpreset" == act[0]) { ///////////////////////////////////// PRIME/FILL
|
||||||
val amount: Double = if ("1" == act[1]) {
|
val amount: Double = if ("1" == act[1]) {
|
||||||
sp.getDouble("fill_button1", 0.3)
|
sp.getDouble("fill_button1", 0.3)
|
||||||
|
@ -470,7 +470,7 @@ class ActionStringHandler @Inject constructor(
|
||||||
if (System.currentTimeMillis() - lastSentTimestamp > TIMEOUT) return
|
if (System.currentTimeMillis() - lastSentTimestamp > TIMEOUT) return
|
||||||
lastConfirmActionString = null
|
lastConfirmActionString = null
|
||||||
// do the parsing, check constraints and enact!
|
// do the parsing, check constraints and enact!
|
||||||
val act = actionString.split("\\s+").toTypedArray()
|
val act = actionString.split("\\s+".toRegex()).toTypedArray()
|
||||||
if ("fill" == act[0]) {
|
if ("fill" == act[0]) {
|
||||||
val amount = SafeParse.stringToDouble(act[1])
|
val amount = SafeParse.stringToDouble(act[1])
|
||||||
val insulinAfterConstraints = constraintChecker.applyBolusConstraints(Constraint(amount)).value()
|
val insulinAfterConstraints = constraintChecker.applyBolusConstraints(Constraint(amount)).value()
|
||||||
|
|
|
@ -178,7 +178,7 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface
|
||||||
return this.service;
|
return this.service;
|
||||||
}
|
}
|
||||||
|
|
||||||
private long range() {
|
protected long range() {
|
||||||
double dia = Constants.defaultDIA;
|
double dia = Constants.defaultDIA;
|
||||||
if (profileFunction.getProfile() != null)
|
if (profileFunction.getProfile() != null)
|
||||||
dia = profileFunction.getProfile().getDia();
|
dia = profileFunction.getProfile().getDia();
|
||||||
|
|
Loading…
Reference in a new issue