using Aurora; using Aurora.Api; using AuroraCellTracker; using System; using System.Reactive.Linq; using System.Windows; using VisionCommon; using WeldingCommon.Data; using WeldingCommon.Sequences; namespace WeldingCommon.Settings { public class SystemParameterManager { private static IAuroraEnvironment _auroraEnv { get; set; } public static SystemParameter SysParam { get; set; } private static bool _IsInitialized = false; public static void Initialize(IAuroraEnvironment aurora) { if (!_IsInitialized) { _auroraEnv = aurora; _auroraEnv.EventObservable .AsObservable(AuroraSysEvent.SYS_SETTING_CHANGED) .Where(msg => (string)msg.Param == CommonSettingIds.SystemParameter) .Select(msg => msg.From) .Subscribe(UpdateSystemParameter); UpdateSystemParameter("Init"); FieldScanParams.GetInstance().Initialize(_auroraEnv); _IsInitialized = true; } } private static void UpdateSystemParameter(string from) { SysParam = _auroraEnv.SettingEntry[CommonSettingIds.SystemParameter] as SystemParameter; if (from == "Init" || from == "USER_via_UI") { UpdateVisionRecipeFromSystemParameter(); } } private static void UpdateVisionRecipeFromSystemParameter() { var forInfos = VisionRecipeManager.GetFovInfos(); if (forInfos == null || forInfos.Count == 0) { MessageBox.Show("현재 Active된 Recipe의 Vision Recipe를 확인 해 주세요"); return; } var forRecipes = VisionRecipeManager.GetFovRecipes(forInfos); if (forRecipes == null) return; foreach (var forRecipe in forRecipes) { // PixelSize forRecipe.CalFovRecipe.PixelSize.X = SysParam.CameraPixelSize; forRecipe.CalFovRecipe.PixelSize.Y = SysParam.CameraPixelSize; } RecipeFileManager.SaveVisionRecipe(); } } }