public static void AfterDeviceQueryInitialization() { // extra check (probably will never happen but just in case) { List <ComputeDevice> invalidDevices = new List <ComputeDevice>(); foreach (var CDev in ComputeDeviceManager.Avaliable.AllAvaliableDevices) { if (CDev.IsAlgorithmSettingsInitialized() == false) { Helpers.ConsolePrint(TAG, "CRITICAL ISSUE!!! Device has AlgorithmSettings == null. Will remove"); invalidDevices.Add(CDev); } } // remove invalids foreach (var invalid in invalidDevices) { ComputeDeviceManager.Avaliable.AllAvaliableDevices.Remove(invalid); } } // set enabled/disabled devs foreach (var CDev in ComputeDeviceManager.Avaliable.AllAvaliableDevices) { foreach (var devConf in GeneralConfig.LastDevicesSettup) { CDev.SetFromComputeDeviceConfig(devConf); } } // create/init device benchmark configs files and configs foreach (var CDev in ComputeDeviceManager.Avaliable.AllAvaliableDevices) { string 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(); }
public static void RestoreBackup() { // restore general GeneralConfig = GeneralConfigBackup; if (GeneralConfig.LastDevicesSettup != null) { foreach (var CDev in ComputeDeviceManager.Avaliable.AllAvaliableDevices) { foreach (var conf in GeneralConfig.LastDevicesSettup) { CDev.SetFromComputeDeviceConfig(conf); } } } // restore benchmarks foreach (var CDev in ComputeDeviceManager.Avaliable.AllAvaliableDevices) { if (BenchmarkConfigsBackup != null && BenchmarkConfigsBackup.ContainsKey(CDev.UUID)) { CDev.SetAlgorithmDeviceConfig(BenchmarkConfigsBackup[CDev.UUID]); } } }