Exemplo n.º 1
0
 public override void Compose(System.Collections.Generic.List <Invert.StateMachine.State> states)
 {
     base.Compose(states);
     UILogin.Login = new StateTransition("Login", UILogin, UILobby);
     Transitions.Add(UILogin.Login);
     UILogin.AddTrigger(Login, UILogin.Login);
     UILogin.StateMachine = this;
     states.Add(UILogin);
     UILobby.Logout = new StateTransition("Logout", UILobby, UILogin);
     Transitions.Add(UILobby.Logout);
     UILobby.EnterRoom = new StateTransition("EnterRoom", UILobby, UIRoom);
     Transitions.Add(UILobby.EnterRoom);
     UILobby.Disconnect = new StateTransition("Disconnect", UILobby, UILogin);
     Transitions.Add(UILobby.Disconnect);
     UILobby.AddTrigger(Logout, UILobby.Logout);
     UILobby.AddTrigger(EnterRoom, UILobby.EnterRoom);
     UILobby.AddTrigger(Disconnect, UILobby.Disconnect);
     UILobby.StateMachine = this;
     states.Add(UILobby);
     UIRoom.QuitRoom = new StateTransition("QuitRoom", UIRoom, UILobby);
     Transitions.Add(UIRoom.QuitRoom);
     UIRoom.Disconnect = new StateTransition("Disconnect", UIRoom, UILogin);
     Transitions.Add(UIRoom.Disconnect);
     UIRoom.AddTrigger(QuitRoom, UIRoom.QuitRoom);
     UIRoom.AddTrigger(Disconnect, UIRoom.Disconnect);
     UIRoom.StateMachine = this;
     states.Add(UIRoom);
 }
Exemplo n.º 2
0
        public void AddTransition(XmlNode node)
        {
            FSMTransition transition = new FSMTransition(States, node);

            Items.Add(transition);
            Transitions.Add(transition);
        }
Exemplo n.º 3
0
        public bool addTransition(U input, T fromState, T toState)
        {
            // Add from state if non existant
            if (!Transitions.ContainsKey(fromState))
            {
                Transitions.Add(fromState, new Dictionary <U, HashSet <T> >());
            }

            if (Transitions[fromState].ContainsKey(input))
            {
                // Add to state to existing input.
                return(Transitions[fromState][input].Add(toState));
            }
            else
            {
                // Add input to alphabet (except for epsilon) so the alphabet can dynamically be changed
                if (!input.Equals(Epsilon))
                {
                    Alphabet.Add(input);
                }
                // Add input with to state.
                Transitions[fromState].Add(input, new HashSet <T>()
                {
                    toState
                });
                return(true);
            }
        }
Exemplo n.º 4
0
        public State Clone()
        {
            var state = new State()
            {
                Description        = Description,
                EnumValue          = EnumValue,
                IsInitialState     = IsInitialState,
                IsAlarmState       = IsAlarmState,
                Name               = Name,
                Key                = Key,
                TransitionInAction = TransitionInAction,
            };

            foreach (var trns in Transitions)
            {
                Transitions.Add(trns.Clone());
            }

            foreach (var dgl in DiagramLocations)
            {
                DiagramLocations.Add(dgl.Clone());
            }

            return(state);
        }
Exemplo n.º 5
0
 public MainViewModel()
 {
     Transitions.Add(new Tuple <string, string, char>("First Item 1", "Second Item 1", 'A'));
     Transitions.Add(new Tuple <string, string, char>("First Item 2", "Second Item 2", 'B'));
     Transitions.Add(new Tuple <string, string, char>("First Item 3", "Second Item 3", 'C'));
     Transitions.Add(new Tuple <string, string, char>("First Item 4", "Second Item 4", 'D'));
 }
Exemplo n.º 6
0
        /// <summary>
        /// Init transitions from the Petri net
        /// </summary>
        /// <param name="pNet">Petri net</param>
        /// <param name="cost">Cost</param>
        /// <param name="moveOnModel">Model Petri net (true), Trace Petri net (false)</param>
        private void InitTransitionsFromPNet(IPetriNet pNet, int cost, bool moveOnModel)
        {
            foreach (var transition in pNet.Transitions)
            {
                var productTransition =
                    new Transition(
                        moveOnModel
                            ? $"(>>,{transition.Id})"
                            : $"({transition.Id},>>)", transition.Activity);
                if (transition.Invisible)
                {
                    productTransition.ChangeVisibility();
                }
                foreach (var iPlace in transition.InputPlaces)
                {
                    productTransition.InputPlaces.Add(iPlace);
                }
                foreach (var oPlace in transition.OutputPlaces)
                {
                    productTransition.OutputPlaces.Add(oPlace);
                }

                // cost 0 for "invisible" transitions
                var syncTransition = new STransition(productTransition, transition.Invisible ? 0 : cost);

                foreach (var place in transition.InputPlaces)
                {
                    PlacesToTransitions[place].Add(Transitions.Count);
                }
                Transitions.Add(syncTransition);
            }
        }
