コード例 #1
0
        /// <summary>
        /// Create an user defined item from XML
        /// </summary>
        /// <param name="itemNode">the xml node</param>
        /// <returns>an user defined item as specified by XML</returns>
        UserDefinedItem createUserDefinedItem(XmlNode itemNode)
        {
            int     count   = Convert.ToInt32(itemNode.Attributes["count"].Value);
            string  name    = itemNode.Attributes["name"].Value;
            int     index   = Convert.ToInt32(itemNode.Attributes["index"].Value);
            string  dbcol   = itemNode.Attributes["dbcol"].Value;
            string  comment = itemNode.SelectSingleNode("comment").InnerText;
            XmlNode udNode  = itemNode.SelectSingleNode("userDefined");

            if (udNode != null)
            {
                string          typeName = udNode.Attributes["name"].Value;
                UserDefinedItem udItem   = new UserDefinedItem(name, count, index, comment, typeName, dbcol);
                //now add all subItems
                XmlNodeList subNodes = userDefinedNodesDict[typeName].SelectNodes("element");
                foreach (XmlNode subNode in subNodes)
                {
                    TelegramItem item = createItem(subNode);
                    udItem.SubItems.Add(item);
                }
                return(udItem);
            }
            else
            {
                XmlNode         recordNode = itemNode.SelectSingleNode("record");
                UserDefinedItem udItem     = new UserDefinedItem(name, count, index, comment, "record", "");
                XmlNodeList     items      = recordNode.SelectNodes("element");
                foreach (XmlNode item in items)
                {
                    udItem.SubItems.Add(createItem(item));
                }
            }
            return(null);
        }
コード例 #2
0
 protected virtual void addItem(LibTelcom.TelegramItem item)
 {
     if (item.Count == 1)
     {
         addItem(item.Name, item);
     }
     else
     {
         for (int i = 0; i < item.Count; i++)
         {
             addItem(item.Name + "[" + i.ToString() + "]", item);
         }
     }
 }
コード例 #3
0
        protected virtual void addItem(string name, LibTelcom.TelegramItem item)
        {
            tableLayoutPanel1.RowCount++;
            int rowNo = tableLayoutPanel1.RowCount - 2;

            addItemLabel(rowNo, name, item.Comment);
            TextValueControl val = new TextValueControl();

            addItemControl(rowNo, val);
            if (item is LibTelcom.PrimitiveItem)
            {
                addUnitLabel(rowNo, (item as LibTelcom.PrimitiveItem).Unit);
            }
            itemControls.Add(name, val);
            itemDefs.Add(name, item);
        }
コード例 #4
0
        public List <TelegramDefinition> getTelegramDefinitions()
        {
            List <TelegramDefinition> telegramList = new List <TelegramDefinition>();
            XmlNodeList telegramNodeList           = xmlDoc.SelectNodes("module/telegram");

            foreach (XmlNode teleNode in telegramNodeList)
            {
                string             teleName = teleNode.Attributes["name"].Value;
                string             comment  = teleNode.SelectSingleNode("comment").InnerText;
                TelegramDefinition tele     = new TelegramDefinition(teleName);
                tele.Description = comment;

                XmlNodeList itemNodeList = teleNode.SelectNodes("record/element");
                foreach (XmlNode itemNode in itemNodeList)
                {
                    TelegramItem item = createItem(itemNode);
                    tele.TelegramItems.Add(item);
                }
                telegramList.Add(tele);
            }
            return(telegramList);
        }