Example #1
0
        /// <summary>
        /// High-speed communication callback process
        /// </summary>
        /// <param name="buffer">Pointer to beginning of received data</param>
        /// <param name="size">Byte size per 1 profile in received data</param>
        /// <param name="count">Profile count</param>
        /// <param name="notify">Exited or not</param>
        /// <param name="user">Information passed when high-speed data communication was initialized (thread ID)</param>
        private static void ReceiveData(IntPtr buffer, uint size, uint count, uint notify, uint user)
        {
            // Received data is in BYTE units, set as a group of INT units.
            uint         profileSize  = size / sizeof(int);
            List <int[]> reciveBuffer = new List <int[]>();

            int[] bufferArray = new int[profileSize * count];
            Marshal.Copy(buffer, bufferArray, 0, (int)(profileSize * count));
            // Retain profile data
            for (int i = 0; i < count; i++)
            {
                int[] oneProfile = new int[profileSize];
                Array.Copy(bufferArray, i * profileSize, oneProfile, 0, profileSize);
                reciveBuffer.Add(oneProfile);
            }

            ThreadSafeBuffer.Add(reciveBuffer, notify);
        }
Example #2
0
        /// <summary>
        /// 高速通信のコールバック処理
        /// </summary>
        /// <param name="buffer">受信データの先頭ポインタ</param>
        /// <param name="size">受信データの1プロファイルあたりのBYTEサイズ</param>
        /// <param name="count">プロファイル数</param>
        /// <param name="notify">終了したかどうか</param>
        /// <param name="user">高速データ通信初期化時に渡した情報(スレッドID)</param>
        private static void ReceiveData(IntPtr buffer, uint size, uint count, uint notify, uint user)
        {
            // 受信はBYTE単位なのでINT単位のまとまりに設定
            uint         profileSize  = size / sizeof(int);
            List <int[]> reciveBuffer = new List <int[]>();

            int[] bufferArray = new int[profileSize * count];
            Marshal.Copy(buffer, bufferArray, 0, (int)(profileSize * count));
            // プロファイルデータ保持
            for (int i = 0; i < count; i++)
            {
                int[] oneProfile = new int[profileSize];
                Array.Copy(bufferArray, i * profileSize, oneProfile, 0, profileSize);
                reciveBuffer.Add(oneProfile);
            }

            ThreadSafeBuffer.Add(reciveBuffer, notify);
        }