allign dana plugin code
This commit is contained in:
parent
3ab235f829
commit
d2cba61354
|
@ -415,7 +415,7 @@ public class DanaRPlugin implements PluginBase, PumpInterface, DanaRInterface, C
|
|||
log.debug("setTempBasalAbsolute: currently running: " + running.toString());
|
||||
if (running.percentRate == percentRate) {
|
||||
if (enforceNew) {
|
||||
cancelTempBasal(true);
|
||||
cancelTempBasal(true);
|
||||
} else {
|
||||
result.success = true;
|
||||
result.percent = percentRate;
|
||||
|
@ -543,7 +543,7 @@ public class DanaRPlugin implements PluginBase, PumpInterface, DanaRInterface, C
|
|||
}
|
||||
result.enacted = false;
|
||||
result.success = false;
|
||||
result.comment = MainApp.instance().getString(R.string.danar_valuenotsetproperly);
|
||||
result.comment = MainApp.instance().getString(R.string.tempbasaldeliveryerror);
|
||||
log.error("setTempBasalPercent: Failed to set temp basal");
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -61,9 +61,9 @@ public class DanaRKoreanPlugin implements PluginBase, PumpInterface, DanaRInterf
|
|||
return DanaRFragment.class.getName();
|
||||
}
|
||||
|
||||
private boolean fragmentPumpEnabled = false;
|
||||
private boolean fragmentProfileEnabled = false;
|
||||
private boolean fragmentPumpVisible = true;
|
||||
private static boolean fragmentPumpEnabled = false;
|
||||
private static boolean fragmentProfileEnabled = false;
|
||||
private static boolean fragmentPumpVisible = true;
|
||||
|
||||
private static DanaRKoreanExecutionService sExecutionService;
|
||||
|
||||
|
@ -201,11 +201,11 @@ public class DanaRKoreanPlugin implements PluginBase, PumpInterface, DanaRInterf
|
|||
@Override
|
||||
public void setFragmentEnabled(int type, boolean fragmentEnabled) {
|
||||
if (type == PluginBase.PROFILE)
|
||||
this.fragmentProfileEnabled = fragmentEnabled;
|
||||
fragmentProfileEnabled = fragmentEnabled;
|
||||
else if (type == PluginBase.PUMP)
|
||||
this.fragmentPumpEnabled = fragmentEnabled;
|
||||
fragmentPumpEnabled = fragmentEnabled;
|
||||
// if pump profile was enabled need to switch to another too
|
||||
if (type == PluginBase.PUMP && !fragmentEnabled && this.fragmentProfileEnabled) {
|
||||
if (type == PluginBase.PUMP && !fragmentEnabled && fragmentProfileEnabled) {
|
||||
setFragmentEnabled(PluginBase.PROFILE, false);
|
||||
setFragmentVisible(PluginBase.PROFILE, false);
|
||||
NSProfilePlugin.getPlugin().setFragmentEnabled(PluginBase.PROFILE, true);
|
||||
|
@ -216,7 +216,7 @@ public class DanaRKoreanPlugin implements PluginBase, PumpInterface, DanaRInterf
|
|||
@Override
|
||||
public void setFragmentVisible(int type, boolean fragmentVisible) {
|
||||
if (type == PluginBase.PUMP)
|
||||
this.fragmentPumpVisible = fragmentVisible;
|
||||
fragmentPumpVisible = fragmentVisible;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -316,8 +316,7 @@ public class DanaRKoreanPlugin implements PluginBase, PumpInterface, DanaRInterf
|
|||
if (detailedBolusInfo.insulin > 0 || detailedBolusInfo.carbs > 0) {
|
||||
Treatment t = new Treatment();
|
||||
boolean connectionOK = false;
|
||||
if (detailedBolusInfo.insulin > 0 || detailedBolusInfo.carbs > 0)
|
||||
connectionOK = sExecutionService.bolus(detailedBolusInfo.insulin, (int) detailedBolusInfo.carbs, t);
|
||||
if (detailedBolusInfo.insulin > 0 || detailedBolusInfo.carbs > 0) connectionOK = sExecutionService.bolus(detailedBolusInfo.insulin, (int) detailedBolusInfo.carbs, t);
|
||||
PumpEnactResult result = new PumpEnactResult();
|
||||
result.success = connectionOK;
|
||||
result.bolusDelivered = t.insulin;
|
||||
|
@ -394,9 +393,12 @@ public class DanaRKoreanPlugin implements PluginBase, PumpInterface, DanaRInterf
|
|||
Integer percentRate = Double.valueOf(absoluteRate / getBaseBasalRate() * 100).intValue();
|
||||
if (percentRate < 100) percentRate = Round.ceilTo((double) percentRate, 10d).intValue();
|
||||
else percentRate = Round.floorTo((double) percentRate, 10d).intValue();
|
||||
if (percentRate > 200) {
|
||||
percentRate = 200;
|
||||
if (percentRate > getPumpDescription().maxTempPercent) {
|
||||
percentRate = getPumpDescription().maxTempPercent;
|
||||
}
|
||||
if (Config.logPumpActions)
|
||||
log.debug("setTempBasalAbsolute: Calculated percent rate: " + percentRate);
|
||||
|
||||
// If extended in progress
|
||||
if (MainApp.getConfigBuilder().isInHistoryExtendedBoluslInProgress() && useExtendedBoluses) {
|
||||
if (Config.logPumpActions)
|
||||
|
@ -410,7 +412,10 @@ public class DanaRKoreanPlugin implements PluginBase, PumpInterface, DanaRInterf
|
|||
// Check if some temp is already in progress
|
||||
if (MainApp.getConfigBuilder().isInHistoryRealTempBasalInProgress()) {
|
||||
// Correct basal already set ?
|
||||
if (MainApp.getConfigBuilder().getRealTempBasalFromHistory(System.currentTimeMillis()).percentRate == percentRate) {
|
||||
TemporaryBasal running = MainApp.getConfigBuilder().getRealTempBasalFromHistory(System.currentTimeMillis());
|
||||
if (Config.logPumpActions)
|
||||
log.debug("setTempBasalAbsolute: currently running: " + running.toString());
|
||||
if (running.percentRate == percentRate) {
|
||||
if (enforceNew) {
|
||||
cancelTempBasal(true);
|
||||
} else {
|
||||
|
@ -451,7 +456,7 @@ public class DanaRKoreanPlugin implements PluginBase, PumpInterface, DanaRInterf
|
|||
Double extendedRateToSet = absoluteRate - getBaseBasalRate();
|
||||
extendedRateToSet = configBuilderPlugin.applyBasalConstraints(extendedRateToSet);
|
||||
// needs to be rounded to 0.1
|
||||
extendedRateToSet = Round.roundTo(extendedRateToSet, pumpDescription.extendedBolusStep * 2); // *2 because of 30 min
|
||||
extendedRateToSet = Round.roundTo(extendedRateToSet, pumpDescription.extendedBolusStep * 2); // *2 because of halfhours
|
||||
|
||||
// What is current rate of extended bolusing in u/h?
|
||||
if (Config.logPumpActions) {
|
||||
|
|
|
@ -61,9 +61,9 @@ public class DanaRv2Plugin implements PluginBase, PumpInterface, DanaRInterface,
|
|||
return DanaRFragment.class.getName();
|
||||
}
|
||||
|
||||
private boolean fragmentPumpEnabled = false;
|
||||
private boolean fragmentProfileEnabled = false;
|
||||
private boolean fragmentPumpVisible = false;
|
||||
private static boolean fragmentPumpEnabled = false;
|
||||
private static boolean fragmentProfileEnabled = false;
|
||||
private static boolean fragmentPumpVisible = true;
|
||||
|
||||
private static DanaRv2ExecutionService sExecutionService;
|
||||
|
||||
|
@ -186,11 +186,11 @@ public class DanaRv2Plugin implements PluginBase, PumpInterface, DanaRInterface,
|
|||
@Override
|
||||
public void setFragmentEnabled(int type, boolean fragmentEnabled) {
|
||||
if (type == PluginBase.PROFILE)
|
||||
this.fragmentProfileEnabled = fragmentEnabled;
|
||||
fragmentProfileEnabled = fragmentEnabled;
|
||||
else if (type == PluginBase.PUMP)
|
||||
this.fragmentPumpEnabled = fragmentEnabled;
|
||||
fragmentPumpEnabled = fragmentEnabled;
|
||||
// if pump profile was enabled need to switch to another too
|
||||
if (type == PluginBase.PUMP && !fragmentEnabled && this.fragmentProfileEnabled) {
|
||||
if (type == PluginBase.PUMP && !fragmentEnabled && fragmentProfileEnabled) {
|
||||
setFragmentEnabled(PluginBase.PROFILE, false);
|
||||
setFragmentVisible(PluginBase.PROFILE, false);
|
||||
NSProfilePlugin.getPlugin().setFragmentEnabled(PluginBase.PROFILE, true);
|
||||
|
@ -201,7 +201,7 @@ public class DanaRv2Plugin implements PluginBase, PumpInterface, DanaRInterface,
|
|||
@Override
|
||||
public void setFragmentVisible(int type, boolean fragmentVisible) {
|
||||
if (type == PluginBase.PUMP)
|
||||
this.fragmentPumpVisible = fragmentVisible;
|
||||
fragmentPumpVisible = fragmentVisible;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -398,7 +398,7 @@ public class DanaRv2Plugin implements PluginBase, PumpInterface, DanaRInterface,
|
|||
if (percentRate > 500) // Special high temp 500/15min
|
||||
percentRate = 500;
|
||||
// Check if some temp is already in progress
|
||||
if (MainApp.getConfigBuilder().isTempBasalInProgress()) {
|
||||
if (MainApp.getConfigBuilder().isInHistoryRealTempBasalInProgress()) {
|
||||
// Correct basal already set ?
|
||||
if (MainApp.getConfigBuilder().getTempBasalFromHistory(System.currentTimeMillis()).percentRate == percentRate) {
|
||||
if (!enforceNew) {
|
||||
|
@ -515,6 +515,7 @@ public class DanaRv2Plugin implements PluginBase, PumpInterface, DanaRInterface,
|
|||
// needs to be rounded
|
||||
int durationInHalfHours = Math.max(durationInMinutes / 30, 1);
|
||||
insulin = Round.roundTo(insulin, getPumpDescription().extendedBolusStep);
|
||||
|
||||
PumpEnactResult result = new PumpEnactResult();
|
||||
ExtendedBolus runningEB = MainApp.getConfigBuilder().getExtendedBolusFromHistory(System.currentTimeMillis());
|
||||
if (runningEB != null && Math.abs(runningEB.insulin - insulin) < getPumpDescription().extendedBolusStep) {
|
||||
|
@ -802,7 +803,7 @@ public class DanaRv2Plugin implements PluginBase, PumpInterface, DanaRInterface,
|
|||
if (pump.lastBolusTime.getTime() != 0) {
|
||||
ret += "LastBolus: " + DecimalFormatter.to2Decimal(pump.lastBolusAmount) + "U @" + android.text.format.DateFormat.format("HH:mm", pump.lastBolusTime) + "\n";
|
||||
}
|
||||
if (MainApp.getConfigBuilder().isTempBasalInProgress()) {
|
||||
if (MainApp.getConfigBuilder().isInHistoryRealTempBasalInProgress()) {
|
||||
ret += "Temp: " + MainApp.getConfigBuilder().getTempBasalFromHistory(System.currentTimeMillis()).toStringFull() + "\n";
|
||||
}
|
||||
if (MainApp.getConfigBuilder().isInHistoryExtendedBoluslInProgress()) {
|
||||
|
@ -816,7 +817,6 @@ public class DanaRv2Plugin implements PluginBase, PumpInterface, DanaRInterface,
|
|||
ret += "Batt: " + pump.batteryRemaining + "\n";
|
||||
return ret;
|
||||
}
|
||||
|
||||
// TODO: daily total constraint
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue