ruffy: add empty battery symbol and parsing.

This commit is contained in:
Johannes Mockenhaupt 2017-10-21 10:47:57 +02:00
parent e2d684ac33
commit 6ec1011bd7
No known key found for this signature in database
GPG key ID: 9E1EA6AF7BBBB0D1
6 changed files with 28 additions and 19 deletions

View file

@ -25,7 +25,6 @@ public class PumpState {
public static final int LOW = 1; public static final int LOW = 1;
public static final int EMPTY = 2; public static final int EMPTY = 2;
public int batteryState = - 1; public int batteryState = - 1;
public int insulinState = -1; public int insulinState = -1;

View file

@ -437,8 +437,7 @@ public class RuffyScripter implements RuffyCommands {
state.tbrRemainingDuration = durationMenuTime.getHour() * 60 + durationMenuTime.getMinute(); state.tbrRemainingDuration = durationMenuTime.getHour() * 60 + durationMenuTime.getMinute();
state.tbrRate = ((double) menu.getAttribute(MenuAttribute.BASAL_RATE)); state.tbrRate = ((double) menu.getAttribute(MenuAttribute.BASAL_RATE));
} }
// ruffy doesn't support 'empty battery' flag, not sure if the pump does state.batteryState = ((int) menu.getAttribute(MenuAttribute.BATTERY_STATE));
state.batteryState = ((boolean) menu.getAttribute(MenuAttribute.LOW_BATTERY)) ? PumpState.LOW : -1;
state.insulinState = ((int) menu.getAttribute(MenuAttribute.INSULIN_STATE)); state.insulinState = ((int) menu.getAttribute(MenuAttribute.INSULIN_STATE));
// TODO v2, read current base basal rate, which is shown center when no TBR is active. // TODO v2, read current base basal rate, which is shown center when no TBR is active.
// Check if that holds true when an extended bolus is running. // Check if that holds true when an extended bolus is running.
@ -448,8 +447,7 @@ public class RuffyScripter implements RuffyCommands {
state.errorMsg = (String) menu.getAttribute(MenuAttribute.MESSAGE); state.errorMsg = (String) menu.getAttribute(MenuAttribute.MESSAGE);
} else if (menuType == MenuType.STOP) { } else if (menuType == MenuType.STOP) {
state.suspended = true; state.suspended = true;
// ruffy doesn't support 'empty battery' flag, not sure if the pump does state.batteryState = ((int) menu.getAttribute(MenuAttribute.BATTERY_STATE));
state.batteryState = ((boolean) menu.getAttribute(MenuAttribute.LOW_BATTERY)) ? PumpState.LOW : -1;
state.insulinState = ((int) menu.getAttribute(MenuAttribute.INSULIN_STATE)); state.insulinState = ((int) menu.getAttribute(MenuAttribute.INSULIN_STATE));
} else { } else {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();

View file

@ -11,7 +11,7 @@ public enum MenuAttribute {
TBR,//double 0-500% TBR,//double 0-500%
BASAL_RATE,//double units/h BASAL_RATE,//double units/h
BASAL_SELECTED,//int selected basal profile BASAL_SELECTED,//int selected basal profile
LOW_BATTERY,//boolean low battery warning BATTERY_STATE,//int, like insulin state
INSULIN_STATE,//int insulin warning 0 == no warning, 1== low, 2 == empty INSULIN_STATE,//int insulin warning 0 == no warning, 1== low, 2 == empty
LOCK_STATE,//int keylock state 0==no lock, 1==unlocked, 2==locked LOCK_STATE,//int keylock state 0==no lock, 1==unlocked, 2==locked
MULTIWAVE_BOLUS,//double immediate bolus on multiwave MULTIWAVE_BOLUS,//double immediate bolus on multiwave

View file

@ -10,6 +10,7 @@ public enum Symbol {
LOCK_OPENED, LOCK_OPENED,
CHECK, CHECK,
LOW_BAT, LOW_BAT,
NO_BAT,
WARNING, WARNING,
DIVIDE, DIVIDE,
LOW_INSULIN, LOW_INSULIN,

View file

@ -620,7 +620,7 @@ public class MenuFactory {
stage = 0; stage = 0;
int lowInsulin = 0; int lowInsulin = 0;
boolean lowBattery= false; int lowBattery= 0;
boolean waranty= true; boolean waranty= true;
int lockState = 0; int lockState = 0;
while(tokens[3].size()>0) { while(tokens[3].size()>0) {
@ -629,7 +629,9 @@ public class MenuFactory {
switch (stage) { switch (stage) {
case 0: case 0:
if (isSymbol(p, Symbol.LOW_BAT)) { if (isSymbol(p, Symbol.LOW_BAT)) {
lowBattery = true; lowBattery= 1;
} else if (isSymbol(p, Symbol.NO_BAT)) {
lowBattery= 2;
} else if (isSymbol(p, Symbol.LOW_INSULIN)) { } else if (isSymbol(p, Symbol.LOW_INSULIN)) {
lowInsulin= 1; lowInsulin= 1;
} else if (isSymbol(p, Symbol.NO_INSULIN)) { } else if (isSymbol(p, Symbol.NO_INSULIN)) {
@ -648,10 +650,8 @@ public class MenuFactory {
return null; return null;
} }
} }
if(lowBattery)
m.setAttribute(MenuAttribute.LOW_BATTERY,new Boolean(true)); m.setAttribute(MenuAttribute.BATTERY_STATE,lowBattery);
else
m.setAttribute(MenuAttribute.LOW_BATTERY,new Boolean(false));
m.setAttribute(MenuAttribute.INSULIN_STATE,lowInsulin); m.setAttribute(MenuAttribute.INSULIN_STATE,lowInsulin);
@ -2334,7 +2334,7 @@ public class MenuFactory {
stage = 0; stage = 0;
number.clear(); number.clear();
int lowInsulin = 0; int lowInsulin = 0;
boolean lowBattery= false; int lowBattery= 0;
boolean waranty = true; boolean waranty = true;
int lockState = 0; int lockState = 0;
@ -2351,7 +2351,9 @@ public class MenuFactory {
number.add(p); number.add(p);
stage++; stage++;
} else if (isSymbol(p, Symbol.LOW_BAT)) { } else if (isSymbol(p, Symbol.LOW_BAT)) {
lowBattery = true; lowBattery = 1;
} else if (isSymbol(p, Symbol.NO_BAT)) {
lowBattery = 2;
} else if (isSymbol(p, Symbol.LOW_INSULIN)) { } else if (isSymbol(p, Symbol.LOW_INSULIN)) {
lowInsulin= 1; lowInsulin= 1;
} else if (isSymbol(p, Symbol.NO_INSULIN)) { } else if (isSymbol(p, Symbol.NO_INSULIN)) {
@ -2368,7 +2370,9 @@ public class MenuFactory {
break; break;
case 1: case 1:
if (isSymbol(p, Symbol.LOW_BAT)) { if (isSymbol(p, Symbol.LOW_BAT)) {
lowBattery = true; lowBattery = 1;
} else if (isSymbol(p, Symbol.NO_BAT)) {
lowBattery = 2;
} else if (isSymbol(p, Symbol.LOW_INSULIN)) { } else if (isSymbol(p, Symbol.LOW_INSULIN)) {
lowInsulin = 1; lowInsulin = 1;
} else if (isSymbol(p, Symbol.NO_INSULIN)) { } else if (isSymbol(p, Symbol.NO_INSULIN)) {
@ -2385,11 +2389,8 @@ public class MenuFactory {
break; break;
} }
} }
if(lowBattery)
m.setAttribute(MenuAttribute.LOW_BATTERY,new Boolean(true));
else
m.setAttribute(MenuAttribute.LOW_BATTERY,new Boolean(false));
m.setAttribute(MenuAttribute.BATTERY_STATE,lowBattery);
m.setAttribute(MenuAttribute.INSULIN_STATE,lowInsulin); m.setAttribute(MenuAttribute.INSULIN_STATE,lowInsulin);
m.setAttribute(MenuAttribute.WARANTY,new Boolean(waranty)); m.setAttribute(MenuAttribute.WARANTY,new Boolean(waranty));

View file

@ -926,6 +926,16 @@ public class SmallTextParser {
"█ █ ", "█ █ ",
"██████████ " "██████████ "
});
symbols.put(Symbol.NO_BAT, new String[]{
"██████████ ",
"█ █ ",
"█ ██",
"█ █",
"█ ██",
"█ █ ",
"██████████ "
}); });
symbols.put(Symbol.LOW_INSULIN, new String[]{ symbols.put(Symbol.LOW_INSULIN, new String[]{
"█████████████ ", "█████████████ ",