コード例 #1
1
    // Get IOB and COB only, dont update chart
    public static JSONObject getIOBCOB(Activity a) {

      List<Stats> statList = Stats.updateActiveBarChart(a.getBaseContext());
      JSONObject reply = new JSONObject();

      if (statList.size() > 0) {
        try {
          reply.put("iob", String.format(Locale.ENGLISH, "%.2f", statList.get(0).iob));
          reply.put("cob", String.format(Locale.ENGLISH, "%.2f", statList.get(0).cob));
        } catch (JSONException e) {
          Crashlytics.logException(e);
          e.printStackTrace();
        }
        return reply;
      } else {
        try {
          reply.put("iob", String.format(Locale.ENGLISH, "%.2f", 0.00));
          reply.put("cob", String.format(Locale.ENGLISH, "%.2f", 0.00));
        } catch (JSONException e) {
          Crashlytics.logException(e);
          e.printStackTrace();
        }
        return reply;
      }
    }
コード例 #2
0
    // Updates Stats
    public static JSONObject updateChart(Activity a) {

      JSONObject reply = new JSONObject();
      List<Stats> statList = Stats.updateActiveBarChart(a.getBaseContext());

      if (iobcobChart != null || statList != null || statList.size() > 0) {
        // reloads charts with Treatment data
        iobcobChart.setColumnChartData(extendedGraphBuilder.iobcobFutureChart(statList));
        try {
          reply.put("iob", String.format(Locale.ENGLISH, "%.2f", statList.get(0).iob));
          reply.put("cob", String.format(Locale.ENGLISH, "%.2f", statList.get(0).cob));
        } catch (JSONException e) {
          Crashlytics.logException(e);
          e.printStackTrace();
        }
        return reply;
      } else {
        try {
          reply.put("iob", String.format(Locale.ENGLISH, "%.2f", 0.00));
          reply.put("cob", String.format(Locale.ENGLISH, "%.2f", 0.00));
        } catch (JSONException e) {
          Crashlytics.logException(e);
          e.printStackTrace();
        }
        return reply;
      }
    }
コード例 #3
0
  public void displayCurrentInfo() {
    final TextView currentBgValueText = (TextView) findViewById(R.id.currentBgValueRealTime);
    final TextView notificationText = (TextView) findViewById(R.id.notices);
    final TextView deltaText = (TextView) findViewById(R.id.bgDelta);
    if ((currentBgValueText.getPaintFlags() & Paint.STRIKE_THRU_TEXT_FLAG) > 0) {
      currentBgValueText.setPaintFlags(
          currentBgValueText.getPaintFlags() & (~Paint.STRIKE_THRU_TEXT_FLAG));
    }
    Bg lastBgreading = Bg.last();

    if (lastBgreading != null) {
      notificationText.setText(lastBgreading.readingAge());
      String bgDelta = new String(String.format(Locale.ENGLISH, "%.2f", lastBgreading.bgdelta));
      if (lastBgreading.bgdelta >= 0) bgDelta = "+" + bgDelta;
      deltaText.setText(bgDelta);
      currentBgValueText.setText(
          extendedGraphBuilder.unitized_string(lastBgreading.sgv_double())
              + " "
              + lastBgreading.slopeArrow());

      if ((new Date().getTime()) - (60000 * 16) - lastBgreading.datetime > 0) {
        notificationText.setTextColor(Color.parseColor("#C30909"));
        currentBgValueText.setPaintFlags(
            currentBgValueText.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
      } else {
        notificationText.setTextColor(Color.WHITE);
      }
      double estimate = lastBgreading.sgv_double();
      if (extendedGraphBuilder.unitized(estimate) <= extendedGraphBuilder.lowMark) {
        currentBgValueText.setTextColor(Color.parseColor("#C30909"));
      } else if (extendedGraphBuilder.unitized(estimate) >= extendedGraphBuilder.highMark) {
        currentBgValueText.setTextColor(Color.parseColor("#FFBB33"));
      } else {
        currentBgValueText.setTextColor(Color.WHITE);
      }
    }

    // Stats age update
    statsAge = (TextView) findViewById(R.id.statsAge);
    Stats lastRun = Stats.last();
    if (lastRun != null) statsAge.setText(lastRun.statAge());

    // OpenAPS age update
    openAPSAgeTextView = (TextView) findViewById(R.id.openapsAge);
    openAPSAgeTextView.setText(openAPSFragment.age());

    // Temp Basal running update
    Date timeNow = new Date();
    sysMsg = (TextView) findViewById(R.id.sysmsg);
    TempBasal lastTempBasal = TempBasal.last();
    String appStatus;
    if (lastTempBasal.isactive(null)) { // Active temp Basal
      appStatus =
          lastTempBasal.basal_adjustemnt
              + " Temp active: "
              + lastTempBasal.rate
              + "U("
              + lastTempBasal.ratePercent
              + "%) "
              + lastTempBasal.durationLeft()
              + "mins left";
    } else { // No temp Basal running, show default
      Double currentBasal = Profile.ProfileAsOf(timeNow, this.getBaseContext()).current_basal;
      appStatus = "No temp basal, current basal: " + currentBasal + "U";
    }
    sysMsg.setText(appStatus);
  }