添加异常报警信息

main
liulb@mesnac.com 11 months ago
parent 03af9f6e2d
commit 029695687f

File diff suppressed because it is too large Load Diff

@ -0,0 +1,14 @@
using Admin.Core.Model;
using Admin.Core.Model.Model_New;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Admin.Core.IRepository.IRepository_New
{
public interface IBaseDeviceParamRepository : IBaseRepository<BaseDeviceParam>
{
}
}

@ -0,0 +1,13 @@
using Admin.Core.Model.Model_New;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Admin.Core.IRepository.IRepository_New
{
public interface IRecordDeviceAlarmInfoRepository : IBaseRepository<Record_DeviceAlarmInfo>
{
}
}

@ -0,0 +1,13 @@
using Admin.Core.Model.Model_New;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Admin.Core.IRepository.IRepository_New
{
public interface IRecordDeviceElectricityRepository : IBaseRepository<Record_DeviceElectricity>
{
}
}

@ -0,0 +1,14 @@
using Admin.Core.Model;
using Admin.Core.Model.Model_New;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Admin.Core.IService.IService_New
{
public interface IBaseDeviceParamServices : IBaseServices<BaseDeviceParam>
{
}
}

@ -0,0 +1,14 @@
using Admin.Core.Model;
using Admin.Core.Model.Model_New;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Admin.Core.IService.IService_New
{
public interface IRecordDeviceAlarmInfoServices : IBaseServices<Record_DeviceAlarmInfo>
{
}
}

@ -0,0 +1,14 @@
using Admin.Core.Model;
using Admin.Core.Model.Model_New;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Admin.Core.IService.IService_New
{
public interface IRecordDeviceElectricityServices : IBaseServices<Record_DeviceElectricity>
{
}
}

@ -0,0 +1,82 @@
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Admin.Core.Model.Model_New
{
/// <summary>
/// 设备参数
///</summary>
[SugarTable("BASE_DEVICEPARAM", "AUCMA_MES")]
public class BaseDeviceParam
{
/// <summary>
/// 主键标识
///</summary>
[SugarColumn(ColumnName = "OBJ_ID", IsPrimaryKey = true)]
public decimal ObjId { get; set; }
/// <summary>
/// 参数编号
///</summary>
[SugarColumn(ColumnName = "PARAM_CODE")]
public string ParamCode { get; set; }
/// <summary>
/// 参数名称
///</summary>
[SugarColumn(ColumnName = "PARAM_NAME")]
public string ParamName { get; set; }
/// <summary>
/// 网络地址
///</summary>
[SugarColumn(ColumnName = "PARAM_NETWORK")]
public string ParamNetwork { get; set; }
/// <summary>
/// 参数地址
///</summary>
[SugarColumn(ColumnName = "PARAM_ADDRESS")]
public string ParamAddress { get; set; }
/// <summary>
/// 参数类型int、float
///</summary>
[SugarColumn(ColumnName = "PARAM_TYPE")]
public string ParamType { get; set; }
/// <summary>
/// 设备编号
///</summary>
[SugarColumn(ColumnName = "DEVICE_CODE")]
public string DeviceCode { get; set; }
/// <summary>
/// 读取频率(毫秒)
///</summary>
[SugarColumn(ColumnName = "READ_FREQUENCY")]
public decimal? ReadFrequency { get; set; }
/// <summary>
/// 是否标识
///</summary>
[SugarColumn(ColumnName = "IS_FLAG")]
public short? IsFlag { get; set; }
/// <summary>
/// 创建人
///</summary>
[SugarColumn(ColumnName = "CREATED_BY")]
public string CreatedBy { get; set; }
/// <summary>
/// 创建时间
///</summary>
[SugarColumn(ColumnName = "CREATED_TIME")]
public DateTime? CreatedTime { get; set; }
/// <summary>
/// 更新人
///</summary>
[SugarColumn(ColumnName = "UPDATED_BY")]
public string UpdatedBy { get; set; }
/// <summary>
/// 更新时间
///</summary>
[SugarColumn(ColumnName = "UPDATED_TIME")]
public DateTime? UpdatedTime { get; set; }
}
}

