/// <summary>
        /// 检验连接状态
        /// </summary>
        private void ThreadConnect()
        {
            string[] sa = richTextBox1.Lines;
            richTextBox1.Clear();


            #region 检验IP
            for (int i = 1; i <= newEqCount; i++)
            {
                try
                {
                    string    ssas   = SystemConfig.GetConfigData(sa[i - 1].Substring(0, 1) + "#装置", string.Empty);
                    TcpClient client = TcpClientConnector.Connect(ssas, 3840 + int.Parse(ssas.Split('.')[3]), 2000);
                    //client = new TcpClient(ssas, 3840 + int.Parse(ssas.Split('.')[3]));
                    // client = new TcpClient(ssas, 3840);
                    detectREC      = new char[8];
                    ns             = client.GetStream();
                    ns.ReadTimeout = 2000;
                    detectINT      = new char[8];
                    detectINT[0]   = 'I'; detectINT[1] = 'N'; detectINT[2] = 'T';
                    detectINT[3]   = detectINT[4] = detectINT[5] = detectINT[6] = (char)0;
                    //detectINT[7] = i.ToString().ToCharArray(0,1)[0];
                    detectINT[7] = (char)0;
                    ns.Write(Encoding.ASCII.GetBytes(detectINT), 0, Encoding.ASCII.GetBytes(detectINT).Length);
                    ns.Flush();
                    channelcount = int.Parse(sa[i - 1].Substring(0, 1));

                    //开始线程接收命令反馈
                    threadReceive = new Thread(new ThreadStart(Order));
                    threadReceive.IsBackground = true;
                    threadReceive.Start();
                    threadReceive.Join();

                    progressBar1.PerformStep();//增加进度条进度
                }
                catch (SocketException)
                {
                    richTextBox1.AppendText(sa[i - 1].Substring(0, 1) + "#装置 " +
                                            SystemConfig.GetConfigData(sa[i - 1].Substring(0, 1) + "#装置", string.Empty) +
                                            " ▼" + System.Environment.NewLine);
                    KeyWordBrush("▼");
                    listBox1.Items.Add(sa[i - 1].Substring(0, 1) + "#装置 连接不可用");
                }
                catch (IOException e1)
                {
                    MessageBox.Show(e1.ToString());
                }
            }
            #endregion
            progressBar1.Visible    = false;//隐藏进度条
            label40.Visible         = false;
            detectConnectbt.Enabled = false;
            if (Dict.Keys.Count != 0)
            {
                DeviceINT();
            }
            // threadConnect.Abort();
        }
Exemplo n.º 2
0
 /// <summary>
 /// 读取项目的XML配置
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnReadConfig_Click(object sender, EventArgs e)
 {
     txtName.Text          = SystemConfig.GetConfigData("UserName", string.Empty);
     txtPassword.Text      = SystemConfig.GetConfigData("Password", string.Empty);
     txtOracleAddress.Text = SystemConfig.GetConfigData("OracleDatebase", string.Empty);
     txtGEOM.Text          = SystemConfig.GetConfigData("GEOM", string.Empty);
     txtPrefix.Text        = SystemConfig.GetConfigData("TablePrefix", string.Empty);
     txtShpName.Text       = SystemConfig.GetConfigData("ShpName", string.Empty);
 }
Exemplo n.º 3
0
        public static void read()
        {
            uint startAddr = 0;

            startAddr = SystemConfig.GetConfigData("DaqAttrTypeXml/StartAddr.xml", "StartAddr", startAddr);
            if (startAddr == 0)
            {
                MessageShow.show("Read StartAddr.xml failed!", "StartAddr.xml获得首地址失败!");
                return;
            }
            DaqAttrType.baseAddr = startAddr;
        }
Exemplo n.º 4
0
        private void ReadFromXML(string file)
        {
            AscanMeasureMap.MaxSingleGateValue  = SystemConfig.GetConfigData(file, "maxSingleGateValue", 0.0);
            AscanMeasureMap.MinSingleGateValue  = SystemConfig.GetConfigData(file, "minSingleGateValue", 0.0);
            AscanMeasureMap.MaxDoubleGatesValue = SystemConfig.GetConfigData(file, "maxDoubleGatesValue", 0.0);
            AscanMeasureMap.MinDoubleGatesValue = SystemConfig.GetConfigData(file, "minDoubleGatesValue", 0.0);

            List <MeasurementData> tmpMapList = (List <MeasurementData>)SystemConfig.ReadBase64Data(file, "measurementDataList");
            List <MapRowDatas>     tmpRowList = (List <MapRowDatas>)SystemConfig.ReadBase64Data(file, "mapRowDataList");

            rebuildMeasureDatas(tmpMapList, tmpRowList);
        }
