Exemplo n.º 1
0
        /// <summary>
        ///   Resets the model to its initial state.
        /// </summary>
        public void Reset()
        {
            if (_choiceResolver == null)
            {
                _choiceResolver = new NondeterministicChoiceResolver(true);
                RuntimeModel.SetChoiceResolver(_choiceResolver);
            }

            var state = stackalloc byte[RuntimeModel.StateVectorSize];

            _states.Clear();
            _stateIndex = -1;

            if (_counterExample == null)
            {
                RuntimeModel.Reset();
            }
            else
            {
                try
                {
                    _counterExample.Replay(_choiceResolver, 0);
                }
                catch (ModelException me)
                {
                    me.RethrowInnerException();
                }
            }

            RuntimeModel.Serialize(state);
            AddState(state);
        }
Exemplo n.º 2
0
 public override void SetChoiceResolver(ChoiceResolver choiceResolver)
 {
     Model.Choice.Resolver = choiceResolver;
     foreach (var faultsValue in Model.Faults.Values)
     {
         faultsValue.Choice.Resolver = choiceResolver;
     }
 }
Exemplo n.º 3
0
        /// <summary>
        ///   Resets the model to its initial state.
        /// </summary>
        /// <param name="traversalModifierStateVectorSize">Extra bytes in state vector for traversal parameters.</param>
        public sealed override void Reset(int traversalModifierStateVectorSize)
        {
            ChoiceResolver.Clear();
            RuntimeModel.Reset();
            TemporaryStateStorage.Reset(traversalModifierStateVectorSize);

            SavedActivations = RuntimeModel.NondeterministicFaults.Select(fault => fault.Activation).ToArray();
        }
		/// <summary>
		///   Initializes a new instance.
		/// </summary>
		/// <param name="runtimeModelCreator">A factory function that creates the model instance that should be executed.</param>
		/// <param name="formulas">The formulas that should be evaluated for each state.</param>
		/// <param name="successorStateCapacity">The maximum number of successor states supported per state.</param>
		internal ActivationMinimalExecutedModel(Func<RuntimeModel> runtimeModelCreator, Func<bool>[] formulas, long successorStateCapacity)
			: base(runtimeModelCreator)
		{
			formulas = formulas ?? RuntimeModel.Formulas.Select(CompilationVisitor.Compile).ToArray();

			_transitions = new ActivationMinimalTransitionSetBuilder(RuntimeModel, successorStateCapacity, formulas);
			_stateConstraints = RuntimeModel.Model.Components.Cast<Component>().SelectMany(component => component.StateConstraints).ToArray();

			ChoiceResolver = new ChoiceResolver(RuntimeModel.Objects.OfType<Choice>());
		}
Exemplo n.º 5
0
        /// <summary>
        ///   Disposes the object, releasing all managed and unmanaged resources.
        /// </summary>
        /// <param name="disposing">If true, indicates that the object is disposed; otherwise, the object is finalized.</param>
        protected override void OnDisposing(bool disposing)
        {
            if (!disposing)
            {
                return;
            }

            ChoiceResolver.SafeDispose();
            TemporaryStateStorage.SafeDispose();
            RuntimeModel.SafeDispose();
        }
Exemplo n.º 6
0
        /// <summary>
        ///   Gets all transitions towards successor states of <paramref name="state" />.
        /// </summary>
        /// <param name="state">The state the successors should be returned for.</param>
        public override TransitionCollection GetSuccessorTransitions(byte *state)
        {
            BeginExecution();
            ChoiceResolver.PrepareNextState();

            while (ChoiceResolver.PrepareNextPath())
            {
                RuntimeModel.Deserialize(state);
                ExecuteTransition();

                GenerateTransition();
            }

            return(EndExecution());
        }
Exemplo n.º 7
0
        /// <summary>
        ///   Gets all initial transitions of the model.
        /// </summary>
        public override TransitionCollection GetInitialTransitions()
        {
            BeginExecution();
            ChoiceResolver.PrepareNextState();

            fixed(byte *state = RuntimeModel.ConstructionState)
            {
                while (ChoiceResolver.PrepareNextPath())
                {
                    RuntimeModel.Deserialize(state);
                    ExecuteInitialTransition();

                    GenerateTransition();
                }
            }

            return(EndExecution());
        }
Exemplo n.º 8
0
		/// <summary>
		///   Replays the transition of the counter example with the zero-baesd <paramref name="transitionIndex" />.
		/// </summary>
		/// <param name="choiceResolver">The choice resolver that should be used to resolve nondeterministic choices.</param>
		/// <param name="transitionIndex">The zero-based index of the transition that should be replayed.</param>
		internal unsafe void Replay(ChoiceResolver choiceResolver, int transitionIndex)
		{
			if (StepCount == 0)
				return;

			choiceResolver.Clear();
			choiceResolver.PrepareNextState();
			choiceResolver.SetChoices(_replayInfo[transitionIndex]);

			fixed (byte* state = _states[transitionIndex])
				RuntimeModel.Deserialize(state);

			if (transitionIndex == 0)
				RuntimeModel.ExecuteInitialStep();
			else
				RuntimeModel.ExecuteStep();

			RuntimeModel.NotifyFaultActivations();
		}
Exemplo n.º 9
0
		/// <summary>
		///   Resets the model to its initial state.
		/// </summary>
		public void Reset()
		{
			if (_choiceResolver == null)
				_choiceResolver = new ChoiceResolver(_runtimeModel.Objects.OfType<Choice>());

			var state = stackalloc byte[_runtimeModel.StateVectorSize];

			_states.Clear();
			_stateIndex = -1;

			if (_counterExample == null)
				_runtimeModel.Reset();
			else
				_counterExample.Replay(_choiceResolver, 0);

			_runtimeModel.Serialize(state);
			AddState(state);
		}