Esempio n. 1
0
 public string[] read()
 {
     string[] Setting = new string[24];
     try
     {
         INIHelper     ini     = new INIHelper(@"./CurrStandard.ini", "Demo");
         List <string> keyList = new List <string>();
         for (int i = 1; i < 7; i++)
         {
             string s1 = "Item" + i + "_HeadH";
             string s2 = "Item" + i + "_HeadL";
             string s3 = "Item" + i + "_TailH";
             string s4 = "Item" + i + "_TailL";
             keyList.Add(s1);
             keyList.Add(s2);
             keyList.Add(s3);
             keyList.Add(s4);
         }
         string[] Key = keyList.ToArray();
         ini.read(Key, out Setting);
     }
     catch (Exception)
     {
         MessageBox.Show("读取曲线范围出错", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return(null);
     }
     return(Setting);
 }
Esempio n. 2
0
        private void FormTest_Load(object sender, EventArgs e)
        {
            string[] s = new string[]
            {
                textBox5.Text,
                textBox6.Text,
                textBox7.Text,
                textBox8.Text,
                textBox9.Text
            };
            string[] key = new string[]
            {
                label5.Text,
                label6.Text,
                label7.Text,
                label8.Text,
                label9.Text
            };

            INIHelper iniHelper = new INIHelper();

            iniHelper.read(key, out s);
            textBox5.Text = s[0];
            textBox6.Text = s[1];
            textBox7.Text = s[2];
            textBox8.Text = s[3];
            textBox9.Text = s[4];
        }
Esempio n. 3
0
        private void FormTestNew_Load(object sender, EventArgs e)
        {
            INIHelper iniHelper = new INIHelper();

            string[] enPlcSetting = new string[1];
            string[] enPlcKey     = { "0" };
            iniHelper.read(enPlcKey, out enPlcSetting);
            enablePLC = enPlcSetting[0] == "a";
            try
            {
                opc.Init();
                labelResult.BackColor = Color.Green;
                labelResult.Text      = "PLC已连接";
            }
            catch (Exception ex)
            {
                labelResult.BackColor = Color.Red;
                labelResult.Text      = "PLC未连接";
            }

            Thread th = new Thread(physicalButtonCheck);

            th.IsBackground = true;
            th.Start();

            //checkedListBox1全部选中
            for (int i = 0; i < this.checkedListBox1.Items.Count; i++)
            {
                this.checkedListBox1.SetItemChecked(i, true);
            }
            addProgressBar();
            controlEnable(Administrator);
        }
Esempio n. 4
0
        public bool comOpen()
        {
            INIHelper ini = new INIHelper(@"./StartBtnCOM.ini", "Demo");

            string[] iniSetting = new string[1];
            string[] iniKey     = { "Item1" };
            ini.read(iniKey, out iniSetting);
            bool isFindCOM = false;

            for (int i = 0; i < cbbComList.Items.Count; i++)
            {
                if (cbbComList.Items[i].ToString() == iniSetting[0])
                {
                    cbbComList.SelectedIndex = i;
                    isFindCOM = true;
                    break;
                }
            }
            if (isFindCOM)
            {
                cbbBaudRate.SelectedIndex   = 5;
                cbbDataBits.SelectedIndex   = 0;
                cbbParity.SelectedIndex     = 0;
                cbbStopBits.SelectedIndex   = 0;
                pictureBox1.BackgroundImage = Properties.Resources.red;
                btnOpen_Click(this, null);
                return(true);
            }
            else
            {
                MessageBox.Show("没有找到启动按钮的:" + iniSetting[0], "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }
        }
Esempio n. 5
0
        private void FormProductSetting_Load(object sender, EventArgs e)
        {
            INIHelper iniHelper = new INIHelper();

            string[] FolderShareSetting = new string[10];
            string[] FolderShareKey     = { "FolderSharePath", "User", "Password", "Local", "FolderSharePath2", "User2", "Password2", "FolderSharePath3", "User3", "Password3" };
            iniHelper.read(FolderShareKey, out FolderShareSetting);
            textBox1.Text        = FolderShareSetting[0];
            textBox2.Text        = FolderShareSetting[1];
            textBox3.Text        = FolderShareSetting[2];
            radioButton1.Checked = FolderShareSetting[3] == "True";
            radioButton2.Checked = FolderShareSetting[3] == false.ToString();
            textBox6.Text        = FolderShareSetting[4];
            textBox5.Text        = FolderShareSetting[5];
            textBox4.Text        = FolderShareSetting[6];
            textBox9.Text        = FolderShareSetting[7];
            textBox8.Text        = FolderShareSetting[8];
            textBox7.Text        = FolderShareSetting[9];
        }
Esempio n. 6
0
        public List <List <float> > readCSVgetCurrent(List <List <string> > pressure, string fileName, List <List <string> > currStandardData, List <List <string> > currStandardDataSearch)
        {
            List <List <float> > dataList;
            int lineCount = pressure.Count;
            List <List <float> > current = new List <List <float> >();

            for (int i = 0; i < lineCount; i++)
            {
                List <float> l = new List <float>();
                current.Add(l);
            }
            string[] tag = File.ReadAllLines(@".\SearchString.txt");
            if (tag.Length != 24)
            {
                string errormsg = "SearchString.txt文件中数据应为24行!";
                throw new Exception(errormsg);
            }
            //MessageBox.Show("pre open", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
            dataList = CSVHelper.OpenCSV(fileName, tag);
            for (int i = 0; i < dataList.Count; i++)
            {
                if (dataList[i].Count <= 0)
                {
                    string errormsg = "SearchString.txt中" + (i + 1) + "行(" + tag[i] + ")在原始数据里没有找到";
                    throw new Exception(errormsg);
                }
            }
            //MessageBox.Show("tail open", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
            //start
            INIHelper ini = new INIHelper(@"./CurrStandard.ini", "Demo");

            string[] iniKey     = { "PinkValue" };
            string[] iniSetting = new string[1];
            ini.read(iniKey, out iniSetting);
            for (int i = 0; i < dataList.Count / 4; i++)
            {
                float[] x  = dataList[i * 4].ToArray();
                float[] y  = dataList[i * 4 + 1].ToArray();
                float[] xx = dataList[i * 4 + 2].ToArray();
                float[] yy = dataList[i * 4 + 3].ToArray();
                for (int k = 0; k < x.Length; k++)
                {
                    x[k] = x[k] / 1000;
                }
                for (int k = 0; k < xx.Length; k++)
                {
                    xx[k] = xx[k] / 1000;
                }
                for (int j = 0; j < pressure[i].Count; j++)
                {
                    //MessageBox.Show("average pre", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    AverageXAverageY a      = new BXHSerialPort.AverageXAverageY();
                    float            v1     = 0;
                    float            v2     = 0;
                    bool             v1Find = a.ifFind(x, y, pressure[i][j], currStandardDataSearch[i][j]);
                    bool             v2Find = a.ifFind(xx, yy, pressure[i][j], currStandardDataSearch[i][j]);
                    if (v1Find || v2Find)
                    {
                        v2 = a.getAverageX(xx, yy, pressure[i][j], currStandardData[i][j], currStandardDataSearch[i][j]);
                        v1 = a.getAverageX(x, y, pressure[i][j], currStandardData[i][j], currStandardDataSearch[i][j]);
                    }
                    //else if (v1Find&&(!v2Find))
                    //{
                    //    v1 = a.getAverageX(x, y, pressure[i][j], currStandardData[i][j], currStandardDataSearch[i][j]);
                    //    v2 = v1;
                    //    v2 = a.getAverageX(xx, yy, pressure[i][j], currStandardData[i][j], currStandardDataSearch[i][j]);
                    //}
                    //else if ((!v1Find) && v2Find)
                    //{
                    //    v2 = a.getAverageX(xx, yy, pressure[i][j], currStandardData[i][j], currStandardDataSearch[i][j]);
                    //    v1 = v2;
                    //    v1 = a.getAverageX(x, y, pressure[i][j], currStandardData[i][j], currStandardDataSearch[i][j]);
                    //}
                    else
                    {
                        string errormsg = "没有搜索到这个压力数据:" + pressure[i][j] + "";
                        throw new Exception(errormsg);
                    }
                    //MessageBox.Show("shuju", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    float resultValue = (v1 + v2) / 2;
                    if ((currStandardDataSearch[i][j] != "55") && (currStandardDataSearch[i][j] != "66") && (pressure[i][j] != "NA"))
                    {
                        float currStand;
                        float pinkValue;
                        try
                        {
                            currStand = Convert.ToSingle(currStandardData[i][j]);
                            pinkValue = Convert.ToSingle(iniSetting[0]);
                        }
                        catch (Exception)
                        {
                            string errormsg = "判断粉色部分的数据值,标准电流:" + currStandardData[i][j] + ",行:" + (i + 1) + "第" + (j + 1) + "个数据" + ",差值基准:" + iniSetting[0];
                            throw new Exception(errormsg);
                        }
                        float abs = Math.Abs(resultValue - currStand);
                        if (abs > pinkValue)
                        {
                            string errormsg = "(粉色部分的数据值 - TCU内部标准值) =差值的绝对值 > " + pinkValue + ",\n行:" + (i + 1) + "第" + (j + 1) + "个数据,压力值:" + pressure[i][j] + ",计算值:" + resultValue + ",标准值:" + currStandardData[i][j];
                            throw new Exception(errormsg);
                        }
                    }
                    current[i].Add(resultValue);
                }
            }
            //end

            return(current);
        }