|
|
|
|
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;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace Aucma.Core.DataCollector
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 设备数据采集
|
|
|
|
|
/// </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>
|
|
|
|
|
/// 采集设备报警信息
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="deviceAlarmInfos"></param>
|
|
|
|
|
public abstract void CollectDeviceAlarmInfo(out List<Record_DeviceAlarmInfo> deviceAlarmInfos);
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 采集设备用电
|
|
|
|
|
/// </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);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|