feat - KPIVOV数据上报

master
SoulStar 2 days ago
parent 8925201faf
commit 00d5a84228

@ -38,7 +38,7 @@ namespace Sln.Iot.Business
public ErrorAnalyseBusiness()
{
_timer = new Timer(TimerCallback, null, 0, 5000);
_timer = new Timer(TimerCallback, null, 0, 2000);
}
/// <summary>

@ -96,10 +96,13 @@ namespace Sln.Iot.Business
{
//单元抵达事件
connect2.PublishEvent(new CFXEnvelope(unitsArrivedEvent.Handle(traycode, prodcode)));
_log.Info($"{traycode} 抵达设备");
//工作开始事件
connect2.PublishEvent(new CFXEnvelope(workStartedEvent.Handle(tid, traycode, prodcode)));
_log.Info($"工作开始ID:{tid}");
//预热炉工段开启
connect3.PublishEvent(new CFXEnvelope(workStageStartedEvent.Handle(tid, "PreHeatOven", 1)));
_log.Info($"预热炉工段开始 ID:{tid}");
});
}
//流程完成

@ -23,6 +23,11 @@ namespace Sln.Iot.Business
private readonly SerilogHelper _log = SerilogHelper.Instance;
private TrayBindingService trayBindingService = TrayBindingService.Instance;
private OvenPlcDataService ovenPlcDataService = OvenPlcDataService.Instance;
private VacuumInjectionPlcDataService vacuumInjectionPlcDataService = VacuumInjectionPlcDataService.Instance;
private UnitsProcessPLCDataGetBusiness unitsProcessPLCDataGetBusiness = UnitsProcessPLCDataGetBusiness.Instance;
private WorkStageStartedEvent workStageStartedEvent = new WorkStageStartedEvent();
private WorkStageCompletedEvent workStageCompletedEvent = new WorkStageCompletedEvent();
private CFXConnect1 connect1 = CFXConnect1.Instance;
@ -32,7 +37,7 @@ namespace Sln.Iot.Business
public RFID02Business()
{
_timer = new Timer(TimerCallback, null, 0, 5000);
_timer = new Timer(TimerCallback, null, 0, 2000);
}
/// <summary>
@ -84,10 +89,33 @@ namespace Sln.Iot.Business
{
//预热炉工段完成事件
connect3.PublishEvent(new CFXEnvelope(workStageCompletedEvent.Handle(tid, "PreHeatOven", 1)));
_log.Info($"预热炉工段完成 ID:{tid}");
//真空箱1工段开启
connect1.PublishEvent(new CFXEnvelope(workStageStartedEvent.Handle(tid, "VacuumInjection1", 1)));
_log.Info($"真空箱1工段开始 ID:{tid}");
//预热炉数据采集
var data = unitsProcessPLCDataGetBusiness.PreHeatOvenPlcDataGet();
ovenPlcDataService.InsertData(stid, data);
_log.Info($"预热炉数据采集, {data}");
//真空箱1数据采集
var data2 = unitsProcessPLCDataGetBusiness.Vacuum1PlcDataGet();
vacuumInjectionPlcDataService.InsertData(stid, data2);
_log.Info($"真空箱1温度数据采集, " +
$"GlueAmountSetValue1:{data2.GlueAmountSetValue1} " +
$"GluePushSpeedSetValue1:{data2.GluePushSpeedSetValue1} " +
$"BarrelA1TempActValue1:{data2.BarrelA1TempActValue1} " +
$"BarrelA2TempActValue1:{data2.BarrelA2TempActValue1} " +
$"BarrelB1TempActValue1:{data2.BarrelB1TempActValue1} " +
$"BarrelB2TempActValue1:{data2.BarrelB2TempActValue1} " +
$"PumpAPressureActValue1:{data2.PumpAPressureActValue1} " +
$"PumpBPressureActValue1:{data2.PumpBPressureActValue1} " +
$"VacuumDegreeActValue1:{data2.VacuumDegreeActValue1} " +
$"PressureHoldTimeSetValue1:{data2.PressureHoldTimeSetValue1}");
});
//CFX
}
//流程完成
}

@ -31,7 +31,7 @@ namespace Sln.Iot.Business
public RFID03Business()
{
_timer = new Timer(TimerCallback, null, 0, 5000);
_timer = new Timer(TimerCallback, null, 0, 2000);
}
/// <summary>
@ -81,8 +81,10 @@ namespace Sln.Iot.Business
{
//真空箱1工段完成事件
connect1.PublishEvent(new CFXEnvelope(workStageCompletedEvent.Handle(tid, "VacuumInjection1", 1)));
_log.Info($"真空箱1工段完成, {tid}");
//预固炉工段开启
connect3.PublishEvent(new CFXEnvelope(workStageStartedEvent.Handle(tid, "PreCureOven", 2)));
_log.Info($"预固炉工段开启, {tid}");
});
}
//流程完成

