예제 #1
0
 public void MenuItemEnteredTransition(MenuItemEntered msg)
 {
     transition_ = "MenuItemEnteredTransition";
     State.MenuItemEnteredTransition(this, msg);
     transition_ = "";
     return;
 }
예제 #2
0
        public bool  isEqual(MenuItemEntered value)
        {
            if (!this.getMenuItemEnteredBody().isEqual(value.getMenuItemEnteredBody()))
            {
                return(false);
            }

            return(true);
        }
예제 #3
0
        public MenuItemEntered(MenuItemEntered value)
        {
            /// Initiliaze the protected variables
            m_MenuItemEnteredBody = new MenuItemEnteredBody();
            m_Name = "MenuItemEntered";

            /// Copy the values
            m_MenuItemEnteredBody = value.m_MenuItemEnteredBody;
        }
예제 #4
0
        public MenuItemEntered(MenuItemEntered value)
        {
            /// Initiliaze the protected variables
            m_MenuItemEnteredBody = new MenuItemEnteredBody();
            m_Name = "MenuItemEntered";

            /// Copy the values
            m_MenuItemEnteredBody = value.m_MenuItemEnteredBody;
        }
        public virtual void sendManagementMessageAction(MenuItemEntered msg)
        {
            Resume resume_msg = new Resume();
            Standby standby_msg = new Standby();
            SetEmergency set_emergency_msg = new SetEmergency();
            ClearEmergency clear_emergency_msg = new ClearEmergency();
            QueryStatus query_status_msg = new QueryStatus();
            ReleaseControl release_control_msg = new ReleaseControl();
            Shutdown shutdown_msg = new Shutdown();

            JausAddress dest = new JausAddress(jausRouter.getJausAddress().getSubsystemID(),
                      jausRouter.getJausAddress().getNodeID(),
                      (byte)160);

            switch (msg.getMenuItemEnteredBody().getMenuItemEnteredRecord().getSelection())
            {
            case 1:
            Console.WriteLine("Sending Resume");
            sendJausMessage(resume_msg, dest);
            break;
            case 2:
            Console.WriteLine("Sending Standby");
            sendJausMessage(standby_msg, dest);
            break;
            case 3:
            Console.WriteLine("Sending SetEmergency");
            sendJausMessage(set_emergency_msg, dest);
            break;
            case 4:
            Console.WriteLine("Sending ClearEmergency");
            sendJausMessage(clear_emergency_msg, dest);
            break;
            case 5:
            Console.WriteLine("Sending QueryStatus");
            sendJausMessage(query_status_msg, dest);
            break;
            case 6:
            Console.WriteLine("Sending Shutdown");
            sendJausMessage(shutdown_msg, dest);
            break;
            case 7:
            Console.WriteLine("Sending ReleaseControl");
            sendJausMessage(release_control_msg, dest);
            break;
            case 8:
            Console.WriteLine("Sending Terminate");
            terminateServiceAction();
            break;
            default:
            Console.WriteLine("Unknown input: " + msg.getMenuItemEnteredBody().getMenuItemEnteredRecord().getSelection());
            break;
            }
        }
            private void displayMenuAndGrabInput()
            {
                short  selection = 255;
                bool   run       = true;
                string s         = "";

                do
                {
                    selection = 255;
                    Console.WriteLine("Menu");
                    Console.WriteLine("____________________________________");
                    Console.WriteLine(" 1) Send Resume");
                    Console.WriteLine(" 2) Send Standby");
                    Console.WriteLine(" 3) Send Set Emergency");
                    Console.WriteLine(" 4) Send Clear Emergency");
                    Console.WriteLine(" 5) Send Query Status");
                    Console.WriteLine(" 6) Send Shutdown");
                    Console.WriteLine(" 7) Send Release Control");
                    Console.WriteLine(" 8) Quit and exit");
                    Console.WriteLine("____________________________________");
                    Console.WriteLine("[Input]: ");

                    try
                    {
                        s         = Console.ReadLine();
                        selection = Convert.ToInt16(s);
                    }
                    catch (Exception e)
                    {
                        s         = null;
                        selection = 255;
                    }

                    if (selection != 255)
                    {
                        MenuItemEntered item = new MenuItemEntered();
                        item.getMenuItemEnteredBody().getMenuItemEnteredRecord().setSelection((int)selection);

                        ieHandler.invoke(item);
                    }
                    if (selection == 8)
                    {
                        run = false;
                    }
                }while (run);
            }
