RuleAttribute.ModeTransition Property

Gets or sets the mode transition associated with the rule.

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

Usage

'Usage

Syntax

'Declaration
public string ModeTransition { get; set; }

Property Value

The mode transition associated with the rule.

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

A mode transition has the syntax: sourceModeSet -> targetModeSet, where sourceModeSet and targetModeSet are comma-separated sets of mode tags. If the ModeTransition property is null, then the rule does not contain a mode transition.

Spec Explorer enables during exploration a rule that contains a mode transition when the source mode set is a subset of the current mode set. The mode set for the subsequent state is the mode set for the current state minus the source mode set, plus the target mode set. For more information about using mode transitions, see Mode Sets.

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

RuleAttribute Class
RuleAttribute Members
Microsoft.Modeling Namespace
InitialModeAttribute Class
AcceptingModeAttribute Class
ErrorModeAttribute Class