Exemplo n.º 5
0
        /// <summary>
        /// 输入完成
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button2_Click(object sender, EventArgs e)
        {
            string password = SystemConfig.GetConfigData("Password", string.Empty);

            if (password != textBox1.Text.Trim())
            {
                MessageBox.Show("口令不对,请重新输入!");
                textBox1.Text = "";
                textBox1.Focus();
                return;
            }
            this.DialogResult = DialogResult.OK;
        }
 /// <summary>
 /// 读取接入的装置数
 /// </summary>
 private void EQcounts()
 {
     string[] ew = SystemConfig.GetConfigData("期望装置", string.Empty).Split('|');
     for (int i = 0; i < ew.Length; i++)
     {
         richTextBox1.AppendText(ew[i] + " " + SystemConfig.GetConfigData(ew[i], string.Empty) +
                                 System.Environment.NewLine);
     }
     //int EqCount = int.Parse(SystemConfig.GetConfigData("EqCounts", string.Empty));
     //for (int i = 1; i <= EqCount; i++)
     //{
     //    richTextBox1.AppendText(i.ToString() + "#装置 " + SystemConfig.GetConfigData(i.ToString() + "#装置", string.Empty) +
     //        System.Environment.NewLine);
     //}
 }
        private void SystemSetting_Load(object sender, EventArgs e)
        {
            if (fla)//如果处于连接状态
            {
                groupBox2.Enabled = false;
            }
            else
            {
                groupBox2.Enabled = true;
                EQcounts();
                //detectConnectbt.Enabled = false;
            }
            label40.Visible      = false;
            progressBar1.Visible = false;//隐藏进度条
            //检验IP进度条设置
            progressBar1.Maximum = 100;
            progressBar1.PerformStep();
            setBtnStatus();                                  //设置连接按钮状态
            Dict = new Dictionary <string, List <short> >(); //存放临时数据

            #region 存储时间置初值
            List <string> savetime = new List <string>();//装置名称
            savetime.AddRange(SystemConfig.GetConfigData("SaveTime", string.Empty).Split('|'));
            WindFieldName.Text = SystemConfig.GetConfigData("风场及装置名称", string.Empty).Split('|')[0];
            for (int i = 0; i < comboBox1.Items.Count; i++)
            {
                if (comboBox1.Items[i].ToString() == savetime[0])
                {
                    comboBox1.SelectedIndex = i;
                    break;
                }
            }
            for (int i = 0; i < comboBox2.Items.Count; i++)
            {
                if (comboBox2.Items[i].ToString() == savetime[1])
                {
                    comboBox2.SelectedIndex = i;
                    break;
                }
            }
            #endregion
        }
        /// <summary>
        /// 保存配置
        /// </summary>
        private void DeviceSetSave()
        {
            if (groupBox2.Enabled && (!detectConnectbt.Enabled) && (!saveSetbt.Enabled))
            {
                List <string> deviceName = new List <string>();//固定的。1#装置,2#装置。。。
                foreach (string st in Dict.Keys)
                {
                    deviceName.Add(st);
                }

                List <string> freq         = new List <string>(); //多个装置频率
                List <string> name         = new List <string>(); //装置名称
                List <string> selectDevice = new List <string>(); //选用装置名称

                name.AddRange(SystemConfig.GetConfigData("风场及装置名称", string.Empty).Split('|'));
                int hfhg = 0;
                name[0] = toolStrip1.Items[0].Text;
                #region 遍历第一层
                foreach (var item in ChannelsBt.DropDownItems)
                {
                    if (item is ToolStripMenuItem)
                    {
                        if ((item as ToolStripMenuItem).Checked)
                        {
                            selectDevice.Add(deviceName[hfhg]);
                        }
                        freq.AddRange(SystemConfig.GetConfigData(deviceName[hfhg].Substring(0, 1) + "#装置通道分频数", string.Empty).Split('|'));
                        freq[0] = (ChannelsBt.DropDownItems[1] as ToolStripComboBox).SelectedIndex.ToString();        //总频率

                        name[5 * int.Parse(deviceName[hfhg].Substring(0, 1)) - 4] = (item as ToolStripMenuItem).Text; //装置名称

                        #region 遍历第二层
                        int ddds = 1;
                        foreach (var k in (item as ToolStripMenuItem).DropDownItems)
                        {
                            if (k is ToolStripMenuItem)
                            {
                                name[5 * int.Parse(deviceName[hfhg].Substring(0, 1)) - 4 + ddds] = (k as ToolStripMenuItem).Text;//通道名称

                                #region 遍历第三层
                                foreach (var m in (k as ToolStripMenuItem).DropDownItems)
                                {
                                    if (m is ToolStripComboBox)
                                    {
                                        freq[ddds] = (m as ToolStripComboBox).SelectedIndex.ToString();//分频
                                    }
                                }
                                #endregion
                                ddds++;
                            }
                        }
                        #endregion

                        #region 写入读好的频率
                        string en = freq[0];
                        for (int w = 1; w < freq.Count; w++)
                        {
                            en = en + "|" + freq[w];
                        }
                        SystemConfig.WriteConfigData(deviceName[hfhg].Substring(0, 1) + "#装置通道分频数", en);
                        freq.Clear();
                        #endregion

                        hfhg++;
                    }
                }
                string we = selectDevice[0];
                for (int t = 1; t < selectDevice.Count; t++)
                {
                    we = we + "|" + selectDevice[t];
                }
                SystemConfig.WriteConfigData("选用装置", ""); //清空
                SystemConfig.WriteConfigData("选用装置", we); //用于生成树

                string name1 = name[0];
                for (int t = 1; t < name.Count; t++)
                {
                    name1 = name1 + "|" + name[t];
                }
                SystemConfig.WriteConfigData("风场及装置名称", name1);
                #endregion

                SystemConfig.WriteConfigData("SaveTime", comboBox1.Text + "|" + comboBox2.Text);//存储时间配置
            }
        }
        /// <summary>
        /// 初始化风机名称和采集卡通道采样率
        /// </summary>
        private void DeviceINT()
        {
            List <string> deviceName = new List <string>();//固定的。1#装置,2#装置。。。

            foreach (string st in Dict.Keys)
            {
                deviceName.Add(st);
            }

            #region 一级菜单项
            ToolStripLabel tl = new ToolStripLabel();
            tl.Text = "总采样率:";
            ChannelsBt.DropDownItems.Add(tl);

            ToolStripComboBox tb1 = new ToolStripComboBox();//总采样率下拉菜单
            tb1.ToolTipText           = "装置总采样率";
            tb1.SelectedIndexChanged += new EventHandler(toolStripComboBox_SelectedIndexChanged);
            tb1.AutoCompleteMode      = AutoCompleteMode.SuggestAppend;//智能提示
            tb1.AutoCompleteSource    = AutoCompleteSource.ListItems;
            tb1.Items.AddRange(new object[] {
                "93.75 kHz",
                "46.88 kHz",
                "31.25 kHz",
                "23.44 kHz",
                "18.75 kHz",
                "15.63 kHz",
                "13.39 kHz",
                "11.72 kHz",
                "10.42 kHz",
                " 9.38 kHz"
            });
            tb1.Size          = new System.Drawing.Size(121, 25);
            tb1.Text          = "93.75 kHz";
            tb1.SelectedIndex = int.Parse(SystemConfig.GetConfigData(deviceName[0].Substring(0, 1) +
                                                                     "#装置通道分频数", string.Empty).Split('|')[0]);//读取 总采样频率 的记录
            ChannelsBt.DropDownItems.Add(tb1);

            ToolStripSeparator ts = new ToolStripSeparator();//分割线
            ChannelsBt.DropDownItems.Add(ts);

            List <ToolStripMenuItem> ListTS1 = new List <ToolStripMenuItem>();//存一级菜单中的ToolStripMenuItem,以备添加二级子菜单
            for (int i = 0; i < deviceName.Count; i++)
            {
                ToolStripMenuItem rr = new ToolStripMenuItem(SystemConfig.GetConfigData("风场及装置名称", string.Empty).Split('|')[5 * int.Parse(deviceName[i].Substring(0, 1)) - 4]);
                rr.Checked = true;
                rr.Click  += new EventHandler(ChildToolStripItem_Click);
                ChannelsBt.DropDownItems.Add(rr);
                ListTS1.Add(rr);
            }
            #endregion

            #region 二三级子菜单
            for (int i = 0; i < ListTS1.Count; i++)
            {
                ToolStripTextBox tt2 = new ToolStripTextBox();
                tt2.Text         = ListTS1[i].Text;
                tt2.ToolTipText  = "装置名称";
                tt2.TextChanged += new EventHandler(toolStripTextBox_TextChanged);
                ListTS1[i].DropDownItems.Add(tt2);

                ToolStripSeparator tss = new ToolStripSeparator();
                ListTS1[i].DropDownItems.Add(tss);

                for (int j = 1; j <= 4; j++)
                {
                    ToolStripMenuItem rr = new ToolStripMenuItem(SystemConfig.GetConfigData("风场及装置名称", string.Empty).Split('|')[5 * int.Parse(deviceName[i].Substring(0, 1)) - 4 + j]);
                    ListTS1[i].DropDownItems.Add(rr);

                    #region  级子菜单
                    ToolStripTextBox tt3 = new ToolStripTextBox();
                    tt3.ToolTipText  = "通道名称";
                    tt3.Text         = rr.Text;
                    tt3.TextChanged += new EventHandler(toolStripTextBox_TextChanged);
                    rr.DropDownItems.Add(tt3);

                    ToolStripComboBox tb3 = new ToolStripComboBox();
                    tb3.AutoCompleteMode   = AutoCompleteMode.SuggestAppend;//智能提示
                    tb3.AutoCompleteSource = AutoCompleteSource.ListItems;
                    tb3.Items.AddRange(new object[] {
                        "93.75 kHz",
                        "46.88 kHz",
                        "31.25 kHz",
                        "23.44 kHz",
                        "18.75 kHz",
                        "15.63 kHz",
                        "13.39 kHz",
                        "11.72 kHz",
                        "10.42 kHz",
                        " 9.38 kHz"
                    });
                    tb3.Size        = new System.Drawing.Size(121, 25);
                    tb3.Text        = "93.75 kHz";
                    tb3.ToolTipText = "通道采样率";
                    rr.DropDownItems.Add(tb3);
                    int sssasad = tb1.SelectedIndex;
                    for (int b = 0; b < sssasad; b++)
                    {
                        tb3.Items.RemoveAt(0);
                    }
                    tb3.SelectedIndex = int.Parse(SystemConfig.GetConfigData(deviceName[i].Substring(0, 1) +
                                                                             "#装置通道分频数", string.Empty).Split('|')[j]);
                    #endregion
                }
            }

            #endregion
        }
