change - 修改数据采集模块,添加箱壳、内胆、泡后数据采集

dev
wenjy 10 months ago
parent 95797c6d9a
commit 80855072cf

@ -15,7 +15,7 @@ using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("Admin.Core.Api")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+91808221759aca287573a9c1018fc2e65b1bfd59")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+95797c6d9a18bfc6da212ef8f1ab31fca740c669")]
[assembly: System.Reflection.AssemblyProductAttribute("Admin.Core.Api")]
[assembly: System.Reflection.AssemblyTitleAttribute("Admin.Core.Api")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]

@ -1 +1 @@
7ce13daf26e56bd8d3c3406081a61aabff4db9fa4cbea6946a0de6ad91f7687f
b2337fe7e5d6fda0ca43b7463be7bbc56ef4d6f810a4050486b6e1940f30b088

@ -14,7 +14,7 @@ using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("Admin.Core.Common")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+91808221759aca287573a9c1018fc2e65b1bfd59")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+95797c6d9a18bfc6da212ef8f1ab31fca740c669")]
[assembly: System.Reflection.AssemblyProductAttribute("Admin.Core.Common")]
[assembly: System.Reflection.AssemblyTitleAttribute("Admin.Core.Common")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]

@ -1 +1 @@
62ae8b13d646c1bee38f596428b0c65aebc8cacc7f8546b0fc7f279f33ddbb5f
a618e8897232ac6ea4e91122b9779d78e457ffe9a6ccd359c19bbb88b3c45edd

@ -14,7 +14,7 @@ using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("Admin.Core.EventBus")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+91808221759aca287573a9c1018fc2e65b1bfd59")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+95797c6d9a18bfc6da212ef8f1ab31fca740c669")]
[assembly: System.Reflection.AssemblyProductAttribute("Admin.Core.EventBus")]
[assembly: System.Reflection.AssemblyTitleAttribute("Admin.Core.EventBus")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]

@ -1 +1 @@
9f6d3940f2a70f8fd050d6fe20a1178b54354adc92bcb268eeb7e95d388fdd79
ea3e4733aaa18e40a302d1139b12a468c5c4b1a7942ddaa4050bf9fc4640f955

@ -14,7 +14,7 @@ using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("Admin.Core.Extensions")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+91808221759aca287573a9c1018fc2e65b1bfd59")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+95797c6d9a18bfc6da212ef8f1ab31fca740c669")]
[assembly: System.Reflection.AssemblyProductAttribute("Admin.Core.Extensions")]
[assembly: System.Reflection.AssemblyTitleAttribute("Admin.Core.Extensions")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]

@ -1 +1 @@
6fb9d9c8187ad98357a41595af7692e35588e2f7d760b068489ada94d6798f74
0f93dbc77ec673200bd7368b0df86e38f4ed62930373a730eaff15686dd7c7b6

@ -14,7 +14,7 @@ using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("Admin.Core.FrameWork")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+91808221759aca287573a9c1018fc2e65b1bfd59")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+95797c6d9a18bfc6da212ef8f1ab31fca740c669")]
[assembly: System.Reflection.AssemblyProductAttribute("Admin.Core.FrameWork")]
[assembly: System.Reflection.AssemblyTitleAttribute("Admin.Core.FrameWork")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]

@ -1 +1 @@
7a1813a9a5d1d19b18e25488399390e5b0d29d88f5978494e031c73a36870caf
7fb166de25c175187e65a7a6f6ffb17b4d86d3d6f47f3d39800f450985890ae4

@ -14,7 +14,7 @@ using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("Admin.Core.IRepository")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+91808221759aca287573a9c1018fc2e65b1bfd59")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+95797c6d9a18bfc6da212ef8f1ab31fca740c669")]
[assembly: System.Reflection.AssemblyProductAttribute("Admin.Core.IRepository")]
[assembly: System.Reflection.AssemblyTitleAttribute("Admin.Core.IRepository")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]

@ -1 +1 @@
e8dda769d754c133979679ea930a6ef1414630c974be509211ac8b020c80e812
d1de46d4cea04a95f16ffdd3c5c78f8a095cd4a4de4af8bdb815cf8eb11b5ece

