Esempio n. 1
0
 /// <summary>
 ///   Updates the fault sets in accordance with the fault's actual activation states.
 /// </summary>
 public void UpdateFaultSets()
 {
     NondeterministicFaults    = Faults.Where(fault => fault.Activation == Activation.Nondeterministic).ToArray();
     ActivationSensitiveFaults = NondeterministicFaults.Where(fault => fault.RequiresActivationNotification).ToArray();
     OnStartOfStepFaults       = NondeterministicFaults.Where(fault => fault.DemandType == Fault.DemandTypes.OnStartOfStep).ToArray();
     OnMethodCallFaults        = NondeterministicFaults.Where(fault => fault.DemandType == Fault.DemandTypes.OnMethodCall).ToArray();
     OnCustomFaults            = NondeterministicFaults.Where(fault => fault.DemandType == Fault.DemandTypes.OnCustom).ToArray();
 }
Esempio n. 2
0
        /// <summary>
        ///   Initializes a new instance.
        /// </summary>
        /// <param name="serializedData">The serialized data describing the model.</param>
        /// <param name="stateHeaderBytes">
        ///   The number of bytes that should be reserved at the beginning of each state vector for the model checker tool.
        /// </param>
        internal RuntimeModel(SerializedRuntimeModel serializedData, int stateHeaderBytes = 0)
        {
            Requires.That(serializedData.Model != null, "Expected a valid model instance.");

            var buffer         = serializedData.Buffer;
            var rootComponents = serializedData.Model.Roots;
            var objectTable    = serializedData.ObjectTable;
            var formulas       = serializedData.Formulas;

            Requires.NotNull(buffer, nameof(buffer));
            Requires.NotNull(rootComponents, nameof(rootComponents));
            Requires.NotNull(objectTable, nameof(objectTable));
            Requires.NotNull(formulas, nameof(formulas));
            Requires.That(stateHeaderBytes % 4 == 0, nameof(stateHeaderBytes), "Expected a multiple of 4.");

            Model                     = serializedData.Model;
            SerializedModel           = buffer;
            RootComponents            = rootComponents.Cast <Component>().ToArray();
            Faults                    = objectTable.OfType <Fault>().Where(fault => fault.Activation == Activation.Nondeterministic && fault.IsUsed).ToArray();
            ActivationSensitiveFaults = Faults.Where(fault => fault.RequiresActivationNotification).ToArray();
            StateFormulas             = objectTable.OfType <StateFormula>().ToArray();
            Formulas                  = formulas;

            // Create a local object table just for the objects referenced by the model; only these objects
            // have to be serialized and deserialized. The local object table does not contain, for instance,
            // the closure types of the state formulas
            var objects             = Model.ReferencedObjects;
            var deterministicFaults = objectTable.OfType <Fault>().Where(fault => fault.Activation != Activation.Nondeterministic);

            _serializedObjects = new ObjectTable(objects.Except(deterministicFaults, ReferenceEqualityComparer <object> .Default));
            Objects            = objectTable;

            StateVectorLayout = SerializationRegistry.Default.GetStateVectorLayout(Model, _serializedObjects, SerializationMode.Optimized);

            _deserialize      = StateVectorLayout.CreateDeserializer(_serializedObjects);
            _serialize        = StateVectorLayout.CreateSerializer(_serializedObjects);
            _restrictRanges   = StateVectorLayout.CreateRangeRestrictor(_serializedObjects);
            _stateHeaderBytes = stateHeaderBytes;

            PortBinding.BindAll(objectTable);
            _choiceResolver = new ChoiceResolver(objectTable);

            ConstructionState = new byte[StateVectorSize];
            fixed(byte *state = ConstructionState)
            {
                Serialize(state);
                _restrictRanges();
            }

            FaultSet.CheckFaultCount(Faults.Length);
            StateFormulaSet.CheckFormulaCount(StateFormulas.Length);
        }
Esempio n. 3
0
 /// <summary>
 ///   Updates the fault sets in accordance with the fault's actual activation states.
 /// </summary>
 public void UpdateFaultSets()
 {
     NondeterministicFaults    = Faults.Where(fault => fault.Activation == Activation.Nondeterministic).ToArray();
     ActivationSensitiveFaults = NondeterministicFaults.Where(fault => fault.RequiresActivationNotification).ToArray();
 }