@ -0,0 +1,61 @@
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Admin.Core.Model.Model_New
{
[SugarTable("RECORD_ALARM_DEVICE", "AUCMA_MES")]
public class Record_DeviceAlarmInfo
{
[SugarColumn(ColumnName = "OBJ_ID", IsPrimaryKey = true, OracleSequenceName = "SQE_DEVICE_ALARM_RECORD")]
public decimal ObjId { get; set; }
[SugarColumn(ColumnName = "BATCH_ID")]
public string BatchId { get; set; }
/// <summary>
/// 设备编号
///</summary>
[SugarColumn(ColumnName = "DEVICE_CODE")]
public string DeviceCode { get; set; }
/// <summary>
/// 设备类型1-生产设备2-计量设备
///</summary>
[SugarColumn(ColumnName = "DEVICE_TYPE")]
public string DeviceType { get; set; }
/// <summary>
/// 参数编号
/// </summary>
[SugarColumn(ColumnName ="PARAM_CODE")]
public string ParamCode { get; set; }
/// <summary>
/// 参数值
/// </summary>
[SugarColumn(ColumnName = "PARAM_VALUE")]
public string ParamValue { get; set; }
/// <summary>
/// 报警信息
///</summary>
[SugarColumn(ColumnName = "ALARM_INFO")]
public string AlarmInfo { get; set; }
/// <summary>
/// 报警时间
/// </summary>
[SugarColumn(ColumnName = "ALARM_TIME")]
public DateTime AlarmTime { get; set; }
/// <summary>
/// 创建时间
/// </summary>
[SugarColumn(ColumnName = "CREATED_TIME")]
public DateTime CreadtedTime { get; set; }
}
}

@ -0,0 +1,122 @@
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Admin.Core.Model.Model_New
{
/// <summary>
/// 电实时数据
///</summary>
[SugarTable("RECORD_DNB_INSTANT", "AUCMA_MES")]
public class Record_DeviceElectricity
{
/// <summary>
/// 主键标识
///</summary>
[SugarColumn(ColumnName = "OBJ_ID", IsPrimaryKey = true, OracleSequenceName = "SEQ_RECORD_DNB_INSTANT")]
public decimal ObjId { get; set; }
/// <summary>
/// 计量设备编号
///</summary>
[SugarColumn(ColumnName = "MONITOR_ID")]
public string MonitorId { get; set; }
/// <summary>
/// 采集时间
///</summary>
[SugarColumn(ColumnName = "COLLECT_TIME")]
public DateTime? CollectTime { get; set; }
/// <summary>
/// A项电压
///</summary>
[SugarColumn(ColumnName = "VA")]
public decimal? Va { get; set; }
/// <summary>
/// B项电压
///</summary>
[SugarColumn(ColumnName = "VB")]
public decimal? Vb { get; set; }
/// <summary>
/// C项电压
///</summary>
[SugarColumn(ColumnName = "VC")]
public decimal? Vc { get; set; }
/// <summary>
/// A项电流
///</summary>
[SugarColumn(ColumnName = "IA")]
public decimal? Ia { get; set; }
/// <summary>
/// B项电流
///</summary>
[SugarColumn(ColumnName = "IB")]
public decimal? Ib { get; set; }
/// <summary>
/// C项电流
///</summary>
[SugarColumn(ColumnName = "IC")]
public decimal? Ic { get; set; }
/// <summary>
/// 记录时间
///</summary>
[SugarColumn(ColumnName = "RECORD_TIME")]
public DateTime? RecordTime { get; set; }
/// <summary>
/// 功率因数
///</summary>
[SugarColumn(ColumnName = "GLYS")]
public decimal? Glys { get; set; }
/// <summary>
/// 正向有功
///</summary>
[SugarColumn(ColumnName = "ZXYG")]
public decimal? Zxyg { get; set; }
/// <summary>
/// 有功功率
///</summary>
[SugarColumn(ColumnName = "ACTIVE_POWER")]
public decimal? ActivePower { get; set; }
/// <summary>
/// 无功功率
///</summary>
[SugarColumn(ColumnName = "REACTIVE_POWER")]
public decimal? ReactivePower { get; set; }
/// <summary>
/// 采集类型0-自动1-手动)
///</summary>
[SugarColumn(ColumnName = "COLLECT_TYPE")]
public decimal? CollectType { get; set; }
/// <summary>
/// 启用标识
///</summary>
[SugarColumn(ColumnName = "IS_FLAG")]
public decimal? IsFlag { get; set; }
/// <summary>
/// 创建人
///</summary>
[SugarColumn(ColumnName = "CREATED_BY")]
public string CreatedBy { get; set; }
/// <summary>
/// 创建时间
///</summary>
[SugarColumn(ColumnName = "CREATED_TIME")]
public DateTime? CreatedTime { get; set; }
/// <summary>
/// 修改人
///</summary>
[SugarColumn(ColumnName = "UPDATED_BY")]
public string UpdatedBy { get; set; }
/// <summary>
/// 修改时间
///</summary>
[SugarColumn(ColumnName = "UPDATED_TIME")]
public DateTime? UpdatedTime { get; set; }
/// <summary>
/// 工厂编号
///</summary>
[SugarColumn(ColumnName = "FACTORY_CODE")]
public string FactoryCode { get; set; }
}
}