@ -14,7 +14,7 @@ using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("Admin.Core.IService")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+91808221759aca287573a9c1018fc2e65b1bfd59")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+95797c6d9a18bfc6da212ef8f1ab31fca740c669")]
[assembly: System.Reflection.AssemblyProductAttribute("Admin.Core.IService")]
[assembly: System.Reflection.AssemblyTitleAttribute("Admin.Core.IService")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]

@ -1 +1 @@
ca087abdcdbbd7244fdd8502c33b3a29363be91638d305d0b22c5f768402d46f
2d250522305d6e2e5025a59c967b0a68c64d3d1a170cbaaff284984ea0372026

@ -14,7 +14,7 @@ using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("Admin.Core.Model")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+91808221759aca287573a9c1018fc2e65b1bfd59")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+95797c6d9a18bfc6da212ef8f1ab31fca740c669")]
[assembly: System.Reflection.AssemblyProductAttribute("Admin.Core.Model")]
[assembly: System.Reflection.AssemblyTitleAttribute("Admin.Core.Model")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]

@ -1 +1 @@
791e45baa48214d65e9377a8397597943892aba54a1a10d284895eacbbfa4352
8561683fdff2f8094ea69771ec03792a7434406a280d6b6087be70ccf45950b5

@ -14,7 +14,7 @@ using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("Admin.Core.RealTimeService")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+91808221759aca287573a9c1018fc2e65b1bfd59")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+95797c6d9a18bfc6da212ef8f1ab31fca740c669")]
[assembly: System.Reflection.AssemblyProductAttribute("Admin.Core.RealTimeService")]
[assembly: System.Reflection.AssemblyTitleAttribute("Admin.Core.RealTimeService")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]

@ -1 +1 @@
b90aaf21ce2e9da9e13b0fb64d65797eba9a93af543963c310c73e113c750708
ba4c9f410f5a53ca2418c45fb63499b8408c300e758240a71ce6f546c9f6e71a

@ -14,7 +14,7 @@ using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("Admin.Core.Repository")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+91808221759aca287573a9c1018fc2e65b1bfd59")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+95797c6d9a18bfc6da212ef8f1ab31fca740c669")]
[assembly: System.Reflection.AssemblyProductAttribute("Admin.Core.Repository")]
[assembly: System.Reflection.AssemblyTitleAttribute("Admin.Core.Repository")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]

@ -1 +1 @@
7ef6935943cbb87b58f408d9001fa5f238f2ee69bd00ae4bb77d9cdef1c5a8e6
829e21d51dcc0fcc2158d7a2d0886e1f2eaf68c2cd64a201aa7728ea368ab90a

@ -14,7 +14,7 @@ using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("Admin.Core.Serilog.Es")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+91808221759aca287573a9c1018fc2e65b1bfd59")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+95797c6d9a18bfc6da212ef8f1ab31fca740c669")]
[assembly: System.Reflection.AssemblyProductAttribute("Admin.Core.Serilog.Es")]
[assembly: System.Reflection.AssemblyTitleAttribute("Admin.Core.Serilog.Es")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]

@ -1 +1 @@
7e4c0482a63e6bdc9d58ba83f484a41ef7633ab886d66aa8de108234c74c3e9b
c8f478eecd1ef8a52cf42637f8b161109c9603f8ad626a88a98b9837d0907947

@ -14,7 +14,7 @@ using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("Admin.Core.Service")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+91808221759aca287573a9c1018fc2e65b1bfd59")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+95797c6d9a18bfc6da212ef8f1ab31fca740c669")]
[assembly: System.Reflection.AssemblyProductAttribute("Admin.Core.Service")]
[assembly: System.Reflection.AssemblyTitleAttribute("Admin.Core.Service")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]

@ -1 +1 @@
64cffb2d314040efeb0c4c286bc1d1b31d9ca3601ab470ebea09444eaf3d81e8
931cb7f6ab57ef1e4fe5830b07b1e7f8967fd7528de4847745341f2c4fa682bf

@ -14,7 +14,7 @@ using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("Admin.Core.Tasks")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+91808221759aca287573a9c1018fc2e65b1bfd59")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+95797c6d9a18bfc6da212ef8f1ab31fca740c669")]
[assembly: System.Reflection.AssemblyProductAttribute("Admin.Core.Tasks")]
[assembly: System.Reflection.AssemblyTitleAttribute("Admin.Core.Tasks")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]