Exemplo n.º 10
0
        /// <summary>
        /// 线程,检验采集卡是否能连接
        /// </summary>
        private void Order()
        {
            #region 检验IP
            while (true)
            {
                try
                {
                    byte[] detOrdRecvByt = new byte[8];
                    int    recv          = ns.Read(detOrdRecvByt, 0, detOrdRecvByt.Length);
                    if (recv == 0)
                    {
                        MessageBox.Show("未接受到命令反馈!");
                        continue;
                    }
                    detectREC = Encoding.UTF8.GetChars(detOrdRecvByt, 0, detOrdRecvByt.Length);
                    if ((detectREC[0] == 'A') && (detectREC[1] == 'C') && (detectREC[2] == 'K'))
                    {
                        #region 可用
                        if ((detectINT[0] == 'I') && (detectREC[7] != (char)0))
                        {
                            List <short> zwsList = new List <short>();
                            zwsList.Add(Convert.ToInt16(detectREC[4])); //转速个数
                            zwsList.Add(Convert.ToInt16(detectREC[5])); //温度个数
                            zwsList.Add(Convert.ToInt16(detectREC[6])); //湿度个数
                            zwsList.Add(Convert.ToInt16(detectREC[7])); //通道个数
                            Dict.Add(channelcount.ToString() + "#装置", zwsList);
                            zwsList = null;

                            richTextBox1.AppendText(channelcount.ToString() + "#装置 " +
                                                    SystemConfig.GetConfigData(channelcount.ToString() + "#装置", string.Empty) +
                                                    " ▲" + System.Environment.NewLine);
                            KeyWordBrush("▲");
                            // conNodechanel.Add(channelcount.ToString() + "#装置", Convert.ToInt16(detectREC[7])); ---------------------------------------
                            listBox1.Items.Add(channelcount.ToString() + "#装置 " + Convert.ToInt16(detectREC[7]).ToString() + "个通道可用");
                            //// ns.Close();
                            //client.Client.Close();
                            ////ns.Dispose();
                            //client.Client.Dispose();
                        }
                        #endregion

                        #region  可用
                        if ((detectINT[0] == 'I') && (detectREC[7] == (char)0))//
                        {
                            richTextBox1.AppendText(channelcount.ToString() + "#装置 " +
                                                    SystemConfig.GetConfigData(channelcount.ToString() + "#装置", string.Empty) +
                                                    " ▼" + System.Environment.NewLine);
                            KeyWordBrush("▼");
                            // conNodechanel.Add(channelcount.ToString() + "#装置", Convert.ToInt16(detectREC[7]));
                            listBox1.Items.Add(channelcount.ToString() + "#装置 没有通道可用");
                            //// ns.Close();
                            //client.Client.Close();
                            ////ns.Dispose();
                            //client.Client.Dispose();
                        }
                        #endregion
                        detectREC = null;
                        break;
                    }
                }
                catch (SocketException)
                {
                    throw;
                }
                catch (IOException)
                {
                }
                //continue;
            }
            #endregion
            threadReceive.Abort();
            client.Close();
            client = null;
        }
