示例#1
0
		/// <summary>
		///   Adds a transition to the <paramref name="successorState" /> to the set.
		/// </summary>
		/// <param name="successorState">The successor state of the transition that should be added.</param>
		/// <param name="activatedFaults">The faults activated by the transition that should be added.</param>
		/// <param name="formulas">The formulas holding in the successor state of the transition that should be added.</param>
		public void Add(byte* successorState, FaultSet activatedFaults, StateFormulaSet formulas)
		{
			var targetState = _targetStateMemory + _count * _stateVectorSize;
			MemoryBuffer.Copy(successorState, targetState, _stateVectorSize);

			_transitions[_count] = new CandidateTransition
			{
				TargetState = targetState,
				Formulas = formulas,
				ActivatedFaults = activatedFaults,
				IsValid = true,
			};

			++_count;
		}
		/// <summary>
		///   Adds a transition to the <paramref name="model" />'s current state.
		/// </summary>
		/// <param name="model">The model the transition should be added for.</param>
		public void Add(RuntimeModel model)
		{
			if (_count >= _capacity)
				throw new OutOfMemoryException("Unable to store an additional transition. Try increasing the successor state capacity.");

			++_computedCount;

			// 1. Serialize the model's computed state; that is the successor state of the transition's source state
			//    modulo any changes resulting from notifications of fault activations
			var successorState = _targetStateMemory + _stateVectorSize * _count;
			var activatedFaults = FaultSet.FromActivatedFaults(model.NondeterministicFaults);
			model.Serialize(successorState);

			// 2. Make sure the transition we're about to add is activation-minimal
			if (!Add(successorState, activatedFaults))
				return;

			// 3. Execute fault activation notifications and serialize the updated state if necessary
			if (model.NotifyFaultActivations())
				model.Serialize(successorState);

			// 4. Store the transition
			_transitions[_count] = new CandidateTransition
			{
				TargetState = successorState,
				Formulas = new StateFormulaSet(_formulas),
				ActivatedFaults = activatedFaults,
				IsValid = true,
			};
			++_count;
		}