@ -1 +1 @@
ed2444c9be6f03c06e36309150ba72a30e6eef0501c11fcb012bc3a49ae67b45
daee51f4ae0b8018b8c418b16172fb8ecd139d668d52bb1ab537277927f58958

@ -1,4 +1,8 @@
using Admin.Core.Model.Model_New;
using Admin.Core.IService.IService_New;
using Admin.Core.Model.Model_New;
using Aucma.Core.DataCollector.Factory;
using Aucma.Core.HwPLc;
using log4net;
using System;
using System.Collections.Generic;
using System.Linq;
@ -12,6 +16,18 @@ namespace Aucma.Core.DataCollector
/// </summary>
public abstract class DataCollectorFactory
{
public readonly log4net.ILog _logger = LogManager.GetLogger(typeof(DataCollectorFactory));
public readonly IBaseDeviceParamServices _deviceParamServices;
public readonly IRecordDeviceAlarmInfoServices _deviceAlarmInfoServices;
public readonly IRecordDeviceElectricityServices _deviceElectricityServices;
public DataCollectorFactory(IBaseDeviceParamServices deviceParamServices, IRecordDeviceAlarmInfoServices deviceAlarmInfoServices, IRecordDeviceElectricityServices deviceElectricityServices)
{
_deviceParamServices = deviceParamServices;
_deviceAlarmInfoServices = deviceAlarmInfoServices;
_deviceElectricityServices = deviceElectricityServices;
}
/// <summary>
/// 采集设备报警信息
@ -24,5 +40,39 @@ namespace Aucma.Core.DataCollector
/// </summary>
/// <param name="deviceElectricity"></param>
public abstract void CollectDeviceElectricity(out Record_DeviceElectricity deviceElectricity);
/// <summary>
/// 读取PLC数据
/// </summary>
/// <param name="_plc"></param>
/// <param name="addr"></param>
/// <param name="dataType"></param>
/// <param name="paramValue"></param>
public void ReadParamValueByPlc(IPlc _plc, string addr, string dataType, out int paramValue)
{
object result = null;
switch (dataType)
{
case "int":
result = _plc.ReadInt16(addr);
break;
case "float":
result = _plc.ReadFloat(addr);
break;
case "bool":
result = _plc.ReadBool(addr);
break;
default:
result = _plc.ReadInt16(addr);
break;
}
if (result == null)
{
result = "0";
}
paramValue = Convert.ToInt32(result);
}
}
}

@ -0,0 +1,67 @@
using Admin.Core.Common;
using Admin.Core.IService.IService_New;
using Aucma.Core.DataCollector.Factory;
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 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))
{
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")//泡前库、发泡线、发泡机、泡后库
{
Task.Run(() =>
{
DataCollectorFactory collector = new BoxFoamFactory(_deviceParamServices, _deviceAlarmInfoServices, _deviceElectricityServices);
Parallel.Invoke(() => collector.CollectDeviceAlarmInfo(out var alarmInfos), () => collector.CollectDeviceElectricity(out var electricity));
});
}else if(stationCode == "1010")//成品分垛
{
Task.Run(() =>
{
DataCollectorFactory collector = new PalletizFactory(_deviceParamServices, _deviceAlarmInfoServices, _deviceElectricityServices);
Parallel.Invoke(() => collector.CollectDeviceAlarmInfo(out var alarmInfos), () => collector.CollectDeviceElectricity(out var electricity));
});
}
}
return app;
}
}
}

