Beispiel #1
0
        public DevAnalog(IniDocument ini, DevAnalogGrp grp, int index)
        {
            this.Group = grp;
            this.Index = index;

            string section = grp.Name + "\\" + (index + 1);

            this.Name = ini.GetString(section, "设备名称");
            if (string.IsNullOrEmpty(this.Name))
            {
                return;
            }
            if (this.Name.ToUpper() == "DUMMY")
            {
                return;
            }



            float val = ini.GetFloat(section, "AD最小", float.NaN);

            this.ADMin = float.IsNaN(val) ? grp.ADMin : val;


            val = ini.GetFloat(section, "AD最大", float.NaN);

            this.ADMax = float.IsNaN(val) ? grp.ADMax : val;

            this.IsValid = true;
        }
Beispiel #2
0
        private void Load(string fileName)
        {
            if (File.Exists(fileName) == false)
            {
                Assembly         assembly  = this.GetType().Assembly;
                System.IO.Stream smEmbeded = assembly.GetManifestResourceStream("ConfigManager.Config.模拟量.rhhcfg");


                byte[] data = new byte[smEmbeded.Length];

                smEmbeded.Read(data, 0, data.Length);


                //建立目录

                string dir = Path.GetDirectoryName(fileName);
                if (Directory.Exists(dir) == false)
                {
                    Directory.CreateDirectory(dir);
                }


                File.WriteAllBytes(fileName, data);


                smEmbeded.Close();
            }
            IniDocument ini = new IniDocument();

            ini.Load(fileName);
            int num = ini.GetInt("模拟量类型", "数目", 0);

            for (int i = 0; i < num; i++)
            {
                DevAnalogGrp grp = new DevAnalogGrp(ini, i);
                if (grp.IsValid == false)
                {
                    continue;
                }

                if (dicAnalogGrp.ContainsKey(grp.Name) == false)
                {
                    dicAnalogGrp.Add(grp.Name, grp);
                }
            }
        }