@Override
 public Signature getSignature() {
   FrameType imageIn = FrameType.image2D(FrameType.ELEMENT_RGBA8888, FrameType.READ_GPU);
   FrameType imageOut = FrameType.image2D(FrameType.ELEMENT_RGBA8888, FrameType.WRITE_GPU);
   return new Signature()
       .addInputPort("image", Signature.PORT_REQUIRED, imageIn)
       .addInputPort("outputWidth", Signature.PORT_OPTIONAL, FrameType.single(int.class))
       .addInputPort("outputHeight", Signature.PORT_OPTIONAL, FrameType.single(int.class))
       .addInputPort("useMipmaps", Signature.PORT_OPTIONAL, FrameType.single(boolean.class))
       .addOutputPort("image", Signature.PORT_REQUIRED, imageOut)
       .disallowOtherPorts();
 }
Beispiel #2
0
  private void frame() {
    FrameType type = frame.getFrameType();

    if (type == null) {
      // ReceivedUnwantedFrame
      if (LOG.isDebugEnabled()) LOG.debug(thisStation + " idle:Unknown frame type");
    } else if (frame.broadcast()
        && type.oneOf(FrameType.token, FrameType.bacnetDataExpectingReply, FrameType.testRequest)) {
      // ReceivedUnwantedFrame
      if (LOG.isDebugEnabled())
        LOG.debug(thisStation + " Frame type should not be broadcast: " + type);
    } else if (frame.forStation(thisStation) && type == FrameType.token) {
      // ReceivedToken
      // debug("idle:ReceivedToken from " + frame.getSourceAddress());
      if (LOG.isDebugEnabled()) LOG.debug(thisStation + " idle:ReceivedToken");
      frameCount = 0;
      soleMaster = false;
      state = MasterNodeState.useToken;
      //
      //            long now = timeSource.currentTimeMillis();
      //            if (lastTokenPossession > 0)
      //                debug("Since last token possession: " + (now - lastTokenPossession) + "
      // ms");
      //            else
      //                debug("Received first token possession");
      //            lastTokenPossession = now;
    } else if (frame.forStation(thisStation) && type == FrameType.pollForMaster) {
      // ReceivedPFM
      //            debug("idle:ReceivedPFM from " + frame.getSourceAddress());
      if (LOG.isDebugEnabled()) LOG.debug(thisStation + " idle:ReceivedPFM");
      sendFrame(FrameType.replyToPollForMaster, frame.getSourceAddress());
    } else if (frame.forStationOrBroadcast(thisStation)
        && type.oneOf(FrameType.bacnetDataNotExpectingReply, FrameType.testResponse)) {
      // ReceivedDataNoReply
      //            debug("idle:ReceivedDataNoReply");
      if (LOG.isDebugEnabled()) LOG.debug(thisStation + " idle:ReceivedDataNoReply");
      receivedDataNoReply(frame);
    } else if (frame.forStation(thisStation)
        && type.oneOf(FrameType.bacnetDataExpectingReply, FrameType.testRequest)) {
      // ReceivedDataNeedingReply
      //            debug("idle:ReceivedDataNeedingReply");
      if (LOG.isDebugEnabled()) LOG.debug(thisStation + " idle:ReceivedDataNeedingReply");
      receivedDataNeedingReply(frame);
      state = MasterNodeState.answerDataRequest;
      replyDeadline = lastNonSilence + Constants.REPLY_DELAY;
    }
  }
 @Override
 public Signature getSignature() {
   // TODO: It would be nice if we could return the slot type here. Not currently possible
   // as getSignature() is typically called before a FrameManager and its slots are setup.
   return new Signature()
       .addInputPort("frame", Signature.PORT_REQUIRED, FrameType.any())
       .disallowOtherPorts();
 }
