Exemplo n.º 1
0
        //定时器读取线程可靠BUFFER中的数据
        private void timer1_Tick(object sender, EventArgs e)
        {
            int  count   = 0;
            uint notify  = 0;
            int  batchNo = 0;

            List <int[]> data = ThreadSafeBuffer.Get(0, out notify, out batchNo);

            if (data.Count != 0)
            {
                if (singleBatchFinish)
                {
                    //currentDatas.Clear();
                    currentBatch.Clear();
                }
                singleBatchFinish = false;
                foreach (int[] profile in data)
                {
                    int[] tempGap  = new int[singleProfilePointCount];
                    int[] tempSeam = new int[singleProfilePointCount];
                    if (SensorCount == 1)
                    {
                        Array.Copy(profile, 6, tempGap, 0, singleProfilePointCount);
                        ProfileData Gap = new ProfileData(tempGap);
                        currentBatch.AddGap(Gap);
                        DrawCurrentGap(Gap);
                        DrawCurrentParameter(Gap);
                    }
                    else if (SensorCount == 2)
                    {
                        Array.Copy(profile, 6, tempGap, 0, singleProfilePointCount);
                        Array.Copy(profile, 6 + singleProfilePointCount, tempSeam, 0, singleProfilePointCount);
                        ProfileData Gap  = new ProfileData(tempGap);
                        ProfileData Seam = new ProfileData(tempSeam);
                        currentBatch.AddGap(Gap);
                        currentBatch.AddSeam(Seam);
                    }
                    count++;
                    currentBatchProfileCount++;
                }
            }
            if (notify != 0)
            {
                AddLog(string.Format("当前批计数达到上限,或中断当前批处理"));
                AddLog(string.Format("  notify[{0}] = {1,0:x8}\tbatch[{0}] = {2}", 0, notify, batchNo));
                AddLog(string.Format("当前批次轮廓数量 = {0}", currentBatchProfileCount));
                currentBatchProfileCount = 0;
                singleBatchFinish        = true;
            }
        }
Exemplo n.º 2
0
        public static void ReceiveHighSpeedData(IntPtr buffer, uint size, uint count, uint notify, uint user)
        {
            // @Point
            // Take care to only implement storing profile data in a thread save buffer in the callback function.
            // As the thread used to call the callback function is the same as the thread used to receive data,
            // the processing time of the callback function affects the speed at which data is received,
            // and may stop communication from being performed properly in some environments.

            uint         profileSize   = (uint)(size / Marshal.SizeOf(typeof(int)));
            List <int[]> receiveBuffer = new List <int[]>();

            int[] bufferArray = new int[profileSize * count];
            Marshal.Copy(buffer, bufferArray, 0, (int)(profileSize * count));

            // Profile data retention
            for (int i = 0; i < count; i++)
            {
                int[] oneProfile = new int[profileSize];
                Array.Copy(bufferArray, i * profileSize, oneProfile, 0, profileSize);
                receiveBuffer.Add(oneProfile);
            }

            ThreadSafeBuffer.Add((int)user, receiveBuffer, notify);
        }
Exemplo n.º 3
0
        private bool StartHighSpeedDataCommunication()
        {
            _sendCommand = SendCommand.StartHighSpeedDataCommunication;

            ThreadSafeBuffer.ClearBuffer(Define._currentDeviceId);
            int rc = NativeMethods.LJV7IF_StartHighSpeedDataCommunication(Define._currentDeviceId);

            // @Point
            //  If the LJ-V does not measure the profile for 30 seconds from the start of transmission,
            //  "0x00000008" is stored in dwNotify of the callback function.
            timer1.Start();
            //ReadingThread.Start();
            //AddLogResult(rc, Resources.SID_START_HIGH_SPEED_DATA_COMMUNICATION);
            if (rc == (int)Rc.Ok)
            {
                AddLog("高速通信启动 OK!");
                return(true);
            }
            else
            {
                AddLog("高速通信启动 Fail!");
                return(false);
            }
        }