|
|
|
@ -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 DoorFoamFactory : DataCollectorFactory
|
|
|
|
|
{
|
|
|
|
|
private PlcModel _plc = PlcHelper.siemensList.FirstOrDefault(d => d.EquipName.Equals("Test"));
|
|
|
|
|
|
|
|
|
|
public DoorFoamFactory(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(base.AlarmReadTimer).Wait();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Task.Delay(base.AlarmReadTimer).Wait();
|
|
|
|
|
_plc = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("Test"));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
base._logger.Error($"采集泡前库、发泡线、发泡机、泡后库设备报警信息:{ex.Message}");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void CollectDeviceElectricity(out List<Record_DeviceElectricity> deviceElectricitys)
|
|
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|