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
'Usage
Syntax
'Declaration
[AttributeUsageAttribute(AttributeTargets.Class|AttributeTargets.Struct|AttributeTargets.Interface, AllowMultiple=true, Inherited=false)]
public sealed class AcceptingModeAttribute : Attribute
Example
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;
}
}
}
Remarks
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.
Inheritance Hierarchy
System.Object
System.Attribute
Microsoft.Modeling.AcceptingModeAttribute
Thread Safety
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Platforms
Development Platforms
Microsoft Windows 7, Microsoft Windows Vista, Microsoft Windows XP SP2 or later, Microsoft Windows Server 2008, Microsoft Windows Server 2003
Change History
See Also
Reference
AcceptingModeAttribute Members
Microsoft.Modeling Namespace
InitialModeAttribute
ErrorModeAttribute
RuleAttribute.ModeTransition