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.LoggerFactory;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import de.jotomo.ruffyscripter.commands.PumpState;
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
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 {
|
||||
private static Logger log = LoggerFactory.getLogger(ComboFragment.class);
|
||||
|
@ -76,9 +74,10 @@ public class ComboFragment extends Fragment {
|
|||
} else {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(getPlugin().statusSummary);
|
||||
if (getPlugin().pumpState != null) {
|
||||
PumpState ps = getPlugin().pumpState;
|
||||
if (ps != null) {
|
||||
sb.append("\n\n");
|
||||
sb.append(getPlugin().pumpState.toString()
|
||||
sb.append(ps.toString()
|
||||
// i know ... i need to take a break already
|
||||
.replaceAll(", ", "\n")
|
||||
.replaceAll("PumpState\\{", "\n")
|
||||
|
|
|
@ -323,17 +323,14 @@ public class ComboPlugin implements PluginBase, PumpInterface {
|
|||
} finally {
|
||||
lastCmdTime = new Date();
|
||||
statusSummary = "Idle";
|
||||
try {
|
||||
if (pumpState != null) {
|
||||
if (pumpState.errorMsg != null) {
|
||||
statusSummary = "Error: " + pumpState.errorMsg;
|
||||
} else if (pumpState.isErrorOrWarning) {
|
||||
PumpState ps = pumpState;
|
||||
if (ps != null) {
|
||||
if (ps.errorMsg != null) {
|
||||
statusSummary = "Error: " + ps.errorMsg;
|
||||
} else if (ps.isErrorOrWarning) {
|
||||
statusSummary = "Error: pump is in error mode, please check pump display";
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
statusSummary = "Error";
|
||||
}
|
||||
|
||||
ruffyScripter.disconnect();
|
||||
MainApp.bus().post(new EventComboPumpUpdateGUI());
|
||||
|
@ -357,7 +354,8 @@ public class ComboPlugin implements PluginBase, PumpInterface {
|
|||
if (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) {
|
||||
log.debug("Not bothering the pump for a small TBR change from " + activeTbrPercentage + "% -> " + roundedPercentage + "%");
|
||||
PumpEnactResult pumpEnactResult = new PumpEnactResult();
|
||||
|
@ -456,11 +454,12 @@ public class ComboPlugin implements PluginBase, PumpInterface {
|
|||
}
|
||||
status.put("timestamp", lastCmdTime);
|
||||
|
||||
if (pumpState != null) {
|
||||
extended.put("TempBasalAbsoluteRate", pumpState.tbrRate);
|
||||
PumpState ps = this.pumpState;
|
||||
if (ps != null) {
|
||||
extended.put("TempBasalAbsoluteRate", ps.tbrRate);
|
||||
// TODO best guess at this point ...
|
||||
extended.put("TempBasalStart", DateUtil.dateAndTimeString(System.currentTimeMillis() - (pumpState.tbrRemainingDuration - 15 * 60 * 1000)));
|
||||
extended.put("TempBasalRemaining", pumpState.tbrRemainingDuration);
|
||||
extended.put("TempBasalStart", DateUtil.dateAndTimeString(System.currentTimeMillis() - (ps.tbrRemainingDuration - 15 * 60 * 1000)));
|
||||
extended.put("TempBasalRemaining", ps.tbrRemainingDuration);
|
||||
}
|
||||
|
||||
// more info here .... look at dana plugin
|
||||
|
|
Loading…
Reference in a new issue