Exemplo n.º 7
0
    internal void CreateTransition(TransitionOutPoint from, EditorStateNode to)
    {
        var trans = new EditorTransition(from, to, this);

        Transitions.Add(trans);
        changed = true;
    }
Exemplo n.º 8
0
        public void ProcessFile(string contents)
        {
            var source    = SpectrumTransition.ParseFromString(contents, "Source");
            var optimized = Spectrum.GetOptimized(source);
            var peaks     = Spectrum.GetPeaks(source);

            AnalyzingSpectrum = new Spectrum()
            {
                Source    = source,
                Optimized = optimized,
                Peaks     = peaks,
                Type      = SpectrumType.Analyzed,
                Name      = Path.GetFileName(SelectedFile.Name)
            };

            Plotter.Plot(AnalyzingSpectrum, OnSeriesClicked, SpectrumType.Analyzed);

            Transitions.Add(new ListViewTransitionItem {
                Name = AnalyzingSpectrum.Source.Name
            });
            Transitions.Add(new ListViewTransitionItem {
                Name = AnalyzingSpectrum.Optimized.Name
            });
            Transitions.Add(new ListViewTransitionItem {
                Name = AnalyzingSpectrum.Peaks.Name
            });
        }
Exemplo n.º 9
0
        public void ReadFA()
        {
            using (var streamReader = new StreamReader(FileName))
            {
                ///All possible states
                States = streamReader.ReadLine().Trim().Split(" ").ToList();

                ///Alphabet
                Alphabet = streamReader.ReadLine().Trim().Split(" ").ToList();

                ///Transitions
                ///1. Transitions are separated by |
                ///2. Transition elements are separated by ,
                var transitionsToCompute = streamReader.ReadLine().Split("|").Select(trasition => trasition.Trim()).ToList();

                transitionsToCompute.ForEach(transition => {
                    var elementsOfTransition = transition.Split(",").ToList();

                    Transitions.Add(new Tuple <string, string>(elementsOfTransition[0], elementsOfTransition[1]), elementsOfTransition[2]);
                });

                InitialState = streamReader.ReadLine().Trim();

                FinalStates = streamReader.ReadLine().Trim().Split(" ").ToList();
            }
        }
Exemplo n.º 10
0
        public IconButton()
        {
            this.WhenActivated(disposables =>
            {
                this.ImageButton.Width  = this.Width;
                this.ImageButton.Height = this.Height;
                this.ImageButton.Source = BitmapHelper.GetImg(Icons.Stop);

                this.OneWayBind(ViewModel, p => p.Img, p => p.ImageButton.Source).DisposeWith(disposables);


                Initialized += (sender, e) =>
                {
                    Tapped       += NewTappedEventAsync;
                    PointerEnter += NewPointerEnter;
                    PointerLeave += NewPointerLeave;
                };
                Opacity = DefaultOpacity;
                Transitions.Add(new DoubleTransition()
                {
                    Property = OpacityProperty, Duration = DefaultAnimationDuration
                });
            });

            this.InitializeComponent();
        }
Exemplo n.º 11
0
        public void AddTransition(Transition transition)
        {
            this.EnsureTransitionIsValid(transition);
            this.EnsureNotContainsTransition(transition);
            this.EnsureContainsState(transition.From);
            this.EnsureContainsState(transition.To);
            if (transition.Input != Automata.SYMBOL_SPONTANEOUS_TRANSITION)
            {
                this.EnsureContainsSymbol(transition.Input);
            }
            else
            {
                this.EnsureAutomataIsOfType(AutomataType.AFNe,
                                            new InvalidValueException(
                                                transition + " (not AFNe)",
                                                typeof(Transition)
                                                )
                                            );
            }

            Transitions.Add(new Transition(
                                GetStateLike(transition.From),
                                transition.Input,
                                GetStateLike(transition.To)
                                ));
        }
