예제 #1
0
        static string Replace(MaterielData data)
        {
            StringBuilder sb = new StringBuilder();

            Append(sb, data.MatNo);
            Append(sb, data.BarCode);
            Append(sb, data.Info);
            Append(sb, data.CameraAddress);
            Append(sb, data.Exposure);
            Append(sb, data.Gain);
            Append(sb, data.FindLineX);
            Append(sb, data.FindLineY);
            Append(sb, data.FindLindHigh);
            Append(sb, data.FindLineWide);
            Append(sb, data.FindLineEdge);
            Append(sb, data.FindLineThreshold);
            Append(sb, data.BarCodeX);
            Append(sb, data.BarCodeY);
            Append(sb, data.BarCodeHigh);
            Append(sb, data.BarCodeWide);

            Append(sb, data.FindLineX_100);
            Append(sb, data.FindLineY_100);
            Append(sb, data.FindLindHigh_100);
            Append(sb, data.FindLineWide_100);
            Append(sb, data.FindLineTs_100);
            Append(sb, data.FindLineEdge_100);
            Append(sb, data.FindLineTs_100L);
            Append(sb, data.FindLineEdge_100L);
            Append(sb, data.Limit);
            sb.Append(data.LowerLimit);
            return(sb.ToString());
        }
예제 #2
0
 public MaterielEdit(Action <MaterielData, int> editAction, List <MaterielData> list, MaterielData data)
 {
     InitializeComponent();
     this.list       = list;
     this.data       = data;
     this.editAction = editAction;
 }
예제 #3
0
        string StringFormat(MaterielData data)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append(data.MatNo);
            sb.Append(":" + data.BarCode);
            sb.Append(":" + data.CameraAddress);
            sb.Append(":" + data.Info);
            sb.Append(":" + data.Exposure);
            sb.Append(":" + data.Gain);
            sb.Append(":" + data.FindLineX);
            sb.Append(":" + data.FindLineY);
            sb.Append(":" + data.FindLindHigh);
            sb.Append(":" + data.FindLineWide);
            sb.Append(":" + data.FindLineEdge);
            sb.Append(":" + data.FindLineThreshold);
            sb.Append(":" + data.BarCodeX);
            sb.Append(":" + data.BarCodeY);
            sb.Append(":" + data.BarCodeHigh);
            sb.Append(":" + data.BarCodeWide);

            sb.Append(":" + data.FindLineX_100);     //	100ml找边区域X坐标
            sb.Append(":" + data.FindLineY_100);     //	100ml找边区域Y坐标
            sb.Append(":" + data.FindLindHigh_100);  //	100ml找边区域高度
            sb.Append(":" + data.FindLineWide_100);  //	100ml找边区域宽度
            sb.Append(":" + data.FindLineTs_100);    //	100ml找边瓶盖阈值
            sb.Append(":" + data.FindLineEdge_100);  //	100ml瓶盖边宽度
            sb.Append(":" + data.FindLineTs_100L);   //	100ml标签找边阈值
            sb.Append(":" + data.FindLineEdge_100L); //	100ml标签边宽度
            sb.Append(":" + data.Limit);
            sb.Append(":" + data.LowerLimit);

            return(sb.ToString());
        }
예제 #4
0
 void LoadInitCameraData(MonitorViewTab monitorViewTab, MaterielData data)
 {
     if (monitorViewTab.LeftMonitorView.CameraAddress.Equals(data.CameraAddress))
     {
         monitorViewTab.LeftMonitorView.Data = data;
         monitorViewTab.LeftMonitorView.LoadData();
     }
     if (monitorViewTab.RightMonitorView.CameraAddress.Equals(data.CameraAddress))
     {
         monitorViewTab.RightMonitorView.Data = data;
         monitorViewTab.RightMonitorView.LoadData();
     }
 }
