2026-06-05 13:44:39 +09:00

59 lines
1.8 KiB
C#

using Aurora;
using Aurora.Api;
using Aurora.Api.Manager;
using AuroraMassFlowMeter;
using AuroraOCT.Trumpf;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using WeldingCommon.Recipes;
using WeldingCommon.RMS;
namespace WeldingCommon.Utils
{
public static class AuroraEx
{
public static bool IsAutoActivation(this Device dev)
{
var Config = Application.Current.AuroraEnv().DeviceManager.GetDeviceConfig(dev.DeviceId);
if(Config is OCTConfig config)
return config.IsAutoActivation;
return true;
}
#region RMS Interface object
private static Func<RMSHandler> _factory;
private static readonly ConcurrentDictionary<Type, RMSHandler> _cache = new ConcurrentDictionary<Type, RMSHandler>();
public static void RegisterRmsHandler<T>() where T : RMSHandler, new()
{
_factory = () => (RMSHandler)_cache.GetOrAdd(typeof(T), _ => new T());
}
public static RMSHandler RmsHandler(this IRecipeManager _)
{
if (_factory == null)
throw new InvalidOperationException("RMSHandler가 등록되지 않았습니다. AuroraEx.RegisterRmsHandler<T>()를 먼저 호출하세요.");
return _factory();
}
#endregion
#region Recipe History Interface object
private static RecipeChangeHistoryHandler _Instance;
public static RecipeChangeHistoryHandler RchHandler(this IRecipeManager _)
{
if (_Instance == null)
_Instance = new RecipeChangeHistoryHandler();
return _Instance;
}
#endregion
}
}