ComboPlugin singletion.
This commit is contained in:
parent
41ebabe5e7
commit
357c84e2e2
3 changed files with 17 additions and 17 deletions
|
@ -48,8 +48,7 @@ import info.nightscout.androidaps.plugins.ProfileCircadianPercentage.CircadianPe
|
||||||
import info.nightscout.androidaps.plugins.ProfileLocal.LocalProfileFragment;
|
import info.nightscout.androidaps.plugins.ProfileLocal.LocalProfileFragment;
|
||||||
import info.nightscout.androidaps.plugins.ProfileNS.NSProfilePlugin;
|
import info.nightscout.androidaps.plugins.ProfileNS.NSProfilePlugin;
|
||||||
import info.nightscout.androidaps.plugins.ProfileSimple.SimpleProfilePlugin;
|
import info.nightscout.androidaps.plugins.ProfileSimple.SimpleProfilePlugin;
|
||||||
import info.nightscout.androidaps.plugins.PumpCombo.ComboFragment;
|
import info.nightscout.androidaps.plugins.PumpCombo.ComboPlugin;
|
||||||
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRFragment;
|
|
||||||
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPlugin;
|
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPlugin;
|
||||||
import info.nightscout.androidaps.plugins.PumpDanaR.services.DanaRExecutionService;
|
import info.nightscout.androidaps.plugins.PumpDanaR.services.DanaRExecutionService;
|
||||||
import info.nightscout.androidaps.plugins.PumpDanaRKorean.DanaRKoreanPlugin;
|
import info.nightscout.androidaps.plugins.PumpDanaRKorean.DanaRKoreanPlugin;
|
||||||
|
@ -129,7 +128,7 @@ public class MainApp extends Application {
|
||||||
if (Config.DANAR) pluginsList.add(DanaRKoreanPlugin.getPlugin());
|
if (Config.DANAR) pluginsList.add(DanaRKoreanPlugin.getPlugin());
|
||||||
if (Config.DANAR) pluginsList.add(DanaRv2Plugin.getPlugin());
|
if (Config.DANAR) pluginsList.add(DanaRv2Plugin.getPlugin());
|
||||||
if (Config.DANAR) pluginsList.add(DanaRSPlugin.getPlugin());
|
if (Config.DANAR) pluginsList.add(DanaRSPlugin.getPlugin());
|
||||||
if (Config.COMBO) pluginsList.add(ComboFragment.getPlugin());
|
if (Config.COMBO) pluginsList.add(ComboPlugin.getPlugin());
|
||||||
pluginsList.add(CareportalFragment.getPlugin());
|
pluginsList.add(CareportalFragment.getPlugin());
|
||||||
if (Config.MDI) pluginsList.add(MDIPlugin.getPlugin());
|
if (Config.MDI) pluginsList.add(MDIPlugin.getPlugin());
|
||||||
if (Config.VIRTUALPUMP) pluginsList.add(VirtualPumpPlugin.getInstance());
|
if (Config.VIRTUALPUMP) pluginsList.add(VirtualPumpPlugin.getInstance());
|
||||||
|
|
|
@ -27,12 +27,6 @@ import info.nightscout.androidaps.plugins.PumpCombo.events.EventComboPumpUpdateG
|
||||||
public class ComboFragment extends Fragment implements View.OnClickListener {
|
public class ComboFragment extends Fragment implements View.OnClickListener {
|
||||||
private static Logger log = LoggerFactory.getLogger(ComboFragment.class);
|
private static Logger log = LoggerFactory.getLogger(ComboFragment.class);
|
||||||
|
|
||||||
private static ComboPlugin comboPlugin = new ComboPlugin();
|
|
||||||
|
|
||||||
public static ComboPlugin getPlugin() {
|
|
||||||
return comboPlugin;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Button refresh;
|
private Button refresh;
|
||||||
|
|
||||||
private TextView statusText;
|
private TextView statusText;
|
||||||
|
@ -103,7 +97,7 @@ public class ComboFragment extends Fragment implements View.OnClickListener {
|
||||||
Thread thread = new Thread(new Runnable() {
|
Thread thread = new Thread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
getPlugin().refreshDataFromPump("User request");
|
ComboPlugin.getPlugin().refreshDataFromPump("User request");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
thread.start();
|
thread.start();
|
||||||
|
@ -117,9 +111,10 @@ public class ComboFragment extends Fragment implements View.OnClickListener {
|
||||||
activity.runOnUiThread(new Runnable() {
|
activity.runOnUiThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
statusText.setText(getPlugin().getPump().stateSummary);
|
ComboPlugin plugin = ComboPlugin.getPlugin();
|
||||||
if (getPlugin().isInitialized()) {
|
statusText.setText(plugin.getPump().stateSummary);
|
||||||
PumpState ps = getPlugin().getPump().state;
|
if (plugin.isInitialized()) {
|
||||||
|
PumpState ps = plugin.getPump().state;
|
||||||
if (ps != null) {
|
if (ps != null) {
|
||||||
boolean tbrActive = ps.tbrPercent != -1 && ps.tbrPercent != 100;
|
boolean tbrActive = ps.tbrPercent != -1 && ps.tbrPercent != 100;
|
||||||
if (tbrActive) {
|
if (tbrActive) {
|
||||||
|
@ -152,16 +147,16 @@ public class ComboFragment extends Fragment implements View.OnClickListener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Command lastCmd = getPlugin().getPump().lastCmd;
|
Command lastCmd = plugin.getPump().lastCmd;
|
||||||
if (lastCmd != null) {
|
if (lastCmd != null) {
|
||||||
lastCmdText.setText(lastCmd.toString());
|
lastCmdText.setText(lastCmd.toString());
|
||||||
lastCmdTimeText.setText(getPlugin().getPump().lastCmdTime.toLocaleString());
|
lastCmdTimeText.setText(plugin.getPump().lastCmdTime.toLocaleString());
|
||||||
} else {
|
} else {
|
||||||
lastCmdText.setText("");
|
lastCmdText.setText("");
|
||||||
lastCmdTimeText.setText("");
|
lastCmdTimeText.setText("");
|
||||||
}
|
}
|
||||||
|
|
||||||
CommandResult lastCmdResult = getPlugin().getPump().lastCmdResult;
|
CommandResult lastCmdResult = plugin.getPump().lastCmdResult;
|
||||||
if (lastCmdResult != null && lastCmdResult.message != null) {
|
if (lastCmdResult != null && lastCmdResult.message != null) {
|
||||||
lastCmdResultText.setText(lastCmdResult.message);
|
lastCmdResultText.setText(lastCmdResult.message);
|
||||||
lastCmdDurationText.setText(lastCmdResult.duration);
|
lastCmdDurationText.setText(lastCmdResult.duration);
|
||||||
|
|
|
@ -62,7 +62,13 @@ public class ComboPlugin implements PluginBase, PumpInterface {
|
||||||
|
|
||||||
private ComboPump pump = new ComboPump();
|
private ComboPump pump = new ComboPump();
|
||||||
|
|
||||||
private boolean ignoreLastSetTbrOrReadStateFailure = false;
|
private static ComboPlugin plugin = null;
|
||||||
|
|
||||||
|
public static ComboPlugin getPlugin() {
|
||||||
|
if (plugin == null)
|
||||||
|
plugin = new ComboPlugin();
|
||||||
|
return plugin;
|
||||||
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
private volatile BolusCommand runningBolusCommand;
|
private volatile BolusCommand runningBolusCommand;
|
||||||
|
|
Loading…
Reference in a new issue