示例#1
0
            public static string BasicModuleDefines(IEnumerable <ECState> states, IEnumerable <Event> events, IEnumerable <ECTransition> transitions, bool showUnconditionalTransitions)
            {
                string ecTran = "";

                foreach (ECState state in states)
                {
                    IEnumerable <ECTransition> stateTrans = transitions.Where(t => t.Source == state.Name);
                    if (!stateTrans.Any())
                    {
                        continue;
                    }

                    ecTran += "(";
                    ecTran += Smv.EccStateVar + "=" + Smv.EccState(state.Name);

                    string transitionRules = "";
                    foreach (var transition in stateTrans)
                    {
                        transitionRules += "(";
                        if (transition.Condition == null || transition.Condition == "1")
                        {
                            if (!showUnconditionalTransitions)
                            {
                                transitionRules = null;
                                break;
                            }
                            else
                            {
                                transitionRules += "1";
                            }
                        }
                        else
                        {
                            transitionRules += _translateEventNames(Smv.ClearConditionExpr(transition.Condition), events);
                        }

                        transitionRules += ") | ";
                    }
                    if (transitionRules != null)
                    {
                        ecTran += "  & (" + transitionRules.TrimEnd(Smv.OrTrimChars) + ")";
                    }
                    ecTran += ") | ";
                }

                string existsEnabledECTran  = String.Format("DEFINE {0}:= {1};\n", Smv.ExistsEnabledEcTran, ecTran.Trim(Smv.OrTrimChars));
                string absentsEnabledECTran = "\n";

                //string alphabeta = "--alpha/beta\nDEFINE alpha_beta := ( (alpha & S_smv=s0_osm & !ExistsInputEvent | S_smv=s1_osm & (!ExistsEnabledECTran)) );\n";
                return(FbSmvCommon.DefineExistsInputEvent(events) + existsEnabledECTran + absentsEnabledECTran); // + alphabeta;
            }
示例#2
0
            private static string _getVarChangingRules(Variable variable, IEnumerable <AlgorithmLine> currrentVarLines, IEnumerable <ECAction> actions, Settings settings)
            {
                string rules = "";

                foreach (AlgorithmLine line in currrentVarLines)
                {
                    foreach (ECAction action in _findActionsByAlgorithmName(actions, line.AlgorithmName))
                    {
                        string rule = "\t" + Smv.OsmStateVar + "=" + Smv.Osm.S2;
                        rule += " & ";
                        rule += Smv.EccStateVar + "=" + Smv.EccState(action.ECState);
                        rule += " & ";
                        rule += Smv.EcActionsCounterVar + "=" + action.Number;
                        rule += " & ";
                        rule += Smv.AlgStepsCounterVar + "=" + line.NI;
                        if (line.Condition != "1")
                        {
                            rule += " & ";
                            rule += "(" + Smv.ClearConditionExpr(line.Condition) + ")";
                        }
                        //string val = line.Value;
                        string val = Smv.ClearConditionExpr(line.Value);
                        if (String.Compare(val, "false", StringComparison.InvariantCultureIgnoreCase) == 0)
                        {
                            val = Smv.False;
                        }
                        if (String.Compare(val, "true", StringComparison.InvariantCultureIgnoreCase) == 0)
                        {
                            val = Smv.True;
                        }

                        if (variable.SmvType.GetType() != typeof(Smv.DataTypes.BoolSmvType) && settings.ModularArithmetics)
                        {
                            //string rangeStr = variable.SmvType.Split()
                            Smv.DataTypes.RangeSmvType varType = (Smv.DataTypes.RangeSmvType)variable.SmvType;
                            rule += " : (" + _modulo_range(val, varType.RangeBegin, varType.RangeEnd) + ");\n";;
                        }
                        else
                        {
                            rule += " : (" + val + ");\n";
                        }
                        rules += rule;
                    }
                }
                return(rules);
            }
示例#3
0
            public static string EcStateChangeBlock(IEnumerable <ECTransition> transitions, IEnumerable <Event> events)
            {
                string ecTransitionsSmv = "";

                foreach (var transition in transitions)
                {
                    ecTransitionsSmv += "\t";
                    ecTransitionsSmv += Smv.EccStateVar + "=" + Smv.EccState(transition.Source);
                    ecTransitionsSmv += " & ";
                    ecTransitionsSmv += Smv.OsmStateVar + "=" + Smv.Osm.S1;

                    if (transition.Condition != null && transition.Condition != "1")
                    {
                        ecTransitionsSmv += " & " + _translateEventNames(Smv.ClearConditionExpr(transition.Condition), events);
                    }
                    ecTransitionsSmv += " : ";
                    ecTransitionsSmv += Smv.EccState(transition.Destination);
                    ecTransitionsSmv += ";\n";
                }
                return(String.Format("\n" + Smv.NextCaseBlock + "\n", Smv.EccStateVar, ecTransitionsSmv));
            }