Esempio n. 1
0
  @Test(timeout = 700)
  public void alterOutput() throws Exception {

    C c = new C();
    c.addListener(
        new Listener() {

          @Override
          public void notice(Type T, EventObject E) {
            if (T == Type.OUT) {
              DataflowEvent ce = (DataflowEvent) E;
              if (ce.getValue() instanceof Double) {
                assertEquals(1.2, ce.getValue());
                ce.setValue(new Double(3.2));
              }
              // System.out.println(" ---- " + ce.getValue() + " " +
              // ce.getValue().getClass());
            }
          }
        });
    c.in = "1";
    c.execute();
    // System.out.println(c.get(c.op2, "cmdOut"));
    assertEquals("CMD2(3.2)", c.out);
  }
Esempio n. 2
0
  /**
   * Don't need to override this method.
   *
   * @param listener
   * @param vehicleCommId
   * @param filter
   * @return
   */
  public boolean addListener(
      MessageListener<Mi, M> listener, I vehicleCommId, MessageFilter<Mi, M> filter) {
    C vci = null;
    I vIdS = vehicleCommId;

    if (vehicleCommId == null) return false;

    vci = commInfo.get(vIdS);
    if (vci == null) {
      // FIXME Ver o q preencher aqui no InetAdress
      initSystemCommInfo(vIdS, "");
      vci = commInfo.get(vIdS);
    }
    boolean ret = false;

    if (vci != null) ret = vci.addListener(listener, filter);

    NeptusLog.pub().debug("Add listener for vehicle: " + vIdS + ".");

    return ret;
  }