Dana: cleanup
This commit is contained in:
parent
3bb7c331d7
commit
0da75f1d69
|
@ -55,7 +55,7 @@ class DanaPump @Inject constructor(
|
|||
|
||||
var lastConnection: Long = 0
|
||||
var lastSettingsRead: Long = 0
|
||||
@JvmField var lastHistoryFetched: Long = 0
|
||||
@JvmField var readHistoryFrom: Long = 0 // start next history read from this timestamp
|
||||
@JvmField var historyDoneReceived: Boolean = false // true when last history message is received
|
||||
|
||||
// Info
|
||||
|
@ -410,7 +410,7 @@ class DanaPump @Inject constructor(
|
|||
aapsLogger.debug(LTag.PUMP, "DanaRPump reset")
|
||||
lastConnection = 0
|
||||
lastSettingsRead = 0
|
||||
lastHistoryFetched = 0
|
||||
readHistoryFrom = 0
|
||||
}
|
||||
|
||||
fun modelFriendlyName(): String =
|
||||
|
|
|
@ -57,8 +57,6 @@ public class DanaRv2Plugin extends AbstractDanaRPlugin {
|
|||
private final TemporaryBasalStorage temporaryBasalStorage;
|
||||
private final FabricPrivacy fabricPrivacy;
|
||||
|
||||
public long lastEventTimeLoaded = 0;
|
||||
|
||||
@Inject
|
||||
public DanaRv2Plugin(
|
||||
HasAndroidInjector injector,
|
||||
|
|
|
@ -277,7 +277,7 @@ class MsgHistoryEventsV2 constructor(
|
|||
status = "UNKNOWN " + dateUtil.timeString(datetime)
|
||||
}
|
||||
}
|
||||
if (datetime > danaRv2Plugin.lastEventTimeLoaded) danaRv2Plugin.lastEventTimeLoaded = datetime
|
||||
if (datetime > danaPump.lastEventTimeLoaded) danaPump.lastEventTimeLoaded = datetime
|
||||
rxBus.send(EventPumpStatusChanged(rh.gs(info.nightscout.pump.dana.R.string.processinghistory) + ": " + status))
|
||||
}
|
||||
}
|
|
@ -346,7 +346,7 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService {
|
|||
MsgSetHistoryEntry_v2 msgSetHistoryEntry_v2 = new MsgSetHistoryEntry_v2(injector,
|
||||
DanaPump.HistoryEntry.CARBS.getValue(), carbtime, carbs, 0);
|
||||
mSerialIOThread.sendMessage(msgSetHistoryEntry_v2);
|
||||
danaPump.lastHistoryFetched = Math.min(danaPump.lastHistoryFetched, carbtime - T.Companion.mins(1).msecs());
|
||||
danaPump.readHistoryFrom = Math.min(danaPump.readHistoryFrom, carbtime - T.Companion.mins(1).msecs());
|
||||
if (!msgSetHistoryEntry_v2.isReceived() || msgSetHistoryEntry_v2.getFailed())
|
||||
uiInteraction.runAlarm(rh.gs(info.nightscout.pump.dana.R.string.carbs_store_error), rh.gs(info.nightscout.core.ui.R.string.error), info.nightscout.core.ui.R.raw.boluserror);
|
||||
}
|
||||
|
@ -418,7 +418,7 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService {
|
|||
MsgSetHistoryEntry_v2 msgSetHistoryEntry_v2 = new MsgSetHistoryEntry_v2(injector,
|
||||
DanaPump.HistoryEntry.CARBS.getValue(), time, amount, 0);
|
||||
mSerialIOThread.sendMessage(msgSetHistoryEntry_v2);
|
||||
danaPump.lastHistoryFetched = Math.min(danaPump.lastHistoryFetched, time - T.Companion.mins(1).msecs());
|
||||
danaPump.readHistoryFrom = Math.min(danaPump.readHistoryFrom, time - T.Companion.mins(1).msecs());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -433,18 +433,17 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService {
|
|||
if (!isConnected())
|
||||
return new PumpEnactResult(injector).success(false);
|
||||
SystemClock.sleep(300);
|
||||
MsgHistoryEventsV2 msg = new MsgHistoryEventsV2(injector, danaPump.lastHistoryFetched);
|
||||
aapsLogger.debug(LTag.PUMP, "Loading event history from: " + dateUtil.dateAndTimeString(danaPump.lastHistoryFetched));
|
||||
MsgHistoryEventsV2 msg = new MsgHistoryEventsV2(injector, danaPump.readHistoryFrom);
|
||||
aapsLogger.debug(LTag.PUMP, "Loading event history from: " + dateUtil.dateAndTimeString(danaPump.readHistoryFrom));
|
||||
|
||||
mSerialIOThread.sendMessage(msg);
|
||||
while (!danaPump.historyDoneReceived && mRfcommSocket.isConnected()) {
|
||||
SystemClock.sleep(100);
|
||||
}
|
||||
SystemClock.sleep(200);
|
||||
if (danaRv2Plugin.lastEventTimeLoaded != 0)
|
||||
danaPump.lastHistoryFetched = danaRv2Plugin.lastEventTimeLoaded - T.Companion.mins(1).msecs();
|
||||
if (danaPump.getLastEventTimeLoaded() != 0) danaPump.readHistoryFrom = danaPump.getLastEventTimeLoaded() - T.Companion.mins(1).msecs();
|
||||
else
|
||||
danaPump.lastHistoryFetched = 0;
|
||||
danaPump.readHistoryFrom = 0;
|
||||
danaPump.setLastConnection(System.currentTimeMillis());
|
||||
return new PumpEnactResult(injector).success(true);
|
||||
}
|
||||
|
|
|
@ -262,19 +262,13 @@ class DanaRSService : DaggerService() {
|
|||
return result
|
||||
}
|
||||
SystemClock.sleep(1000)
|
||||
val msg: DanaRSPacketAPSHistoryEvents
|
||||
if (danaPump.lastHistoryFetched == 0L) {
|
||||
msg = DanaRSPacketAPSHistoryEvents(injector, 0)
|
||||
aapsLogger.debug(LTag.PUMPCOMM, "Loading complete event history")
|
||||
} else {
|
||||
msg = DanaRSPacketAPSHistoryEvents(injector, danaPump.lastHistoryFetched)
|
||||
aapsLogger.debug(LTag.PUMPCOMM, "Loading event history from: " + dateUtil.dateAndTimeString(danaPump.lastHistoryFetched))
|
||||
}
|
||||
val msg = DanaRSPacketAPSHistoryEvents(injector, danaPump.readHistoryFrom)
|
||||
aapsLogger.debug(LTag.PUMPCOMM, "Loading event history from: " + dateUtil.dateAndTimeString(danaPump.readHistoryFrom))
|
||||
sendMessage(msg)
|
||||
while (!danaPump.historyDoneReceived && bleComm.isConnected) {
|
||||
SystemClock.sleep(100)
|
||||
}
|
||||
danaPump.lastHistoryFetched = if (danaPump.lastEventTimeLoaded != 0L) danaPump.lastEventTimeLoaded - T.mins(1).msecs() else 0
|
||||
danaPump.readHistoryFrom = if (danaPump.lastEventTimeLoaded != 0L) danaPump.lastEventTimeLoaded - T.mins(1).msecs() else 0
|
||||
aapsLogger.debug(LTag.PUMPCOMM, "Events loaded")
|
||||
rxBus.send(EventPumpStatusChanged(rh.gs(info.nightscout.pump.dana.R.string.gettingpumpstatus)))
|
||||
sendMessage(DanaRSPacketGeneralInitialScreenInformation(injector))
|
||||
|
@ -305,7 +299,7 @@ class DanaRSService : DaggerService() {
|
|||
// sendMessage(msg);
|
||||
val msgSetHistoryEntryV2 = DanaRSPacketAPSSetEventHistory(injector, DanaPump.HistoryEntry.CARBS.value, carbTime, carbs, 0)
|
||||
sendMessage(msgSetHistoryEntryV2)
|
||||
danaPump.lastHistoryFetched = min(danaPump.lastHistoryFetched, carbTime - T.mins(1).msecs())
|
||||
danaPump.readHistoryFrom = min(danaPump.readHistoryFrom, carbTime - T.mins(1).msecs())
|
||||
if (!msgSetHistoryEntryV2.isReceived || msgSetHistoryEntryV2.failed)
|
||||
uiInteraction.runAlarm(rh.gs(info.nightscout.pump.dana.R.string.carbs_store_error), rh.gs(info.nightscout.core.ui.R.string.error), info.nightscout.core.ui.R.raw.boluserror)
|
||||
}
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
<string name="patch_buzzer_reminders">패치 버저 알림</string>
|
||||
|
||||
<string name="time_format_a_h_mm">h:mm a</string>
|
||||
<string name="bolusdelivered">볼루스 %1$.2f U의 주입이 완료되었습니다.</string>
|
||||
<string name="eopatch_ble_status">BLE 상태</string>
|
||||
<string name="eopatch_serial_number">일련 번호</string>
|
||||
<string name="eopatch_lot_number">로트 번호</string>
|
||||
|
|
Loading…
Reference in a new issue