예제 #7
0
 protected internal virtual void MenuItemEnteredTransition(ManagementOCU_ManagementOcuFSMContext context, MenuItemEntered msg)
 {
     Default(context);
 }
            private void displayMenuAndGrabInput()
            {
                short selection = 255;
                bool run = true;
                string s = "";
                do
                {
                    selection = 255;
                    Console.WriteLine("Menu");
                    Console.WriteLine("____________________________________");
                    Console.WriteLine(" 1) Send Resume");
                    Console.WriteLine(" 2) Send Standby");
                    Console.WriteLine(" 3) Send Set Emergency");
                    Console.WriteLine(" 4) Send Clear Emergency");
                    Console.WriteLine(" 5) Send Query Status");
                    Console.WriteLine(" 6) Send Shutdown");
                    Console.WriteLine(" 7) Send Release Control");
                    Console.WriteLine(" 8) Quit and exit");
                    Console.WriteLine("____________________________________");
                    Console.WriteLine("[Input]: ");

                    try
                    {
                        s = Console.ReadLine();
                        selection = Convert.ToInt16(s);
                    }
                    catch (Exception e)
                    {
                        s = null;
                        selection = 255;
                    }

                    if (selection != 255)
                    {
                        MenuItemEntered item = new MenuItemEntered();
                        item.getMenuItemEnteredBody().getMenuItemEnteredRecord().setSelection((int)selection);

                        ieHandler.invoke(item);
                    }
                    if (selection == 8) run = false;
                }
                while (run);
            }
 public virtual bool isSelectionToEnd(MenuItemEntered msg)
 {
     return (msg.getMenuItemEnteredBody().getMenuItemEnteredRecord().getSelection() == '8');
 }
예제 #10
0
        public bool isEqual(MenuItemEntered value)
        {
            if (!this.getMenuItemEnteredBody().isEqual(value.getMenuItemEnteredBody()))
            {
            return false;
            }

            return true;
        }
예제 #11
0
 public bool notEquals(MenuItemEntered value)
 {
     return !this.isEqual(value);
 }
예제 #12
0
        public MenuItemEntered setAs(MenuItemEntered value)
        {
            m_MenuItemEnteredBody = value.m_MenuItemEnteredBody;

            return this;
        }
예제 #13
0
        public MenuItemEntered setAs(MenuItemEntered value)
        {
            m_MenuItemEnteredBody = value.m_MenuItemEnteredBody;

            return(this);
        }
