コード例 #1
0
        public static void AfterDeviceQueryInitialization()
        {
            // extra check (probably will never happen but just in case)
            AvailableDevices.RemoveInvalidDevs();

            // set enabled/disabled devs
            foreach (var cDev in AvailableDevices.Devices)
            {
                foreach (var devConf in GeneralConfig.LastDevicesSettup)
                {
                    cDev.SetFromComputeDeviceConfig(devConf);
                }
            }
            // create/init device benchmark configs files and configs
            foreach (var cDev in AvailableDevices.Devices)
            {
                var keyUuid = cDev.Uuid;
                BenchmarkConfigFiles[keyUuid] = new DeviceBenchmarkConfigFile(keyUuid);
                // init
                {
                    DeviceBenchmarkConfig currentConfig = null;
                    if (BenchmarkConfigFiles[keyUuid].IsFileExists())
                    {
                        currentConfig = BenchmarkConfigFiles[keyUuid].ReadFile();
                    }
                    // config exists and file load success set from file
                    if (currentConfig != null)
                    {
                        cDev.SetAlgorithmDeviceConfig(currentConfig);
                        // if new version create backup
                        if (_isNewVersion)
                        {
                            BenchmarkConfigFiles[keyUuid].CreateBackup();
                        }
                    }
                    else
                    {
                        // no config file or not loaded, create new
                        BenchmarkConfigFiles[keyUuid].Commit(cDev.GetAlgorithmDeviceConfig());
                    }
                }
            }
            // save settings
            GeneralConfigFileCommit();
        }