re-initialize on time sync Rv2

This commit is contained in:
AdrianLxM 2018-06-24 15:46:31 +02:00 committed by GitHub
parent 54e647bbe1
commit 87d24b6e6e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -205,8 +205,7 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService {
MainApp.instance().startActivity(i); MainApp.instance().startActivity(i);
//deinitialize pump //deinitialize pump
DanaRPump.reset(); mDanaRPump.lastConnection = 0;
mDanaRPump = DanaRPump.getInstance();
MainApp.bus().post(new EventDanaRNewStatus()); MainApp.bus().post(new EventDanaRNewStatus());
MainApp.bus().post(new EventInitializationChanged()); MainApp.bus().post(new EventInitializationChanged());
return; return;
@ -219,6 +218,7 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService {
log.debug("Pump time difference: " + timeDiff + " seconds"); log.debug("Pump time difference: " + timeDiff + " seconds");
} }
} }
mDanaRPump.lastConnection = System.currentTimeMillis();
long now = System.currentTimeMillis(); long now = System.currentTimeMillis();
if (mDanaRPump.lastSettingsRead + 60 * 60 * 1000L < now || !MainApp.getSpecificPlugin(DanaRv2Plugin.class).isInitialized()) { if (mDanaRPump.lastSettingsRead + 60 * 60 * 1000L < now || !MainApp.getSpecificPlugin(DanaRv2Plugin.class).isInitialized()) {
@ -445,6 +445,14 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService {
} }
public PumpEnactResult loadEvents() { public PumpEnactResult loadEvents() {
if(!MainApp.getSpecificPlugin(DanaRv2Plugin.class).isInitialized()){
PumpEnactResult result = new PumpEnactResult().success(false);
result.comment = "pump not initialized";
return result;
}
if (!isConnected()) if (!isConnected())
return new PumpEnactResult().success(false); return new PumpEnactResult().success(false);
SystemClock.sleep(300); SystemClock.sleep(300);