Пример #1
0
 public Form1()
 {
     InitializeComponent();
     this.StartPosition = FormStartPosition.CenterScreen; //窗口居中
     t = new Thread(receive_data);                        //启动UDP数据接收线程
     for (int i = 0; i < 5; i++)
     {
         string s;
         s           = "D:\\detect\\ch";
         s          += (i + 1).ToString();
         s          += GetTimeStamp();
         s          += ".log";
         rec_file[i] = new FileStream(s, FileMode.Create, FileAccess.Write);
     }
     for (int i = 0; i < 5; i++)
     {
         ch[i]       = new detect();
         errIndex[i] = new List <int>();
     }
     t.Start();
 }
Пример #2
0
        private void button4_Click(object sender, EventArgs e)//开始停止
        {
            isStart = !isStart;
            if (isStart)
            {
                form3 = new Form3();
                if (!form3.succuss)
                {
                    isStart              = !isStart;
                    displayTextBox.Text += GetTimeStamp1();
                    displayTextBox.Text += "系统未开始\n";
                    return;
                }
                button4.Text         = "停止";
                displayTextBox.Text += GetTimeStamp1();
                displayTextBox.Text += "批次";
                displayTextBox.Text += form3.name;
                displayTextBox.Text += "纸张已开始检测...";
                displayTextBox.Text += "\n";
                for (int i = 0; i < 5; i++)
                {
                    string s;
                    s           = "D:\\detect\\";
                    s          += form3.name;
                    s          += "ch";
                    s          += (i + 1).ToString();
                    s          += GetTimeStamp();
                    s          += ".log";
                    rec_file[i] = new FileStream(s, FileMode.Create, FileAccess.Write);
                    if (detect.isallwrite)
                    {
                        string all;
                        all            = "D:\\detect\\all";
                        all           += form3.name;
                        all           += "ch";
                        all           += (i + 1).ToString();
                        all           += GetTimeStamp();
                        all           += ".log";
                        recall_file[i] = new FileStream(all, FileMode.Create, FileAccess.Write);
                    }
                }

                t = new Thread(receive_data);  //启动UDP数据接收线程
                for (int i = 0; i < 5; i++)
                {
                    ch[i]       = new detect();
                    errIndex[i] = new List <int>();
                    recData[i]  = new List <short>();
                }
                button1.Enabled          = false;
                zedGraphControl1.Enabled = false;
                button3.Enabled          = false;
                checkBox1.Enabled        = false;
                t.Start();
                fileopendflag = 0;
            }
            else
            {
                button4.Text             = "开始";
                displayTextBox.Text     += GetTimeStamp1();
                displayTextBox.Text     += "系统已停止。";
                displayTextBox.Text     += "\n";
                threadEnd                = true;
                button1.Enabled          = true;
                zedGraphControl1.Enabled = true;
                checkBox1.Enabled        = true;
                button3.Enabled          = true;
                for (int i = 0; i < 5; i++)
                {
                    rec_file[i].Close();
                    if (detect.isallwrite)
                    {
                        recall_file[i].Close();
                    }
                }
            }
        }
Пример #3
0
        public void createPane(ZedGraphControl zgc)  //创建波形
        {
            myPane = zgc.GraphPane;
            myPane.CurveList.Clear();
            list1     = new PointPairList();
            chOffline = new detect();
            listView.Clear();
            listViewChangedFlag = 0;
            listViewLastCount   = 0;
            this.listView1.Items.Clear();
            myPane.YAxis.Scale.Min = 0;
            myPane.YAxis.Scale.Max = 25000;
            myPane.XAxis.Scale.Min = 0;
            myPane.XAxis.Scale.Max = 5000;
            PointPairList listMaxH = new PointPairList();
            PointPairList listMaxL = new PointPairList();
            PointPairList listerr  = new PointPairList();
            int           type;
            short         temp_filted = 0, temp_filtedLastLast = 0, temp_filtedLast = 0;
            int           errmCnt = 0;
            int           pointCnt = 0, pointCount = 0;;
            int           bill_no = 0;
            int           no      = 0;
            int           errType = 0;

            for (int i = 0; i < buffer.Count(); i++)
            {
                temp_filted = chOffline.filter(buffer[i]);
                temp_filted = chOffline.filter2(temp_filted);
                list1.Add(i, temp_filted);
                type = chOffline.isExtemum(temp_filted);

                if ((type == 1) || (type == 3))//小极大值
                {
                    listMaxH.Add(i - 2, temp_filtedLastLast);
                }
                else if (type == 2)//大极大值
                {
                    listMaxL.Add(i - 2, temp_filtedLastLast);
                }
                else if (type < 0)
                {
                    listerr.Add(i - 2, temp_filtedLastLast);
                    errType = 0 - type;
                    errmCnt++;
                }

                if ((type == 1) || (type == 3) || (type == 2))
                {
                    pointCount = pointCnt;
                }
                if ((type == 10) || (type == -10))
                {
                    bill_no++;
                    pointCnt = 0;
                    listEndPoint.Add(i - 2);

                    if (errmCnt > 0)
                    {
                        no++;
                        string[] listViewString = new string[4];
                        listViewString[0]  = no.ToString();
                        listViewString[1]  = bill_no.ToString();
                        listViewString[2]  = getChannel(this.openfilename);
                        listViewString[3]  = "判据";
                        listViewString[3] += errType.ToString();
                        listView.Add(new ListViewItem(listViewString));
                        listViewChangedFlag = 1;
                        // this.listView1.Items.Add(listView[listView.Count-1]);
                        errmCnt = 0;
                        errType = 0;
                    }
                    else //好周期
                    {
                    }
                    errmCnt = 0;
                }
                temp_filtedLastLast = temp_filtedLast;
                temp_filtedLast     = temp_filted;
                //if (i < 10)
                //{
                //    listView.Add(new ListViewItem(new string[] { "1", "1", "bbbb", "aaaa" }));
                //    this.listView1.Items.Add(listView[i]);
                //}
            }
            //createPane(zedGraphControl1);
            numericUpDown1.Maximum = listEndPoint.Count;
            myPane.YAxis.Scale.Min = 0;
            myPane.YAxis.Scale.Max = 50000;
            if (listEndPoint.Count != 0)
            {
                myPane.XAxis.Scale.Min = listEndPoint[0] - 5000;
                myPane.XAxis.Scale.Max = listEndPoint[Math.Min(listEndPoint.Count - 1, 50)];
            }
            else
            {
                myPane.XAxis.Scale.Min = 0;
                myPane.XAxis.Scale.Max = 60000;
            }


            textBox1.Text = bill_no.ToString();

            myPane = zedGraphControl1.GraphPane;
            myPane.CurveList.Clear();
            LineItem myCurve  = myPane.AddCurve("原始数据", list1, Color.Red, SymbolType.None);
            LineItem myCurveH = myPane.AddCurve("极大值", listMaxH, Color.Green, SymbolType.Star);

            myCurveH.Line.Color = Color.White;
            LineItem myCurveL = myPane.AddCurve("极小值", listMaxL, Color.Blue, SymbolType.Circle);

            myCurveL.Line.Color = Color.White;
            LineItem myCurveErr2 = myPane.AddCurve("错误点", listerr, Color.Coral, SymbolType.Circle);

            myCurveErr2.Line.Color             = Color.White;
            zedGraphControl1.IsShowPointValues = true; //当鼠标经过时,显示点的坐标。
            zedGraphControl1.AxisChange();             //画到zedGraphControl1控件中,此句必加
            Refresh();                                 //重绘控件
        }