41 lines
1.7 KiB
C#
41 lines
1.7 KiB
C#
using Microsoft.Extensions.DependencyInjection;
|
|
using Seyounth.Auto.Hs.Runtime.Balances;
|
|
using Seyounth.Auto.Hs.Runtime.Handlers;
|
|
using Seyounth.Auto.Hs.Runtime.Plc;
|
|
using Seyounth.Auto.Hs.Runtime.Printer;
|
|
using Seyounth.Auto.Hs.Runtime.Scanner;
|
|
|
|
namespace Seyounth.Auto.Hs.Runtime;
|
|
|
|
public static class HsExtensions
|
|
{
|
|
/// <summary>
|
|
/// 添加HS手动包装服务
|
|
/// </summary>
|
|
/// <param name="services"></param>
|
|
/// <typeparam name="TOnWarningHandler">报警信息处理器</typeparam>
|
|
/// <typeparam name="TWeighBoxRequestHandler">纸箱称重处理器</typeparam>
|
|
/// <typeparam name="TWeighSpindleRequestHandler">丝锭称重处理器</typeparam>
|
|
/// <returns></returns>
|
|
public static IServiceCollection AddHs<TOnWarningHandler, TWeighBoxRequestHandler, TWeighSpindleRequestHandler>(
|
|
this IServiceCollection services)
|
|
where TOnWarningHandler : OnWarningHandler
|
|
where TWeighBoxRequestHandler : WeighSpindleRequestHandler
|
|
where TWeighSpindleRequestHandler : WeighSpindleRequestHandler
|
|
{
|
|
services.AddSingleton<IBalanceService, BalanceService>();
|
|
services.AddSingleton<IPlcService, PlcService>();
|
|
services.AddSingleton<IPrinterService, PrinterService>();
|
|
services.AddSingleton<IScannerService, ScannerService>();
|
|
services.AddSingleton<IHsAutoRuntime, HsAutoRuntime>();
|
|
#region 接口调试阶段先注释
|
|
//services.AddHostedService<PlcBackgroundService>();
|
|
// services.AddHostedService<HsBackgroundService>();
|
|
#endregion
|
|
services.AddMediatR(cfg =>
|
|
{
|
|
cfg.RegisterServicesFromAssembly(typeof(OnWarningHandler).Assembly);
|
|
});
|
|
return services;
|
|
}
|
|
} |