Beispiel #1
0
 /// <summary>
 /// 获取最新的流盘数据
 /// </summary>
 /// <param name="buf">用户定义返回数据的缓冲区</param>
 /// <param name="samplesPerChannel">每通道要取的数据</param>
 /// <param name="timeout">超时时间,单位ms,-1为无限等待</param>
 /// <returns></returns>
 public override void ReadLatestData(ref double[,] buf, int samplesPerChannel, int timeout)
 {
     if (buf.Length < samplesPerChannel * aitask.Channels.Count)
     {
         JYLog.Print("GetRecordPreviewData:参数buf长度不足");
         throw new JYDriverException(JYDriverExceptionPublic.UserBufferError);
     }
     _localPreviewBuffer.Dequeue(ref _previewDataConvertBuffer, samplesPerChannel * aitask.Channels.Count);
     ScaleRawData(_previewDataConvertBuffer, ref buf, samplesPerChannel, range);
 }
Beispiel #2
0
        /// <summary>
        /// 获取最新的流盘数据
        /// </summary>
        /// <param name="buf">用户定义返回数据的缓冲区</param>
        /// <param name="samplesPerChannel">每通道要取的数据</param>
        /// <param name="timeout">超时时间,单位ms,-1为无限等待</param>
        public override void ReadLatestData(ref double[] buf, int samplesPerChannel, int timeout)
        {
            if (buf.Length < samplesPerChannel * aitask.Channels.Count)
            {
                JYLog.Print("GetRecordPreviewData:参数buf长度不足");
                throw new JYDriverException(JYDriverExceptionPublic.UserBufferError);
            }
            var tempBuf = new double[samplesPerChannel, buf.Length / samplesPerChannel];

            _localPreviewBuffer.Dequeue(ref _previewDataConvertBuffer, tempBuf.Length);
            ScaleRawData(_previewDataConvertBuffer, ref tempBuf, samplesPerChannel, range);
            Buffer.BlockCopy(tempBuf, 0, buf, 0, tempBuf.Length * sizeof(double));
        }
Beispiel #3
0
        /// <summary>
        /// 停止流盘任务
        /// </summary>
        public override void Stop()
        {
            txtFileStream = new FileStream(FilePath + "\\" + currentTime + ".txt", FileMode.Append);
            StreamWriter txt = new StreamWriter(txtFileStream);

            txt.WriteLine("ElapsedTime = " + (DateTime.Now - startTime).TotalMilliseconds);
            txt.Close();
            txtFileStream.Close();
            if (_thdFetchAndWriteData.IsAlive == true)
            {
                if (false == _thdFetchAndWriteData.Join(200))
                {
                    _thdFetchAndWriteData.Abort();
                    JYLog.Print(JYLogLevel.DEBUG, "WriteDataFile Thread Exit Abnormally...");
                }
            }
            aitask.Stop();
            _wt.Close();
            _fs.Close();
        }