@ -0,0 +1,91 @@
using Admin.Core.IService.IService_New;
using Admin.Core.Model.Model_New;
using Aucma.Core.HwPLc;
using log4net;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Aucma.Core.DataCollector.Factory
{
/// <summary>
/// 泡前库、发泡线、发泡机、泡后库数据采集
/// </summary>
public class BoxFoamFactory : DataCollectorFactory
{
private PlcModel _plc = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("Test"));
public BoxFoamFactory(IBaseDeviceParamServices deviceParamServices, IRecordDeviceAlarmInfoServices deviceAlarmInfoServices, IRecordDeviceElectricityServices deviceElectricityServices) : base(deviceParamServices, deviceAlarmInfoServices, deviceElectricityServices)
{
}
/// <summary>
/// 采集泡前库、发泡线、发泡机、泡后库设备报警信息
/// </summary>
/// <param name="deviceAlarmInfos"></param>
public override void CollectDeviceAlarmInfo(out List<Record_DeviceAlarmInfo> deviceAlarmInfos)
{
while (true)
{
try
{
if (_plc != null)
{
Console.WriteLine($"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}采集泡前库、发泡线、发泡机、泡后库设备报警信息");
var plc = _plc.plc;
var deviceParams = base._deviceParamServices.Query(x => x.DeviceCode == "E00009");
if (deviceParams != null)
{
deviceAlarmInfos = new List<Record_DeviceAlarmInfo>();
string batchId = System.Guid.NewGuid().ToString("N");
foreach (var item in deviceParams)
{
base.ReadParamValueByPlc(plc, item.ParamAddress, item.ParamType, out int paramValue);
if (paramValue != 0)
{
deviceAlarmInfos.Add(new Record_DeviceAlarmInfo()
{
BatchId = batchId,
DeviceCode = item.DeviceCode,
DeviceType = "1",
ParamCode = item.ParamCode,
ParamValue = paramValue.ToString(),
AlarmInfo = item.ParamName,
AlarmTime = DateTime.Now,
CreadtedTime = DateTime.Now,
});
}
}
if (deviceAlarmInfos.Count > 0)
{
base._deviceAlarmInfoServices.AddAsync(deviceAlarmInfos);
}
}
Task.Delay(1000 * 5).Wait();
}
else
{
Task.Delay(1000 * 5).Wait();
_plc = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("Test"));
}
}
catch (Exception ex)
{
base._logger.Error($"采集泡前库、发泡线、发泡机、泡后库设备报警信息:{ex.Message}");
}
}
}
public override void CollectDeviceElectricity(out Record_DeviceElectricity deviceElectricity)
{
throw new NotImplementedException();
}
}
}

@ -0,0 +1,91 @@
using Admin.Core.IService.IService_New;
using Admin.Core.Model.Model_New;
using Aucma.Core.HwPLc;
using log4net;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Aucma.Core.DataCollector.Factory
{
/// <summary>
/// 内胆预装、内胆库数据采集
/// </summary>
public class LinerStoreFactory : DataCollectorFactory
{
private PlcModel _plc = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("Test"));
public LinerStoreFactory(IBaseDeviceParamServices deviceParamServices, IRecordDeviceAlarmInfoServices deviceAlarmInfoServices, IRecordDeviceElectricityServices deviceElectricityServices) : base(deviceParamServices, deviceAlarmInfoServices, deviceElectricityServices)
{
}
/// <summary>
/// 采集内胆预装、内胆库设备报警信息
/// </summary>
/// <param name="deviceAlarmInfos"></param>
public override void CollectDeviceAlarmInfo(out List<Record_DeviceAlarmInfo> deviceAlarmInfos)
{
while (true)
{
try
{
if (_plc != null)
{
Console.WriteLine($"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}采集内胆预装、内胆库设备报警信息");
var plc = _plc.plc;
var deviceParams = base._deviceParamServices.Query(x => x.DeviceCode == "E00024" || x.DeviceCode == "E00032");
if (deviceParams != null)
{
deviceAlarmInfos = new List<Record_DeviceAlarmInfo>();
string batchId = System.Guid.NewGuid().ToString("N");
foreach (var item in deviceParams)
{
base.ReadParamValueByPlc(plc, item.ParamAddress, item.ParamType, out int paramValue);
if (paramValue != 0)
{
deviceAlarmInfos.Add(new Record_DeviceAlarmInfo()
{
BatchId = batchId,
DeviceCode = item.DeviceCode,
DeviceType = "1",
ParamCode = item.ParamCode,
ParamValue = paramValue.ToString(),
AlarmInfo = item.ParamName,
AlarmTime = DateTime.Now,
CreadtedTime = DateTime.Now,
});
}
}
if (deviceAlarmInfos.Count > 0)
{
base._deviceAlarmInfoServices.AddAsync(deviceAlarmInfos);
}
}
Task.Delay(1000 * 5).Wait();
}
else
{
Task.Delay(1000 * 5).Wait();
_plc = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("Test"));
}
}
catch (Exception ex)
{
base._logger.Error($"采集内胆预装、内胆库设备报警信息异常:{ex.Message}");
}
}
}
public override void CollectDeviceElectricity(out Record_DeviceElectricity deviceElectricity)
{
throw new NotImplementedException();
}
}
}