@ -0,0 +1,19 @@
using Admin.Core.IRepository;
using Admin.Core.IRepository.IRepository_New;
using Admin.Core.Model;
using Admin.Core.Model.Model_New;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Admin.Core.Repository.Repository_New
{
public class BaseDeviceParamRepository : BaseRepository<BaseDeviceParam>, IBaseDeviceParamRepository
{
public BaseDeviceParamRepository(IUnitOfWork unitOfWork) : base(unitOfWork)
{
}
}
}

@ -0,0 +1,19 @@
using Admin.Core.IRepository;
using Admin.Core.IRepository.IRepository_New;
using Admin.Core.Model;
using Admin.Core.Model.Model_New;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Admin.Core.Repository.Repository_New
{
public class RecordDeviceAlarmInfoRepository : BaseRepository<Record_DeviceAlarmInfo>, IRecordDeviceAlarmInfoRepository
{
public RecordDeviceAlarmInfoRepository(IUnitOfWork unitOfWork) : base(unitOfWork)
{
}
}
}

@ -0,0 +1,17 @@
using Admin.Core.IRepository.IRepository_New;
using Admin.Core.Model.Model_New;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Admin.Core.Repository.Repository_New
{
internal class RecordDeviceElectricityRepository : BaseRepository<Record_DeviceElectricity>, IRecordDeviceElectricityRepository
{
public RecordDeviceElectricityRepository(IUnitOfWork unitOfWork) : base(unitOfWork)
{
}
}
}

@ -0,0 +1,22 @@
using Admin.Core.IRepository;
using Admin.Core.IService.IService_New;
using Admin.Core.Model;
using Admin.Core.Model.Model_New;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Admin.Core.Service.Service_New
{
public class BaseDeviceParamServicesImpl : BaseServices<BaseDeviceParam>, IBaseDeviceParamServices
{
private readonly IBaseRepository<BaseDeviceParam> _dal;
public BaseDeviceParamServicesImpl(IBaseRepository<BaseDeviceParam> dal)
{
this._dal = dal;
base.BaseDal = dal;
}
}
}

@ -0,0 +1,21 @@
using Admin.Core.IRepository;
using Admin.Core.IService.IService_New;
using Admin.Core.Model.Model_New;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Admin.Core.Service.Service_New
{
public class RecordDeviceAlarmInfoServicesImpl : BaseServices<Record_DeviceAlarmInfo>, IRecordDeviceAlarmInfoServices
{
private readonly IBaseRepository<Record_DeviceAlarmInfo> _dal;
public RecordDeviceAlarmInfoServicesImpl(IBaseRepository<Record_DeviceAlarmInfo> dal)
{
this._dal = dal;
base.BaseDal = dal;
}
}
}

@ -0,0 +1,21 @@
using Admin.Core.IRepository;
using Admin.Core.IService.IService_New;
using Admin.Core.Model.Model_New;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Admin.Core.Service.Service_New
{
public class RecordDeviceElectricityServicesImpl : BaseServices<Record_DeviceElectricity>, IRecordDeviceElectricityServices
{
private readonly IBaseRepository<Record_DeviceElectricity> _dal;
public RecordDeviceElectricityServicesImpl(IBaseRepository<Record_DeviceElectricity> dal)
{
this._dal = dal;
base.BaseDal = dal;
}
}
}

