Пример #1
0
        internal static string WriteParentDivisionVariableNext(NuSMV.Module module, ParentInstance parentInstance)
        {
            string op = "";

            foreach (var variable in module.Variables)
            {
                if (variable.Behaviour == VariableBehaviour.DIVISION)
                {
                    op += "next (" + parentInstance.Name + "." + variable.Name + ") := case\n";
                    foreach (var caseLine in (variable as Variable).Next.CaseStatement.CaseLines)
                    {
                        string temp = "\t";
                        temp += TVariables.insertInstanceName(caseLine.Rule.Condition, parentInstance);
                        temp += " : ";
                        temp += insertInstanceName2Expression(caseLine.Result, parentInstance);
                        //if (caseLine.Result is InstancedExp)
                        //    temp += parentInstance.Name + "." + caseLine.Result;
                        //else if (caseLine.Result is Expression)
                        //    temp += caseLine.Result;

                        temp += ";\n";
                        op   += temp;
                    }
                    op += "esac;\n";
                }
            }
            return(op);
        }
Пример #2
0
        internal static string WriteStatusNextWithInstance(NuSMV.Module module, Instance instance)
        {
            string   op     = "";
            Variable status = module.Status;

            op = "next (" + instance.Name + "." + module.Status.Name + ") := case\n";
            foreach (var caseLine in status.Next.CaseStatement.CaseLines)
            {
                // CaseLine newcaseLine = new CaseLine();
                if (!(caseLine.Rule is CommunicationRule))
                {
                    string temp = "";
                    temp += TVariables.insertInstanceName(caseLine.Rule.Condition, instance);
                    temp += " : ";
                    // for last true case
                    if (caseLine.Rule.Condition is TruthValue)
                    {
                        temp += instance.Name + "." + caseLine.Result;
                    }
                    else
                    {
                        temp += caseLine.Result;
                    }
                    temp += ";\n";
                    op   += temp;
                }
            }
            op += "esac;\n";
            return(op);
        }
Пример #3
0
        /// <summary>
        /// Print status rules of each child instance
        /// </summary>
        internal static string WriteChildStatusNext(NuSMV.Module module, ChildInstance childInstance)
        {
            string   op     = "";
            Variable status = childInstance.DivisionStatus;

            op = "next (" + childInstance.Name + "." + status.Name + ") := case\n";

            bool firstRule = true;// first rule related with parent, so, its rule shouldn't be named with child instances

            foreach (var caseLine in status.Next.CaseStatement.CaseLines)
            {
                string temp = "";
                if (!firstRule)
                {
                    // add child name as prefix
                    temp += TVariables.insertInstanceName(caseLine.Rule.Condition, childInstance);
                }
                else
                {
                    temp     += caseLine.Rule.Condition;
                    firstRule = false;
                }
                temp += " : ";
                // for last true case
                if (caseLine.Rule.Condition is TruthValue)
                {
                    temp += childInstance.Name + "." + caseLine.Result;
                }
                else
                {
                    temp += caseLine.Result;
                }
                temp += ";\n";
                op   += temp;
            }
            op += "esac;\n";
            return(op);
        }