fix RunningConfiguration.kt

This commit is contained in:
Milos Kozak 2021-01-18 11:41:29 +01:00
parent 270b6623ea
commit 3f18f94c79

View file

@ -51,6 +51,7 @@ class RunningConfiguration @Inject constructor(
// called in NSClient mode only
fun apply(configuration: JSONObject) {
if (configuration.has("insulin")) {
val insulin = InsulinInterface.InsulinType.fromInt(JsonHelper.safeGetInt(configuration, "insulin", InsulinInterface.InsulinType.UNKNOWN.value))
for (p in activePlugin.getSpecificPluginsListByInterface(InsulinInterface::class.java)) {
val insulinPlugin = p as InsulinInterface
@ -62,7 +63,9 @@ class RunningConfiguration @Inject constructor(
insulinPlugin.applyConfiguration(configuration.getJSONObject("insulinConfiguration"))
}
}
}
if (configuration.has("sensitivity")) {
val sensitivity = SensitivityInterface.SensitivityType.fromInt(JsonHelper.safeGetInt(configuration, "sensitivity", SensitivityInterface.SensitivityType.UNKNOWN.value))
for (p in activePlugin.getSpecificPluginsListByInterface(SensitivityInterface::class.java)) {
val sensitivityPlugin = p as SensitivityInterface
@ -74,10 +77,14 @@ class RunningConfiguration @Inject constructor(
sensitivityPlugin.applyConfiguration(configuration.getJSONObject("sensitivityConfiguration"))
}
}
}
if (configuration.has("pump")) {
val pumpType = JsonHelper.safeGetString(configuration, "pump", PumpType.GenericAAPS.description)
sp.putString(R.string.key_virtualpump_type, pumpType)
activePlugin.activePump.pumpDescription.setPumpDescription(PumpType.getByDescription(pumpType))
aapsLogger.debug(LTag.CORE, "Changing pump type to ${pumpType}")
}
if (configuration.has("overviewConfiguration"))
activePlugin.activeOverview.applyConfiguration(configuration.getJSONObject("overviewConfiguration"))