コード例 #1
0
        /// <summary>
        ///     Updates an expression according to translation rules
        /// </summary>
        /// <param name="step">the step in which the expression occurs</param>
        /// <param name="expression"></param>
        /// <returns>the updated string</returns>
        private string ReviewExpression(Step step, string expression)
        {
            string retVal = expression;

            if (expression.IndexOf('%') >= 0)
            {
                SubSequence subSequence = step.TestCase.SubSequence;

                retVal = retVal.Replace("%D_LRBG", format_decimal_as_str(subSequence.getD_LRBG()));
                retVal = retVal.Replace("%Level", format_level(subSequence.getLevel()));
                retVal = retVal.Replace("%Mode", format_mode(subSequence.getMode()));
                retVal = retVal.Replace("%NID_LRBG", format_decimal_as_str(subSequence.getNID_LRBG()));
                retVal = retVal.Replace("%Q_DIRLRBG", format_decimal_as_str(subSequence.getQ_DIRLRBG()));
                retVal = retVal.Replace("%Q_DIRTRAIN", format_decimal_as_str(subSequence.getQ_DIRTRAIN()));
                retVal = retVal.Replace("%Q_DLRBG", format_decimal_as_str(subSequence.getQ_DLRBG()));
                retVal = retVal.Replace("%RBC_ID", format_decimal_as_str(subSequence.getRBC_ID()));
                retVal = retVal.Replace("%RBCPhone", format_str(subSequence.getRBCPhone()));

                retVal = retVal.Replace("%Step_Distance", step.getDistance() + "");
                retVal = retVal.Replace("%Step_LevelIN", format_level(step.getLevelIN()));
                retVal = retVal.Replace("%Step_LevelOUT", format_level(step.getLevelOUT()));
                retVal = retVal.Replace("%Step_ModeIN", format_mode(step.getModeOUT()));
                retVal = retVal.Replace("%Step_ModeOUT", format_mode(step.getModeOUT()));

                int max_step_messages = 8;
                for (int i = 0; i < max_step_messages; i++)
                {
                    if (retVal.IndexOf("%Step_Messages_" + i) >= 0)
                    {
                        if (step.StepMessages.Count > i)
                        {
                            DBMessage message = step.StepMessages[i] as DBMessage;
                            if (message != null)
                            {
                                retVal = retVal.Replace("%Step_Messages_" + i, format_message(message));
                            }
                        }
                        else
                        {
                            retVal = retVal.Replace("%Step_Messages_" + i, format_default_message(expression));
                        }
                    }
                }

                if (retVal.IndexOf("%") > 0)
                {
                    step.AddError("Cannot completely translate this step");
                }
            }

            return(retVal);
        }
コード例 #2
0
        /// <summary>
        /// Activates the rules in the dictionary until stabilisation
        /// </summary>
        public void Cycle()
        {
            try
            {
                DataDictionary.Generated.ControllersManager.NamableController.DesactivateNotification();

                LastActivationTime = Time;

                Utils.ModelElement.ErrorCount = 0;

                foreach (Generated.acceptor.RulePriority priority in PRIORITIES_ORDER)
                {
                    // Clears the cache of functions
                    FunctionCacheCleaner.ClearCaches();

                    // Activates the processing engine
                    HashSet <Activation> activations = new HashSet <Activation>();
                    foreach (DataDictionary.Dictionary dictionary in EFSSystem.Dictionaries)
                    {
                        foreach (DataDictionary.Types.NameSpace nameSpace in dictionary.NameSpaces)
                        {
                            SetupNameSpaceActivations(priority, activations, nameSpace);
                        }
                    }

                    ApplyActivations(activations);
                }
                // Clears the cache of functions
                FunctionCacheCleaner.ClearCaches();

                if (Utils.ModelElement.ErrorCount > 0)
                {
                    SubStep subStep = CurrentSubStep();
                    if (subStep != null)
                    {
                        subStep.AddError("Errors were raised while evaluating this sub step. See model view for more informations");
                    }
                    else
                    {
                        Step step = CurrentStep();
                        if (step != null)
                        {
                            step.AddError("Errors were raised while evaluating this step. See model view for more informations");
                        }
                        else
                        {
                            TestCase testCase = CurrentTestCase();
                            if (testCase != null)
                            {
                                testCase.AddError("Errors were raised while evaluating this test case. See model view for more informations");
                            }
                            else
                            {
                                SubSequence.AddError("Errors were raised while evaluating this sub sequence. See model view for more informations");
                            }
                        }
                    }
                }
            }
            finally
            {
                DataDictionary.Generated.ControllersManager.NamableController.ActivateNotification();
            }

            EventTimeLine.CurrentTime += Step;
        }