예제 #14
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 (ie.getName().CompareTo("Receive") == 0 && (ie.getSource().CompareTo("ManagementOCU_ManagementOcuFSM") != 0) && (!done))
                {
                    Receive casted_ie = (Receive)ie;
                    int     pos       = 0;
                    ushort  id        = BitConverter.ToUInt16(casted_ie.getBody().getReceiveRec().getMessagePayload().getData(), pos);
                    if (id == new ConfirmControl().getID())
                    {
                        ConfirmControl msg = new ConfirmControl();
                        msg.decode(casted_ie.getBody().getReceiveRec().getMessagePayload().getData(), pos);
                        pManagementOCU_ManagementOcuFSM.context.ConfirmControlTransition(msg);
                        done = true;
                    }
                }
            } catch (Exception e) {}

            try
            {
                if (ie.getName().CompareTo("MenuItemEntered") == 0 && (ie.getSource().CompareTo("ManagementOCU_ManagementOcuFSM") != 0) && (!done))
                {
                    MenuItemEntered casted_ie = (MenuItemEntered)ie;
                    MenuItemEntered msg       = casted_ie;
                    pManagementOCU_ManagementOcuFSM.context.MenuItemEnteredTransition(msg);
                    done = true;
                }
            } catch (Exception e) {}

            try
            {
                if (ie.getName().CompareTo("MenuItemEntered") == 0 && (ie.getSource().CompareTo("ManagementOCU_ManagementOcuFSM") != 0) && (!done))
                {
                    MenuItemEntered casted_ie = (MenuItemEntered)ie;
                    MenuItemEntered msg       = casted_ie;
                    pManagementOCU_ManagementOcuFSM.context.MenuItemEnteredTransition(msg);
                    done = true;
                }
            } catch (Exception e) {}

            try
            {
                if (ie.getName().CompareTo("Receive") == 0 && (ie.getSource().CompareTo("ManagementOCU_ManagementOcuFSM") != 0) && (!done))
                {
                    Receive casted_ie = (Receive)ie;
                    int     pos       = 0;
                    ushort  id        = BitConverter.ToUInt16(casted_ie.getBody().getReceiveRec().getMessagePayload().getData(), pos);
                    if (id == new ConfirmControl().getID())
                    {
                        ConfirmControl msg = new ConfirmControl();
                        msg.decode(casted_ie.getBody().getReceiveRec().getMessagePayload().getData(), pos);
                        pManagementOCU_ManagementOcuFSM.context.ConfirmControlTransition(msg);
                        done = true;
                    }
                }
            } catch (Exception e) {}

            try
            {
                if (ie.getName().CompareTo("InternalStateChange_To_ManagementOCU_ManagementOcuFSM_HandleMenu") == 0 && (ie.getSource().CompareTo("ManagementOCU_ManagementOcuFSM") != 0) && (!done))
                {
                    pManagementOCU_ManagementOcuFSM.context.InternalStateChange_To_ManagementOCU_ManagementOcuFSM_HandleMenuTransition(ie);
                    done = true;
                }
            } catch (Exception e) {}

            try
            {
                if (ie.getName().CompareTo("MenuItemEntered") == 0 && (ie.getSource().CompareTo("ManagementOCU_ManagementOcuFSM") != 0) && (!done))
                {
                    MenuItemEntered casted_ie = (MenuItemEntered)ie;
                    MenuItemEntered msg       = casted_ie;
                    pManagementOCU_ManagementOcuFSM.context.MenuItemEnteredTransition(msg);
                    done = true;
                }
            } catch (Exception e) {}

            try
            {
                if (ie.getName().CompareTo("MenuItemEntered") == 0 && (ie.getSource().CompareTo("ManagementOCU_ManagementOcuFSM") != 0) && (!done))
                {
                    MenuItemEntered casted_ie = (MenuItemEntered)ie;
                    MenuItemEntered msg       = casted_ie;
                    pManagementOCU_ManagementOcuFSM.context.MenuItemEnteredTransition(msg);
                    done = true;
                }
            } catch (Exception e) {}

            try
            {
                if (ie.getName().CompareTo("Receive") == 0 && (ie.getSource().CompareTo("ManagementOCU_ManagementOcuFSM") != 0) && (!done))
                {
                    Receive casted_ie = (Receive)ie;
                    int     pos       = 0;
                    ushort  id        = BitConverter.ToUInt16(casted_ie.getBody().getReceiveRec().getMessagePayload().getData(), pos);
                    if (id == new RejectControl().getID())
                    {
                        RejectControl msg = new RejectControl();
                        msg.decode(casted_ie.getBody().getReceiveRec().getMessagePayload().getData(), pos);
                        pManagementOCU_ManagementOcuFSM.context.RejectControlTransition(msg);
                        done = true;
                    }
                }
            } catch (Exception e) {}

            try
            {
                if (ie.getName().CompareTo("Receive") == 0 && (ie.getSource().CompareTo("ManagementOCU_ManagementOcuFSM") != 0) && (!done))
                {
                    Receive casted_ie = (Receive)ie;
                    int     pos       = 0;
                    ushort  id        = BitConverter.ToUInt16(casted_ie.getBody().getReceiveRec().getMessagePayload().getData(), pos);
                    if (id == new ReportStatus().getID())
                    {
                        ReportStatus msg = new ReportStatus();
                        msg.decode(casted_ie.getBody().getReceiveRec().getMessagePayload().getData(), pos);
                        pManagementOCU_ManagementOcuFSM.context.ReportStatusTransition(msg);
                        done = true;
                    }
                }
            } catch (Exception e) {}

            try
            {
                if (ie.getName().CompareTo("InternalStateChange_To_ManagementOCU_ManagementOcuFSM_WaitForControl") == 0 && (ie.getSource().CompareTo("ManagementOCU_ManagementOcuFSM") != 0) && (!done))
                {
                    pManagementOCU_ManagementOcuFSM.context.InternalStateChange_To_ManagementOCU_ManagementOcuFSM_WaitForControlTransition(ie);
                    done = true;
                }
            } catch (Exception e) {}



            mutex.ReleaseMutex();
            return(done);
        }
