pump status tweaking
This commit is contained in:
parent
de124b8e3e
commit
5f4eb1e4c4
|
@ -0,0 +1,50 @@
|
||||||
|
package info.nightscout.androidaps.events;
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.MainApp;
|
||||||
|
import info.nightscout.androidaps.R;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by mike on 19.02.2017.
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class EventPumpStatusChanged {
|
||||||
|
public static final int CONNECTING = 0;
|
||||||
|
public static final int CONNECTED = 1;
|
||||||
|
public static final int PERFORMING = 2;
|
||||||
|
public static final int DISCONNECTING = 3;
|
||||||
|
public static final int DISCONNECTED = 4;
|
||||||
|
|
||||||
|
public int sStatus = DISCONNECTED;
|
||||||
|
public int sSecondsElapsed = 0;
|
||||||
|
public String sPerfomingAction = "";
|
||||||
|
|
||||||
|
public EventPumpStatusChanged(int status) {
|
||||||
|
sStatus = status;
|
||||||
|
sSecondsElapsed = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public EventPumpStatusChanged(int status, int secondsElapsed) {
|
||||||
|
sStatus = status;
|
||||||
|
sSecondsElapsed = secondsElapsed;
|
||||||
|
}
|
||||||
|
|
||||||
|
public EventPumpStatusChanged(String action) {
|
||||||
|
sStatus = PERFORMING;
|
||||||
|
sSecondsElapsed = 0;
|
||||||
|
sPerfomingAction = action;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String textStatus() {
|
||||||
|
if (sStatus == CONNECTING)
|
||||||
|
return String.format(MainApp.sResources.getString(R.string.danar_history_connectingfor), sSecondsElapsed);
|
||||||
|
else if (sStatus == CONNECTED)
|
||||||
|
return MainApp.sResources.getString(R.string.connected);
|
||||||
|
else if (sStatus == PERFORMING)
|
||||||
|
return sPerfomingAction;
|
||||||
|
else if (sStatus == DISCONNECTING)
|
||||||
|
return MainApp.sResources.getString(R.string.disconnecting);
|
||||||
|
else if (sStatus == DISCONNECTED)
|
||||||
|
return "";
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
|
@ -29,8 +29,8 @@ public interface PumpInterface {
|
||||||
int setNewBasalProfile(NSProfile profile);
|
int setNewBasalProfile(NSProfile profile);
|
||||||
boolean isThisProfileSet(NSProfile profile);
|
boolean isThisProfileSet(NSProfile profile);
|
||||||
|
|
||||||
Date lastStatusTime();
|
Date lastDataTime();
|
||||||
void updateStatus(String reason);
|
void refreshDataFromPump(String reason);
|
||||||
|
|
||||||
double getBaseBasalRate(); // base basal rate, not temp basal
|
double getBaseBasalRate(); // base basal rate, not temp basal
|
||||||
double getTempBasalAbsoluteRate();
|
double getTempBasalAbsoluteRate();
|
||||||
|
@ -51,7 +51,9 @@ public interface PumpInterface {
|
||||||
JSONObject getJSONStatus();
|
JSONObject getJSONStatus();
|
||||||
String deviceID();
|
String deviceID();
|
||||||
|
|
||||||
|
// Pump capabilities
|
||||||
PumpDescription getPumpDescription();
|
PumpDescription getPumpDescription();
|
||||||
|
|
||||||
public String shortStatus(boolean veryShort);
|
// Short info for SMS, Wear etc
|
||||||
|
String shortStatus(boolean veryShort);
|
||||||
}
|
}
|
||||||
|
|
|
@ -390,13 +390,13 @@ public class ConfigBuilderPlugin implements PluginBase, PumpInterface, Constrain
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Date lastStatusTime() {
|
public Date lastDataTime() {
|
||||||
return activePump.lastStatusTime();
|
return activePump.lastDataTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateStatus(String reason) {
|
public void refreshDataFromPump(String reason) {
|
||||||
activePump.updateStatus(reason);
|
activePump.refreshDataFromPump(reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -682,7 +682,7 @@ public class ConfigBuilderPlugin implements PluginBase, PumpInterface, Constrain
|
||||||
public String deviceID() {
|
public String deviceID() {
|
||||||
if (activePump != null)
|
if (activePump != null)
|
||||||
return activePump.deviceID();
|
return activePump.deviceID();
|
||||||
else return "Unknown";
|
else return "No Pump active!";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -24,12 +24,12 @@ import java.util.Date;
|
||||||
|
|
||||||
import info.nightscout.androidaps.MainApp;
|
import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
|
import info.nightscout.androidaps.events.EventPumpStatusChanged;
|
||||||
import info.nightscout.androidaps.events.EventTempBasalChange;
|
import info.nightscout.androidaps.events.EventTempBasalChange;
|
||||||
import info.nightscout.androidaps.interfaces.FragmentBase;
|
import info.nightscout.androidaps.interfaces.FragmentBase;
|
||||||
import info.nightscout.androidaps.plugins.DanaR.Dialogs.ProfileViewDialog;
|
import info.nightscout.androidaps.plugins.DanaR.Dialogs.ProfileViewDialog;
|
||||||
import info.nightscout.androidaps.plugins.DanaR.History.DanaRHistoryActivity;
|
import info.nightscout.androidaps.plugins.DanaR.History.DanaRHistoryActivity;
|
||||||
import info.nightscout.androidaps.plugins.DanaR.History.DanaRStatsActivity;
|
import info.nightscout.androidaps.plugins.DanaR.History.DanaRStatsActivity;
|
||||||
import info.nightscout.androidaps.plugins.DanaR.events.EventDanaRConnectionStatus;
|
|
||||||
import info.nightscout.androidaps.plugins.DanaR.events.EventDanaRNewStatus;
|
import info.nightscout.androidaps.plugins.DanaR.events.EventDanaRNewStatus;
|
||||||
import info.nightscout.utils.DateUtil;
|
import info.nightscout.utils.DateUtil;
|
||||||
import info.nightscout.utils.DecimalFormatter;
|
import info.nightscout.utils.DecimalFormatter;
|
||||||
|
@ -165,18 +165,18 @@ public class DanaRFragment extends Fragment implements FragmentBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onStatusEvent(final EventDanaRConnectionStatus c) {
|
public void onStatusEvent(final EventPumpStatusChanged c) {
|
||||||
Activity activity = getActivity();
|
Activity activity = getActivity();
|
||||||
if (activity != null) {
|
if (activity != null) {
|
||||||
activity.runOnUiThread(
|
activity.runOnUiThread(
|
||||||
new Runnable() {
|
new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (c.sStatus == EventDanaRConnectionStatus.CONNECTING)
|
if (c.sStatus == EventPumpStatusChanged.CONNECTING)
|
||||||
btConnectionView.setText("{fa-bluetooth-b spin} " + c.sSecondsElapsed + "s");
|
btConnectionView.setText("{fa-bluetooth-b spin} " + c.sSecondsElapsed + "s");
|
||||||
else if (c.sStatus == EventDanaRConnectionStatus.CONNECTED)
|
else if (c.sStatus == EventPumpStatusChanged.CONNECTED)
|
||||||
btConnectionView.setText("{fa-bluetooth}");
|
btConnectionView.setText("{fa-bluetooth}");
|
||||||
else
|
else if (c.sStatus == EventPumpStatusChanged.DISCONNECTED)
|
||||||
btConnectionView.setText("{fa-bluetooth-b}");
|
btConnectionView.setText("{fa-bluetooth-b}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -285,12 +285,12 @@ public class DanaRPlugin implements PluginBase, PumpInterface, ConstraintsInterf
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Date lastStatusTime() {
|
public Date lastDataTime() {
|
||||||
return getDanaRPump().lastConnection;
|
return getDanaRPump().lastConnection;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateStatus(String reason) {
|
public void refreshDataFromPump(String reason) {
|
||||||
if (!isConnected() && !isConnecting()) {
|
if (!isConnected() && !isConnecting()) {
|
||||||
doConnect(reason);
|
doConnect(reason);
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,10 +38,10 @@ import info.nightscout.androidaps.Constants;
|
||||||
import info.nightscout.androidaps.MainApp;
|
import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.db.DanaRHistoryRecord;
|
import info.nightscout.androidaps.db.DanaRHistoryRecord;
|
||||||
|
import info.nightscout.androidaps.events.EventPumpStatusChanged;
|
||||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||||
import info.nightscout.androidaps.plugins.DanaR.Services.ExecutionService;
|
import info.nightscout.androidaps.plugins.DanaR.Services.ExecutionService;
|
||||||
import info.nightscout.androidaps.plugins.DanaR.comm.RecordTypes;
|
import info.nightscout.androidaps.plugins.DanaR.comm.RecordTypes;
|
||||||
import info.nightscout.androidaps.plugins.DanaR.events.EventDanaRConnectionStatus;
|
|
||||||
import info.nightscout.androidaps.plugins.DanaR.events.EventDanaRSyncStatus;
|
import info.nightscout.androidaps.plugins.DanaR.events.EventDanaRSyncStatus;
|
||||||
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSProfile;
|
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSProfile;
|
||||||
import info.nightscout.utils.DateUtil;
|
import info.nightscout.utils.DateUtil;
|
||||||
|
@ -306,7 +306,7 @@ public class DanaRHistoryActivity extends Activity {
|
||||||
case RecordTypes.RECORD_TYPE_DAILY:
|
case RecordTypes.RECORD_TYPE_DAILY:
|
||||||
holder.dailybasal.setText(DecimalFormatter.to2Decimal(record.getRecordDailyBasal()) + "U");
|
holder.dailybasal.setText(DecimalFormatter.to2Decimal(record.getRecordDailyBasal()) + "U");
|
||||||
holder.dailybolus.setText(DecimalFormatter.to2Decimal(record.getRecordDailyBolus()) + "U");
|
holder.dailybolus.setText(DecimalFormatter.to2Decimal(record.getRecordDailyBolus()) + "U");
|
||||||
holder.dailytotal.setText(DecimalFormatter.to2Decimal(record.getRecordDailyBolus()+ record.getRecordDailyBasal()) + "U");
|
holder.dailytotal.setText(DecimalFormatter.to2Decimal(record.getRecordDailyBolus() + record.getRecordDailyBasal()) + "U");
|
||||||
holder.time.setText(DateUtil.dateString(record.getRecordDate()));
|
holder.time.setText(DateUtil.dateString(record.getRecordDate()));
|
||||||
holder.time.setVisibility(View.VISIBLE);
|
holder.time.setVisibility(View.VISIBLE);
|
||||||
holder.value.setVisibility(View.GONE);
|
holder.value.setVisibility(View.GONE);
|
||||||
|
@ -434,21 +434,12 @@ public class DanaRHistoryActivity extends Activity {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onStatusEvent(final EventDanaRConnectionStatus c) {
|
public void onStatusEvent(final EventPumpStatusChanged s) {
|
||||||
runOnUiThread(
|
runOnUiThread(
|
||||||
new Runnable() {
|
new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (c.sStatus == EventDanaRConnectionStatus.CONNECTING) {
|
statusView.setText(s.textStatus());
|
||||||
statusView.setText(String.format(getString(R.string.danar_history_connectingfor), c.sSecondsElapsed));
|
|
||||||
log.debug("EventDanaRConnectionStatus: " + "Connecting for " + c.sSecondsElapsed + "s");
|
|
||||||
} else if (c.sStatus == EventDanaRConnectionStatus.CONNECTED) {
|
|
||||||
statusView.setText(MainApp.sResources.getString(R.string.connected));
|
|
||||||
log.debug("EventDanaRConnectionStatus: Connected");
|
|
||||||
} else {
|
|
||||||
statusView.setText(MainApp.sResources.getString(R.string.disconnected));
|
|
||||||
log.debug("EventDanaRConnectionStatus: Disconnected");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
|
@ -48,12 +48,12 @@ import java.util.List;
|
||||||
import info.nightscout.androidaps.MainApp;
|
import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.db.DanaRHistoryRecord;
|
import info.nightscout.androidaps.db.DanaRHistoryRecord;
|
||||||
|
import info.nightscout.androidaps.events.EventPumpStatusChanged;
|
||||||
import info.nightscout.androidaps.interfaces.ProfileInterface;
|
import info.nightscout.androidaps.interfaces.ProfileInterface;
|
||||||
import info.nightscout.androidaps.plugins.CircadianPercentageProfile.CircadianPercentageProfilePlugin;
|
import info.nightscout.androidaps.plugins.CircadianPercentageProfile.CircadianPercentageProfilePlugin;
|
||||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||||
import info.nightscout.androidaps.plugins.DanaR.Services.ExecutionService;
|
import info.nightscout.androidaps.plugins.DanaR.Services.ExecutionService;
|
||||||
import info.nightscout.androidaps.plugins.DanaR.comm.RecordTypes;
|
import info.nightscout.androidaps.plugins.DanaR.comm.RecordTypes;
|
||||||
import info.nightscout.androidaps.plugins.DanaR.events.EventDanaRConnectionStatus;
|
|
||||||
import info.nightscout.androidaps.plugins.DanaR.events.EventDanaRSyncStatus;
|
import info.nightscout.androidaps.plugins.DanaR.events.EventDanaRSyncStatus;
|
||||||
import info.nightscout.utils.DecimalFormatter;
|
import info.nightscout.utils.DecimalFormatter;
|
||||||
import info.nightscout.utils.SafeParse;
|
import info.nightscout.utils.SafeParse;
|
||||||
|
@ -68,11 +68,11 @@ public class DanaRStatsActivity extends Activity {
|
||||||
private Handler mHandler;
|
private Handler mHandler;
|
||||||
private static HandlerThread mHandlerThread;
|
private static HandlerThread mHandlerThread;
|
||||||
|
|
||||||
TextView statusView, statsMessage,totalBaseBasal2;
|
TextView statusView, statsMessage, totalBaseBasal2;
|
||||||
EditText totalBaseBasal;
|
EditText totalBaseBasal;
|
||||||
Button reloadButton;
|
Button reloadButton;
|
||||||
LinearLayoutManager llm;
|
LinearLayoutManager llm;
|
||||||
TableLayout tl,ctl,etl;
|
TableLayout tl, ctl, etl;
|
||||||
String TBB;
|
String TBB;
|
||||||
double magicNumber;
|
double magicNumber;
|
||||||
DecimalFormat decimalFormat;
|
DecimalFormat decimalFormat;
|
||||||
|
@ -118,15 +118,15 @@ public class DanaRStatsActivity extends Activity {
|
||||||
public boolean dispatchTouchEvent(MotionEvent event) {
|
public boolean dispatchTouchEvent(MotionEvent event) {
|
||||||
if (event.getAction() == MotionEvent.ACTION_DOWN) {
|
if (event.getAction() == MotionEvent.ACTION_DOWN) {
|
||||||
View myView = getCurrentFocus();
|
View myView = getCurrentFocus();
|
||||||
if ( myView instanceof EditText) {
|
if (myView instanceof EditText) {
|
||||||
Rect rect = new Rect();
|
Rect rect = new Rect();
|
||||||
myView.getGlobalVisibleRect(rect);
|
myView.getGlobalVisibleRect(rect);
|
||||||
if (!rect.contains((int)event.getRawX(), (int)event.getRawY())) {
|
if (!rect.contains((int) event.getRawX(), (int) event.getRawY())) {
|
||||||
myView.clearFocus();
|
myView.clearFocus();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return super.dispatchTouchEvent( event );
|
return super.dispatchTouchEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
ServiceConnection mConnection = new ServiceConnection() {
|
ServiceConnection mConnection = new ServiceConnection() {
|
||||||
|
@ -172,11 +172,11 @@ public class DanaRStatsActivity extends Activity {
|
||||||
totalBaseBasal.setText(TBB);
|
totalBaseBasal.setText(TBB);
|
||||||
|
|
||||||
ProfileInterface pi = ConfigBuilderPlugin.getActiveProfile();
|
ProfileInterface pi = ConfigBuilderPlugin.getActiveProfile();
|
||||||
if (pi != null && pi instanceof CircadianPercentageProfilePlugin){
|
if (pi != null && pi instanceof CircadianPercentageProfilePlugin) {
|
||||||
double cppTBB = ((CircadianPercentageProfilePlugin)pi).baseBasalSum();
|
double cppTBB = ((CircadianPercentageProfilePlugin) pi).baseBasalSum();
|
||||||
totalBaseBasal.setText(decimalFormat.format(cppTBB));
|
totalBaseBasal.setText(decimalFormat.format(cppTBB));
|
||||||
SharedPreferences.Editor edit = preferences.edit();
|
SharedPreferences.Editor edit = preferences.edit();
|
||||||
edit.putString("TBB",totalBaseBasal.getText().toString());
|
edit.putString("TBB", totalBaseBasal.getText().toString());
|
||||||
edit.commit();
|
edit.commit();
|
||||||
TBB = preferences.getString("TBB", "");
|
TBB = preferences.getString("TBB", "");
|
||||||
}
|
}
|
||||||
|
@ -312,7 +312,7 @@ public class DanaRStatsActivity extends Activity {
|
||||||
totalBaseBasal.setOnEditorActionListener(new TextView.OnEditorActionListener() {
|
totalBaseBasal.setOnEditorActionListener(new TextView.OnEditorActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
|
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
|
||||||
if(actionId== EditorInfo.IME_ACTION_DONE){
|
if (actionId == EditorInfo.IME_ACTION_DONE) {
|
||||||
totalBaseBasal.clearFocus();
|
totalBaseBasal.clearFocus();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -323,11 +323,11 @@ public class DanaRStatsActivity extends Activity {
|
||||||
totalBaseBasal.setOnFocusChangeListener(new View.OnFocusChangeListener() {
|
totalBaseBasal.setOnFocusChangeListener(new View.OnFocusChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onFocusChange(View v, boolean hasFocus) {
|
public void onFocusChange(View v, boolean hasFocus) {
|
||||||
if(hasFocus){
|
if (hasFocus) {
|
||||||
totalBaseBasal.getText().clear();
|
totalBaseBasal.getText().clear();
|
||||||
} else {
|
} else {
|
||||||
SharedPreferences.Editor edit = preferences.edit();
|
SharedPreferences.Editor edit = preferences.edit();
|
||||||
edit.putString("TBB",totalBaseBasal.getText().toString());
|
edit.putString("TBB", totalBaseBasal.getText().toString());
|
||||||
edit.commit();
|
edit.commit();
|
||||||
TBB = preferences.getString("TBB", "");
|
TBB = preferences.getString("TBB", "");
|
||||||
loadDataFromDB(RecordTypes.RECORD_TYPE_DAILY);
|
loadDataFromDB(RecordTypes.RECORD_TYPE_DAILY);
|
||||||
|
@ -362,15 +362,14 @@ public class DanaRStatsActivity extends Activity {
|
||||||
cleanTable(etl);
|
cleanTable(etl);
|
||||||
DateFormat df = new SimpleDateFormat("dd.MM.");
|
DateFormat df = new SimpleDateFormat("dd.MM.");
|
||||||
|
|
||||||
if(TextUtils.isEmpty(TBB)) {
|
if (TextUtils.isEmpty(TBB)) {
|
||||||
totalBaseBasal.setError("Please Enter Total Base Basal");
|
totalBaseBasal.setError("Please Enter Total Base Basal");
|
||||||
return;
|
return;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
magicNumber = SafeParse.stringToDouble(TBB);
|
magicNumber = SafeParse.stringToDouble(TBB);
|
||||||
}
|
}
|
||||||
|
|
||||||
magicNumber *=2;
|
magicNumber *= 2;
|
||||||
totalBaseBasal2.setText(decimalFormat.format(magicNumber));
|
totalBaseBasal2.setText(decimalFormat.format(magicNumber));
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
@ -379,45 +378,45 @@ public class DanaRStatsActivity extends Activity {
|
||||||
double weighted05 = 0d;
|
double weighted05 = 0d;
|
||||||
double weighted07 = 0d;
|
double weighted07 = 0d;
|
||||||
|
|
||||||
for (DanaRHistoryRecord record: historyList) {
|
for (DanaRHistoryRecord record : historyList) {
|
||||||
double tdd= record.getRecordDailyBolus() + record.getRecordDailyBasal();
|
double tdd = record.getRecordDailyBolus() + record.getRecordDailyBasal();
|
||||||
|
|
||||||
// Create the table row
|
// Create the table row
|
||||||
TableRow tr = new TableRow(DanaRStatsActivity.this);
|
TableRow tr = new TableRow(DanaRStatsActivity.this);
|
||||||
if(i%2!=0) tr.setBackgroundColor(Color.DKGRAY);
|
if (i % 2 != 0) tr.setBackgroundColor(Color.DKGRAY);
|
||||||
tr.setId(100+i);
|
tr.setId(100 + i);
|
||||||
tr.setLayoutParams(new TableLayout.LayoutParams(
|
tr.setLayoutParams(new TableLayout.LayoutParams(
|
||||||
TableLayout.LayoutParams.MATCH_PARENT,
|
TableLayout.LayoutParams.MATCH_PARENT,
|
||||||
TableLayout.LayoutParams.WRAP_CONTENT));
|
TableLayout.LayoutParams.WRAP_CONTENT));
|
||||||
|
|
||||||
// Here create the TextView dynamically
|
// Here create the TextView dynamically
|
||||||
TextView labelDATE = new TextView(DanaRStatsActivity.this);
|
TextView labelDATE = new TextView(DanaRStatsActivity.this);
|
||||||
labelDATE.setId(200+i);
|
labelDATE.setId(200 + i);
|
||||||
labelDATE.setText(df.format(new Date(record.getRecordDate())));
|
labelDATE.setText(df.format(new Date(record.getRecordDate())));
|
||||||
labelDATE.setTextColor(Color.WHITE);
|
labelDATE.setTextColor(Color.WHITE);
|
||||||
tr.addView(labelDATE);
|
tr.addView(labelDATE);
|
||||||
|
|
||||||
TextView labelBASAL = new TextView(DanaRStatsActivity.this);
|
TextView labelBASAL = new TextView(DanaRStatsActivity.this);
|
||||||
labelBASAL.setId(300+i);
|
labelBASAL.setId(300 + i);
|
||||||
labelBASAL.setText(DecimalFormatter.to2Decimal(record.getRecordDailyBasal()) + " U");
|
labelBASAL.setText(DecimalFormatter.to2Decimal(record.getRecordDailyBasal()) + " U");
|
||||||
labelBASAL.setTextColor(Color.WHITE);
|
labelBASAL.setTextColor(Color.WHITE);
|
||||||
tr.addView(labelBASAL);
|
tr.addView(labelBASAL);
|
||||||
|
|
||||||
TextView labelBOLUS = new TextView(DanaRStatsActivity.this);
|
TextView labelBOLUS = new TextView(DanaRStatsActivity.this);
|
||||||
labelBOLUS.setId(400+i);
|
labelBOLUS.setId(400 + i);
|
||||||
labelBOLUS.setText(DecimalFormatter.to2Decimal(record.getRecordDailyBolus()) + " U");
|
labelBOLUS.setText(DecimalFormatter.to2Decimal(record.getRecordDailyBolus()) + " U");
|
||||||
labelBOLUS.setTextColor(Color.WHITE);
|
labelBOLUS.setTextColor(Color.WHITE);
|
||||||
tr.addView(labelBOLUS);
|
tr.addView(labelBOLUS);
|
||||||
|
|
||||||
TextView labelTDD = new TextView(DanaRStatsActivity.this);
|
TextView labelTDD = new TextView(DanaRStatsActivity.this);
|
||||||
labelTDD.setId(500+i);
|
labelTDD.setId(500 + i);
|
||||||
labelTDD.setText(DecimalFormatter.to2Decimal(tdd) + " U");
|
labelTDD.setText(DecimalFormatter.to2Decimal(tdd) + " U");
|
||||||
labelTDD.setTextColor(Color.WHITE);
|
labelTDD.setTextColor(Color.WHITE);
|
||||||
tr.addView(labelTDD);
|
tr.addView(labelTDD);
|
||||||
|
|
||||||
TextView labelRATIO = new TextView(DanaRStatsActivity.this);
|
TextView labelRATIO = new TextView(DanaRStatsActivity.this);
|
||||||
labelRATIO.setId(600+i);
|
labelRATIO.setId(600 + i);
|
||||||
labelRATIO.setText(Math.round(100*tdd/magicNumber) +" %");
|
labelRATIO.setText(Math.round(100 * tdd / magicNumber) + " %");
|
||||||
labelRATIO.setTextColor(Color.WHITE);
|
labelRATIO.setTextColor(Color.WHITE);
|
||||||
tr.addView(labelRATIO);
|
tr.addView(labelRATIO);
|
||||||
|
|
||||||
|
@ -431,28 +430,28 @@ public class DanaRStatsActivity extends Activity {
|
||||||
|
|
||||||
// Create the cumtable row
|
// Create the cumtable row
|
||||||
TableRow ctr = new TableRow(DanaRStatsActivity.this);
|
TableRow ctr = new TableRow(DanaRStatsActivity.this);
|
||||||
if(i%2==0) ctr.setBackgroundColor(Color.DKGRAY);
|
if (i % 2 == 0) ctr.setBackgroundColor(Color.DKGRAY);
|
||||||
ctr.setId(700+i);
|
ctr.setId(700 + i);
|
||||||
ctr.setLayoutParams(new TableLayout.LayoutParams(
|
ctr.setLayoutParams(new TableLayout.LayoutParams(
|
||||||
TableLayout.LayoutParams.MATCH_PARENT,
|
TableLayout.LayoutParams.MATCH_PARENT,
|
||||||
TableLayout.LayoutParams.WRAP_CONTENT));
|
TableLayout.LayoutParams.WRAP_CONTENT));
|
||||||
|
|
||||||
// Here create the TextView dynamically
|
// Here create the TextView dynamically
|
||||||
TextView labelDAYS = new TextView(DanaRStatsActivity.this);
|
TextView labelDAYS = new TextView(DanaRStatsActivity.this);
|
||||||
labelDAYS.setId(800+i);
|
labelDAYS.setId(800 + i);
|
||||||
labelDAYS.setText("" + i);
|
labelDAYS.setText("" + i);
|
||||||
labelDAYS.setTextColor(Color.WHITE);
|
labelDAYS.setTextColor(Color.WHITE);
|
||||||
ctr.addView(labelDAYS);
|
ctr.addView(labelDAYS);
|
||||||
|
|
||||||
TextView labelCUMTDD = new TextView(DanaRStatsActivity.this);
|
TextView labelCUMTDD = new TextView(DanaRStatsActivity.this);
|
||||||
labelCUMTDD.setId(900+i);
|
labelCUMTDD.setId(900 + i);
|
||||||
labelCUMTDD.setText(DecimalFormatter.to2Decimal(sum/i) + " U");
|
labelCUMTDD.setText(DecimalFormatter.to2Decimal(sum / i) + " U");
|
||||||
labelCUMTDD.setTextColor(Color.WHITE);
|
labelCUMTDD.setTextColor(Color.WHITE);
|
||||||
ctr.addView(labelCUMTDD);
|
ctr.addView(labelCUMTDD);
|
||||||
|
|
||||||
TextView labelCUMRATIO = new TextView(DanaRStatsActivity.this);
|
TextView labelCUMRATIO = new TextView(DanaRStatsActivity.this);
|
||||||
labelCUMRATIO.setId(1000+i);
|
labelCUMRATIO.setId(1000 + i);
|
||||||
labelCUMRATIO.setText(Math.round(100*sum/i/magicNumber) + " %");
|
labelCUMRATIO.setText(Math.round(100 * sum / i / magicNumber) + " %");
|
||||||
labelCUMRATIO.setTextColor(Color.WHITE);
|
labelCUMRATIO.setTextColor(Color.WHITE);
|
||||||
ctr.addView(labelCUMRATIO);
|
ctr.addView(labelCUMRATIO);
|
||||||
|
|
||||||
|
@ -462,7 +461,7 @@ public class DanaRStatsActivity extends Activity {
|
||||||
TableLayout.LayoutParams.WRAP_CONTENT));
|
TableLayout.LayoutParams.WRAP_CONTENT));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (historyList.size()<3 || !(df.format(new Date(historyList.get(0).getRecordDate())).equals(df.format(new Date(System.currentTimeMillis() - 1000*60*60*24))))){
|
if (historyList.size() < 3 || !(df.format(new Date(historyList.get(0).getRecordDate())).equals(df.format(new Date(System.currentTimeMillis() - 1000 * 60 * 60 * 24))))) {
|
||||||
statsMessage.setVisibility(View.VISIBLE);
|
statsMessage.setVisibility(View.VISIBLE);
|
||||||
statsMessage.setText(getString(R.string.danar_stats_olddata_Message));
|
statsMessage.setText(getString(R.string.danar_stats_olddata_Message));
|
||||||
|
|
||||||
|
@ -474,38 +473,38 @@ public class DanaRStatsActivity extends Activity {
|
||||||
|
|
||||||
i = 0;
|
i = 0;
|
||||||
|
|
||||||
for (DanaRHistoryRecord record: historyList) {
|
for (DanaRHistoryRecord record : historyList) {
|
||||||
double tdd= record.getRecordDailyBolus() + record.getRecordDailyBasal();
|
double tdd = record.getRecordDailyBolus() + record.getRecordDailyBasal();
|
||||||
if(i == 0 ) {
|
if (i == 0) {
|
||||||
weighted03 = tdd;
|
weighted03 = tdd;
|
||||||
weighted05 = tdd;
|
weighted05 = tdd;
|
||||||
weighted07 = tdd;
|
weighted07 = tdd;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
weighted07 = (weighted07*0.3 + tdd*0.7);
|
weighted07 = (weighted07 * 0.3 + tdd * 0.7);
|
||||||
weighted05 = (weighted05*0.5 + tdd*0.5);
|
weighted05 = (weighted05 * 0.5 + tdd * 0.5);
|
||||||
weighted03 = (weighted03*0.7 + tdd*0.3);
|
weighted03 = (weighted03 * 0.7 + tdd * 0.3);
|
||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create the exptable row
|
// Create the exptable row
|
||||||
TableRow etr = new TableRow(DanaRStatsActivity.this);
|
TableRow etr = new TableRow(DanaRStatsActivity.this);
|
||||||
if(i%2!=0) etr.setBackgroundColor(Color.DKGRAY);
|
if (i % 2 != 0) etr.setBackgroundColor(Color.DKGRAY);
|
||||||
etr.setId(1100+i);
|
etr.setId(1100 + i);
|
||||||
etr.setLayoutParams(new TableLayout.LayoutParams(
|
etr.setLayoutParams(new TableLayout.LayoutParams(
|
||||||
TableLayout.LayoutParams.MATCH_PARENT,
|
TableLayout.LayoutParams.MATCH_PARENT,
|
||||||
TableLayout.LayoutParams.WRAP_CONTENT));
|
TableLayout.LayoutParams.WRAP_CONTENT));
|
||||||
|
|
||||||
// Here create the TextView dynamically
|
// Here create the TextView dynamically
|
||||||
TextView labelWEIGHT = new TextView(DanaRStatsActivity.this);
|
TextView labelWEIGHT = new TextView(DanaRStatsActivity.this);
|
||||||
labelWEIGHT.setId(1200+i);
|
labelWEIGHT.setId(1200 + i);
|
||||||
labelWEIGHT.setText("0.3\n" + "0.5\n" + "0.7");
|
labelWEIGHT.setText("0.3\n" + "0.5\n" + "0.7");
|
||||||
labelWEIGHT.setTextColor(Color.WHITE);
|
labelWEIGHT.setTextColor(Color.WHITE);
|
||||||
etr.addView(labelWEIGHT);
|
etr.addView(labelWEIGHT);
|
||||||
|
|
||||||
TextView labelEXPTDD = new TextView(DanaRStatsActivity.this);
|
TextView labelEXPTDD = new TextView(DanaRStatsActivity.this);
|
||||||
labelEXPTDD.setId(1300+i);
|
labelEXPTDD.setId(1300 + i);
|
||||||
labelEXPTDD.setText(DecimalFormatter.to2Decimal(weighted03)
|
labelEXPTDD.setText(DecimalFormatter.to2Decimal(weighted03)
|
||||||
+ " U\n" + DecimalFormatter.to2Decimal(weighted05)
|
+ " U\n" + DecimalFormatter.to2Decimal(weighted05)
|
||||||
+ " U\n" + DecimalFormatter.to2Decimal(weighted07) + " U");
|
+ " U\n" + DecimalFormatter.to2Decimal(weighted07) + " U");
|
||||||
|
@ -513,10 +512,10 @@ public class DanaRStatsActivity extends Activity {
|
||||||
etr.addView(labelEXPTDD);
|
etr.addView(labelEXPTDD);
|
||||||
|
|
||||||
TextView labelEXPRATIO = new TextView(DanaRStatsActivity.this);
|
TextView labelEXPRATIO = new TextView(DanaRStatsActivity.this);
|
||||||
labelEXPRATIO.setId(1400+i);
|
labelEXPRATIO.setId(1400 + i);
|
||||||
labelEXPRATIO.setText(Math.round(100*weighted03/magicNumber) +" %\n"
|
labelEXPRATIO.setText(Math.round(100 * weighted03 / magicNumber) + " %\n"
|
||||||
+ Math.round(100*weighted05/magicNumber) +" %\n"
|
+ Math.round(100 * weighted05 / magicNumber) + " %\n"
|
||||||
+ Math.round(100*weighted07/magicNumber) +" %");
|
+ Math.round(100 * weighted07 / magicNumber) + " %");
|
||||||
labelEXPRATIO.setTextColor(Color.WHITE);
|
labelEXPRATIO.setTextColor(Color.WHITE);
|
||||||
etr.addView(labelEXPRATIO);
|
etr.addView(labelEXPRATIO);
|
||||||
|
|
||||||
|
@ -549,21 +548,12 @@ public class DanaRStatsActivity extends Activity {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onStatusEvent(final EventDanaRConnectionStatus c) {
|
public void onStatusEvent(final EventPumpStatusChanged c) {
|
||||||
runOnUiThread(
|
runOnUiThread(
|
||||||
new Runnable() {
|
new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (c.sStatus == EventDanaRConnectionStatus.CONNECTING) {
|
statusView.setText(c.textStatus());
|
||||||
statusView.setText(String.format(getString(R.string.danar_history_connectingfor), c.sSecondsElapsed));
|
|
||||||
log.debug("EventDanaRConnectionStatus: " + "Connecting for " + c.sSecondsElapsed + "s");
|
|
||||||
} else if (c.sStatus == EventDanaRConnectionStatus.CONNECTED) {
|
|
||||||
statusView.setText(MainApp.sResources.getString(R.string.connected));
|
|
||||||
log.debug("EventDanaRConnectionStatus: Connected");
|
|
||||||
} else {
|
|
||||||
statusView.setText(MainApp.sResources.getString(R.string.disconnected));
|
|
||||||
log.debug("EventDanaRConnectionStatus: Disconnected");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
|
@ -33,6 +33,7 @@ import info.nightscout.androidaps.db.Treatment;
|
||||||
import info.nightscout.androidaps.events.EventAppExit;
|
import info.nightscout.androidaps.events.EventAppExit;
|
||||||
import info.nightscout.androidaps.events.EventInitializationChanged;
|
import info.nightscout.androidaps.events.EventInitializationChanged;
|
||||||
import info.nightscout.androidaps.events.EventPreferenceChange;
|
import info.nightscout.androidaps.events.EventPreferenceChange;
|
||||||
|
import info.nightscout.androidaps.events.EventPumpStatusChanged;
|
||||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||||
import info.nightscout.androidaps.plugins.DanaR.DanaRPlugin;
|
import info.nightscout.androidaps.plugins.DanaR.DanaRPlugin;
|
||||||
import info.nightscout.androidaps.plugins.DanaR.DanaRPump;
|
import info.nightscout.androidaps.plugins.DanaR.DanaRPump;
|
||||||
|
@ -77,7 +78,6 @@ import info.nightscout.androidaps.plugins.DanaR.comm.MsgStatusBolusExtended;
|
||||||
import info.nightscout.androidaps.plugins.DanaR.comm.MsgStatusTempBasal;
|
import info.nightscout.androidaps.plugins.DanaR.comm.MsgStatusTempBasal;
|
||||||
import info.nightscout.androidaps.plugins.DanaR.comm.RecordTypes;
|
import info.nightscout.androidaps.plugins.DanaR.comm.RecordTypes;
|
||||||
import info.nightscout.androidaps.plugins.DanaR.events.EventDanaRBolusStart;
|
import info.nightscout.androidaps.plugins.DanaR.events.EventDanaRBolusStart;
|
||||||
import info.nightscout.androidaps.plugins.DanaR.events.EventDanaRConnectionStatus;
|
|
||||||
import info.nightscout.androidaps.plugins.DanaR.events.EventDanaRNewStatus;
|
import info.nightscout.androidaps.plugins.DanaR.events.EventDanaRNewStatus;
|
||||||
import info.nightscout.androidaps.plugins.Overview.Notification;
|
import info.nightscout.androidaps.plugins.Overview.Notification;
|
||||||
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
|
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
|
||||||
|
@ -117,7 +117,7 @@ public class ExecutionService extends Service {
|
||||||
if (mSerialIOThread != null) {
|
if (mSerialIOThread != null) {
|
||||||
mSerialIOThread.disconnect("BT disconnection broadcast");
|
mSerialIOThread.disconnect("BT disconnection broadcast");
|
||||||
}
|
}
|
||||||
MainApp.bus().post(new EventDanaRConnectionStatus(EventDanaRConnectionStatus.DISCONNECTED, 0));
|
MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.DISCONNECTED));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -207,7 +207,7 @@ public class ExecutionService extends Service {
|
||||||
long startTime = new Date().getTime();
|
long startTime = new Date().getTime();
|
||||||
while (!isConnected() && startTime + maxConnectionTime >= new Date().getTime()) {
|
while (!isConnected() && startTime + maxConnectionTime >= new Date().getTime()) {
|
||||||
long secondsElapsed = (new Date().getTime() - startTime) / 1000L;
|
long secondsElapsed = (new Date().getTime() - startTime) / 1000L;
|
||||||
MainApp.bus().post(new EventDanaRConnectionStatus(EventDanaRConnectionStatus.CONNECTING, (int) secondsElapsed));
|
MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.CONNECTING, (int) secondsElapsed));
|
||||||
if (Config.logDanaBTComm)
|
if (Config.logDanaBTComm)
|
||||||
log.debug("connect waiting " + secondsElapsed + "sec from: " + from);
|
log.debug("connect waiting " + secondsElapsed + "sec from: " + from);
|
||||||
try {
|
try {
|
||||||
|
@ -226,18 +226,19 @@ public class ExecutionService extends Service {
|
||||||
mSerialIOThread.disconnect("Recreate SerialIOThread");
|
mSerialIOThread.disconnect("Recreate SerialIOThread");
|
||||||
}
|
}
|
||||||
mSerialIOThread = new SerialIOThread(mRfcommSocket);
|
mSerialIOThread = new SerialIOThread(mRfcommSocket);
|
||||||
MainApp.bus().post(new EventDanaRConnectionStatus(EventDanaRConnectionStatus.CONNECTED, 0));
|
MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.CONNECTED, 0));
|
||||||
if (!getPumpStatus()) {
|
if (!getPumpStatus()) {
|
||||||
mSerialIOThread.disconnect("getPumpStatus failed");
|
mSerialIOThread.disconnect("getPumpStatus failed");
|
||||||
waitMsec(3000);
|
waitMsec(3000);
|
||||||
if (!MainApp.getSpecificPlugin(DanaRPlugin.class).isEnabled(PluginBase.PUMP))
|
if (!MainApp.getSpecificPlugin(DanaRPlugin.class).isEnabled(PluginBase.PUMP))
|
||||||
return;
|
return;
|
||||||
getBTSocketForSelectedPump();
|
getBTSocketForSelectedPump();
|
||||||
|
startTime = new Date().getTime();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!isConnected()) {
|
if (!isConnected()) {
|
||||||
MainApp.bus().post(new EventDanaRConnectionStatus(EventDanaRConnectionStatus.DISCONNECTED, 0));
|
MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.DISCONNECTED));
|
||||||
log.error("Pump connection timed out");
|
log.error("Pump connection timed out");
|
||||||
}
|
}
|
||||||
connectionInProgress = false;
|
connectionInProgress = false;
|
||||||
|
@ -279,7 +280,7 @@ public class ExecutionService extends Service {
|
||||||
|
|
||||||
private boolean getPumpStatus() {
|
private boolean getPumpStatus() {
|
||||||
try {
|
try {
|
||||||
MainApp.bus().post(new EventDanaRConnectionStatus(EventDanaRConnectionStatus.PERFORMING, 0, MainApp.sResources.getString(R.string.gettingpumpstatus)));
|
MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.gettingpumpstatus)));
|
||||||
MsgStatus statusMsg = new MsgStatus();
|
MsgStatus statusMsg = new MsgStatus();
|
||||||
MsgStatusBasic statusBasicMsg = new MsgStatusBasic();
|
MsgStatusBasic statusBasicMsg = new MsgStatusBasic();
|
||||||
MsgStatusTempBasal tempStatusMsg = new MsgStatusTempBasal();
|
MsgStatusTempBasal tempStatusMsg = new MsgStatusTempBasal();
|
||||||
|
@ -356,39 +357,40 @@ public class ExecutionService extends Service {
|
||||||
public boolean tempBasal(int percent, int durationInHours) {
|
public boolean tempBasal(int percent, int durationInHours) {
|
||||||
connect("tempBasal");
|
connect("tempBasal");
|
||||||
if (!isConnected()) return false;
|
if (!isConnected()) return false;
|
||||||
MainApp.bus().post(new EventDanaRConnectionStatus(EventDanaRConnectionStatus.PERFORMING, 0, MainApp.sResources.getString(R.string.settingtempbasal)));
|
MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.settingtempbasal)));
|
||||||
mSerialIOThread.sendMessage(new MsgSetTempBasalStart(percent, durationInHours));
|
mSerialIOThread.sendMessage(new MsgSetTempBasalStart(percent, durationInHours));
|
||||||
mSerialIOThread.sendMessage(new MsgStatusTempBasal());
|
mSerialIOThread.sendMessage(new MsgStatusTempBasal());
|
||||||
MainApp.bus().post(new EventDanaRConnectionStatus(EventDanaRConnectionStatus.PERFORMING, 0, MainApp.sResources.getString(R.string.disconnecting)));
|
MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.DISCONNECTING));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean tempBasalStop() {
|
public boolean tempBasalStop() {
|
||||||
connect("tempBasalStop");
|
connect("tempBasalStop");
|
||||||
if (!isConnected()) return false;
|
if (!isConnected()) return false;
|
||||||
MainApp.bus().post(new EventDanaRConnectionStatus(EventDanaRConnectionStatus.PERFORMING, 0, MainApp.sResources.getString(R.string.stoppingtempbasal)));
|
MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.stoppingtempbasal)));
|
||||||
mSerialIOThread.sendMessage(new MsgSetTempBasalStop());
|
mSerialIOThread.sendMessage(new MsgSetTempBasalStop());
|
||||||
mSerialIOThread.sendMessage(new MsgStatusTempBasal());
|
mSerialIOThread.sendMessage(new MsgStatusTempBasal());
|
||||||
MainApp.bus().post(new EventDanaRConnectionStatus(EventDanaRConnectionStatus.PERFORMING, 0, MainApp.sResources.getString(R.string.disconnecting)));
|
MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.DISCONNECTING));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean extendedBolus(double insulin, int durationInHalfHours) {
|
public boolean extendedBolus(double insulin, int durationInHalfHours) {
|
||||||
connect("extendedBolus");
|
connect("extendedBolus");
|
||||||
if (!isConnected()) return false;
|
if (!isConnected()) return false;
|
||||||
MainApp.bus().post(new EventDanaRConnectionStatus(EventDanaRConnectionStatus.PERFORMING, 0, MainApp.sResources.getString(R.string.settingextendedbolus)));
|
MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.settingextendedbolus)));
|
||||||
mSerialIOThread.sendMessage(new MsgSetExtendedBolusStart(insulin, (byte) (durationInHalfHours & 0xFF)));
|
mSerialIOThread.sendMessage(new MsgSetExtendedBolusStart(insulin, (byte) (durationInHalfHours & 0xFF)));
|
||||||
mSerialIOThread.sendMessage(new MsgStatusBolusExtended());
|
mSerialIOThread.sendMessage(new MsgStatusBolusExtended());
|
||||||
MainApp.bus().post(new EventDanaRConnectionStatus(EventDanaRConnectionStatus.PERFORMING, 0, MainApp.sResources.getString(R.string.disconnecting)));
|
MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.DISCONNECTING));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean extendedBolusStop() {
|
public boolean extendedBolusStop() {
|
||||||
connect("extendedBolusStop");
|
connect("extendedBolusStop");
|
||||||
if (!isConnected()) return false;
|
if (!isConnected()) return false;
|
||||||
MainApp.bus().post(new EventDanaRConnectionStatus(EventDanaRConnectionStatus.PERFORMING, 0, MainApp.sResources.getString(R.string.stoppingextendedbolus)));
|
MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.stoppingextendedbolus)));
|
||||||
mSerialIOThread.sendMessage(new MsgSetExtendedBolusStop());
|
mSerialIOThread.sendMessage(new MsgSetExtendedBolusStop());
|
||||||
mSerialIOThread.sendMessage(new MsgStatusBolusExtended());
|
mSerialIOThread.sendMessage(new MsgStatusBolusExtended());
|
||||||
|
MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.DISCONNECTING));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -500,7 +502,7 @@ public class ExecutionService extends Service {
|
||||||
public boolean updateBasalsInPump(final NSProfile profile) {
|
public boolean updateBasalsInPump(final NSProfile profile) {
|
||||||
connect("updateBasalsInPump");
|
connect("updateBasalsInPump");
|
||||||
if (!isConnected()) return false;
|
if (!isConnected()) return false;
|
||||||
MainApp.bus().post(new EventDanaRConnectionStatus(EventDanaRConnectionStatus.PERFORMING, 0, MainApp.sResources.getString(R.string.updatingbasalrates)));
|
MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.updatingbasalrates)));
|
||||||
double[] basal = buildDanaRProfileRecord(profile);
|
double[] basal = buildDanaRProfileRecord(profile);
|
||||||
MsgSetBasalProfile msgSet = new MsgSetBasalProfile((byte) 0, basal);
|
MsgSetBasalProfile msgSet = new MsgSetBasalProfile((byte) 0, basal);
|
||||||
mSerialIOThread.sendMessage(msgSet);
|
mSerialIOThread.sendMessage(msgSet);
|
||||||
|
@ -508,7 +510,7 @@ public class ExecutionService extends Service {
|
||||||
mSerialIOThread.sendMessage(msgActivate);
|
mSerialIOThread.sendMessage(msgActivate);
|
||||||
danaRPump.lastSettingsRead = new Date(0); // force read full settings
|
danaRPump.lastSettingsRead = new Date(0); // force read full settings
|
||||||
getPumpStatus();
|
getPumpStatus();
|
||||||
MainApp.bus().post(new EventDanaRConnectionStatus(EventDanaRConnectionStatus.PERFORMING, 0, MainApp.sResources.getString(R.string.disconnecting)));
|
MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.DISCONNECTING));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,23 +0,0 @@
|
||||||
package info.nightscout.androidaps.plugins.DanaR.events;
|
|
||||||
|
|
||||||
public class EventDanaRConnectionStatus {
|
|
||||||
public static final int CONNECTING = 0;
|
|
||||||
public static final int CONNECTED = 1;
|
|
||||||
public static final int DISCONNECTED = 2;
|
|
||||||
public static final int PERFORMING = 3;
|
|
||||||
|
|
||||||
public int sStatus = DISCONNECTED;
|
|
||||||
public int sSecondsElapsed = 0;
|
|
||||||
public String sAction = "";
|
|
||||||
|
|
||||||
public EventDanaRConnectionStatus(int status, int secondsElapsed) {
|
|
||||||
sStatus = status;
|
|
||||||
sSecondsElapsed = secondsElapsed;
|
|
||||||
}
|
|
||||||
|
|
||||||
public EventDanaRConnectionStatus(int status, int secondsElapsed, String action) {
|
|
||||||
sStatus = status;
|
|
||||||
sSecondsElapsed = secondsElapsed;
|
|
||||||
sAction = action;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -24,10 +24,10 @@ import java.util.Date;
|
||||||
|
|
||||||
import info.nightscout.androidaps.MainApp;
|
import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
|
import info.nightscout.androidaps.events.EventPumpStatusChanged;
|
||||||
import info.nightscout.androidaps.events.EventTempBasalChange;
|
import info.nightscout.androidaps.events.EventTempBasalChange;
|
||||||
import info.nightscout.androidaps.interfaces.FragmentBase;
|
import info.nightscout.androidaps.interfaces.FragmentBase;
|
||||||
import info.nightscout.androidaps.plugins.DanaR.Dialogs.ProfileViewDialog;
|
import info.nightscout.androidaps.plugins.DanaR.Dialogs.ProfileViewDialog;
|
||||||
import info.nightscout.androidaps.plugins.DanaR.events.EventDanaRConnectionStatus;
|
|
||||||
import info.nightscout.androidaps.plugins.DanaR.events.EventDanaRNewStatus;
|
import info.nightscout.androidaps.plugins.DanaR.events.EventDanaRNewStatus;
|
||||||
import info.nightscout.androidaps.plugins.DanaRKorean.History.DanaRHistoryActivity;
|
import info.nightscout.androidaps.plugins.DanaRKorean.History.DanaRHistoryActivity;
|
||||||
import info.nightscout.androidaps.plugins.DanaRKorean.History.DanaRStatsActivity;
|
import info.nightscout.androidaps.plugins.DanaRKorean.History.DanaRStatsActivity;
|
||||||
|
@ -162,18 +162,18 @@ public class DanaRKoreanFragment extends Fragment implements FragmentBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onStatusEvent(final EventDanaRConnectionStatus c) {
|
public void onStatusEvent(final EventPumpStatusChanged c) {
|
||||||
Activity activity = getActivity();
|
Activity activity = getActivity();
|
||||||
if (activity != null) {
|
if (activity != null) {
|
||||||
activity.runOnUiThread(
|
activity.runOnUiThread(
|
||||||
new Runnable() {
|
new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (c.sStatus == EventDanaRConnectionStatus.CONNECTING)
|
if (c.sStatus == EventPumpStatusChanged.CONNECTING)
|
||||||
btConnectionView.setText("{fa-bluetooth-b spin} " + c.sSecondsElapsed + "s");
|
btConnectionView.setText("{fa-bluetooth-b spin} " + c.sSecondsElapsed + "s");
|
||||||
else if (c.sStatus == EventDanaRConnectionStatus.CONNECTED)
|
else if (c.sStatus == EventPumpStatusChanged.CONNECTED)
|
||||||
btConnectionView.setText("{fa-bluetooth}");
|
btConnectionView.setText("{fa-bluetooth}");
|
||||||
else
|
else if (c.sStatus == EventPumpStatusChanged.DISCONNECTED)
|
||||||
btConnectionView.setText("{fa-bluetooth-b}");
|
btConnectionView.setText("{fa-bluetooth-b}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,6 +72,8 @@ public class DanaRKoreanPlugin implements PluginBase, PumpInterface, Constraints
|
||||||
return sDanaRKoreanPump;
|
return sDanaRKoreanPump;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String textStatus = "";
|
||||||
|
|
||||||
public DanaRKoreanPlugin() {
|
public DanaRKoreanPlugin() {
|
||||||
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(MainApp.instance().getApplicationContext());
|
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(MainApp.instance().getApplicationContext());
|
||||||
useExtendedBoluses = sharedPreferences.getBoolean("danar_useextended", false);
|
useExtendedBoluses = sharedPreferences.getBoolean("danar_useextended", false);
|
||||||
|
@ -285,12 +287,12 @@ public class DanaRKoreanPlugin implements PluginBase, PumpInterface, Constraints
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Date lastStatusTime() {
|
public Date lastDataTime() {
|
||||||
return getDanaRPump().lastConnection;
|
return getDanaRPump().lastConnection;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateStatus(String reason) {
|
public void refreshDataFromPump(String reason) {
|
||||||
if (!isConnected() && !isConnecting()) {
|
if (!isConnected() && !isConnecting()) {
|
||||||
doConnect(reason);
|
doConnect(reason);
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,10 +38,10 @@ import info.nightscout.androidaps.Constants;
|
||||||
import info.nightscout.androidaps.MainApp;
|
import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.db.DanaRHistoryRecord;
|
import info.nightscout.androidaps.db.DanaRHistoryRecord;
|
||||||
|
import info.nightscout.androidaps.events.EventPumpStatusChanged;
|
||||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||||
import info.nightscout.androidaps.plugins.DanaR.History.DanaRNSHistorySync;
|
import info.nightscout.androidaps.plugins.DanaR.History.DanaRNSHistorySync;
|
||||||
import info.nightscout.androidaps.plugins.DanaR.comm.RecordTypes;
|
import info.nightscout.androidaps.plugins.DanaR.comm.RecordTypes;
|
||||||
import info.nightscout.androidaps.plugins.DanaR.events.EventDanaRConnectionStatus;
|
|
||||||
import info.nightscout.androidaps.plugins.DanaR.events.EventDanaRSyncStatus;
|
import info.nightscout.androidaps.plugins.DanaR.events.EventDanaRSyncStatus;
|
||||||
import info.nightscout.androidaps.plugins.DanaRKorean.Services.ExecutionService;
|
import info.nightscout.androidaps.plugins.DanaRKorean.Services.ExecutionService;
|
||||||
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSProfile;
|
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSProfile;
|
||||||
|
@ -305,7 +305,7 @@ public class DanaRHistoryActivity extends Activity {
|
||||||
case RecordTypes.RECORD_TYPE_DAILY:
|
case RecordTypes.RECORD_TYPE_DAILY:
|
||||||
holder.dailybasal.setText(DecimalFormatter.to2Decimal(record.getRecordDailyBasal()) + "U");
|
holder.dailybasal.setText(DecimalFormatter.to2Decimal(record.getRecordDailyBasal()) + "U");
|
||||||
holder.dailybolus.setText(DecimalFormatter.to2Decimal(record.getRecordDailyBolus()) + "U");
|
holder.dailybolus.setText(DecimalFormatter.to2Decimal(record.getRecordDailyBolus()) + "U");
|
||||||
holder.dailytotal.setText(DecimalFormatter.to2Decimal(record.getRecordDailyBolus()+ record.getRecordDailyBasal()) + "U");
|
holder.dailytotal.setText(DecimalFormatter.to2Decimal(record.getRecordDailyBolus() + record.getRecordDailyBasal()) + "U");
|
||||||
holder.time.setText(DateUtil.dateString(record.getRecordDate()));
|
holder.time.setText(DateUtil.dateString(record.getRecordDate()));
|
||||||
holder.time.setVisibility(View.VISIBLE);
|
holder.time.setVisibility(View.VISIBLE);
|
||||||
holder.value.setVisibility(View.GONE);
|
holder.value.setVisibility(View.GONE);
|
||||||
|
@ -433,21 +433,12 @@ public class DanaRHistoryActivity extends Activity {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onStatusEvent(final EventDanaRConnectionStatus c) {
|
public void onStatusEvent(final EventPumpStatusChanged c) {
|
||||||
runOnUiThread(
|
runOnUiThread(
|
||||||
new Runnable() {
|
new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (c.sStatus == EventDanaRConnectionStatus.CONNECTING) {
|
statusView.setText(c.textStatus());
|
||||||
statusView.setText(String.format(getString(R.string.danar_history_connectingfor), c.sSecondsElapsed));
|
|
||||||
log.debug("EventDanaRConnectionStatus: " + "Connecting for " + c.sSecondsElapsed + "s");
|
|
||||||
} else if (c.sStatus == EventDanaRConnectionStatus.CONNECTED) {
|
|
||||||
statusView.setText(MainApp.sResources.getString(R.string.connected));
|
|
||||||
log.debug("EventDanaRConnectionStatus: Connected");
|
|
||||||
} else {
|
|
||||||
statusView.setText(MainApp.sResources.getString(R.string.disconnected));
|
|
||||||
log.debug("EventDanaRConnectionStatus: Disconnected");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
|
@ -48,11 +48,11 @@ import java.util.List;
|
||||||
import info.nightscout.androidaps.MainApp;
|
import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.db.DanaRHistoryRecord;
|
import info.nightscout.androidaps.db.DanaRHistoryRecord;
|
||||||
|
import info.nightscout.androidaps.events.EventPumpStatusChanged;
|
||||||
import info.nightscout.androidaps.interfaces.ProfileInterface;
|
import info.nightscout.androidaps.interfaces.ProfileInterface;
|
||||||
import info.nightscout.androidaps.plugins.CircadianPercentageProfile.CircadianPercentageProfilePlugin;
|
import info.nightscout.androidaps.plugins.CircadianPercentageProfile.CircadianPercentageProfilePlugin;
|
||||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||||
import info.nightscout.androidaps.plugins.DanaR.comm.RecordTypes;
|
import info.nightscout.androidaps.plugins.DanaR.comm.RecordTypes;
|
||||||
import info.nightscout.androidaps.plugins.DanaR.events.EventDanaRConnectionStatus;
|
|
||||||
import info.nightscout.androidaps.plugins.DanaR.events.EventDanaRSyncStatus;
|
import info.nightscout.androidaps.plugins.DanaR.events.EventDanaRSyncStatus;
|
||||||
import info.nightscout.androidaps.plugins.DanaRKorean.Services.ExecutionService;
|
import info.nightscout.androidaps.plugins.DanaRKorean.Services.ExecutionService;
|
||||||
import info.nightscout.utils.DecimalFormatter;
|
import info.nightscout.utils.DecimalFormatter;
|
||||||
|
@ -68,11 +68,11 @@ public class DanaRStatsActivity extends Activity {
|
||||||
private Handler mHandler;
|
private Handler mHandler;
|
||||||
private static HandlerThread mHandlerThread;
|
private static HandlerThread mHandlerThread;
|
||||||
|
|
||||||
TextView statusView, statsMessage,totalBaseBasal2;
|
TextView statusView, statsMessage, totalBaseBasal2;
|
||||||
EditText totalBaseBasal;
|
EditText totalBaseBasal;
|
||||||
Button reloadButton;
|
Button reloadButton;
|
||||||
LinearLayoutManager llm;
|
LinearLayoutManager llm;
|
||||||
TableLayout tl,ctl,etl;
|
TableLayout tl, ctl, etl;
|
||||||
String TBB;
|
String TBB;
|
||||||
double magicNumber;
|
double magicNumber;
|
||||||
DecimalFormat decimalFormat;
|
DecimalFormat decimalFormat;
|
||||||
|
@ -118,15 +118,15 @@ public class DanaRStatsActivity extends Activity {
|
||||||
public boolean dispatchTouchEvent(MotionEvent event) {
|
public boolean dispatchTouchEvent(MotionEvent event) {
|
||||||
if (event.getAction() == MotionEvent.ACTION_DOWN) {
|
if (event.getAction() == MotionEvent.ACTION_DOWN) {
|
||||||
View myView = getCurrentFocus();
|
View myView = getCurrentFocus();
|
||||||
if ( myView instanceof EditText) {
|
if (myView instanceof EditText) {
|
||||||
Rect rect = new Rect();
|
Rect rect = new Rect();
|
||||||
myView.getGlobalVisibleRect(rect);
|
myView.getGlobalVisibleRect(rect);
|
||||||
if (!rect.contains((int)event.getRawX(), (int)event.getRawY())) {
|
if (!rect.contains((int) event.getRawX(), (int) event.getRawY())) {
|
||||||
myView.clearFocus();
|
myView.clearFocus();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return super.dispatchTouchEvent( event );
|
return super.dispatchTouchEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
ServiceConnection mConnection = new ServiceConnection() {
|
ServiceConnection mConnection = new ServiceConnection() {
|
||||||
|
@ -172,11 +172,11 @@ public class DanaRStatsActivity extends Activity {
|
||||||
totalBaseBasal.setText(TBB);
|
totalBaseBasal.setText(TBB);
|
||||||
|
|
||||||
ProfileInterface pi = ConfigBuilderPlugin.getActiveProfile();
|
ProfileInterface pi = ConfigBuilderPlugin.getActiveProfile();
|
||||||
if (pi != null && pi instanceof CircadianPercentageProfilePlugin){
|
if (pi != null && pi instanceof CircadianPercentageProfilePlugin) {
|
||||||
double cppTBB = ((CircadianPercentageProfilePlugin)pi).baseBasalSum();
|
double cppTBB = ((CircadianPercentageProfilePlugin) pi).baseBasalSum();
|
||||||
totalBaseBasal.setText(decimalFormat.format(cppTBB));
|
totalBaseBasal.setText(decimalFormat.format(cppTBB));
|
||||||
SharedPreferences.Editor edit = preferences.edit();
|
SharedPreferences.Editor edit = preferences.edit();
|
||||||
edit.putString("TBB",totalBaseBasal.getText().toString());
|
edit.putString("TBB", totalBaseBasal.getText().toString());
|
||||||
edit.commit();
|
edit.commit();
|
||||||
TBB = preferences.getString("TBB", "");
|
TBB = preferences.getString("TBB", "");
|
||||||
}
|
}
|
||||||
|
@ -312,7 +312,7 @@ public class DanaRStatsActivity extends Activity {
|
||||||
totalBaseBasal.setOnEditorActionListener(new TextView.OnEditorActionListener() {
|
totalBaseBasal.setOnEditorActionListener(new TextView.OnEditorActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
|
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
|
||||||
if(actionId== EditorInfo.IME_ACTION_DONE){
|
if (actionId == EditorInfo.IME_ACTION_DONE) {
|
||||||
totalBaseBasal.clearFocus();
|
totalBaseBasal.clearFocus();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -323,11 +323,11 @@ public class DanaRStatsActivity extends Activity {
|
||||||
totalBaseBasal.setOnFocusChangeListener(new View.OnFocusChangeListener() {
|
totalBaseBasal.setOnFocusChangeListener(new View.OnFocusChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onFocusChange(View v, boolean hasFocus) {
|
public void onFocusChange(View v, boolean hasFocus) {
|
||||||
if(hasFocus){
|
if (hasFocus) {
|
||||||
totalBaseBasal.getText().clear();
|
totalBaseBasal.getText().clear();
|
||||||
} else {
|
} else {
|
||||||
SharedPreferences.Editor edit = preferences.edit();
|
SharedPreferences.Editor edit = preferences.edit();
|
||||||
edit.putString("TBB",totalBaseBasal.getText().toString());
|
edit.putString("TBB", totalBaseBasal.getText().toString());
|
||||||
edit.commit();
|
edit.commit();
|
||||||
TBB = preferences.getString("TBB", "");
|
TBB = preferences.getString("TBB", "");
|
||||||
loadDataFromDB(RecordTypes.RECORD_TYPE_DAILY);
|
loadDataFromDB(RecordTypes.RECORD_TYPE_DAILY);
|
||||||
|
@ -362,15 +362,14 @@ public class DanaRStatsActivity extends Activity {
|
||||||
cleanTable(etl);
|
cleanTable(etl);
|
||||||
DateFormat df = new SimpleDateFormat("dd.MM.");
|
DateFormat df = new SimpleDateFormat("dd.MM.");
|
||||||
|
|
||||||
if(TextUtils.isEmpty(TBB)) {
|
if (TextUtils.isEmpty(TBB)) {
|
||||||
totalBaseBasal.setError("Please Enter Total Base Basal");
|
totalBaseBasal.setError("Please Enter Total Base Basal");
|
||||||
return;
|
return;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
magicNumber = SafeParse.stringToDouble(TBB);
|
magicNumber = SafeParse.stringToDouble(TBB);
|
||||||
}
|
}
|
||||||
|
|
||||||
magicNumber *=2;
|
magicNumber *= 2;
|
||||||
totalBaseBasal2.setText(decimalFormat.format(magicNumber));
|
totalBaseBasal2.setText(decimalFormat.format(magicNumber));
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
@ -379,45 +378,45 @@ public class DanaRStatsActivity extends Activity {
|
||||||
double weighted05 = 0d;
|
double weighted05 = 0d;
|
||||||
double weighted07 = 0d;
|
double weighted07 = 0d;
|
||||||
|
|
||||||
for (DanaRHistoryRecord record: historyList) {
|
for (DanaRHistoryRecord record : historyList) {
|
||||||
double tdd= record.getRecordDailyBolus() + record.getRecordDailyBasal();
|
double tdd = record.getRecordDailyBolus() + record.getRecordDailyBasal();
|
||||||
|
|
||||||
// Create the table row
|
// Create the table row
|
||||||
TableRow tr = new TableRow(DanaRStatsActivity.this);
|
TableRow tr = new TableRow(DanaRStatsActivity.this);
|
||||||
if(i%2!=0) tr.setBackgroundColor(Color.DKGRAY);
|
if (i % 2 != 0) tr.setBackgroundColor(Color.DKGRAY);
|
||||||
tr.setId(100+i);
|
tr.setId(100 + i);
|
||||||
tr.setLayoutParams(new TableLayout.LayoutParams(
|
tr.setLayoutParams(new TableLayout.LayoutParams(
|
||||||
TableLayout.LayoutParams.MATCH_PARENT,
|
TableLayout.LayoutParams.MATCH_PARENT,
|
||||||
TableLayout.LayoutParams.WRAP_CONTENT));
|
TableLayout.LayoutParams.WRAP_CONTENT));
|
||||||
|
|
||||||
// Here create the TextView dynamically
|
// Here create the TextView dynamically
|
||||||
TextView labelDATE = new TextView(DanaRStatsActivity.this);
|
TextView labelDATE = new TextView(DanaRStatsActivity.this);
|
||||||
labelDATE.setId(200+i);
|
labelDATE.setId(200 + i);
|
||||||
labelDATE.setText(df.format(new Date(record.getRecordDate())));
|
labelDATE.setText(df.format(new Date(record.getRecordDate())));
|
||||||
labelDATE.setTextColor(Color.WHITE);
|
labelDATE.setTextColor(Color.WHITE);
|
||||||
tr.addView(labelDATE);
|
tr.addView(labelDATE);
|
||||||
|
|
||||||
TextView labelBASAL = new TextView(DanaRStatsActivity.this);
|
TextView labelBASAL = new TextView(DanaRStatsActivity.this);
|
||||||
labelBASAL.setId(300+i);
|
labelBASAL.setId(300 + i);
|
||||||
labelBASAL.setText(DecimalFormatter.to2Decimal(record.getRecordDailyBasal()) + " U");
|
labelBASAL.setText(DecimalFormatter.to2Decimal(record.getRecordDailyBasal()) + " U");
|
||||||
labelBASAL.setTextColor(Color.WHITE);
|
labelBASAL.setTextColor(Color.WHITE);
|
||||||
tr.addView(labelBASAL);
|
tr.addView(labelBASAL);
|
||||||
|
|
||||||
TextView labelBOLUS = new TextView(DanaRStatsActivity.this);
|
TextView labelBOLUS = new TextView(DanaRStatsActivity.this);
|
||||||
labelBOLUS.setId(400+i);
|
labelBOLUS.setId(400 + i);
|
||||||
labelBOLUS.setText(DecimalFormatter.to2Decimal(record.getRecordDailyBolus()) + " U");
|
labelBOLUS.setText(DecimalFormatter.to2Decimal(record.getRecordDailyBolus()) + " U");
|
||||||
labelBOLUS.setTextColor(Color.WHITE);
|
labelBOLUS.setTextColor(Color.WHITE);
|
||||||
tr.addView(labelBOLUS);
|
tr.addView(labelBOLUS);
|
||||||
|
|
||||||
TextView labelTDD = new TextView(DanaRStatsActivity.this);
|
TextView labelTDD = new TextView(DanaRStatsActivity.this);
|
||||||
labelTDD.setId(500+i);
|
labelTDD.setId(500 + i);
|
||||||
labelTDD.setText(DecimalFormatter.to2Decimal(tdd) + " U");
|
labelTDD.setText(DecimalFormatter.to2Decimal(tdd) + " U");
|
||||||
labelTDD.setTextColor(Color.WHITE);
|
labelTDD.setTextColor(Color.WHITE);
|
||||||
tr.addView(labelTDD);
|
tr.addView(labelTDD);
|
||||||
|
|
||||||
TextView labelRATIO = new TextView(DanaRStatsActivity.this);
|
TextView labelRATIO = new TextView(DanaRStatsActivity.this);
|
||||||
labelRATIO.setId(600+i);
|
labelRATIO.setId(600 + i);
|
||||||
labelRATIO.setText(Math.round(100*tdd/magicNumber) +" %");
|
labelRATIO.setText(Math.round(100 * tdd / magicNumber) + " %");
|
||||||
labelRATIO.setTextColor(Color.WHITE);
|
labelRATIO.setTextColor(Color.WHITE);
|
||||||
tr.addView(labelRATIO);
|
tr.addView(labelRATIO);
|
||||||
|
|
||||||
|
@ -431,28 +430,28 @@ public class DanaRStatsActivity extends Activity {
|
||||||
|
|
||||||
// Create the cumtable row
|
// Create the cumtable row
|
||||||
TableRow ctr = new TableRow(DanaRStatsActivity.this);
|
TableRow ctr = new TableRow(DanaRStatsActivity.this);
|
||||||
if(i%2==0) ctr.setBackgroundColor(Color.DKGRAY);
|
if (i % 2 == 0) ctr.setBackgroundColor(Color.DKGRAY);
|
||||||
ctr.setId(700+i);
|
ctr.setId(700 + i);
|
||||||
ctr.setLayoutParams(new TableLayout.LayoutParams(
|
ctr.setLayoutParams(new TableLayout.LayoutParams(
|
||||||
TableLayout.LayoutParams.MATCH_PARENT,
|
TableLayout.LayoutParams.MATCH_PARENT,
|
||||||
TableLayout.LayoutParams.WRAP_CONTENT));
|
TableLayout.LayoutParams.WRAP_CONTENT));
|
||||||
|
|
||||||
// Here create the TextView dynamically
|
// Here create the TextView dynamically
|
||||||
TextView labelDAYS = new TextView(DanaRStatsActivity.this);
|
TextView labelDAYS = new TextView(DanaRStatsActivity.this);
|
||||||
labelDAYS.setId(800+i);
|
labelDAYS.setId(800 + i);
|
||||||
labelDAYS.setText("" + i);
|
labelDAYS.setText("" + i);
|
||||||
labelDAYS.setTextColor(Color.WHITE);
|
labelDAYS.setTextColor(Color.WHITE);
|
||||||
ctr.addView(labelDAYS);
|
ctr.addView(labelDAYS);
|
||||||
|
|
||||||
TextView labelCUMTDD = new TextView(DanaRStatsActivity.this);
|
TextView labelCUMTDD = new TextView(DanaRStatsActivity.this);
|
||||||
labelCUMTDD.setId(900+i);
|
labelCUMTDD.setId(900 + i);
|
||||||
labelCUMTDD.setText(DecimalFormatter.to2Decimal(sum/i) + " U");
|
labelCUMTDD.setText(DecimalFormatter.to2Decimal(sum / i) + " U");
|
||||||
labelCUMTDD.setTextColor(Color.WHITE);
|
labelCUMTDD.setTextColor(Color.WHITE);
|
||||||
ctr.addView(labelCUMTDD);
|
ctr.addView(labelCUMTDD);
|
||||||
|
|
||||||
TextView labelCUMRATIO = new TextView(DanaRStatsActivity.this);
|
TextView labelCUMRATIO = new TextView(DanaRStatsActivity.this);
|
||||||
labelCUMRATIO.setId(1000+i);
|
labelCUMRATIO.setId(1000 + i);
|
||||||
labelCUMRATIO.setText(Math.round(100*sum/i/magicNumber) + " %");
|
labelCUMRATIO.setText(Math.round(100 * sum / i / magicNumber) + " %");
|
||||||
labelCUMRATIO.setTextColor(Color.WHITE);
|
labelCUMRATIO.setTextColor(Color.WHITE);
|
||||||
ctr.addView(labelCUMRATIO);
|
ctr.addView(labelCUMRATIO);
|
||||||
|
|
||||||
|
@ -462,7 +461,7 @@ public class DanaRStatsActivity extends Activity {
|
||||||
TableLayout.LayoutParams.WRAP_CONTENT));
|
TableLayout.LayoutParams.WRAP_CONTENT));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (historyList.size()<3 || !(df.format(new Date(historyList.get(0).getRecordDate())).equals(df.format(new Date(System.currentTimeMillis() - 1000*60*60*24))))){
|
if (historyList.size() < 3 || !(df.format(new Date(historyList.get(0).getRecordDate())).equals(df.format(new Date(System.currentTimeMillis() - 1000 * 60 * 60 * 24))))) {
|
||||||
statsMessage.setVisibility(View.VISIBLE);
|
statsMessage.setVisibility(View.VISIBLE);
|
||||||
statsMessage.setText(getString(R.string.danar_stats_olddata_Message));
|
statsMessage.setText(getString(R.string.danar_stats_olddata_Message));
|
||||||
|
|
||||||
|
@ -474,38 +473,38 @@ public class DanaRStatsActivity extends Activity {
|
||||||
|
|
||||||
i = 0;
|
i = 0;
|
||||||
|
|
||||||
for (DanaRHistoryRecord record: historyList) {
|
for (DanaRHistoryRecord record : historyList) {
|
||||||
double tdd= record.getRecordDailyBolus() + record.getRecordDailyBasal();
|
double tdd = record.getRecordDailyBolus() + record.getRecordDailyBasal();
|
||||||
if(i == 0 ) {
|
if (i == 0) {
|
||||||
weighted03 = tdd;
|
weighted03 = tdd;
|
||||||
weighted05 = tdd;
|
weighted05 = tdd;
|
||||||
weighted07 = tdd;
|
weighted07 = tdd;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
weighted07 = (weighted07*0.3 + tdd*0.7);
|
weighted07 = (weighted07 * 0.3 + tdd * 0.7);
|
||||||
weighted05 = (weighted05*0.5 + tdd*0.5);
|
weighted05 = (weighted05 * 0.5 + tdd * 0.5);
|
||||||
weighted03 = (weighted03*0.7 + tdd*0.3);
|
weighted03 = (weighted03 * 0.7 + tdd * 0.3);
|
||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create the exptable row
|
// Create the exptable row
|
||||||
TableRow etr = new TableRow(DanaRStatsActivity.this);
|
TableRow etr = new TableRow(DanaRStatsActivity.this);
|
||||||
if(i%2!=0) etr.setBackgroundColor(Color.DKGRAY);
|
if (i % 2 != 0) etr.setBackgroundColor(Color.DKGRAY);
|
||||||
etr.setId(1100+i);
|
etr.setId(1100 + i);
|
||||||
etr.setLayoutParams(new TableLayout.LayoutParams(
|
etr.setLayoutParams(new TableLayout.LayoutParams(
|
||||||
TableLayout.LayoutParams.MATCH_PARENT,
|
TableLayout.LayoutParams.MATCH_PARENT,
|
||||||
TableLayout.LayoutParams.WRAP_CONTENT));
|
TableLayout.LayoutParams.WRAP_CONTENT));
|
||||||
|
|
||||||
// Here create the TextView dynamically
|
// Here create the TextView dynamically
|
||||||
TextView labelWEIGHT = new TextView(DanaRStatsActivity.this);
|
TextView labelWEIGHT = new TextView(DanaRStatsActivity.this);
|
||||||
labelWEIGHT.setId(1200+i);
|
labelWEIGHT.setId(1200 + i);
|
||||||
labelWEIGHT.setText("0.3\n" + "0.5\n" + "0.7");
|
labelWEIGHT.setText("0.3\n" + "0.5\n" + "0.7");
|
||||||
labelWEIGHT.setTextColor(Color.WHITE);
|
labelWEIGHT.setTextColor(Color.WHITE);
|
||||||
etr.addView(labelWEIGHT);
|
etr.addView(labelWEIGHT);
|
||||||
|
|
||||||
TextView labelEXPTDD = new TextView(DanaRStatsActivity.this);
|
TextView labelEXPTDD = new TextView(DanaRStatsActivity.this);
|
||||||
labelEXPTDD.setId(1300+i);
|
labelEXPTDD.setId(1300 + i);
|
||||||
labelEXPTDD.setText(DecimalFormatter.to2Decimal(weighted03)
|
labelEXPTDD.setText(DecimalFormatter.to2Decimal(weighted03)
|
||||||
+ " U\n" + DecimalFormatter.to2Decimal(weighted05)
|
+ " U\n" + DecimalFormatter.to2Decimal(weighted05)
|
||||||
+ " U\n" + DecimalFormatter.to2Decimal(weighted07) + " U");
|
+ " U\n" + DecimalFormatter.to2Decimal(weighted07) + " U");
|
||||||
|
@ -513,10 +512,10 @@ public class DanaRStatsActivity extends Activity {
|
||||||
etr.addView(labelEXPTDD);
|
etr.addView(labelEXPTDD);
|
||||||
|
|
||||||
TextView labelEXPRATIO = new TextView(DanaRStatsActivity.this);
|
TextView labelEXPRATIO = new TextView(DanaRStatsActivity.this);
|
||||||
labelEXPRATIO.setId(1400+i);
|
labelEXPRATIO.setId(1400 + i);
|
||||||
labelEXPRATIO.setText(Math.round(100*weighted03/magicNumber) +" %\n"
|
labelEXPRATIO.setText(Math.round(100 * weighted03 / magicNumber) + " %\n"
|
||||||
+ Math.round(100*weighted05/magicNumber) +" %\n"
|
+ Math.round(100 * weighted05 / magicNumber) + " %\n"
|
||||||
+ Math.round(100*weighted07/magicNumber) +" %");
|
+ Math.round(100 * weighted07 / magicNumber) + " %");
|
||||||
labelEXPRATIO.setTextColor(Color.WHITE);
|
labelEXPRATIO.setTextColor(Color.WHITE);
|
||||||
etr.addView(labelEXPRATIO);
|
etr.addView(labelEXPRATIO);
|
||||||
|
|
||||||
|
@ -549,21 +548,12 @@ public class DanaRStatsActivity extends Activity {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onStatusEvent(final EventDanaRConnectionStatus c) {
|
public void onStatusEvent(final EventPumpStatusChanged c) {
|
||||||
runOnUiThread(
|
runOnUiThread(
|
||||||
new Runnable() {
|
new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (c.sStatus == EventDanaRConnectionStatus.CONNECTING) {
|
statusView.setText(c.textStatus());
|
||||||
statusView.setText(String.format(getString(R.string.danar_history_connectingfor), c.sSecondsElapsed));
|
|
||||||
log.debug("EventDanaRConnectionStatus: " + "Connecting for " + c.sSecondsElapsed + "s");
|
|
||||||
} else if (c.sStatus == EventDanaRConnectionStatus.CONNECTED) {
|
|
||||||
statusView.setText(MainApp.sResources.getString(R.string.connected));
|
|
||||||
log.debug("EventDanaRConnectionStatus: Connected");
|
|
||||||
} else {
|
|
||||||
statusView.setText(MainApp.sResources.getString(R.string.disconnected));
|
|
||||||
log.debug("EventDanaRConnectionStatus: Disconnected");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
|
@ -31,6 +31,7 @@ import info.nightscout.androidaps.db.Treatment;
|
||||||
import info.nightscout.androidaps.events.EventAppExit;
|
import info.nightscout.androidaps.events.EventAppExit;
|
||||||
import info.nightscout.androidaps.events.EventInitializationChanged;
|
import info.nightscout.androidaps.events.EventInitializationChanged;
|
||||||
import info.nightscout.androidaps.events.EventPreferenceChange;
|
import info.nightscout.androidaps.events.EventPreferenceChange;
|
||||||
|
import info.nightscout.androidaps.events.EventPumpStatusChanged;
|
||||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||||
import info.nightscout.androidaps.plugins.DanaR.comm.MessageBase;
|
import info.nightscout.androidaps.plugins.DanaR.comm.MessageBase;
|
||||||
import info.nightscout.androidaps.plugins.DanaR.comm.MsgBolusProgress;
|
import info.nightscout.androidaps.plugins.DanaR.comm.MsgBolusProgress;
|
||||||
|
@ -57,7 +58,6 @@ import info.nightscout.androidaps.plugins.DanaR.comm.MsgSetTempBasalStop;
|
||||||
import info.nightscout.androidaps.plugins.DanaR.comm.MsgSetTime;
|
import info.nightscout.androidaps.plugins.DanaR.comm.MsgSetTime;
|
||||||
import info.nightscout.androidaps.plugins.DanaR.comm.RecordTypes;
|
import info.nightscout.androidaps.plugins.DanaR.comm.RecordTypes;
|
||||||
import info.nightscout.androidaps.plugins.DanaR.events.EventDanaRBolusStart;
|
import info.nightscout.androidaps.plugins.DanaR.events.EventDanaRBolusStart;
|
||||||
import info.nightscout.androidaps.plugins.DanaR.events.EventDanaRConnectionStatus;
|
|
||||||
import info.nightscout.androidaps.plugins.DanaR.events.EventDanaRNewStatus;
|
import info.nightscout.androidaps.plugins.DanaR.events.EventDanaRNewStatus;
|
||||||
import info.nightscout.androidaps.plugins.DanaRKorean.DanaRKoreanPlugin;
|
import info.nightscout.androidaps.plugins.DanaRKorean.DanaRKoreanPlugin;
|
||||||
import info.nightscout.androidaps.plugins.DanaRKorean.DanaRKoreanPump;
|
import info.nightscout.androidaps.plugins.DanaRKorean.DanaRKoreanPump;
|
||||||
|
@ -110,7 +110,7 @@ public class ExecutionService extends Service {
|
||||||
if (mSerialIOThread != null) {
|
if (mSerialIOThread != null) {
|
||||||
mSerialIOThread.disconnect("BT disconnection broadcast");
|
mSerialIOThread.disconnect("BT disconnection broadcast");
|
||||||
}
|
}
|
||||||
MainApp.bus().post(new EventDanaRConnectionStatus(EventDanaRConnectionStatus.DISCONNECTED, 0));
|
MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.DISCONNECTED));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -200,7 +200,7 @@ public class ExecutionService extends Service {
|
||||||
long startTime = new Date().getTime();
|
long startTime = new Date().getTime();
|
||||||
while (!isConnected() && startTime + maxConnectionTime >= new Date().getTime()) {
|
while (!isConnected() && startTime + maxConnectionTime >= new Date().getTime()) {
|
||||||
long secondsElapsed = (new Date().getTime() - startTime) / 1000L;
|
long secondsElapsed = (new Date().getTime() - startTime) / 1000L;
|
||||||
MainApp.bus().post(new EventDanaRConnectionStatus(EventDanaRConnectionStatus.CONNECTING, (int) secondsElapsed));
|
MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.CONNECTING, (int) secondsElapsed));
|
||||||
if (Config.logDanaBTComm)
|
if (Config.logDanaBTComm)
|
||||||
log.debug("connect waiting " + secondsElapsed + "sec from: " + from);
|
log.debug("connect waiting " + secondsElapsed + "sec from: " + from);
|
||||||
try {
|
try {
|
||||||
|
@ -219,18 +219,19 @@ public class ExecutionService extends Service {
|
||||||
mSerialIOThread.disconnect("Recreate SerialIOThread");
|
mSerialIOThread.disconnect("Recreate SerialIOThread");
|
||||||
}
|
}
|
||||||
mSerialIOThread = new SerialIOThread(mRfcommSocket);
|
mSerialIOThread = new SerialIOThread(mRfcommSocket);
|
||||||
MainApp.bus().post(new EventDanaRConnectionStatus(EventDanaRConnectionStatus.CONNECTED, 0));
|
MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.CONNECTED));
|
||||||
if (!getPumpStatus()) {
|
if (!getPumpStatus()) {
|
||||||
mSerialIOThread.disconnect("getPumpStatus failed");
|
mSerialIOThread.disconnect("getPumpStatus failed");
|
||||||
waitMsec(3000);
|
waitMsec(3000);
|
||||||
if (!MainApp.getSpecificPlugin(DanaRKoreanPlugin.class).isEnabled(PluginBase.PUMP))
|
if (!MainApp.getSpecificPlugin(DanaRKoreanPlugin.class).isEnabled(PluginBase.PUMP))
|
||||||
return;
|
return;
|
||||||
getBTSocketForSelectedPump();
|
getBTSocketForSelectedPump();
|
||||||
|
startTime = new Date().getTime();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!isConnected()) {
|
if (!isConnected()) {
|
||||||
MainApp.bus().post(new EventDanaRConnectionStatus(EventDanaRConnectionStatus.DISCONNECTED, 0));
|
MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.DISCONNECTED));
|
||||||
log.error("Pump connection timed out");
|
log.error("Pump connection timed out");
|
||||||
}
|
}
|
||||||
connectionInProgress = false;
|
connectionInProgress = false;
|
||||||
|
@ -272,7 +273,7 @@ public class ExecutionService extends Service {
|
||||||
|
|
||||||
private boolean getPumpStatus() {
|
private boolean getPumpStatus() {
|
||||||
try {
|
try {
|
||||||
MainApp.bus().post(new EventDanaRConnectionStatus(EventDanaRConnectionStatus.PERFORMING, 0, MainApp.sResources.getString(R.string.gettingpumpstatus)));
|
MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.gettingpumpstatus)));
|
||||||
//MsgStatus statusMsg = new MsgStatus();
|
//MsgStatus statusMsg = new MsgStatus();
|
||||||
MsgStatusBasic statusBasicMsg = new MsgStatusBasic();
|
MsgStatusBasic statusBasicMsg = new MsgStatusBasic();
|
||||||
MsgStatusTempBasal tempStatusMsg = new MsgStatusTempBasal();
|
MsgStatusTempBasal tempStatusMsg = new MsgStatusTempBasal();
|
||||||
|
@ -347,40 +348,40 @@ public class ExecutionService extends Service {
|
||||||
public boolean tempBasal(int percent, int durationInHours) {
|
public boolean tempBasal(int percent, int durationInHours) {
|
||||||
connect("tempBasal");
|
connect("tempBasal");
|
||||||
if (!isConnected()) return false;
|
if (!isConnected()) return false;
|
||||||
MainApp.bus().post(new EventDanaRConnectionStatus(EventDanaRConnectionStatus.PERFORMING, 0, MainApp.sResources.getString(R.string.settingtempbasal)));
|
MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.settingtempbasal)));
|
||||||
mSerialIOThread.sendMessage(new MsgSetTempBasalStart(percent, durationInHours));
|
mSerialIOThread.sendMessage(new MsgSetTempBasalStart(percent, durationInHours));
|
||||||
mSerialIOThread.sendMessage(new MsgStatusTempBasal());
|
mSerialIOThread.sendMessage(new MsgStatusTempBasal());
|
||||||
MainApp.bus().post(new EventDanaRConnectionStatus(EventDanaRConnectionStatus.PERFORMING, 0, MainApp.sResources.getString(R.string.disconnecting)));
|
MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.DISCONNECTING));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean tempBasalStop() {
|
public boolean tempBasalStop() {
|
||||||
connect("tempBasalStop");
|
connect("tempBasalStop");
|
||||||
if (!isConnected()) return false;
|
if (!isConnected()) return false;
|
||||||
MainApp.bus().post(new EventDanaRConnectionStatus(EventDanaRConnectionStatus.PERFORMING, 0, MainApp.sResources.getString(R.string.stoppingtempbasal)));
|
MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.stoppingtempbasal)));
|
||||||
mSerialIOThread.sendMessage(new MsgSetTempBasalStop());
|
mSerialIOThread.sendMessage(new MsgSetTempBasalStop());
|
||||||
mSerialIOThread.sendMessage(new MsgStatusTempBasal());
|
mSerialIOThread.sendMessage(new MsgStatusTempBasal());
|
||||||
MainApp.bus().post(new EventDanaRConnectionStatus(EventDanaRConnectionStatus.PERFORMING, 0, MainApp.sResources.getString(R.string.disconnecting)));
|
MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.DISCONNECTING));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean extendedBolus(double insulin, int durationInHalfHours) {
|
public boolean extendedBolus(double insulin, int durationInHalfHours) {
|
||||||
connect("extendedBolus");
|
connect("extendedBolus");
|
||||||
if (!isConnected()) return false;
|
if (!isConnected()) return false;
|
||||||
MainApp.bus().post(new EventDanaRConnectionStatus(EventDanaRConnectionStatus.PERFORMING, 0, MainApp.sResources.getString(R.string.settingextendedbolus)));
|
MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.settingextendedbolus)));
|
||||||
mSerialIOThread.sendMessage(new MsgSetExtendedBolusStart(insulin, (byte) (durationInHalfHours & 0xFF)));
|
mSerialIOThread.sendMessage(new MsgSetExtendedBolusStart(insulin, (byte) (durationInHalfHours & 0xFF)));
|
||||||
mSerialIOThread.sendMessage(new MsgStatusBolusExtended());
|
mSerialIOThread.sendMessage(new MsgStatusBolusExtended());
|
||||||
MainApp.bus().post(new EventDanaRConnectionStatus(EventDanaRConnectionStatus.PERFORMING, 0, MainApp.sResources.getString(R.string.disconnecting)));
|
MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.DISCONNECTING));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean extendedBolusStop() {
|
public boolean extendedBolusStop() {
|
||||||
connect("extendedBolusStop");
|
connect("extendedBolusStop");
|
||||||
if (!isConnected()) return false;
|
if (!isConnected()) return false;
|
||||||
MainApp.bus().post(new EventDanaRConnectionStatus(EventDanaRConnectionStatus.PERFORMING, 0, MainApp.sResources.getString(R.string.stoppingextendedbolus)));
|
MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.stoppingextendedbolus)));
|
||||||
mSerialIOThread.sendMessage(new MsgSetExtendedBolusStop());
|
mSerialIOThread.sendMessage(new MsgSetExtendedBolusStop());
|
||||||
mSerialIOThread.sendMessage(new MsgStatusBolusExtended());
|
mSerialIOThread.sendMessage(new MsgStatusBolusExtended());
|
||||||
MainApp.bus().post(new EventDanaRConnectionStatus(EventDanaRConnectionStatus.PERFORMING, 0, MainApp.sResources.getString(R.string.disconnecting)));
|
MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.DISCONNECTING));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -493,13 +494,13 @@ public class ExecutionService extends Service {
|
||||||
public boolean updateBasalsInPump(final NSProfile profile) {
|
public boolean updateBasalsInPump(final NSProfile profile) {
|
||||||
connect("updateBasalsInPump");
|
connect("updateBasalsInPump");
|
||||||
if (!isConnected()) return false;
|
if (!isConnected()) return false;
|
||||||
MainApp.bus().post(new EventDanaRConnectionStatus(EventDanaRConnectionStatus.PERFORMING, 0, MainApp.sResources.getString(R.string.updatingbasalrates)));
|
MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.updatingbasalrates)));
|
||||||
double[] basal = buildDanaRProfileRecord(profile);
|
double[] basal = buildDanaRProfileRecord(profile);
|
||||||
MsgSetSingleBasalProfile msgSet = new MsgSetSingleBasalProfile(basal);
|
MsgSetSingleBasalProfile msgSet = new MsgSetSingleBasalProfile(basal);
|
||||||
mSerialIOThread.sendMessage(msgSet);
|
mSerialIOThread.sendMessage(msgSet);
|
||||||
danaRKoreanPump.lastSettingsRead = new Date(0); // force read full settings
|
danaRKoreanPump.lastSettingsRead = new Date(0); // force read full settings
|
||||||
getPumpStatus();
|
getPumpStatus();
|
||||||
MainApp.bus().post(new EventDanaRConnectionStatus(EventDanaRConnectionStatus.PERFORMING, 0, MainApp.sResources.getString(R.string.disconnecting)));
|
MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.DISCONNECTING));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -143,12 +143,12 @@ public class MDIPlugin implements PluginBase, PumpInterface {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Date lastStatusTime() {
|
public Date lastDataTime() {
|
||||||
return new Date();
|
return new Date();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateStatus(String reason) {
|
public void refreshDataFromPump(String reason) {
|
||||||
// do nothing
|
// do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,10 +18,10 @@ import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import info.nightscout.androidaps.MainApp;
|
import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
|
import info.nightscout.androidaps.events.EventPumpStatusChanged;
|
||||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||||
import info.nightscout.androidaps.plugins.Overview.events.EventOverviewBolusProgress;
|
import info.nightscout.androidaps.plugins.Overview.events.EventOverviewBolusProgress;
|
||||||
import info.nightscout.androidaps.plugins.DanaR.events.EventDanaRBolusStart;
|
import info.nightscout.androidaps.plugins.DanaR.events.EventDanaRBolusStart;
|
||||||
import info.nightscout.androidaps.plugins.DanaR.events.EventDanaRConnectionStatus;
|
|
||||||
|
|
||||||
public class BolusProgressDialog extends DialogFragment implements View.OnClickListener {
|
public class BolusProgressDialog extends DialogFragment implements View.OnClickListener {
|
||||||
private static Logger log = LoggerFactory.getLogger(BolusProgressDialog.class);
|
private static Logger log = LoggerFactory.getLogger(BolusProgressDialog.class);
|
||||||
|
@ -46,7 +46,7 @@ public class BolusProgressDialog extends DialogFragment implements View.OnClickL
|
||||||
bolusEnded = false;
|
bolusEnded = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setHelperActivity(BolusProgressHelperActivity activity){
|
public void setHelperActivity(BolusProgressHelperActivity activity) {
|
||||||
this.helperActivity = activity;
|
this.helperActivity = activity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,9 +77,9 @@ public class BolusProgressDialog extends DialogFragment implements View.OnClickL
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void dismiss(){
|
public void dismiss() {
|
||||||
super.dismiss();
|
super.dismiss();
|
||||||
if (helperActivity!= null){
|
if (helperActivity != null) {
|
||||||
helperActivity.finish();
|
helperActivity.finish();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -128,7 +128,7 @@ public class BolusProgressDialog extends DialogFragment implements View.OnClickL
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onStatusEvent(final EventDanaRConnectionStatus c) {
|
public void onStatusEvent(final EventPumpStatusChanged c) {
|
||||||
|
|
||||||
Activity activity = getActivity();
|
Activity activity = getActivity();
|
||||||
if (activity != null) {
|
if (activity != null) {
|
||||||
|
@ -136,14 +136,7 @@ public class BolusProgressDialog extends DialogFragment implements View.OnClickL
|
||||||
new Runnable() {
|
new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (c.sStatus == c.CONNECTING) {
|
statusView.setText(c.textStatus());
|
||||||
statusView.setText(String.format(MainApp.sResources.getString(R.string.danar_history_connectingfor), c.sSecondsElapsed));
|
|
||||||
} else if (c.sStatus == c.CONNECTED) {
|
|
||||||
statusView.setText(MainApp.sResources.getString(R.string.connected));
|
|
||||||
} else {
|
|
||||||
statusView.setText(MainApp.sResources.getString(R.string.disconnected));
|
|
||||||
if (started) scheduleDismiss();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
|
@ -63,6 +63,7 @@ import info.nightscout.androidaps.events.EventInitializationChanged;
|
||||||
import info.nightscout.androidaps.events.EventNewBG;
|
import info.nightscout.androidaps.events.EventNewBG;
|
||||||
import info.nightscout.androidaps.events.EventNewBasalProfile;
|
import info.nightscout.androidaps.events.EventNewBasalProfile;
|
||||||
import info.nightscout.androidaps.events.EventPreferenceChange;
|
import info.nightscout.androidaps.events.EventPreferenceChange;
|
||||||
|
import info.nightscout.androidaps.events.EventPumpStatusChanged;
|
||||||
import info.nightscout.androidaps.events.EventRefreshGui;
|
import info.nightscout.androidaps.events.EventRefreshGui;
|
||||||
import info.nightscout.androidaps.events.EventTempBasalChange;
|
import info.nightscout.androidaps.events.EventTempBasalChange;
|
||||||
import info.nightscout.androidaps.events.EventTreatmentChange;
|
import info.nightscout.androidaps.events.EventTreatmentChange;
|
||||||
|
@ -71,7 +72,6 @@ import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||||
import info.nightscout.androidaps.plugins.Careportal.Dialogs.NewNSTreatmentDialog;
|
import info.nightscout.androidaps.plugins.Careportal.Dialogs.NewNSTreatmentDialog;
|
||||||
import info.nightscout.androidaps.plugins.Careportal.OptionsToShow;
|
import info.nightscout.androidaps.plugins.Careportal.OptionsToShow;
|
||||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||||
import info.nightscout.androidaps.plugins.DanaR.events.EventDanaRConnectionStatus;
|
|
||||||
import info.nightscout.androidaps.plugins.Loop.LoopPlugin;
|
import info.nightscout.androidaps.plugins.Loop.LoopPlugin;
|
||||||
import info.nightscout.androidaps.plugins.Loop.events.EventNewOpenLoopNotification;
|
import info.nightscout.androidaps.plugins.Loop.events.EventNewOpenLoopNotification;
|
||||||
import info.nightscout.androidaps.plugins.Objectives.ObjectivesPlugin;
|
import info.nightscout.androidaps.plugins.Objectives.ObjectivesPlugin;
|
||||||
|
@ -93,7 +93,6 @@ import info.nightscout.utils.DateUtil;
|
||||||
import info.nightscout.utils.DecimalFormatter;
|
import info.nightscout.utils.DecimalFormatter;
|
||||||
import info.nightscout.utils.Round;
|
import info.nightscout.utils.Round;
|
||||||
import info.nightscout.utils.SP;
|
import info.nightscout.utils.SP;
|
||||||
import info.nightscout.utils.SafeParse;
|
|
||||||
|
|
||||||
|
|
||||||
public class OverviewFragment extends Fragment {
|
public class OverviewFragment extends Fragment {
|
||||||
|
@ -118,6 +117,8 @@ public class OverviewFragment extends Fragment {
|
||||||
TextView apsModeView;
|
TextView apsModeView;
|
||||||
TextView tempTargetView;
|
TextView tempTargetView;
|
||||||
TextView pumpStatusView;
|
TextView pumpStatusView;
|
||||||
|
LinearLayout loopStatusLayout;
|
||||||
|
LinearLayout pumpStatusLayout;
|
||||||
GraphView bgGraph;
|
GraphView bgGraph;
|
||||||
CheckBox showPredictionView;
|
CheckBox showPredictionView;
|
||||||
|
|
||||||
|
@ -162,7 +163,9 @@ public class OverviewFragment extends Fragment {
|
||||||
baseBasalView = (TextView) view.findViewById(R.id.overview_basebasal);
|
baseBasalView = (TextView) view.findViewById(R.id.overview_basebasal);
|
||||||
basalLayout = (LinearLayout) view.findViewById(R.id.overview_basallayout);
|
basalLayout = (LinearLayout) view.findViewById(R.id.overview_basallayout);
|
||||||
activeProfileView = (TextView) view.findViewById(R.id.overview_activeprofile);
|
activeProfileView = (TextView) view.findViewById(R.id.overview_activeprofile);
|
||||||
pumpStatusView = (TextView) view.findViewById(R.id.overview_initializing);
|
pumpStatusView = (TextView) view.findViewById(R.id.overview_pumpstatus);
|
||||||
|
loopStatusLayout = (LinearLayout) view.findViewById(R.id.overview_looplayout);
|
||||||
|
pumpStatusLayout = (LinearLayout) view.findViewById(R.id.overview_pumpstatuslayout);
|
||||||
|
|
||||||
iobView = (TextView) view.findViewById(R.id.overview_iob);
|
iobView = (TextView) view.findViewById(R.id.overview_iob);
|
||||||
apsModeView = (TextView) view.findViewById(R.id.overview_apsmode);
|
apsModeView = (TextView) view.findViewById(R.id.overview_apsmode);
|
||||||
|
@ -295,7 +298,7 @@ public class OverviewFragment extends Fragment {
|
||||||
sHandler.post(new Runnable() {
|
sHandler.post(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
MainApp.getConfigBuilder().updateStatus("RefreshClicked");
|
MainApp.getConfigBuilder().refreshDataFromPump("RefreshClicked");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -320,7 +323,7 @@ public class OverviewFragment extends Fragment {
|
||||||
|
|
||||||
final JSONObject boluscalcJSON = new JSONObject();
|
final JSONObject boluscalcJSON = new JSONObject();
|
||||||
try {
|
try {
|
||||||
boluscalcJSON.put("eventTime", DateUtil.toISOString(new Date()));
|
boluscalcJSON.put("eventTime", DateUtil.toISOString(new Date()));
|
||||||
boluscalcJSON.put("targetBGLow", wizard.targetBGLow);
|
boluscalcJSON.put("targetBGLow", wizard.targetBGLow);
|
||||||
boluscalcJSON.put("targetBGHigh", wizard.targetBGHigh);
|
boluscalcJSON.put("targetBGHigh", wizard.targetBGHigh);
|
||||||
boluscalcJSON.put("isf", wizard.sens);
|
boluscalcJSON.put("isf", wizard.sens);
|
||||||
|
@ -477,18 +480,13 @@ public class OverviewFragment extends Fragment {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onStatusEvent(final EventDanaRConnectionStatus s) {
|
public void onStatusEvent(final EventPumpStatusChanged s) {
|
||||||
Activity activity = getActivity();
|
Activity activity = getActivity();
|
||||||
if (activity != null)
|
if (activity != null)
|
||||||
activity.runOnUiThread(new Runnable() {
|
activity.runOnUiThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (s.sStatus == EventDanaRConnectionStatus.CONNECTING)
|
updatePumpStatus(s.textStatus());
|
||||||
updatePumpStatus(String.format(getString(R.string.danar_history_connectingfor), s.sSecondsElapsed));
|
|
||||||
else if (s.sStatus == EventDanaRConnectionStatus.PERFORMING)
|
|
||||||
updatePumpStatus(s.sAction);
|
|
||||||
else if (s.sStatus == EventDanaRConnectionStatus.DISCONNECTED)
|
|
||||||
updatePumpStatus(null);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -517,30 +515,15 @@ public class OverviewFragment extends Fragment {
|
||||||
|
|
||||||
private void updatePumpStatus(String status) {
|
private void updatePumpStatus(String status) {
|
||||||
PumpInterface pump = MainApp.getConfigBuilder();
|
PumpInterface pump = MainApp.getConfigBuilder();
|
||||||
if (status != null) {
|
if (!status.equals("")) {
|
||||||
pumpStatusView.setText(status);
|
pumpStatusView.setText(status);
|
||||||
pumpStatusView.setVisibility(View.VISIBLE);
|
pumpStatusLayout.setVisibility(View.VISIBLE);
|
||||||
} else if (pump.isBusy()) {
|
loopStatusLayout.setVisibility(View.GONE);
|
||||||
pumpStatusView.setText(R.string.pumpbusy);
|
|
||||||
pumpStatusView.setVisibility(View.VISIBLE);
|
|
||||||
} else if (pump.isSuspended()) {
|
|
||||||
// disable all treatment buttons because we are not able to check constraints without profile
|
|
||||||
wizardButton.setVisibility(View.INVISIBLE);
|
|
||||||
treatmentButton.setVisibility(View.INVISIBLE);
|
|
||||||
quickWizardButton.setVisibility(View.INVISIBLE);
|
|
||||||
pumpStatusView.setText(R.string.pumpsuspendedclicktorefresh);
|
|
||||||
pumpStatusView.setVisibility(View.VISIBLE);
|
|
||||||
} else if (!pump.isInitialized()) {
|
|
||||||
// disable all treatment buttons because we are not able to check constraints without profile
|
|
||||||
wizardButton.setVisibility(View.INVISIBLE);
|
|
||||||
treatmentButton.setVisibility(View.INVISIBLE);
|
|
||||||
quickWizardButton.setVisibility(View.INVISIBLE);
|
|
||||||
pumpStatusView.setText(R.string.waitingforpumpclicktorefresh);
|
|
||||||
pumpStatusView.setVisibility(View.VISIBLE);
|
|
||||||
} else {
|
} else {
|
||||||
wizardButton.setVisibility(View.VISIBLE);
|
wizardButton.setVisibility(View.VISIBLE);
|
||||||
treatmentButton.setVisibility(View.VISIBLE);
|
treatmentButton.setVisibility(View.VISIBLE);
|
||||||
pumpStatusView.setVisibility(View.GONE);
|
pumpStatusLayout.setVisibility(View.GONE);
|
||||||
|
loopStatusLayout.setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -552,10 +535,12 @@ public class OverviewFragment extends Fragment {
|
||||||
|
|
||||||
if (MainApp.getConfigBuilder() == null || MainApp.getConfigBuilder().getActiveProfile() == null || MainApp.getConfigBuilder().getActiveProfile().getProfile() == null) {// app not initialized yet
|
if (MainApp.getConfigBuilder() == null || MainApp.getConfigBuilder().getActiveProfile() == null || MainApp.getConfigBuilder().getActiveProfile().getProfile() == null) {// app not initialized yet
|
||||||
pumpStatusView.setText(R.string.noprofileset);
|
pumpStatusView.setText(R.string.noprofileset);
|
||||||
pumpStatusView.setVisibility(View.VISIBLE);
|
pumpStatusLayout.setVisibility(View.VISIBLE);
|
||||||
|
loopStatusLayout.setVisibility(View.GONE);
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
pumpStatusView.setVisibility(View.GONE);
|
pumpStatusLayout.setVisibility(View.GONE);
|
||||||
|
loopStatusLayout.setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Skip if not initialized yet
|
// Skip if not initialized yet
|
||||||
|
@ -1003,7 +988,7 @@ public class OverviewFragment extends Fragment {
|
||||||
bgGraph.getGridLabelRenderer().setVerticalLabelsSecondScaleColor(ContextCompat.getColor(MainApp.instance(), R.color.background_material_dark)); // same color as backround = hide
|
bgGraph.getGridLabelRenderer().setVerticalLabelsSecondScaleColor(ContextCompat.getColor(MainApp.instance(), R.color.background_material_dark)); // same color as backround = hide
|
||||||
}
|
}
|
||||||
|
|
||||||
updatePumpStatus(null);
|
//updatePumpStatus(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Notifications
|
//Notifications
|
||||||
|
|
|
@ -158,12 +158,12 @@ public class VirtualPumpPlugin implements PluginBase, PumpInterface {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Date lastStatusTime() {
|
public Date lastDataTime() {
|
||||||
return new Date();
|
return new Date();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateStatus(String reason) {
|
public void refreshDataFromPump(String reason) {
|
||||||
// do nothing
|
// do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,7 @@ public class KeepAliveReceiver extends BroadcastReceiver {
|
||||||
boolean isBasalOutdated = false;
|
boolean isBasalOutdated = false;
|
||||||
boolean isStatusOutdated = false;
|
boolean isStatusOutdated = false;
|
||||||
|
|
||||||
Date lastConnection = pump.lastStatusTime();
|
Date lastConnection = pump.lastDataTime();
|
||||||
if (lastConnection.getTime() + 30 * 60 * 1000L < new Date().getTime())
|
if (lastConnection.getTime() + 30 * 60 * 1000L < new Date().getTime())
|
||||||
isStatusOutdated = true;
|
isStatusOutdated = true;
|
||||||
if (Math.abs(profile.getBasal(NSProfile.secondsFromMidnight()) - pump.getBaseBasalRate()) > pump.getPumpDescription().basalStep)
|
if (Math.abs(profile.getBasal(NSProfile.secondsFromMidnight()) - pump.getBaseBasalRate()) > pump.getPumpDescription().basalStep)
|
||||||
|
@ -58,7 +58,7 @@ public class KeepAliveReceiver extends BroadcastReceiver {
|
||||||
Thread t = new Thread(new Runnable() {
|
Thread t = new Thread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
pump.updateStatus("KeepAlive. Status outdated.");
|
pump.refreshDataFromPump("KeepAlive. Status outdated.");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
t.start();
|
t.start();
|
||||||
|
@ -66,7 +66,7 @@ public class KeepAliveReceiver extends BroadcastReceiver {
|
||||||
Thread t = new Thread(new Runnable() {
|
Thread t = new Thread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
pump.updateStatus("KeepAlive. Basal outdated.");
|
pump.refreshDataFromPump("KeepAlive. Basal outdated.");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
t.start();
|
t.start();
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
</android.support.v7.widget.RecyclerView>
|
</android.support.v7.widget.RecyclerView>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
|
android:id="@+id/overview_looplayout"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
|
@ -32,13 +33,13 @@
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_marginLeft="10dp"
|
android:layout_marginLeft="10dp"
|
||||||
android:layout_marginRight="10dp"
|
android:layout_marginRight="10dp"
|
||||||
|
android:layout_weight="0.1"
|
||||||
android:background="@drawable/loopmodeborder"
|
android:background="@drawable/loopmodeborder"
|
||||||
android:gravity="center_vertical|center_horizontal"
|
android:gravity="center_vertical|center_horizontal"
|
||||||
android:paddingLeft="10dp"
|
android:paddingLeft="10dp"
|
||||||
android:paddingRight="10dp"
|
android:paddingRight="10dp"
|
||||||
android:text="Open Loop"
|
android:text="Open Loop"
|
||||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
android:textAppearance="?android:attr/textAppearanceSmall" />
|
||||||
android:layout_weight="0.1" />
|
|
||||||
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
|
@ -62,38 +63,40 @@
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="right"
|
android:layout_gravity="right"
|
||||||
android:layout_marginRight="10dp"
|
android:layout_marginRight="10dp"
|
||||||
|
android:layout_weight="0.2"
|
||||||
android:background="@drawable/temptargetborder"
|
android:background="@drawable/temptargetborder"
|
||||||
android:gravity="center_vertical|center_horizontal"
|
android:gravity="center_vertical|center_horizontal"
|
||||||
android:text="TempTarget"
|
|
||||||
android:paddingLeft="10dp"
|
android:paddingLeft="10dp"
|
||||||
android:paddingRight="10dp"
|
android:paddingRight="10dp"
|
||||||
|
android:text="TempTarget"
|
||||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||||
android:textColor="@color/mdtp_white"
|
android:textColor="@color/mdtp_white" />
|
||||||
android:layout_weight="0.2" />
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
|
android:id="@+id/overview_pumpstatuslayout"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
android:paddingTop="2dp">
|
android:paddingTop="2dp">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/overview_initializing"
|
android:id="@+id/overview_pumpstatus"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:background="@drawable/initializingborder"
|
android:background="@drawable/initializingborder"
|
||||||
android:gravity="center_vertical|center_horizontal"
|
android:gravity="center_vertical|center_horizontal"
|
||||||
|
android:layout_marginLeft="10dp"
|
||||||
|
android:layout_marginRight="10dp"
|
||||||
android:text="@string/initializing"
|
android:text="@string/initializing"
|
||||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
android:textAppearance="?android:attr/textAppearanceMedium" />
|
||||||
android:layout_marginTop="10dp" />
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="horizontal"
|
android:gravity="center_horizontal"
|
||||||
android:gravity="center_horizontal">
|
android:orientation="horizontal">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/overview_bg"
|
android:id="@+id/overview_bg"
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
<color name="colorPrimary">#3F51B5</color>
|
<color name="colorPrimary">#3F51B5</color>
|
||||||
<color name="colorPrimaryDark">#303F9F</color>
|
<color name="colorPrimaryDark">#303F9F</color>
|
||||||
<color name="colorAccent">#FF4081</color>
|
<color name="colorAccent">#FF4081</color>
|
||||||
<color name="colorInitializingBorder">#ff2630</color>
|
<color name="colorInitializingBorder">#00695c</color>
|
||||||
|
|
||||||
<color name="cardColorBackground">#121212</color>
|
<color name="cardColorBackground">#121212</color>
|
||||||
<color name="cardObjectiveText">#779ECB</color>
|
<color name="cardObjectiveText">#779ECB</color>
|
||||||
|
|
Loading…
Reference in a new issue