示例#1
0
        /// <summary>
        /// Returns true if the action is enabled in the current state.
        /// If the action is not enabled, provides a reason in <paramref name="failureReason"/>.
        /// </summary>
        /// <param name="action">action whose enabledness is being checked</param>
        /// <param name="failureReason">failure reason if the action is not enabled</param>
        /// <returns>true if the action is enabled, false otherwise</returns>
        public bool IsActionEnabled(CompoundTerm action, out string failureReason)
        {
            if (!AllActionSymbols.Contains(action.Symbol))
            {
                failureReason = "Action symbol '" + action.Symbol.ToString() + "' not enabled in the model";
                return(false);
            }
            else
            {
                bool isEnabled = modelProgram.IsEnabled(currState, action);
                if (!isEnabled)
                {
                    failureReason = "Action '" + ConformanceTester.MakeQuotedString(action.ToString()) + "' not enabled in the model";

                    foreach (string s in modelProgram.GetEnablingConditionDescriptions(currState, action, true))
                    {
                        failureReason += "\n";
                        failureReason += s;
                    }
                    return(false);
                }
                else
                {
                    failureReason = "";
                    return(true);
                }
            }
        }