Combo: Show count of boluses delivered and TBRs set on pump.
This commit is contained in:
parent
0205dc40b3
commit
6a6359f1ee
6 changed files with 133 additions and 0 deletions
|
@ -75,6 +75,7 @@ import info.nightscout.androidaps.receivers.KeepAliveReceiver;
|
||||||
import info.nightscout.androidaps.receivers.NSAlarmReceiver;
|
import info.nightscout.androidaps.receivers.NSAlarmReceiver;
|
||||||
import info.nightscout.utils.FabricPrivacy;
|
import info.nightscout.utils.FabricPrivacy;
|
||||||
import info.nightscout.utils.NSUpload;
|
import info.nightscout.utils.NSUpload;
|
||||||
|
import info.nightscout.utils.SP;
|
||||||
import io.fabric.sdk.android.Fabric;
|
import io.fabric.sdk.android.Fabric;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -27,6 +27,7 @@ import info.nightscout.androidaps.plugins.PumpCombo.events.EventComboPumpUpdateG
|
||||||
import info.nightscout.androidaps.queue.Callback;
|
import info.nightscout.androidaps.queue.Callback;
|
||||||
import info.nightscout.androidaps.queue.events.EventQueueChanged;
|
import info.nightscout.androidaps.queue.events.EventQueueChanged;
|
||||||
import info.nightscout.utils.DateUtil;
|
import info.nightscout.utils.DateUtil;
|
||||||
|
import info.nightscout.utils.SP;
|
||||||
|
|
||||||
public class ComboFragment extends SubscriberFragment implements View.OnClickListener, View.OnLongClickListener {
|
public class ComboFragment extends SubscriberFragment implements View.OnClickListener, View.OnLongClickListener {
|
||||||
private TextView stateView;
|
private TextView stateView;
|
||||||
|
@ -40,6 +41,8 @@ public class ComboFragment extends SubscriberFragment implements View.OnClickLis
|
||||||
private Button refreshButton;
|
private Button refreshButton;
|
||||||
private Button alertsButton;
|
private Button alertsButton;
|
||||||
private Button tddsButton;
|
private Button tddsButton;
|
||||||
|
private TextView bolusCount;
|
||||||
|
private TextView tbrCount;
|
||||||
private Button fullHistoryButton;
|
private Button fullHistoryButton;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -55,6 +58,8 @@ public class ComboFragment extends SubscriberFragment implements View.OnClickLis
|
||||||
lastConnectionView = (TextView) view.findViewById(R.id.combo_lastconnection);
|
lastConnectionView = (TextView) view.findViewById(R.id.combo_lastconnection);
|
||||||
baseBasalRate = (TextView) view.findViewById(R.id.combo_base_basal_rate);
|
baseBasalRate = (TextView) view.findViewById(R.id.combo_base_basal_rate);
|
||||||
tempBasalText = (TextView) view.findViewById(R.id.combo_temp_basal);
|
tempBasalText = (TextView) view.findViewById(R.id.combo_temp_basal);
|
||||||
|
bolusCount = (TextView) view.findViewById(R.id.combo_bolus_count);
|
||||||
|
tbrCount = (TextView) view.findViewById(R.id.combo_tbr_count);
|
||||||
|
|
||||||
refreshButton = (Button) view.findViewById(R.id.combo_refresh_button);
|
refreshButton = (Button) view.findViewById(R.id.combo_refresh_button);
|
||||||
refreshButton.setOnClickListener(this);
|
refreshButton.setOnClickListener(this);
|
||||||
|
@ -297,6 +302,10 @@ public class ComboFragment extends SubscriberFragment implements View.OnClickLis
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
tempBasalText.setText(tbrStr);
|
tempBasalText.setText(tbrStr);
|
||||||
|
|
||||||
|
// stats
|
||||||
|
bolusCount.setText(String.valueOf(SP.getLong(ComboPlugin.COMBO_BOLUSES_DELIVERED, 0L)));
|
||||||
|
tbrCount.setText(String.valueOf(SP.getLong(ComboPlugin.COMBO_TBRS_SET, 0L)));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,12 +54,15 @@ import info.nightscout.androidaps.queue.Callback;
|
||||||
import info.nightscout.androidaps.queue.CommandQueue;
|
import info.nightscout.androidaps.queue.CommandQueue;
|
||||||
import info.nightscout.utils.DateUtil;
|
import info.nightscout.utils.DateUtil;
|
||||||
import info.nightscout.utils.FabricPrivacy;
|
import info.nightscout.utils.FabricPrivacy;
|
||||||
|
import info.nightscout.utils.SP;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by mike on 05.08.2016.
|
* Created by mike on 05.08.2016.
|
||||||
*/
|
*/
|
||||||
public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterface {
|
public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterface {
|
||||||
private static final Logger log = LoggerFactory.getLogger(ComboPlugin.class);
|
private static final Logger log = LoggerFactory.getLogger(ComboPlugin.class);
|
||||||
|
public static final String COMBO_TBRS_SET = "combo_tbrs_set";
|
||||||
|
public static final String COMBO_BOLUSES_DELIVERED = "combo_boluses_delivered";
|
||||||
|
|
||||||
private static ComboPlugin plugin = null;
|
private static ComboPlugin plugin = null;
|
||||||
private boolean fragmentEnabled = false;
|
private boolean fragmentEnabled = false;
|
||||||
|
@ -662,6 +665,7 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf
|
||||||
}
|
}
|
||||||
|
|
||||||
// full bolus was delivered successfully
|
// full bolus was delivered successfully
|
||||||
|
incrementBolusCount();
|
||||||
return new PumpEnactResult()
|
return new PumpEnactResult()
|
||||||
.success(true)
|
.success(true)
|
||||||
.enacted(lastPumpBolus.amount > 0)
|
.enacted(lastPumpBolus.amount > 0)
|
||||||
|
@ -675,6 +679,22 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void incrementTbrCount() {
|
||||||
|
try {
|
||||||
|
SP.putLong(COMBO_TBRS_SET, SP.getLong(COMBO_TBRS_SET, 0L) + 1);
|
||||||
|
} catch (Exception e) {
|
||||||
|
// ignore
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void incrementBolusCount() {
|
||||||
|
try {
|
||||||
|
SP.putLong(COMBO_BOLUSES_DELIVERED, SP.getLong(COMBO_BOLUSES_DELIVERED, 0L) + 1);
|
||||||
|
} catch (Exception e) {
|
||||||
|
// ignore
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates a DetailedBolusInfo from a pump bolus and adds it as a Treatment to the DB.
|
* Updates a DetailedBolusInfo from a pump bolus and adds it as a Treatment to the DB.
|
||||||
* Handles edge cases when dates aren't unique which are extremely unlikely to occur,
|
* Handles edge cases when dates aren't unique which are extremely unlikely to occur,
|
||||||
|
@ -803,6 +823,7 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf
|
||||||
MainApp.bus().post(new EventComboPumpUpdateGUI());
|
MainApp.bus().post(new EventComboPumpUpdateGUI());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
incrementTbrCount();
|
||||||
return new PumpEnactResult().success(true).enacted(true).isPercent(true)
|
return new PumpEnactResult().success(true).enacted(true).isPercent(true)
|
||||||
.percent(state.tbrPercent).duration(state.tbrRemainingDuration);
|
.percent(state.tbrPercent).duration(state.tbrRemainingDuration);
|
||||||
}
|
}
|
||||||
|
|
|
@ -379,6 +379,104 @@
|
||||||
android:layout_marginRight="20dp"
|
android:layout_marginRight="20dp"
|
||||||
android:layout_marginTop="5dp"
|
android:layout_marginTop="5dp"
|
||||||
android:background="@color/listdelimiter" />
|
android:background="@color/listdelimiter" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1.5"
|
||||||
|
android:gravity="end"
|
||||||
|
android:paddingRight="5dp"
|
||||||
|
android:text="@string/combo_bolus_count"
|
||||||
|
android:textSize="14sp" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="5dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="0"
|
||||||
|
android:gravity="center_horizontal"
|
||||||
|
android:paddingEnd="2dp"
|
||||||
|
android:paddingStart="2dp"
|
||||||
|
android:text=":"
|
||||||
|
android:textSize="14sp" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/combo_bolus_count"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:gravity="start"
|
||||||
|
android:paddingLeft="5dp"
|
||||||
|
android:textColor="@android:color/white"
|
||||||
|
android:textSize="14sp" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="2dip"
|
||||||
|
android:layout_marginBottom="5dp"
|
||||||
|
android:layout_marginLeft="20dp"
|
||||||
|
android:layout_marginRight="20dp"
|
||||||
|
android:layout_marginTop="5dp"
|
||||||
|
android:background="@color/listdelimiter" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1.5"
|
||||||
|
android:gravity="end"
|
||||||
|
android:paddingRight="5dp"
|
||||||
|
android:text="@string/combo_tbr_count"
|
||||||
|
android:textSize="14sp" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="5dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="0"
|
||||||
|
android:gravity="center_horizontal"
|
||||||
|
android:paddingEnd="2dp"
|
||||||
|
android:paddingStart="2dp"
|
||||||
|
android:text=":"
|
||||||
|
android:textSize="14sp" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/combo_tbr_count"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:gravity="start"
|
||||||
|
android:paddingLeft="5dp"
|
||||||
|
android:textColor="@android:color/white"
|
||||||
|
android:textSize="14sp" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="2dip"
|
||||||
|
android:layout_marginBottom="5dp"
|
||||||
|
android:layout_marginLeft="20dp"
|
||||||
|
android:layout_marginRight="20dp"
|
||||||
|
android:layout_marginTop="5dp"
|
||||||
|
android:background="@color/listdelimiter" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/combo_queue"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text=""
|
||||||
|
android:textAlignment="center" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
|
@ -388,6 +486,7 @@
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_alignParentBottom="true"
|
android:layout_alignParentBottom="true"
|
||||||
|
android:paddingRight="5dp"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
|
|
|
@ -392,6 +392,7 @@
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:paddingRight="5dp"
|
||||||
android:orientation="horizontal">
|
android:orientation="horizontal">
|
||||||
|
|
||||||
<info.nightscout.utils.SingleClickButton
|
<info.nightscout.utils.SingleClickButton
|
||||||
|
|
|
@ -999,5 +999,7 @@
|
||||||
<string name="combo_check_date">The last bolus is older than 24 hours or is in the future. Please check the date on the pump is set correctly.</string>
|
<string name="combo_check_date">The last bolus is older than 24 hours or is in the future. Please check the date on the pump is set correctly.</string>
|
||||||
<string name="combo_suspious_bolus_time">Time/date of the delivered bolus on pump seems wrong, IOB is likely incorrect. Please check pump time/date.</string>
|
<string name="combo_suspious_bolus_time">Time/date of the delivered bolus on pump seems wrong, IOB is likely incorrect. Please check pump time/date.</string>
|
||||||
<string name="profileswitch_ismissing">ProfileSwitch missing. Please do a profile switch or press \"Activate Profile\" in the LocalProfile.</string>
|
<string name="profileswitch_ismissing">ProfileSwitch missing. Please do a profile switch or press \"Activate Profile\" in the LocalProfile.</string>
|
||||||
|
<string name="combo_bolus_count">Bolus count</string>
|
||||||
|
<string name="combo_tbr_count">TBR count</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue