Ejemplo n.º 1
0
  /** Computes the total burst energy. */
  private void computeBurstEnergyRadioResource() {
    List<RrcStateRange> rrcCollection = analysis.getRrcStateMachine().getRRcStateRanges();
    int rrcCount = rrcCollection.size();
    if (rrcCount == 0) {
      return;
    }
    int p = 0;
    double time2 = -1;
    double totalEnergy = 0.0f;
    Iterator<Burst> iter = burstCollection.iterator();
    Burst currentBurst = iter.next();
    double time1 = rrcCollection.get(0).getBeginTime();
    while (true) {
      Burst nextBurst = iter.hasNext() ? iter.next() : null;
      time2 =
          nextBurst != null
              ? nextBurst.getBeginTime()
              : rrcCollection.get(rrcCount - 1).getEndTime();
      double e = 0.0f;
      double activeTime = 0.0f;
      while (p < rrcCount) {
        RrcStateRange rrCntrl = rrcCollection.get(p);
        if (rrCntrl.getEndTime() < time1) {
          p++;
        } else {
          if (time2 > rrCntrl.getEndTime()) {
            e +=
                profile.energy(
                    time1, rrCntrl.getEndTime(), rrCntrl.getState(), analysis.getPackets());
            if ((rrCntrl.getState() == RRCState.STATE_DCH
                    || rrCntrl.getState() == RRCState.TAIL_DCH)
                || (rrCntrl.getState() == RRCState.LTE_CONTINUOUS
                    || rrCntrl.getState() == RRCState.LTE_CR_TAIL)
                || (rrCntrl.getState() == RRCState.WIFI_ACTIVE
                    || rrCntrl.getState() == RRCState.WIFI_TAIL)) {
              activeTime += rrCntrl.getEndTime() - time1;
            }
            p++;
          }
          break;
        }
      }
      while (p < rrcCount) {
        RrcStateRange rrCntrl = rrcCollection.get(p);
        if (rrCntrl.getEndTime() < time2) {
          e +=
              profile.energy(
                  Math.max(rrCntrl.getBeginTime(), time1),
                  rrCntrl.getEndTime(),
                  rrCntrl.getState(),
                  analysis.getPackets());
          if ((rrCntrl.getState() == RRCState.STATE_DCH || rrCntrl.getState() == RRCState.TAIL_DCH)
              || (rrCntrl.getState() == RRCState.LTE_CONTINUOUS
                  || rrCntrl.getState() == RRCState.LTE_CR_TAIL)
              || (rrCntrl.getState() == RRCState.WIFI_ACTIVE
                  || rrCntrl.getState() == RRCState.WIFI_TAIL)) {
            activeTime += rrCntrl.getEndTime() - Math.max(rrCntrl.getBeginTime(), time1);
          }
          p++;
        } else {
          e +=
              profile.energy(
                  Math.max(rrCntrl.getBeginTime(), time1),
                  time2,
                  rrCntrl.getState(),
                  analysis.getPackets());
          if ((rrCntrl.getState() == RRCState.STATE_DCH || rrCntrl.getState() == RRCState.TAIL_DCH)
              || (rrCntrl.getState() == RRCState.LTE_CONTINUOUS
                  || rrCntrl.getState() == RRCState.LTE_CR_TAIL)
              || (rrCntrl.getState() == RRCState.WIFI_ACTIVE
                  || rrCntrl.getState() == RRCState.WIFI_TAIL)) {
            activeTime += time2 - Math.max(rrCntrl.getBeginTime(), time1);
          }
          break;
        }
      }
      currentBurst.setEnergy(e);
      totalEnergy += e;
      currentBurst.setActiveTime(activeTime);

      time1 = time2;
      if (nextBurst != null) {
        currentBurst = nextBurst;
      } else {
        break;
      }
    }
    this.totalEnergy = totalEnergy;
  }