예제 #5
0
        private void MaterielEdit_Load(object sender, EventArgs e)
        {
            if (data != null)
            {
                wlhTextBox.Text      = data.MatNo;
                InfoTextBox.Text     = data.Info;
                CameraIpTextBox.Text = data.CameraAddress;
                ewmTextBox.Text      = data.BarCode;
                bgsjTextBox.Text     = data.Exposure;
                zyTextBox.Text       = data.Gain;
                zbxTextBox.Text      = data.FindLineX;
                zbyTextBox.Text      = data.FindLineY;
                zbgdTextBox.Text     = data.FindLindHigh;
                zbkdTextBox.Text     = data.FindLineWide;
                bkdTextBox.Text      = data.FindLineEdge;
                zbyzTextBox.Text     = data.FindLineThreshold;
                ewmxzTextBox.Text    = data.BarCodeX;
                ewmyzTextBox.Text    = data.BarCodeY;
                ewmgdTextBox.Text    = data.BarCodeHigh;
                ewmkdTextBox.Text    = data.BarCodeWide;

                zbx100TextBox.Text    = data.FindLineX_100;
                zby100TextBox.Text    = data.FindLineY_100;
                zbgd100TextBox.Text   = data.FindLindHigh_100;
                zbkd100TextBox.Text   = data.FindLineWide_100;
                pgzbyz100TextBox.Text = data.FindLineTs_100;
                pgbkd100TextBox.Text  = data.FindLineEdge_100;
                bqbyz100TextBox.Text  = data.FindLineTs_100L;
                bqbkd100TextBox.Text  = data.FindLineEdge_100L;
                bqsxyzTextBox.Text    = data.Limit;
                bqxxyzTextBox.Text    = data.LowerLimit;

                IsAdd     = false;
                editIndex = list.IndexOf(data);
            }
            else
            {
                data      = new MaterielData();
                IsAdd     = true;
                editIndex = list.Count;
            }
        }
예제 #6
0
        private void EditMaterielData(MaterielData data, int editIndex)
        {
            LoadData();
            return;

            if (add)
            {
                //if (materielDataMap.ContainsKey(data.MatNo))
                //{
                //    materielDataMap[data.MatNo].Add(data);
                //}
                //else
                //{
                //    List<MaterielData> list = new List<MaterielData>();
                //   list.Add(data);
                //   materielDataMap.Add(data.MatNo, list);
                //}
                LoadData();//增加物料编号全部刷新
                return;
            }
            listView1.Items[selectIndex].SubItems[1].Text  = data.BarCode;
            listView1.Items[selectIndex].SubItems[2].Text  = data.CameraAddress;
            listView1.Items[selectIndex].SubItems[3].Text  = data.Info;
            listView1.Items[selectIndex].SubItems[4].Text  = data.Exposure;
            listView1.Items[selectIndex].SubItems[5].Text  = data.Gain;
            listView1.Items[selectIndex].SubItems[6].Text  = data.FindLineX;
            listView1.Items[selectIndex].SubItems[7].Text  = data.FindLineY;
            listView1.Items[selectIndex].SubItems[8].Text  = data.FindLindHigh;
            listView1.Items[selectIndex].SubItems[9].Text  = data.FindLineWide;
            listView1.Items[selectIndex].SubItems[10].Text = data.FindLineEdge;
            listView1.Items[selectIndex].SubItems[11].Text = data.FindLineThreshold;
            listView1.Items[selectIndex].SubItems[12].Text = data.BarCodeX;
            listView1.Items[selectIndex].SubItems[13].Text = data.BarCodeY;
            listView1.Items[selectIndex].SubItems[14].Text = data.BarCodeHigh;
            listView1.Items[selectIndex].SubItems[15].Text = data.BarCodeWide;
            listView1.Items[selectIndex].SubItems[16].Text = data.Limit;
            listView1.Items[selectIndex].SubItems[17].Text = data.LowerLimit;
        }
