Beispiel #1
0
        public HHDevice(IniDocument ini, int index, HHDeviceGrp devGrp)
        {
            this.DevGroup = devGrp;
            string sectionName = devGrp.Name + "\\设备" + (index + 1);
            this.Name = ini.GetString(sectionName, "设备名称");
            if (string.IsNullOrEmpty(this.Name)) return;
            IList<HHDeviceProperty> props = devGrp.Properties;
            for (int i = 0; i < props.Count; i++)
            {
                string propName = props[i].Name;

                string bindName = ini.GetString(sectionName, propName);

                listProp.Add(props[i].Bind(bindName));

            }
            this.IsValid = true;
            for (int i = 0; i < listProp.Count; i++)
            {
                if (listProp[i].IsBind==false)
                {
                    this.IsValid = false;
                    break;
                }
            }
        }
Beispiel #2
0
        public HHDevice(IniDocument ini, int index, HHDeviceGrp devGrp)
        {
            this.DevGroup = devGrp;
            string sectionName = devGrp.Name + "\\设备" + (index + 1);

            this.Name = ini.GetString(sectionName, "设备名称");
            if (string.IsNullOrEmpty(this.Name))
            {
                return;
            }
            IList <HHDeviceProperty> props = devGrp.Properties;

            for (int i = 0; i < props.Count; i++)
            {
                string propName = props[i].Name;

                string bindName = ini.GetString(sectionName, propName);


                listProp.Add(props[i].Bind(bindName));
            }
            this.IsValid = true;
            for (int i = 0; i < listProp.Count; i++)
            {
                if (listProp[i].IsBind == false)
                {
                    this.IsValid = false;
                    break;
                }
            }
        }
        public HHDeviceProperty(IniDocument ini, HHDeviceGrp grp, int index)
        {
            this.DevGrp = grp;
            string sectionName = grp.Name + "\\属性" + (index + 1);
            this.Type = ini.GetString(sectionName, "类型");
            if (string.IsNullOrEmpty(Type)) return;
            this.DisplayName = ini.GetString(sectionName, "显示名称");
            if (string.IsNullOrEmpty(DisplayName)) return;
            this.Name = ini.GetString(sectionName, "名称");
            if (string.IsNullOrEmpty(Name)) return;
            this.DataSrc = ini.GetString(sectionName, "数据来源");
            if (string.IsNullOrEmpty(DataSrc)) return;
            string monitorType = ini.GetString(sectionName, "室外监测类型");
            if (string.IsNullOrEmpty(monitorType)) return;
            this.MonitorType = SignalType.SignalAC;
            switch (monitorType)
            {
                case "直流":
                    this.MonitorType = SignalType.SignalDC;
                    break;
                case "载频":
                    this.MonitorType = SignalType.SignalCarrier;
                    break;
                case "低频":
                    this.MonitorType = SignalType.SignalLow;
                    break;
                case "直流道岔":
                    this.MonitorType = SignalType.SignalDCCurve;
                    break;
                case "交流道岔":
                    this.MonitorType = SignalType.SignalACCurve;
                    break;
                case "相位角":
                    this.MonitorType = SignalType.SignalAngle;
                    break;
            }

            string monitorGrp = ini.GetString(sectionName, "室外监测数据源");
            if (string.IsNullOrEmpty(monitorGrp)) return;

            string[] grps = monitorGrp.Split(new char[]{'-'},StringSplitOptions.RemoveEmptyEntries);
            this.GroupIndex = int.Parse(grps[0]);
            this.GroupCount = 1;
            if (grps.Length > 1)
            {
                this.GroupCount = int.Parse(grps[1]);
            }

            this.Unit = ini.GetString(sectionName, "单位");

            this.IsValid = true;
        }
        public HHDeviceProperty(IniDocument ini, HHDeviceGrp grp, int index)
        {
            this.DevGrp = grp;
            string sectionName = grp.Name + "\\属性" + (index + 1);

            this.Type = ini.GetString(sectionName, "类型");
            if (string.IsNullOrEmpty(Type))
            {
                return;
            }
            this.DisplayName = ini.GetString(sectionName, "显示名称");
            if (string.IsNullOrEmpty(DisplayName))
            {
                return;
            }
            this.Name = ini.GetString(sectionName, "名称");
            if (string.IsNullOrEmpty(Name))
            {
                return;
            }
            this.DataSrc = ini.GetString(sectionName, "数据来源");
            if (string.IsNullOrEmpty(DataSrc))
            {
                return;
            }
            string monitorType = ini.GetString(sectionName, "室外监测类型");

            if (string.IsNullOrEmpty(monitorType))
            {
                return;
            }
            this.MonitorType = SignalType.SignalAC;
            switch (monitorType)
            {
            case "直流":
                this.MonitorType = SignalType.SignalDC;
                break;

            case "载频":
                this.MonitorType = SignalType.SignalCarrier;
                break;

            case "低频":
                this.MonitorType = SignalType.SignalLow;
                break;

            case "直流道岔":
                this.MonitorType = SignalType.SignalDCCurve;
                break;

            case "交流道岔":
                this.MonitorType = SignalType.SignalACCurve;
                break;

            case "相位角":
                this.MonitorType = SignalType.SignalAngle;
                break;
            }

            string monitorGrp = ini.GetString(sectionName, "室外监测数据源");

            if (string.IsNullOrEmpty(monitorGrp))
            {
                return;
            }

            string[] grps = monitorGrp.Split(new char[] { '-' }, StringSplitOptions.RemoveEmptyEntries);
            this.GroupIndex = int.Parse(grps[0]);
            this.GroupCount = 1;
            if (grps.Length > 1)
            {
                this.GroupCount = int.Parse(grps[1]);
            }


            this.Unit = ini.GetString(sectionName, "单位");

            this.IsValid = true;
        }
        private void InitDevList(HHDeviceGrp devGrp)
        {
            comboBoxEdit2.Properties.Items.Clear();

            for (int i = 0; i < MaxSrcs; i++)
            {
                selectChannels[i] = null;
                txtBoxes[i] = null;
                buttons[i] = null;
            }
            comboBoxEdit2.Text = "";

            IList<HHDevice> devices = devGrp.Devices;
            for (int i = 0; i < devices.Count; i++)
            {
                comboBoxEdit2.Properties.Items.Add(devices[i]);
            }

            List<HHSourceGroup> grps = devGrp.SourceGroups;

            xtraTabControl1.TabPages.Clear();

            for (int i = 0; i < grps.Count; i++)
            {
                XtraTabPage tabPage = new XtraTabPage();
                tabPage.Name = "Signal" + i;
                tabPage.Text = "信号源" + (i + 1);

                int height = 15;

                int grpCnt = 1;

                for (int j = 0; j < grps[i].Properties.Count; j++)
                {
                    string propName = grps[i].Properties[j].Name;
                    Label label = new Label();
                    label.AutoSize = true;
                    label.Font = new Font("宋体", 11, FontStyle.Bold);
                    label.Text = (j + 1) + ":" + propName;
                    label.Location = new Point(15, height);

                    height += 30;

                    tabPage.Controls.Add(label);

                    grpCnt = grps[i].Properties[j].GroupCount;

                }

                string[][] txtList=new string[][]{
                new string[]{"选取"},
                new string[]{"参考","选取"},
                new string[]{"A相(或单相)","B相","C相"},
                };
                for (int j = 0; j < grpCnt; j++)
                {
                    TextBox textBox = new TextBox();
                    txtBoxes[i * PropChannelNum + j] = textBox;
                    textBox.Location = new Point(15, height);
                    textBox.Size = new Size(150, 25);
                    textBox.ReadOnly = true;
                    textBox.BackColor = Color.Pink;
                    tabPage.Controls.Add(textBox);

                    Button bt = new Button();
                    bt.Tag = i * PropChannelNum + j;
                    bt.Location = new Point(textBox.Left + textBox.Width, height);
                    bt.Size = new Size(80, 25);

                    bt.Text = txtList[grpCnt - 1][j];
                    tabPage.Controls.Add(bt);

                    bt.Click += new EventHandler(bt_Click);

                    height += 30;
                }

                xtraTabControl1.TabPages.Add(tabPage);
            }
        }
        private void Load(string fileName)
        {
            if (File.Exists(fileName) == false)
            {
                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++)
            {
                HHDeviceGrp devGrp = new HHDeviceGrp(ini,i);
                if (devGrp.IsValid)
                {
                    listGrp.Add(devGrp);
                }
            }

            //区间轨道电路

            List<HHDeviceGrp> grpsQJ = new List<HHDeviceGrp>();
            HHDeviceGrp grpQJ = null;

            List<HHDeviceGrp> grpsZN = new List<HHDeviceGrp>();
            HHDeviceGrp grpZN = null;

            for (int i = 0; i < listGrp.Count; i++)
            {
                int devType=listGrp[i].DevType;
                switch (devType)
                {
                    case 8: //区间轨道电路
                        grpQJ = listGrp[i];
                        listGrpSort.Add(grpQJ);
                        break;
                    case 10: //无绝缘移频
                        grpsQJ.Add(listGrp[i]);
                        break;
                    case 30: //有绝缘移频
                        grpsQJ.Add(listGrp[i]);
                        break;
                    case 208: //ZPW2000
                        grpsQJ.Add(listGrp[i]);
                        break;
                    case 4: //站内轨道电路
                        grpZN = listGrp[i];
                        listGrpSort.Add(grpZN);
                        break;
                    case 11: //25HZ轨道电路
                        grpsZN.Add(listGrp[i]);
                        break;
                    case 16: //480轨道电路
                        grpsZN.Add(listGrp[i]);
                        break;
                    case 17: //高压不对称
                        grpsZN.Add(listGrp[i]);
                        break;
                    case 25: //驼峰
                        grpsZN.Add(listGrp[i]);
                        break;
                    default:
                        listGrpSort.Add(listGrp[i]);
                        break;

                }
                if (devType != 4 && devType != 8)
                {
                    listGrpUnsort.Add(listGrp[i]);
                }

            }

            if (grpQJ != null)
            {
                grpQJ.AddGrp(grpsQJ);
            }
            else
            {
                listGrpSort.AddRange(grpsQJ);
            }
            if (grpZN != null)
            {
                grpZN.AddGrp(grpsZN);
            }
            else
            {
                listGrpSort.AddRange(grpsZN);
            }
        }