コード例 #1
0
  // Do a O(n) pass through the motes updating the given moteSender's
  // connectivity to and from each other mote
  public void updateLossRates(MoteSimObject moteSender) {
    Iterator it = state.getMoteSimObjects().iterator();
    while (it.hasNext()) {
      MoteSimObject moteReceiver = (MoteSimObject) it.next();
      if (moteReceiver.getID() == moteSender.getID()) continue;

      updateLossRate(moteSender, moteReceiver);
      updateLossRate(moteReceiver, moteSender);
    }
  }
コード例 #2
0
  // Send the loss rate for the pair of motes to the simulator
  public void publishLossRate(MoteSimObject moteSender, MoteSimObject moteReceiver, double prob) {
    try {
      int senderID = moteSender.getID();
      int receiverID = moteReceiver.getID();

      debug.err.println(
          "RADIOMODEL: publishing rate [" + senderID + "->" + receiverID + "]: " + prob);

      long scaledBitLossRate = (long) (curModel.getBitLossRate(prob) * 10000);
      SetLinkProbCommand cmd =
          new SetLinkProbCommand((short) senderID, 0L, (short) receiverID, scaledBitLossRate);
      simComm.sendCommand(cmd);
    } catch (java.io.IOException ioe) {
      System.err.println("RADIOMODEL: Cannot send command: " + ioe);
    }
  }
コード例 #3
0
  // Send the loss rate for all pairs of motes to the simulator
  public void publishModel() {
    debug.err.println("RADIOMODEL: Publishing model, current is " + curModel);
    Iterator it1 = state.getMoteSimObjects().iterator();
    while (it1.hasNext()) {
      MoteSimObject moteSender = (MoteSimObject) it1.next();
      MoteCoordinateAttribute moteSenderCoord = moteSender.getCoordinate();
      Iterator it2 = state.getMoteSimObjects().iterator();
      while (it2.hasNext()) {
        MoteSimObject moteReceiver = (MoteSimObject) it2.next();
        if (moteReceiver.getID() == moteSender.getID()) continue;

        String key = graphKey(moteSender, moteReceiver);
        double prob = ((Double) connectivityGraph.get(key)).doubleValue();
        publishLossRate(moteSender, moteReceiver, prob);
      }
    }
  }
コード例 #4
0
 public double getLossRate(MoteSimObject sender, MoteSimObject receiver) {
   return getLossRate(sender.getID(), receiver.getID());
 }
コード例 #5
0
 private String graphKey(MoteSimObject sender, MoteSimObject receiver) {
   return graphKey(sender.getID(), receiver.getID());
 }