Exemplo n.º 12
0
        public Transition AddTransition()
        {
            var t = new Transition(this);

            Transitions.Add(t);
            return(t);
        }
Exemplo n.º 13
0
        /// <summary>
        /// Adds a transition between this and the state with the inputted state ID.
        /// </summary>
        /// <param name="destinationStateID">The ID of the state we will transition to.</param>
        public void AddTransition(uint destinationStateID)
        {
            Debug.Assert(destinationStateID != StateID);
            Debug.Assert(!Transitions.Exists(x => x.DestinationState == destinationStateID));

            Transitions.Add(new Transition(destinationStateID));
        }
Exemplo n.º 14
0
        private IState HandleTransition(Type type)
        {
            if (type == null)
            {
                return(null);
            }

            var match = States.FirstOrDefault(s => s.GetType() == type);

            if (match != null)
            {
                return(match);
            }

            var state = (IState)Activator.CreateInstance(type);

            States.Add(state);

            foreach (var transition in type.GetCustomAttributes <TransitionAttribute>())
            {
                var t = new Transition(transition.Trigger, state, HandleTransition(transition.ToState), transition.Mode);
                Transitions.Add(t);
            }

            return(state);
        }
Exemplo n.º 15
0
        internal void setTransition(State begin, State end, double p)
        {
            if (!States.Contains(begin) || !States.Contains(end))
            {
                throw new InvalidTransitionException();
            }

            if (p < 0 || p > 1)
            {
                throw new OutOfRangeProbabilityException();
            }


            var transition = new Transition(begin, end, p);

            if (Transitions.ContainsKey(begin))
            {
                Transitions[begin].Add(transition);
            }
            else
            {
                Transitions.Add(begin, new List <Transition>()
                {
                    transition
                });
            }
        }
Exemplo n.º 16
0
        public Transition CreateTransition(string id, int mean, int deviation, int priority = 0)
        {
            var transition = new Transition(id, mean, deviation, priority);

            Transitions.Add(transition.Id, transition);

            return(transition);
        }
Exemplo n.º 17
0
        protected void Map(string transition, Func <Task> function)
        {
            var value = new TransitionValue {
                Handler = WrapHandler(function), Fields = null
            };

            Transitions.Add(transition, value);
        }
Exemplo n.º 18
0
        /// <summary>
        ///     Adds the transition.
        /// </summary>
        /// <typeparam name="T"> </typeparam>
        /// <param name="transition"> The transition. </param>
        /// <returns> </returns>
        public IStateTransition AddTransition <T> (T transition) where T : class, IStateTransition
        {
            Transitions.Add(transition);

            Container.BuildUp(transition);

            return(transition);
        }
Exemplo n.º 19
0
 public void AddTransitions(int lineId, int[] t)
 {
     if (Transitions.ContainsKey(lineId))
     {
         Transitions.Remove(lineId);
     }
     Transitions.Add(lineId, t);
 }
Exemplo n.º 20
0
            public void SetTransitionLabel(Graph <TNode, TTransition> .Transition transition, int x, int y, int width, int height)
            {
                UpdateBounds(x, y, width, height);

                Transitions.Add(new NodeLayout <Graph <TNode, TTransition> .Transition>(
                                    transition,
                                    new Point(x, y),
                                    new Size(width, height)));
            }
Exemplo n.º 21
0
        protected void Map <T1>(string transition, Func <T1, Task> function, Field field)
        {
            var value =
                new TransitionValue {
                Handler = WrapHandler(function), Fields = new Field[] { field }
            };

            Transitions.Add(transition, value);
        }
Exemplo n.º 22
0
    public override void Init(StateMachine stateMachine)
    {
        base.Init(stateMachine);
        var transition     = new SmTransition(GetPriority(), Transition);
        var doneTransition = new SmTransition(GetPriority(), DoneTransition);

        stateMachine.GetComponent <SmsIdle>().Transitions.Add(transition);
        Transitions.Add(doneTransition);
    }
Exemplo n.º 23
0
        protected void Map <T1, T2, T3, T4, T5, T6>(string transition, Func <T1, T2, T3, T4, T5, T6, Task> function, IEnumerable <Field> fields)
        {
            var value =
                new TransitionValue {
                Handler = WrapHandler(function), Fields = fields
            };

            Transitions.Add(transition, value);
        }