@ -1,15 +1,7 @@
using Admin.Core.IService.IService_New;
using Admin.Core.Model.Model_New;
using Aucma.Core.DataCollector.Factory;
using Aucma.Core.HwPLc;
using log4net;
using NPOI.SS.Formula.Functions;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Aucma.Core.DataCollector
{

@ -31,74 +31,24 @@ namespace Aucma.Core.DataCollector
{
try
{
if (stationCode == "1002") //箱壳、内胆,包含预装线、集存库
if (stationCode == "1001") //箱壳
{
//前板
Task.Run(() =>
{
DataCollectorFactory collector = new ShellStoreFactory(_deviceParamServices, _deviceAlarmInfoServices, _deviceElectricityServices);
DataCollectorFactory collector = new SidePanelFactory(_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));
//});
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));
});
Task.Run(() =>
{
DataCollectorFactory collector = new ShellPreassembleFactory(_deviceParamServices, _deviceAlarmInfoServices, _deviceElectricityServices);
Parallel.Invoke(() => collector.CollectDeviceAlarmInfo(out var alarmInfos), () => collector.CollectDeviceElectricity(out var electricity));
});
Task.Run(() =>
{
DataCollectorFactory collector = new LinerPreassembleFactory(_deviceParamServices, _deviceAlarmInfoServices, _deviceElectricityServices);
Parallel.Invoke(() => collector.CollectDeviceAlarmInfo(out var alarmInfos), () => collector.CollectDeviceElectricity(out var electricity));
});
//后板
Task.Run(() =>
{
DataCollectorFactory collector = new FoamBackFactory(_deviceParamServices, _deviceAlarmInfoServices, _deviceElectricityServices);
DataCollectorFactory collector = new BackPanelFactory(_deviceParamServices, _deviceAlarmInfoServices, _deviceElectricityServices);
Parallel.Invoke(() => collector.CollectDeviceAlarmInfo(out var alarmInfos), () => collector.CollectDeviceElectricity(out var electricity));
});
}
}catch(Exception ex)
{
_logger.Error($"UseDataCollectorExtensions逻辑执行异常:{ex.Message}");

@ -1,7 +1,6 @@
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;
@ -10,19 +9,15 @@ using System.Threading.Tasks;
namespace Aucma.Core.DataCollector.Factory
{
/// <summary>
/// 箱体发泡数据采集
/// </summary>
public class BoxFoamFactory : DataCollectorFactory
public class BackPanelFactory : DataCollectorFactory
{
private PlcModel _plc = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("Test"));
public BoxFoamFactory(IBaseDeviceParamServices deviceParamServices, IRecordDeviceAlarmInfoServices deviceAlarmInfoServices, IRecordDeviceElectricityServices deviceElectricityServices) : base(deviceParamServices, deviceAlarmInfoServices, deviceElectricityServices)
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)
@ -31,13 +26,12 @@ namespace Aucma.Core.DataCollector.Factory
{
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 (plc.IsConnected == false) continue;
var deviceParams = base._deviceParamServices.Query(x => x.DeviceCode == "E00029");
if (deviceParams != null)
{
@ -73,19 +67,19 @@ namespace Aucma.Core.DataCollector.Factory
else
{
Task.Delay(base.AlarmReadTimer).Wait();
_plc = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("Test"));
}
}
catch (Exception ex)
{
base._logger.Error($"采集泡前库、发泡线、发泡机、泡后库设备报警信息:{ex.Message}");
base._logger.Error($"采集泡前库、发泡线、发泡机、泡后库设备报警信息:{ex.Message}");
}
}
}
public override void CollectDeviceElectricity(out List<Record_DeviceElectricity> deviceElectricitys)
{
throw new NotImplementedException();
deviceElectricitys = null;
return;
}
}
}

@ -1,38 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
#region << 版 本 注 释 >>
/*--------------------------------------------------------------------
* (c) 2024 WenJY
* CLR4.0.30319.42000
* LAPTOP-E0N2L34V
* Aucma.Core.DataCollector.Factory
* a4c93b2e-0cca-4fc8-be63-7f560c451cd9
*
* WenJY
* wenjy@mesnac.com
* 2024-03-28 11:16:52
* V1.0.0
*
*
*--------------------------------------------------------------------
*
*
*
*
* V1.0.0
*--------------------------------------------------------------------*/
#endregion << 版 本 注 释 >>
namespace Aucma.Core.DataCollector.Factory
{
/// <summary>
/// 泡前数据采集
/// </summary>
public class BeforeFoamFactory
{
}
}

@ -1,186 +0,0 @@
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
* CLR4.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}");
}
}
}
}
}

