コード例 #1
0
ファイル: DeviceManager.cs プロジェクト: xibeilang524/scada-1
 private string GetCOMPort(DeviceEntry entry)
 {
     if (entry.Contains(DeviceEntry.SerialPort))
     {
         return((StringValue)entry[DeviceEntry.SerialPort]);
     }
     return(string.Empty);
 }
コード例 #2
0
        private bool Initialize(DeviceEntry entry)
        {
            this.Name             = entry[DeviceEntry.Name].ToString();
            this.Id               = entry[DeviceEntry.Identity].ToString();
            this.DeviceConfigPath = entry[DeviceEntry.Path].ToString();
            this.Version          = entry[DeviceEntry.Version].ToString();

            this.processName = (StringValue)entry[ProcessName];

            for (int i = 1; i < 50; i++)
            {
                string elemId = string.Format("ElemId{0}", i);
                if (!entry.Contains(elemId))
                {
                    break;
                }
                string controlIdStr = (StringValue)entry[elemId];
                int    controlId    = 0;
                if (controlIdStr.StartsWith("0x"))
                {
                    controlIdStr = controlIdStr.Substring(2);
                    controlId    = int.Parse(controlIdStr, NumberStyles.AllowHexSpecifier);
                    this.elemIdList.Add(controlId);
                }
                else
                {
                    if (int.TryParse(controlIdStr, out controlId))
                    {
                        this.elemIdList.Add(controlId);
                    }
                }
            }

            string tableName   = (StringValue)entry[DeviceEntry.TableName];
            string tableFields = (StringValue)entry[DeviceEntry.TableFields];


            if (!Device.GetFactor(entry, 1, out this.factor1))
            {
                // Debug.Assert(false);
            }

            string[] fields = tableFields.Split(',');
            string   atList = string.Empty;

            for (int i = 0; i < fields.Length; ++i)
            {
                string at = string.Format("@{0}, ", i + 1);
                atList += at;
            }
            atList = atList.TrimEnd(',', ' ');

            this.tableName = tableName;
            string cmd = string.Format("insert into {0}({1}) values({2})", tableName, tableFields, atList);

            this.insertIntoCommand = cmd;


            string             fieldsConfigStr = (StringValue)entry[DeviceEntry.FieldsConfig];
            List <FieldConfig> fieldConfigList = ParseDataFieldConfig(fieldsConfigStr);

            this.fieldsConfig = fieldConfigList.ToArray <FieldConfig>();

            this.GenCurrentSid();
            return(true);
        }