Esempio n. 1
0
 public void ReceiveTransition(GrantNodeID msg, Receive.Body.ReceiveRec transportData)
 {
     transition_ = "ReceiveTransition";
     State.ReceiveTransition(this, msg, transportData);
     transition_ = "";
     return;
 }
Esempio n. 2
0
        public virtual void updateNodeIDAction(GrantNodeID msg, Receive.Body.ReceiveRec transportData)
        {
            // Convert incoming MAC to string
            StringBuilder sb = new StringBuilder();

            for (int i = 0; i < 7; i++)
            {
                sb.Append(((byte)msg.getBody().getGrantNodeIDRec().getRequesterID().getRequesterIDArrayField(i)).ToString("x2"));
                if (i < 6)
                {
                    sb.Append(":");
                }
            }
            Console.WriteLine("Got GrantNodeID message for " + sb);

            // Check the MAC address to see if this is for us.
            if (String.Compare(sb.ToString(), mac_string) == 0)
            {
                Console.WriteLine("Updating NodeID to " + msg.getBody().getGrantNodeIDRec().getNodeID() + " for MAC: " + sb);

                JausAddress id = new JausAddress((ushort)jausRouter.getJausAddress().getSubsystemID(),
                                                 (byte)msg.getBody().getGrantNodeIDRec().getNodeID(),
                                                 (byte)jausRouter.getJausAddress().getComponentID());
                jausRouter.updateJausID(id);
            }
            else
            {
                Console.WriteLine("Ignoring grant message since " + sb + " != " + mac_string);
            }
        }
Esempio n. 3
0
        public GrantNodeID setAs(GrantNodeID value)
        {
            m_JAUSApplicationLayerHeader = value.m_JAUSApplicationLayerHeader;
            m_Body = value.m_Body;

            return(this);
        }
Esempio n. 4
0
        public GrantNodeID(GrantNodeID value)
        {
            /// Initiliaze the protected variables
            m_JAUSApplicationLayerHeader = new JAUSApplicationLayerHeader();
            m_Body      = new Body();
            m_IsCommand = false;

            /// Copy the values
            m_JAUSApplicationLayerHeader = value.m_JAUSApplicationLayerHeader;
            m_Body = value.m_Body;
        }
Esempio n. 5
0
        public bool  isEqual(GrantNodeID value)
        {
            if (!this.getJAUSApplicationLayerHeader().isEqual(value.getJAUSApplicationLayerHeader()))
            {
                return(false);
            }
            if (!this.getBody().isEqual(value.getBody()))
            {
                return(false);
            }

            return(true);
        }
Esempio n. 6
0
                protected internal override void ReceiveTransition(DiscoveryClient_ReceiveFSMContext context, GrantNodeID msg, Receive.Body.ReceiveRec transportData)
                {
                    DiscoveryClient_ReceiveFSM ctxt = context.Owner;


#if TRACE
                    Trace.WriteLine(
                        "LEAVING STATE   : DiscoveryClient_ReceiveFSM_SM.Receiving_Ready");
#endif

                    DiscoveryClient_ReceiveFSMState endState = context.State;

#if TRACE
                    Trace.WriteLine(
                        "ENTER TRANSITION: DiscoveryClient_ReceiveFSM_SM.DiscoveryClient_ReceiveFSM_SM.Receiving_Ready.ReceiveTransition(, GrantNodeID msg, Receive.Body.ReceiveRec transportData)");
#endif

                    context.ClearState();

                    try
                    {
                        ctxt.updateNodeIDAction(msg, transportData);
                    }
                    finally
                    {
#if TRACE
                        Trace.WriteLine(
                            "EXIT TRANSITION : DiscoveryClient_ReceiveFSM_SM.DiscoveryClient_ReceiveFSM_SM.Receiving_Ready.ReceiveTransition(, GrantNodeID msg, Receive.Body.ReceiveRec transportData)");
#endif

                        context.State = endState;
                    }

                    return;
                }
Esempio n. 7
0
 protected internal virtual void ReceiveTransition(DiscoveryClient_ReceiveFSMContext context, GrantNodeID msg, Receive.Body.ReceiveRec transportData)
 {
     Default(context);
 }
Esempio n. 8
0
 public bool  notEquals(GrantNodeID value)
 {
     return(!this.isEqual(value));
 }
