the same for korean danar
This commit is contained in:
parent
538e8fd2fa
commit
926a26a724
|
@ -77,10 +77,6 @@ public class SerialIOThread extends Thread {
|
|||
|
||||
if (Config.logDanaMessageDetail)
|
||||
log.debug("<<<<< " + message.getMessageName() + " " + message.toHexString(extractedBuff));
|
||||
if (message.getCommand() == 0xF0F1) {
|
||||
DanaRPlugin.getDanaRPump().isNewPump = true;
|
||||
log.debug("New firmware confirmed");
|
||||
}
|
||||
|
||||
// process the message content
|
||||
message.received = true;
|
||||
|
|
|
@ -279,7 +279,6 @@ public class ExecutionService extends Service {
|
|||
MsgStatusBolusExtended exStatusMsg = new MsgStatusBolusExtended();
|
||||
MsgCheckValue checkValue = new MsgCheckValue();
|
||||
|
||||
|
||||
if (danaRPump.isNewPump) {
|
||||
mSerialIOThread.sendMessage(checkValue);
|
||||
if (!checkValue.received) {
|
||||
|
|
|
@ -24,6 +24,9 @@ public class MsgCheckValue extends MessageBase {
|
|||
public void handleMessage(byte[] bytes) {
|
||||
DanaRPump pump = DanaRPlugin.getDanaRPump();
|
||||
|
||||
DanaRPlugin.getDanaRPump().isNewPump = true;
|
||||
log.debug("New firmware confirmed");
|
||||
|
||||
pump.model = intFromBuff(bytes, 0, 1);
|
||||
pump.protocol = intFromBuff(bytes, 1, 1);
|
||||
pump.productCode = intFromBuff(bytes, 2, 1);
|
||||
|
|
|
@ -60,6 +60,7 @@ public class DanaRKoreanFragment extends Fragment implements FragmentBase {
|
|||
TextView batteryView;
|
||||
TextView reservoirView;
|
||||
TextView iobView;
|
||||
TextView firmwareView;
|
||||
Button viewProfileButton;
|
||||
Button historyButton;
|
||||
|
||||
|
@ -100,6 +101,7 @@ public class DanaRKoreanFragment extends Fragment implements FragmentBase {
|
|||
batteryView = (TextView) view.findViewById(R.id.danar_battery);
|
||||
reservoirView = (TextView) view.findViewById(R.id.danar_reservoir);
|
||||
iobView = (TextView) view.findViewById(R.id.danar_iob);
|
||||
firmwareView = (TextView) view.findViewById(R.id.danar_firmware);
|
||||
viewProfileButton = (Button) view.findViewById(R.id.danar_viewprofile);
|
||||
historyButton = (Button) view.findViewById(R.id.danar_history);
|
||||
|
||||
|
@ -192,24 +194,24 @@ public class DanaRKoreanFragment extends Fragment implements FragmentBase {
|
|||
@SuppressLint("SetTextI18n")
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
if (DanaRKoreanPlugin.getDanaRPump().lastConnection.getTime() != 0) {
|
||||
Long agoMsec = new Date().getTime() - DanaRKoreanPlugin.getDanaRPump().lastConnection.getTime();
|
||||
DanaRKoreanPump pump = DanaRKoreanPlugin.getDanaRPump();
|
||||
if (pump.lastConnection.getTime() != 0) {
|
||||
Long agoMsec = new Date().getTime() - pump.lastConnection.getTime();
|
||||
int agoMin = (int) (agoMsec / 60d / 1000d);
|
||||
lastConnectionView.setText(DateUtil.timeString(DanaRKoreanPlugin.getDanaRPump().lastConnection) + " (" + String.format(MainApp.sResources.getString(R.string.minago), agoMin) + ")");
|
||||
lastConnectionView.setText(DateUtil.timeString(pump.lastConnection) + " (" + String.format(MainApp.sResources.getString(R.string.minago), agoMin) + ")");
|
||||
SetWarnColor.setColor(lastConnectionView, agoMin, 16d, 31d);
|
||||
}
|
||||
// if (DanaRKoreanPlugin.getDanaRPump().lastBolusTime.getTime() != 0) {
|
||||
// Long agoMsec = new Date().getTime() - DanaRKoreanPlugin.getDanaRPump().lastBolusTime.getTime();
|
||||
// if (pump.lastBolusTime.getTime() != 0) {
|
||||
// Long agoMsec = new Date().getTime() - pump.lastBolusTime.getTime();
|
||||
// double agoHours = agoMsec / 60d / 60d / 1000d;
|
||||
// if (agoHours < 6) // max 6h back
|
||||
// lastBolusView.setText(formatTime.format(DanaRKoreanPlugin.getDanaRPump().lastBolusTime) + " (" + DecimalFormatter.to1Decimal(agoHours) + " " + getString(R.string.hoursago) + ") " + DecimalFormatter.to2Decimal(danaRKoreanPlugin.getDanaRPump().lastBolusAmount) + " U");
|
||||
// lastBolusView.setText(formatTime.format(pump.lastBolusTime) + " (" + DecimalFormatter.to1Decimal(agoHours) + " " + getString(R.string.hoursago) + ") " + DecimalFormatter.to2Decimal(pump.lastBolusAmount) + " U");
|
||||
// else lastBolusView.setText("");
|
||||
// }
|
||||
|
||||
dailyUnitsView.setText(DecimalFormatter.to0Decimal(DanaRKoreanPlugin.getDanaRPump().dailyTotalUnits) + " / " + DanaRKoreanPlugin.getDanaRPump().maxDailyTotalUnits + " U");
|
||||
SetWarnColor.setColor(dailyUnitsView, DanaRKoreanPlugin.getDanaRPump().dailyTotalUnits, DanaRKoreanPlugin.getDanaRPump().maxDailyTotalUnits * 0.75d, DanaRKoreanPlugin.getDanaRPump().maxDailyTotalUnits * 0.9d);
|
||||
basaBasalRateView.setText("( " + (DanaRKoreanPlugin.getDanaRPump().activeProfile + 1) + " ) " + DecimalFormatter.to2Decimal(danaRKoreanPlugin.getBaseBasalRate()) + " U/h");
|
||||
dailyUnitsView.setText(DecimalFormatter.to0Decimal(pump.dailyTotalUnits) + " / " + pump.maxDailyTotalUnits + " U");
|
||||
SetWarnColor.setColor(dailyUnitsView, pump.dailyTotalUnits, pump.maxDailyTotalUnits * 0.75d, pump.maxDailyTotalUnits * 0.9d);
|
||||
basaBasalRateView.setText("( " + (pump.activeProfile + 1) + " ) " + DecimalFormatter.to2Decimal(danaRKoreanPlugin.getBaseBasalRate()) + " U/h");
|
||||
if (danaRKoreanPlugin.isRealTempBasalInProgress()) {
|
||||
tempBasalView.setText(danaRKoreanPlugin.getRealTempBasal().toString());
|
||||
} else {
|
||||
|
@ -220,11 +222,16 @@ public class DanaRKoreanFragment extends Fragment implements FragmentBase {
|
|||
} else {
|
||||
extendedBolusView.setText("");
|
||||
}
|
||||
reservoirView.setText(DecimalFormatter.to0Decimal(DanaRKoreanPlugin.getDanaRPump().reservoirRemainingUnits) + " / 300 U");
|
||||
SetWarnColor.setColorInverse(reservoirView, DanaRKoreanPlugin.getDanaRPump().reservoirRemainingUnits, 50d, 20d);
|
||||
batteryView.setText("{fa-battery-" + (DanaRKoreanPlugin.getDanaRPump().batteryRemaining / 25) + "}");
|
||||
SetWarnColor.setColorInverse(batteryView, DanaRKoreanPlugin.getDanaRPump().batteryRemaining, 51d, 26d);
|
||||
iobView.setText(DanaRKoreanPlugin.getDanaRPump().iob + " U");
|
||||
reservoirView.setText(DecimalFormatter.to0Decimal(pump.reservoirRemainingUnits) + " / 300 U");
|
||||
SetWarnColor.setColorInverse(reservoirView, pump.reservoirRemainingUnits, 50d, 20d);
|
||||
batteryView.setText("{fa-battery-" + (pump.batteryRemaining / 25) + "}");
|
||||
SetWarnColor.setColorInverse(batteryView, pump.batteryRemaining, 51d, 26d);
|
||||
iobView.setText(pump.iob + " U");
|
||||
if (pump.isNewPump) {
|
||||
firmwareView.setText(String.format(getString(R.string.danar_model), pump.model, pump.protocol, pump.productCode));
|
||||
} else {
|
||||
firmwareView.setText("OLD");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ public class DanaRKoreanPump {
|
|||
public String serialNumber = "";
|
||||
public Date shippingDate = new Date(0);
|
||||
public String shippingCountry = "";
|
||||
public boolean isNewPump = false;
|
||||
public boolean isNewPump = true;
|
||||
public int password = -1;
|
||||
public Date pumpTime = new Date(0);
|
||||
|
||||
|
|
|
@ -176,6 +176,10 @@ public class SerialIOThread extends Thread {
|
|||
}
|
||||
if (!message.received) {
|
||||
log.warn("Reply not received " + message.getMessageName());
|
||||
if (message.getCommand() == 0xF0F1) {
|
||||
DanaRKoreanPlugin.getDanaRPump().isNewPump = false;
|
||||
log.debug("Old firmware detected");
|
||||
}
|
||||
}
|
||||
scheduleDisconnection();
|
||||
}
|
||||
|
|
|
@ -222,6 +222,7 @@ public class ExecutionService extends Service {
|
|||
if (!getPumpStatus()) {
|
||||
mSerialIOThread.disconnect("getPumpStatus failed");
|
||||
waitMsec(3000);
|
||||
getBTSocketForSelectedPump();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -272,7 +273,14 @@ public class ExecutionService extends Service {
|
|||
MsgStatusBasic statusBasicMsg = new MsgStatusBasic();
|
||||
MsgStatusTempBasal tempStatusMsg = new MsgStatusTempBasal();
|
||||
MsgStatusBolusExtended exStatusMsg = new MsgStatusBolusExtended();
|
||||
MsgCheckValue checkValue = new MsgCheckValue();
|
||||
|
||||
if (danaRKoreanPump.isNewPump) {
|
||||
mSerialIOThread.sendMessage(checkValue);
|
||||
if (!checkValue.received) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
mSerialIOThread.sendMessage(new MsgSettingShippingInfo()); // TODO: show it somewhere
|
||||
mSerialIOThread.sendMessage(tempStatusMsg); // do this before statusBasic because here is temp duration
|
||||
|
@ -280,8 +288,6 @@ public class ExecutionService extends Service {
|
|||
//mSerialIOThread.sendMessage(statusMsg);
|
||||
mSerialIOThread.sendMessage(statusBasicMsg);
|
||||
|
||||
mSerialIOThread.sendMessage(new MsgCheckValue());
|
||||
|
||||
// if (!statusMsg.received) {
|
||||
// mSerialIOThread.sendMessage(statusMsg);
|
||||
// }
|
||||
|
|
|
@ -25,6 +25,9 @@ public class MsgCheckValue extends MessageBase {
|
|||
public void handleMessage(byte[] bytes) {
|
||||
DanaRKoreanPump pump = DanaRKoreanPlugin.getDanaRPump();
|
||||
|
||||
DanaRKoreanPlugin.getDanaRPump().isNewPump = true;
|
||||
log.debug("New firmware confirmed");
|
||||
|
||||
pump.model = intFromBuff(bytes, 0, 1);
|
||||
pump.protocol = intFromBuff(bytes, 1, 1);
|
||||
pump.productCode = intFromBuff(bytes, 2, 1);
|
||||
|
|
|
@ -25,10 +25,6 @@ public class MsgSettingShippingInfo extends MessageBase {
|
|||
pump.serialNumber = stringFromBuff(bytes, 0, 10);
|
||||
pump.shippingDate = dateFromBuff(bytes, 10);
|
||||
pump.shippingCountry = asciiStringFromBuff(bytes, 13, 3);
|
||||
if (pump.shippingDate.getTime() > new Date(116, 4, 1).getTime()) {
|
||||
pump.isNewPump = true;
|
||||
} else
|
||||
pump.isNewPump = false;
|
||||
if (Config.logDanaMessageDetail) {
|
||||
log.debug("Serial number: " + pump.serialNumber);
|
||||
log.debug("Shipping date: " + pump.shippingDate);
|
||||
|
|
Loading…
Reference in a new issue