@ -21,6 +21,10 @@ namespace Sln.Iot.Business
private readonly PLCConnect _plc = PLCConnect.Instance;
private readonly SerilogHelper _log = SerilogHelper.Instance;
private OvenPlcDataService ovenPlcDataService = OvenPlcDataService.Instance;
private VacuumInjectionPlcDataService vacuumInjectionPlcDataService = VacuumInjectionPlcDataService.Instance;
private UnitsProcessPLCDataGetBusiness unitsProcessPLCDataGetBusiness = UnitsProcessPLCDataGetBusiness.Instance;
private TrayBindingService trayBindingService = TrayBindingService.Instance;
private WorkStageStartedEvent workStageStartedEvent = new WorkStageStartedEvent();
@ -31,7 +35,7 @@ namespace Sln.Iot.Business
public RFID04Business()
{
_timer = new Timer(TimerCallback, null, 0, 5000);
_timer = new Timer(TimerCallback, null, 0, 2000);
}
/// <summary>
@ -82,8 +86,19 @@ namespace Sln.Iot.Business
{
//预固炉工段完成事件
connect3.PublishEvent(new CFXEnvelope(workStageCompletedEvent.Handle(tid, "PreCureOven", 2)));
_log.Info($"预固炉工段完成, {tid}");
//真空箱2工段开启
connect1.PublishEvent(new CFXEnvelope(workStageStartedEvent.Handle(tid, "VacuumInjection2", 2)));
_log.Info($"真空箱2工段开启, {tid}");
//预固炉数据采集
var data = unitsProcessPLCDataGetBusiness.PreCureOvenPlcDataGet();
ovenPlcDataService.UpdateDataPreCure(stid, data);
_log.Info($"预固炉温度数据采集, " +
$"PreCureOven1TempActValue:{data.PreCureOven1TempActValue} " +
$"PreCureOven2TempActValue:{data.PreCureOven2TempActValue} " +
$"PreCureOven3TempActValue:{data.PreCureOven3TempActValue} " +
$"PreCureOven4TempActValue:{data.PreCureOven4TempActValue}");
});
}
//流程完成
@ -122,13 +137,6 @@ namespace Sln.Iot.Business
{
_log.Error("胶机2真空箱前时间计算PLC写入完成信号异常");
}
//CFX
Task.Run(() =>
{
//单元抵达事件
});
}
//流程完成
}

