Exemple #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;
            }
Exemple #2
0
            public string TranslateCompositeFB(FBType fbType)
            {
                string         smvModule          = "";
                ExecutionModel executionModel     = _executionModels.FirstOrDefault(em => em.FBTypeName == fbType.Name);
                var            events             = _storage.Events.Where(ev => ev.FBType == fbType.Name);
                var            variables          = _storage.Variables.Where(ev => ev.FBType == fbType.Name);
                var            instances          = _storage.Instances.Where(inst => inst.FBType == fbType.Name);
                var            withConnections    = _storage.WithConnections.Where(conn => conn.FBType == fbType.Name);
                var            connections        = _storage.Connections.Where(conn => conn.FBType == fbType.Name);
                var            instanceParameters = _storage.InstanceParameters.Where(p => p.FBType == fbType.Name);

                IDispatcher dispatcher = executionModel.Dispatcher;

                //smvModule += _moduleHeader(events, variables, fbType.Name) + "\n";
                smvModule += FbSmvCommon.SmvModuleDeclaration(events, variables, fbType.Name);
                smvModule += CompositeFbSmv.FbInstances(instances, _storage.Events, _storage.Variables, connections, _settings) + "\n";
                smvModule += CompositeFbSmv.InternalBuffersDeclaration(instances, connections, _storage.Events, _storage.Variables) + "\n";
                smvModule += Smv.Assign;
                smvModule += CompositeFbSmv.InternalBuffersInitialization(instances, connections, _storage.Events, _storage.Variables, instanceParameters) + "\n";

                if (_settings.UseProcesses)
                {
                    smvModule += CompositeFbSmv.NonConnectedInstanceOutputEvents(_storage.Events, instances, connections);
                    smvModule += CompositeFbSmv.ComponentDataOutputNextStatements(_storage.Variables, instances);
                }
                //smvModule += _moduleVariablesInitBlock(variables) + "\n";
                //smvModule += _inputVariablesSampleComposite(variables, withConnections) + "\n";
                smvModule += CompositeFbSmv.NonConnectedEventInputs(connections, _storage.Events, instances, _showMessage);
                smvModule += CompositeFbSmv.NonConnectedInputs(connections, _storage.Variables, instances);
                smvModule += CompositeFbSmv.InternalDataConnections(connections, withConnections, _storage.Variables, instances) + "\n";
                smvModule += CompositeFbSmv.ComponentEventOutputs(connections, _settings.UseProcesses) + "\n";
                //smvModule += _eventInputsResetRules(events) + "\n";
                smvModule += "\n-- ---DISPATCHER--- --\n";
                smvModule += "-- *************** --\n";
                smvModule += dispatcher.GetSmvCode(_settings.UseProcesses) + "\n";

                smvModule += CompositeFbSmv.InternalEventConnections(connections, _settings.UseProcesses) + "\n";
                smvModule += CompositeFbSmv.InputEventsResetRules(events, _settings.UseProcesses);
                smvModule += FbSmvCommon.DefineExistsInputEvent(events) + "\n";
                smvModule += CompositeFbSmv.DefineOmega(connections) + "\n";
                smvModule += CompositeFbSmv.DefinePhi(instances, _storage.Events) + "\n"; //phi variable for timed models

                smvModule += FbSmvCommon.ModuleFooter(_settings) + "\n";
                //smvModule += Smv.AlphaBetaRules;

                return(smvModule);
            }