@ -1,167 +0,0 @@
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
* CLR4.0.30319.42000
* LAPTOP-E0N2L34V
* Aucma.Core.DataCollector.Factory
* 81c294d4-c4ab-4504-b193-9a5d013383d3
*
* WenJY
* wenjy@mesnac.com
* 2024-03-28 11:57:37
* V1.0.0
*
*
*--------------------------------------------------------------------
*
*
*
*
* V1.0.0
*--------------------------------------------------------------------*/
#endregion << 版 本 注 释 >>
namespace Aucma.Core.DataCollector.Factory
{
public class LinerPreassembleFactory : DataCollectorFactory
{
private PlcModel _plc = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("LinerPreassemble"));
public LinerPreassembleFactory(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 == "E00024");
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("LinerPreassemble"));
}
}
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>();
// 地面内胆预装主柜
string[] ground = new string[] { "D7602", "D7604", "D7606", "D7608", "D7610", "D7612", "D7630", "D7634", "D7638", "D7642" };
Record_DeviceElectricity _deviceElectricity_ground = new Record_DeviceElectricity()
{
MonitorId = "E00024_0001"
};
base.ReadDeviceElectricity(ground, plc, ref _deviceElectricity_ground);
if(_deviceElectricity_ground != null)
{
deviceElectricitys.Add(_deviceElectricity_ground);
}
//平台内胆预装远程
string[] platform = new string[] { "D7652", "D7664", "D7666", "D7668", "D7660", "D7662", "D7680", "D7684", "D7688", "D7692" };
Record_DeviceElectricity _deviceElectricity_platform = new Record_DeviceElectricity()
{
MonitorId = "E00024_0002"
};
base.ReadDeviceElectricity(platform, plc, ref _deviceElectricity_platform);
if (_deviceElectricity_platform != null)
{
deviceElectricitys.Add(_deviceElectricity_platform);
}
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("LinerPreassemble"));
}
}
catch (Exception ex)
{
base._logger.Error($"采集内胆预装用电数据采集异常:{ex.Message}");
}
}
}
}
}

@ -1,138 +0,0 @@
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("LinerStore"));
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 == "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(base.AlarmReadTimer).Wait();
}
else
{
Task.Delay(base.AlarmReadTimer).Wait();
_plc = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("LinerStore"));
}
}
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>();
string[] address = new string[] { "D7602", "D7604", "D7606", "D7608", "D7610", "D7612", "D7630", "D7634", "D7638", "D7642" };
Record_DeviceElectricity _deviceElectricity_address = new Record_DeviceElectricity()
{
MonitorId = "E00032_0001"
};
base.ReadDeviceElectricity(address, plc, ref _deviceElectricity_address);
if( _deviceElectricity_address != null)
{
deviceElectricitys.Add(_deviceElectricity_address);
}
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("LinerStore"));
}
}
catch (Exception ex)
{
base._logger.Error($"采集内胆库设备用电数据采集异常:{ex.Message}");
}
}
}
}
}

@ -1,184 +0,0 @@
using Admin.Core.Common.Helper;
using Admin.Core.IService.IService_New;
using Admin.Core.Model.Model_New;
using Aucma.Core.HwPLc;
using log4net;
using System.Globalization;
namespace Aucma.Core.DataCollector.Factory
{
/// <summary>
/// 分垛入库数据采集
/// </summary>
public class PalletizFactory : DataCollectorFactory
{
private PlcModel _plc = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("Palletiz"));
public PalletizFactory(IBaseDeviceParamServices deviceParamServices, IRecordDeviceAlarmInfoServices deviceAlarmInfoServices, IRecordDeviceElectricityServices deviceElectricityServices) : base(deviceParamServices, deviceAlarmInfoServices, deviceElectricityServices)
{
}
/// <summary>
/// 采集成品分垛设备报警信息
/// </summary>
/// <param name="deviceAlarmInfos"></param>
/// <exception cref="NotImplementedException"></exception>
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 == "E00002");
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("Palletiz"));
}
}
catch(Exception ex)
{
base._logger.Error($"采集成品分垛设备报警信息异常:{ex.Message}");
}
}
}
/// <summary>
/// 采集设备用电信息
/// </summary>
/// <param name="deviceElectricity"></param>
/// <exception cref="NotImplementedException"></exception>
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>();
string[] ground = new string[] { "D7602", "D7604", "D7606", "D7608", "D7610", "D7612", "D7630", "D7634", "D7638", "D7642" };
Record_DeviceElectricity _deviceElectricity_ground = new Record_DeviceElectricity()
{
MonitorId = "E0003"
};
base.ReadDeviceElectricity(ground, plc, ref _deviceElectricity_ground);
deviceElectricitys.Add(_deviceElectricity_ground);
string[] platform = new string[] { "D7652", "D7664", "D7666", "D7668", "D7660", "D7662", "D7680", "D7684", "D7688", "D7692" };
Record_DeviceElectricity _deviceElectricity_platform = new Record_DeviceElectricity()
{
MonitorId = "E0004"
};
base.ReadDeviceElectricity(platform, plc, ref _deviceElectricity_platform);
deviceElectricitys.Add(_deviceElectricity_platform);
var result = base._deviceElectricityServices.AddAsync(deviceElectricitys);
Task.Delay(base.EleReadTimer).Wait();
}
else
{
Task.Delay(base.EleReadTimer).Wait();
_plc = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("Palletiz"));
}
}
catch (Exception ex)
{
base._logger.Error($"采集成品分垛设备用电数据采集异常:{ex.Message}");
}
}
}
public byte[] array(byte[] data)
{
if (data == null) return null;
for (int i = 0; i < data.Length; i += 2)
{
byte temp = data[i];
data[i] = data[i + 1];
data[i + 1] = temp;
}
return data;
}
/// <summary>
/// 用电数据解析
/// </summary>
/// <param name="data"></param>
/// <param name="startIndex"></param>
/// <param name="length"></param>
/// <returns></returns>
/// <exception cref="ArgumentException"></exception>
private int[] ParseAndReverseByteArray(byte[] data, int startIndex, int length)
{
if (data == null || data.Length < startIndex + length)
{
throw new ArgumentException("Invalid data or startIndex/length parameter.");
}
int[] resultArray = new int[length / 2];
for (int i = 0; i < resultArray.Length; i++)
{
byte[] subset = new byte[2];
Array.Copy(data, startIndex + (i * 2), subset, 0, 2);
Array.Reverse(subset);
string hexString = BitConverter.ToString(subset).Replace("-", "");
resultArray[i] = Convert.ToInt32(hexString, 16);
}
return resultArray;
}
}
}

