コード例 #1
0
        private void ReadPointsData()
        {
            string[] dat = null;
            point.x1   = "";
            point.z1   = "";
            point.y    = "";
            point.x2   = "";
            point.z2   = "";
            pointIndex = 0;

            for (int i = 0; i < 30; i++)     //读取30个点
            {
                dat = comm.ReadDMDat(dm2000 + pointIndex * 2);

                if (dat != null)
                {
                    point.x1 = dat[0];
                }

                dat = comm.ReadDMDat(dm2000 + 100 + pointIndex * 2);

                if (dat != null)
                {
                    point.z1 = dat[0];
                }

                dat = comm.ReadDMDat(dm2000 + 200 + pointIndex * 2);

                if (dat != null)
                {
                    point.y = dat[0];
                }

                if (Product.CurProduct == Product.ProductEnum.Product001)
                {
                    dat = comm.ReadDMDat(dm2000 + 300 + pointIndex * 2);

                    if (dat != null)
                    {
                        point.x2 = dat[0];
                    }

                    dat = comm.ReadDMIntDat(dm2000 + 400 + pointIndex * 2);

                    if (dat != null)
                    {
                        point.z2 = dat[0];
                    }
                }
                else if (Product.CurProduct == Product.ProductEnum.Product002)
                {
                    dat = comm.ReadDMIntDat(dm2000 + 400 + pointIndex * 2);

                    if (dat != null)
                    {
                        point.x2 = dat[0];
                    }
                }

                pointsList.Add(point);
                pointIndex++;
                //加载读取到的点位信息到表格中去
                int col = i + 1;
                dataGridView1.Rows[0].Cells[col].Value = point.x1;
                dataGridView1.Rows[1].Cells[col].Value = point.z1;
                dataGridView1.Rows[2].Cells[col].Value = point.y;
                dataGridView1.Rows[3].Cells[col].Value = point.x2;

                if (Product.CurProduct == Product.ProductEnum.Product001)
                {
                    dataGridView1.Rows[4].Cells[col].Value = point.z2;
                }
            }
        }