/// <summary>
 /// Get DeviceLoader Which Is Adapte To The Protocol In Config
 /// </summary>
 public static IDeviceLoader GetDeviceLoader()
 {
     if (deviceLoader == null)
     {
         deviceLoader = (IDeviceLoader)GetServiceEntity();
     }
     return(deviceLoader);
 }
Exemple #2
0
        public void ScanSubConfig(Config config)
        {
            if (loader == null)
            {
                loader = ConfigProtocol.GetDeviceLoader();
            }

            config.DeviceInfo.DeviceList = loader.GetDevice();
        }
Exemple #3
0
        private void LoadDevice(IMiningDeviceObject d)
        {
            IDeviceLoader loader = d as IDeviceLoader;

            if (loader != null)
            {
                foreach (IMiningDevice device in loader.LoadDevices())
                {
                    LoadDevice(device);
                }
            }
            else
            {
                IHotplugLoader hotplugLoader = d as IHotplugLoader;

                if (hotplugLoader != null)
                {
                    hotplugLoader.DeviceFound += this.AddNewDevice;
                    hotplugLoader.StartListening();

                    lock (hotplugListLock)
                    {
                        hotplugLoaders.Add(hotplugLoader);
                    }
                }
                else
                {
                    IMiningDevice device = d as IMiningDevice;

                    if (device != null)
                    {
                        lock (deviceListLock)
                        {
                            device.Id = deviceId;
                            deviceId++;

                            loadedDevices.Add(device);
                        }

                        device.ValidNonce    += this.SubmitWork;
                        device.WorkRequested += this.RequestWork;
                        device.InvalidNonce  += this.InvalidNonce;

                        device.Connected    += OnDeviceConnected;
                        device.Disconnected += OnDeviceDisconnected;

                        device.Load();

                        this.SetUpDevice(device);
                    }
                }
            }
        }
Exemple #4
0
        Task LoadAsync(ILog log, IDeviceLoader deviceManager, string name)
        {
            log.Description = $"{name} Listing (in progress)";

            var capturedLog = log;

            return(deviceManager.LoadDevices(capturedLog, includeLocked: false, forceRefresh: true).ContinueWith((v) => {
                if (v.IsFaulted)
                {
                    capturedLog.WriteLine("Failed to load:");
                    capturedLog.WriteLine(v.Exception.ToString());
                    capturedLog.Description = $"{name} Listing {v.Exception.Message})";
                }
                else if (v.IsCompleted)
                {
                    capturedLog.Description = deviceManager switch
                    {
                        IHardwareDeviceLoader d => BuildDevicesDescription(d, name),
                        ISimulatorLoader s => BuildSimulatorsDescription(s, name),
                        _ => throw new NotImplementedException(),
                    };
                }
            }));
        }