@ -1,5 +1,6 @@
using CFX;
using HslCommunication;
using Sln.Iot.CFX.CFXBusiness;
using Sln.Iot.CFX.CFXConnect;
using Sln.Iot.CFX.Event;
using Sln.Iot.PLC;
@ -22,15 +23,23 @@ namespace Sln.Iot.Business
private readonly SerilogHelper _log = SerilogHelper.Instance;
private TrayBindingService trayBindingService = TrayBindingService.Instance;
private OvenPlcDataService ovenPlcDataService = OvenPlcDataService.Instance;
private VacuumInjectionPlcDataService vacuumInjectionPlcDataService = VacuumInjectionPlcDataService.Instance;
private UnitsProcessPLCDataGetBusiness unitsProcessPLCDataGetBusiness = UnitsProcessPLCDataGetBusiness.Instance;
private CFXUnitProcessedDataGet cFXUnitProcessedDataGet = CFXUnitProcessedDataGet.Instance;
private WorkStageStartedEvent workStageStartedEvent = new WorkStageStartedEvent();
private WorkStageCompletedEvent workStageCompletedEvent = new WorkStageCompletedEvent();
private UnitsProcessedEvent unitsProcessedEvent = new UnitsProcessedEvent();
private CFXConnect1 connect1 = CFXConnect1.Instance;
private CFXConnect2 connect2 = CFXConnect2.Instance;
private CFXConnect3 connect3 = CFXConnect3.Instance;
public RFID05Business()
{
_timer = new Timer(TimerCallback, null, 0, 5000);
_timer = new Timer(TimerCallback, null, 0, 2000);
}
/// <summary>
@ -80,9 +89,46 @@ namespace Sln.Iot.Business
{
//真空箱2工段完成事件
connect1.PublishEvent(new CFXEnvelope(workStageCompletedEvent.Handle(tid, "VacuumInjection2", 2)));
_log.Info($"真空箱2工段完成, {tid}");
//固化炉工段开启
connect3.PublishEvent(new CFXEnvelope(workStageStartedEvent.Handle(tid, "CureOven", 3)));
_log.Info($"固化炉工段开启, {tid}");
//真空箱获取并上传数据
var unitsData1 = vacuumInjectionPlcDataService.GetData(stid);
var unitsData2 = unitsProcessPLCDataGetBusiness.Vacuum2PlcDataGet();
unitsData1.GlueAmountSetValue2 = unitsData2.GlueAmountSetValue2;
unitsData1.GluePushSpeedSetValue2 = unitsData2.GluePushSpeedSetValue2;
unitsData1.BarrelA1TempActValue2 = unitsData2.BarrelA1TempActValue2;
unitsData1.BarrelA2TempActValue2 = unitsData2.BarrelA2TempActValue2;
unitsData1.BarrelB1TempActValue2 = unitsData2.BarrelB1TempActValue2;
unitsData1.BarrelB2TempActValue2 = unitsData2.BarrelB2TempActValue2;
unitsData1.PumpAPressureActValue2 = unitsData2.PumpAPressureActValue2;
unitsData1.PumpBPressureActValue2 = unitsData2.PumpBPressureActValue2;
unitsData1.VacuumDegreeActValue2 = unitsData2.VacuumDegreeActValue2;
unitsData1.PressureHoldTimeSetValue2 = unitsData2.PressureHoldTimeSetValue2;
connect1.PublishEvent(new CFXEnvelope(unitsProcessedEvent.Handle(tid, cFXUnitProcessedDataGet.ProcessDataGet1(unitsData1))));
_log.Info($"真空箱温度数据上传, " +
$"GlueAmountSetValue1:{unitsData1.GlueAmountSetValue1} " +
$"GluePushSpeedSetValue1:{unitsData1.GluePushSpeedSetValue1} " +
$"BarrelA1TempActValue1:{unitsData1.BarrelA1TempActValue1} " +
$"BarrelA2TempActValue1:{unitsData1.BarrelA2TempActValue1} " +
$"BarrelB1TempActValue1:{unitsData1.BarrelB1TempActValue1} " +
$"BarrelB2TempActValue1:{unitsData1.BarrelB2TempActValue1} " +
$"PumpAPressureActValue1:{unitsData1.PumpAPressureActValue1} " +
$"PumpBPressureActValue1:{unitsData1.PumpBPressureActValue1} " +
$"VacuumDegreeActValue1:{unitsData1.VacuumDegreeActValue1} " +
$"PressureHoldTimeSetValue1:{unitsData1.PressureHoldTimeSetValue1} " +
$"GlueAmountSetValue2:{unitsData1.GlueAmountSetValue2} " +
$"GluePushSpeedSetValue2:{unitsData1.GluePushSpeedSetValue2} " +
$"BarrelA1TempActValue2:{unitsData1.BarrelA1TempActValue2} " +
$"BarrelA2TempActValue2:{unitsData1.BarrelA2TempActValue2} " +
$"BarrelB1TempActValue2:{unitsData1.BarrelB1TempActValue2} " +
$"BarrelB2TempActValue2:{unitsData1.BarrelB2TempActValue2} " +
$"PumpAPressureActValue2:{unitsData1.PumpAPressureActValue2} " +
$"PumpBPressureActValue2:{unitsData1.PumpBPressureActValue2} " +
$"VacuumDegreeActValue2:{unitsData1.VacuumDegreeActValue2} " +
$"PressureHoldTimeSetValue2:{unitsData1.PressureHoldTimeSetValue2}");
});
}
//流程完成