Exemplo n.º 11
0
        /// <summary>
        /// 系统帮助
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnHelp_Click(object sender, EventArgs e)
        {
            String help = SystemConfig.GetConfigData("help", string.Empty);

            MessageBox.Show(help, "帮助-By rongc,光光聂", MessageBoxButtons.OK);
        }
Exemplo n.º 12
0
        private void buttonConfirm_Click(object sender, EventArgs e)
        {
            oldName     = SystemConfig.GetConfigData("UserID", string.Empty);
            oldPassword = SystemConfig.GetConfigData("Password", string.Empty);

            #region 判断输入是否有错
            if ((txtBoxOldname.Text.Trim().Equals(string.Empty)) | (oldName != txtBoxOldname.Text))
            {
                errorProvider1.SetError(txtBoxOldname, "用户名有误,请重新输入"); //显示错误的提示信息
                MessageBox.Show("用户名有误,请重新输入");
                txtBoxOldname.Text     = null;
                txtBoxOldPassword.Text = null;
                txtBoxNewname.Text     = null;
                txtBoxNewPassword.Text = null;
                txtBoxConfirm.Text     = null;
                txtBoxOldname.Focus();
                return;
            }
            if ((txtBoxOldPassword.Text.Trim().Equals(string.Empty)) | (oldPassword != txtBoxOldPassword.Text))
            {
                errorProvider1.SetError(txtBoxOldPassword, "密码有误,请重新输入"); //显示错误的提示信息
                MessageBox.Show("密码有误,请重新输入");
                txtBoxOldPassword.Text = null;
                txtBoxNewname.Text     = null;
                txtBoxNewPassword.Text = null;
                txtBoxConfirm.Text     = null;
                txtBoxOldPassword.Focus();
                return;
            }
            if (txtBoxNewname.Text.Trim().Equals(string.Empty))
            {
                errorProvider1.SetError(txtBoxNewname, "用户名为空,请重新输入"); //显示错误的提示信息
                MessageBox.Show("用户名为空,请重新输入");
                txtBoxNewPassword.Text = null;
                txtBoxConfirm.Text     = null;
                txtBoxNewname.Focus();
                return;
            }
            if (txtBoxNewPassword.Text.Trim().Equals(string.Empty))
            {
                errorProvider1.SetError(txtBoxNewPassword, "新密码为空,请重新输入"); //显示错误的提示信息
                MessageBox.Show("新密码为空,请重新输入");
                txtBoxConfirm.Text = null;
                txtBoxNewPassword.Focus();
                return;
            }
            if (txtBoxConfirm.Text.Trim().Equals(string.Empty))
            {
                errorProvider1.SetError(txtBoxConfirm, "不能为空,请重新输入"); //显示错误的提示信息
                MessageBox.Show("不能为空,请重新输入");
                txtBoxConfirm.Text = null;
                txtBoxConfirm.Focus();
                return;
            }
            if (txtBoxConfirm.Text != txtBoxNewPassword.Text)
            {
                errorProvider1.SetError(txtBoxNewPassword, "两次输入密码不一致"); //显示错误的提示信息
                MessageBox.Show("两次输入密码不一致");
                txtBoxNewPassword.Text = null;
                txtBoxConfirm.Text     = null;
                txtBoxConfirm.Focus();
                return;
            }
            #endregion

            SystemConfig.WriteConfigData("UserID", txtBoxNewname.Text.Trim());
            SystemConfig.WriteConfigData("Password", txtBoxNewPassword.Text.Trim());
            this.Close();
            GC.Collect();
        }