예제 #7
0
        public static void WriteExcelByText(MaterielData materielData)
        {
            if (materielData == null)
            {
                return;
            }
            string     path     = AppSetting.EXCEL_PATH;
            string     tempPath = AppSetting.EXCEL_TEMP_PATH;
            FileStream fsRead   = null;

            try
            {
                fsRead = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Delete);
            }
            catch (Exception ex)
            {
                MessageBox.Show("保存到excel表格失败!请先关闭Excel表格占用进程!");
                return;
            }
            try
            {
                FileStream   fsWrite = new FileStream(tempPath, FileMode.Create, FileAccess.Write, FileShare.ReadWrite);
                StreamReader sr      = new StreamReader(fsRead, System.Text.Encoding.GetEncoding("gb2312"));
                StreamWriter sw      = new StreamWriter(fsWrite, System.Text.Encoding.GetEncoding("gb2312"));
                string       line    = sr.ReadLine();
                if (line != null)
                {
                    sw.WriteLine(line);
                }
                while (line != null)
                {
                    line = sr.ReadLine();
                    if (line != null)
                    {
                        string[] cells = line.Split(',');
                        if (cells[0].Equals(materielData.MatNo) && cells[3].Equals(materielData.CameraAddress))
                        {
                            string newLine = Replace(materielData);
                            sw.WriteLine(newLine);
                        }
                        else
                        {
                            sw.WriteLine(line);
                        }
                    }
                }
                sw.WriteLine();
                sw.Flush();
                sw.Close();
                sr.Close();
                fsRead.Close();
                fsWrite.Close();
                File.Delete(path);
                File.Move(tempPath, path);
            }
            catch (Exception e)
            {
                MessageBox.Show("保存失败:" + e);
            }
            MessageBox.Show("保存成功!");
        }
예제 #8
0
        public static List <MaterielData> ReadExcelByText()
        {
            string path = AppSetting.EXCEL_PATH;

            if (!File.Exists(path))
            {
                MessageBox.Show("物料excel表不存在,请检查!");
                return(null);
            }
            FileStream          fs   = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
            StreamReader        sr   = new StreamReader(fs, System.Text.Encoding.GetEncoding("gb2312"));
            List <MaterielData> list = new List <MaterielData>();

            try
            {
                string line = sr.ReadLine();
                while (line != null)
                {
                    line = sr.ReadLine();
                    if (line != null)
                    {
                        string[] cells = line.Split(',');
                        if (cells[0].Equals("111"))
                        {
                            int a = 0;
                        }
                        if (cells.Length < 18)
                        {
                            continue;
                        }
                        MaterielData data = new MaterielData();
                        data.MatNo             = cells[0];
                        data.BarCode           = cells[1];
                        data.Info              = cells[2];
                        data.CameraAddress     = cells[3];
                        data.Exposure          = cells[4];
                        data.Gain              = cells[5];
                        data.FindLineX         = cells[6];
                        data.FindLineY         = cells[7];
                        data.FindLindHigh      = cells[8];
                        data.FindLineWide      = cells[9];
                        data.FindLineEdge      = cells[10];
                        data.FindLineThreshold = cells[11];
                        data.BarCodeX          = cells[12];
                        data.BarCodeY          = cells[13];
                        data.BarCodeHigh       = cells[14];
                        data.BarCodeWide       = cells[15];


                        data.FindLineX_100     = cells[16];
                        data.FindLineY_100     = cells[17];
                        data.FindLindHigh_100  = cells[18];
                        data.FindLineWide_100  = cells[19];
                        data.FindLineTs_100    = cells[20];
                        data.FindLineEdge_100  = cells[21];
                        data.FindLineTs_100L   = cells[22];
                        data.FindLineEdge_100L = cells[23];
                        data.Limit             = cells[24];
                        data.LowerLimit        = cells[25];


                        list.Add(data);
                    }
                }
                fs.Flush();
                sr.Close();
                fs.Close();
            }
            catch (Exception e)
            {
                MessageBox.Show("物料excel表读取失败:" + e);
                return(null);
            }
            return(list);
        }