@ -1,166 +0,0 @@
using Admin.Core.IService.IService_New;
using Admin.Core.Model.Model_New;
using Aucma.Core.HwPLc;
#region << 版 本 注 释 >>
/*--------------------------------------------------------------------
* (c) 2024 WenJY
* CLR4.0.30319.42000
* LAPTOP-E0N2L34V
* Aucma.Core.DataCollector.Factory
* f88ccab0-cc8a-4d6f-8be8-1a0dbc687b9e
*
* WenJY
* wenjy@mesnac.com
* 2024-03-28 11:53:14
* V1.0.0
*
*
*--------------------------------------------------------------------
*
*
*
*
* V1.0.0
*--------------------------------------------------------------------*/
#endregion << 版 本 注 释 >>
namespace Aucma.Core.DataCollector.Factory
{
/// <summary>
/// 箱壳预装数据采集
/// </summary>
public class ShellPreassembleFactory : DataCollectorFactory
{
private PlcModel _plc = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("ShellPreassemble"));
public ShellPreassembleFactory(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 == "E00019");
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("ShellPreassemble"));
}
}
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>();
// 地面箱壳预装远程
string[] ground = new string[] { "D7602", "D7604", "D7606", "D7608", "D7610", "D7612", "D7630", "D7634", "D7638", "D7642" };
Record_DeviceElectricity _deviceElectricity_ground = new Record_DeviceElectricity()
{
MonitorId = "E00019_0001"
};
base.ReadDeviceElectricity(ground, plc, ref _deviceElectricity_ground);
if(_deviceElectricity_ground != null)
{
deviceElectricitys.Add(_deviceElectricity_ground);
}
//平台箱壳预装主柜
string[] platform = new string[] { "D7652", "D7664", "D7666", "D7668", "D7660", "D7662", "D7680", "D7684", "D7688", "D7692" };
Record_DeviceElectricity _deviceElectricity_platform = new Record_DeviceElectricity()
{
MonitorId = "E00019_0002"
};
base.ReadDeviceElectricity(platform, plc, ref _deviceElectricity_platform);
if(_deviceElectricity_platform != null)
{
deviceElectricitys.Add(_deviceElectricity_platform);
}
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("ShellPreassemble"));
}
}
catch (Exception ex)
{
base._logger.Error($"采集箱壳库设备用电数据采集异常:{ex.Message}");
}
}
}
}
}

