예제 #1
0
 public virtual void EnqueueAction(Send msg)
 {
     sendJausMessage(
     (uint)msg.getBody().getSendRec().getMessagePayload().getLength(),
     msg.getBody().getSendRec().getMessagePayload().getData(),
     new JausAddress((ushort)msg.getBody().getSendRec().getDestinationID().getSubsystemID(),
     (byte)msg.getBody().getSendRec().getDestinationID().getNodeID(),
     (byte)msg.getBody().getSendRec().getDestinationID().getComponentID()));
 }
예제 #2
0
        /// <summary>
        /// Wraps the message buffer into a Send wrapper and sends it through
        /// the JausRouter.
        /// </summary>
        /// <param name="bufsize">the size of the given buffer in bytes</param>
        /// <param name="buffer">the bytes from the message to be sent</param>
        /// <param name="dest">the destination of the message</param>
        protected void sendJausMessage(uint bufsize, byte[] buffer, JausAddress dest)
        {
            Send response = new Send();

            response.getBody().getSendRec().getMessagePayload().set((int)bufsize, buffer);
            response.getBody().getSendRec().getDestinationID().setSubsystemID(dest.getSubsystemID());
            response.getBody().getSendRec().getDestinationID().setNodeID(dest.getNodeID());
            response.getBody().getSendRec().getDestinationID().setComponentID(dest.getComponentID());
            //Console.WriteLine("Sending response msg " + BitConverter.ToInt16(b, 0));
            jausRouter.sendMessage(ref response);
        }
예제 #3
0
        /// <summary>
        /// Determines if the outgoing message is local, or needs to be routed through
        /// the node manager.
        /// </summary>
        /// <param name="msg">the outgoing message wrapped in a Send wrapper.</param>
        public void sendMessage(ref Send msg)
        {
            // Pull the destination ID
            JausAddress destination = new JausAddress((ushort)msg.getBody().getSendRec().getDestinationID().getSubsystemID(),
                                                      (byte)msg.getBody().getSendRec().getDestinationID().getNodeID(),
                                                      (byte)msg.getBody().getSendRec().getDestinationID().getComponentID());

            // If the destination is local, loopback to the route message function
            if (destination.get() == jausAddress.get())
            {
                Receive message = new Receive();
                message.getBody().getReceiveRec().getSourceID().setSubsystemID(jausAddress.getSubsystemID());
                message.getBody().getReceiveRec().getSourceID().setNodeID(jausAddress.getNodeID());
                message.getBody().getReceiveRec().getSourceID().setComponentID(jausAddress.getComponentID());
                message.getBody().getReceiveRec().getMessagePayload().set(msg.getBody().getSendRec().getMessagePayload().getLength(),
                                                                          msg.getBody().getSendRec().getMessagePayload().getData());

                routeMessage(message);
            }
            // Otherwise, forward the message to NodeManager
            else
            {
                JrErrorCode ret = JuniorAPI.JrSend((int)jrHandle, destination.get(),
                                                   (uint)msg.getBody().getSendRec().getMessagePayload().getLength(),
                                                   msg.getBody().getSendRec().getMessagePayload().getData());
            }
        }
예제 #4
0
        /// <summary>
        /// Wraps the message buffer into a Send wrapper and sends it through
        /// the JausRouter.
        /// </summary>
        /// <param name="bufsize">the size of the given buffer in bytes</param>
        /// <param name="buffer">the bytes from the message to be sent</param>
        /// <param name="dest">the destination of the message</param>
        protected void sendJausMessage(uint bufsize, byte[] buffer, JausAddress dest, bool force = false)
        {
            // We need to have a complete JAUS ID (no wildcards)
            // to send any messages, unless that message is specifically forced
            // to send by the calling application
            if (jausRouter.getJausAddress().containsWildcards() && !force)
            {
                Console.WriteLine("Can't send message when ID contains wildcards");
                return;
            }

            Send response = new Send();

            response.getBody().getSendRec().getMessagePayload().set((int)bufsize, buffer);
            response.getBody().getSendRec().getDestinationID().setSubsystemID(dest.getSubsystemID());
            response.getBody().getSendRec().getDestinationID().setNodeID(dest.getNodeID());
            response.getBody().getSendRec().getDestinationID().setComponentID(dest.getComponentID());
            //Console.WriteLine("Sending response msg " + BitConverter.ToInt16(b, 0));
            jausRouter.sendMessage(ref response);
        }
예제 #5
0
 /// <summary>
 /// Wraps the message buffer into a Send wrapper and sends it through
 /// the JausRouter.
 /// </summary>
 /// <param name="bufsize">the size of the given buffer in bytes</param>
 /// <param name="buffer">the bytes from the message to be sent</param>
 /// <param name="dest">the destination of the message</param>
 protected void sendJausMessage(uint bufsize, byte[] buffer, JausAddress dest)
 {
     Send response = new Send();
     response.getBody().getSendRec().getMessagePayload().set((int)bufsize, buffer);
     response.getBody().getSendRec().getDestinationID().setSubsystemID(dest.getSubsystemID());
     response.getBody().getSendRec().getDestinationID().setNodeID(dest.getNodeID());
     response.getBody().getSendRec().getDestinationID().setComponentID(dest.getComponentID());
     //Console.WriteLine("Sending response msg " + BitConverter.ToInt16(b, 0));
     jausRouter.sendMessage(ref response);
 }
예제 #6
0
        /// <summary>
        /// Determines if the outgoing message is local, or needs to be routed through
        /// the node manager.
        /// </summary>
        /// <param name="msg">the outgoing message wrapped in a Send wrapper.</param>
        public void sendMessage(ref Send msg)
        {
            // Pull the destination ID
            JausAddress destination = new JausAddress((ushort) msg.getBody().getSendRec().getDestinationID().getSubsystemID(),
                                                      (byte) msg.getBody().getSendRec().getDestinationID().getNodeID(),
                                                      (byte) msg.getBody().getSendRec().getDestinationID().getComponentID());
            // If the destination is local, loopback to the route message function
            if(destination.get() == jausAddress.get())
            {
                Receive message = new Receive();
                message.getBody().getReceiveRec().getSourceID().setSubsystemID(jausAddress.getSubsystemID());
                message.getBody().getReceiveRec().getSourceID().setNodeID(jausAddress.getNodeID());
                message.getBody().getReceiveRec().getSourceID().setComponentID(jausAddress.getComponentID());
                message.getBody().getReceiveRec().getMessagePayload().set(msg.getBody().getSendRec().getMessagePayload().getLength(),
                                                                      msg.getBody().getSendRec().getMessagePayload().getData());

                routeMessage(message);
            }
            // Otherwise, forward the message to NodeManager
            else
            {
                JrErrorCode ret = JuniorAPI.JrSend((int) jrHandle, destination.get(),
                                                   (uint) msg.getBody().getSendRec().getMessagePayload().getLength(),
                                                   msg.getBody().getSendRec().getMessagePayload().getData());
            }
        }