Example #1
0
 /// <summary>
 ///   Optionally modifies the <paramref name="transitions" />, changing any of their values. However, no new transitions can be
 ///   added; transitions can be removed by setting their <see cref="CandidateTransition.IsValid" /> flag to <c>false</c>.
 ///   During subsequent traversal steps, only valid transitions and target states reached by at least one valid transition
 ///   are considered.
 /// </summary>
 /// <param name="context">The context of the model traversal.</param>
 /// <param name="worker">The worker that found the transition.</param>
 /// <param name="transitions">The transitions that should be checked.</param>
 /// <param name="sourceState">The source state of the transitions.</param>
 /// <param name="sourceStateIndex">The unique index of the transition's source state.</param>
 /// <param name="isInitial">Indicates whether the transitions are initial transitions not starting in any valid source state.</param>
 public void ModifyTransitions(TraversalContext <TExecutableModel> context, Worker <TExecutableModel> worker, TransitionCollection transitions, byte *sourceState,
                               int sourceStateIndex, bool isInitial)
 {
     foreach (CandidateTransition *transition in transitions)
     {
         transition->Flags = TransitionFlags.SetIsValidIffCondition(transition->Flags, transition->ActivatedFaults.GetIntersection(_suppressedFaults).IsEmpty);
     }
 }
Example #2
0
        /// <summary>
        ///   Optionally modifies the <paramref name="transitions" />, changing any of their values. However, no new transitions can be
        ///   added; transitions can be removed by setting their <see cref="CandidateTransition.IsValid" /> flag to <c>false</c>.
        ///   During subsequent traversal steps, only valid transitions and target states reached by at least one valid transition
        ///   are considered.
        /// </summary>
        /// <param name="context">The context of the model traversal.</param>
        /// <param name="worker">The worker that found the transition.</param>
        /// <param name="transitions">The transitions that should be checked.</param>
        /// <param name="sourceState">The source state of the transitions.</param>
        /// <param name="sourceStateIndex">The unique index of the transition's source state.</param>
        /// <param name="isInitial">Indicates whether the transitions are initial transitions not starting in any valid source state.</param>
        public void ModifyTransitions(TraversalContext <TExecutableModel> context, Worker <TExecutableModel> worker, TransitionCollection transitions, byte *sourceState,
                                      int sourceStateIndex, bool isInitial)
        {
            // The fault order state is encoded into the first four bytes of the state vector (must be four bytes as required by
            // RuntimeModel's state header field)
            var state = isInitial ? State.NeitherFaultActivated : *(State *)sourceState;

            foreach (CandidateTransition *transition in transitions)
            {
                var activatedFaults = transition->ActivatedFaults;
                var isValid         = true;
                var nextState       = state;

                switch (state)
                {
                case State.NeitherFaultActivated:
                    if (activatedFaults.Contains(_firstFault) && activatedFaults.Contains(_secondFault))
                    {
                        if (_forceSimultaneous)
                        {
                            nextState = State.BothFaultsActivated;
                        }
                        else
                        {
                            isValid = false;
                        }
                    }
                    else if (activatedFaults.Contains(_firstFault))
                    {
                        if (_forceSimultaneous)
                        {
                            isValid = false;
                        }
                        else
                        {
                            nextState = State.FirstFaultActivated;
                        }
                    }
                    else if (activatedFaults.Contains(_secondFault))
                    {
                        isValid = false;
                    }
                    break;

                case State.FirstFaultActivated:
                    if (activatedFaults.Contains(_secondFault))
                    {
                        nextState = State.BothFaultsActivated;
                    }
                    break;

                case State.BothFaultsActivated:
                    break;

                default:
                    Assert.NotReached("Unexpected state value.");
                    break;
                }

                transition->Flags = TransitionFlags.SetIsValidIffCondition(transition->Flags, isValid);
                *(State *)transition->TargetStatePointer = nextState;
            }
        }