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;
        }
        public virtual void SendAction(string arg0, Receive.Body.ReceiveRec transportData)
        {
            if (arg0.CompareTo("ReportStatus") == 0)
            {
            ReportStatus status_msg = new ReportStatus();

            // Get the state from the context.  Note that since we are inside a transition, the "current state"
            // is ill-defined.  We instead use the state we left to execute this transition.  Recall that the state
            // is actually an amalgamation of all parent states, we're only concerned with the management
            string currentState = context.PreviousState.Name;  //getPreviousState().getName();
            if (currentState.Contains("_"))
            currentState = currentState.Substring(currentState.LastIndexOf("_") + 1);
            if (currentState.CompareTo("Init") == 0) status_msg.getBody().getReportStatusRec().setStatus(0);
            if (currentState.CompareTo("Ready") == 0) status_msg.getBody().getReportStatusRec().setStatus(1);
            if (currentState.CompareTo("Standby") == 0) status_msg.getBody().getReportStatusRec().setStatus(2);
            if (currentState.CompareTo("Shutdown") == 0) status_msg.getBody().getReportStatusRec().setStatus(3);
            if (currentState.CompareTo("Failure") == 0) status_msg.getBody().getReportStatusRec().setStatus(4);
            if (currentState.CompareTo("Emergency") == 0) status_msg.getBody().getReportStatusRec().setStatus(5);

            Console.WriteLine("Sending ReportStatus: " + currentState);

            // Now send it to the requesting component
            JausAddress sender = new JausAddress((ushort)transportData.getSourceID().getSubsystemID(),
                                               (byte)transportData.getSourceID().getNodeID(),
                                               (byte)transportData.getSourceID().getComponentID());
            sendJausMessage(status_msg, sender);
            }
        }
        public virtual void SendAction(string arg0, string arg1, Receive.Body.ReceiveRec transportData)
        {
            if (arg0.CompareTo("RejectControl") == 0)
            {
            RejectControl reject_msg = new RejectControl();
            if (arg1.CompareTo("CONTROL_RELEASED") == 0) reject_msg.getBody().getRejectControlRec().setResponseCode(0);
            if (arg1.CompareTo("NOT_ACCEPTED") == 0) reject_msg.getBody().getRejectControlRec().setResponseCode(1);

            // Now send it to the requesting component
            JausAddress sender = new JausAddress((ushort)transportData.getSourceID().getSubsystemID(),
                                            (byte)transportData.getSourceID().getNodeID(),
                                            (byte)transportData.getSourceID().getComponentID());

            sendJausMessage(reject_msg, sender);

            }

            else if (arg0.CompareTo("ConfirmControl") == 0)
            {
            ConfirmControl confirm_msg = new ConfirmControl();
            byte responseCode = 0;
            if (arg1.CompareTo("CONTROL_ACCEPTED") == 0) responseCode = 0;
            if (arg1.CompareTo("NOT_AVAILABLE") == 0) responseCode = 1;
            if (arg1.CompareTo("INSUFFICIENT_AUTHORITY") == 0) responseCode = 2;
            Console.WriteLine("Sending ConfirmControl with argument " + arg1);
            confirm_msg.getBody().getConfirmControlRec().setResponseCode(responseCode);

            // Now send it to the requesting component
            JausAddress sender = new JausAddress((ushort)transportData.getSourceID().getSubsystemID(),
                                            (byte)transportData.getSourceID().getNodeID(),
                                            (byte)transportData.getSourceID().getComponentID());
            sendJausMessage(confirm_msg, sender);
            }
            else if (arg0.CompareTo("ReportControl") == 0)
            {
            ReportControl control_msg = new ReportControl();
            control_msg.getBody().getReportControlRec().setSubsystemID((ushort)(
                                         (currentController == null) ? 0 : currentController.getSubsystemID()));
            control_msg.getBody().getReportControlRec().setNodeID((byte)(
                                    (currentController == null) ? 0 : currentController.getNodeID()));
            control_msg.getBody().getReportControlRec().setComponentID((byte)(
                                         (currentController == null) ? 0 : currentController.getComponentID()));

            // Now send it to the requesting component
            JausAddress sender = new JausAddress((ushort)transportData.getSourceID().getSubsystemID(),
                                            (byte)transportData.getSourceID().getNodeID(),
                                            (byte)transportData.getSourceID().getComponentID());
            sendJausMessage(control_msg, sender);
            }
        }
        public virtual void StoreAddressAction(Receive.Body.ReceiveRec transportData)
        {
            Console.WriteLine( "Storing address of controlling component as " +
            (ushort)transportData.getSourceID().getSubsystemID(),
            (byte)transportData.getSourceID().getNodeID(),
            (byte)transportData.getSourceID().getComponentID());

            currentController = new JausAddress((ushort)transportData.getSourceID().getSubsystemID(),
                                           (byte)transportData.getSourceID().getNodeID(),
                                           (byte)transportData.getSourceID().getComponentID());
        }