Dana: remove core dependency
This commit is contained in:
parent
aee226ffa4
commit
97433c7ace
146 changed files with 1448 additions and 453 deletions
|
@ -5,8 +5,6 @@ import dagger.Component
|
|||
import dagger.android.AndroidInjectionModule
|
||||
import dagger.android.AndroidInjector
|
||||
import info.nightscout.androidaps.MainApp
|
||||
import info.nightscout.androidaps.dana.di.DanaHistoryModule
|
||||
import info.nightscout.androidaps.dana.di.DanaModule
|
||||
import info.nightscout.androidaps.danar.di.DanaRModule
|
||||
import info.nightscout.androidaps.danars.di.DanaRSModule
|
||||
import info.nightscout.androidaps.diaconn.di.DiaconnG8Module
|
||||
|
@ -28,6 +26,8 @@ import info.nightscout.plugins.aps.di.ApsModule
|
|||
import info.nightscout.plugins.di.PluginsModule
|
||||
import info.nightscout.pump.combo.di.ComboModule
|
||||
import info.nightscout.pump.combov2.di.ComboV2Module
|
||||
import info.nightscout.pump.dana.di.DanaHistoryModule
|
||||
import info.nightscout.pump.dana.di.DanaModule
|
||||
import info.nightscout.rx.di.RxModule
|
||||
import info.nightscout.shared.di.SharedModule
|
||||
import info.nightscout.shared.impl.di.SharedImplModule
|
||||
|
|
|
@ -8,7 +8,6 @@ import android.view.ViewGroup
|
|||
import androidx.core.text.toSpanned
|
||||
import dagger.android.support.DaggerFragment
|
||||
import info.nightscout.androidaps.R
|
||||
import info.nightscout.androidaps.dana.database.DanaHistoryDatabase
|
||||
import info.nightscout.androidaps.databinding.MaintenanceFragmentBinding
|
||||
import info.nightscout.androidaps.diaconn.database.DiaconnHistoryDatabase
|
||||
import info.nightscout.androidaps.insight.database.InsightDatabase
|
||||
|
@ -29,6 +28,7 @@ import info.nightscout.interfaces.protection.ProtectionCheck.Protection.PREFEREN
|
|||
import info.nightscout.interfaces.pump.PumpSync
|
||||
import info.nightscout.interfaces.sync.DataSyncSelector
|
||||
import info.nightscout.interfaces.utils.HtmlHelper
|
||||
import info.nightscout.pump.dana.database.DanaHistoryDatabase
|
||||
import info.nightscout.rx.AapsSchedulers
|
||||
import info.nightscout.rx.bus.RxBus
|
||||
import info.nightscout.rx.events.EventPreferenceChange
|
||||
|
|
|
@ -30,7 +30,6 @@ import dagger.android.support.DaggerFragment
|
|||
import info.nightscout.androidaps.R
|
||||
import info.nightscout.androidaps.extensions.directionToIcon
|
||||
import info.nightscout.androidaps.extensions.valueToUnitsString
|
||||
import info.nightscout.interfaces.logging.UserEntryLogger
|
||||
import info.nightscout.androidaps.plugins.general.overview.activities.QuickWizardListActivity
|
||||
import info.nightscout.androidaps.plugins.general.overview.events.EventUpdateOverviewCalcProgress
|
||||
import info.nightscout.androidaps.plugins.general.overview.events.EventUpdateOverviewGraph
|
||||
|
@ -60,6 +59,7 @@ import info.nightscout.interfaces.aps.Loop
|
|||
import info.nightscout.interfaces.constraints.Constraint
|
||||
import info.nightscout.interfaces.constraints.Constraints
|
||||
import info.nightscout.interfaces.iob.IobCobCalculator
|
||||
import info.nightscout.interfaces.logging.UserEntryLogger
|
||||
import info.nightscout.interfaces.plugin.ActivePlugin
|
||||
import info.nightscout.interfaces.plugin.PluginBase
|
||||
import info.nightscout.interfaces.profile.DefaultValueHelper
|
||||
|
@ -621,7 +621,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
|
|||
it.layoutParams = LinearLayout.LayoutParams(0, ViewGroup.LayoutParams.MATCH_PARENT, 0.5f).also { l ->
|
||||
l.setMargins(0, 0, rh.dpToPx(-4), 0)
|
||||
}
|
||||
it.setCompoundDrawablesWithIntrinsicBounds(null, rh.gd(R.drawable.ic_danar_useropt), null, null)
|
||||
it.setCompoundDrawablesWithIntrinsicBounds(null, rh.gd(R.drawable.ic_user_options), null, null)
|
||||
it.text = event.title
|
||||
|
||||
it.setOnClickListener {
|
||||
|
|
|
@ -5,10 +5,10 @@ import dagger.android.AndroidInjector
|
|||
import dagger.android.HasAndroidInjector
|
||||
import info.nightscout.androidaps.extensions.pureProfileFromJson
|
||||
import info.nightscout.core.profile.ProfileSealed
|
||||
import info.nightscout.core.profile.ProfileStoreObject
|
||||
import info.nightscout.core.utils.fabric.FabricPrivacy
|
||||
import info.nightscout.database.entities.EffectiveProfileSwitch
|
||||
import info.nightscout.database.entities.embedments.InsulinConfiguration
|
||||
import info.nightscout.implementation.profile.ProfileStoreObject
|
||||
import info.nightscout.interfaces.Config
|
||||
import info.nightscout.interfaces.iob.IobCobCalculator
|
||||
import info.nightscout.interfaces.plugin.ActivePlugin
|
||||
|
|
|
@ -5,7 +5,6 @@ import dagger.android.HasAndroidInjector
|
|||
import info.nightscout.androidaps.HardLimitsMock
|
||||
import info.nightscout.androidaps.R
|
||||
import info.nightscout.androidaps.TestBaseWithProfile
|
||||
import info.nightscout.androidaps.dana.DanaPump
|
||||
import info.nightscout.androidaps.danar.DanaRPlugin
|
||||
import info.nightscout.androidaps.danars.DanaRSPlugin
|
||||
import info.nightscout.androidaps.implementations.ConfigImpl
|
||||
|
@ -22,6 +21,7 @@ import info.nightscout.interfaces.maintenance.PrefFileListProvider
|
|||
import info.nightscout.interfaces.plugin.ActivePlugin
|
||||
import info.nightscout.interfaces.plugin.PluginBase
|
||||
import info.nightscout.interfaces.plugin.PluginType
|
||||
import info.nightscout.interfaces.profile.ProfileInstantiator
|
||||
import info.nightscout.interfaces.profiling.Profiler
|
||||
import info.nightscout.interfaces.pump.DetailedBolusInfoStorage
|
||||
import info.nightscout.interfaces.pump.PumpEnactResult
|
||||
|
@ -31,6 +31,9 @@ import info.nightscout.interfaces.pump.defs.PumpDescription
|
|||
import info.nightscout.interfaces.queue.CommandQueue
|
||||
import info.nightscout.interfaces.ui.ActivityNames
|
||||
import info.nightscout.interfaces.utils.HardLimits
|
||||
import info.nightscout.plugins.aps.openAPSAMA.OpenAPSAMAPlugin
|
||||
import info.nightscout.plugins.aps.openAPSSMB.OpenAPSSMBPlugin
|
||||
import info.nightscout.plugins.aps.openAPSSMBDynamicISF.OpenAPSSMBDynamicISFPlugin
|
||||
import info.nightscout.plugins.constraints.objectives.ObjectivesPlugin
|
||||
import info.nightscout.plugins.constraints.objectives.objectives.Objective
|
||||
import info.nightscout.plugins.constraints.safety.SafetyPlugin
|
||||
|
@ -38,6 +41,7 @@ import info.nightscout.plugins.pump.virtual.VirtualPumpPlugin
|
|||
import info.nightscout.plugins.source.GlimpPlugin
|
||||
import info.nightscout.pump.combo.ComboPlugin
|
||||
import info.nightscout.pump.combo.ruffyscripter.RuffyScripter
|
||||
import info.nightscout.pump.dana.DanaPump
|
||||
import info.nightscout.shared.sharedPreferences.SP
|
||||
import org.junit.Assert
|
||||
import org.junit.Before
|
||||
|
@ -64,6 +68,7 @@ class ConstraintsCheckerTest : TestBaseWithProfile() {
|
|||
@Mock lateinit var insightDatabaseDao: InsightDatabaseDao
|
||||
@Mock lateinit var ruffyScripter: RuffyScripter
|
||||
@Mock lateinit var activityNames: ActivityNames
|
||||
@Mock lateinit var profileInstantiator: ProfileInstantiator
|
||||
|
||||
private lateinit var hardLimits: HardLimits
|
||||
private lateinit var danaPump: DanaPump
|
||||
|
@ -75,9 +80,9 @@ class ConstraintsCheckerTest : TestBaseWithProfile() {
|
|||
private lateinit var danaRPlugin: DanaRPlugin
|
||||
private lateinit var danaRSPlugin: DanaRSPlugin
|
||||
private lateinit var insightPlugin: LocalInsightPlugin
|
||||
private lateinit var openAPSSMBPlugin: info.nightscout.plugins.aps.openAPSSMB.OpenAPSSMBPlugin
|
||||
private lateinit var openAPSAMAPlugin: info.nightscout.plugins.aps.openAPSAMA.OpenAPSAMAPlugin
|
||||
private lateinit var openAPSSMBDynamicISFPlugin: info.nightscout.plugins.aps.openAPSSMBDynamicISF.OpenAPSSMBDynamicISFPlugin
|
||||
private lateinit var openAPSSMBPlugin: OpenAPSSMBPlugin
|
||||
private lateinit var openAPSAMAPlugin: OpenAPSAMAPlugin
|
||||
private lateinit var openAPSSMBDynamicISFPlugin: OpenAPSSMBDynamicISFPlugin
|
||||
|
||||
private val injector = HasAndroidInjector {
|
||||
AndroidInjector {
|
||||
|
@ -132,7 +137,7 @@ class ConstraintsCheckerTest : TestBaseWithProfile() {
|
|||
|
||||
hardLimits = HardLimitsMock(sp, rh)
|
||||
insightDbHelper = InsightDbHelper(insightDatabaseDao)
|
||||
danaPump = DanaPump(aapsLogger, sp, dateUtil, injector)
|
||||
danaPump = DanaPump(aapsLogger, sp, dateUtil, profileInstantiator)
|
||||
objectivesPlugin = ObjectivesPlugin(injector, aapsLogger, rh, activePlugin, sp, config)
|
||||
comboPlugin = ComboPlugin(injector, aapsLogger, rxBus, rh, profileFunction, sp, commandQueue, pumpSync, dateUtil, ruffyScripter, activityNames)
|
||||
danaRPlugin = DanaRPlugin(injector, aapsLogger, aapsSchedulers, rxBus, context, rh, constraintChecker, activePlugin, sp, commandQueue, danaPump, dateUtil, fabricPrivacy, pumpSync)
|
||||
|
|
|
@ -157,7 +157,7 @@ class UserEntryPresentationHelper @Inject constructor(
|
|||
csvString(R.string.date),
|
||||
csvString(R.string.ue_utc_offset),
|
||||
csvString(R.string.ue_action),
|
||||
csvString(R.string.eventtype),
|
||||
csvString(R.string.event_type),
|
||||
csvString(R.string.ue_source),
|
||||
csvString(R.string.careportal_note),
|
||||
csvString(R.string.ue_string),
|
||||
|
|
|
@ -4,7 +4,6 @@ import dagger.Module
|
|||
import dagger.android.ContributesAndroidInjector
|
||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.data.AutosensDataObject
|
||||
import info.nightscout.core.aps.APSResultObject
|
||||
import info.nightscout.core.profile.ProfileStoreObject
|
||||
import info.nightscout.core.wizard.BolusWizard
|
||||
import info.nightscout.core.wizard.QuickWizardEntry
|
||||
import info.nightscout.interfaces.pump.PumpEnactResult
|
||||
|
@ -16,7 +15,6 @@ abstract class CoreDataClassesModule {
|
|||
@ContributesAndroidInjector abstract fun pumpEnactResultInjector(): PumpEnactResult
|
||||
@ContributesAndroidInjector abstract fun apsResultInjector(): APSResultObject
|
||||
@ContributesAndroidInjector abstract fun autosensDataInjector(): AutosensDataObject
|
||||
@ContributesAndroidInjector abstract fun profileStoreInjector(): ProfileStoreObject
|
||||
@ContributesAndroidInjector abstract fun bolusWizardInjector(): BolusWizard
|
||||
@ContributesAndroidInjector abstract fun quickWizardEntryInjector(): QuickWizardEntry
|
||||
}
|
||||
|
|
|
@ -1,106 +1,2 @@
|
|||
package info.nightscout.core.profile
|
||||
|
||||
import androidx.collection.ArrayMap
|
||||
import dagger.android.HasAndroidInjector
|
||||
import info.nightscout.androidaps.extensions.pureProfileFromJson
|
||||
import info.nightscout.interfaces.Config
|
||||
import info.nightscout.interfaces.plugin.ActivePlugin
|
||||
import info.nightscout.interfaces.profile.ProfileStore
|
||||
import info.nightscout.interfaces.profile.PureProfile
|
||||
import info.nightscout.interfaces.utils.HardLimits
|
||||
import info.nightscout.interfaces.utils.JsonHelper
|
||||
import info.nightscout.rx.bus.RxBus
|
||||
import info.nightscout.rx.logging.AAPSLogger
|
||||
import info.nightscout.shared.interfaces.ResourceHelper
|
||||
import info.nightscout.shared.utils.DateUtil
|
||||
import org.json.JSONException
|
||||
import org.json.JSONObject
|
||||
import javax.inject.Inject
|
||||
|
||||
class ProfileStoreObject(val injector: HasAndroidInjector, override val data: JSONObject, val dateUtil: DateUtil) : ProfileStore {
|
||||
|
||||
@Inject lateinit var aapsLogger: AAPSLogger
|
||||
@Inject lateinit var activePlugin: ActivePlugin
|
||||
@Inject lateinit var config: Config
|
||||
@Inject lateinit var rh: ResourceHelper
|
||||
@Inject lateinit var rxBus: RxBus
|
||||
@Inject lateinit var hardLimits: HardLimits
|
||||
|
||||
init {
|
||||
injector.androidInjector().inject(this)
|
||||
}
|
||||
|
||||
private val cachedObjects = ArrayMap<String, PureProfile>()
|
||||
|
||||
private fun storeUnits(): String? = JsonHelper.safeGetStringAllowNull(data, "units", null)
|
||||
|
||||
private fun getStore(): JSONObject? {
|
||||
try {
|
||||
if (data.has("store")) return data.getJSONObject("store")
|
||||
} catch (e: JSONException) {
|
||||
aapsLogger.error("Unhandled exception", e)
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
override fun getStartDate(): Long {
|
||||
val iso = JsonHelper.safeGetString(data, "startDate") ?: return 0
|
||||
return try {
|
||||
dateUtil.fromISODateString(iso)
|
||||
} catch (e: Exception) {
|
||||
0
|
||||
}
|
||||
}
|
||||
|
||||
override fun getDefaultProfile(): PureProfile? = getDefaultProfileName()?.let { getSpecificProfile(it) }
|
||||
override fun getDefaultProfileJson(): JSONObject? = getDefaultProfileName()?.let { getSpecificProfileJson(it) }
|
||||
|
||||
override fun getDefaultProfileName(): String? {
|
||||
val defaultProfileName = data.optString("defaultProfile")
|
||||
return if (defaultProfileName.isNotEmpty()) getStore()?.has(defaultProfileName)?.let { defaultProfileName } else null
|
||||
}
|
||||
|
||||
override fun getProfileList(): ArrayList<CharSequence> {
|
||||
val ret = ArrayList<CharSequence>()
|
||||
getStore()?.keys()?.let { keys ->
|
||||
while (keys.hasNext()) {
|
||||
val profileName = keys.next() as String
|
||||
ret.add(profileName)
|
||||
}
|
||||
}
|
||||
return ret
|
||||
}
|
||||
|
||||
@Synchronized
|
||||
override fun getSpecificProfile(profileName: String): PureProfile? {
|
||||
var profile: PureProfile? = null
|
||||
val units = JsonHelper.safeGetStringAllowNull(data, "units", storeUnits())
|
||||
getStore()?.let { store ->
|
||||
if (store.has(profileName)) {
|
||||
profile = cachedObjects[profileName]
|
||||
if (profile == null) {
|
||||
JsonHelper.safeGetJSONObject(store, profileName, null)?.let { profileObject ->
|
||||
profile = pureProfileFromJson(profileObject, dateUtil, units)
|
||||
profile?.let { cachedObjects[profileName] = profile }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return profile
|
||||
}
|
||||
|
||||
private fun getSpecificProfileJson(profileName: String): JSONObject? {
|
||||
getStore()?.let { store ->
|
||||
if (store.has(profileName))
|
||||
return JsonHelper.safeGetJSONObject(store, profileName, null)
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
override val allProfilesValid: Boolean
|
||||
get() = getProfileList()
|
||||
.asSequence()
|
||||
.map { profileName -> getSpecificProfile(profileName.toString()) }
|
||||
.map { pureProfile -> pureProfile?.let { ProfileSealed.Pure(pureProfile).isValid("allProfilesValid", activePlugin.activePump, config, rh, rxBus, hardLimits, false) } }
|
||||
.all { it?.isValid == true }
|
||||
}
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
<string name="androidaps_start">AAPS started</string>
|
||||
<string name="formatsignedinsulinunits">%1$+.2f U</string>
|
||||
<string name="format_carbs">%1$d g</string>
|
||||
<string name="reservoirvalue">%1$.0f / %2$d U</string>
|
||||
<string name="format_hours">%1$.2f h</string>
|
||||
<string name="format_mins">%1$d mins</string>
|
||||
<string name="pumpbusy">Pump is busy</string>
|
||||
|
@ -17,7 +16,6 @@
|
|||
<string name="objectives">Objectives</string>
|
||||
<string name="please_wait">Please wait…</string>
|
||||
<string name="mute">Mute</string>
|
||||
<string name="reload">Reload</string>
|
||||
<string name="stop">Stop</string>
|
||||
<string name="carbs">Carbs</string>
|
||||
<string name="invalid_profile">Invalid profile!</string>
|
||||
|
@ -36,12 +34,6 @@
|
|||
<string name="basal_long_label">Basal rate</string>
|
||||
<string name="target_long_label">Blood Glucose Target</string>
|
||||
<string name="initializing">Initializing ...</string>
|
||||
<string name="dailyunits">Daily units</string>
|
||||
<string name="pumphistory">Pump history</string>
|
||||
<string name="viewprofile">View profile</string>
|
||||
<string name="eventtype">Event type</string>
|
||||
<string name="mgdl">mg/dl</string>
|
||||
<string name="mmol">mmol/l</string>
|
||||
<string name="shortgram">g</string>
|
||||
<string name="shortpercent">%</string>
|
||||
<string name="advancedsettings_title">Advanced Settings</string>
|
||||
|
@ -228,7 +220,6 @@
|
|||
<string name="ns">NS</string>
|
||||
<string name="record">Record</string>
|
||||
<string name="reading_pump_history">Reading pump history</string>
|
||||
<string name="pump_icon">Pump icon</string>
|
||||
|
||||
<!-- Command-->
|
||||
<string name="connectiontimedout">Connection timed out</string>
|
||||
|
@ -247,7 +238,6 @@
|
|||
<string name="carbsreq">%1$d g additional carbs required within %2$d minutes</string>
|
||||
|
||||
<!-- TDDStatsActivity-->
|
||||
<string name="stats">Stats</string>
|
||||
<string name="cumulative_tdd">Cumulative TDD</string>
|
||||
<string name="expweight">Exponentially Weighted TDD</string>
|
||||
<string name="basalrate">Basal</string>
|
||||
|
@ -436,7 +426,6 @@
|
|||
<string name="keepalive_status_outdated" comment="26 characters max for translation">KeepAlive. Status outdated.</string>
|
||||
<string name="keepalive_basal_outdated" comment="26 characters max for translation">KeepAlive. Basal outdated.</string>
|
||||
<string name="sms" comment="26 characters max for translation">SMS</string>
|
||||
<string name="clicked_connect_to_pump" comment="26 characters max for translation">Clicked connect to pump</string>
|
||||
<string name="pump_driver_change" comment="26 characters max for translation">Pump driver change.</string>
|
||||
<string name="device_changed" comment="26 characters max for translation">Device changed</string>
|
||||
<string name="clicked_refresh" comment="26 characters max for translation">Clicked refresh</string>
|
||||
|
|
|
@ -0,0 +1,107 @@
|
|||
package info.nightscout.androidaps
|
||||
|
||||
import androidx.collection.ArrayMap
|
||||
import dagger.android.HasAndroidInjector
|
||||
import info.nightscout.androidaps.extensions.pureProfileFromJson
|
||||
import info.nightscout.core.profile.ProfileSealed
|
||||
import info.nightscout.interfaces.Config
|
||||
import info.nightscout.interfaces.plugin.ActivePlugin
|
||||
import info.nightscout.interfaces.profile.ProfileStore
|
||||
import info.nightscout.interfaces.profile.PureProfile
|
||||
import info.nightscout.interfaces.utils.HardLimits
|
||||
import info.nightscout.interfaces.utils.JsonHelper
|
||||
import info.nightscout.rx.bus.RxBus
|
||||
import info.nightscout.rx.logging.AAPSLogger
|
||||
import info.nightscout.shared.interfaces.ResourceHelper
|
||||
import info.nightscout.shared.utils.DateUtil
|
||||
import org.json.JSONException
|
||||
import org.json.JSONObject
|
||||
import javax.inject.Inject
|
||||
|
||||
class ProfileStoreObject(val injector: HasAndroidInjector, override val data: JSONObject, val dateUtil: DateUtil) : ProfileStore {
|
||||
|
||||
@Inject lateinit var aapsLogger: AAPSLogger
|
||||
@Inject lateinit var activePlugin: ActivePlugin
|
||||
@Inject lateinit var config: Config
|
||||
@Inject lateinit var rh: ResourceHelper
|
||||
@Inject lateinit var rxBus: RxBus
|
||||
@Inject lateinit var hardLimits: HardLimits
|
||||
|
||||
init {
|
||||
injector.androidInjector().inject(this)
|
||||
}
|
||||
|
||||
private val cachedObjects = ArrayMap<String, PureProfile>()
|
||||
|
||||
private fun storeUnits(): String? = JsonHelper.safeGetStringAllowNull(data, "units", null)
|
||||
|
||||
private fun getStore(): JSONObject? {
|
||||
try {
|
||||
if (data.has("store")) return data.getJSONObject("store")
|
||||
} catch (e: JSONException) {
|
||||
aapsLogger.error("Unhandled exception", e)
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
override fun getStartDate(): Long {
|
||||
val iso = JsonHelper.safeGetString(data, "startDate") ?: return 0
|
||||
return try {
|
||||
dateUtil.fromISODateString(iso)
|
||||
} catch (e: Exception) {
|
||||
0
|
||||
}
|
||||
}
|
||||
|
||||
override fun getDefaultProfile(): PureProfile? = getDefaultProfileName()?.let { getSpecificProfile(it) }
|
||||
override fun getDefaultProfileJson(): JSONObject? = getDefaultProfileName()?.let { getSpecificProfileJson(it) }
|
||||
|
||||
override fun getDefaultProfileName(): String? {
|
||||
val defaultProfileName = data.optString("defaultProfile")
|
||||
return if (defaultProfileName.isNotEmpty()) getStore()?.has(defaultProfileName)?.let { defaultProfileName } else null
|
||||
}
|
||||
|
||||
override fun getProfileList(): ArrayList<CharSequence> {
|
||||
val ret = ArrayList<CharSequence>()
|
||||
getStore()?.keys()?.let { keys ->
|
||||
while (keys.hasNext()) {
|
||||
val profileName = keys.next() as String
|
||||
ret.add(profileName)
|
||||
}
|
||||
}
|
||||
return ret
|
||||
}
|
||||
|
||||
@Synchronized
|
||||
override fun getSpecificProfile(profileName: String): PureProfile? {
|
||||
var profile: PureProfile? = null
|
||||
val units = JsonHelper.safeGetStringAllowNull(data, "units", storeUnits())
|
||||
getStore()?.let { store ->
|
||||
if (store.has(profileName)) {
|
||||
profile = cachedObjects[profileName]
|
||||
if (profile == null) {
|
||||
JsonHelper.safeGetJSONObject(store, profileName, null)?.let { profileObject ->
|
||||
profile = pureProfileFromJson(profileObject, dateUtil, units)
|
||||
profile?.let { cachedObjects[profileName] = profile }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return profile
|
||||
}
|
||||
|
||||
private fun getSpecificProfileJson(profileName: String): JSONObject? {
|
||||
getStore()?.let { store ->
|
||||
if (store.has(profileName))
|
||||
return JsonHelper.safeGetJSONObject(store, profileName, null)
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
override val allProfilesValid: Boolean
|
||||
get() = getProfileList()
|
||||
.asSequence()
|
||||
.map { profileName -> getSpecificProfile(profileName.toString()) }
|
||||
.map { pureProfile -> pureProfile?.let { ProfileSealed.Pure(pureProfile).isValid("allProfilesValid", activePlugin.activePump, config, rh, rxBus, hardLimits, false) } }
|
||||
.all { it?.isValid == true }
|
||||
}
|
|
@ -5,7 +5,6 @@ import dagger.android.AndroidInjector
|
|||
import dagger.android.HasAndroidInjector
|
||||
import info.nightscout.androidaps.extensions.pureProfileFromJson
|
||||
import info.nightscout.core.profile.ProfileSealed
|
||||
import info.nightscout.core.profile.ProfileStoreObject
|
||||
import info.nightscout.interfaces.Config
|
||||
import info.nightscout.interfaces.plugin.ActivePlugin
|
||||
import info.nightscout.interfaces.profile.DefaultValueHelper
|
||||
|
|
|
@ -95,6 +95,7 @@ public class PointsWithLabelGraphSeries<E extends DataPointWithLabelInterface> e
|
|||
* @param canvas canvas to draw on
|
||||
* @param isSecondScale whether it is the second scale
|
||||
*/
|
||||
@SuppressWarnings({"deprecation"})
|
||||
@Override
|
||||
public void draw(GraphView graphView, Canvas canvas, boolean isSecondScale) {
|
||||
// Convert the sp to pixels
|
||||
|
|
|
@ -18,6 +18,10 @@
|
|||
<string name="no_valid_basal_rate">No valid basal rate read from pump</string>
|
||||
<string name="limiting_iob">Limiting IOB to %1$.1f U because of %2$s</string>
|
||||
<string name="loop_disabled">LOOP DISABLED BY CONSTRAINTS</string>
|
||||
<string name="event_type">Event type</string>
|
||||
<string name="reload">Reload</string>
|
||||
<string name="mgdl">mg/dl</string>
|
||||
<string name="mmol">mmol/l</string>
|
||||
|
||||
<!-- PumpFragments-->
|
||||
<string name="battery_label">Battery</string>
|
||||
|
@ -30,6 +34,13 @@
|
|||
<string name="serial_number">Serial number</string>
|
||||
<string name="disconnected">Disconnected</string>
|
||||
<string name="connecting">Connecting</string>
|
||||
<string name="clicked_connect_to_pump" comment="26 characters max for translation">Clicked connect to pump</string>
|
||||
<string name="reservoir_value">%1$.0f / %2$d U</string>
|
||||
<string name="daily_units">Daily units</string>
|
||||
<string name="pump_icon">Pump icon</string>
|
||||
<string name="view_profile">View profile</string>
|
||||
<string name="pump_history">Pump history</string>
|
||||
<string name="stats">Stats</string>
|
||||
|
||||
<!-- Locale -->
|
||||
<string name="key_language" translatable="false">language</string>
|
||||
|
|
|
@ -2,6 +2,7 @@ package info.nightscout.implementation.di
|
|||
|
||||
import dagger.Binds
|
||||
import dagger.Module
|
||||
import dagger.android.ContributesAndroidInjector
|
||||
import info.nightscout.core.graph.OverviewData
|
||||
import info.nightscout.implementation.AndroidPermissionImpl
|
||||
import info.nightscout.implementation.BolusTimerImpl
|
||||
|
@ -19,6 +20,8 @@ import info.nightscout.implementation.logging.LoggerUtilsImpl
|
|||
import info.nightscout.implementation.maintenance.PrefFileListProviderImpl
|
||||
import info.nightscout.implementation.overview.OverviewDataImpl
|
||||
import info.nightscout.implementation.plugin.PluginStore
|
||||
import info.nightscout.implementation.profile.ProfileInstantiatorImpl
|
||||
import info.nightscout.implementation.profile.ProfileStoreObject
|
||||
import info.nightscout.implementation.profiling.ProfilerImpl
|
||||
import info.nightscout.implementation.protection.PasswordCheckImpl
|
||||
import info.nightscout.implementation.protection.ProtectionCheckImpl
|
||||
|
@ -45,6 +48,7 @@ import info.nightscout.interfaces.logging.UserEntryLogger
|
|||
import info.nightscout.interfaces.maintenance.PrefFileListProvider
|
||||
import info.nightscout.interfaces.plugin.ActivePlugin
|
||||
import info.nightscout.interfaces.profile.DefaultValueHelper
|
||||
import info.nightscout.interfaces.profile.ProfileInstantiator
|
||||
import info.nightscout.interfaces.profiling.Profiler
|
||||
import info.nightscout.interfaces.protection.PasswordCheck
|
||||
import info.nightscout.interfaces.protection.ProtectionCheck
|
||||
|
@ -68,7 +72,9 @@ import info.nightscout.shared.interfaces.ResourceHelper
|
|||
)
|
||||
|
||||
@Suppress("unused")
|
||||
open class ImplementationModule {
|
||||
abstract class ImplementationModule {
|
||||
|
||||
@ContributesAndroidInjector abstract fun profileStoreInjector(): ProfileStoreObject
|
||||
|
||||
@Module
|
||||
interface Bindings {
|
||||
|
@ -88,6 +94,7 @@ open class ImplementationModule {
|
|||
@Binds fun bindWarnColors(warnColorsImpl: WarnColorsImpl): WarnColors
|
||||
@Binds fun bindHardLimits(hardLimitsImpl: HardLimitsImpl): HardLimits
|
||||
@Binds fun bindResourceHelper(resourceHelperImpl: ResourceHelperImpl): ResourceHelper
|
||||
@Binds fun bindProfileStoreInstantiator(profileStoreInstantiatorImpl: ProfileInstantiatorImpl): ProfileInstantiator
|
||||
|
||||
@Binds fun bindTrendCalculatorInterface(trendCalculator: TrendCalculatorImpl): TrendCalculator
|
||||
@Binds fun bindTddCalculatorInterface(tddCalculator: TddCalculatorImpl): TddCalculator
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
package info.nightscout.implementation.profile
|
||||
|
||||
import dagger.android.HasAndroidInjector
|
||||
import info.nightscout.interfaces.profile.ProfileInstantiator
|
||||
import info.nightscout.interfaces.profile.ProfileStore
|
||||
import info.nightscout.shared.utils.DateUtil
|
||||
import org.json.JSONObject
|
||||
import javax.inject.Inject
|
||||
|
||||
class ProfileInstantiatorImpl @Inject constructor(
|
||||
private val injector: HasAndroidInjector,
|
||||
private val dateUtil: DateUtil
|
||||
): ProfileInstantiator {
|
||||
|
||||
override fun storeInstance(jsonObject: JSONObject): ProfileStore =
|
||||
ProfileStoreObject(injector, jsonObject, dateUtil)
|
||||
}
|
|
@ -0,0 +1,107 @@
|
|||
package info.nightscout.implementation.profile
|
||||
|
||||
import androidx.collection.ArrayMap
|
||||
import dagger.android.HasAndroidInjector
|
||||
import info.nightscout.androidaps.extensions.pureProfileFromJson
|
||||
import info.nightscout.core.profile.ProfileSealed
|
||||
import info.nightscout.interfaces.Config
|
||||
import info.nightscout.interfaces.plugin.ActivePlugin
|
||||
import info.nightscout.interfaces.profile.ProfileStore
|
||||
import info.nightscout.interfaces.profile.PureProfile
|
||||
import info.nightscout.interfaces.utils.HardLimits
|
||||
import info.nightscout.interfaces.utils.JsonHelper
|
||||
import info.nightscout.rx.bus.RxBus
|
||||
import info.nightscout.rx.logging.AAPSLogger
|
||||
import info.nightscout.shared.interfaces.ResourceHelper
|
||||
import info.nightscout.shared.utils.DateUtil
|
||||
import org.json.JSONException
|
||||
import org.json.JSONObject
|
||||
import javax.inject.Inject
|
||||
|
||||
class ProfileStoreObject(val injector: HasAndroidInjector, override val data: JSONObject, val dateUtil: DateUtil) : ProfileStore {
|
||||
|
||||
@Inject lateinit var aapsLogger: AAPSLogger
|
||||
@Inject lateinit var activePlugin: ActivePlugin
|
||||
@Inject lateinit var config: Config
|
||||
@Inject lateinit var rh: ResourceHelper
|
||||
@Inject lateinit var rxBus: RxBus
|
||||
@Inject lateinit var hardLimits: HardLimits
|
||||
|
||||
init {
|
||||
injector.androidInjector().inject(this)
|
||||
}
|
||||
|
||||
private val cachedObjects = ArrayMap<String, PureProfile>()
|
||||
|
||||
private fun storeUnits(): String? = JsonHelper.safeGetStringAllowNull(data, "units", null)
|
||||
|
||||
private fun getStore(): JSONObject? {
|
||||
try {
|
||||
if (data.has("store")) return data.getJSONObject("store")
|
||||
} catch (e: JSONException) {
|
||||
aapsLogger.error("Unhandled exception", e)
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
override fun getStartDate(): Long {
|
||||
val iso = JsonHelper.safeGetString(data, "startDate") ?: return 0
|
||||
return try {
|
||||
dateUtil.fromISODateString(iso)
|
||||
} catch (e: Exception) {
|
||||
0
|
||||
}
|
||||
}
|
||||
|
||||
override fun getDefaultProfile(): PureProfile? = getDefaultProfileName()?.let { getSpecificProfile(it) }
|
||||
override fun getDefaultProfileJson(): JSONObject? = getDefaultProfileName()?.let { getSpecificProfileJson(it) }
|
||||
|
||||
override fun getDefaultProfileName(): String? {
|
||||
val defaultProfileName = data.optString("defaultProfile")
|
||||
return if (defaultProfileName.isNotEmpty()) getStore()?.has(defaultProfileName)?.let { defaultProfileName } else null
|
||||
}
|
||||
|
||||
override fun getProfileList(): ArrayList<CharSequence> {
|
||||
val ret = ArrayList<CharSequence>()
|
||||
getStore()?.keys()?.let { keys ->
|
||||
while (keys.hasNext()) {
|
||||
val profileName = keys.next() as String
|
||||
ret.add(profileName)
|
||||
}
|
||||
}
|
||||
return ret
|
||||
}
|
||||
|
||||
@Synchronized
|
||||
override fun getSpecificProfile(profileName: String): PureProfile? {
|
||||
var profile: PureProfile? = null
|
||||
val units = JsonHelper.safeGetStringAllowNull(data, "units", storeUnits())
|
||||
getStore()?.let { store ->
|
||||
if (store.has(profileName)) {
|
||||
profile = cachedObjects[profileName]
|
||||
if (profile == null) {
|
||||
JsonHelper.safeGetJSONObject(store, profileName, null)?.let { profileObject ->
|
||||
profile = pureProfileFromJson(profileObject, dateUtil, units)
|
||||
profile?.let { cachedObjects[profileName] = profile }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return profile
|
||||
}
|
||||
|
||||
private fun getSpecificProfileJson(profileName: String): JSONObject? {
|
||||
getStore()?.let { store ->
|
||||
if (store.has(profileName))
|
||||
return JsonHelper.safeGetJSONObject(store, profileName, null)
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
override val allProfilesValid: Boolean
|
||||
get() = getProfileList()
|
||||
.asSequence()
|
||||
.map { profileName -> getSpecificProfile(profileName.toString()) }
|
||||
.map { pureProfile -> pureProfile?.let { ProfileSealed.Pure(pureProfile).isValid("allProfilesValid", activePlugin.activePump, config, rh, rxBus, hardLimits, false) } }
|
||||
.all { it?.isValid == true }
|
||||
}
|
|
@ -5,10 +5,10 @@ import dagger.android.AndroidInjector
|
|||
import dagger.android.HasAndroidInjector
|
||||
import info.nightscout.androidaps.extensions.pureProfileFromJson
|
||||
import info.nightscout.core.profile.ProfileSealed
|
||||
import info.nightscout.core.profile.ProfileStoreObject
|
||||
import info.nightscout.core.utils.fabric.FabricPrivacy
|
||||
import info.nightscout.database.entities.EffectiveProfileSwitch
|
||||
import info.nightscout.database.entities.embedments.InsulinConfiguration
|
||||
import info.nightscout.implementation.profile.ProfileStoreObject
|
||||
import info.nightscout.interfaces.Config
|
||||
import info.nightscout.interfaces.iob.IobCobCalculator
|
||||
import info.nightscout.interfaces.plugin.ActivePlugin
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
package info.nightscout.interfaces.profile
|
||||
|
||||
import org.json.JSONObject
|
||||
|
||||
interface ProfileInstantiator {
|
||||
fun storeInstance(jsonObject: JSONObject): ProfileStore
|
||||
}
|
|
@ -19,18 +19,18 @@ import android.widget.TableRow
|
|||
import android.widget.TextView
|
||||
import dagger.android.HasAndroidInjector
|
||||
import dagger.android.support.DaggerFragment
|
||||
import info.nightscout.interfaces.logging.UserEntryLogger
|
||||
import info.nightscout.core.profile.ProfileSealed
|
||||
import info.nightscout.core.profile.ProfileStoreObject
|
||||
import info.nightscout.core.ui.dialogs.OKDialog
|
||||
import info.nightscout.core.utils.fabric.FabricPrivacy
|
||||
import info.nightscout.database.entities.UserEntry
|
||||
import info.nightscout.database.entities.ValueWithUnit
|
||||
import info.nightscout.interfaces.Constants
|
||||
import info.nightscout.interfaces.GlucoseUnit
|
||||
import info.nightscout.interfaces.logging.UserEntryLogger
|
||||
import info.nightscout.interfaces.plugin.ActivePlugin
|
||||
import info.nightscout.interfaces.profile.Profile
|
||||
import info.nightscout.interfaces.profile.ProfileFunction
|
||||
import info.nightscout.interfaces.profile.ProfileInstantiator
|
||||
import info.nightscout.interfaces.profile.ProfileStore
|
||||
import info.nightscout.interfaces.ui.ActivityNames
|
||||
import info.nightscout.interfaces.utils.MidnightTime
|
||||
|
@ -70,6 +70,7 @@ class AutotuneFragment : DaggerFragment() {
|
|||
@Inject lateinit var injector: HasAndroidInjector
|
||||
@Inject lateinit var aapsSchedulers: AapsSchedulers
|
||||
@Inject lateinit var activityNames: ActivityNames
|
||||
@Inject lateinit var profileInstantiator: ProfileInstantiator
|
||||
|
||||
private var disposable: CompositeDisposable = CompositeDisposable()
|
||||
private var handler = Handler(HandlerThread(this::class.simpleName + "Handler").also { it.start() }.looper)
|
||||
|
@ -96,7 +97,7 @@ class AutotuneFragment : DaggerFragment() {
|
|||
if (autotunePlugin.lastNbDays.isEmpty())
|
||||
autotunePlugin.lastNbDays = sp.getInt(R.string.key_autotune_default_tune_days, 5).toString()
|
||||
val defaultValue = sp.getInt(R.string.key_autotune_default_tune_days, 5).toDouble()
|
||||
profileStore = activePlugin.activeProfileSource.profile ?: ProfileStoreObject(injector, JSONObject(), dateUtil)
|
||||
profileStore = activePlugin.activeProfileSource.profile ?: profileInstantiator.storeInstance(JSONObject())
|
||||
profileName = if (binding.profileList.text.toString() == rh.gs(R.string.active)) "" else binding.profileList.text.toString()
|
||||
profileFunction.getProfile()?.let { currentProfile ->
|
||||
profile = ATProfile(profileStore.getSpecificProfile(profileName)?.let { ProfileSealed.Pure(it) } ?: currentProfile, LocalInsulin(""), injector)
|
||||
|
@ -294,7 +295,7 @@ class AutotuneFragment : DaggerFragment() {
|
|||
@Synchronized
|
||||
private fun updateGui() {
|
||||
_binding ?: return
|
||||
profileStore = activePlugin.activeProfileSource.profile ?: ProfileStoreObject(injector, JSONObject(), dateUtil)
|
||||
profileStore = activePlugin.activeProfileSource.profile ?: profileInstantiator.storeInstance(JSONObject())
|
||||
profileName = if (binding.profileList.text.toString() == rh.gs(R.string.active)) "" else binding.profileList.text.toString()
|
||||
profileFunction.getProfile()?.let { currentProfile ->
|
||||
profile = ATProfile(profileStore.getSpecificProfile(profileName)?.let { ProfileSealed.Pure(it) } ?: currentProfile, LocalInsulin(""), injector)
|
||||
|
|
|
@ -3,20 +3,20 @@ package info.nightscout.plugins.general.autotune
|
|||
import android.view.View
|
||||
import dagger.android.HasAndroidInjector
|
||||
import info.nightscout.androidaps.extensions.pureProfileFromJson
|
||||
import info.nightscout.interfaces.logging.UserEntryLogger
|
||||
import info.nightscout.core.profile.ProfileSealed
|
||||
import info.nightscout.core.profile.ProfileStoreObject
|
||||
import info.nightscout.database.entities.UserEntry
|
||||
import info.nightscout.database.entities.ValueWithUnit
|
||||
import info.nightscout.interfaces.Config
|
||||
import info.nightscout.interfaces.autotune.Autotune
|
||||
import info.nightscout.interfaces.insulin.Insulin
|
||||
import info.nightscout.interfaces.logging.UserEntryLogger
|
||||
import info.nightscout.interfaces.plugin.ActivePlugin
|
||||
import info.nightscout.interfaces.plugin.PluginBase
|
||||
import info.nightscout.interfaces.plugin.PluginDescription
|
||||
import info.nightscout.interfaces.plugin.PluginType
|
||||
import info.nightscout.interfaces.profile.Profile
|
||||
import info.nightscout.interfaces.profile.ProfileFunction
|
||||
import info.nightscout.interfaces.profile.ProfileInstantiator
|
||||
import info.nightscout.interfaces.utils.JsonHelper
|
||||
import info.nightscout.interfaces.utils.MidnightTime
|
||||
import info.nightscout.plugins.aps.R
|
||||
|
@ -60,7 +60,8 @@ class AutotunePlugin @Inject constructor(
|
|||
private val autotuneCore: AutotuneCore,
|
||||
private val config: Config,
|
||||
private val uel: UserEntryLogger,
|
||||
aapsLogger: AAPSLogger
|
||||
aapsLogger: AAPSLogger,
|
||||
private val profileInstantiator: ProfileInstantiator
|
||||
) : PluginBase(
|
||||
PluginDescription()
|
||||
.mainType(PluginType.GENERAL)
|
||||
|
@ -324,7 +325,7 @@ class AutotunePlugin @Inject constructor(
|
|||
if (newProfile == null) return
|
||||
val profilePlugin = activePlugin.activeProfileSource
|
||||
val circadian = sp.getBoolean(R.string.key_autotune_circadian_ic_isf, false)
|
||||
val profileStore = activePlugin.activeProfileSource.profile ?: ProfileStoreObject(injector, JSONObject(), dateUtil)
|
||||
val profileStore = activePlugin.activeProfileSource.profile ?: profileInstantiator.storeInstance(JSONObject())
|
||||
val profileList: ArrayList<CharSequence> = profileStore.getProfileList()
|
||||
var indexLocalProfile = -1
|
||||
for (p in profileList.indices)
|
||||
|
|
|
@ -5,7 +5,6 @@ import info.nightscout.androidaps.extensions.blockValueBySeconds
|
|||
import info.nightscout.androidaps.extensions.pureProfileFromJson
|
||||
import info.nightscout.core.main.R
|
||||
import info.nightscout.core.profile.ProfileSealed
|
||||
import info.nightscout.core.profile.ProfileStoreObject
|
||||
import info.nightscout.core.utils.MidnightUtils
|
||||
import info.nightscout.database.entities.data.Block
|
||||
import info.nightscout.interfaces.Config
|
||||
|
@ -14,6 +13,7 @@ import info.nightscout.interfaces.insulin.Insulin
|
|||
import info.nightscout.interfaces.plugin.ActivePlugin
|
||||
import info.nightscout.interfaces.profile.Profile
|
||||
import info.nightscout.interfaces.profile.ProfileFunction
|
||||
import info.nightscout.interfaces.profile.ProfileInstantiator
|
||||
import info.nightscout.interfaces.profile.ProfileStore
|
||||
import info.nightscout.interfaces.profile.PureProfile
|
||||
import info.nightscout.interfaces.utils.Round
|
||||
|
@ -39,6 +39,7 @@ class ATProfile(profile: Profile, var localInsulin: LocalInsulin, val injector:
|
|||
@Inject lateinit var config: Config
|
||||
@Inject lateinit var rxBus: RxBus
|
||||
@Inject lateinit var rh: ResourceHelper
|
||||
@Inject lateinit var profileInstantiator: ProfileInstantiator
|
||||
|
||||
var profile: ProfileSealed
|
||||
var circadianProfile: ProfileSealed
|
||||
|
@ -179,7 +180,7 @@ class ATProfile(profile: Profile, var localInsulin: LocalInsulin, val injector:
|
|||
json.put("defaultProfile", profilename)
|
||||
json.put("store", store)
|
||||
json.put("startDate", dateUtil.toISOAsUTC(dateUtil.now()))
|
||||
profileStore = ProfileStoreObject(injector, json, dateUtil)
|
||||
profileStore = profileInstantiator.storeInstance(json)
|
||||
} catch (e: JSONException) {
|
||||
}
|
||||
return profileStore
|
||||
|
|
|
@ -0,0 +1,107 @@
|
|||
package info.nightscout.androidaps
|
||||
|
||||
import androidx.collection.ArrayMap
|
||||
import dagger.android.HasAndroidInjector
|
||||
import info.nightscout.androidaps.extensions.pureProfileFromJson
|
||||
import info.nightscout.core.profile.ProfileSealed
|
||||
import info.nightscout.interfaces.Config
|
||||
import info.nightscout.interfaces.plugin.ActivePlugin
|
||||
import info.nightscout.interfaces.profile.ProfileStore
|
||||
import info.nightscout.interfaces.profile.PureProfile
|
||||
import info.nightscout.interfaces.utils.HardLimits
|
||||
import info.nightscout.interfaces.utils.JsonHelper
|
||||
import info.nightscout.rx.bus.RxBus
|
||||
import info.nightscout.rx.logging.AAPSLogger
|
||||
import info.nightscout.shared.interfaces.ResourceHelper
|
||||
import info.nightscout.shared.utils.DateUtil
|
||||
import org.json.JSONException
|
||||
import org.json.JSONObject
|
||||
import javax.inject.Inject
|
||||
|
||||
class ProfileStoreObject(val injector: HasAndroidInjector, override val data: JSONObject, val dateUtil: DateUtil) : ProfileStore {
|
||||
|
||||
@Inject lateinit var aapsLogger: AAPSLogger
|
||||
@Inject lateinit var activePlugin: ActivePlugin
|
||||
@Inject lateinit var config: Config
|
||||
@Inject lateinit var rh: ResourceHelper
|
||||
@Inject lateinit var rxBus: RxBus
|
||||
@Inject lateinit var hardLimits: HardLimits
|
||||
|
||||
init {
|
||||
injector.androidInjector().inject(this)
|
||||
}
|
||||
|
||||
private val cachedObjects = ArrayMap<String, PureProfile>()
|
||||
|
||||
private fun storeUnits(): String? = JsonHelper.safeGetStringAllowNull(data, "units", null)
|
||||
|
||||
private fun getStore(): JSONObject? {
|
||||
try {
|
||||
if (data.has("store")) return data.getJSONObject("store")
|
||||
} catch (e: JSONException) {
|
||||
aapsLogger.error("Unhandled exception", e)
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
override fun getStartDate(): Long {
|
||||
val iso = JsonHelper.safeGetString(data, "startDate") ?: return 0
|
||||
return try {
|
||||
dateUtil.fromISODateString(iso)
|
||||
} catch (e: Exception) {
|
||||
0
|
||||
}
|
||||
}
|
||||
|
||||
override fun getDefaultProfile(): PureProfile? = getDefaultProfileName()?.let { getSpecificProfile(it) }
|
||||
override fun getDefaultProfileJson(): JSONObject? = getDefaultProfileName()?.let { getSpecificProfileJson(it) }
|
||||
|
||||
override fun getDefaultProfileName(): String? {
|
||||
val defaultProfileName = data.optString("defaultProfile")
|
||||
return if (defaultProfileName.isNotEmpty()) getStore()?.has(defaultProfileName)?.let { defaultProfileName } else null
|
||||
}
|
||||
|
||||
override fun getProfileList(): ArrayList<CharSequence> {
|
||||
val ret = ArrayList<CharSequence>()
|
||||
getStore()?.keys()?.let { keys ->
|
||||
while (keys.hasNext()) {
|
||||
val profileName = keys.next() as String
|
||||
ret.add(profileName)
|
||||
}
|
||||
}
|
||||
return ret
|
||||
}
|
||||
|
||||
@Synchronized
|
||||
override fun getSpecificProfile(profileName: String): PureProfile? {
|
||||
var profile: PureProfile? = null
|
||||
val units = JsonHelper.safeGetStringAllowNull(data, "units", storeUnits())
|
||||
getStore()?.let { store ->
|
||||
if (store.has(profileName)) {
|
||||
profile = cachedObjects[profileName]
|
||||
if (profile == null) {
|
||||
JsonHelper.safeGetJSONObject(store, profileName, null)?.let { profileObject ->
|
||||
profile = pureProfileFromJson(profileObject, dateUtil, units)
|
||||
profile?.let { cachedObjects[profileName] = profile }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return profile
|
||||
}
|
||||
|
||||
private fun getSpecificProfileJson(profileName: String): JSONObject? {
|
||||
getStore()?.let { store ->
|
||||
if (store.has(profileName))
|
||||
return JsonHelper.safeGetJSONObject(store, profileName, null)
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
override val allProfilesValid: Boolean
|
||||
get() = getProfileList()
|
||||
.asSequence()
|
||||
.map { profileName -> getSpecificProfile(profileName.toString()) }
|
||||
.map { pureProfile -> pureProfile?.let { ProfileSealed.Pure(pureProfile).isValid("allProfilesValid", activePlugin.activePump, config, rh, rxBus, hardLimits, false) } }
|
||||
.all { it?.isValid == true }
|
||||
}
|
|
@ -5,7 +5,6 @@ import dagger.android.AndroidInjector
|
|||
import dagger.android.HasAndroidInjector
|
||||
import info.nightscout.androidaps.extensions.pureProfileFromJson
|
||||
import info.nightscout.core.profile.ProfileSealed
|
||||
import info.nightscout.core.profile.ProfileStoreObject
|
||||
import info.nightscout.core.utils.fabric.FabricPrivacy
|
||||
import info.nightscout.database.entities.EffectiveProfileSwitch
|
||||
import info.nightscout.database.entities.embedments.InsulinConfiguration
|
||||
|
|
|
@ -23,7 +23,6 @@ import androidx.recyclerview.widget.LinearLayoutManager
|
|||
import androidx.recyclerview.widget.RecyclerView
|
||||
import dagger.android.HasAndroidInjector
|
||||
import dagger.android.support.DaggerFragment
|
||||
import info.nightscout.interfaces.logging.UserEntryLogger
|
||||
import info.nightscout.automation.databinding.AutomationEventItemBinding
|
||||
import info.nightscout.automation.databinding.AutomationFragmentBinding
|
||||
import info.nightscout.automation.dialogs.EditEventDialog
|
||||
|
@ -38,6 +37,7 @@ import info.nightscout.database.entities.UserEntry.Sources
|
|||
import info.nightscout.interfaces.dragHelpers.ItemTouchHelperAdapter
|
||||
import info.nightscout.interfaces.dragHelpers.OnStartDragListener
|
||||
import info.nightscout.interfaces.dragHelpers.SimpleItemTouchHelperCallback
|
||||
import info.nightscout.interfaces.logging.UserEntryLogger
|
||||
import info.nightscout.interfaces.utils.HtmlHelper
|
||||
import info.nightscout.rx.AapsSchedulers
|
||||
import info.nightscout.rx.bus.RxBus
|
||||
|
@ -212,7 +212,7 @@ class AutomationFragment : DaggerFragment(), OnStartDragListener, MenuProvider {
|
|||
holder.binding.iconLayout.removeAllViews()
|
||||
// trigger icons
|
||||
val triggerIcons = HashSet<Int>()
|
||||
if (automation.userAction) triggerIcons.add(R.drawable.ic_danar_useropt)
|
||||
if (automation.userAction) triggerIcons.add(R.drawable.ic_user_options)
|
||||
fillIconSet(automation.trigger, triggerIcons)
|
||||
for (res in triggerIcons) {
|
||||
addImage(res, holder.context, holder.binding.iconLayout)
|
||||
|
|
|
@ -69,7 +69,7 @@
|
|||
android:importantForAccessibility="no"
|
||||
android:scaleX="0.7"
|
||||
android:scaleY="0.7"
|
||||
android:src="@drawable/ic_danar_useropt" />
|
||||
android:src="@drawable/ic_user_options" />
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/user_action"
|
||||
|
|
|
@ -0,0 +1,107 @@
|
|||
package info.nightscout.androidaps
|
||||
|
||||
import androidx.collection.ArrayMap
|
||||
import dagger.android.HasAndroidInjector
|
||||
import info.nightscout.androidaps.extensions.pureProfileFromJson
|
||||
import info.nightscout.core.profile.ProfileSealed
|
||||
import info.nightscout.interfaces.Config
|
||||
import info.nightscout.interfaces.plugin.ActivePlugin
|
||||
import info.nightscout.interfaces.profile.ProfileStore
|
||||
import info.nightscout.interfaces.profile.PureProfile
|
||||
import info.nightscout.interfaces.utils.HardLimits
|
||||
import info.nightscout.interfaces.utils.JsonHelper
|
||||
import info.nightscout.rx.bus.RxBus
|
||||
import info.nightscout.rx.logging.AAPSLogger
|
||||
import info.nightscout.shared.interfaces.ResourceHelper
|
||||
import info.nightscout.shared.utils.DateUtil
|
||||
import org.json.JSONException
|
||||
import org.json.JSONObject
|
||||
import javax.inject.Inject
|
||||
|
||||
class ProfileStoreObject(val injector: HasAndroidInjector, override val data: JSONObject, val dateUtil: DateUtil) : ProfileStore {
|
||||
|
||||
@Inject lateinit var aapsLogger: AAPSLogger
|
||||
@Inject lateinit var activePlugin: ActivePlugin
|
||||
@Inject lateinit var config: Config
|
||||
@Inject lateinit var rh: ResourceHelper
|
||||
@Inject lateinit var rxBus: RxBus
|
||||
@Inject lateinit var hardLimits: HardLimits
|
||||
|
||||
init {
|
||||
injector.androidInjector().inject(this)
|
||||
}
|
||||
|
||||
private val cachedObjects = ArrayMap<String, PureProfile>()
|
||||
|
||||
private fun storeUnits(): String? = JsonHelper.safeGetStringAllowNull(data, "units", null)
|
||||
|
||||
private fun getStore(): JSONObject? {
|
||||
try {
|
||||
if (data.has("store")) return data.getJSONObject("store")
|
||||
} catch (e: JSONException) {
|
||||
aapsLogger.error("Unhandled exception", e)
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
override fun getStartDate(): Long {
|
||||
val iso = JsonHelper.safeGetString(data, "startDate") ?: return 0
|
||||
return try {
|
||||
dateUtil.fromISODateString(iso)
|
||||
} catch (e: Exception) {
|
||||
0
|
||||
}
|
||||
}
|
||||
|
||||
override fun getDefaultProfile(): PureProfile? = getDefaultProfileName()?.let { getSpecificProfile(it) }
|
||||
override fun getDefaultProfileJson(): JSONObject? = getDefaultProfileName()?.let { getSpecificProfileJson(it) }
|
||||
|
||||
override fun getDefaultProfileName(): String? {
|
||||
val defaultProfileName = data.optString("defaultProfile")
|
||||
return if (defaultProfileName.isNotEmpty()) getStore()?.has(defaultProfileName)?.let { defaultProfileName } else null
|
||||
}
|
||||
|
||||
override fun getProfileList(): ArrayList<CharSequence> {
|
||||
val ret = ArrayList<CharSequence>()
|
||||
getStore()?.keys()?.let { keys ->
|
||||
while (keys.hasNext()) {
|
||||
val profileName = keys.next() as String
|
||||
ret.add(profileName)
|
||||
}
|
||||
}
|
||||
return ret
|
||||
}
|
||||
|
||||
@Synchronized
|
||||
override fun getSpecificProfile(profileName: String): PureProfile? {
|
||||
var profile: PureProfile? = null
|
||||
val units = JsonHelper.safeGetStringAllowNull(data, "units", storeUnits())
|
||||
getStore()?.let { store ->
|
||||
if (store.has(profileName)) {
|
||||
profile = cachedObjects[profileName]
|
||||
if (profile == null) {
|
||||
JsonHelper.safeGetJSONObject(store, profileName, null)?.let { profileObject ->
|
||||
profile = pureProfileFromJson(profileObject, dateUtil, units)
|
||||
profile?.let { cachedObjects[profileName] = profile }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return profile
|
||||
}
|
||||
|
||||
private fun getSpecificProfileJson(profileName: String): JSONObject? {
|
||||
getStore()?.let { store ->
|
||||
if (store.has(profileName))
|
||||
return JsonHelper.safeGetJSONObject(store, profileName, null)
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
override val allProfilesValid: Boolean
|
||||
get() = getProfileList()
|
||||
.asSequence()
|
||||
.map { profileName -> getSpecificProfile(profileName.toString()) }
|
||||
.map { pureProfile -> pureProfile?.let { ProfileSealed.Pure(pureProfile).isValid("allProfilesValid", activePlugin.activePump, config, rh, rxBus, hardLimits, false) } }
|
||||
.all { it?.isValid == true }
|
||||
}
|
|
@ -4,7 +4,6 @@ import dagger.android.AndroidInjector
|
|||
import dagger.android.HasAndroidInjector
|
||||
import info.nightscout.androidaps.extensions.pureProfileFromJson
|
||||
import info.nightscout.core.profile.ProfileSealed
|
||||
import info.nightscout.core.profile.ProfileStoreObject
|
||||
import info.nightscout.core.utils.fabric.FabricPrivacy
|
||||
import info.nightscout.database.impl.AppRepository
|
||||
import info.nightscout.interfaces.Config
|
||||
|
|
|
@ -10,7 +10,6 @@ import info.nightscout.androidaps.annotations.OpenForTesting
|
|||
import info.nightscout.androidaps.extensions.blockFromJsonArray
|
||||
import info.nightscout.androidaps.extensions.pureProfileFromJson
|
||||
import info.nightscout.core.profile.ProfileSealed
|
||||
import info.nightscout.core.profile.ProfileStoreObject
|
||||
import info.nightscout.core.ui.dialogs.OKDialog
|
||||
import info.nightscout.core.ui.toast.ToastUtils
|
||||
import info.nightscout.core.utils.receivers.DataWorkerStorage
|
||||
|
@ -25,6 +24,7 @@ import info.nightscout.interfaces.plugin.PluginDescription
|
|||
import info.nightscout.interfaces.plugin.PluginType
|
||||
import info.nightscout.interfaces.profile.Profile
|
||||
import info.nightscout.interfaces.profile.ProfileFunction
|
||||
import info.nightscout.interfaces.profile.ProfileInstantiator
|
||||
import info.nightscout.interfaces.profile.ProfileSource
|
||||
import info.nightscout.interfaces.profile.ProfileStore
|
||||
import info.nightscout.interfaces.profile.PureProfile
|
||||
|
@ -59,7 +59,8 @@ class ProfilePlugin @Inject constructor(
|
|||
private val activePlugin: ActivePlugin,
|
||||
private val hardLimits: HardLimits,
|
||||
private val dateUtil: DateUtil,
|
||||
private val config: Config
|
||||
private val config: Config,
|
||||
private val profileInstantiator: ProfileInstantiator
|
||||
) : PluginBase(
|
||||
PluginDescription()
|
||||
.mainType(PluginType.PROFILE)
|
||||
|
@ -73,7 +74,7 @@ class ProfilePlugin @Inject constructor(
|
|||
aapsLogger, rh, injector
|
||||
), ProfileSource {
|
||||
|
||||
private var rawProfile: ProfileStoreObject? = null
|
||||
private var rawProfile: ProfileStore? = null
|
||||
|
||||
private val defaultArray = "[{\"time\":\"00:00\",\"timeAsSeconds\":0,\"value\":0}]"
|
||||
|
||||
|
@ -389,7 +390,7 @@ class ProfilePlugin @Inject constructor(
|
|||
isEdited = false
|
||||
}
|
||||
|
||||
fun createProfileStore(): ProfileStoreObject {
|
||||
fun createProfileStore(): ProfileStore {
|
||||
val json = JSONObject()
|
||||
val store = JSONObject()
|
||||
|
||||
|
@ -418,7 +419,7 @@ class ProfilePlugin @Inject constructor(
|
|||
aapsLogger.error("Unhandled exception", e)
|
||||
}
|
||||
|
||||
return ProfileStoreObject(injector, json, dateUtil)
|
||||
return profileInstantiator.storeInstance(json)
|
||||
}
|
||||
|
||||
override val profile: ProfileStore?
|
||||
|
@ -444,6 +445,7 @@ class ProfilePlugin @Inject constructor(
|
|||
@Inject lateinit var config: Config
|
||||
@Inject lateinit var profilePlugin: ProfilePlugin
|
||||
@Inject lateinit var xDripBroadcast: XDripBroadcast
|
||||
@Inject lateinit var profileInstantiator: ProfileInstantiator
|
||||
|
||||
init {
|
||||
(context.applicationContext as HasAndroidInjector).androidInjector().inject(this)
|
||||
|
@ -454,7 +456,7 @@ class ProfilePlugin @Inject constructor(
|
|||
?: return Result.failure(workDataOf("Error" to "missing input data"))
|
||||
xDripBroadcast.sendProfile(profileJson)
|
||||
if (sp.getBoolean(R.string.key_ns_receive_profile_store, true) || config.NSCLIENT) {
|
||||
val store = ProfileStoreObject(injector, profileJson, dateUtil)
|
||||
val store = profileInstantiator.storeInstance(profileJson)
|
||||
val createdAt = store.getStartDate()
|
||||
val lastLocalChange = sp.getLong(R.string.key_local_profile_last_change, 0)
|
||||
aapsLogger.debug(LTag.PROFILE, "Received profileStore: createdAt: $createdAt Local last modification: $lastLocalChange")
|
||||
|
|
|
@ -0,0 +1,107 @@
|
|||
package info.nightscout.androidaps
|
||||
|
||||
import androidx.collection.ArrayMap
|
||||
import dagger.android.HasAndroidInjector
|
||||
import info.nightscout.androidaps.extensions.pureProfileFromJson
|
||||
import info.nightscout.core.profile.ProfileSealed
|
||||
import info.nightscout.interfaces.Config
|
||||
import info.nightscout.interfaces.plugin.ActivePlugin
|
||||
import info.nightscout.interfaces.profile.ProfileStore
|
||||
import info.nightscout.interfaces.profile.PureProfile
|
||||
import info.nightscout.interfaces.utils.HardLimits
|
||||
import info.nightscout.interfaces.utils.JsonHelper
|
||||
import info.nightscout.rx.bus.RxBus
|
||||
import info.nightscout.rx.logging.AAPSLogger
|
||||
import info.nightscout.shared.interfaces.ResourceHelper
|
||||
import info.nightscout.shared.utils.DateUtil
|
||||
import org.json.JSONException
|
||||
import org.json.JSONObject
|
||||
import javax.inject.Inject
|
||||
|
||||
class ProfileStoreObject(val injector: HasAndroidInjector, override val data: JSONObject, val dateUtil: DateUtil) : ProfileStore {
|
||||
|
||||
@Inject lateinit var aapsLogger: AAPSLogger
|
||||
@Inject lateinit var activePlugin: ActivePlugin
|
||||
@Inject lateinit var config: Config
|
||||
@Inject lateinit var rh: ResourceHelper
|
||||
@Inject lateinit var rxBus: RxBus
|
||||
@Inject lateinit var hardLimits: HardLimits
|
||||
|
||||
init {
|
||||
injector.androidInjector().inject(this)
|
||||
}
|
||||
|
||||
private val cachedObjects = ArrayMap<String, PureProfile>()
|
||||
|
||||
private fun storeUnits(): String? = JsonHelper.safeGetStringAllowNull(data, "units", null)
|
||||
|
||||
private fun getStore(): JSONObject? {
|
||||
try {
|
||||
if (data.has("store")) return data.getJSONObject("store")
|
||||
} catch (e: JSONException) {
|
||||
aapsLogger.error("Unhandled exception", e)
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
override fun getStartDate(): Long {
|
||||
val iso = JsonHelper.safeGetString(data, "startDate") ?: return 0
|
||||
return try {
|
||||
dateUtil.fromISODateString(iso)
|
||||
} catch (e: Exception) {
|
||||
0
|
||||
}
|
||||
}
|
||||
|
||||
override fun getDefaultProfile(): PureProfile? = getDefaultProfileName()?.let { getSpecificProfile(it) }
|
||||
override fun getDefaultProfileJson(): JSONObject? = getDefaultProfileName()?.let { getSpecificProfileJson(it) }
|
||||
|
||||
override fun getDefaultProfileName(): String? {
|
||||
val defaultProfileName = data.optString("defaultProfile")
|
||||
return if (defaultProfileName.isNotEmpty()) getStore()?.has(defaultProfileName)?.let { defaultProfileName } else null
|
||||
}
|
||||
|
||||
override fun getProfileList(): ArrayList<CharSequence> {
|
||||
val ret = ArrayList<CharSequence>()
|
||||
getStore()?.keys()?.let { keys ->
|
||||
while (keys.hasNext()) {
|
||||
val profileName = keys.next() as String
|
||||
ret.add(profileName)
|
||||
}
|
||||
}
|
||||
return ret
|
||||
}
|
||||
|
||||
@Synchronized
|
||||
override fun getSpecificProfile(profileName: String): PureProfile? {
|
||||
var profile: PureProfile? = null
|
||||
val units = JsonHelper.safeGetStringAllowNull(data, "units", storeUnits())
|
||||
getStore()?.let { store ->
|
||||
if (store.has(profileName)) {
|
||||
profile = cachedObjects[profileName]
|
||||
if (profile == null) {
|
||||
JsonHelper.safeGetJSONObject(store, profileName, null)?.let { profileObject ->
|
||||
profile = pureProfileFromJson(profileObject, dateUtil, units)
|
||||
profile?.let { cachedObjects[profileName] = profile }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return profile
|
||||
}
|
||||
|
||||
private fun getSpecificProfileJson(profileName: String): JSONObject? {
|
||||
getStore()?.let { store ->
|
||||
if (store.has(profileName))
|
||||
return JsonHelper.safeGetJSONObject(store, profileName, null)
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
override val allProfilesValid: Boolean
|
||||
get() = getProfileList()
|
||||
.asSequence()
|
||||
.map { profileName -> getSpecificProfile(profileName.toString()) }
|
||||
.map { pureProfile -> pureProfile?.let { ProfileSealed.Pure(pureProfile).isValid("allProfilesValid", activePlugin.activePump, config, rh, rxBus, hardLimits, false) } }
|
||||
.all { it?.isValid == true }
|
||||
}
|
|
@ -5,7 +5,6 @@ import dagger.android.AndroidInjector
|
|||
import dagger.android.HasAndroidInjector
|
||||
import info.nightscout.androidaps.extensions.pureProfileFromJson
|
||||
import info.nightscout.core.profile.ProfileSealed
|
||||
import info.nightscout.core.profile.ProfileStoreObject
|
||||
import info.nightscout.core.utils.fabric.FabricPrivacy
|
||||
import info.nightscout.database.entities.EffectiveProfileSwitch
|
||||
import info.nightscout.database.entities.embedments.InsulinConfiguration
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
<string name="combov2_error_10">Reservoir error</string>
|
||||
<string name="combov2_error_11">Infusion set not primed</string>
|
||||
<string name="combov2_extended_bolus_not_supported">Extended bolus is not supported</string>
|
||||
<string name="combov2_title">Accu-Check Combo</string>
|
||||
<string name="combov2_title">Accu-Check Combo v2</string>
|
||||
<string name="combov2_pair_with_pump_title">Pair with pump</string>
|
||||
<string name="combov2_unpair_pump_title">Unpair pump</string>
|
||||
<string name="combov2_driver_state_label">Driver state</string>
|
||||
|
|
|
@ -14,7 +14,7 @@ apply from: "${project.rootDir}/core/core-main/jacoco_global.gradle"
|
|||
|
||||
android {
|
||||
|
||||
namespace 'info.nightscout.androidaps.dana'
|
||||
namespace 'info.nightscout.pump.dana'
|
||||
defaultConfig {
|
||||
kapt {
|
||||
arguments {
|
||||
|
@ -27,7 +27,7 @@ android {
|
|||
|
||||
dependencies {
|
||||
implementation project(':libraries')
|
||||
implementation project(':core:core-main')
|
||||
implementation project(':core:ui')
|
||||
implementation project(':core:utils')
|
||||
implementation project(':app-wear-shared:rx')
|
||||
implementation project(':app-wear-shared:shared')
|
||||
|
@ -36,7 +36,7 @@ dependencies {
|
|||
api "androidx.room:room-ktx:$room_version"
|
||||
api "androidx.room:room-runtime:$room_version"
|
||||
api "androidx.room:room-rxjava3:$room_version"
|
||||
implementation project(path: ':core:ui')
|
||||
implementation project(path: ':core:ui')
|
||||
kapt "androidx.room:room-compiler:$room_version"
|
||||
|
||||
testImplementation project(':core:core-main') // create profile from json
|
||||
}
|
|
@ -0,0 +1,93 @@
|
|||
{
|
||||
"formatVersion": 1,
|
||||
"database": {
|
||||
"version": 1,
|
||||
"identityHash": "04f2e440fae2d62ca4e4a38840b5cf2f",
|
||||
"entities": [
|
||||
{
|
||||
"tableName": "danaHistory",
|
||||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`timestamp` INTEGER NOT NULL, `code` INTEGER NOT NULL, `value` REAL NOT NULL, `bolusType` TEXT NOT NULL, `stringValue` TEXT NOT NULL, `duration` INTEGER NOT NULL, `dailyBasal` REAL NOT NULL, `dailyBolus` REAL NOT NULL, `alarm` TEXT NOT NULL, PRIMARY KEY(`timestamp`))",
|
||||
"fields": [
|
||||
{
|
||||
"fieldPath": "timestamp",
|
||||
"columnName": "timestamp",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "code",
|
||||
"columnName": "code",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "value",
|
||||
"columnName": "value",
|
||||
"affinity": "REAL",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "bolusType",
|
||||
"columnName": "bolusType",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "stringValue",
|
||||
"columnName": "stringValue",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "duration",
|
||||
"columnName": "duration",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "dailyBasal",
|
||||
"columnName": "dailyBasal",
|
||||
"affinity": "REAL",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "dailyBolus",
|
||||
"columnName": "dailyBolus",
|
||||
"affinity": "REAL",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "alarm",
|
||||
"columnName": "alarm",
|
||||
"affinity": "TEXT",
|
||||
"notNull": true
|
||||
}
|
||||
],
|
||||
"primaryKey": {
|
||||
"columnNames": [
|
||||
"timestamp"
|
||||
],
|
||||
"autoGenerate": false
|
||||
},
|
||||
"indices": [
|
||||
{
|
||||
"name": "index_danaHistory_code_timestamp",
|
||||
"unique": false,
|
||||
"columnNames": [
|
||||
"code",
|
||||
"timestamp"
|
||||
],
|
||||
"orders": [],
|
||||
"createSql": "CREATE INDEX IF NOT EXISTS `index_danaHistory_code_timestamp` ON `${TABLE_NAME}` (`code`, `timestamp`)"
|
||||
}
|
||||
],
|
||||
"foreignKeys": []
|
||||
}
|
||||
],
|
||||
"views": [],
|
||||
"setupQueries": [
|
||||
"CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
|
||||
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '04f2e440fae2d62ca4e4a38840b5cf2f')"
|
||||
]
|
||||
}
|
||||
}
|
|
@ -2,12 +2,12 @@
|
|||
|
||||
<application android:supportsRtl="true">
|
||||
<activity
|
||||
android:name="info.nightscout.androidaps.dana.activities.DanaHistoryActivity"
|
||||
android:name="info.nightscout.pump.dana.activities.DanaHistoryActivity"
|
||||
android:exported="false"
|
||||
android:theme="@style/AppTheme" />
|
||||
android:theme="@style/AppTheme.NoActionBar" />
|
||||
<activity
|
||||
android:name="info.nightscout.androidaps.dana.activities.DanaUserOptionsActivity"
|
||||
android:name="info.nightscout.pump.dana.activities.DanaUserOptionsActivity"
|
||||
android:exported="false"
|
||||
android:theme="@style/AppTheme" />
|
||||
android:theme="@style/AppTheme.NoActionBar" />
|
||||
</application>
|
||||
</manifest>
|
||||
|
|
|
@ -1,22 +0,0 @@
|
|||
package info.nightscout.androidaps.dana.di
|
||||
|
||||
import android.content.Context
|
||||
import dagger.Module
|
||||
import dagger.Provides
|
||||
import dagger.android.ContributesAndroidInjector
|
||||
import info.nightscout.androidaps.dana.DanaFragment
|
||||
import info.nightscout.androidaps.dana.activities.DanaHistoryActivity
|
||||
import info.nightscout.androidaps.dana.activities.DanaUserOptionsActivity
|
||||
import info.nightscout.androidaps.dana.database.DanaHistoryDatabase
|
||||
import info.nightscout.androidaps.dana.database.DanaHistoryRecordDao
|
||||
import javax.inject.Singleton
|
||||
|
||||
@Module
|
||||
@Suppress("unused")
|
||||
abstract class DanaModule {
|
||||
|
||||
@ContributesAndroidInjector abstract fun contributesDanaRFragment(): DanaFragment
|
||||
@ContributesAndroidInjector abstract fun contributeDanaRHistoryActivity(): DanaHistoryActivity
|
||||
@ContributesAndroidInjector abstract fun contributeDanaRUserOptionsActivity(): DanaUserOptionsActivity
|
||||
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package info.nightscout.androidaps.dana
|
||||
package info.nightscout.pump.dana
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Intent
|
||||
|
@ -10,10 +10,6 @@ import android.view.View
|
|||
import android.view.ViewGroup
|
||||
import androidx.core.content.ContextCompat
|
||||
import dagger.android.support.DaggerFragment
|
||||
import info.nightscout.androidaps.dana.activities.DanaHistoryActivity
|
||||
import info.nightscout.androidaps.dana.activities.DanaUserOptionsActivity
|
||||
import info.nightscout.androidaps.dana.databinding.DanarFragmentBinding
|
||||
import info.nightscout.androidaps.dana.events.EventDanaRNewStatus
|
||||
import info.nightscout.core.ui.dialogs.OKDialog
|
||||
import info.nightscout.core.utils.fabric.FabricPrivacy
|
||||
import info.nightscout.interfaces.logging.UserEntryLogger
|
||||
|
@ -26,6 +22,10 @@ import info.nightscout.interfaces.queue.CommandQueue
|
|||
import info.nightscout.interfaces.ui.ActivityNames
|
||||
import info.nightscout.interfaces.userEntry.UserEntryMapper.Action
|
||||
import info.nightscout.interfaces.userEntry.UserEntryMapper.Sources
|
||||
import info.nightscout.pump.dana.activities.DanaHistoryActivity
|
||||
import info.nightscout.pump.dana.activities.DanaUserOptionsActivity
|
||||
import info.nightscout.pump.dana.databinding.DanarFragmentBinding
|
||||
import info.nightscout.pump.dana.events.EventDanaRNewStatus
|
||||
import info.nightscout.rx.AapsSchedulers
|
||||
import info.nightscout.rx.bus.RxBus
|
||||
import info.nightscout.rx.events.EventExtendedBolusChange
|
||||
|
@ -207,26 +207,26 @@ class DanaFragment : DaggerFragment() {
|
|||
if (pump.lastConnection != 0L) {
|
||||
val agoMilliseconds = System.currentTimeMillis() - pump.lastConnection
|
||||
val agoMin = (agoMilliseconds.toDouble() / 60.0 / 1000.0).toInt()
|
||||
binding.lastconnection.text = dateUtil.timeString(pump.lastConnection) + " (" + rh.gs(R.string.minago, agoMin) + ")"
|
||||
warnColors.setColor(binding.lastconnection, agoMin.toDouble(), 16.0, 31.0)
|
||||
binding.lastConnection.text = dateUtil.timeString(pump.lastConnection) + " (" + rh.gs(R.string.minago, agoMin) + ")"
|
||||
warnColors.setColor(binding.lastConnection, agoMin.toDouble(), 16.0, 31.0)
|
||||
}
|
||||
if (pump.lastBolusTime != 0L) {
|
||||
val agoMilliseconds = System.currentTimeMillis() - pump.lastBolusTime
|
||||
val agoHours = agoMilliseconds.toDouble() / 60.0 / 60.0 / 1000.0
|
||||
if (agoHours < 6)
|
||||
// max 6h back
|
||||
binding.lastbolus.text = dateUtil.timeString(pump.lastBolusTime) + " " + dateUtil.sinceString(pump.lastBolusTime, rh) + " " + rh.gs(R.string.format_insulin_units, pump.lastBolusAmount)
|
||||
binding.lastBolus.text = dateUtil.timeString(pump.lastBolusTime) + " " + dateUtil.sinceString(pump.lastBolusTime, rh) + " " + rh.gs(R.string.format_insulin_units, pump.lastBolusAmount)
|
||||
else
|
||||
binding.lastbolus.text = ""
|
||||
binding.lastBolus.text = ""
|
||||
}
|
||||
|
||||
binding.dailyunits.text = rh.gs(R.string.reservoirvalue, pump.dailyTotalUnits, pump.maxDailyTotalUnits)
|
||||
warnColors.setColor(binding.dailyunits, pump.dailyTotalUnits, pump.maxDailyTotalUnits * 0.75, pump.maxDailyTotalUnits * 0.9)
|
||||
binding.basabasalrate.text = "( " + (pump.activeProfile + 1) + " ) " + rh.gs(R.string.pump_base_basal_rate, plugin.baseBasalRate)
|
||||
binding.dailyUnits.text = rh.gs(R.string.reservoir_value, pump.dailyTotalUnits, pump.maxDailyTotalUnits)
|
||||
warnColors.setColor(binding.dailyUnits, pump.dailyTotalUnits, pump.maxDailyTotalUnits * 0.75, pump.maxDailyTotalUnits * 0.9)
|
||||
binding.baseBasalRate.text = "( " + (pump.activeProfile + 1) + " ) " + rh.gs(R.string.pump_base_basal_rate, plugin.baseBasalRate)
|
||||
// DanaRPlugin, DanaRKoreanPlugin
|
||||
binding.tempbasal.text = danaPump.temporaryBasalToString()
|
||||
binding.extendedbolus.text = danaPump.extendedBolusToString()
|
||||
binding.reservoir.text = rh.gs(R.string.reservoirvalue, pump.reservoirRemainingUnits, 300)
|
||||
binding.reservoir.text = rh.gs(R.string.reservoir_value, pump.reservoirRemainingUnits, 300)
|
||||
warnColors.setColorInverse(binding.reservoir, pump.reservoirRemainingUnits, 50.0, 20.0)
|
||||
binding.battery.text = "{fa-battery-" + pump.batteryRemaining / 25 + "}"
|
||||
warnColors.setColorInverse(binding.battery, pump.batteryRemaining.toDouble(), 51.0, 26.0)
|
|
@ -1,9 +1,8 @@
|
|||
package info.nightscout.androidaps.dana
|
||||
package info.nightscout.pump.dana
|
||||
|
||||
import dagger.android.HasAndroidInjector
|
||||
import info.nightscout.core.profile.ProfileStoreObject
|
||||
import info.nightscout.interfaces.Constants
|
||||
import info.nightscout.interfaces.profile.Profile
|
||||
import info.nightscout.interfaces.profile.ProfileInstantiator
|
||||
import info.nightscout.interfaces.profile.ProfileStore
|
||||
import info.nightscout.interfaces.pump.PumpSync
|
||||
import info.nightscout.interfaces.pump.defs.PumpType
|
||||
|
@ -34,7 +33,7 @@ class DanaPump @Inject constructor(
|
|||
private val aapsLogger: AAPSLogger,
|
||||
private val sp: SP,
|
||||
private val dateUtil: DateUtil,
|
||||
private val injector: HasAndroidInjector
|
||||
private val profileInstantiator: ProfileInstantiator
|
||||
) {
|
||||
|
||||
@Suppress("unused")
|
||||
|
@ -381,7 +380,7 @@ class DanaPump @Inject constructor(
|
|||
} catch (e: Exception) {
|
||||
return null
|
||||
}
|
||||
return ProfileStoreObject(injector, json, dateUtil)
|
||||
return profileInstantiator.storeInstance(json)
|
||||
}
|
||||
return null
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package info.nightscout.androidaps.dana.activities
|
||||
package info.nightscout.pump.dana.activities
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
|
@ -8,13 +8,7 @@ import android.widget.AdapterView
|
|||
import android.widget.ArrayAdapter
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import info.nightscout.androidaps.dana.R
|
||||
import info.nightscout.androidaps.dana.comm.RecordTypes
|
||||
import info.nightscout.androidaps.dana.database.DanaHistoryRecord
|
||||
import info.nightscout.androidaps.dana.database.DanaHistoryRecordDao
|
||||
import info.nightscout.androidaps.dana.databinding.DanarHistoryActivityBinding
|
||||
import info.nightscout.androidaps.dana.databinding.DanarHistoryItemBinding
|
||||
import info.nightscout.core.activities.NoSplashAppCompatActivity
|
||||
import dagger.android.support.DaggerAppCompatActivity
|
||||
import info.nightscout.core.utils.fabric.FabricPrivacy
|
||||
import info.nightscout.interfaces.Constants
|
||||
import info.nightscout.interfaces.plugin.ActivePlugin
|
||||
|
@ -24,18 +18,30 @@ import info.nightscout.interfaces.pump.defs.PumpType
|
|||
import info.nightscout.interfaces.queue.Callback
|
||||
import info.nightscout.interfaces.queue.CommandQueue
|
||||
import info.nightscout.interfaces.utils.DecimalFormatter
|
||||
import info.nightscout.pump.dana.R
|
||||
import info.nightscout.pump.dana.comm.RecordTypes
|
||||
import info.nightscout.pump.dana.database.DanaHistoryRecord
|
||||
import info.nightscout.pump.dana.database.DanaHistoryRecordDao
|
||||
import info.nightscout.pump.dana.databinding.DanarHistoryActivityBinding
|
||||
import info.nightscout.pump.dana.databinding.DanarHistoryItemBinding
|
||||
import info.nightscout.rx.AapsSchedulers
|
||||
import info.nightscout.rx.bus.RxBus
|
||||
import info.nightscout.rx.events.EventDanaRSyncStatus
|
||||
import info.nightscout.rx.events.EventPumpStatusChanged
|
||||
import info.nightscout.rx.logging.AAPSLogger
|
||||
import info.nightscout.rx.logging.LTag
|
||||
import info.nightscout.shared.interfaces.ResourceHelper
|
||||
import info.nightscout.shared.utils.DateUtil
|
||||
import info.nightscout.shared.utils.T
|
||||
import io.reactivex.rxjava3.disposables.CompositeDisposable
|
||||
import io.reactivex.rxjava3.kotlin.plusAssign
|
||||
import javax.inject.Inject
|
||||
|
||||
class DanaHistoryActivity : NoSplashAppCompatActivity() {
|
||||
class DanaHistoryActivity : DaggerAppCompatActivity() {
|
||||
|
||||
@Inject lateinit var rxBus: RxBus
|
||||
@Inject lateinit var rh: ResourceHelper
|
||||
@Inject lateinit var aapsLogger: AAPSLogger
|
||||
@Inject lateinit var profileFunction: ProfileFunction
|
||||
@Inject lateinit var fabricPrivacy: FabricPrivacy
|
||||
@Inject lateinit var activePlugin: ActivePlugin
|
||||
|
@ -80,7 +86,6 @@ class DanaHistoryActivity : NoSplashAppCompatActivity() {
|
|||
super.onCreate(savedInstanceState)
|
||||
binding = DanarHistoryActivityBinding.inflate(layoutInflater)
|
||||
setContentView(binding.root)
|
||||
setTheme(R.style.AppTheme)
|
||||
|
||||
binding.recyclerview.setHasFixedSize(true)
|
||||
binding.recyclerview.layoutManager = LinearLayoutManager(this)
|
|
@ -1,11 +1,8 @@
|
|||
package info.nightscout.androidaps.dana.activities
|
||||
package info.nightscout.pump.dana.activities
|
||||
|
||||
import android.content.Context
|
||||
import android.os.Bundle
|
||||
import info.nightscout.androidaps.dana.DanaPump
|
||||
import info.nightscout.androidaps.dana.R
|
||||
import info.nightscout.androidaps.dana.databinding.DanarUserOptionsActivityBinding
|
||||
import info.nightscout.core.activities.NoSplashAppCompatActivity
|
||||
import dagger.android.support.DaggerAppCompatActivity
|
||||
import info.nightscout.core.utils.fabric.FabricPrivacy
|
||||
import info.nightscout.interfaces.Constants
|
||||
import info.nightscout.interfaces.plugin.ActivePlugin
|
||||
|
@ -13,9 +10,15 @@ import info.nightscout.interfaces.pump.defs.PumpType
|
|||
import info.nightscout.interfaces.queue.Callback
|
||||
import info.nightscout.interfaces.queue.CommandQueue
|
||||
import info.nightscout.interfaces.ui.ActivityNames
|
||||
import info.nightscout.pump.dana.DanaPump
|
||||
import info.nightscout.pump.dana.R
|
||||
import info.nightscout.pump.dana.databinding.DanarUserOptionsActivityBinding
|
||||
import info.nightscout.rx.AapsSchedulers
|
||||
import info.nightscout.rx.bus.RxBus
|
||||
import info.nightscout.rx.events.EventInitializationChanged
|
||||
import info.nightscout.rx.logging.AAPSLogger
|
||||
import info.nightscout.rx.logging.LTag
|
||||
import info.nightscout.shared.interfaces.ResourceHelper
|
||||
import io.reactivex.rxjava3.disposables.CompositeDisposable
|
||||
import io.reactivex.rxjava3.kotlin.plusAssign
|
||||
import java.text.DecimalFormat
|
||||
|
@ -23,8 +26,11 @@ import javax.inject.Inject
|
|||
import kotlin.math.max
|
||||
import kotlin.math.min
|
||||
|
||||
class DanaUserOptionsActivity : NoSplashAppCompatActivity() {
|
||||
class DanaUserOptionsActivity : DaggerAppCompatActivity() {
|
||||
|
||||
@Inject lateinit var rxBus: RxBus
|
||||
@Inject lateinit var aapsLogger: AAPSLogger
|
||||
@Inject lateinit var rh: ResourceHelper
|
||||
@Inject lateinit var fabricPrivacy: FabricPrivacy
|
||||
@Inject lateinit var context: Context
|
||||
@Inject lateinit var danaPump: DanaPump
|
||||
|
@ -40,7 +46,7 @@ class DanaUserOptionsActivity : NoSplashAppCompatActivity() {
|
|||
private fun isDanaR() = activePlugin.activePump.pumpDescription.pumpType == PumpType.DANA_R
|
||||
private fun isDanaRv2() = activePlugin.activePump.pumpDescription.pumpType == PumpType.DANA_RV2
|
||||
|
||||
var minBacklight = 1
|
||||
private var minBacklight = 1
|
||||
|
||||
private lateinit var binding: DanarUserOptionsActivityBinding
|
||||
|
||||
|
@ -80,27 +86,27 @@ class DanaUserOptionsActivity : NoSplashAppCompatActivity() {
|
|||
+ "\nlowReservoir:" + danaPump.lowReservoirRate
|
||||
)
|
||||
|
||||
binding.screentimeout.setParams(danaPump.lcdOnTimeSec.toDouble(), 5.0, 240.0, 5.0, DecimalFormat("1"), false, binding.saveUserOptions)
|
||||
binding.screenTimeout.setParams(danaPump.lcdOnTimeSec.toDouble(), 5.0, 240.0, 5.0, DecimalFormat("1"), false, binding.saveUserOptions)
|
||||
binding.backlight.setParams(danaPump.backlightOnTimeSec.toDouble(), minBacklight.toDouble(), 60.0, 1.0, DecimalFormat("1"), false, binding.saveUserOptions)
|
||||
binding.shutdown.setParams(danaPump.shutdownHour.toDouble(), 0.0, 24.0, 1.0, DecimalFormat("1"), true, binding.saveUserOptions)
|
||||
binding.lowreservoir.setParams(danaPump.lowReservoirRate.toDouble(), 10.0, 50.0, 10.0, DecimalFormat("10"), false, binding.saveUserOptions)
|
||||
binding.lowReservoir.setParams(danaPump.lowReservoirRate.toDouble(), 10.0, 50.0, 10.0, DecimalFormat("10"), false, binding.saveUserOptions)
|
||||
when (danaPump.beepAndAlarm) {
|
||||
0b01 -> binding.pumpalarmSound.isChecked = true
|
||||
0b10 -> binding.pumpalarmVibrate.isChecked = true
|
||||
0b11 -> binding.pumpalarmBoth.isChecked = true
|
||||
0b01 -> binding.pumpAlarmSound.isChecked = true
|
||||
0b10 -> binding.pumpAlarmVibrate.isChecked = true
|
||||
0b11 -> binding.pumpAlarmBoth.isChecked = true
|
||||
|
||||
0b101 -> {
|
||||
binding.pumpalarmSound.isChecked = true
|
||||
binding.pumpAlarmSound.isChecked = true
|
||||
binding.beep.isChecked = true
|
||||
}
|
||||
|
||||
0b110 -> {
|
||||
binding.pumpalarmVibrate.isChecked = true
|
||||
binding.pumpAlarmVibrate.isChecked = true
|
||||
binding.beep.isChecked = true
|
||||
}
|
||||
|
||||
0b111 -> {
|
||||
binding.pumpalarmBoth.isChecked = true
|
||||
binding.pumpAlarmBoth.isChecked = true
|
||||
binding.beep.isChecked = true
|
||||
}
|
||||
}
|
||||
|
@ -110,35 +116,35 @@ class DanaUserOptionsActivity : NoSplashAppCompatActivity() {
|
|||
setData()
|
||||
}
|
||||
|
||||
fun setData() {
|
||||
private fun setData() {
|
||||
// in DanaRS timeDisplay values are reversed
|
||||
binding.timeformat.isChecked = danaPump.timeDisplayType24
|
||||
binding.buttonscroll.isChecked = danaPump.buttonScrollOnOff
|
||||
binding.timeFormat.isChecked = danaPump.timeDisplayType24
|
||||
binding.buttonScroll.isChecked = danaPump.buttonScrollOnOff
|
||||
binding.beep.isChecked = danaPump.beepAndAlarm > 4
|
||||
binding.screentimeout.value = danaPump.lcdOnTimeSec.toDouble()
|
||||
binding.screenTimeout.value = danaPump.lcdOnTimeSec.toDouble()
|
||||
binding.backlight.value = danaPump.backlightOnTimeSec.toDouble()
|
||||
binding.units.isChecked = danaPump.getUnits() == Constants.MMOL
|
||||
binding.shutdown.value = danaPump.shutdownHour.toDouble()
|
||||
binding.lowreservoir.value = danaPump.lowReservoirRate.toDouble()
|
||||
binding.lowReservoir.value = danaPump.lowReservoirRate.toDouble()
|
||||
}
|
||||
|
||||
private fun onSaveClick() {
|
||||
//exit if pump is not DanaRS, DanaR, or DanaR with upgraded firmware
|
||||
if (!isRS() && !isDanaR() && !isDanaRv2()) return
|
||||
|
||||
danaPump.timeDisplayType24 = binding.timeformat.isChecked
|
||||
danaPump.timeDisplayType24 = binding.timeFormat.isChecked
|
||||
|
||||
danaPump.buttonScrollOnOff = binding.buttonscroll.isChecked
|
||||
danaPump.buttonScrollOnOff = binding.buttonScroll.isChecked
|
||||
danaPump.beepAndAlarm = when {
|
||||
binding.pumpalarmSound.isChecked -> 1
|
||||
binding.pumpalarmVibrate.isChecked -> 2
|
||||
binding.pumpalarmBoth.isChecked -> 3
|
||||
binding.pumpAlarmSound.isChecked -> 1
|
||||
binding.pumpAlarmVibrate.isChecked -> 2
|
||||
binding.pumpAlarmBoth.isChecked -> 3
|
||||
else -> 1
|
||||
}
|
||||
if (binding.beep.isChecked) danaPump.beepAndAlarm += 4
|
||||
|
||||
// step is 5 seconds, 5 to 240
|
||||
danaPump.lcdOnTimeSec = min(max(binding.screentimeout.value.toInt() / 5 * 5, 5), 240)
|
||||
danaPump.lcdOnTimeSec = min(max(binding.screenTimeout.value.toInt() / 5 * 5, 5), 240)
|
||||
// 1 to 60
|
||||
danaPump.backlightOnTimeSec = min(max(binding.backlight.value.toInt(), minBacklight), 60)
|
||||
|
||||
|
@ -147,7 +153,7 @@ class DanaUserOptionsActivity : NoSplashAppCompatActivity() {
|
|||
danaPump.shutdownHour = min(binding.shutdown.value.toInt(), 24)
|
||||
|
||||
// 10 to 50
|
||||
danaPump.lowReservoirRate = min(max(binding.lowreservoir.value.toInt() * 10 / 10, 10), 50)
|
||||
danaPump.lowReservoirRate = min(max(binding.lowReservoir.value.toInt() * 10 / 10, 10), 50)
|
||||
|
||||
commandQueue.setUserOptions(object : Callback() {
|
||||
override fun run() {
|
|
@ -1,4 +1,4 @@
|
|||
package info.nightscout.androidaps.dana.comm
|
||||
package info.nightscout.pump.dana.comm
|
||||
|
||||
object RecordTypes {
|
||||
const val RECORD_TYPE_BOLUS = 0x01.toByte()
|
|
@ -1,10 +1,9 @@
|
|||
package info.nightscout.androidaps.dana.database
|
||||
package info.nightscout.pump.dana.database
|
||||
|
||||
import android.content.Context
|
||||
import androidx.room.Database
|
||||
import androidx.room.Room
|
||||
import androidx.room.RoomDatabase
|
||||
import androidx.room.TypeConverters
|
||||
|
||||
const val TABLE_DANA_HISTORY = "danaHistory"
|
||||
|
|
@ -1,11 +1,11 @@
|
|||
package info.nightscout.androidaps.dana.database
|
||||
package info.nightscout.pump.dana.database
|
||||
|
||||
import androidx.room.Entity
|
||||
import androidx.room.Index
|
||||
import androidx.room.PrimaryKey
|
||||
|
||||
@Entity(tableName = TABLE_DANA_HISTORY,
|
||||
indices = [Index("code", "timestamp")])
|
||||
indices = [Index("code", "timestamp")])
|
||||
data class DanaHistoryRecord(
|
||||
@PrimaryKey var timestamp: Long,
|
||||
var code: Byte = 0x0F,
|
|
@ -1,4 +1,4 @@
|
|||
package info.nightscout.androidaps.dana.database
|
||||
package info.nightscout.pump.dana.database
|
||||
|
||||
import androidx.room.Dao
|
||||
import androidx.room.Insert
|
|
@ -1,10 +1,10 @@
|
|||
package info.nightscout.androidaps.dana.di
|
||||
package info.nightscout.pump.dana.di
|
||||
|
||||
import android.content.Context
|
||||
import dagger.Module
|
||||
import dagger.Provides
|
||||
import info.nightscout.androidaps.dana.database.DanaHistoryDatabase
|
||||
import info.nightscout.androidaps.dana.database.DanaHistoryRecordDao
|
||||
import info.nightscout.pump.dana.database.DanaHistoryDatabase
|
||||
import info.nightscout.pump.dana.database.DanaHistoryRecordDao
|
||||
import javax.inject.Singleton
|
||||
|
||||
@Module
|
|
@ -0,0 +1,17 @@
|
|||
package info.nightscout.pump.dana.di
|
||||
|
||||
import dagger.Module
|
||||
import dagger.android.ContributesAndroidInjector
|
||||
import info.nightscout.pump.dana.DanaFragment
|
||||
import info.nightscout.pump.dana.activities.DanaHistoryActivity
|
||||
import info.nightscout.pump.dana.activities.DanaUserOptionsActivity
|
||||
|
||||
@Module
|
||||
@Suppress("unused")
|
||||
abstract class DanaModule {
|
||||
|
||||
@ContributesAndroidInjector abstract fun contributesDanaRFragment(): DanaFragment
|
||||
@ContributesAndroidInjector abstract fun contributeDanaRHistoryActivity(): DanaHistoryActivity
|
||||
@ContributesAndroidInjector abstract fun contributeDanaRUserOptionsActivity(): DanaUserOptionsActivity
|
||||
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package info.nightscout.androidaps.dana.events
|
||||
package info.nightscout.pump.dana.events
|
||||
|
||||
import info.nightscout.rx.events.Event
|
||||
|
|
@ -4,7 +4,7 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
tools:context="info.nightscout.androidaps.dana.DanaFragment">
|
||||
tools:context="info.nightscout.pump.dana.DanaFragment">
|
||||
|
||||
<ScrollView
|
||||
android:id="@+id/scrollview"
|
||||
|
@ -193,7 +193,7 @@
|
|||
tools:ignore="HardcodedText" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/lastconnection"
|
||||
android:id="@+id/last_connection"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
|
@ -241,7 +241,7 @@
|
|||
tools:ignore="HardcodedText" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/lastbolus"
|
||||
android:id="@+id/last_bolus"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
|
@ -272,7 +272,7 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:paddingEnd="5dp"
|
||||
android:text="@string/dailyunits"
|
||||
android:text="@string/daily_units"
|
||||
android:textAlignment="viewEnd"
|
||||
android:textSize="14sp"
|
||||
tools:ignore="RtlSymmetry" />
|
||||
|
@ -289,7 +289,7 @@
|
|||
tools:ignore="HardcodedText" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/dailyunits"
|
||||
android:id="@+id/daily_units"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
|
@ -337,7 +337,7 @@
|
|||
tools:ignore="HardcodedText" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/basabasalrate"
|
||||
android:id="@+id/base_basal_rate"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
|
@ -560,7 +560,7 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:paddingEnd="5dp"
|
||||
android:text="@string/virtualpump_firmware_label"
|
||||
android:text="@string/firmware_label"
|
||||
android:textAlignment="viewEnd"
|
||||
android:textSize="14sp"
|
||||
tools:ignore="RtlSymmetry" />
|
||||
|
@ -667,10 +667,10 @@
|
|||
android:layout_height="match_parent"
|
||||
android:layout_marginEnd="-2dp"
|
||||
android:layout_weight="1"
|
||||
android:drawableTop="@drawable/ic_danarprofile"
|
||||
android:drawableTop="@drawable/ic_dana_profile"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="2"
|
||||
android:text="@string/viewprofile"
|
||||
android:text="@string/view_profile"
|
||||
app:iconPadding="-4dp" />
|
||||
|
||||
<info.nightscout.core.ui.elements.SingleClickButton
|
||||
|
@ -683,7 +683,7 @@
|
|||
android:drawableTop="@drawable/ic_pump_history"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="2"
|
||||
android:text="@string/pumphistory"
|
||||
android:text="@string/pump_history"
|
||||
app:iconPadding="-4dp"
|
||||
tools:ignore="TooManyViews" />
|
||||
|
||||
|
@ -694,7 +694,7 @@
|
|||
android:layout_height="match_parent"
|
||||
android:layout_marginEnd="-2dp"
|
||||
android:layout_weight="1"
|
||||
android:drawableTop="@drawable/ic_danarstats"
|
||||
android:drawableTop="@drawable/ic_stats"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="2"
|
||||
android:text="@string/stats"
|
||||
|
@ -707,10 +707,10 @@
|
|||
android:layout_height="match_parent"
|
||||
android:layout_marginEnd="-2dp"
|
||||
android:layout_weight="1"
|
||||
android:drawableTop="@drawable/ic_danar_useropt"
|
||||
android:drawableTop="@drawable/ic_user_options"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="2"
|
||||
android:text="@string/danar_useroptions"
|
||||
android:text="@string/danar_user_options"
|
||||
app:iconPadding="-4dp" />
|
||||
|
||||
</LinearLayout>
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
android:id="@+id/relativeLayout"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
tools:context="info.nightscout.androidaps.dana.activities.DanaHistoryActivity">
|
||||
tools:context="info.nightscout.pump.dana.activities.DanaHistoryActivity">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/header"
|
||||
|
@ -39,7 +39,7 @@
|
|||
android:layout_gravity="center"
|
||||
android:layout_marginStart="10dp"
|
||||
android:layout_marginEnd="10dp"
|
||||
android:text="@string/pumphistory"
|
||||
android:text="@string/pump_history"
|
||||
android:textAlignment="center"
|
||||
android:textAppearance="?android:attr/textAppearanceLarge"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
|
@ -56,7 +56,7 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="5dp"
|
||||
android:layout_marginEnd="5dp"
|
||||
android:hint="@string/eventtype"
|
||||
android:hint="@string/event_type"
|
||||
app:layout_constraintBottom_toTopOf="@+id/status"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
android:fillViewport="true"
|
||||
android:focusable="true"
|
||||
android:focusableInTouchMode="true"
|
||||
tools:context="info.nightscout.androidaps.dana.activities.DanaUserOptionsActivity">
|
||||
tools:context="info.nightscout.pump.dana.activities.DanaUserOptionsActivity">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
|
@ -26,7 +26,7 @@
|
|||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:importantForAccessibility="no"
|
||||
app:srcCompat="@drawable/ic_danar_useropt" />
|
||||
app:srcCompat="@drawable/ic_user_options" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
|
@ -49,14 +49,14 @@
|
|||
android:padding="5dp" />
|
||||
|
||||
<com.google.android.material.switchmaterial.SwitchMaterial
|
||||
android:id="@+id/timeformat"
|
||||
android:id="@+id/time_format"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="20dp"
|
||||
android:layout_marginEnd="20dp"
|
||||
android:text="@string/danar_timedisplay"
|
||||
android:textOff="@string/timeformat12h"
|
||||
android:textOn="@string/timeformat24h"
|
||||
android:text="@string/danar_time_display"
|
||||
android:textOff="@string/time_format_12h"
|
||||
android:textOn="@string/time_format_24h"
|
||||
app:showText="true" />
|
||||
|
||||
<View
|
||||
|
@ -69,12 +69,12 @@
|
|||
android:background="?android:attr/dividerHorizontal" />
|
||||
|
||||
<com.google.android.material.switchmaterial.SwitchMaterial
|
||||
android:id="@+id/buttonscroll"
|
||||
android:id="@+id/button_scroll"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="20dp"
|
||||
android:layout_marginEnd="20dp"
|
||||
android:text="@string/danar_buttonscroll"
|
||||
android:text="@string/danar_button_scroll"
|
||||
android:textOff="@string/option_off"
|
||||
android:textOn="@string/option_on"
|
||||
app:showText="true" />
|
||||
|
@ -120,33 +120,33 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:gravity="start"
|
||||
android:text="@string/danar_pumpalarm"
|
||||
android:text="@string/danar_pump_alarm"
|
||||
android:textSize="14sp" />
|
||||
|
||||
<RadioGroup
|
||||
android:id="@+id/pumpalarm"
|
||||
android:id="@+id/pump_alarm"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:checkedButton="@+id/pumpalarm_sound"
|
||||
android:checkedButton="@+id/pump_alarm_sound"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<RadioButton
|
||||
android:id="@+id/pumpalarm_sound"
|
||||
android:id="@+id/pump_alarm_sound"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/danar_pumpalarm_sound" />
|
||||
android:text="@string/danar_pump_alarm_sound" />
|
||||
|
||||
<RadioButton
|
||||
android:id="@+id/pumpalarm_vibrate"
|
||||
android:id="@+id/pump_alarm_vibrate"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/danar_pumpalarm_vibrate" />
|
||||
android:text="@string/danar_pump_alarm_vibrate" />
|
||||
|
||||
<RadioButton
|
||||
android:id="@+id/pumpalarm_both"
|
||||
android:id="@+id/pump_alarm_both"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/danar_pumpalarm_both" />
|
||||
android:text="@string/danar_pump_alarm_both" />
|
||||
|
||||
</RadioGroup>
|
||||
|
||||
|
@ -174,11 +174,11 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:gravity="top"
|
||||
android:text="@string/danar_screentimeout"
|
||||
android:text="@string/danar_screen_timeout"
|
||||
android:textSize="14sp" />
|
||||
|
||||
<info.nightscout.core.ui.elements.NumberPicker
|
||||
android:id="@+id/screentimeout"
|
||||
android:id="@+id/screen_timeout"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="40dp"
|
||||
android:layout_gravity="end"
|
||||
|
@ -240,7 +240,7 @@
|
|||
android:layout_marginStart="20dp"
|
||||
android:layout_marginEnd="20dp"
|
||||
android:splitTrack="false"
|
||||
android:text="@string/danar_glucoseunits"
|
||||
android:text="@string/danar_glucose_units"
|
||||
android:textOff="@string/mgdl"
|
||||
android:textOn="@string/mmol"
|
||||
app:showText="true" />
|
||||
|
@ -304,11 +304,11 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:gravity="start"
|
||||
android:text="@string/danar_lowreservoir"
|
||||
android:text="@string/danar_low_reservoir"
|
||||
android:textSize="14sp" />
|
||||
|
||||
<info.nightscout.core.ui.elements.NumberPicker
|
||||
android:id="@+id/lowreservoir"
|
||||
android:id="@+id/low_reservoir"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="40dp"
|
||||
android:layout_gravity="end"
|
||||
|
@ -323,7 +323,7 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:drawableStart="@drawable/ic_local_save"
|
||||
android:text="@string/danar_saveuseroptions" />
|
||||
android:text="@string/danar_save_user_options" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
|
|
@ -80,20 +80,20 @@
|
|||
<string name="danar_history_refill">Refill</string>
|
||||
<string name="danar_history_syspend">Suspend</string>
|
||||
<string name="danar_history_prime">Prime</string>
|
||||
<string name="danar_useroptions">User options</string>
|
||||
<string name="danar_timedisplay">Display time format</string>
|
||||
<string name="danar_buttonscroll">Button scroll</string>
|
||||
<string name="danar_user_options">User options</string>
|
||||
<string name="danar_time_display">Display time format</string>
|
||||
<string name="danar_button_scroll">Button scroll</string>
|
||||
<string name="danar_beep">Beep on button press</string>
|
||||
<string name="danar_pumpalarm">Alarm</string>
|
||||
<string name="danar_pumpalarm_sound">Sound</string>
|
||||
<string name="danar_pumpalarm_vibrate">Vibrate</string>
|
||||
<string name="danar_pumpalarm_both">Both</string>
|
||||
<string name="danar_screentimeout">LCD on time [seconds]</string>
|
||||
<string name="danar_pump_alarm">Alarm</string>
|
||||
<string name="danar_pump_alarm_sound">Sound</string>
|
||||
<string name="danar_pump_alarm_vibrate">Vibrate</string>
|
||||
<string name="danar_pump_alarm_both">Both</string>
|
||||
<string name="danar_screen_timeout">LCD on time [seconds]</string>
|
||||
<string name="danar_backlight">Backlight on time [seconds]</string>
|
||||
<string name="danar_glucoseunits">Glucose units</string>
|
||||
<string name="danar_glucose_units">Glucose units</string>
|
||||
<string name="danar_shutdown">Shutdown [hours]</string>
|
||||
<string name="danar_lowreservoir">Low reservoir [Units]</string>
|
||||
<string name="danar_saveuseroptions">Save options to pump</string>
|
||||
<string name="danar_low_reservoir">Low reservoir [Units]</string>
|
||||
<string name="danar_save_user_options">Save options to pump</string>
|
||||
<string name="description_pump_dana_r">Pump integration for DANA Diabecare R pumps</string>
|
||||
<string name="description_pump_dana_r_korean">Pump integration for domestic DANA Diabecare R pumps</string>
|
||||
<string name="description_pump_dana_r_v2">Pump integration for DANA Diabecare R pumps with upgraded firmware</string>
|
||||
|
@ -109,10 +109,10 @@
|
|||
<string name="profile_set_failed">Setting of basal profile failed</string>
|
||||
<string name="danar_bluetooth_status">Bluetooth status</string>
|
||||
<string name="danar_iob_label">Pump IOB</string>
|
||||
<string name="virtualpump_firmware_label">Firmware</string>
|
||||
<string name="firmware_label">Firmware</string>
|
||||
<string name="danar_pump_settings">Dana pump settings</string>
|
||||
<string name="timeformat12h">12h</string>
|
||||
<string name="timeformat24h">24h</string>
|
||||
<string name="time_format_12h">12h</string>
|
||||
<string name="time_format_24h">24h</string>
|
||||
<string name="option_on">On</string>
|
||||
<string name="option_off">Off</string>
|
||||
<string name="danar_bt_name_title">DanaR Bluetooth device</string>
|
||||
|
|
|
@ -0,0 +1,107 @@
|
|||
package info.nightscout.androidaps
|
||||
|
||||
import androidx.collection.ArrayMap
|
||||
import dagger.android.HasAndroidInjector
|
||||
import info.nightscout.androidaps.extensions.pureProfileFromJson
|
||||
import info.nightscout.core.profile.ProfileSealed
|
||||
import info.nightscout.interfaces.Config
|
||||
import info.nightscout.interfaces.plugin.ActivePlugin
|
||||
import info.nightscout.interfaces.profile.ProfileStore
|
||||
import info.nightscout.interfaces.profile.PureProfile
|
||||
import info.nightscout.interfaces.utils.HardLimits
|
||||
import info.nightscout.interfaces.utils.JsonHelper
|
||||
import info.nightscout.rx.bus.RxBus
|
||||
import info.nightscout.rx.logging.AAPSLogger
|
||||
import info.nightscout.shared.interfaces.ResourceHelper
|
||||
import info.nightscout.shared.utils.DateUtil
|
||||
import org.json.JSONException
|
||||
import org.json.JSONObject
|
||||
import javax.inject.Inject
|
||||
|
||||
class ProfileStoreObject(val injector: HasAndroidInjector, override val data: JSONObject, val dateUtil: DateUtil) : ProfileStore {
|
||||
|
||||
@Inject lateinit var aapsLogger: AAPSLogger
|
||||
@Inject lateinit var activePlugin: ActivePlugin
|
||||
@Inject lateinit var config: Config
|
||||
@Inject lateinit var rh: ResourceHelper
|
||||
@Inject lateinit var rxBus: RxBus
|
||||
@Inject lateinit var hardLimits: HardLimits
|
||||
|
||||
init {
|
||||
injector.androidInjector().inject(this)
|
||||
}
|
||||
|
||||
private val cachedObjects = ArrayMap<String, PureProfile>()
|
||||
|
||||
private fun storeUnits(): String? = JsonHelper.safeGetStringAllowNull(data, "units", null)
|
||||
|
||||
private fun getStore(): JSONObject? {
|
||||
try {
|
||||
if (data.has("store")) return data.getJSONObject("store")
|
||||
} catch (e: JSONException) {
|
||||
aapsLogger.error("Unhandled exception", e)
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
override fun getStartDate(): Long {
|
||||
val iso = JsonHelper.safeGetString(data, "startDate") ?: return 0
|
||||
return try {
|
||||
dateUtil.fromISODateString(iso)
|
||||
} catch (e: Exception) {
|
||||
0
|
||||
}
|
||||
}
|
||||
|
||||
override fun getDefaultProfile(): PureProfile? = getDefaultProfileName()?.let { getSpecificProfile(it) }
|
||||
override fun getDefaultProfileJson(): JSONObject? = getDefaultProfileName()?.let { getSpecificProfileJson(it) }
|
||||
|
||||
override fun getDefaultProfileName(): String? {
|
||||
val defaultProfileName = data.optString("defaultProfile")
|
||||
return if (defaultProfileName.isNotEmpty()) getStore()?.has(defaultProfileName)?.let { defaultProfileName } else null
|
||||
}
|
||||
|
||||
override fun getProfileList(): ArrayList<CharSequence> {
|
||||
val ret = ArrayList<CharSequence>()
|
||||
getStore()?.keys()?.let { keys ->
|
||||
while (keys.hasNext()) {
|
||||
val profileName = keys.next() as String
|
||||
ret.add(profileName)
|
||||
}
|
||||
}
|
||||
return ret
|
||||
}
|
||||
|
||||
@Synchronized
|
||||
override fun getSpecificProfile(profileName: String): PureProfile? {
|
||||
var profile: PureProfile? = null
|
||||
val units = JsonHelper.safeGetStringAllowNull(data, "units", storeUnits())
|
||||
getStore()?.let { store ->
|
||||
if (store.has(profileName)) {
|
||||
profile = cachedObjects[profileName]
|
||||
if (profile == null) {
|
||||
JsonHelper.safeGetJSONObject(store, profileName, null)?.let { profileObject ->
|
||||
profile = pureProfileFromJson(profileObject, dateUtil, units)
|
||||
profile?.let { cachedObjects[profileName] = profile }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return profile
|
||||
}
|
||||
|
||||
private fun getSpecificProfileJson(profileName: String): JSONObject? {
|
||||
getStore()?.let { store ->
|
||||
if (store.has(profileName))
|
||||
return JsonHelper.safeGetJSONObject(store, profileName, null)
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
override val allProfilesValid: Boolean
|
||||
get() = getProfileList()
|
||||
.asSequence()
|
||||
.map { profileName -> getSpecificProfile(profileName.toString()) }
|
||||
.map { pureProfile -> pureProfile?.let { ProfileSealed.Pure(pureProfile).isValid("allProfilesValid", activePlugin.activePump, config, rh, rxBus, hardLimits, false) } }
|
||||
.all { it?.isValid == true }
|
||||
}
|
|
@ -2,14 +2,10 @@ package info.nightscout.androidaps
|
|||
|
||||
import dagger.android.AndroidInjector
|
||||
import dagger.android.HasAndroidInjector
|
||||
import info.nightscout.androidaps.extensions.pureProfileFromJson
|
||||
import info.nightscout.core.profile.ProfileSealed
|
||||
import info.nightscout.core.profile.ProfileStoreObject
|
||||
import info.nightscout.core.utils.fabric.FabricPrivacy
|
||||
import info.nightscout.interfaces.Config
|
||||
import info.nightscout.interfaces.plugin.ActivePlugin
|
||||
import info.nightscout.interfaces.profile.DefaultValueHelper
|
||||
import info.nightscout.interfaces.profile.Profile
|
||||
import info.nightscout.interfaces.profile.ProfileFunction
|
||||
import info.nightscout.interfaces.profile.ProfileStore
|
||||
import info.nightscout.rx.bus.RxBus
|
||||
|
@ -38,7 +34,6 @@ open class TestBaseWithProfile : TestBase() {
|
|||
}
|
||||
|
||||
private lateinit var validProfileJSON: String
|
||||
lateinit var validProfile: Profile
|
||||
@Suppress("PropertyName") val TESTPROFILENAME = "someProfile"
|
||||
|
||||
@Before
|
||||
|
@ -46,7 +41,6 @@ open class TestBaseWithProfile : TestBase() {
|
|||
validProfileJSON = "{\"dia\":\"5\",\"carbratio\":[{\"time\":\"00:00\",\"value\":\"30\"}],\"carbs_hr\":\"20\",\"delay\":\"20\",\"sens\":[{\"time\":\"00:00\",\"value\":\"3\"}," +
|
||||
"{\"time\":\"2:00\",\"value\":\"3.4\"}],\"timezone\":\"UTC\",\"basal\":[{\"time\":\"00:00\",\"value\":\"1\"}],\"target_low\":[{\"time\":\"00:00\",\"value\":\"4.5\"}]," +
|
||||
"\"target_high\":[{\"time\":\"00:00\",\"value\":\"7\"}],\"startDate\":\"1970-01-01T00:00:00.000Z\",\"units\":\"mmol\"}"
|
||||
validProfile = ProfileSealed.Pure(pureProfileFromJson(JSONObject(validProfileJSON), dateUtil)!!)
|
||||
}
|
||||
|
||||
fun getValidProfileStore(): ProfileStore {
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package info.nightscout.androidaps.dana
|
||||
|
||||
import info.nightscout.androidaps.TestBaseWithProfile
|
||||
import info.nightscout.interfaces.profile.ProfileInstantiator
|
||||
import info.nightscout.pump.dana.DanaPump
|
||||
import info.nightscout.shared.sharedPreferences.SP
|
||||
import org.junit.Assert
|
||||
import org.junit.Before
|
||||
|
@ -10,12 +12,13 @@ import org.mockito.Mock
|
|||
class DanaPumpTest : TestBaseWithProfile() {
|
||||
|
||||
@Mock lateinit var sp: SP
|
||||
@Mock lateinit var profileInstantiator: ProfileInstantiator
|
||||
|
||||
private lateinit var sut: DanaPump
|
||||
|
||||
@Before
|
||||
fun setup() {
|
||||
sut = DanaPump(aapsLogger, sp, dateUtil, profileInjector)
|
||||
sut = DanaPump(aapsLogger, sp, dateUtil, profileInstantiator)
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -6,7 +6,6 @@ import android.content.Intent
|
|||
import android.content.ServiceConnection
|
||||
import android.os.IBinder
|
||||
import dagger.android.HasAndroidInjector
|
||||
import info.nightscout.androidaps.dana.DanaPump
|
||||
import info.nightscout.androidaps.danaRKorean.services.DanaRKoreanExecutionService
|
||||
import info.nightscout.androidaps.danar.AbstractDanaRPlugin
|
||||
import info.nightscout.androidaps.danar.R
|
||||
|
@ -22,6 +21,7 @@ import info.nightscout.interfaces.pump.PumpSync.TemporaryBasalType
|
|||
import info.nightscout.interfaces.pump.defs.PumpType
|
||||
import info.nightscout.interfaces.queue.CommandQueue
|
||||
import info.nightscout.interfaces.utils.Round
|
||||
import info.nightscout.pump.dana.DanaPump
|
||||
import info.nightscout.rx.AapsSchedulers
|
||||
import info.nightscout.rx.bus.RxBus
|
||||
import info.nightscout.rx.events.EventAppExit
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
package info.nightscout.androidaps.danaRKorean.comm
|
||||
|
||||
import dagger.android.HasAndroidInjector
|
||||
import info.nightscout.androidaps.dana.DanaPump
|
||||
import info.nightscout.androidaps.danar.comm.MessageBase
|
||||
import info.nightscout.pump.dana.DanaPump
|
||||
import info.nightscout.rx.logging.LTag
|
||||
|
||||
|
||||
class MsgCheckValue_k(
|
||||
injector: HasAndroidInjector
|
||||
) : MessageBase(injector) {
|
||||
|
|
|
@ -8,8 +8,6 @@ import java.io.IOException;
|
|||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import info.nightscout.androidaps.dana.DanaPump;
|
||||
import info.nightscout.androidaps.dana.events.EventDanaRNewStatus;
|
||||
import info.nightscout.androidaps.danaRKorean.DanaRKoreanPlugin;
|
||||
import info.nightscout.androidaps.danaRKorean.comm.MessageHashTableRKorean;
|
||||
import info.nightscout.androidaps.danaRKorean.comm.MsgCheckValue_k;
|
||||
|
@ -49,6 +47,8 @@ import info.nightscout.interfaces.pump.PumpSync;
|
|||
import info.nightscout.interfaces.pump.defs.PumpType;
|
||||
import info.nightscout.interfaces.queue.Command;
|
||||
import info.nightscout.interfaces.queue.CommandQueue;
|
||||
import info.nightscout.pump.dana.DanaPump;
|
||||
import info.nightscout.pump.dana.events.EventDanaRNewStatus;
|
||||
import info.nightscout.rx.bus.RxBus;
|
||||
import info.nightscout.rx.events.EventInitializationChanged;
|
||||
import info.nightscout.rx.events.EventOverviewBolusProgress;
|
||||
|
|
|
@ -12,7 +12,6 @@ import javax.inject.Inject;
|
|||
import javax.inject.Singleton;
|
||||
|
||||
import dagger.android.HasAndroidInjector;
|
||||
import info.nightscout.androidaps.dana.DanaPump;
|
||||
import info.nightscout.androidaps.danaRv2.services.DanaRv2ExecutionService;
|
||||
import info.nightscout.androidaps.danar.AbstractDanaRPlugin;
|
||||
import info.nightscout.androidaps.danar.R;
|
||||
|
@ -29,6 +28,7 @@ import info.nightscout.interfaces.pump.TemporaryBasalStorage;
|
|||
import info.nightscout.interfaces.pump.defs.PumpType;
|
||||
import info.nightscout.interfaces.queue.CommandQueue;
|
||||
import info.nightscout.interfaces.utils.Round;
|
||||
import info.nightscout.pump.dana.DanaPump;
|
||||
import info.nightscout.rx.AapsSchedulers;
|
||||
import info.nightscout.rx.bus.RxBus;
|
||||
import info.nightscout.rx.events.EventAppExit;
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
package info.nightscout.androidaps.danaRv2.comm
|
||||
|
||||
import dagger.android.HasAndroidInjector
|
||||
import info.nightscout.androidaps.dana.DanaPump
|
||||
import info.nightscout.androidaps.danar.R
|
||||
import info.nightscout.androidaps.danar.comm.MessageBase
|
||||
import info.nightscout.core.events.EventNewNotification
|
||||
import info.nightscout.interfaces.notifications.Notification
|
||||
import info.nightscout.interfaces.plugin.PluginType
|
||||
import info.nightscout.pump.dana.DanaPump
|
||||
import info.nightscout.rx.events.EventRebuildTabs
|
||||
import info.nightscout.rx.logging.LTag
|
||||
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
package info.nightscout.androidaps.danaRv2.comm
|
||||
|
||||
import dagger.android.HasAndroidInjector
|
||||
import info.nightscout.androidaps.dana.DanaPump
|
||||
import info.nightscout.androidaps.danar.R
|
||||
import info.nightscout.androidaps.danar.comm.MessageBase
|
||||
import info.nightscout.interfaces.pump.defs.PumpType
|
||||
import info.nightscout.pump.dana.DanaPump
|
||||
import info.nightscout.rx.events.EventPumpStatusChanged
|
||||
import info.nightscout.rx.logging.LTag
|
||||
import info.nightscout.shared.utils.T
|
||||
|
|
|
@ -10,8 +10,6 @@ import java.io.IOException;
|
|||
import javax.inject.Inject;
|
||||
|
||||
import dagger.android.HasAndroidInjector;
|
||||
import info.nightscout.androidaps.dana.DanaPump;
|
||||
import info.nightscout.androidaps.dana.events.EventDanaRNewStatus;
|
||||
import info.nightscout.androidaps.danaRKorean.DanaRKoreanPlugin;
|
||||
import info.nightscout.androidaps.danaRv2.DanaRv2Plugin;
|
||||
import info.nightscout.androidaps.danaRv2.comm.MessageHashTableRv2;
|
||||
|
@ -63,6 +61,8 @@ import info.nightscout.interfaces.queue.Callback;
|
|||
import info.nightscout.interfaces.queue.Command;
|
||||
import info.nightscout.interfaces.queue.CommandQueue;
|
||||
import info.nightscout.interfaces.ui.ActivityNames;
|
||||
import info.nightscout.pump.dana.DanaPump;
|
||||
import info.nightscout.pump.dana.events.EventDanaRNewStatus;
|
||||
import info.nightscout.rx.bus.RxBus;
|
||||
import info.nightscout.rx.events.EventInitializationChanged;
|
||||
import info.nightscout.rx.events.EventOverviewBolusProgress;
|
||||
|
|
|
@ -6,9 +6,6 @@ import org.json.JSONException;
|
|||
import org.json.JSONObject;
|
||||
|
||||
import dagger.android.HasAndroidInjector;
|
||||
import info.nightscout.androidaps.dana.DanaFragment;
|
||||
import info.nightscout.androidaps.dana.DanaPump;
|
||||
import info.nightscout.androidaps.dana.comm.RecordTypes;
|
||||
import info.nightscout.androidaps.danar.services.AbstractDanaRExecutionService;
|
||||
import info.nightscout.core.events.EventNewNotification;
|
||||
import info.nightscout.interfaces.constraints.Constraint;
|
||||
|
@ -28,6 +25,9 @@ import info.nightscout.interfaces.pump.defs.PumpDescription;
|
|||
import info.nightscout.interfaces.queue.CommandQueue;
|
||||
import info.nightscout.interfaces.utils.DecimalFormatter;
|
||||
import info.nightscout.interfaces.utils.Round;
|
||||
import info.nightscout.pump.dana.DanaFragment;
|
||||
import info.nightscout.pump.dana.DanaPump;
|
||||
import info.nightscout.pump.dana.comm.RecordTypes;
|
||||
import info.nightscout.rx.AapsSchedulers;
|
||||
import info.nightscout.rx.bus.RxBus;
|
||||
import info.nightscout.rx.events.EventConfigBuilderChange;
|
||||
|
|
|
@ -12,7 +12,6 @@ import javax.inject.Inject;
|
|||
import javax.inject.Singleton;
|
||||
|
||||
import dagger.android.HasAndroidInjector;
|
||||
import info.nightscout.androidaps.dana.DanaPump;
|
||||
import info.nightscout.androidaps.danar.services.DanaRExecutionService;
|
||||
import info.nightscout.core.utils.fabric.FabricPrivacy;
|
||||
import info.nightscout.interfaces.constraints.Constraint;
|
||||
|
@ -25,6 +24,7 @@ import info.nightscout.interfaces.pump.PumpSync;
|
|||
import info.nightscout.interfaces.pump.defs.PumpType;
|
||||
import info.nightscout.interfaces.queue.CommandQueue;
|
||||
import info.nightscout.interfaces.utils.Round;
|
||||
import info.nightscout.pump.dana.DanaPump;
|
||||
import info.nightscout.rx.AapsSchedulers;
|
||||
import info.nightscout.rx.bus.RxBus;
|
||||
import info.nightscout.rx.events.EventAppExit;
|
||||
|
|
|
@ -7,10 +7,10 @@ import java.io.IOException;
|
|||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
|
||||
import info.nightscout.androidaps.dana.DanaPump;
|
||||
import info.nightscout.androidaps.danar.comm.MessageBase;
|
||||
import info.nightscout.androidaps.danar.comm.MessageHashTableBase;
|
||||
import info.nightscout.androidaps.utils.CRC;
|
||||
import info.nightscout.pump.dana.DanaPump;
|
||||
import info.nightscout.rx.logging.AAPSLogger;
|
||||
import info.nightscout.rx.logging.LTag;
|
||||
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
package info.nightscout.androidaps.danar.comm
|
||||
|
||||
import dagger.android.HasAndroidInjector
|
||||
import info.nightscout.androidaps.dana.DanaPump
|
||||
import info.nightscout.androidaps.dana.database.DanaHistoryRecordDao
|
||||
import info.nightscout.androidaps.danaRKorean.DanaRKoreanPlugin
|
||||
import info.nightscout.androidaps.danaRv2.DanaRv2Plugin
|
||||
import info.nightscout.androidaps.danar.DanaRPlugin
|
||||
|
@ -15,6 +13,8 @@ import info.nightscout.interfaces.pump.DetailedBolusInfoStorage
|
|||
import info.nightscout.interfaces.pump.PumpSync
|
||||
import info.nightscout.interfaces.pump.TemporaryBasalStorage
|
||||
import info.nightscout.interfaces.queue.CommandQueue
|
||||
import info.nightscout.pump.dana.DanaPump
|
||||
import info.nightscout.pump.dana.database.DanaHistoryRecordDao
|
||||
import info.nightscout.rx.bus.RxBus
|
||||
import info.nightscout.rx.logging.AAPSLogger
|
||||
import info.nightscout.rx.logging.LTag
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package info.nightscout.androidaps.danar.comm
|
||||
|
||||
import dagger.android.HasAndroidInjector
|
||||
import info.nightscout.androidaps.dana.DanaPump
|
||||
import info.nightscout.pump.dana.DanaPump
|
||||
import info.nightscout.rx.logging.LTag
|
||||
|
||||
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
package info.nightscout.androidaps.danar.comm
|
||||
|
||||
import dagger.android.HasAndroidInjector
|
||||
import info.nightscout.androidaps.dana.comm.RecordTypes
|
||||
import info.nightscout.androidaps.dana.database.DanaHistoryRecord
|
||||
import info.nightscout.shared.utils.T
|
||||
import info.nightscout.pump.dana.comm.RecordTypes
|
||||
import info.nightscout.pump.dana.database.DanaHistoryRecord
|
||||
import info.nightscout.rx.events.EventDanaRSyncStatus
|
||||
import info.nightscout.rx.logging.LTag
|
||||
import info.nightscout.shared.utils.T
|
||||
|
||||
open class MsgHistoryAll(
|
||||
injector: HasAndroidInjector
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package info.nightscout.androidaps.danar.comm
|
||||
|
||||
import dagger.android.HasAndroidInjector
|
||||
import info.nightscout.pump.dana.DanaPump
|
||||
import info.nightscout.rx.logging.LTag
|
||||
|
||||
|
||||
|
@ -32,10 +33,10 @@ class MsgInitConnStatusBasic(
|
|||
val extendedBolusRate = intFromBuff(bytes, 18, 2) / 100.0
|
||||
danaPump.batteryRemaining = intFromBuff(bytes, 20, 1)
|
||||
val bolusConfig = intFromBuff(bytes, 21, 1)
|
||||
val deliveryPrime = bolusConfig and info.nightscout.androidaps.dana.DanaPump.DELIVERY_PRIME != 0
|
||||
val deliveryStepBolus = bolusConfig and info.nightscout.androidaps.dana.DanaPump.DELIVERY_STEP_BOLUS != 0
|
||||
val deliveryBasal = bolusConfig and info.nightscout.androidaps.dana.DanaPump.DELIVERY_BASAL != 0
|
||||
val deliveryExtBolus = bolusConfig and info.nightscout.androidaps.dana.DanaPump.DELIVERY_EXT_BOLUS != 0
|
||||
val deliveryPrime = bolusConfig and DanaPump.DELIVERY_PRIME != 0
|
||||
val deliveryStepBolus = bolusConfig and DanaPump.DELIVERY_STEP_BOLUS != 0
|
||||
val deliveryBasal = bolusConfig and DanaPump.DELIVERY_BASAL != 0
|
||||
val deliveryExtBolus = bolusConfig and DanaPump.DELIVERY_EXT_BOLUS != 0
|
||||
aapsLogger.debug(LTag.PUMPCOMM, "Delivery prime: $deliveryPrime")
|
||||
aapsLogger.debug(LTag.PUMPCOMM, "Delivery step bolus: $deliveryStepBolus")
|
||||
aapsLogger.debug(LTag.PUMPCOMM, "Delivery basal: $deliveryBasal")
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package info.nightscout.androidaps.danar.comm
|
||||
|
||||
import dagger.android.HasAndroidInjector
|
||||
import info.nightscout.pump.dana.comm.RecordTypes
|
||||
import info.nightscout.rx.logging.LTag
|
||||
import java.util.Calendar
|
||||
|
||||
|
@ -15,7 +16,7 @@ class MsgSetCarbsEntry(
|
|||
aapsLogger.debug(LTag.PUMPBTCOMM, "New message")
|
||||
val calendar = Calendar.getInstance()
|
||||
calendar.timeInMillis = time
|
||||
addParamByte(info.nightscout.androidaps.dana.comm.RecordTypes.RECORD_TYPE_CARBO)
|
||||
addParamByte(RecordTypes.RECORD_TYPE_CARBO)
|
||||
addParamByte((calendar[Calendar.YEAR] % 100).toByte())
|
||||
addParamByte((calendar[Calendar.MONTH] + 1).toByte())
|
||||
addParamByte(calendar[Calendar.DAY_OF_MONTH].toByte())
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package info.nightscout.androidaps.danar.comm
|
||||
|
||||
import dagger.android.HasAndroidInjector
|
||||
import info.nightscout.androidaps.dana.DanaPump
|
||||
import info.nightscout.pump.dana.DanaPump
|
||||
import info.nightscout.rx.logging.LTag
|
||||
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package info.nightscout.androidaps.danar.comm
|
||||
|
||||
import dagger.android.HasAndroidInjector
|
||||
import info.nightscout.androidaps.dana.DanaPump
|
||||
import info.nightscout.pump.dana.DanaPump
|
||||
import info.nightscout.rx.logging.LTag
|
||||
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package info.nightscout.androidaps.danar.comm
|
||||
|
||||
import dagger.android.HasAndroidInjector
|
||||
import info.nightscout.androidaps.dana.DanaPump
|
||||
import info.nightscout.pump.dana.DanaPump
|
||||
import info.nightscout.rx.logging.LTag
|
||||
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package info.nightscout.androidaps.danar.comm
|
||||
|
||||
import dagger.android.HasAndroidInjector
|
||||
import info.nightscout.androidaps.dana.DanaPump
|
||||
import info.nightscout.pump.dana.DanaPump
|
||||
import info.nightscout.rx.logging.LTag
|
||||
|
||||
|
||||
|
|
|
@ -22,8 +22,6 @@ import javax.inject.Inject;
|
|||
|
||||
import dagger.android.DaggerService;
|
||||
import dagger.android.HasAndroidInjector;
|
||||
import info.nightscout.androidaps.dana.DanaPump;
|
||||
import info.nightscout.androidaps.dana.comm.RecordTypes;
|
||||
import info.nightscout.androidaps.danar.R;
|
||||
import info.nightscout.androidaps.danar.SerialIOThread;
|
||||
import info.nightscout.androidaps.danar.comm.MessageBase;
|
||||
|
@ -47,6 +45,8 @@ import info.nightscout.interfaces.plugin.ActivePlugin;
|
|||
import info.nightscout.interfaces.profile.Profile;
|
||||
import info.nightscout.interfaces.pump.PumpEnactResult;
|
||||
import info.nightscout.interfaces.pump.PumpSync;
|
||||
import info.nightscout.pump.dana.DanaPump;
|
||||
import info.nightscout.pump.dana.comm.RecordTypes;
|
||||
import info.nightscout.rx.AapsSchedulers;
|
||||
import info.nightscout.rx.bus.RxBus;
|
||||
import info.nightscout.rx.events.EventAppExit;
|
||||
|
|
|
@ -9,8 +9,6 @@ import java.io.IOException;
|
|||
import javax.inject.Inject;
|
||||
|
||||
import dagger.android.HasAndroidInjector;
|
||||
import info.nightscout.androidaps.dana.DanaPump;
|
||||
import info.nightscout.androidaps.dana.events.EventDanaRNewStatus;
|
||||
import info.nightscout.androidaps.danaRKorean.DanaRKoreanPlugin;
|
||||
import info.nightscout.androidaps.danar.DanaRPlugin;
|
||||
import info.nightscout.androidaps.danar.R;
|
||||
|
@ -55,6 +53,8 @@ import info.nightscout.interfaces.pump.defs.PumpType;
|
|||
import info.nightscout.interfaces.queue.Callback;
|
||||
import info.nightscout.interfaces.queue.Command;
|
||||
import info.nightscout.interfaces.queue.CommandQueue;
|
||||
import info.nightscout.pump.dana.DanaPump;
|
||||
import info.nightscout.pump.dana.events.EventDanaRNewStatus;
|
||||
import info.nightscout.rx.bus.RxBus;
|
||||
import info.nightscout.rx.events.EventInitializationChanged;
|
||||
import info.nightscout.rx.events.EventOverviewBolusProgress;
|
||||
|
|
|
@ -0,0 +1,107 @@
|
|||
package info.nightscout.androidaps
|
||||
|
||||
import androidx.collection.ArrayMap
|
||||
import dagger.android.HasAndroidInjector
|
||||
import info.nightscout.androidaps.extensions.pureProfileFromJson
|
||||
import info.nightscout.core.profile.ProfileSealed
|
||||
import info.nightscout.interfaces.Config
|
||||
import info.nightscout.interfaces.plugin.ActivePlugin
|
||||
import info.nightscout.interfaces.profile.ProfileStore
|
||||
import info.nightscout.interfaces.profile.PureProfile
|
||||
import info.nightscout.interfaces.utils.HardLimits
|
||||
import info.nightscout.interfaces.utils.JsonHelper
|
||||
import info.nightscout.rx.bus.RxBus
|
||||
import info.nightscout.rx.logging.AAPSLogger
|
||||
import info.nightscout.shared.interfaces.ResourceHelper
|
||||
import info.nightscout.shared.utils.DateUtil
|
||||
import org.json.JSONException
|
||||
import org.json.JSONObject
|
||||
import javax.inject.Inject
|
||||
|
||||
class ProfileStoreObject(val injector: HasAndroidInjector, override val data: JSONObject, val dateUtil: DateUtil) : ProfileStore {
|
||||
|
||||
@Inject lateinit var aapsLogger: AAPSLogger
|
||||
@Inject lateinit var activePlugin: ActivePlugin
|
||||
@Inject lateinit var config: Config
|
||||
@Inject lateinit var rh: ResourceHelper
|
||||
@Inject lateinit var rxBus: RxBus
|
||||
@Inject lateinit var hardLimits: HardLimits
|
||||
|
||||
init {
|
||||
injector.androidInjector().inject(this)
|
||||
}
|
||||
|
||||
private val cachedObjects = ArrayMap<String, PureProfile>()
|
||||
|
||||
private fun storeUnits(): String? = JsonHelper.safeGetStringAllowNull(data, "units", null)
|
||||
|
||||
private fun getStore(): JSONObject? {
|
||||
try {
|
||||
if (data.has("store")) return data.getJSONObject("store")
|
||||
} catch (e: JSONException) {
|
||||
aapsLogger.error("Unhandled exception", e)
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
override fun getStartDate(): Long {
|
||||
val iso = JsonHelper.safeGetString(data, "startDate") ?: return 0
|
||||
return try {
|
||||
dateUtil.fromISODateString(iso)
|
||||
} catch (e: Exception) {
|
||||
0
|
||||
}
|
||||
}
|
||||
|
||||
override fun getDefaultProfile(): PureProfile? = getDefaultProfileName()?.let { getSpecificProfile(it) }
|
||||
override fun getDefaultProfileJson(): JSONObject? = getDefaultProfileName()?.let { getSpecificProfileJson(it) }
|
||||
|
||||
override fun getDefaultProfileName(): String? {
|
||||
val defaultProfileName = data.optString("defaultProfile")
|
||||
return if (defaultProfileName.isNotEmpty()) getStore()?.has(defaultProfileName)?.let { defaultProfileName } else null
|
||||
}
|
||||
|
||||
override fun getProfileList(): ArrayList<CharSequence> {
|
||||
val ret = ArrayList<CharSequence>()
|
||||
getStore()?.keys()?.let { keys ->
|
||||
while (keys.hasNext()) {
|
||||
val profileName = keys.next() as String
|
||||
ret.add(profileName)
|
||||
}
|
||||
}
|
||||
return ret
|
||||
}
|
||||
|
||||
@Synchronized
|
||||
override fun getSpecificProfile(profileName: String): PureProfile? {
|
||||
var profile: PureProfile? = null
|
||||
val units = JsonHelper.safeGetStringAllowNull(data, "units", storeUnits())
|
||||
getStore()?.let { store ->
|
||||
if (store.has(profileName)) {
|
||||
profile = cachedObjects[profileName]
|
||||
if (profile == null) {
|
||||
JsonHelper.safeGetJSONObject(store, profileName, null)?.let { profileObject ->
|
||||
profile = pureProfileFromJson(profileObject, dateUtil, units)
|
||||
profile?.let { cachedObjects[profileName] = profile }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return profile
|
||||
}
|
||||
|
||||
private fun getSpecificProfileJson(profileName: String): JSONObject? {
|
||||
getStore()?.let { store ->
|
||||
if (store.has(profileName))
|
||||
return JsonHelper.safeGetJSONObject(store, profileName, null)
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
override val allProfilesValid: Boolean
|
||||
get() = getProfileList()
|
||||
.asSequence()
|
||||
.map { profileName -> getSpecificProfile(profileName.toString()) }
|
||||
.map { pureProfile -> pureProfile?.let { ProfileSealed.Pure(pureProfile).isValid("allProfilesValid", activePlugin.activePump, config, rh, rxBus, hardLimits, false) } }
|
||||
.all { it?.isValid == true }
|
||||
}
|
|
@ -5,7 +5,6 @@ import dagger.android.AndroidInjector
|
|||
import dagger.android.HasAndroidInjector
|
||||
import info.nightscout.androidaps.extensions.pureProfileFromJson
|
||||
import info.nightscout.core.profile.ProfileSealed
|
||||
import info.nightscout.core.profile.ProfileStoreObject
|
||||
import info.nightscout.core.utils.fabric.FabricPrivacy
|
||||
import info.nightscout.interfaces.Config
|
||||
import info.nightscout.interfaces.iob.IobCobCalculator
|
||||
|
|
|
@ -3,15 +3,16 @@ package info.nightscout.androidaps.plugins.pump.danaR
|
|||
import dagger.android.AndroidInjector
|
||||
import dagger.android.HasAndroidInjector
|
||||
import info.nightscout.androidaps.TestBaseWithProfile
|
||||
import info.nightscout.androidaps.dana.DanaPump
|
||||
import info.nightscout.androidaps.danar.DanaRPlugin
|
||||
import info.nightscout.androidaps.danar.R
|
||||
import info.nightscout.interfaces.Constants
|
||||
import info.nightscout.interfaces.constraints.Constraint
|
||||
import info.nightscout.interfaces.constraints.Constraints
|
||||
import info.nightscout.interfaces.plugin.PluginType
|
||||
import info.nightscout.interfaces.profile.ProfileInstantiator
|
||||
import info.nightscout.interfaces.pump.PumpSync
|
||||
import info.nightscout.interfaces.queue.CommandQueue
|
||||
import info.nightscout.pump.dana.DanaPump
|
||||
import info.nightscout.shared.sharedPreferences.SP
|
||||
import org.junit.Assert
|
||||
import org.junit.Before
|
||||
|
@ -25,6 +26,7 @@ class DanaRPluginTest : TestBaseWithProfile() {
|
|||
@Mock lateinit var sp: SP
|
||||
@Mock lateinit var commandQueue: CommandQueue
|
||||
@Mock lateinit var pumpSync: PumpSync
|
||||
@Mock lateinit var profileInstantiator: ProfileInstantiator
|
||||
|
||||
lateinit var danaPump: DanaPump
|
||||
|
||||
|
@ -41,7 +43,7 @@ class DanaRPluginTest : TestBaseWithProfile() {
|
|||
`when`(rh.gs(R.string.itmustbepositivevalue)).thenReturn("it must be positive value")
|
||||
`when`(rh.gs(R.string.limitingbasalratio)).thenReturn("Limiting max basal rate to %1\$.2f U/h because of %2\$s")
|
||||
`when`(rh.gs(R.string.limitingpercentrate)).thenReturn("Limiting max percent rate to %1\$d%% because of %2\$s")
|
||||
danaPump = DanaPump(aapsLogger, sp, dateUtil, injector)
|
||||
danaPump = DanaPump(aapsLogger, sp, dateUtil, profileInstantiator)
|
||||
danaRPlugin = DanaRPlugin(injector, aapsLogger, aapsSchedulers, rxBus, context, rh, constraintChecker, activePluginProvider, sp, commandQueue, danaPump, dateUtil, fabricPrivacy, pumpSync)
|
||||
}
|
||||
|
||||
|
|
|
@ -4,8 +4,6 @@ import dagger.android.AndroidInjector
|
|||
import dagger.android.HasAndroidInjector
|
||||
import info.nightscout.androidaps.TestBase
|
||||
import info.nightscout.androidaps.TestPumpPlugin
|
||||
import info.nightscout.androidaps.dana.DanaPump
|
||||
import info.nightscout.androidaps.dana.database.DanaHistoryRecordDao
|
||||
import info.nightscout.androidaps.danaRKorean.DanaRKoreanPlugin
|
||||
import info.nightscout.androidaps.danaRv2.DanaRv2Plugin
|
||||
import info.nightscout.androidaps.danar.DanaRPlugin
|
||||
|
@ -14,9 +12,12 @@ import info.nightscout.interfaces.ConfigBuilder
|
|||
import info.nightscout.interfaces.constraints.Constraints
|
||||
import info.nightscout.interfaces.plugin.ActivePlugin
|
||||
import info.nightscout.interfaces.profile.ProfileFunction
|
||||
import info.nightscout.interfaces.profile.ProfileInstantiator
|
||||
import info.nightscout.interfaces.pump.DetailedBolusInfoStorage
|
||||
import info.nightscout.interfaces.pump.PumpSync
|
||||
import info.nightscout.interfaces.queue.CommandQueue
|
||||
import info.nightscout.pump.dana.DanaPump
|
||||
import info.nightscout.pump.dana.database.DanaHistoryRecordDao
|
||||
import info.nightscout.rx.bus.RxBus
|
||||
import info.nightscout.shared.interfaces.ResourceHelper
|
||||
import info.nightscout.shared.sharedPreferences.SP
|
||||
|
@ -44,12 +45,13 @@ open class DanaRTestBase : TestBase() {
|
|||
@Mock lateinit var constraintChecker: Constraints
|
||||
@Mock lateinit var pumpSync: PumpSync
|
||||
@Mock lateinit var danaHistoryRecordDao: DanaHistoryRecordDao
|
||||
@Mock lateinit var profileInstantiator: ProfileInstantiator
|
||||
|
||||
private lateinit var testPumpPlugin: TestPumpPlugin
|
||||
|
||||
@Before
|
||||
fun setup() {
|
||||
danaPump = DanaPump(aapsLogger, sp, dateUtil, injector)
|
||||
danaPump = DanaPump(aapsLogger, sp, dateUtil, profileInstantiator)
|
||||
testPumpPlugin = TestPumpPlugin(injector)
|
||||
`when`(activePlugin.activePump).thenReturn(testPumpPlugin)
|
||||
doNothing().`when`(danaRKoreanPlugin).setPluginEnabled(anyObject(), anyBoolean())
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package info.nightscout.androidaps.plugins.pump.danaR.comm
|
||||
|
||||
import info.nightscout.androidaps.dana.DanaPump
|
||||
import info.nightscout.androidaps.danar.comm.MsgCheckValue
|
||||
import info.nightscout.pump.dana.DanaPump
|
||||
import org.junit.Assert
|
||||
import org.junit.Test
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package info.nightscout.androidaps.plugins.pump.danaR.comm
|
||||
|
||||
import info.nightscout.androidaps.dana.DanaPump
|
||||
import info.nightscout.androidaps.danar.comm.MsgSettingProfileRatiosAll
|
||||
import info.nightscout.pump.dana.DanaPump
|
||||
import org.junit.Assert
|
||||
import org.junit.Test
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package info.nightscout.androidaps.plugins.pump.danaR.comm
|
||||
|
||||
import info.nightscout.androidaps.dana.DanaPump
|
||||
import info.nightscout.androidaps.danar.comm.MsgSettingProfileRatios
|
||||
import info.nightscout.pump.dana.DanaPump
|
||||
import org.junit.Assert
|
||||
import org.junit.Test
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package info.nightscout.androidaps.plugins.pump.danaR.comm
|
||||
|
||||
import info.nightscout.androidaps.dana.DanaPump
|
||||
import info.nightscout.androidaps.danar.comm.MsgSettingPumpTime
|
||||
import info.nightscout.pump.dana.DanaPump
|
||||
import org.joda.time.DateTime
|
||||
import org.junit.Assert
|
||||
import org.junit.Test
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package info.nightscout.androidaps.plugins.pump.danaR.comm
|
||||
|
||||
import info.nightscout.androidaps.dana.DanaPump
|
||||
import info.nightscout.androidaps.danar.comm.MessageBase
|
||||
import info.nightscout.androidaps.danar.comm.MsgSettingShippingInfo
|
||||
import info.nightscout.pump.dana.DanaPump
|
||||
import org.junit.Assert
|
||||
import org.junit.Test
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package info.nightscout.androidaps.plugins.pump.danaR.comm
|
||||
|
||||
import info.nightscout.androidaps.dana.DanaPump
|
||||
import info.nightscout.androidaps.danar.comm.MsgSettingUserOptions
|
||||
import info.nightscout.pump.dana.DanaPump
|
||||
import org.junit.Assert
|
||||
import org.junit.Test
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package info.nightscout.androidaps.plugins.pump.danaR.comm
|
||||
|
||||
import info.nightscout.androidaps.dana.DanaPump
|
||||
import info.nightscout.androidaps.danar.comm.MsgStatusProfile
|
||||
import info.nightscout.pump.dana.DanaPump
|
||||
import org.junit.Assert
|
||||
import org.junit.Test
|
||||
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
package info.nightscout.androidaps.plugins.pump.danaR.comm
|
||||
|
||||
import info.nightscout.pump.dana.comm.RecordTypes
|
||||
import org.junit.Assert
|
||||
import org.junit.Test
|
||||
|
||||
class RecordTypesTest {
|
||||
|
||||
@Test fun runTest() {
|
||||
Assert.assertEquals(1.toByte(), info.nightscout.androidaps.dana.comm.RecordTypes.RECORD_TYPE_BOLUS)
|
||||
Assert.assertEquals(1.toByte(), RecordTypes.RECORD_TYPE_BOLUS)
|
||||
}
|
||||
}
|
|
@ -3,15 +3,16 @@ package info.nightscout.androidaps.plugins.pump.danaRKorean
|
|||
import dagger.android.AndroidInjector
|
||||
import dagger.android.HasAndroidInjector
|
||||
import info.nightscout.androidaps.TestBaseWithProfile
|
||||
import info.nightscout.androidaps.dana.DanaPump
|
||||
import info.nightscout.androidaps.danaRKorean.DanaRKoreanPlugin
|
||||
import info.nightscout.androidaps.danar.R
|
||||
import info.nightscout.interfaces.Constants
|
||||
import info.nightscout.interfaces.constraints.Constraint
|
||||
import info.nightscout.interfaces.constraints.Constraints
|
||||
import info.nightscout.interfaces.plugin.PluginType
|
||||
import info.nightscout.interfaces.profile.ProfileInstantiator
|
||||
import info.nightscout.interfaces.pump.PumpSync
|
||||
import info.nightscout.interfaces.queue.CommandQueue
|
||||
import info.nightscout.pump.dana.DanaPump
|
||||
import info.nightscout.shared.sharedPreferences.SP
|
||||
import org.junit.Assert
|
||||
import org.junit.Before
|
||||
|
@ -25,6 +26,7 @@ class DanaRKoreanPluginTest : TestBaseWithProfile() {
|
|||
@Mock lateinit var sp: SP
|
||||
@Mock lateinit var commandQueue: CommandQueue
|
||||
@Mock lateinit var pumpSync: PumpSync
|
||||
@Mock lateinit var profileInstantiator: ProfileInstantiator
|
||||
|
||||
lateinit var danaPump: DanaPump
|
||||
|
||||
|
@ -41,7 +43,7 @@ class DanaRKoreanPluginTest : TestBaseWithProfile() {
|
|||
`when`(rh.gs(R.string.itmustbepositivevalue)).thenReturn("it must be positive value")
|
||||
`when`(rh.gs(R.string.limitingbasalratio)).thenReturn("Limiting max basal rate to %1\$.2f U/h because of %2\$s")
|
||||
`when`(rh.gs(R.string.limitingpercentrate)).thenReturn("Limiting max percent rate to %1\$d%% because of %2\$s")
|
||||
danaPump = DanaPump(aapsLogger, sp, dateUtil, injector)
|
||||
danaPump = DanaPump(aapsLogger, sp, dateUtil, profileInstantiator)
|
||||
danaRPlugin = DanaRKoreanPlugin(injector, aapsLogger, aapsSchedulers, rxBus, context, rh, constraintChecker, activePluginProvider, sp, commandQueue, danaPump, dateUtil, fabricPrivacy, pumpSync)
|
||||
}
|
||||
|
||||
|
|
|
@ -3,17 +3,18 @@ package info.nightscout.androidaps.plugins.pump.danaRv2
|
|||
import dagger.android.AndroidInjector
|
||||
import dagger.android.HasAndroidInjector
|
||||
import info.nightscout.androidaps.TestBaseWithProfile
|
||||
import info.nightscout.androidaps.dana.DanaPump
|
||||
import info.nightscout.androidaps.danaRv2.DanaRv2Plugin
|
||||
import info.nightscout.androidaps.danar.R
|
||||
import info.nightscout.interfaces.Constants
|
||||
import info.nightscout.interfaces.constraints.Constraint
|
||||
import info.nightscout.interfaces.constraints.Constraints
|
||||
import info.nightscout.interfaces.plugin.PluginType
|
||||
import info.nightscout.interfaces.profile.ProfileInstantiator
|
||||
import info.nightscout.interfaces.pump.DetailedBolusInfoStorage
|
||||
import info.nightscout.interfaces.pump.PumpSync
|
||||
import info.nightscout.interfaces.pump.TemporaryBasalStorage
|
||||
import info.nightscout.interfaces.queue.CommandQueue
|
||||
import info.nightscout.pump.dana.DanaPump
|
||||
import info.nightscout.shared.sharedPreferences.SP
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
|
@ -28,6 +29,7 @@ class DanaRv2PluginTest : TestBaseWithProfile() {
|
|||
@Mock lateinit var detailedBolusInfoStorage: DetailedBolusInfoStorage
|
||||
@Mock lateinit var temporaryBasalStorage: TemporaryBasalStorage
|
||||
@Mock lateinit var pumpSync: PumpSync
|
||||
@Mock lateinit var profileInstantiator: ProfileInstantiator
|
||||
|
||||
lateinit var danaPump: DanaPump
|
||||
|
||||
|
@ -44,7 +46,7 @@ class DanaRv2PluginTest : TestBaseWithProfile() {
|
|||
`when`(rh.gs(R.string.itmustbepositivevalue)).thenReturn("it must be positive value")
|
||||
`when`(rh.gs(R.string.limitingbasalratio)).thenReturn("Limiting max basal rate to %1\$.2f U/h because of %2\$s")
|
||||
`when`(rh.gs(R.string.limitingpercentrate)).thenReturn("Limiting max percent rate to %1\$d%% because of %2\$s")
|
||||
danaPump = DanaPump(aapsLogger, sp, dateUtil, injector)
|
||||
danaPump = DanaPump(aapsLogger, sp, dateUtil, profileInstantiator)
|
||||
danaRv2Plugin = DanaRv2Plugin(injector, aapsLogger, aapsSchedulers, rxBus, context, rh, constraintChecker, activePluginProvider, sp, commandQueue, danaPump,detailedBolusInfoStorage, temporaryBasalStorage, dateUtil, fabricPrivacy, pumpSync)
|
||||
}
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package info.nightscout.androidaps.plugins.pump.danaRv2.comm
|
||||
|
||||
import info.nightscout.androidaps.dana.DanaPump
|
||||
import info.nightscout.androidaps.danaRv2.comm.MsgCheckValue_v2
|
||||
import info.nightscout.androidaps.plugins.pump.danaR.comm.DanaRTestBase
|
||||
import info.nightscout.pump.dana.DanaPump
|
||||
import org.junit.Assert
|
||||
import org.junit.Test
|
||||
|
||||
|
|
|
@ -8,9 +8,6 @@ import android.os.IBinder
|
|||
import android.text.format.DateFormat
|
||||
import androidx.preference.Preference
|
||||
import dagger.android.HasAndroidInjector
|
||||
import info.nightscout.androidaps.dana.DanaFragment
|
||||
import info.nightscout.androidaps.dana.DanaPump
|
||||
import info.nightscout.androidaps.dana.comm.RecordTypes
|
||||
import info.nightscout.androidaps.danars.events.EventDanaRSDeviceChange
|
||||
import info.nightscout.androidaps.danars.services.DanaRSService
|
||||
import info.nightscout.core.events.EventNewNotification
|
||||
|
@ -37,6 +34,9 @@ import info.nightscout.interfaces.pump.defs.PumpType
|
|||
import info.nightscout.interfaces.queue.CommandQueue
|
||||
import info.nightscout.interfaces.utils.DecimalFormatter
|
||||
import info.nightscout.interfaces.utils.Round
|
||||
import info.nightscout.pump.dana.DanaFragment
|
||||
import info.nightscout.pump.dana.DanaPump
|
||||
import info.nightscout.pump.dana.comm.RecordTypes
|
||||
import info.nightscout.rx.AapsSchedulers
|
||||
import info.nightscout.rx.bus.RxBus
|
||||
import info.nightscout.rx.events.EventAppExit
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
package info.nightscout.androidaps.danars.comm
|
||||
|
||||
import dagger.android.HasAndroidInjector
|
||||
import info.nightscout.androidaps.dana.DanaPump
|
||||
import info.nightscout.androidaps.danars.R
|
||||
import info.nightscout.androidaps.danars.encryption.BleEncryption
|
||||
import info.nightscout.interfaces.pump.DetailedBolusInfo
|
||||
import info.nightscout.interfaces.pump.DetailedBolusInfoStorage
|
||||
import info.nightscout.interfaces.pump.PumpSync
|
||||
import info.nightscout.interfaces.pump.TemporaryBasalStorage
|
||||
import info.nightscout.pump.dana.DanaPump
|
||||
import info.nightscout.rx.bus.RxBus
|
||||
import info.nightscout.rx.events.EventPumpStatusChanged
|
||||
import info.nightscout.rx.logging.LTag
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
package info.nightscout.androidaps.danars.comm
|
||||
|
||||
import dagger.android.HasAndroidInjector
|
||||
import info.nightscout.androidaps.dana.DanaPump
|
||||
import info.nightscout.androidaps.danars.encryption.BleEncryption
|
||||
import info.nightscout.pump.dana.DanaPump
|
||||
import info.nightscout.rx.logging.LTag
|
||||
|
||||
import org.joda.time.DateTime
|
||||
import org.joda.time.DateTimeZone
|
||||
import javax.inject.Inject
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
package info.nightscout.androidaps.danars.comm
|
||||
|
||||
import dagger.android.HasAndroidInjector
|
||||
import info.nightscout.androidaps.dana.DanaPump
|
||||
import info.nightscout.androidaps.danars.R
|
||||
import info.nightscout.androidaps.danars.encryption.BleEncryption
|
||||
import info.nightscout.core.events.EventNewNotification
|
||||
import info.nightscout.interfaces.notifications.Notification
|
||||
import info.nightscout.pump.dana.DanaPump
|
||||
import info.nightscout.rx.bus.RxBus
|
||||
import info.nightscout.rx.events.EventDismissNotification
|
||||
import info.nightscout.rx.logging.LTag
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package info.nightscout.androidaps.danars.comm
|
||||
|
||||
import dagger.android.HasAndroidInjector
|
||||
import info.nightscout.androidaps.dana.DanaPump
|
||||
import info.nightscout.androidaps.danars.encryption.BleEncryption
|
||||
import info.nightscout.pump.dana.DanaPump
|
||||
import info.nightscout.rx.logging.LTag
|
||||
import javax.inject.Inject
|
||||
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue