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.
86 lines
3.6 KiB
C#
86 lines
3.6 KiB
C#
using Admin.Core.IService.IService_New;
|
|
using Admin.Core.Model.Model_New;
|
|
using Aucma.Core.HwPLc;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Aucma.Core.DataCollector.Factory
|
|
{
|
|
public class BackPanelFactory : DataCollectorFactory
|
|
{
|
|
private PlcModel _plc = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("BackPanelPLC"));
|
|
public BackPanelFactory(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;
|
|
if (plc.IsConnected == false) continue;
|
|
var deviceParams = base._deviceParamServices.Query(x => x.DeviceCode == "E00029");
|
|
|
|
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(base.AlarmReadTimer).Wait();
|
|
}
|
|
else
|
|
{
|
|
Task.Delay(base.AlarmReadTimer).Wait();
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
base._logger.Error($"采集泡前库、发泡线、发泡机、泡后库设备报警信息:{ex.Message}");
|
|
}
|
|
}
|
|
}
|
|
|
|
public override void CollectDeviceElectricity(out List<Record_DeviceElectricity> deviceElectricitys)
|
|
{
|
|
deviceElectricitys = null;
|
|
return;
|
|
}
|
|
}
|
|
}
|