@ -12,23 +12,14 @@ namespace Aucma.Core.DataCollector.Factory
/// </summary>
public class PalletizFactory : DataCollectorFactory
{
private PlcModel _plc = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("Test"));
private static readonly log4net.ILog _logger = LogManager.GetLogger(typeof(PalletizFactory));
private readonly IBaseDeviceParamServices _deviceParamServices;
private readonly IRecordDeviceAlarmInfoServices _deviceAlarmInfoServices;
private readonly IRecordDeviceElectricityServices _deviceElectricityServices;
public PalletizFactory(IBaseDeviceParamServices deviceParamServices, IRecordDeviceAlarmInfoServices deviceAlarmInfoServices, IRecordDeviceElectricityServices deviceElectricityServices)
public PalletizFactory(IBaseDeviceParamServices deviceParamServices, IRecordDeviceAlarmInfoServices deviceAlarmInfoServices, IRecordDeviceElectricityServices deviceElectricityServices) : base(deviceParamServices, deviceAlarmInfoServices, deviceElectricityServices)
{
_deviceParamServices = deviceParamServices;
_deviceAlarmInfoServices = deviceAlarmInfoServices;
_deviceElectricityServices = deviceElectricityServices;
}
private PlcModel _plc = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("Test"));
/// <summary>
/// 采集设备报警信息
/// 采集成品分垛设备报警信息
/// </summary>
/// <param name="deviceAlarmInfos"></param>
/// <exception cref="NotImplementedException"></exception>
@ -41,10 +32,10 @@ namespace Aucma.Core.DataCollector.Factory
if (_plc != null)
{
Console.WriteLine($"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}采集设备报警信息");
Console.WriteLine($"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}采集成品分垛设备报警信息");
var plc = _plc.plc;
var deviceParams = _deviceParamServices.Query(x => x.DeviceCode == "E00002");
var deviceParams = base._deviceParamServices.Query(x => x.DeviceCode == "E00002");
if (deviceParams != null)
{
@ -52,9 +43,9 @@ namespace Aucma.Core.DataCollector.Factory
string batchId = System.Guid.NewGuid().ToString("N");
foreach (var item in deviceParams)
{
ReadParamValueByPlc(plc, item.ParamAddress, item.ParamType, out string paramValue);
base.ReadParamValueByPlc(plc, item.ParamAddress, item.ParamType, out int paramValue);
if (paramValue != "0")
if (paramValue != 0)
{
deviceAlarmInfos.Add(new Record_DeviceAlarmInfo()
{
@ -62,7 +53,7 @@ namespace Aucma.Core.DataCollector.Factory
DeviceCode = item.DeviceCode,
DeviceType = "1",
ParamCode = item.ParamCode,
ParamValue = paramValue as string,
ParamValue = paramValue.ToString(),
AlarmInfo = item.ParamName,
AlarmTime = DateTime.Now,
CreadtedTime = DateTime.Now,
@ -72,7 +63,7 @@ namespace Aucma.Core.DataCollector.Factory
}
if (deviceAlarmInfos.Count > 0)
{
_deviceAlarmInfoServices.AddAsync(deviceAlarmInfos);
base._deviceAlarmInfoServices.AddAsync(deviceAlarmInfos);
}
}
Task.Delay(1000 * 5).Wait();
@ -85,7 +76,7 @@ namespace Aucma.Core.DataCollector.Factory
}
catch(Exception ex)
{
_logger.Error($"成品分垛设备报警信息采集异常:{ex.Message}");
base._logger.Error($"采集成品分垛设备报警信息异常:{ex.Message}");
}
}
}
@ -150,7 +141,7 @@ namespace Aucma.Core.DataCollector.Factory
if(deviceElectricity.Zxyg > 0)
{
var result = _deviceElectricityServices.AddAsync(deviceElectricity);
var result = base._deviceElectricityServices.AddAsync(deviceElectricity);
}
}
Task.Delay(1000 * 5).Wait();
@ -164,45 +155,11 @@ namespace Aucma.Core.DataCollector.Factory
}
catch(Exception ex)
{
_logger.Error($"成品分垛设备用电数据采集异常:{ex.Message}");
base._logger.Error($"成品分垛设备用电数据采集异常:{ex.Message}");
}
}
}
/// <summary>
/// 读取PLC数据
/// </summary>
/// <param name="_plc"></param>
/// <param name="addr"></param>
/// <param name="dataType"></param>
/// <param name="paramValue"></param>
private void ReadParamValueByPlc(IPlc _plc,string addr,string dataType,out string paramValue)
{
object result = null;
switch (dataType)
{
case "int":
result = _plc.ReadInt16(addr);
break;
case "float":
result = _plc.ReadFloat(addr);
break;
case "bool":
result = _plc.ReadBool(addr);
break;
default:
result = _plc.ReadInt16(addr);
break;
}
if(result == null)
{
result = "0";
}
paramValue = result.ToString();
}
/// <summary>
/// 用电数据解析
/// </summary>