Exemplo n.º 24
0
        public void AddTransition(Transition <T> transition)
        {
            if (transition.To != null && !States.Contains(transition.To) || (transition.From != null && !States.Contains(transition.From)))
            {
                throw new ArgumentException($"Parameter {nameof(transition)} is invalid: {nameof(States)} does not contain the required States.", nameof(transition));
            }

            Transitions.Add(transition);
        }
Exemplo n.º 25
0
 /// <summary>
 /// Add all transitions to the graph
 /// </summary>
 /// <param name="machineInfo"></param>
 void AddTransitions(StateMachineInfo machineInfo)
 {
     foreach (var stateInfo in machineInfo.States)
     {
         State fromState = States[stateInfo.UnderlyingState.ToString()];
         foreach (var fix in stateInfo.FixedTransitions)
         {
             State toState = States[fix.DestinationState.UnderlyingState.ToString()];
             if (fromState == toState)
             {
                 StayTransition stay = new StayTransition(fromState, fix.Trigger, fix.GuardConditionsMethodDescriptions, true);
                 Transitions.Add(stay);
                 fromState.Leaving.Add(stay);
                 fromState.Arriving.Add(stay);
             }
             else
             {
                 FixedTransition trans = new FixedTransition(fromState, toState, fix.Trigger, fix.GuardConditionsMethodDescriptions);
                 Transitions.Add(trans);
                 fromState.Leaving.Add(trans);
                 toState.Arriving.Add(trans);
             }
         }
         foreach (var dyno in stateInfo.DynamicTransitions)
         {
             Decision decide = new Decision(dyno.DestinationStateSelectorDescription, Decisions.Count + 1);
             Decisions.Add(decide);
             FixedTransition trans = new FixedTransition(fromState, decide, dyno.Trigger,
                                                         dyno.GuardConditionsMethodDescriptions);
             Transitions.Add(trans);
             fromState.Leaving.Add(trans);
             decide.Arriving.Add(trans);
             if (dyno.PossibleDestinationStates != null)
             {
                 foreach (var dynamicStateInfo in dyno.PossibleDestinationStates)
                 {
                     State toState = null;
                     States.TryGetValue(dynamicStateInfo.DestinationState, out toState);
                     if (toState != null)
                     {
                         DynamicTransition dtrans = new DynamicTransition(decide, toState, dyno.Trigger, dynamicStateInfo.Criterion);
                         Transitions.Add(dtrans);
                         decide.Leaving.Add(dtrans);
                         toState.Arriving.Add(dtrans);
                     }
                 }
             }
         }
         foreach (var igno in stateInfo.IgnoredTriggers)
         {
             StayTransition stay = new StayTransition(fromState, igno.Trigger, igno.GuardConditionsMethodDescriptions, false);
             Transitions.Add(stay);
             fromState.Leaving.Add(stay);
             fromState.Arriving.Add(stay);
         }
     }
 }
Exemplo n.º 26
0
 protected internal void AddAll(NFA nfa)
 {
     foreach (State state in nfa.States)
     {
         States.Add(state);
     }
     foreach (Transition <State> edge in nfa.Transitions)
     {
         Transitions.Add(edge);
     }
 }
Exemplo n.º 27
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="stateMachine"></param>
 public TransitionFinder(StateMachine stateMachine)
 {
     Utils.FinderRepository.INSTANCE.ClearCache();
     Transitions.Clear();
     StateMachine = stateMachine;
     Constants.State initialState = StateMachine.DefaultValue as Constants.State;
     if (initialState != null)
     {
         Transitions.Add(new Rules.Transition(null, null, null, initialState));
     }
 }
Exemplo n.º 28
0
 public StateInfo TransitionTo(object state, object trigger)
 {
     if (Transitions.FirstOrDefault(x => x.State == (int)state && x.Trigger == (int)trigger) == null)
     {
         Transitions.Add(new Transition()
         {
             State   = (int)state,
             Trigger = (int)trigger
         });
     }
     return(this);
 }
        public void CreateNewTransition()
        {
            var newTransition = new Transition()
            {
                Name  = "Transition" + transitionNumber,
                IsNew = true
            };

            Transitions.Add(newTransition);
            transitionNumber++;
            SelectedObject = newTransition;
        }
Exemplo n.º 30
0
        public ICondition <TActor> On <TMessage>(Func <TActor, Action <IEnvelope> > transition)
        {
            var onMessage = new ConditionalTransition <TActor, TMessage>
            {
                Transition      = transition,
                Guard           = Guard,
                GuardExpression = GuardExpression
            };

            Transitions.Add(typeof(TMessage), onMessage);
            return(this);
        }