Exemple #1
0
 /// <summary>
 /// 格式化磁盘
 /// </summary>
 /// <param name="deviceId"></param>
 public void FormatDevice()
 {
     CanFormat  = false;
     FormatText = "正在格式化";
     _eventAggregator.GetEvent <InfoEventArgs>().Publish("正在格式化磁盘...\n");
     Task.Run(() =>
     {
         var ret = SDKApi.EagleControl_ReformatDisk(DeviceId);
         if (ret == 0)
         {
             _eventAggregator.GetEvent <InfoEventArgs>().Publish("正在初始化磁盘...\n");
         }
         else
         {
             _eventAggregator.GetEvent <InfoEventArgs>().Publish("正在格式化磁盘出错...\n");
             MessageBox.Show(string.Format("格式化出现异常:{0}!", ret));
             FormatText = "格式化存储";
             CanFormat  = true;
             return;
         }
         var result = SDKApi.EagleControl_ReinitDisk(DeviceId);
         if (result == 0)
         {
             _eventAggregator.GetEvent <InfoEventArgs>().Publish("已成功初始化磁盘!\n");
         }
         else
         {
             _eventAggregator.GetEvent <InfoEventArgs>().Publish("初始化磁盘异常!\n");
         }
         FormatText = "格式化存储";
         CanFormat  = true;
         MessageBox.Show("格式化完成!");
     });
 }
Exemple #2
0
        /// <summary>
        /// 加载网卡信息
        /// </summary>
        public void LoadNetCard()
        {
            eagle_all_netcards nics = new eagle_all_netcards();
            int ret = SDKApi.EagleControl_GetSystemNICs(ref nics);

            for (int i = 1; i <= nics.card_num; i++)
            {
                // LogHelper.WriteLog(string.Format("{0} : {1}\n", i, nics.cards[i - 1].dev_description));
            }
            var settingModel = _container.Resolve <SettingsViewModel>();

            for (int i = 0; i < nics.cards.Count(); i++)
            {
                if (!string.IsNullOrEmpty(nics.cards[i].dev_name))
                {
                    if (i == Settings.Default.NetCardIndex)
                    {
                        settingModel.CurrentNetCard = nics.cards[i].dev_description;
                    }
                    settingModel.NetCardInfos.Add(new Models.NetCardInfo()
                    {
                        dev_name = nics.cards[i].dev_name, dev_description = nics.cards[i].dev_description
                    });
                }
            }
        }
Exemple #3
0
        /// <summary>
        /// 扫描并获取设备数量
        /// </summary>
        /// <returns></returns>
        private int ScanAndGetDeviceNum()
        {
            int deviceNum = 0;

            SDKApi.EagleControl_ScanAndGetDeviceNum(ref deviceNum);
            return(deviceNum);
        }
Exemple #4
0
        public void LoadDeviceStatus()
        {
            var nameStr = new StringBuilder();
            // var DeviceName = string.Empty;
            var name = SDKApi.EagleControl_GetDeviceName(DeviceId, nameStr);

            DeviceName = nameStr.ToString();
            var sys    = new eagle_system_status();
            var volume = new eagle_disk_total_volume();
            int ret    = SDKApi.EagleControl_GetSystemStatus(DeviceId, out sys);         //获取系统状态 温度‘磁盘数及剩余容量

            ret         = SDKApi.EagleControl_GetDeviceDiskVolume(DeviceId, ref volume); //磁盘总容量
            Temperature = string.Format("{0}℃", sys.fpga_tempture);
            int  freevolume  = 0;
            uint totalvolume = 0;

            for (int i = 0; i < sys.disk_num; i++)
            {
                freevolume  += sys.remained_volume[i];
                totalvolume += volume.total_volume[i];
            }
            FreeVolume  = string.Format("{0}GB可用", freevolume);
            TotalVolume = string.Format("{0}GB", totalvolume);
            DiskPercent = 100.0 - (int)(freevolume * 100.0 / totalvolume);
            //设置相机Check
            for (int i = 1; i < 5; i++)
            {
                ret = SDKApi.EagleControl_CheckChannel(DeviceId, i, i == 1 ? true : false);
            }
        }
Exemple #5
0
        public eagle_reocrd_status GetRecordStatus()
        {
            // eagle_reocrd_status reocrdstatus = new eagle_reocrd_status();//记录时间,大小计算速度
            var ret = SDKApi.EagleControl_GetRecordStatus(DeviceId, ref _reocrdstatus);

            return(_reocrdstatus);
        }
Exemple #6
0
        /// <summary>
        /// 获取记录列表
        /// </summary>
        public void Get_Record_List()
        {
            CcdRecordModels.Clear();
            SDKApi.EagleData_RefetchRecList();
            int record_num = SDKApi.EagleData_GetRecordNumber();

            if (record_num > 0)
            {
                IntPtr intPtr        = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(EagleData_Record_Id)) * record_num);
                int    nStructLength = Marshal.SizeOf(typeof(EagleData_Record));

                int actual_num = SDKApi.EagleData_GetRecordList(intPtr, record_num);

                _recordIds = new EagleData_Record_Id[actual_num];

                for (int i = 0; i < actual_num; i++)
                {
                    _recordIds[i] = (EagleData_Record_Id)Marshal.PtrToStructure(intPtr + Marshal.SizeOf(typeof(EagleData_Record_Id)) * i, typeof(EagleData_Record_Id));
                    // EagleData_Record ccd = new EagleData_Record();
                    var record = SDKApi.EagleData_GetRecordAndAllocMemory(_recordIds[i]);
                    var ccd    = (EagleData_Record)Marshal.PtrToStructure(record, typeof(EagleData_Record));

                    //得到数据项
                    var item  = (EagleData_CcdRecord)Marshal.PtrToStructure(ccd.ccd_record_list, typeof(EagleData_CcdRecord));
                    var model = new CcdRecordModel()
                    {
                        data_size        = item.data_size,
                        data_source_type = item.data_source_type,
                        disk_bitmap      = item.disk_bitmap,
                        end_time         = item.end_time,
                        frame_number     = item.frame_number,//镇数
                        head_size        = item.head_size,
                        id = item.id,
                        pixel_sampling_type = item.pixel_sampling_type,
                        record_id           = item.record_id,
                        record_index        = item.record_index,
                        start_time          = item.start_time,
                        task_index          = item.task_index,
                        TaskName            = item.record_id.task_name,
                        RecordName          = item.record_id.task_name + item.record_id.start_time,
                    };
                    long totalsize = 0;
                    if (item.frame_number < 2)
                    {
                        totalsize = 0;
                    }
                    else
                    {
                        totalsize = (long)(item.frame_number + 1) * item.data_size;
                    }
                    model.TotalSize = String.Format("{0:F2}GB", totalsize / (1024.0 * 1024.0 * 1024.0));
                    CcdRecordModels.Add(model);
                    SDKApi.EagleData_FreeRecordMemory(record);
                    //  var r1 = SDKApi.EagleData_DeleteRecord(list.record_id, list.id);
                }
                Marshal.FreeHGlobal(intPtr);
            }
        }
Exemple #7
0
        private unsafe void get_record_list()
        {
            SDKApi.EagleData_RefetchRecList();
            int record_num = SDKApi.EagleData_GetRecordNumber();

            if (record_num > 0)
            {
                //var ids =IntPtr.Zero ;// new EagleData_Record_Id();
                //  List<EagleData_Record_Id> list = new List<EagleData_Record_Id>();
                //  var ids = new IntPtr[record_num];//EagleData_Record_Id[record_num];
                //  for (int i = 0; i < record_num; i++)
                //  {
                //     // ids[i].task_name = new  string('\0',64);
                //     // list.Add(new EagleData_Record_Id() { task_name=new string ('\0',64),start_time=0 });
                //  }

                //// var intptr = Marshal.AllocHGlobal(Marshal.SizeOf(64));
                //  IntPtr[] ptArr = new IntPtr[1];
                //  ptArr[0] = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(EagleData_Record_Id)));
                IntPtr pt            = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(EagleData_Record_Id)) * record_num);
                int    nStructLength = Marshal.SizeOf(typeof(EagleData_Record));
                //  Marshal.Copy(ptArr, 0, pt, 1);

                int actual_num = SDKApi.EagleData_GetRecordList(pt, record_num);

                EagleData_Record_Id[] ids = new EagleData_Record_Id[actual_num];

                for (int i = 0; i < actual_num; i++)
                {
                    ids[i] = (EagleData_Record_Id)Marshal.PtrToStructure(pt + Marshal.SizeOf(typeof(EagleData_Record_Id)) * i, typeof(EagleData_Record_Id));
                    EagleData_Record ccd = new EagleData_Record();
                    var record           = SDKApi.EagleData_GetRecordAndAllocMemory(ids[i]);
                    ccd = (EagleData_Record)Marshal.PtrToStructure(record, typeof(EagleData_Record));
                    int s    = 0;
                    var list = (EagleData_CcdRecord)Marshal.PtrToStructure(ccd.ccd_record_list, typeof(EagleData_CcdRecord));

                    var r1  = SDKApi.EagleData_DeleteRecord(list.record_id, list.id);
                    int ss1 = 0;
                    //var ret = SDKApi.EagleData_CheckAndRemountFileSystem(0, DISK_MOUNT_TYPE.DISK_MOUNT_FROM_AOE);
                    //var databuffer = new byte[list.data_size];
                    //var headerbuffer = new byte[list.head_size];

                    //// if (record!= null)
                    //for (int index = 0; index < list.frame_number; i++)
                    //{
                    //    var flag = SDKApi.EagleData_ReadOneStoredFrame(list.record_id, list.id, index, databuffer, (int)list.data_size, headerbuffer, (int)list.head_size);
                    //   //保存数据  databuffer
                    //}
                    //ret = SDKApi.EagleData_RemoveFileSystem(0, DISK_MOUNT_TYPE.DISK_MOUNT_FROM_AOE);
                    //_print_record_detail(&record->id, i + 1);


                    // EagleData_FreeRecordMemory(record);
                }
                Marshal.FreeHGlobal(pt);
            }
        }
Exemple #8
0
        public void Delete_Ccd_Record()
        {
            SDKApi.EagleData_RefetchRecList();
            int record_num = SDKApi.EagleData_GetRecordNumber();

            if (record_num > 0)
            {
                //get record list
                var ids        = new EagleData_Record_Id[record_num];
                int actual_num = 0;// SDKApi.EagleData_GetRecordList(ref ids, record_num);
            }
        }
Exemple #9
0
        public void StopRecord(int deviceId)
        {
            int ret = SDKApi.EagleControl_StopRecord(DeviceId);

            if (ret == 0)
            {
                IsRecording = false;
            }
            else
            {
                IsRecording = true;
            }
        }
Exemple #10
0
        private void OnSDKInit()
        {
            //获取存储SDK 版本
            int major = 0, minor = 0;

            //SetConsoleCtrlHandler(CosonleHandler, TRUE);
            SDKApi.EagleData_GetVersion(ref major, ref minor);
            Console.WriteLine(string.Format("SDK Version: {0}.{1}\n", major, minor));
            LogHelper.WriteLog(string.Format("SDK Version: {0}.{1}\n", major, minor));
            //所有在本地计算机上网卡列表

            eagle_all_netcards nics = new eagle_all_netcards();

            int ret = SDKApi.EagleControl_GetSystemNICs(ref nics);

            LogHelper.WriteLog(nics.card_num.ToString());

            for (int i = 1; i <= nics.card_num; i++)
            {
                LogHelper.WriteLog(string.Format("{0} : {1}\n", i, nics.cards[i - 1].dev_description));
            }

            /*
             * get device number
             */
            int device_num = 0;

            ret = SDKApi.EagleControl_ScanAndGetDeviceNum(ref device_num);
            LogHelper.WriteLog(string.Format("get device numbers {0}", device_num));

            /*
             * get device ids
             */
            int[] device_ids = new int[device_num];
            int   ids        = 0;
            //ret = SDKApi.EagleControl_GetDeviceIds(out device_ids, device_num, ref ids);
            //LogHelper.WriteLog("get device ids:\n");
            //for (int i = 0; i < ids; i++)
            //{
            //    LogHelper.WriteLog(string.Format(" ** {0}: device id {1}\n", i + 1, device_ids[i]));
            //}

            /*
             * init data api
             */
            var initdevice = SDKApi.EagleData_Init();

            LogHelper.WriteLog(string.Format("init eagle data {0}", initdevice));
        }
Exemple #11
0
        public bool GetSystemStatus()
        {
            var sys = new eagle_system_status();
            int ret = SDKApi.EagleControl_GetSystemStatus(DeviceId, out sys);//获取系统状态 温度‘磁盘数及剩余容量

            if (ret == 0)
            {
                IsConnected = true;
                return(true);
            }
            else
            {
                IsConnected = false;
                return(false);
            }
        }
Exemple #12
0
        /// <summary>
        /// 设置网卡
        /// </summary>
        /// <returns></returns>
        public int SetCurrentNetCard()
        {
            int cardIndex           = Properties.Settings.Default.NetCardIndex;
            eagle_all_netcards nics = new eagle_all_netcards();
            int ret = SDKApi.EagleControl_GetSystemNICs(ref nics);

            if (nics.card_num > 0)
            {
                var infoList = new eagle_netcard_info[10];
                infoList[0] = nics.cards[cardIndex];
                var setnice = new eagle_all_netcards();
                setnice.card_num = 1;
                setnice.cards    = infoList;
                ret = SDKApi.EagleControl_SetControlNICs(ref setnice);
            }
            return(ret);
        }
Exemple #13
0
 /// <summary>
 /// 开始记录
 /// </summary>
 /// <param name="deviceId"></param>
 public bool StartRecord(int deviceId, int capture_frame_num = 0, int capture_time = 0, int capture_frame_interval = 0)
 {
     if (IsConnected)
     {
         var date = System.DateTime.Now;
         eagle_device_time time = new eagle_device_time();
         time.wYear       = (UInt16)date.Year;
         time.wMouth      = (UInt16)date.Month;
         time.wDay        = (UInt16)date.Day;
         time.wHour       = (UInt16)date.Hour;
         time.wMinite     = (UInt16)date.Minute;
         time.wSecond     = (UInt16)date.Second;
         time.wMillsecond = (UInt16)date.Millisecond;
         var settime = SDKApi.EagleControl_SetDeviceTimeBase(DeviceId, ref time);
         if (settime > 0)
         {
             _eventAggregator.GetEvent <InfoEventArgs>().Publish("存储设备授时失败!\n");
         }
         bool flag = true;
         var  ret  = SDKApi.EagleControl_StartTask(DeviceId, Settings.Default.TaskName, 0x01, 0);
         if (ret != 0)
         {
             IsRecording = false;
             flag        = false;
             _eventAggregator.GetEvent <InfoEventArgs>().Publish("开启任务失败,请检查任务名称是否有效!\n");
             MessageBox.Show("开启任务失败!");
         }
         var str = SDKApi.EagleControl_StartRecord(DeviceId, 0, 0, 0);
         if (str != 0)
         {
             IsRecording = false;
             flag        = false;
             _eventAggregator.GetEvent <InfoEventArgs>().Publish("开启存储记录失败!\n");
             MessageBox.Show("开启存储记录失败!");
         }
         Thread.Sleep(10);
         Get_Record_List();
         return(flag);
     }
     else
     {
         _eventAggregator.GetEvent <InfoEventArgs>().Publish("存储设备已断开连接!\n");
         return(false);
     }
 }
Exemple #14
0
        private void OnDeleteFile(CcdRecordModel model)
        {
            var result = MessageBox.Show("你确定要删除当前记录吗?", "删除提醒", MessageBoxButton.OKCancel, MessageBoxImage.Warning);

            if (result == MessageBoxResult.OK)
            {
                int ret = SDKApi.EagleData_DeleteRecord(model.record_id, model.id);
                if (ret != 0)
                {
                    _eventAggregator.GetEvent <InfoEventArgs>().Publish("删除存储记录失败!\n");
                    MessageBox.Show("删除记录失败!");
                }
                else
                {
                    Get_Record_List();
                }
            }
        }
Exemple #15
0
        public void ReNameTask()
        {
            SDKApi.EagleData_RefetchRecList();
            int record_num = SDKApi.EagleData_GetRecordNumber();

            if (record_num > 0)
            {
                EagleData_Record_Id[] ids = new EagleData_Record_Id[record_num];
                // int actual_num = SDKApi.EagleData_GetRecordList(ref ids, record_num);
                //_print_record_list(ids, actual_num);
                //int record_index = _select_input("input record to rename", actual_num, 1, 0);
                //if (record_index == 0)
                //{
                //    return;
                //}
                //printf("input new name:");
                //wchar_t new_name[32] = { '\0' };
                //wscanf_s(L"%ls", new_name, 31);
                //int ret = SDKApi.EagleData_RenameTask(ids[actual_num - 1], "new-code");
                //PrintResult(ret, "rename");
                //delete[] ids;
            }
        }
Exemple #16
0
        /// <summary>
        /// 查询连接存储设备
        /// </summary>
        /// <returns></returns>
        public bool Connected()
        {
            int device_num = 0;
            int ret        = SDKApi.EagleControl_ScanAndGetDeviceNum(ref device_num);

            if (ret == 0)
            {
                if (device_num > 0)
                {
                    IntPtr[] device_ids = new IntPtr[device_num];
                    int      ids        = 0;
                    ret = SDKApi.EagleControl_GetDeviceIds(device_ids, 1, ref ids);
                    if (ret == 0)
                    {
                        var initdevice = SDKApi.EagleData_Init();//初始化设备
                        DeviceId    = (int)device_ids[0];
                        IsConnected = true;
                        return(true);
                    }
                }
            }

            return(false);
        }
Exemple #17
0
 /// <summary>
 /// 暂停记录
 /// </summary>
 /// <param name="deviceId"></param>
 private void PauseRecord(int deviceId)
 {
     SDKApi.EagleControl_PauseRecord(deviceId);
 }
Exemple #18
0
 /// <summary>
 ///  恢复到出厂设置。
 /// </summary>
 /// <param name="deviceId"></param>
 public void RestoreConfig(int deviceId)
 {
     SDKApi.EagleControl_RestoreConfig(deviceId);
 }
Exemple #19
0
 private void StopTask(int deviceId)
 {
     var ret = SDKApi.EagleControl_StopTask(deviceId);
 }
Exemple #20
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);
            });
        }
Exemple #21
0
 /// <summary>
 /// 继续记录
 /// </summary>
 /// <param name="deviceId"></param>
 private void ResumeRecord(int deviceId)
 {
     SDKApi.EagleControl_ResumeRecord(deviceId);
 }