예제 #15
0
                protected internal override void MenuItemEnteredTransition(ManagementOCU_ManagementOcuFSMContext context, MenuItemEntered msg)
                {
                    ManagementOCU_ManagementOcuFSM ctxt = context.Owner;


#if TRACE
                    Trace.WriteLine(
                        "TRANSITION   : ManagementOCU_ManagementOcuFSM_SM.HandleMenu.MenuItemEnteredTransition(, MenuItemEntered msg)");
#endif

                    if (!ctxt.isSelectionToEnd(msg))
                    {
                        context.State.Exit(context);
                        context.ClearState();

                        try
                        {
                            ctxt.sendManagementMessageAction(msg);
                            ctxt.displayMenuAction();
                            ctxt.processNotifications("HandleMenu", null);
                        }
                        finally
                        {
                            context.State = ManagementOCU_ManagementOcuFSM_SM.HandleMenu;
                            context.State.Entry(context);
                        }
                    }
                    else if (ctxt.isSelectionToEnd(msg))
                    {
                        context.State.Exit(context);
                        context.ClearState();

                        try
                        {
                            ctxt.terminateServiceAction();
                            ctxt.displayMenuAction();
                            ctxt.processNotifications("HandleMenu", null);
                        }
                        finally
                        {
                            context.State = ManagementOCU_ManagementOcuFSM_SM.HandleMenu;
                            context.State.Entry(context);
                        }
                    }
                    else
                    {
                        base.MenuItemEnteredTransition(context, msg);
                    }

                    return;
                }
 public virtual bool isSelectionToEnd(MenuItemEntered msg)
 {
     return(msg.getMenuItemEnteredBody().getMenuItemEnteredRecord().getSelection() == '8');
 }
        public virtual void sendManagementMessageAction(MenuItemEntered msg)
        {
            Resume         resume_msg          = new Resume();
            Standby        standby_msg         = new Standby();
            SetEmergency   set_emergency_msg   = new SetEmergency();
            ClearEmergency clear_emergency_msg = new ClearEmergency();
            QueryStatus    query_status_msg    = new QueryStatus();
            ReleaseControl release_control_msg = new ReleaseControl();
            Shutdown       shutdown_msg        = new Shutdown();

            JausAddress dest = new JausAddress(jausRouter.getJausAddress().getSubsystemID(),
                                               jausRouter.getJausAddress().getNodeID(),
                                               (byte)160);

            switch (msg.getMenuItemEnteredBody().getMenuItemEnteredRecord().getSelection())
            {
            case 1:
                Console.WriteLine("Sending Resume");
                sendJausMessage(resume_msg, dest);
                break;

            case 2:
                Console.WriteLine("Sending Standby");
                sendJausMessage(standby_msg, dest);
                break;

            case 3:
                Console.WriteLine("Sending SetEmergency");
                sendJausMessage(set_emergency_msg, dest);
                break;

            case 4:
                Console.WriteLine("Sending ClearEmergency");
                sendJausMessage(clear_emergency_msg, dest);
                break;

            case 5:
                Console.WriteLine("Sending QueryStatus");
                sendJausMessage(query_status_msg, dest);
                break;

            case 6:
                Console.WriteLine("Sending Shutdown");
                sendJausMessage(shutdown_msg, dest);
                break;

            case 7:
                Console.WriteLine("Sending ReleaseControl");
                sendJausMessage(release_control_msg, dest);
                break;

            case 8:
                Console.WriteLine("Sending Terminate");
                terminateServiceAction();
                break;

            default:
                Console.WriteLine("Unknown input: " + msg.getMenuItemEnteredBody().getMenuItemEnteredRecord().getSelection());
                break;
            }
        }
예제 #18
0
 public bool  notEquals(MenuItemEntered value)
 {
     return(!this.isEqual(value));
 }