コード例 #1
0
ファイル: NodeInfo.java プロジェクト: saurabhd14/tinyos-1.x
 public void updateDebug(MultihopMsg msg) {
   DebugPacket DMsg = new DebugPacket(msg.dataGet(), msg.offset_data(0));
   hopcount = (byte) DMsg.getElement_estList_hopcount(0) + 1;
   int i = 0;
   for (i = 0; i < (int) DMsg.get_estEntries(); i++) {
     neighbors[i].id = 0;
     neighbors[i].id = (int) DMsg.getElement_estList_id(i);
     neighbors[i].link_quality = (int) DMsg.getElement_estList_sendEst(i);
     neighbors[i].hopcount = (int) DMsg.getElement_estList_hopcount(i);
   }
   for (; i < 5; i++) {
     neighbors[i].id = 0;
     neighbors[i].link_quality = 0;
     neighbors[i].hopcount = 0;
   }
   if (link_panel != null) link_panel.get_new_data();
 }
コード例 #2
0
ファイル: NodeInfo.java プロジェクト: saurabhd14/tinyos-1.x
  public void decay() {

    long curtime = System.currentTimeMillis();
    msgRate = calcMsgRate(curtime - lastTime);
    msgYield = calcMsgYield(curtime - lastTime);
    // also cycle the yield history.
    if (yieldHistoryCounter++ > SensorAnalyzer.YIELD_INTERVAL) {
      yieldHistoryCounter = 0;
      depthHistory[yieldHistoryPointer] = (byte) hopcount;
      yieldHistory[yieldHistoryPointer++] = yield();

      yieldHistoryPointer %= yieldHistory.length;
      if (panel != null) panel.repaint();
      if (link_panel != null) link_panel.get_new_data();
    }
    if (active) {
      active = false;
      return;
    }

    if (curtime - lastTime >= AVERAGE_INTERVAL) {
      if (self_calc != false) infoString = msgCount + " msgs ";
      else infoString = "";
      if (panel != null) panel.YieldLabel.setText(String.valueOf(percent_yield()) + " %");
    }
    int best = 0;
    int best_parent = 0;
    for (int i = 0; i < parent_count.length; i++) {
      if (parent_count[i] > best) {
        best_parent = i;
        best = parent_count[i];
      }
    }
    primary_parent = best_parent;
    best = 0;
    for (int i = 0; i < parent_count.length; i++) {
      if (parent_count[i] > best && i != primary_parent) {
        best_parent = i;
        best = parent_count[i];
      }
    }
    secondary_parent = best_parent;
  }