示例#1
0
        private void Init()
        {
            var selectDir = Properties.Settings.Default.LocalPath + _ccdModel.TaskName + "\\" + _ccdModel.RecordName;

            if (!Directory.Exists(selectDir))
            {
                Directory.CreateDirectory(selectDir);
            }
            totalSize = (EndIndex - BeginIndex) * _ccdModel.data_size;
            Task.Run(() =>
            {
                var ret = SDKApi.EagleData_CheckAndRemountFileSystem(0, DISK_MOUNT_TYPE.DISK_MOUNT_FROM_AOE);

                var filePath = Path.Combine(selectDir, DateTime.Now.ToString("yyyy-MM-dd-HHmmss"));
                var fixData  = GetFixData();
                dispatcherTimer.Start();
                using (var fileStream = new FileStream(filePath, FileMode.Append, FileAccess.Write))
                {
                    int readIndex    = 0;
                    var databuffer   = new byte[_ccdModel.data_size];
                    var headerbuffer = new byte[_ccdModel.head_size];
                    if (_ccdModel.frame_number > 1)
                    {
                        for (int i = BeginIndex; i <= EndIndex; i++)
                        {
                            readSize += _ccdModel.data_size;
                            if (IsClose)
                            {
                                break;
                            }
                            var flag = SDKApi.EagleData_ReadOneStoredFrame(_ccdModel.record_id, _ccdModel.id, i, databuffer, (int)_ccdModel.data_size, headerbuffer, (int)_ccdModel.head_size);
                            if (i >= _ccdModel.frame_number)
                            {
                                var tmpDataLength = _ccdModel.data_size / 64;
                                for (int index = 0; index < tmpDataLength; index++)
                                {
                                    var n      = index * 64;
                                    var buffer = new Byte[64];
                                    for (int j = 0; j < 64; j++)
                                    {
                                        buffer[j] = databuffer[n + j];
                                    }
                                    IntPtr intptr = new IntPtr(64);
                                    var retval    = (int)SDKApi.memcmp(buffer, fixData, intptr);
                                    if (retval == 0)
                                    {
                                        readIndex = n;
                                        break;
                                    }
                                }
                                if (readIndex > 0)
                                {
                                    fileStream.Write(databuffer, 0, readIndex);
                                    fileStream.Flush();
                                    break;
                                }
                            }
                            else
                            {
                                //保存数据  databuffer
                                fileStream.Write(databuffer, 0, (int)_ccdModel.data_size);
                                fileStream.Flush();
                            }
                        }
                    }
                }
                dispatcherTimer.Stop();
                ProgressText  = "导出记录完成!";
                RateText      = string.Empty;
                ProgressValue = 100;

                ret = SDKApi.EagleData_RemoveFileSystem(0, DISK_MOUNT_TYPE.DISK_MOUNT_FROM_AOE);
            });
        }