Beispiel #4
0
  private void waitForReply() {
    if (silence() > Constants.REPLY_TIMEOUT) {
      // ReplyTimeout - assume that the request has failed
      //            debug("waitForReply:ReplyTimeout");
      if (LOG.isDebugEnabled()) LOG.debug(thisStation + " waitForReply:ReplyTimeout");
      frameCount = maxInfoFrames;
      state = MasterNodeState.doneWithToken;
    } else if (receivedInvalidFrame != null) {
      // InvalidFrame
      //            debug("waitForReply:InvalidFrame: '" + receivedInvalidFrame + "', frame=" +
      // frame);
      if (LOG.isDebugEnabled()) LOG.debug("Received invalid frame: " + receivedInvalidFrame);
      receivedInvalidFrame = null;
      state = MasterNodeState.doneWithToken;
      activity = true;
    } else if (receivedValidFrame) {
      activity = true;
      FrameType type = frame.getFrameType();

      if (frame.forStation(thisStation)) {
        if (type.oneOf(FrameType.testResponse, FrameType.bacnetDataNotExpectingReply)) {
          // ReceivedReply
          // debug("waitForReply:ReceivedReply from " + frame.getSourceAddress());
          if (LOG.isDebugEnabled()) LOG.debug(thisStation + " waitForReply:ReceivedReply");
          receivedDataNoReply(frame);
        } else if (type.oneOf(FrameType.replyPostponed)) {
          // ReceivedPostpone
          // debug("waitForReply:ReceivedPostpone from " + frame.getSourceAddress());
          if (LOG.isDebugEnabled()) LOG.debug(thisStation + " waitForReply:ReceivedPostpone");
          ; // the reply to the message has been postponed until a later time.
        }

        state = MasterNodeState.doneWithToken;
      } else if (!type.oneOf(FrameType.testResponse, FrameType.bacnetDataNotExpectingReply)) {
        // ReceivedUnexpectedFrame
        // debug("waitForReply:ReceivedUnexpectedFrame: " + frame);
        if (LOG.isDebugEnabled()) LOG.debug(thisStation + " waitForReply:ReceivedUnexpectedFrame");

        // This may indicate the presence of multiple tokens.
        state = MasterNodeState.idle;
      }

      receivedValidFrame = false;
    }
  }
Beispiel #5
0
 /** {@inheritDoc} */
 public void setYear(String s) {
   try {
     putFrame(
         new TextFrame(
             FrameType.getId(FrameType.YEAR, header.getVersion()), s, header.getVersion()));
   } catch (IOException ex) {
     ex.printStackTrace();
   }
 }
Beispiel #6
0
  public void queueFrame(FrameType type, byte destination, byte[] data) {
    if (!type.oneOf(
        FrameType.bacnetDataExpectingReply,
        FrameType.bacnetDataNotExpectingReply,
        FrameType.testRequest)) throw new RuntimeException("Cannot send frame of type: " + type);

    Frame frame = new Frame(type, destination, thisStation, data);
    synchronized (framesToSend) {
      framesToSend.add(frame);
    }
  }
Beispiel #7
0
 /** {@inheritDoc} */
 public String getTitle() {
   TextFrame tf = (TextFrame) getFrame(FrameType.getId(FrameType.SONGNAME, header.getVersion()));
   return tf == null ? "" : tf.getValue();
 }
Beispiel #8
0
 /** {@inheritDoc} */
 public String getGenre() {
   TextFrame tf = (TextFrame) getFrame(FrameType.getId(FrameType.GENRE, header.getVersion()));
   return tf == null ? "" : tf.getValue();
 }
Beispiel #9
0
 /** {@inheritDoc} */
 public String getComment() {
   CommentFrame cf =
       (CommentFrame) getFrame(FrameType.getId(FrameType.COMMENT, header.getVersion()));
   return cf == null ? "" : cf.getComment();
 }
Beispiel #10
0
 /** {@inheritDoc} */
 public String getArtist() {
   TextFrame tf = (TextFrame) getFrame(FrameType.getId(FrameType.ARTIST, header.getVersion()));
   return tf == null ? "" : tf.getValue();
 }
Beispiel #11
0
 /** {@inheritDoc} */
 public String getAlbum() {
   TextFrame tf = (TextFrame) getFrame(FrameType.getId(FrameType.ALBUM, header.getVersion()));
   return tf == null ? "" : tf.getValue();
 }
Beispiel #12
0
 /** {@inheritDoc} */
 public String getYear() {
   TextFrame tf = (TextFrame) getFrame(FrameType.getId(FrameType.YEAR, header.getVersion()));
   return tf == null ? "" : tf.getValue();
 }
Beispiel #13
0
 /** {@inheritDoc} */
 public String getTrack() {
   TextFrame tf = (TextFrame) getFrame(FrameType.getId(FrameType.TRACK, header.getVersion()));
   return tf == null ? "" : tf.getValue();
 }