|
|
|
@ -0,0 +1,186 @@
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
#region << 版 本 注 释 >>
|
|
|
|
|
/*--------------------------------------------------------------------
|
|
|
|
|
* 版权所有 (c) 2024 WenJY 保留所有权利。
|
|
|
|
|
* CLR版本:4.0.30319.42000
|
|
|
|
|
* 机器名称:LAPTOP-E0N2L34V
|
|
|
|
|
* 命名空间:Aucma.Core.DataCollector.Factory
|
|
|
|
|
* 唯一标识:d14bf35f-5d0b-4d74-a9a8-f7781f5c12cd
|
|
|
|
|
*
|
|
|
|
|
* 创建者:WenJY
|
|
|
|
|
* 电子邮箱:wenjy@mesnac.com
|
|
|
|
|
* 创建时间:2024-03-28 11:15:55
|
|
|
|
|
* 版本:V1.0.0
|
|
|
|
|
* 描述:
|
|
|
|
|
*
|
|
|
|
|
*--------------------------------------------------------------------
|
|
|
|
|
* 修改人:
|
|
|
|
|
* 时间:
|
|
|
|
|
* 修改说明:
|
|
|
|
|
*
|
|
|
|
|
* 版本:V1.0.0
|
|
|
|
|
*--------------------------------------------------------------------*/
|
|
|
|
|
#endregion << 版 本 注 释 >>
|
|
|
|
|
namespace Aucma.Core.DataCollector.Factory
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 泡后数据采集
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class FoamBackFactory : DataCollectorFactory
|
|
|
|
|
{
|
|
|
|
|
private PlcModel _plc = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("FoamBack"));
|
|
|
|
|
|
|
|
|
|
public FoamBackFactory(IBaseDeviceParamServices deviceParamServices, IRecordDeviceAlarmInfoServices deviceAlarmInfoServices, IRecordDeviceElectricityServices deviceElectricityServices) : base(deviceParamServices, deviceAlarmInfoServices, deviceElectricityServices)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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("FoamBack"));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
base._logger.Error($"采集泡后库设备报警信息异常:{ex.Message}");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void CollectDeviceElectricity(out List<Record_DeviceElectricity> deviceElectricitys)
|
|
|
|
|
{
|
|
|
|
|
while (true)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
if (_plc != null)
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine($"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}采集泡后库设备用电数据");
|
|
|
|
|
var plc = _plc.plc;
|
|
|
|
|
|
|
|
|
|
deviceElectricitys = new List<Record_DeviceElectricity>();
|
|
|
|
|
|
|
|
|
|
//泡后集存库(10柜-主柜)
|
|
|
|
|
string[] address_10 = new string[] { "D7602", "D7604", "D7606", "D7608", "D7610", "D7612", "D7630", "D7634", "D7638", "D7642" };
|
|
|
|
|
|
|
|
|
|
Record_DeviceElectricity _deviceElectricity_10 = new Record_DeviceElectricity()
|
|
|
|
|
{
|
|
|
|
|
MonitorId = "E00009_0001"
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
base.ReadDeviceElectricity(address_10, plc, ref _deviceElectricity_10);
|
|
|
|
|
|
|
|
|
|
if(_deviceElectricity_10 != null)
|
|
|
|
|
{
|
|
|
|
|
deviceElectricitys.Add(_deviceElectricity_10);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//泡后集存库(09柜-分柜)IP10.10.92.40
|
|
|
|
|
string[] address_09 = new string[] { "D7652", "D7664", "D7666", "D7668", "D7660", "D7662", "D7680", "D7684", "D7688", "D7692" };
|
|
|
|
|
|
|
|
|
|
Record_DeviceElectricity _deviceElectricity_09 = new Record_DeviceElectricity()
|
|
|
|
|
{
|
|
|
|
|
MonitorId = "E00009_0002"
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
base.ReadDeviceElectricity(address_09, plc, ref _deviceElectricity_09);
|
|
|
|
|
|
|
|
|
|
if (_deviceElectricity_09 != null)
|
|
|
|
|
{
|
|
|
|
|
deviceElectricitys.Add(_deviceElectricity_09);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//泡后集存库(12柜-分柜)
|
|
|
|
|
string[] address_12 = new string[] { "D7752", "D7764", "D7766", "D7768", "D7760", "D7762", "D7780", "D7784", "D7788", "D7792" };
|
|
|
|
|
|
|
|
|
|
Record_DeviceElectricity _deviceElectricity_12 = new Record_DeviceElectricity()
|
|
|
|
|
{
|
|
|
|
|
MonitorId = "E00009_0003"
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
base.ReadDeviceElectricity(address_12, plc, ref _deviceElectricity_12);
|
|
|
|
|
|
|
|
|
|
if (_deviceElectricity_12 != null)
|
|
|
|
|
{
|
|
|
|
|
deviceElectricitys.Add(_deviceElectricity_12);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(deviceElectricitys.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
var result = base._deviceElectricityServices.AddAsync(deviceElectricitys);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine($"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}采集泡后库设备用电数据失败,数据为空");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Task.Delay(base.EleReadTimer).Wait();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Task.Delay(base.EleReadTimer).Wait();
|
|
|
|
|
_plc = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("FoamBack"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
base._logger.Error($"采集泡后库设备用电数据采集异常:{ex.Message}");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|