@ -0,0 +1,91 @@
using Admin.Core.IService.IService_New;
using Admin.Core.Model.Model_New;
using Aucma.Core.HwPLc;
using log4net;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Aucma.Core.DataCollector.Factory
{
/// <summary>
/// 箱壳预装、箱壳库数据采集
/// </summary>
public class ShellStoreFactory : DataCollectorFactory
{
private PlcModel _plc = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("Test"));
public ShellStoreFactory(IBaseDeviceParamServices deviceParamServices, IRecordDeviceAlarmInfoServices deviceAlarmInfoServices, IRecordDeviceElectricityServices deviceElectricityServices) : base(deviceParamServices, deviceAlarmInfoServices, deviceElectricityServices)
{
}
/// <summary>
/// 采集箱壳预装、箱壳库设备报警信息
/// </summary>
/// <param name="deviceAlarmInfos"></param>
public override void CollectDeviceAlarmInfo(out List<Record_DeviceAlarmInfo> deviceAlarmInfos)
{
while (true)
{
try
{
if (_plc != null)
{
Console.WriteLine($"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}采集箱壳预装、箱壳库设备报警信息");
var plc = _plc.plc;
var deviceParams = base._deviceParamServices.Query(x => x.DeviceCode == "E00019" || x.DeviceCode == "E00031");
if (deviceParams != null)
{
deviceAlarmInfos = new List<Record_DeviceAlarmInfo>();
string batchId = System.Guid.NewGuid().ToString("N");
foreach (var item in deviceParams)
{
base.ReadParamValueByPlc(plc, item.ParamAddress, item.ParamType, out int paramValue);
if (paramValue != 0)
{
deviceAlarmInfos.Add(new Record_DeviceAlarmInfo()
{
BatchId = batchId,
DeviceCode = item.DeviceCode,
DeviceType = "1",
ParamCode = item.ParamCode,
ParamValue = paramValue.ToString(),
AlarmInfo = item.ParamName,
AlarmTime = DateTime.Now,
CreadtedTime = DateTime.Now,
});
}
}
if (deviceAlarmInfos.Count > 0)
{
base._deviceAlarmInfoServices.AddAsync(deviceAlarmInfos);
}
}
Task.Delay(1000 * 5).Wait();
}
else
{
Task.Delay(1000 * 5).Wait();
_plc = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("Test"));
}
}
catch (Exception ex)
{
base._logger.Error($"采集箱壳预装、箱壳库设备报警信息异常:{ex.Message}");
}
}
}
public override void CollectDeviceElectricity(out Record_DeviceElectricity deviceElectricity)
{
throw new NotImplementedException();
}
}
}

@ -14,7 +14,7 @@ using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("HwControlLib")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+91808221759aca287573a9c1018fc2e65b1bfd59")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+95797c6d9a18bfc6da212ef8f1ab31fca740c669")]
[assembly: System.Reflection.AssemblyProductAttribute("HwControlLib")]
[assembly: System.Reflection.AssemblyTitleAttribute("HwControlLib")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]

@ -1 +1 @@
49ea3a11ac512c6a9f0475e17a7baf5c555a64a4dbb032b671d1b48f6eb1e163
540ef5d666d7f5ad016f7d96d8ec52a237608fb458897649dffe82d6e1a7f754

Loading…
Cancel
Save