示例#1
0
        /// <summary>
        ///     二维位置压入
        /// </summary>
        /// <param name="nCardNum">位置比较数据个数</param>
        /// <param name="axis1">轴1坐标</param>
        /// <param name="axis2">D轴2坐标</param>
        /// <param name="chn">通道号 0:HSIO1 ; 通道号 1: HSIO2</param>
        /// <param name="fifo">数据压入的 FIFO,范围: [0,1],该数据目前保留,使用 0 即可</param>
        /// <returns></returns>
        public override short D2DCompareData(short nCardNum, List <int> axis1, List <int> axis2, short chn, short fifo)
        {
            short nRtn = 0;

            //清除
            nRtn |= mc.GT_2DCompareClear(nCardNum, chn);

            //设置模式
            nRtn |= mc.GT_2DCompareMode(nCardNum, chn, mc.COMPARE2D_MODE_2D);

            var ll = axis1.Count;
            int maxL;

            if (ll > 1000)
            {
                maxL = 1000;
            }
            else
            {
                maxL = ll;
            }


            var td = new mc.T2DCompareData[1000];


            for (var i = 0; i < maxL; i++)
            {
                td[i].px = axis1[i];
                td[i].py = axis2[i];
            }

            //压入数据
            nRtn |= mc.GT_2DCompareData(nCardNum, chn, (short)maxL, ref td[0], fifo);


            //如果数量超过1000个,开启线程继续压入
            if (maxL == 1000)
            {
                DD_POINT t2P;
                t2P.m_lAxis1 = axis1;
                t2P.m_lAxis2 = axis2;
                t2P.nIndex   = 1000;
                t2P.nChn     = chn;
                t2P.nCardNum = nCardNum;


                var t = new Thread(ThreadAddP);

                t.IsBackground = true;
                t.Start(t2P);
            }


            return(nRtn);
        }
示例#2
0
        /// <summary>
        /// 设置二维比较输出数据
        /// </summary>
        /// <param name="cardId">卡号</param>
        /// <param name="chn">0,1</param>
        /// <param name="count">比较点数</param>
        /// <param name="x">数据x</param>
        /// <param name="y">数据y</param>
        /// <param name="fifo">0,1</param>
        /// <returns></returns>
        public short Cmp2dData(short cardId, short chn, short count, int[] x, int[] y, short fifo)
        {
            if (x == null || y == null || x.Length == 0 || y.Length == 0 || x.Length != y.Length ||
                x.Length < count || y.Length < count)
            {
                return(-10);
            }

            mc.T2DCompareData[] data = new mc.T2DCompareData[2048];
            for (int i = 0; i < count; i++)
            {
                data[i].px = x[i];
                data[i].py = y[i];
            }
            return(mc.GT_2DCompareData(cardId, chn, count, ref data[0], fifo));
        }
示例#3
0
        private void ThreadAddP(object point)
        {
            var t2P = (DD_POINT)point;

            //已经添加的个数
            var index = t2P.nIndex;
            var td    = new mc.T2DCompareData[t2P.m_lAxis1.Count - index];

            var maxL = t2P.m_lAxis1.Count - index;

            //提取剩下的点
            for (var i = 0; i < maxL; i++)
            {
                td[i].px = t2P.m_lAxis1[i + index];
                td[i].py = t2P.m_lAxis2[i + index];
            }

            //当前索引
            var preIndex = 0;

            while (index < t2P.m_lAxis1.Count)
            {
                short pStatus;    //0 :正在进行比较输出 1:比较输出完成
                int   pCount;     //位置比较已输出次数
                short pFifo;      //当前空闲 FIFO
                short pFifoCount; //当前空闲 FIFO 剩余空间
                short pBufCount;  //FPGA 中 FIFO 剩余空间,FPGA 的 FIFO 总大小为 512,启动位置比较之前,压入的数据先进入 FPGA 的 FIFO
                mc.GT_2DCompareStatus(t2P.nCardNum, t2P.nChn, out pStatus, out pCount, out pFifo,
                                      out pFifoCount, out pBufCount);

                if (pFifoCount >= 1024)
                {
                    if (index + pFifoCount > t2P.m_lAxis1.Count)          //如果pFifoCount大于剩余点数量,
                    {
                        pFifoCount = (short)(t2P.m_lAxis1.Count - index); //=总数-已加数
                    }
                    //压入数据
                    mc.GT_2DCompareData(t2P.nCardNum, t2P.nChn, pFifoCount, ref td[preIndex], pFifo);
                    index    = index + pFifoCount;
                    preIndex = preIndex + pFifoCount;
                }
            }
        }