33 lines
989 B
C#
33 lines
989 B
C#
using JSMachine.WMS.Common;
|
|||
|
|
using JSMachine.WMS.Infrastructure.AppConfiguration;
|
||
|
|
using Microsoft.AspNetCore.Builder;
|
||
|
|
using System;
|
||
|
|
using System.Collections.Generic;
|
||
|
|
using System.Linq;
|
||
|
|
using System.Text;
|
||
|
|
using System.Threading.Tasks;
|
||
|
|
|
||
|
|
namespace JSMachine.WMS.PLC.ModbusImpl.Elevator.Exstension
|
||
|
|
{
|
||
|
|
/// <summary>
|
||
|
|
/// 电梯 PLC 的 ASP.NET Core 应用构建扩展。
|
||
|
|
/// </summary>
|
||
|
|
public static class ElevatorPlcExstension
|
||
|
|
{
|
||
|
|
/// <summary>
|
||
|
|
/// 按配置异步初始化每台电梯的 PLC 连接。
|
||
|
|
/// </summary>
|
||
|
|
/// <param name="app">当前应用构建器。</param>
|
||
|
|
public static void UseElevatorPlc(this IApplicationBuilder app)
|
||
|
|
{
|
||
|
|
foreach (ElevatorConfig elevatorConfig in Global.AppSettings.ElevatorConfig)
|
||
|
|
{
|
||
|
|
Task.Run(() =>
|
||
|
|
{
|
||
|
|
new ElevatorPlc().Init(elevatorConfig.IP, elevatorConfig.Port);
|
||
|
|
});
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|