예제 #1
0
  /**
   * The "do it" method called by the SingleMethodActivator. Receive information from its probes
   * (getObjectsFromAllProbes()) and send them to bee projectionists (EpiphyteProjectionist)
   */
  public void observe() {
    if (((BeeControler) redControler.getAgentNb(0)).getPurposeName().equals("carre")) {
      watchRedQueensPoints();
      if (redPoints.length > 0) {
        msg.setTable(redPoints);
        broadcastMessage(
            BeeLauncher.BEE_COMMUNITY, "simulation", Color.red.toString() + "Controler", msg);
      }
    }

    if (((BeeControler) blueControler.getAgentNb(0)).getPurposeName().equals("carre")) {
      watchBlueQueensPoints();
      if (bluePoints.length > 0) {
        msg.setTable(bluePoints);
        broadcastMessage(
            BeeLauncher.BEE_COMMUNITY, "simulation", Color.blue.toString() + "Controler", msg);
      }
    }

    if (((BeeControler) greenControler.getAgentNb(0)).getPurposeName().equals("carre")) {
      watchGreenQueensPoints();
      if (greenPoints.length > 0) {
        msg.setTable(greenPoints);
        broadcastMessage(
            BeeLauncher.BEE_COMMUNITY, "simulation", Color.green.toString() + "Controler", msg);
      }
    }
  }
 public boolean sendMessage(ServiceMessage what, String key, String extra) {
   if (sResMessenger == null || sReqMessenger == null) {
     return false;
   }
   Message msg = Message.obtain(null, what.ordinal());
   Bundle msgBundle = new Bundle();
   msgBundle.putString(key, extra);
   msg.setData(msgBundle);
   msg.replyTo = sReqMessenger;
   try {
     sResMessenger.send(msg);
     return true;
   } catch (RemoteException e) {
     Log.e(LOG_TAG, e.getLocalizedMessage());
     return false;
   }
 }