RandomBgPlugin injection
This commit is contained in:
parent
2f59cd4f09
commit
716053229a
|
@ -146,6 +146,7 @@ public class MainApp extends DaggerApplication {
|
|||
@Inject OpenAPSAMAPlugin openAPSAMAPlugin;
|
||||
@Inject OpenAPSSMBPlugin openAPSSMBPlugin;
|
||||
@Inject OverviewPlugin overviewPlugin;
|
||||
@Inject RandomBgPlugin randomBgPlugin;
|
||||
@Inject StatusLinePlugin statusLinePlugin;
|
||||
@Inject TidepoolPlugin tidepoolPlugin;
|
||||
@Inject TreatmentsPlugin treatmentsPlugin;
|
||||
|
@ -244,7 +245,7 @@ public class MainApp extends DaggerApplication {
|
|||
pluginsList.add(SourcePoctechPlugin.getPlugin());
|
||||
pluginsList.add(SourceTomatoPlugin.getPlugin());
|
||||
pluginsList.add(SourceEversensePlugin.getPlugin());
|
||||
pluginsList.add(RandomBgPlugin.INSTANCE);
|
||||
pluginsList.add(randomBgPlugin);
|
||||
if (!Config.NSCLIENT) pluginsList.add(smsCommunicatorPlugin);
|
||||
pluginsList.add(FoodPlugin.getPlugin());
|
||||
|
||||
|
|
|
@ -9,29 +9,35 @@ import info.nightscout.androidaps.interfaces.BgSourceInterface
|
|||
import info.nightscout.androidaps.interfaces.PluginBase
|
||||
import info.nightscout.androidaps.interfaces.PluginDescription
|
||||
import info.nightscout.androidaps.interfaces.PluginType
|
||||
import info.nightscout.androidaps.logging.L
|
||||
import info.nightscout.androidaps.logging.AAPSLogger
|
||||
import info.nightscout.androidaps.logging.LTag
|
||||
import info.nightscout.androidaps.plugins.pump.virtual.VirtualPumpPlugin
|
||||
import info.nightscout.androidaps.utils.DateUtil
|
||||
import info.nightscout.androidaps.utils.T
|
||||
import info.nightscout.androidaps.utils.isRunningTest
|
||||
import org.slf4j.LoggerFactory
|
||||
import java.util.*
|
||||
import javax.inject.Inject
|
||||
import javax.inject.Singleton
|
||||
import kotlin.math.PI
|
||||
import kotlin.math.sin
|
||||
|
||||
object RandomBgPlugin : PluginBase(PluginDescription()
|
||||
.mainType(PluginType.BGSOURCE)
|
||||
.fragmentClass(BGSourceFragment::class.java.name)
|
||||
.pluginName(R.string.randombg)
|
||||
.shortName(R.string.randombg_short)
|
||||
.description(R.string.description_source_randombg)), BgSourceInterface {
|
||||
|
||||
private val log = LoggerFactory.getLogger(L.BGSOURCE)
|
||||
@Singleton
|
||||
class RandomBgPlugin @Inject constructor(
|
||||
private val aapsLogger: AAPSLogger,
|
||||
private var virtualPumpPlugin: VirtualPumpPlugin
|
||||
) : PluginBase(PluginDescription()
|
||||
.mainType(PluginType.BGSOURCE)
|
||||
.fragmentClass(BGSourceFragment::class.java.name)
|
||||
.pluginName(R.string.randombg)
|
||||
.shortName(R.string.randombg_short)
|
||||
.description(R.string.description_source_randombg)), BgSourceInterface {
|
||||
|
||||
private val loopHandler = Handler()
|
||||
private lateinit var refreshLoop: Runnable
|
||||
|
||||
const val interval = 5L // minutes
|
||||
companion object {
|
||||
const val interval = 5L // minutes
|
||||
}
|
||||
|
||||
init {
|
||||
refreshLoop = Runnable {
|
||||
|
@ -55,7 +61,7 @@ object RandomBgPlugin : PluginBase(PluginDescription()
|
|||
}
|
||||
|
||||
override fun specialEnableCondition(): Boolean {
|
||||
return VirtualPumpPlugin.getPlugin().isEnabled(PluginType.PUMP) && (MainApp.engineeringMode || isRunningTest())
|
||||
return virtualPumpPlugin.isEnabled(PluginType.PUMP) && (MainApp.engineeringMode || isRunningTest())
|
||||
}
|
||||
|
||||
override fun handleNewData(intent: Intent) {
|
||||
|
@ -72,6 +78,6 @@ object RandomBgPlugin : PluginBase(PluginDescription()
|
|||
bgReading.date = DateUtil.now()
|
||||
bgReading.raw = bgMgdl
|
||||
MainApp.getDbHelper().createIfNotExists(bgReading, "RandomBG")
|
||||
log.debug("Generated BG: $bgReading")
|
||||
aapsLogger.debug(LTag.BGSOURCE, "Generated BG: $bgReading")
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue