Ejemplo n.º 1
0
        public static void ParseTextForDeviceDetails(string text, List<DeviceDetails> deviceDetails)
        {
            List<string> responseParts = ParseResponseText(text);
            if (responseParts.Count == 0)
                return;

            foreach (string responsePart in responseParts)
            {
                Dictionary<string, string> keyValuePairs = ParseResponsePart(responsePart);

                //check for key-value pairs, seen Count == 0 with user API logs
                if (keyValuePairs.Count > 0)
                {
                    DeviceDetails newDevice = new DeviceDetails();

                    newDevice.Index = int.Parse(keyValuePairs["DEVDETAILS"]);
                    newDevice.Name = keyValuePairs["Name"];
                    newDevice.ID = int.Parse(keyValuePairs["ID"]);
                    newDevice.Driver = keyValuePairs["Driver"];
                    if (keyValuePairs.ContainsKey("Device Path"))
                        newDevice.DevicePath = keyValuePairs["Device Path"];
                    if (keyValuePairs.ContainsKey("Serial"))
                        newDevice.Serial = keyValuePairs["Serial"];
                    if (keyValuePairs.ContainsKey("Kernel"))
                        newDevice.Kernel = keyValuePairs["Kernel"];
                    if (keyValuePairs.ContainsKey("Model"))
                        newDevice.Model = keyValuePairs["Model"];

                    deviceDetails.Add(newDevice);
                }
            }
        }
Ejemplo n.º 2
0
        public static void ParseTextForDeviceDetails(string text, List<DeviceDetails> deviceDetails)
        {
            List<string> deviceBlob = text.Split('|').ToList();
            deviceBlob.RemoveAt(0);

            foreach (string deviceText in deviceBlob)
            {
                if (deviceText == "\0")
                    continue;

                //bfgminer may have multiple entries for the same key, e.g. Hardware Errors
                //seen with customer data/hardware
                //remove dupes using Distinct()
                var deviceAttributes = deviceText.Split(',').ToList().Distinct();

                Dictionary<string, string> keyValuePairs = deviceAttributes
                  .Where(value => value.Contains('='))
                  .Select(value => value.Split('='))
                  .ToDictionary(pair => pair[0], pair => pair[1]);

                //seen Count == 0 with user API logs
                if (keyValuePairs.Count > 0)
                {
                    DeviceDetails newDevice = new DeviceDetails();

                    newDevice.Index = int.Parse(keyValuePairs["DEVDETAILS"]);
                    newDevice.Name = keyValuePairs["Name"];
                    newDevice.ID = int.Parse(keyValuePairs["ID"]);
                    newDevice.Driver = keyValuePairs["Driver"];
                    if (keyValuePairs.ContainsKey("Device Path"))
                        newDevice.DevicePath = keyValuePairs["Device Path"];
                    if (keyValuePairs.ContainsKey("Serial"))
                        newDevice.Serial = keyValuePairs["Serial"];
                    if (keyValuePairs.ContainsKey("Kernel"))
                        newDevice.Kernel = keyValuePairs["Kernel"];
                    if (keyValuePairs.ContainsKey("Model"))
                        newDevice.Model = keyValuePairs["Model"];

                    deviceDetails.Add(newDevice);
                }
            }
        }
Ejemplo n.º 3
0
        private int GetDeviceIndexForDeviceDetails(DeviceDetails deviceDetails, MinerProcess minerProcess)
        {
            int result = devices
                .FindIndex((device) => {
                    return device.Driver.Equals(deviceDetails.Driver, StringComparison.OrdinalIgnoreCase)
                    &&
                    (
                        //serial == serial && path == path (serial may not be unique)
                        (!String.IsNullOrEmpty(device.Serial) && device.Serial.Equals(deviceDetails.Serial, StringComparison.OrdinalIgnoreCase)
                            && !String.IsNullOrEmpty(device.Path) && device.Path.Equals(deviceDetails.DevicePath, StringComparison.OrdinalIgnoreCase))

                        //serial == serial && path == String.Empty - WinUSB/LibUSB has no path, but has a serial #
                        || (!String.IsNullOrEmpty(device.Serial) && device.Serial.Equals(deviceDetails.Serial, StringComparison.OrdinalIgnoreCase)
                            && String.IsNullOrEmpty(device.Path) && String.IsNullOrEmpty(deviceDetails.DevicePath))

                        //path == path
                        || (!String.IsNullOrEmpty(device.Path) && device.Path.Equals(deviceDetails.DevicePath, StringComparison.OrdinalIgnoreCase))

                        //proxy == proxy && ID = RelativeIndex
                        || (device.Driver.Equals("proxy", StringComparison.OrdinalIgnoreCase) && (minerProcess.MinerConfiguration.DeviceDescriptors.Contains(device)))

                        //opencl = opencl && ID = RelativeIndex
                        || (device.Driver.Equals("opencl", StringComparison.OrdinalIgnoreCase) && (device.RelativeIndex == deviceDetails.ID))

                        //cpu = cpu && ID = RelativeIndex
                        || (device.Driver.Equals("cpu", StringComparison.OrdinalIgnoreCase) && (device.RelativeIndex == deviceDetails.ID))
                    );

                });

            return result;
        }
Ejemplo n.º 4
0
        private int GetDeviceIndexForDeviceDetails(DeviceDetails deviceDetails)
        {
            for (int i = 0; i < devices.Count; i++)
            {
                Xgminer.Data.Device device = devices[i];

                if (device.Driver.Equals(deviceDetails.Driver, StringComparison.OrdinalIgnoreCase)
                    &&
                    (
                    //serial == serial && path == path (serial may not be unique)
                    (!String.IsNullOrEmpty(device.Serial) && device.Serial.Equals(deviceDetails.Serial, StringComparison.OrdinalIgnoreCase)
                      && !String.IsNullOrEmpty(device.Path) && device.Path.Equals(deviceDetails.DevicePath, StringComparison.OrdinalIgnoreCase))

                    //serial == serial && path == String.Empty - WinUSB/LibUSB has no path, but has a serial #
                    || (!String.IsNullOrEmpty(device.Serial) && device.Serial.Equals(deviceDetails.Serial, StringComparison.OrdinalIgnoreCase)
                      && String.IsNullOrEmpty(device.Path) && String.IsNullOrEmpty(deviceDetails.DevicePath))

                    //path == path
                    || (!String.IsNullOrEmpty(device.Path) && device.Path.Equals(deviceDetails.DevicePath, StringComparison.OrdinalIgnoreCase))

                    //proxy == proxy
                    || (device.Driver.Equals("proxy", StringComparison.OrdinalIgnoreCase))

                    //opencl = opencl && ID = RelativeIndex
                    || (device.Driver.Equals("opencl", StringComparison.OrdinalIgnoreCase) && (device.RelativeIndex == deviceDetails.ID))

                    //cpu = cpu && ID = RelativeIndex
                    || (device.Driver.Equals("cpu", StringComparison.OrdinalIgnoreCase) && (device.RelativeIndex == deviceDetails.ID))

                    ))
                {
                    return i;
                }
            }

            return -1;
        }