@ -1,158 +0,0 @@
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("ShellStore"));
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 == "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(base.AlarmReadTimer).Wait();
}
else
{
Task.Delay(base.AlarmReadTimer).Wait();
_plc = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("ShellStore"));
}
}
catch (Exception ex)
{
base._logger.Error($"采集箱壳库设备报警信息异常:{ex.Message}");
}
}
}
/// <summary>
/// 采集箱壳库设备用电
/// </summary>
/// <param name="deviceElectricitys"></param>
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>();
//箱壳主柜
string[] mainCabinet = new string[] { "D7602", "D7604", "D7606", "D7608", "D7610", "D7612", "D7630", "D7634", "D7638", "D7642" };
Record_DeviceElectricity _deviceElectricity_mainCabinet = new Record_DeviceElectricity()
{
MonitorId = "E00031_0001"
};
base.ReadDeviceElectricity(mainCabinet, plc, ref _deviceElectricity_mainCabinet);
if(_deviceElectricity_mainCabinet != null)
{
deviceElectricitys.Add(_deviceElectricity_mainCabinet);
}
//箱壳远程柜
string[] rangeCabinet = new string[] { "D7652", "D7664", "D7666", "D7668", "D7660", "D7662", "D7680", "D7684", "D7688", "D7692" };
Record_DeviceElectricity _deviceElectricity_rangeCabinet = new Record_DeviceElectricity()
{
MonitorId = "E00031_0002"
};
base.ReadDeviceElectricity(rangeCabinet, plc, ref _deviceElectricity_rangeCabinet);
if(_deviceElectricity_rangeCabinet != null)
{
deviceElectricitys.Add(_deviceElectricity_rangeCabinet);
}
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("ShellStore"));
}
}
catch (Exception ex)
{
base._logger.Error($"采集箱壳库设备用电数据采集异常:{ex.Message}");
}
}
}
}
}

@ -0,0 +1,88 @@
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 SidePanelFactory : DataCollectorFactory
{
private PlcModel _plc = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("SidePanelPlc"));
public SidePanelFactory(IBaseDeviceParamServices deviceParamServices, IRecordDeviceAlarmInfoServices deviceAlarmInfoServices, IRecordDeviceElectricityServices deviceElectricityServices) : base(deviceParamServices, deviceAlarmInfoServices, deviceElectricityServices)
{
}
/// <summary>
/// 设备报警采集
/// </summary>
/// <param name="deviceAlarmInfos"></param>
/// <exception cref="NotImplementedException"></exception>
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;
}
}
}

@ -38,6 +38,10 @@ namespace Aucma.Core.HwPLc
/// <param name="address"></param>
/// <returns></returns>
byte[] Read(string address, ushort len);
public short[] ReadRandomInt16(string[] address);
public byte[] ReadRandomInt32(string[] address);
/// <summary>
/// 读取bool
/// </summary>

@ -592,5 +592,58 @@ namespace Aucma.Core.HwPLc
b = temp;
}
/// <summary>
/// 根据数组读取
/// </summary>
/// <param name="address"></param>
/// <returns></returns>
public short[] ReadRandomInt16(string[] address)
{
try
{
var info = melsecMcNet.ReadRandomInt16(address);
if (info.IsSuccess)
{
IsConnected = true;
return info.Content;
}
else
{
Console.WriteLine($"读取失败信息:{info.Message}");
}
}
catch (Exception ex)
{
Console.WriteLine($"读取失败信息:{ex.Message}");
}
return null;
}
public byte[] ReadRandomInt32(string[] address)
{
try
{
var info = melsecMcNet.ReadRandom(address);
if (info.IsSuccess)
{
IsConnected = true;
return info.Content;
}
else
{
Console.WriteLine($"读取失败信息:{info.Message}");
}
}
catch (Exception ex)
{
Console.WriteLine($"读取失败信息:{ex.Message}");
}
return null;
}
}
}

@ -528,5 +528,20 @@ namespace Aucma.Core.HwPLc
{
throw new NotImplementedException();
}
/// <summary>
/// 根据数组读取
/// </summary>
/// <param name="address"></param>
/// <returns></returns>
public short[] ReadRandomInt16(string[] address)
{
throw new NotImplementedException();
}
public byte[] ReadRandomInt32(string[] address)
{
throw new NotImplementedException();
}
}
}

@ -71,6 +71,8 @@
<ItemGroup>
<ProjectReference Include="..\Admin.Core.Extensions\Admin.Core.Extensions.csproj" />
<ProjectReference Include="..\Aucma.Core.DataCollector\Aucma.Core.DataCollector.csproj" />
<ProjectReference Include="..\Aucma.Core.SheetMetalTasks\Aucma.Core.SheetMetalTasks.csproj" />
</ItemGroup>
<ItemGroup>

@ -9,6 +9,7 @@ using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using System.Text;
using Aucma.Core.DataCollector;
namespace Aucma.Core.SheetMetal
{
@ -88,6 +89,9 @@ namespace Aucma.Core.SheetMetal
app.UsePlcMildd(runPlcService);
//澳柯玛任务处理中间件
app.UseAucamSheetMetalTaskMildds(aucamSheetMetalTaskService);
// 前后板生产报警采集
app.UseDataCollectorExtensions();
}
#region 注册服务

