Properly accessing volatile field pumpState.
This commit is contained in:
parent
69e560baee
commit
83e9ec743e
|
@ -17,13 +17,11 @@ import com.squareup.otto.Subscribe;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
|
import de.jotomo.ruffyscripter.commands.PumpState;
|
||||||
import info.nightscout.androidaps.MainApp;
|
import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.plugins.PumpCombo.events.EventComboPumpUpdateGUI;
|
import info.nightscout.androidaps.plugins.PumpCombo.events.EventComboPumpUpdateGUI;
|
||||||
import info.nightscout.androidaps.plugins.PumpVirtual.VirtualPumpPlugin;
|
|
||||||
import info.nightscout.androidaps.plugins.PumpVirtual.events.EventVirtualPumpUpdateGui;
|
|
||||||
|
|
||||||
public class ComboFragment extends Fragment {
|
public class ComboFragment extends Fragment {
|
||||||
private static Logger log = LoggerFactory.getLogger(ComboFragment.class);
|
private static Logger log = LoggerFactory.getLogger(ComboFragment.class);
|
||||||
|
@ -76,9 +74,10 @@ public class ComboFragment extends Fragment {
|
||||||
} else {
|
} else {
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
sb.append(getPlugin().statusSummary);
|
sb.append(getPlugin().statusSummary);
|
||||||
if (getPlugin().pumpState != null) {
|
PumpState ps = getPlugin().pumpState;
|
||||||
|
if (ps != null) {
|
||||||
sb.append("\n\n");
|
sb.append("\n\n");
|
||||||
sb.append(getPlugin().pumpState.toString()
|
sb.append(ps.toString()
|
||||||
// i know ... i need to take a break already
|
// i know ... i need to take a break already
|
||||||
.replaceAll(", ", "\n")
|
.replaceAll(", ", "\n")
|
||||||
.replaceAll("PumpState\\{", "\n")
|
.replaceAll("PumpState\\{", "\n")
|
||||||
|
|
|
@ -323,16 +323,13 @@ public class ComboPlugin implements PluginBase, PumpInterface {
|
||||||
} finally {
|
} finally {
|
||||||
lastCmdTime = new Date();
|
lastCmdTime = new Date();
|
||||||
statusSummary = "Idle";
|
statusSummary = "Idle";
|
||||||
try {
|
PumpState ps = pumpState;
|
||||||
if (pumpState != null) {
|
if (ps != null) {
|
||||||
if (pumpState.errorMsg != null) {
|
if (ps.errorMsg != null) {
|
||||||
statusSummary = "Error: " + pumpState.errorMsg;
|
statusSummary = "Error: " + ps.errorMsg;
|
||||||
} else if (pumpState.isErrorOrWarning) {
|
} else if (ps.isErrorOrWarning) {
|
||||||
statusSummary = "Error: pump is in error mode, please check pump display";
|
statusSummary = "Error: pump is in error mode, please check pump display";
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
|
||||||
statusSummary = "Error";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ruffyScripter.disconnect();
|
ruffyScripter.disconnect();
|
||||||
|
@ -357,7 +354,8 @@ public class ComboPlugin implements PluginBase, PumpInterface {
|
||||||
if (unroundedPercentage != roundedPercentage) {
|
if (unroundedPercentage != roundedPercentage) {
|
||||||
log.debug("Rounded requested rate " + unroundedPercentage + "% -> " + roundedPercentage + "%");
|
log.debug("Rounded requested rate " + unroundedPercentage + "% -> " + roundedPercentage + "%");
|
||||||
}
|
}
|
||||||
int activeTbrPercentage = pumpState != null ? pumpState.tbrPercent : 100;
|
PumpState ps = pumpState;
|
||||||
|
int activeTbrPercentage = ps != null ? ps.tbrPercent : 100;
|
||||||
if (activeTbrPercentage != -1 && Math.abs(activeTbrPercentage - roundedPercentage) <= 20) {
|
if (activeTbrPercentage != -1 && Math.abs(activeTbrPercentage - roundedPercentage) <= 20) {
|
||||||
log.debug("Not bothering the pump for a small TBR change from " + activeTbrPercentage + "% -> " + roundedPercentage + "%");
|
log.debug("Not bothering the pump for a small TBR change from " + activeTbrPercentage + "% -> " + roundedPercentage + "%");
|
||||||
PumpEnactResult pumpEnactResult = new PumpEnactResult();
|
PumpEnactResult pumpEnactResult = new PumpEnactResult();
|
||||||
|
@ -456,11 +454,12 @@ public class ComboPlugin implements PluginBase, PumpInterface {
|
||||||
}
|
}
|
||||||
status.put("timestamp", lastCmdTime);
|
status.put("timestamp", lastCmdTime);
|
||||||
|
|
||||||
if (pumpState != null) {
|
PumpState ps = this.pumpState;
|
||||||
extended.put("TempBasalAbsoluteRate", pumpState.tbrRate);
|
if (ps != null) {
|
||||||
|
extended.put("TempBasalAbsoluteRate", ps.tbrRate);
|
||||||
// TODO best guess at this point ...
|
// TODO best guess at this point ...
|
||||||
extended.put("TempBasalStart", DateUtil.dateAndTimeString(System.currentTimeMillis() - (pumpState.tbrRemainingDuration - 15 * 60 * 1000)));
|
extended.put("TempBasalStart", DateUtil.dateAndTimeString(System.currentTimeMillis() - (ps.tbrRemainingDuration - 15 * 60 * 1000)));
|
||||||
extended.put("TempBasalRemaining", pumpState.tbrRemainingDuration);
|
extended.put("TempBasalRemaining", ps.tbrRemainingDuration);
|
||||||
}
|
}
|
||||||
|
|
||||||
// more info here .... look at dana plugin
|
// more info here .... look at dana plugin
|
||||||
|
|
Loading…
Reference in a new issue