using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;
using SlnMesnac.Plc.Factory;

namespace SlnMesnac.Plc
{
    public static class PlcSetup
    {
        public static void AddPlcSetup(this IServiceCollection services)
        {
            services.AddSingleton<PlcPool>();

            //services.AddSingleton<PlcAbsractFactory>();
            services.AddSingleton<InovanceFactory>();
            services.AddSingleton<MelsecBinaryFactory>();
            services.AddSingleton<OmronNJFactory>();
            services.AddSingleton<SiemensFactory>();
        }

        public static IApplicationBuilder UsePlcExtensions(this IApplicationBuilder app)
        {
            var plcPool = app.ApplicationServices.GetService<PlcPool>();
            plcPool.Init();
            return app;
        }
    }
}