@ -23,20 +23,30 @@ namespace Sln.Iot.Business
private readonly SerilogHelper _log = SerilogHelper.Instance;
private UnitsDepartedEvent unitsDepartedEvent = new UnitsDepartedEvent();
private TrayBindingService trayBindingService = TrayBindingService.Instance;
//CFX数据采集业务
private UnitsProcessPLCDataGetBusiness unitsProcessPLCDataGetBusiness = UnitsProcessPLCDataGetBusiness.Instance;
private CFXUnitProcessedDataGet cFXUnitProcessedDataGet = CFXUnitProcessedDataGet.Instance;
//SQL服务
private OvenPlcDataService ovenPlcDataService = OvenPlcDataService.Instance;
private VacuumInjectionPlcDataService vacuumInjectionPlcDataService = VacuumInjectionPlcDataService.Instance;
private TrayBindingService trayBindingService = TrayBindingService.Instance;
//CFX事件
private UnitsDepartedEvent unitsDepartedEvent = new UnitsDepartedEvent();
private WorkStageCompletedEvent workStageCompletedEvent = new WorkStageCompletedEvent();
private UnitsProcessedEvent unitsProcessedEvent = new UnitsProcessedEvent();
private WorkCompletedEvent workCompletedEvent = new WorkCompletedEvent();
// CFX连接
private CFXConnect1 connect1 = CFXConnect1.Instance;
private CFXConnect2 connect2 = CFXConnect2.Instance;
private CFXConnect3 connect3 = CFXConnect3.Instance;
public RFID06Business()
{
_timer = new Timer(TimerCallback, null, 0, 5000);
_timer = new Timer(TimerCallback, null, 0, 2000);
}
/// <summary>
@ -72,7 +82,7 @@ namespace Sln.Iot.Business
string[] prodcode = trayBindingService.ProdCodeGet(traycode);
bool res = trayBindingService.TrayCodeDelete(traycode);
if (!res)
{
_log.Error("下料提升机绑定数据删除异常或删除条数为0");
@ -90,10 +100,32 @@ namespace Sln.Iot.Business
{
//固化炉工段完成事件
connect3.PublishEvent(new CFXEnvelope(workStageCompletedEvent.Handle(tid, "CureOven", 3)));
_log.Info($"固化炉工段完成, {tid}");
//单元离站事件
connect2.PublishEvent(new CFXEnvelope(unitsDepartedEvent.Handle(traycode, prodcode)));
//上报数据
connect2.PublishEvent(new CFXEnvelope(unitsProcessedEvent.Handle(tid, cFXUnitProcessedDataGet.ProcessDataGet1())));
_log.Info($"{traycode} 单元离站 ");
//工单完成事件
connect2.PublishEvent(new CFXEnvelope(workCompletedEvent.Handle(tid, traycode, prodcode)));
_log.Info($"工单完成 ID:{tid}");
//固化炉数据采集
var unitsdata = unitsProcessPLCDataGetBusiness.CureOvenPlcDataGet();
//存数据库里整合
ovenPlcDataService.UpdateDataCure(stid, unitsdata);
//取出整合数据
unitsdata = ovenPlcDataService.GetData(stid);
connect3.PublishEvent(new CFXEnvelope(unitsProcessedEvent.Handle(tid, cFXUnitProcessedDataGet.ProcessDataGet3(unitsdata))));
_log.Info($"隧道烤箱温度数据上传, " +
$"PreheatOvenTempActValue:{unitsdata.PreheatOvenTempActValue} " +
$"PreCureOven1TempActValue:{unitsdata.PreCureOven1TempActValue} " +
$"PreCureOven2TempActValue:{unitsdata.PreCureOven2TempActValue} " +
$"PreCureOven3TempActValue:{unitsdata.PreCureOven3TempActValue} " +
$"PreCureOven4TempActValue:{unitsdata.PreCureOven4TempActValue} " +
$"CureOven1TempActValue:{unitsdata.CureOven1TempActValue} " +
$"CureOven2TempActValue:{unitsdata.CureOven2TempActValue} " +
$"CureOven3TempActValue:{unitsdata.CureOven3TempActValue} " +
$"CureOven4TempActValue:{unitsdata.CureOven4TempActValue} ");
});
}
//流程完成

@ -94,9 +94,6 @@ namespace Sln.Iot.Business
_log.Info($"真空箱2配方激活{recipeName}");
}
}
}
}
}

@ -13,6 +13,7 @@
<ItemGroup>
<ProjectReference Include="..\Sln.Iot.CFX\Sln.Iot.CFX.csproj" />
<ProjectReference Include="..\Sln.Iot.Common\Sln.Iot.Common.csproj" />
<ProjectReference Include="..\Sln.Iot.Model\Sln.Iot.Model.csproj" />
<ProjectReference Include="..\Sln.Iot.PLC\Sln.Iot.PLC.csproj" />
<ProjectReference Include="..\Sln.Iot.Repository\Sln.Iot.Repository.csproj" />
<ProjectReference Include="..\Sln.Iot.Serilog\Sln.Iot.Serilog.csproj" />

@ -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();
}
}
}
}

@ -37,10 +37,5 @@ namespace Sln.Iot.CFX.CFXBusiness
}
return units;
}
public List<Fault> FaultsTrans()
{
}
}
}

