Exemple #1
0
        internal void GenerateNodeSpecificFiles(ModelContainer mc)
        {
            foreach (Node node in mc.Model.Nodes)
            {
                StringBuilder sb = new StringBuilder();

                //const eApplicationID MODEL::NodeMasterApplication = eApplicationID::SNSCT_L0_TECH_HS_1;
                sb.AFL("const sensact::eApplicationID applications::NodeMasterApplication = sensact::eApplicationID::{0};", node.NodeName);
                WriteFileInSubdirectory(node.NodeName, "nodeMasterApplicationId", sb);
                sb.Clear();

                //const char MODEL::ModelString[] ="NodeId SNSCT_L0_TECH_HS_1 created on 02.02.2021 22:29:40 using model Sattlerstraße 16 from git hash ea29f6371a5d33c7621cecf1e6bda050edf38681";
                sb.AFL("const char* const node::NodeDescription =\"NodeId {0} created on {1} using model {2}\";", node.NodeName, DateTime.Now, mc.Model.Name);
                //const eNodeID MODEL::NodeID = eNodeID::SNSCT_L0_TECH_HS_1;
                sb.AFL("const sensact::eNodeID node::NodeID = sensact::eNodeID::{0};", node.NodeName);
                WriteFileInSubdirectory(node.NodeName, "nodeDescription", sb);
                sb.Clear();

                string[] Glo2LocCmd = new string[mc.NextFreeIndex];
                for (int i = 0; i < mc.NextFreeIndex; i++)
                {
                    Glo2LocCmd[i] = "\tnullptr,";
                }
                //Static initializers
                foreach (SensactApplication app in node.Applications)
                {
                    sb.Append(app.GenerateInitializer(mc));
                    SensactApplicationContainer appCont = mc.id2app[app.ApplicationId];
                    Glo2LocCmd[appCont.Application.ApplicationId] = "    &" + app.ApplicationId + ",";
                }
                WriteFileInSubdirectory(node.NodeName, "applicationInitializers", sb);
                sb.Clear();
                for (int i = 0; i < Glo2LocCmd.Length; i++)
                {
                    sb.AppendLine(Glo2LocCmd[i]);
                }
                WriteFileInSubdirectory(node.NodeName, "glo2LocCmd", sb);
                sb.Clear();
                string[] Glo2LocEvents = new string[mc.NextFreeIndex];
                for (int i = 0; i < Glo2LocEvents.Length; i++)
                {
                    Glo2LocEvents[i] = "\tnullptr,";
                }
                for (int i = 0; i < Glo2LocCmd.Length; i++)
                {
                    sb.AppendLine(Glo2LocEvents[i]);
                }

                WriteFileInSubdirectory(node.NodeName, "glo2LocEvt", sb);
                sb.Clear();
            }
            LOG.LogInformation("Successfully created all node specific .inc files");
            return;
        }
Exemple #2
0
        internal void GenerateApplicationNames(ModelContainer mc)
        {
            var ApplicationNames = new string[mc.NextFreeIndex];

            foreach (var kv in Enum.GetValues <Nodes.ApplicationId>().Where(x => x != Nodes.ApplicationId.NO_APPLICATION))
            {
                ApplicationNames[(ushort)kv] = kv.ToString();
                //Alle vordefinierten Indizes müssen bekannt sein, auch wenn die App (noch) nicht definiert ist
            }
            foreach (var appc in mc.id2app.Values)
            {
                //Sanity check
                if (ApplicationNames[appc.Application.ApplicationId] != null && !ApplicationNames[appc.Application.ApplicationId].Equals(appc.Application.ApplicationName))
                {
                    throw new Exception("Implementation error!");
                }
                ApplicationNames[appc.Application.ApplicationId] = appc.Application.ApplicationName;
                //Auch alle Apps, die keinen vordefinierten Index verwenden, müssen bekannt sein
            }

            StringBuilder sb = new StringBuilder();

            foreach (var name in ApplicationNames)
            {
                sb.AFL("\"{0}\",", name);
            }
            this.WriteCommonFile("applicationNames", sb);
        }