Пример #1
0
 void _timerHighSpeed_Elapsed(object sender, EventArgs e)
 {
     try
     {
         if (_cancellation.IsCancellationRequested)
         {
             _timerHighSpeed.Stop();
             StopHighSpeedAquisition();
         }
         else
         {
             int          count   = 0;
             uint         notify  = 0;
             int          batchNo = 0;
             List <int[]> data    = ThreadSafeBuffer.Get(0, out notify, out batchNo);
             if (data.Count == 0)
             {
                 return;
             }
             foreach (int[] profile in data)
             {
                 if (_deviceData.ProfileData.Count < Define.WRITE_DATA_SIZE)
                 {
                     _deviceData.ProfileData.Add(new ProfileData(profile, _profileInfo));
                 }
                 count++;
             }
             _receivedProfileCount += count;
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
Пример #2
0
        public NetworkClient()
        {
            inputBuffer = new ThreadSafeBuffer<NetworkCommandObject>();
            outputBuffer = new ThreadSafeBuffer<NetworkCommandObject>();

            recvThread = new Thread(new ThreadStart(RecvLoop));
            recvThread.IsBackground = true;

            sendThread = new Thread(new ThreadStart(SendLoop));
            sendThread.IsBackground = true;
        }
Пример #3
0
        public NetworkServer()
        {
            inputBuffer = new ThreadSafeBuffer<NetworkCommandObject>();
            outputBuffer = new ThreadSafeBuffer<NetworkCommandObject>();
            clientThreads = new List<Thread>();
            clients = new List<GameClient>();

            listenThread = new Thread(new ThreadStart(ListenLoop));
            listenThread.IsBackground = true;

            sendThread = new Thread(new ThreadStart(SendLoop));
            sendThread.IsBackground = true;

            playerIndex = 1;
        }
Пример #4
0
 void StartHighSpeedDataCommunication()
 {
     try
     {
         ThreadSafeBuffer.ClearBuffer(_currentDeviceId);
         Thread.Sleep(50);
         _receivedProfiles = 0;
         rc = (Rc)NativeMethods.LJV7IF_StartHighSpeedDataCommunication(_currentDeviceId);
         CheckReturnValue(rc);
         // @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.
     }
     catch (Exception)
     {
         throw;
     }
 }
Пример #5
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);
        }