Esempio n. 9
0
        //	This is the function that will process an event either generated
        //  by the service, sent to it by another service on the same component,
        //  or as a message sent by a different component.
        public override bool processTransitions(InternalEvent ie)
        {
            bool done = false;

            // Since this function can be called from multiple threads,
            // we use a mutex to ensure only one state transition is
            // active at a time.
            mutex.WaitOne();

            // Invoke the FSM transition for this event.
            try
            {
                if ((!done) && ie.getName().CompareTo("Receive") == 0 && (ie.getSource().CompareTo("DiscoveryClient_ReceiveFSM") != 0))
                {
                    Receive casted_ie = (Receive)ie;
                    int     pos       = 0;
                    ushort  id        = BitConverter.ToUInt16(casted_ie.getBody().getReceiveRec().getMessagePayload().getData(), pos);
                    if (id == new ReportHeartbeatPulse().getID())
                    {
                        ReportHeartbeatPulse msg = new ReportHeartbeatPulse();
                        msg.decode(casted_ie.getBody().getReceiveRec().getMessagePayload().getData(), pos);
                        Receive.Body.ReceiveRec transportData = casted_ie.getBody().getReceiveRec();
                        pDiscoveryClient_ReceiveFSM.context.ReceiveTransition(msg, transportData);
                        done = true;
                    }
                }
            } catch (Exception e) {}

            try
            {
                if ((!done) && ie.getName().CompareTo("Receive") == 0 && (ie.getSource().CompareTo("DiscoveryClient_ReceiveFSM") != 0))
                {
                    Receive casted_ie = (Receive)ie;
                    int     pos       = 0;
                    ushort  id        = BitConverter.ToUInt16(casted_ie.getBody().getReceiveRec().getMessagePayload().getData(), pos);
                    if (id == new ReportServices().getID())
                    {
                        ReportServices msg = new ReportServices();
                        msg.decode(casted_ie.getBody().getReceiveRec().getMessagePayload().getData(), pos);
                        Receive.Body.ReceiveRec transportData = casted_ie.getBody().getReceiveRec();
                        pDiscoveryClient_ReceiveFSM.context.ReceiveTransition(msg, transportData);
                        done = true;
                    }
                }
            } catch (Exception e) {}

            try
            {
                if ((!done) && ie.getName().CompareTo("Receive") == 0 && (ie.getSource().CompareTo("DiscoveryClient_ReceiveFSM") != 0))
                {
                    Receive casted_ie = (Receive)ie;
                    int     pos       = 0;
                    ushort  id        = BitConverter.ToUInt16(casted_ie.getBody().getReceiveRec().getMessagePayload().getData(), pos);
                    if (id == new ReportIdentification().getID())
                    {
                        ReportIdentification msg = new ReportIdentification();
                        msg.decode(casted_ie.getBody().getReceiveRec().getMessagePayload().getData(), pos);
                        Receive.Body.ReceiveRec transportData = casted_ie.getBody().getReceiveRec();
                        pDiscoveryClient_ReceiveFSM.context.ReceiveTransition(msg, transportData);
                        done = true;
                    }
                }
            } catch (Exception e) {}

            try
            {
                if ((!done) && ie.getName().CompareTo("Receive") == 0 && (ie.getSource().CompareTo("DiscoveryClient_ReceiveFSM") != 0))
                {
                    Receive casted_ie = (Receive)ie;
                    int     pos       = 0;
                    ushort  id        = BitConverter.ToUInt16(casted_ie.getBody().getReceiveRec().getMessagePayload().getData(), pos);
                    if (id == new GrantNodeID().getID())
                    {
                        GrantNodeID msg = new GrantNodeID();
                        msg.decode(casted_ie.getBody().getReceiveRec().getMessagePayload().getData(), pos);
                        Receive.Body.ReceiveRec transportData = casted_ie.getBody().getReceiveRec();
                        pDiscoveryClient_ReceiveFSM.context.ReceiveTransition(msg, transportData);
                        done = true;
                    }
                }
            } catch (Exception e) {}

            try
            {
                if ((!done) && ie.getName().CompareTo("RHP_Timeout") == 0 && (ie.getSource().CompareTo("DiscoveryClient_ReceiveFSM") != 0))
                {
                    RHP_Timeout casted_ie = (RHP_Timeout)ie;
                    pDiscoveryClient_ReceiveFSM.context.RHP_TimeoutTransition();
                    done = true;
                }
            } catch (Exception e) {}



            mutex.ReleaseMutex();
            return(done);
        }