/// <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); foreach (var fault in RuntimeModel.NondeterministicFaults) { fault.Reset(); } if (transitionIndex == 0) { RuntimeModel.ExecuteInitialStep(); } else { RuntimeModel.ExecuteStep(); } RuntimeModel.NotifyFaultActivations(); }
/// <summary> /// Deserializes the state at the <paramref name="position" /> of the counter example. /// </summary> /// <param name="position">The position of the state within the counter example that should be deserialized.</param> public unsafe ExecutableModel <TExecutableModel> DeserializeState(int position) { Requires.That(States != null, "No counter example has been loaded."); Requires.InRange(position, nameof(position), 0, StepCount); using (var pointer = PinnedPointer.Create(GetState(position))) RuntimeModel.Deserialize((byte *)pointer); return(RuntimeModel); }
/// <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()); }
/// <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()); }
/// <summary> /// Restores a previously discovered state. /// </summary> private void RestoreState(int stateNumber) { fixed(byte *state = _states[stateNumber]) _runtimeModel.Deserialize(state); }