Пример #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());
            }
        }
Пример #2
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
                }
            }
        }
Пример #3
0
    protected void sendMessage(JTS.Message msg, Inheritence1_csharp dest)
    {
        // First encode the message
        uint bufsize = (uint)msg.getSize();

        byte[] buffer = new byte[bufsize];
        int    pos    = 0;

        msg.encode(buffer, pos);

        // To inject a message directly into the component, we need
        // to wrap it in a receive event and spoof the source.
        JTS.Receive ie = new JTS.Receive();
        ie.getBody().getReceiveRec().getMessagePayload().set(bufsize, buffer);
        ie.getBody().getReceiveRec().setSrcSubsystemID(160);
        ie.getBody().getReceiveRec().setSrcNodeID(1);
        ie.getBody().getReceiveRec().setSrcComponentID(1);

        // Now wedge the event into the component...
        dest.processInternalEvent(ie);

        // Sleep for a bit to let the event percolate through...
        Thread.Sleep(500);
    }
Пример #4
0
			if (layer == 1) return ((urn_org_jts_test_Intermediary_1_0.IntermediaryService) serviceList[layer]).pIntermediary_Parent1FSM.context.State.Name;
			if (layer == 2) return ((urn_org_jts_test_Child_1_0.ChildService) serviceList[layer]).pChild_Parent1FSM.context.State.Name;
			return "";
		}
Пример #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());
            }
        }
Пример #6
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
                }
            }
        }