Beispiel #1
0
 protected override void DoWork()
 {
     lock (portal)
     {
         try
         {
             HMIConstantTable table = new HMIConstantTable(PRESET_CONSTANT_TABLE_NAME);
             foreach (KeyValuePair <string, ConstantLookup.Entry> entry in constants)
             {
                 if (entry.Key.StartsWith("PresetNumber"))
                 {
                     if (int.TryParse(entry.Value.value, out int value))
                     {
                         table.AddIntegerConstant(entry.Key, value);
                     }
                 }
             }
             TIAutils.ImportHMITagTableXML(table.Document, folder);
         }
         catch (Exception ex)
         {
             LogMessage(MessageLog.Severity.Error, "Failed to update preset constant table " + PRESET_CONSTANT_TABLE_NAME + "\n" + ex.Message);
             return;
         }
     }
 }
Beispiel #2
0
        protected override void DoWork()
        {
            lock (portal)
            {
                try
                {
                    TagTable table = folder.TagTables.Find(function);

                    if (table != null)
                    {
                        XmlDocument table_doc = TIAutils.ExportHMITagTableXML(table);
                        TagParser   parser    = new TagParser(portal);
                        parser.HandleTag += Parser_HandleTag;
                        parser.Parse(block, log, TagParser.Options.AllowNoComment | TagParser.Options.NoSubelement);

                        TIAutils.ImportHMITagTableXML(table_doc, folder);
                    }
                    else
                    {
                        LogMessage(MessageLog.Severity.Warning, "No tag table named " + function + " for tags from " + block.Name);
                    }
                }
                catch (Exception ex)
                {
                    LogMessage(MessageLog.Severity.Error, "Failed to update tag table from block:\n" + ex.Message);
                    return;
                }
            }
        }
Beispiel #3
0
        protected override void DoWork()
        {
            lock (portal)
            {
                try
                {
                    TagTable table = folder.TagTables.Find(tableName);

                    if (table != null)
                    {
                        XmlDocument   table_doc       = TIAutils.ExportHMITagTableXML(table);
                        HMITagTable   editor          = new HMITagTable(table_doc);
                        PathComponent enable_selected = new MemberComponent("EnableSelected", new STRUCT(), new MemberComponent(hmiDbName, new STRUCT()));
                        PathComponent preset_selected = new MemberComponent("PresetSelected", new STRUCT(), new MemberComponent(hmiDbName, new STRUCT()));

                        int index = 1;
                        foreach (var tag in tags)
                        {
                            editor.AddIndexedTag("PresetEnable_" + groupName + "_", index, tag.tagPath.PrependPath(enable_selected).ToString());
                            editor.AddIndexedTag("PresetValue_" + groupName + "_", index, tag.tagPath.PrependPath(preset_selected).ToString(), tag.tagPath.Type);

                            index++;
                        }

                        ARRAY name_array = new ARRAY();
                        name_array.MemberType = new STRING();
                        PathComponent preset_names = new MemberComponent("Names", name_array, new MemberComponent(dbName, new STRUCT()));
                        ARRAY         color_array  = new ARRAY();
                        color_array.MemberType = INT.Type;
                        PathComponent preset_colors = new MemberComponent("Colors", color_array, new MemberComponent(dbName, new STRUCT()));
                        for (int p = 1; p <= nPresets; p++)
                        {
                            PathComponent name = new IndexComponent(new int[1] {
                                p
                            }, new STRING(), preset_names);
                            editor.AddIndexedTag("PresetName_" + groupName + "_", p, name.ToString());
                            PathComponent color = new IndexComponent(new int[1] {
                                p
                            }, INT.Type, preset_colors);
                            editor.AddIndexedTag("PresetColor_" + groupName + "_", p, color.ToString());
                        }
                        TIAutils.ImportHMITagTableXML(table_doc, folder);
                    }
                    else
                    {
                        LogMessage(MessageLog.Severity.Warning, "No tag table named '" + tableName + "' was found, skipping.");
                    }
                }
                catch (Exception ex)
                {
                    LogMessage(MessageLog.Severity.Error, "Failed to update tag table:\n" + ex.Message);
                    return;
                }
            }
        }