Move initialized flag to ComoPump class.

This commit is contained in:
Johannes Mockenhaupt 2017-10-28 13:12:55 +02:00
parent 4befa38d46
commit 255e9d0dff
No known key found for this signature in database
GPG key ID: 9E1EA6AF7BBBB0D1
3 changed files with 6 additions and 7 deletions

View file

@ -45,8 +45,6 @@ public class ComboPlugin implements PluginBase, PumpInterface {
private boolean fragmentEnabled = false;
private boolean fragmentVisible = false;
private boolean initialized = false;
private PumpDescription pumpDescription = new PumpDescription();
@NonNull
@ -180,7 +178,7 @@ public class ComboPlugin implements PluginBase, PumpInterface {
@Override
public boolean isInitialized() {
return initialized;
return pump.initialized;
}
@Override
@ -193,13 +191,11 @@ public class ComboPlugin implements PluginBase, PumpInterface {
return ruffyScripter.isPumpBusy() && !pump.state.suspended;
}
// TODO
@Override
public int setNewBasalProfile(Profile profile) {
return FAILED;
}
// TODO
@Override
public boolean isThisProfileSet(Profile profile) {
return false;
@ -215,7 +211,7 @@ public class ComboPlugin implements PluginBase, PumpInterface {
public synchronized void refreshDataFromPump(String reason) {
log.debug("RefreshDataFromPump called");
if (!initialized) {
if (!pump.initialized) {
runCommand(MainApp.sResources.getString(R.string.connecting), new CommandExecution() {
@Override
public CommandResult execute() {
@ -223,7 +219,7 @@ public class ComboPlugin implements PluginBase, PumpInterface {
}
});
checkPumpHistory();
initialized = true;
pump.initialized = true;
} else {
runCommand(MainApp.sResources.getString(R.string.combo_action_refreshing), new CommandExecution() {
@Override

View file

@ -9,6 +9,8 @@ import de.jotomo.ruffy.spi.history.PumpHistory;
class ComboPump {
// TODO actually ... this isn't about successful command execution, but whether we could connect to the pump at all
boolean initialized = false;
volatile long lastSuccessfulConnection;
volatile long lastConnectionAttempt;
@Nullable

View file

@ -18,6 +18,7 @@ public class PumpState {
* longer to read that and the pump connection gets interrupted if we're not
* reacting quickly.
*/
// TODO pump errors (EXX) vs. errors talking to the pump
public String errorMsg;
public boolean suspended;