File diff suppressed because it is too large Load Diff

@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Admin.Core.IService\Admin.Core.IService.csproj" />
<ProjectReference Include="..\Aucma.Core.HwPLc\Aucma.Core.HwPLc.csproj" />
</ItemGroup>
</Project>

@ -0,0 +1,19 @@

namespace Aucma.Core.SheetMetalTasks
{
public interface IAucamSheetMetalTaskService
{
/// <summary>
/// 钣金计划任务
/// </summary>
Task SheetMetalTasks();
Task SendSidePanelPlan();
Task SendBackPanelPlan();
Task ExecUpdateComplatePlan();
Task ExecProcessTheEndTask();
}
}

@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Aucma.Core.SheetMetalTasks.Models
{
/// <summary>
/// 前后板料仓型号
/// </summary>
public class Bin
{
/// <summary>
/// 料仓Id
/// </summary>
public string? ProductId { get; set; }
/// <summary>
/// 是否启用
/// </summary>
public bool Status { get; set; }
}
}

@ -45,10 +45,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Aucma.Core.RunPlc", "Aucma.
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Aucma.Core.HwPLc", "Aucma.Core.HwPLc\Aucma.Core.HwPLc.csproj", "{A1473270-1D54-40D5-9E68-5C917347CFE8}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Aucma.Core.SheetMetalTasks", "Aucma.Core.SheetMetalTasks\Aucma.Core.SheetMetalTasks.csproj", "{F78F41F3-8B38-4CA1-A254-C18CCDCA8291}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Aucma.Core.DataCollector", "Aucma.Core.DataCollector\Aucma.Core.DataCollector.csproj", "{495F20DC-9159-4FC5-A8F8-3A61D1E9B6B8}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Aucma.Core.SheetMetalTasks", "Aucma.Core.SheetMetalTasks\Aucma.Core.SheetMetalTasks.csproj", "{2CFD13EF-06C8-4AA0-A1EE-0B93784F3DA9}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -103,14 +103,14 @@ Global
{A1473270-1D54-40D5-9E68-5C917347CFE8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A1473270-1D54-40D5-9E68-5C917347CFE8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A1473270-1D54-40D5-9E68-5C917347CFE8}.Release|Any CPU.Build.0 = Release|Any CPU
{F78F41F3-8B38-4CA1-A254-C18CCDCA8291}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F78F41F3-8B38-4CA1-A254-C18CCDCA8291}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F78F41F3-8B38-4CA1-A254-C18CCDCA8291}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F78F41F3-8B38-4CA1-A254-C18CCDCA8291}.Release|Any CPU.Build.0 = Release|Any CPU
{495F20DC-9159-4FC5-A8F8-3A61D1E9B6B8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{495F20DC-9159-4FC5-A8F8-3A61D1E9B6B8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{495F20DC-9159-4FC5-A8F8-3A61D1E9B6B8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{495F20DC-9159-4FC5-A8F8-3A61D1E9B6B8}.Release|Any CPU.Build.0 = Release|Any CPU
{2CFD13EF-06C8-4AA0-A1EE-0B93784F3DA9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2CFD13EF-06C8-4AA0-A1EE-0B93784F3DA9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2CFD13EF-06C8-4AA0-A1EE-0B93784F3DA9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2CFD13EF-06C8-4AA0-A1EE-0B93784F3DA9}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@ -131,8 +131,8 @@ Global
{AD2C008F-7D9F-43EB-9B44-F15A46F05583} = {BD987F3A-4E6C-4C47-B28F-1671F875EAE3}
{680718C5-E39C-442F-AC9E-4A56E15AF261} = {F8FB57F6-5465-4E60-B052-D3A63C3C56AE}
{A1473270-1D54-40D5-9E68-5C917347CFE8} = {F8FB57F6-5465-4E60-B052-D3A63C3C56AE}
{F78F41F3-8B38-4CA1-A254-C18CCDCA8291} = {F8FB57F6-5465-4E60-B052-D3A63C3C56AE}
{495F20DC-9159-4FC5-A8F8-3A61D1E9B6B8} = {F8FB57F6-5465-4E60-B052-D3A63C3C56AE}
{2CFD13EF-06C8-4AA0-A1EE-0B93784F3DA9} = {F8FB57F6-5465-4E60-B052-D3A63C3C56AE}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {8047AB56-042B-4AE4-B06A-34137067A86A}

Loading…
Cancel
Save