|
|
|
|
@ -0,0 +1,180 @@
|
|
|
|
|
using Sln.Iot.CFX.CFXBusiness;
|
|
|
|
|
using Sln.Iot.CFX.Entity;
|
|
|
|
|
using Sln.Iot.Model.Entity;
|
|
|
|
|
using Sln.Iot.PLC;
|
|
|
|
|
using Sln.Iot.Serilog;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace Sln.Iot.Business
|
|
|
|
|
{
|
|
|
|
|
public class UnitsProcessPLCDataGetBusiness
|
|
|
|
|
{
|
|
|
|
|
private static readonly Lazy<UnitsProcessPLCDataGetBusiness> lazy = new Lazy<UnitsProcessPLCDataGetBusiness>(() => new UnitsProcessPLCDataGetBusiness());
|
|
|
|
|
|
|
|
|
|
public static UnitsProcessPLCDataGetBusiness Instance
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return lazy.Value;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private readonly PLCConnect _plc = PLCConnect.Instance;
|
|
|
|
|
private readonly SerilogHelper _log = SerilogHelper.Instance;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 真空箱PLC数据获取
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public UnitsProcess1Entity Vacuum1PlcDataGet()
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var res11 = _plc.ReadBytes(_plc.DeltaInstance1, "D200", 8);
|
|
|
|
|
var res12 = _plc.ReadBytes(_plc.DeltaInstance1, "D610", 6);
|
|
|
|
|
var res13 = _plc.ReadBytes(_plc.DeltaInstance1, "D120", 4);
|
|
|
|
|
var res14 = _plc.ReadFloat(_plc.DeltaInstance1, "D58");
|
|
|
|
|
|
|
|
|
|
UnitsProcess1Entity entity = new UnitsProcess1Entity()
|
|
|
|
|
{
|
|
|
|
|
GlueAmountSetValue1 = BitConverter.ToSingle(res12.Content, 4),
|
|
|
|
|
GluePushSpeedSetValue1 = BitConverter.ToSingle(res12.Content, 0),
|
|
|
|
|
BarrelA1TempActValue1 = BitConverter.ToInt16(res11.Content, 0),
|
|
|
|
|
BarrelA2TempActValue1 = BitConverter.ToInt16(res11.Content, 4),
|
|
|
|
|
BarrelB1TempActValue1 = BitConverter.ToInt16(res11.Content, 12),
|
|
|
|
|
BarrelB2TempActValue1 = BitConverter.ToInt16(res11.Content, 16),
|
|
|
|
|
PumpAPressureActValue1 = BitConverter.ToSingle(res13.Content, 0),
|
|
|
|
|
PumpBPressureActValue1 = BitConverter.ToSingle(res13.Content, 4),
|
|
|
|
|
VacuumDegreeActValue1 = res14.Content,
|
|
|
|
|
PressureHoldTimeSetValue1 = BitConverter.ToInt16(res12.Content, 12),
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return entity;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
_log.Error("PLC读取真空箱1信息失败");
|
|
|
|
|
return new UnitsProcess1Entity();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 真空箱PLC数据获取
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public UnitsProcess1Entity Vacuum2PlcDataGet()
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var res21 = _plc.ReadBytes(_plc.DeltaInstance2, "D200", 8);
|
|
|
|
|
var res22 = _plc.ReadBytes(_plc.DeltaInstance2, "D610", 6);
|
|
|
|
|
var res23 = _plc.ReadBytes(_plc.DeltaInstance2, "D120", 4);
|
|
|
|
|
var res24 = _plc.ReadFloat(_plc.DeltaInstance2, "D58");
|
|
|
|
|
|
|
|
|
|
UnitsProcess1Entity entity = new UnitsProcess1Entity()
|
|
|
|
|
{
|
|
|
|
|
GlueAmountSetValue2 = BitConverter.ToSingle(res22.Content, 4),
|
|
|
|
|
GluePushSpeedSetValue2 = BitConverter.ToSingle(res22.Content, 0),
|
|
|
|
|
BarrelA1TempActValue2 = BitConverter.ToInt16(res21.Content, 0),
|
|
|
|
|
BarrelA2TempActValue2 = BitConverter.ToInt16(res21.Content, 4),
|
|
|
|
|
BarrelB1TempActValue2 = BitConverter.ToInt16(res21.Content, 12),
|
|
|
|
|
BarrelB2TempActValue2 = BitConverter.ToInt16(res21.Content, 16),
|
|
|
|
|
PumpAPressureActValue2 = BitConverter.ToSingle(res23.Content, 0),
|
|
|
|
|
PumpBPressureActValue2 = BitConverter.ToSingle(res23.Content, 4),
|
|
|
|
|
VacuumDegreeActValue2 = res24.Content,
|
|
|
|
|
PressureHoldTimeSetValue2 = BitConverter.ToInt16(res22.Content, 12),
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return entity;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
_log.Error("PLC读取真空箱2信息失败");
|
|
|
|
|
return new UnitsProcess1Entity();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 预热炉数据获取
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public int PreHeatOvenPlcDataGet()
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var res = _plc.ReadInt16(_plc.DeltaInstance0, "D200");
|
|
|
|
|
|
|
|
|
|
if (res.IsSuccess)
|
|
|
|
|
{
|
|
|
|
|
return res.Content;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
_log.Error("PLC读取预热炉信息失败");
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 预固炉数据获取
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public UnitsProcess3Entity PreCureOvenPlcDataGet()
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var res = _plc.ReadBytes(_plc.DeltaInstance0, "D201", 4);
|
|
|
|
|
|
|
|
|
|
UnitsProcess3Entity unitsProcess3Entity = new UnitsProcess3Entity()
|
|
|
|
|
{
|
|
|
|
|
PreCureOven1TempActValue = BitConverter.ToInt16(res.Content, 0),
|
|
|
|
|
PreCureOven2TempActValue = BitConverter.ToInt16(res.Content, 2),
|
|
|
|
|
PreCureOven3TempActValue = BitConverter.ToInt16(res.Content, 4),
|
|
|
|
|
PreCureOven4TempActValue = BitConverter.ToInt16(res.Content, 6),
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return unitsProcess3Entity;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
_log.Error("PLC读取预固炉信息失败");
|
|
|
|
|
return new UnitsProcess3Entity();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 固化炉数据获取
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public UnitsProcess3Entity CureOvenPlcDataGet()
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var res = _plc.ReadBytes(_plc.DeltaInstance0, "D205", 4);
|
|
|
|
|
|
|
|
|
|
UnitsProcess3Entity unitsProcess3Entity = new UnitsProcess3Entity()
|
|
|
|
|
{
|
|
|
|
|
CureOven1TempActValue = BitConverter.ToInt16(res.Content, 0),
|
|
|
|
|
CureOven2TempActValue = BitConverter.ToInt16(res.Content, 2),
|
|
|
|
|
CureOven3TempActValue = BitConverter.ToInt16(res.Content, 4),
|
|
|
|
|
CureOven4TempActValue = BitConverter.ToInt16(res.Content, 6),
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return unitsProcess3Entity;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
_log.Error("PLC读取固化炉信息失败");
|
|
|
|
|
return new UnitsProcess3Entity();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|