예제 #1
0
  /*
   * (non-Javadoc)
   * @see com.isencia.passerelle.actor.Transformer#doFire(com.isencia.passerelle. message.ManagedMessage)
   */
  @Override
  protected void doFire() throws ProcessingException {

    double input1 = 0;
    final Token token = firstOperandHandler.getToken();
    if (token != null && token != Token.NIL) {
      input1 = getDoubleFromMessage(token);
      double input2 = 1.0;
      if (_function == _MODULO) {
        if (secondOperand != null) {
          final Token tokenSec = secondOperandHandler.getToken();
          if (tokenSec != null && token != Token.NIL) {
            input2 = getDoubleFromMessage(tokenSec);
          }
        }
      }
      final ManagedMessage resultMsg = createMessage();
      try {
        resultMsg.setBodyContent(
            new Double(_doFunction(input1, input2)), ManagedMessage.objectContentType);
        output.broadcast(new ObjectToken(resultMsg));
      } catch (final MessageException e) {
        ExceptionUtil.throwProcessingException("Cannot send result to output", output, e);
      } catch (final IllegalActionException e) {
        ExceptionUtil.throwProcessingException("Cannot send result to output", output, e);
      }
    } else {
      requestFinish();
    }
  }