@ -1,13 +1,7 @@
using CFX.Structures;
using CFX.Structures.CommonUseEquipment;
using CFX.Structures.SolderReflow;
using Sln.Iot.CFX.Entity;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Sln.Iot.Model.Entity;
namespace Sln.Iot.CFX.CFXBusiness
{
@ -22,14 +16,14 @@ namespace Sln.Iot.CFX.CFXBusiness
return lazy.Value;
}
}
/// <summary>
/// 真空点胶数据
/// </summary>
/// <returns></returns>
public CommonProcessData ProcessDataGet1()
public CommonProcessData ProcessDataGet1(UnitsProcess1Entity entity)
{
UnitsProcess1Entity entity = new UnitsProcess1Entity()
entity = new UnitsProcess1Entity()
{
GlueAmountSetValue1 = 123.4f,
GluePushSpeedSetValue1 = 10.1f,
@ -234,19 +228,19 @@ namespace Sln.Iot.CFX.CFXBusiness
/// 隧道烤箱数据
/// </summary>
/// <returns></returns>
public CommonProcessData ProcessDataGet3()
public CommonProcessData ProcessDataGet3(UnitsProcess3Entity entity)
{
UnitsProcess3Entity entity = new UnitsProcess3Entity()
entity = new UnitsProcess3Entity()
{
PreheatOvenTempActValue = 800,
PreCureOven1TempActValue = 800,
PreCureOven2TempActValue = 800,
PreCureOven3TempActValue = 800,
PreCureOven4TempActValue = 800,
CureOven1ActValue = 800,
CureOven2ActValue = 800,
CureOven3ActValue = 800,
CureOven4ActValue = 800,
CureOven1TempActValue = 800,
CureOven2TempActValue = 800,
CureOven3TempActValue = 800,
CureOven4TempActValue = 800,
};
CommonProcessData processData = new CommonProcessData()
@ -309,22 +303,22 @@ namespace Sln.Iot.CFX.CFXBusiness
{
new CommonUseReading()
{
ReadingValue = entity.CureOven1ActValue,
ReadingValue = entity.CureOven1TempActValue,
ReadingName = "CureOven1ActValue",
},
new CommonUseReading()
{
ReadingValue = entity.CureOven2ActValue,
ReadingValue = entity.CureOven2TempActValue,
ReadingName = "CureOven2ActValue",
},
new CommonUseReading()
{
ReadingValue = entity.CureOven3ActValue,
ReadingValue = entity.CureOven3TempActValue,
ReadingName = "CureOven3ActValue",
},
new CommonUseReading()
{
ReadingValue = entity.CureOven4ActValue,
ReadingValue = entity.CureOven4TempActValue,
ReadingName = "CureOven4ActValue",
}
},

@ -8,6 +8,7 @@ using CFX.Structures;
using Sln.Iot.CFX.CFXBusiness;
using Sln.Iot.CFX.CFXConnect;
using Sln.Iot.CFX.Event;
using Sln.Iot.Model.Entity;
namespace Sln.Iot.CFX
{
@ -93,7 +94,7 @@ namespace Sln.Iot.CFX
_cfxHelper.PublishEvent(new CFXEnvelope(workCompletedEvent.Handle()));
_cfxHelper.PublishEvent(new CFXEnvelope(unitsDepartedEvent.Handle(null, new string[1] { "A123" })));
_cfxHelper.PublishEvent(new CFXEnvelope(unitsProcessedEvent.Handle(testGuid, cFXUnitProcessedDataGet.ProcessDataGet1())));
_cfxHelper.PublishEvent(new CFXEnvelope(unitsProcessedEvent.Handle(testGuid, cFXUnitProcessedDataGet.ProcessDataGet1(new UnitsProcess1Entity()))));
_cfxHelper.PublishEvent(new CFXEnvelope(endpointShuttingDownEvent.Handle("CFX.A00.SDSH000001")));
_cfxHelper.SendValidateUnitsRequest("amqp://127.0.0.1:8888", "A123456", new string[1] { "A123" });
@ -207,7 +208,7 @@ namespace Sln.Iot.CFX
_cfxHelper3.PublishEvent(new CFXEnvelope(workCompletedEvent.Handle()));
_cfxHelper3.PublishEvent(new CFXEnvelope(unitsDepartedEvent.Handle(null, new string[1] { "A123" })));
_cfxHelper3.PublishEvent(new CFXEnvelope(unitsProcessedEvent.Handle(testGuid, cFXUnitProcessedDataGet.ProcessDataGet3())));
_cfxHelper3.PublishEvent(new CFXEnvelope(unitsProcessedEvent.Handle(testGuid, cFXUnitProcessedDataGet.ProcessDataGet3(new UnitsProcess3Entity()))));
_cfxHelper3.PublishEvent(new CFXEnvelope(endpointShuttingDownEvent.Handle("CFX.A00.SDSH000003")));
_cfxHelper3.SendValidateUnitsRequest("amqp://127.0.0.1:8888", "A123456", new string[1] { "A123" });

@ -1,6 +1,7 @@
using CFX;
using CFX.Production;
using CFX.Structures;
using Sln.Iot.CFX.CFXBusiness;
using Sln.Iot.Serilog;
namespace Sln.Iot.CFX.Event
@ -11,57 +12,60 @@ namespace Sln.Iot.CFX.Event
/// </summary>
public class WorkCompletedEvent
{
private CFXEventTools cFXEventTools = CFXEventTools.Instance;
/// <summary>
/// 数据封装处理
/// </summary>
/// <returns></returns>
public CFXMessage Handle()
public CFXMessage Handle(Guid transactionID, string pirmaryIdentifier, string[] unitIdentifier)
{
CFXMessage eve = null;
try
{
eve = new WorkCompleted()
{
TransactionID = Guid.Parse("281fa09f-cbf6-498d-9f27-7ca77cb60399"),
PrimaryIdentifier = "WORKORDER-0001",
TransactionID = transactionID,
PrimaryIdentifier = pirmaryIdentifier,
Result = WorkResult.Completed,
Units = new List<UnitPosition>()
{
new UnitPosition()
{
UnitIdentifier = "PreHeatOven",
PositionNumber = 1,
PositionName = "位置1",
X = 50.0,
Y = 80.0,
Rotation = 0.0,
FlipX = false,
FlipY = false
},
new UnitPosition()
{
UnitIdentifier = "PreCureOven",
PositionNumber = 2,
PositionName = "位置2",
X = 50.0,
Y = 80.0,
Rotation = 0.0,
FlipX = false,
FlipY = false
},
new UnitPosition()
{
UnitIdentifier = "CureOven",
PositionNumber = 3,
PositionName = "位置3",
X = 50.0,
Y = 80.0,
Rotation = 0.0,
FlipX = false,
FlipY = false
},
Units = cFXEventTools.UnitPositionTrans(unitIdentifier)
//Units = new List<UnitPosition>()
//{
// new UnitPosition()
// {
// UnitIdentifier = "PreHeatOven",
// PositionNumber = 1,
// PositionName = "位置1",
// X = 50.0,
// Y = 80.0,
// Rotation = 0.0,
// FlipX = false,
// FlipY = false
// },
// new UnitPosition()
// {
// UnitIdentifier = "PreCureOven",
// PositionNumber = 2,
// PositionName = "位置2",
// X = 50.0,
// Y = 80.0,
// Rotation = 0.0,
// FlipX = false,
// FlipY = false
// },
// new UnitPosition()
// {
// UnitIdentifier = "CureOven",
// PositionNumber = 3,
// PositionName = "位置3",
// X = 50.0,
// Y = 80.0,
// Rotation = 0.0,
// FlipX = false,
// FlipY = false
// },
//}
}
};
}
catch (Exception e)

@ -11,6 +11,7 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Sln.Iot.Model\Sln.Iot.Model.csproj" />
<ProjectReference Include="..\Sln.Iot.PLC\Sln.Iot.PLC.csproj" />
<ProjectReference Include="..\Sln.Iot.Repository\Sln.Iot.Repository.csproj" />
<ProjectReference Include="..\Sln.Iot.Serilog\Sln.Iot.Serilog.csproj" />

@ -4,7 +4,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Sln.Iot.CFX.Entity
namespace Sln.Iot.Model.Entity
{
public class UnitsProcess1Entity
{

@ -4,7 +4,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Sln.Iot.CFX.Entity
namespace Sln.Iot.Model.Entity
{
public class UnitsProcess3Entity
{
@ -36,21 +36,21 @@ namespace Sln.Iot.CFX.Entity
/// <summary>
/// 固化炉温度1
/// </summary>
public int CureOven1ActValue { get; set; }
public int CureOven1TempActValue { get; set; }
/// <summary>
/// 固化炉温度2
/// </summary>
public int CureOven2ActValue { get; set; }
public int CureOven2TempActValue { get; set; }
/// <summary>
/// 固化炉温度3
/// </summary>
public int CureOven3ActValue { get; set; }
public int CureOven3TempActValue { get; set; }
/// <summary>
/// 固化炉温度4
/// </summary>
public int CureOven4ActValue { get; set; }
public int CureOven4TempActValue { get; set; }
}
}

@ -12,6 +12,7 @@
<ItemGroup>
<ProjectReference Include="..\Sln.Iot.Config\Sln.Iot.Config.csproj" />
<ProjectReference Include="..\Sln.Iot.Model\Sln.Iot.Model.csproj" />
<ProjectReference Include="..\Sln.Iot.Serilog\Sln.Iot.Serilog.csproj" />
</ItemGroup>

@ -0,0 +1,60 @@
using SQLite;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Sln.Iot.Repository.dao
{
public class OvenPlcData
{
[PrimaryKey]
public string GUID { get; set; }
/// <summary>
/// 预热炉温度
/// </summary>
public int PreheatOvenTempActValue { get; set; }
/// <summary>
/// 预固炉温度1
/// </summary>
public int PreCureOven1TempActValue { get; set; }
/// <summary>
/// 预固炉温度2
/// </summary>
public int PreCureOven2TempActValue { get; set; }
/// <summary>
/// 预固炉温度3
/// </summary>
public int PreCureOven3TempActValue { get; set; }
/// <summary>
/// 预固炉温度4
/// </summary>
public int PreCureOven4TempActValue { get; set; }
/// <summary>
/// 固化炉温度1
/// </summary>
public int CureOven1TempActValue { get; set; }
/// <summary>
/// 固化炉温度2
/// </summary>
public int CureOven2TempActValue { get; set; }
/// <summary>
/// 固化炉温度3
/// </summary>
public int CureOven3TempActValue { get; set; }
/// <summary>
/// 固化炉温度4
/// </summary>
public int CureOven4TempActValue { get; set; }
}
}

@ -0,0 +1,65 @@
using SQLite;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Sln.Iot.Repository.dao
{
public class VacuumInjectionPlcData
{
[PrimaryKey]
public string GUID { get; set; }
/// <summary>
/// 当前胶量设定值
/// </summary>
public float GlueAmountSetValue { get; set; }
/// <summary>
/// 当前推胶速度设定值
/// </summary>
public float GluePushSpeedSetValue { get; set; }
/// <summary>
/// 当前A1桶温度实际值
/// </summary>
public int BarrelA1TempActValue { get; set; }
/// <summary>
/// 当前A2桶温度实际值
/// </summary>
public int BarrelA2TempActValue { get; set; }
/// <summary>
/// 当前B1桶温度实际值
/// </summary>
public int BarrelB1TempActValue { get; set; }
/// <summary>
/// 当前B2桶温度实际值
/// </summary>
public int BarrelB2TempActValue { get; set; }
/// <summary>
/// 当前A泵压力实际值
/// </summary>
public float PumpAPressureActValue { get; set; }
/// <summary>
/// 当前B泵压力实际值
/// </summary>
public float PumpBPressureActValue { get; set; }
/// <summary>
/// 当前真空度实际值
/// </summary>
public float VacuumDegreeActValue { get; set; }
/// <summary>
/// 保压时长设定值
/// </summary>
public int PressureHoldTimeSetValue { get; set; }
}
}

@ -0,0 +1,140 @@
using Sln.Iot.Model.Entity;
using Sln.Iot.Repository.dao;
using Sln.Iot.Serilog;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Sln.Iot.Repository.service
{
public class OvenPlcDataService
{
private static readonly Lazy<OvenPlcDataService> lazy = new Lazy<OvenPlcDataService>(() => new OvenPlcDataService());
public static OvenPlcDataService Instance
{
get
{
return lazy.Value;
}
}
private SQLiteHelper<OvenPlcData> _helper = SQLiteHelper<OvenPlcData>.Instance;
private SerilogHelper _log = SerilogHelper.Instance;
/// <summary>
/// 插入数据
/// </summary>
/// <param name="GUID"></param>
/// <param name=""></param>
/// <returns></returns>
public bool InsertData(string guid, int data)
{
try
{
var res = _helper.Insert(new OvenPlcData()
{
GUID = guid,
PreheatOvenTempActValue = data,
});
return res == 0 ? false : true;
}
catch (Exception ex)
{
_log.Error("插入烤炉数据失败", ex);
return false;
}
}
/// <summary>
/// 预固炉温度插入
/// </summary>
/// <returns></returns>
public bool UpdateDataPreCure(string guid, UnitsProcess3Entity data)
{
try
{
var res = _helper.Update(new OvenPlcData()
{
GUID = guid,
PreCureOven1TempActValue = data.PreCureOven1TempActValue,
PreCureOven2TempActValue = data.PreCureOven2TempActValue,
PreCureOven3TempActValue = data.PreCureOven3TempActValue,
PreCureOven4TempActValue = data.PreCureOven4TempActValue,
});
return res == 0 ? false : true;
}
catch (Exception ex)
{
_log.Error("更新预固炉温度数据失败", ex);
return false;
}
}
/// <summary>
/// 固化炉温度插入
/// </summary>
/// <returns></returns>
public bool UpdateDataCure(string guid, UnitsProcess3Entity data)
{
try
{
var res = _helper.Update(new OvenPlcData()
{
GUID = guid,
CureOven1TempActValue = data.CureOven1TempActValue,
CureOven2TempActValue = data.CureOven2TempActValue,
CureOven3TempActValue = data.CureOven3TempActValue,
CureOven4TempActValue = data.CureOven4TempActValue,
});
return res == 0 ? false : true;
}
catch (Exception ex)
{
_log.Error("更新固化炉炉温度数据失败", ex);
return false;
}
}
/// <summary>
/// 获取之前暂存的数据
/// </summary>
/// <returns></returns>
public UnitsProcess3Entity GetData(string guid)
{
try
{
var res = _helper.QuerySingle(x => x.GUID == guid);
if (res == null)
{
return new UnitsProcess3Entity();
}
UnitsProcess3Entity entity = new UnitsProcess3Entity()
{
PreheatOvenTempActValue = res.PreheatOvenTempActValue,
PreCureOven1TempActValue = res.PreCureOven1TempActValue,
PreCureOven2TempActValue = res.PreCureOven2TempActValue,
PreCureOven3TempActValue = res.PreCureOven3TempActValue,
PreCureOven4TempActValue = res.PreCureOven4TempActValue,
CureOven1TempActValue = res.CureOven1TempActValue,
CureOven2TempActValue = res.CureOven2TempActValue,
CureOven3TempActValue = res.CureOven3TempActValue,
CureOven4TempActValue = res.CureOven4TempActValue,
};
_helper.Delete(guid);
return entity;
}
catch (Exception ex)
{
_log.Error("获取或删除隧道烤箱传感器数据失败", ex);
return new UnitsProcess3Entity();
}
}
}
}

@ -0,0 +1,101 @@
using Dm;
using Sln.Iot.Model.Entity;
using Sln.Iot.Repository.dao;
using Sln.Iot.Serilog;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Sln.Iot.Repository.service
{
public class VacuumInjectionPlcDataService
{
private static readonly Lazy<VacuumInjectionPlcDataService> lazy = new Lazy<VacuumInjectionPlcDataService>(() => new VacuumInjectionPlcDataService());
public static VacuumInjectionPlcDataService Instance
{
get
{
return lazy.Value;
}
}
private SQLiteHelper<VacuumInjectionPlcData> _helper = SQLiteHelper<VacuumInjectionPlcData>.Instance;
private SerilogHelper _log = SerilogHelper.Instance;
/// <summary>
/// 插入数据
/// </summary>
/// <param name="GUID"></param>
/// <param name=""></param>
/// <returns></returns>
public bool InsertData(string guid, UnitsProcess1Entity data)
{
try
{
var res = _helper.Insert(new VacuumInjectionPlcData()
{
GUID = guid,
GlueAmountSetValue = data.GlueAmountSetValue1,
GluePushSpeedSetValue = data.GluePushSpeedSetValue1,
BarrelA1TempActValue = data.BarrelA1TempActValue1,
BarrelA2TempActValue = data.BarrelA2TempActValue1,
BarrelB1TempActValue = data.BarrelB1TempActValue1,
BarrelB2TempActValue = data.BarrelB2TempActValue1,
PumpAPressureActValue = data.PumpAPressureActValue1,
PumpBPressureActValue = data.PumpBPressureActValue1,
VacuumDegreeActValue = data.VacuumDegreeActValue1,
PressureHoldTimeSetValue = data.PressureHoldTimeSetValue1
});
return res == 0 ? false : true;
}
catch (Exception ex)
{
_log.Error("插入真空箱传感器数据失败", ex);
return false;
}
}
/// <summary>
/// 获取之前暂存的数据
/// </summary>
/// <returns></returns>
public UnitsProcess1Entity GetData(string guid)
{
try
{
var res = _helper.QuerySingle(x => x.GUID == guid);
if(res == null)
{
return new UnitsProcess1Entity();
}
UnitsProcess1Entity entity = new UnitsProcess1Entity()
{
GlueAmountSetValue1 = res.GlueAmountSetValue,
GluePushSpeedSetValue1 = res.GluePushSpeedSetValue,
BarrelA1TempActValue1 = res.BarrelA1TempActValue,
BarrelA2TempActValue1 = res.BarrelA2TempActValue,
BarrelB1TempActValue1 = res.BarrelB1TempActValue,
BarrelB2TempActValue1 = res.BarrelB2TempActValue,
PumpAPressureActValue1 = res.PumpAPressureActValue,
PumpBPressureActValue1 = res.PumpBPressureActValue,
VacuumDegreeActValue1 = res.VacuumDegreeActValue,
PressureHoldTimeSetValue1 = res.PressureHoldTimeSetValue
};
_helper.Delete(guid);
return entity;
}
catch (Exception ex)
{
_log.Error("获取或删除真空箱传感器数据失败", ex);
return new UnitsProcess1Entity();
}
}
}
}
Loading…
Cancel
Save