AcceptingModeAttribute Class

Defines a set of mode tags that identifies an accepting mode set of the model program.


Namespace: Microsoft.Modeling
Assembly: Microsoft.Xrt.Runtime (in Microsoft.Xrt.Runtime.dll)

'Usage

The following example shows a model program that makes use of various mode attributes to describe parts of the model behavior.

using Microsoft.Modeling;

namespace Modes
{
    [InitialMode("Unstarted")]
    [AcceptingMode("Finished")]
    [AcceptingMode("Unstarted")]
    [ErrorMode("StartError")]
    static class ModesModelProgram
    {
        static int jobCount = 0;

        [Probe]
        public static string CountProbe { get { return string.Format("Jobs: {0}", jobCount); } }

        [AcceptingStateCondition]
        static bool IsAccepting { get { return jobCount == 0; } }

        [Rule(Action = "Start(initialCount)", ModeTransition = "Unstarted->Running")]
        static void Start(int initialCount)
        {
            Condition.IsTrue(initialCount > 0);
            jobCount = initialCount;
        }

        [Rule(Action = "Start(initialCount)", ModeTransition = "Unstarted->StartError")]
        static void StartError(int initialCount)
        {
            Condition.IsFalse(initialCount > 0);
        }

        [Rule(Action = "DoNext", ModeTransition = "Running->Running")]
        static void DoNext()
        {
            Condition.IsTrue(jobCount > 0);
            jobCount--;
        }

        [Rule(Action = "Stop/result", ModeTransition = "Running->Finished")]
        static int Stop()
        {
            Condition.IsTrue(jobCount == 0);
            return jobCount;
        }

        [Rule(Action = "Stop/result", ModeTransition = "Running->JobError")]
        static int StopError()
        {
            Condition.IsFalse(jobCount == 0);
            return jobCount;
        }

        [Rule(ModeTransition = "Finished->Unstarted")]
        static void Reset()
        {
            jobCount = 0;
        }
    }
}

When one or more accepting mode sets are defined, Spec Explorer can mark a state as an accepting state if an accepting mode set is defined that is a subset of the mode set for the state. If the model program also includes an accepting state condition, then Spec Explorer only marks the state as an accepting state if the state also meets the accepting state condition. For more information about using mode transitions, see Mode Sets. For more information about accepting state conditions, see State Attributes and AcceptingStateConditionAttribute.

Spec Explorer's validation process checks the value of the Mode property and generates a validation error if the value of the property is invalid. The compiler does not identify such errors.

For more information about using attributes, see Extending Metadata Using Attributes.


System.Object
   System.Attribute
    Microsoft.Modeling.AcceptingModeAttribute

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Development Platforms

Microsoft Windows 7, Microsoft Windows Vista, Microsoft Windows XP SP2 or later, Microsoft Windows Server 2008, Microsoft Windows Server 2003

 



Community Additions

ADD
Show: