/// <summary> /// 扫描并获取设备数量 /// </summary> /// <returns></returns> private int ScanAndGetDeviceNum() { int deviceNum = 0; SDKApi.EagleControl_ScanAndGetDeviceNum(ref deviceNum); return(deviceNum); }
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)); }
/// <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); }