コード例 #1
0
        private void CheckProgressLoop()
        {
            while (true)
            {
                if (CtrlEndPt != null)
                {
                    CtrlEndPt.Target = CyConst.TGT_DEVICE;

                    CtrlEndPt.ReqType = 0x40;

                    CtrlEndPt.ReqCode = 0xb8;

                    CtrlEndPt.Value = 0x00ba;

                    CtrlEndPt.Index = 0x0000;

                    int len = 2;

                    byte[] buf = new byte[] { 0xC1, 0x01 };

                    CtrlEndPt.Write(ref buf, ref len);
                }

                if (MyDevice.BulkInEndPt != null)
                {
                    int len = 512;

                    byte[] buf = new byte[len];

                    MyDevice.BulkInEndPt.XferData(ref buf, ref len);

                    uint currentAccumNum = BitConverter.ToUInt32(buf, 1);

                    UpdateAcquisitionProgress(currentAccumNum);

                    if (currentAccumNum >= accumTimes)
                    {
                        break;
                    }
                }
                Thread.Sleep(80);
            }
            CheckAcquisitionChannelData(chA, chB);
            count++;
            UpdateAcquisitionCount(count);
            UpdateChannelDataList(chA, chB);
            if (continued)
            {
                StartAcquisition();
            }
            else
            {
                InitBtnStart();
            }
        }
コード例 #2
0
        private static int CheckAcquisitionChannelData(byte[] ChA, byte[] ChB)
        {
            if (CtrlEndPt != null)
            {
                var  readLength = chA.Length;
                var  readTimes  = (int)Math.Ceiling(readLength / 512.0);
                byte readLen    = (byte)(readTimes / 2);

                int    len  = 3;
                byte[] bufA = new byte[] { 0xC2, 0xca, readLen };
                CtrlEndPt.Write(ref bufA, ref len);

                len  = 512;
                bufA = new byte[len];
                for (int i = 0; i < readTimes - 1; i++)
                {
                    MyDevice.BulkInEndPt.XferData(ref bufA, ref len);
                    Array.Copy(bufA, 0, ChA, 512 * i, 512);
                }
                MyDevice.BulkInEndPt.XferData(ref bufA, ref len);
                Array.Copy(bufA, 0, ChA, 512 * (readTimes - 1), readLength % 512);

                len = 3;
                byte[] bufB = new byte[] { 0xC2, 0xcb, readLen };
                CtrlEndPt.Write(ref bufB, ref len);

                len  = 512;
                bufB = new byte[len];
                for (int i = 0; i < readTimes - 1; i++)
                {
                    MyDevice.BulkInEndPt.XferData(ref bufB, ref len);
                    Array.Copy(bufB, 0, ChB, 512 * i, 512);
                }
                MyDevice.BulkInEndPt.XferData(ref bufB, ref len);
                Array.Copy(bufB, 0, ChB, 512 * (readTimes - 1), readLength % 512);

                return(0);
            }
            else
            {
                return(-1);
            }
        }
コード例 #3
0
        private static int StartAcquisition()
        {
            //for (int i = 0; i < 1; i++)
            //{
            //    GetAcqCard();
            //    Thread.Sleep(100);
            //}

            if (CtrlEndPt != null)
            {
                int len = acquisitionStartCmd.Length;
                CtrlEndPt.Write(ref acquisitionStartCmd, ref len);
                return(1);
            }
            else
            {
                return(-1);
            }
        }
コード例 #4
0
        private static void WaitAcquistionFinish()
        {
            int wloop = 3;

            int[] curNum = new int[wloop];
            int   rN     = 5;
            int   r0     = 0;

            while (true)
            {
                r0++;
                for (int i = 0; i < wloop; i++)
                {
                    int    len = 2;
                    byte[] buf = new byte[] { 0xC1, 0x01 };
                    CtrlEndPt.Write(ref buf, ref len);

                    len = 512;
                    buf = new byte[len];

                    MyDevice.BulkInEndPt.XferData(ref buf, ref len);
                    curNum[i] = (int)BitConverter.ToUInt32(buf, 1);
                    Thread.Sleep(100);
                }
                Array.Sort(curNum);
                currentAccumNum = curNum[0];
                r0 %= rN;
                if (r0 == 0)
                {
                    Console.Write("\r{0}% ", (int)(currentAccumNum * 100.0f / accumTimes));
                }
                if (currentAccumNum == accumTimes)
                {
                    break;
                }
            }
        }