Example #1
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());
            }
        }
Example #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);
        }
        public virtual bool isControllingClient(Receive.Body.ReceiveRec transportData)
        {
            JausAddress requester = new JausAddress((ushort)transportData.getSourceID().getSubsystemID(),
                                            (byte)transportData.getSourceID().getNodeID(),
                                            (byte)transportData.getSourceID().getComponentID());

            if ((currentController != null) &&
            (requester.getSubsystemID() == currentController.getSubsystemID() &&
            requester.getNodeID() == currentController.getNodeID() &&
            requester.getComponentID() == currentController.getComponentID()))
            {
            return true;
            }
            return false;
        }
Example #4
0
        /// <summary>
        /// Checks the C++ framework for incoming messages, routing them as needed.
        /// </summary>
        public override void run()
        {
            int  priority = 0;
            uint source   = 0;
            int  flags    = 0;
            uint bufsize  = 0;

            byte[] buffer;
            ushort msg_id = 0;

            //runLock._lock();
            isRunning = true;
            //runLock.unlock();

            while (isRunning)
            {
                buffer = JuniorAPI.JrReceive((int)jrHandle, ref source, ref priority, ref flags, ref msg_id);
                if (buffer != null & buffer.Length > 0)
                {
                    if (!isRunning)
                    {
                        break;
                    }
                    bufsize = (uint)buffer.Length;
                    byte[] tmpBuff = new byte[buffer.Length];
                    for (int i = 0; i < buffer.Length; i++)
                    {
                        tmpBuff[i] = buffer[i];
                    }
                    buffer = null;
                    Receive     message = new Receive();
                    JausAddress sender  = new JausAddress(source);

                    message.getBody().getReceiveRec().setSrcSubsystemID(sender.getSubsystemID());
                    message.getBody().getReceiveRec().setSrcNodeID(sender.getNodeID());
                    message.getBody().getReceiveRec().setSrcComponentID(sender.getComponentID());
                    message.getBody().getReceiveRec().getMessagePayload().set(bufsize, tmpBuff);
                    routeMessage(message);
                }
                else
                {
                    //OS.JrSleep(1); //throttle
                }
            }
        }
Example #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, 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);
        }
Example #6
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);
 }
Example #7
0
        /// <summary>
        /// Checks the C++ framework for incoming messages, routing them as needed.
        /// </summary>
        public override void run()
        {
            int priority = 0;
            uint source = 0;
            int flags =0;
            uint bufsize = 0;
            byte[] buffer;
            ushort msg_id = 0;
            //runLock._lock();
            isRunning = true;
            //runLock.unlock();

            while(isRunning)
            {
                buffer = JuniorAPI.JrReceive((int) jrHandle, ref source, ref priority, ref flags, ref msg_id);
                if( buffer != null & buffer.Length > 0)
                {
                    if(!isRunning)
                    {
                        break;
                    }
                    bufsize = (uint) buffer.Length;
                    Receive message = new Receive();
                    JausAddress sender = new JausAddress(source);

                    message.getBody().getReceiveRec().getSourceID().setSubsystemID(sender.getSubsystemID());
                    message.getBody().getReceiveRec().getSourceID().setNodeID(sender.getNodeID());
                    message.getBody().getReceiveRec().getSourceID().setComponentID(sender.getComponentID());
                    message.getBody().getReceiveRec().getMessagePayload().set((int) bufsize, buffer);
                    routeMessage(message);
                }
                else
                {
                    //OS.JrSleep(1); //throttle
                }
            }
        }