Esempio n. 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());
            }
        }
Esempio n. 2
0
 /// <summary>
 /// Constructor. Connects with nodeManager and sets up variables.
 /// </summary>
 /// <param name="jausAddress">The JausAddress of the current component.</param>
 public JausRouter(JausAddress jausAddress, InternalEventHandler ieHandler)
 {
     this.jausAddress = jausAddress;
     this.ieHandler = ieHandler;
     jrHandle = 0;
     if (JuniorAPI.JrConnect((int)jausAddress.get(), "nm.cfg", ref jrHandle) != 0)
     {
         Console.WriteLine("UNABLE TO CONNECT TO THE NODE MANAGER.  IS IT RUNNING?");
     }
 }
Esempio n. 3
0
 /// <summary>
 /// Constructor. Connects with nodeManager and sets up variables.
 /// </summary>
 /// <param name="jausAddress">The JausAddress of the current component.</param>
 public JausRouter(JausAddress jausAddress, InternalEventHandler ieHandler)
 {
     this.jausAddress = jausAddress;
     this.ieHandler   = ieHandler;
     jrHandle         = 0;
     if (JuniorAPI.JrConnect((int)jausAddress.get(), "nm.cfg", ref jrHandle) != 0)
     {
         Console.WriteLine("UNABLE TO CONNECT TO THE NODE MANAGER.  IS IT RUNNING?");
     }
 }
Esempio n. 4
0
        public void updateJausID(JausAddress jausAddress, bool allowWildcards = false)
        {
            // Request to change our JAUS ID.  This means we have to close the current connection
            // to junior, and recreate it.  But first we need to stop the receive thread.
            stop();
            JuniorAPI.JrDisconnect((int)jrHandle);
            this.jausAddress = jausAddress;
            jrHandle         = 0;
            int jWildcards = allowWildcards ? 1 : 0;

            if (JuniorAPI.JrConnect((int)jausAddress.get(), "nm.cfg", ref jrHandle, jWildcards) != 0)
            {
                Console.WriteLine("UNABLE TO CONNECT TO THE NODE MANAGER.  IS IT RUNNING?");
            }

            start();
        }
Esempio n. 5
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());
            }
        }