/// <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()); } }
/// <summary> /// Overrides the SimpleThread.stop() method. /// Wakes up any sleeping C++ threads. /// Joins JausRouter thread. /// </summary> public override void stop() { lock (runLock){ isRunning = false; } // Send a message to ourselves to wake up the thread. byte[] msg_id = { 0 }; JuniorAPI.JrSend(jrHandle, jausAddress.get(), (uint)2, msg_id); thread.Join(THREAD_JOIN_TIME * 10); }