You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
166 lines
8.7 KiB
C#
166 lines
8.7 KiB
C#
using Admin.Core.Common;
|
|
using Admin.Core.IService.IService_New;
|
|
using Aucma.Core.DataCollector.Factory;
|
|
using log4net;
|
|
using Microsoft.AspNetCore.Builder;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using Org.BouncyCastle.Crypto.Tls;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Aucma.Core.DataCollector
|
|
{
|
|
public static class DataCollectorSetup
|
|
{
|
|
public static readonly log4net.ILog _logger = LogManager.GetLogger(typeof(DataCollectorSetup));
|
|
|
|
public static IApplicationBuilder UseDataCollectorExtensions(this IApplicationBuilder app)
|
|
{
|
|
if (app == null) throw new ArgumentNullException(nameof(app));
|
|
|
|
var stationCode = Appsettings.app("StationInfo", "StationCode");
|
|
|
|
var _deviceParamServices = app.ApplicationServices.GetService<IBaseDeviceParamServices>();
|
|
var _deviceAlarmInfoServices = app.ApplicationServices.GetService<IRecordDeviceAlarmInfoServices>();
|
|
var _deviceElectricityServices = app.ApplicationServices.GetService< IRecordDeviceElectricityServices>();
|
|
|
|
if (!string.IsNullOrEmpty(stationCode))
|
|
{
|
|
try
|
|
{
|
|
if (stationCode == "1002") //暂未使用--箱壳、内胆,包含预装线、集存库
|
|
{
|
|
Task.Run(() =>
|
|
{
|
|
DataCollectorFactory collector = new ShellStoreFactory(_deviceParamServices, _deviceAlarmInfoServices, _deviceElectricityServices);
|
|
|
|
Parallel.Invoke(() => collector.CollectDeviceAlarmInfo(out var alarmInfos), () => collector.CollectDeviceElectricity(out var electricity));
|
|
});
|
|
|
|
Task.Run(() =>
|
|
{
|
|
DataCollectorFactory collector = new LinerStoreFactory(_deviceParamServices, _deviceAlarmInfoServices, _deviceElectricityServices);
|
|
|
|
Parallel.Invoke(() => collector.CollectDeviceAlarmInfo(out var alarmInfos), () => collector.CollectDeviceElectricity(out var electricity));
|
|
});
|
|
}
|
|
|
|
else if (stationCode == "1005")//箱体发泡、发泡线、发泡机、异常数据采集
|
|
{
|
|
Console.WriteLine("开始执行异常数据采集");
|
|
//发泡机
|
|
Task.Run(() =>
|
|
{
|
|
DataCollectorFactory collector = new BoxFoamFactory(_deviceParamServices, _deviceAlarmInfoServices, _deviceElectricityServices);
|
|
|
|
Parallel.Invoke(() => collector.CollectDeviceAlarmInfo(out var alarmInfos), () => collector.CollectDeviceElectricity(out var electricity));
|
|
});
|
|
//发泡线1
|
|
Task.Run(() =>
|
|
{
|
|
DataCollectorFactory collector = new BoxFoamFixture1Factory(_deviceParamServices, _deviceAlarmInfoServices, _deviceElectricityServices);
|
|
|
|
Parallel.Invoke(() => collector.CollectDeviceAlarmInfo(out var alarmInfos), () => collector.CollectDeviceElectricity(out var electricity));
|
|
});
|
|
//发泡线2
|
|
Task.Run(() =>
|
|
{
|
|
DataCollectorFactory collector = new BoxFoamFixture2Factory(_deviceParamServices, _deviceAlarmInfoServices, _deviceElectricityServices);
|
|
|
|
Parallel.Invoke(() => collector.CollectDeviceAlarmInfo(out var alarmInfos), () => collector.CollectDeviceElectricity(out var electricity));
|
|
});
|
|
}
|
|
else if (stationCode == "1008")//条码绑定工位
|
|
{
|
|
// 包装线采集
|
|
Task.Run(() =>
|
|
{
|
|
DataCollectorFactory collector = new PackingCX02Factory(_deviceParamServices, _deviceAlarmInfoServices, _deviceElectricityServices);
|
|
|
|
Parallel.Invoke(() => collector.CollectDeviceAlarmInfo(out var alarmInfos), () => collector.CollectDeviceElectricity(out var electricity));
|
|
});
|
|
|
|
// 箱壳
|
|
Task.Run(() =>
|
|
{
|
|
DataCollectorFactory collector = new ShellStoreFactory(_deviceParamServices, _deviceAlarmInfoServices, _deviceElectricityServices);
|
|
|
|
Parallel.Invoke(() => collector.CollectDeviceAlarmInfo(out var alarmInfos), () => collector.CollectDeviceElectricity(out var electricity));
|
|
});
|
|
// 内胆
|
|
Task.Run(() =>
|
|
{
|
|
DataCollectorFactory collector = new LinerStoreFactory(_deviceParamServices, _deviceAlarmInfoServices, _deviceElectricityServices);
|
|
|
|
Parallel.Invoke(() => collector.CollectDeviceAlarmInfo(out var alarmInfos), () => collector.CollectDeviceElectricity(out var electricity));
|
|
});
|
|
//箱壳预装线
|
|
Task.Run(() =>
|
|
{
|
|
DataCollectorFactory collector = new ShellPreassembleFactory(_deviceParamServices, _deviceAlarmInfoServices, _deviceElectricityServices);
|
|
|
|
Parallel.Invoke(() => collector.CollectDeviceAlarmInfo(out var alarmInfos), () => collector.CollectDeviceElectricity(out var electricity));
|
|
});
|
|
// 内胆预装线
|
|
Task.Run(() =>
|
|
{
|
|
DataCollectorFactory collector = new LinerPreassembleFactory(_deviceParamServices, _deviceAlarmInfoServices, _deviceElectricityServices);
|
|
|
|
Parallel.Invoke(() => collector.CollectDeviceAlarmInfo(out var alarmInfos), () => collector.CollectDeviceElectricity(out var electricity));
|
|
});
|
|
// 泡后库
|
|
Task.Run(() =>
|
|
{
|
|
DataCollectorFactory collector = new FoamBackFactory(_deviceParamServices, _deviceAlarmInfoServices, _deviceElectricityServices);
|
|
|
|
Parallel.Invoke(() => collector.CollectDeviceAlarmInfo(out var alarmInfos), () => collector.CollectDeviceElectricity(out var electricity));
|
|
});
|
|
}
|
|
else if (stationCode == "1010")//分垛A库
|
|
{
|
|
// 二线分垛
|
|
Task.Run(() =>
|
|
{
|
|
DataCollectorFactory collector = new PalletizFactory(_deviceParamServices, _deviceAlarmInfoServices, _deviceElectricityServices);
|
|
|
|
Parallel.Invoke(() => collector.CollectDeviceAlarmInfo(out var alarmInfos), () => collector.CollectDeviceElectricity(out var electricity));
|
|
});
|
|
// 二线输送平台
|
|
Task.Run(() =>
|
|
{
|
|
DataCollectorFactory collector = new TransPlatformCX02Factory(_deviceParamServices, _deviceAlarmInfoServices, _deviceElectricityServices);
|
|
|
|
Parallel.Invoke(() => collector.CollectDeviceAlarmInfo(out var alarmInfos), () => collector.CollectDeviceElectricity(out var electricity));
|
|
});
|
|
}
|
|
else if (stationCode == "1012")//门体发泡
|
|
{
|
|
Console.WriteLine("开始执行异常数据采集");
|
|
Task.Run(() =>
|
|
{
|
|
DataCollectorFactory collector = new DoorFoamFactory(_deviceParamServices, _deviceAlarmInfoServices, _deviceElectricityServices);
|
|
|
|
Parallel.Invoke(() => collector.CollectDeviceAlarmInfo(out var alarmInfos), () => collector.CollectDeviceElectricity(out var electricity));
|
|
});
|
|
}
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
_logger.Error($"UseDataCollectorExtensions逻辑执行异常:{ex.Message}");
|
|
}
|
|
}
|
|
else
|
|
{
|
|
new InvalidOperationException($"设备数据采集逻辑初始化失败:未获取到工位编号");
|
|
}
|
|
|
|
|
|
return app;
|
|
}
|
|
}
|
|
}
|