|
|
|
@ -8,6 +8,11 @@ using Admin.Core.Model;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using Admin.Core.Model.Model_New;
|
|
|
|
|
using Aucma.Core.HwPLc;
|
|
|
|
|
using Admin.Core.Common.Helper;
|
|
|
|
|
using HwCommunication.Core;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using Admin.Core.Service;
|
|
|
|
|
using Admin.Core.Common;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 箱体发泡 最后一枪数据采集
|
|
|
|
@ -18,22 +23,100 @@ namespace Admin.Core.Tasks
|
|
|
|
|
{
|
|
|
|
|
public delegate Task RefreshBoxFoamDataDelegate();
|
|
|
|
|
public static event RefreshBoxFoamDataDelegate RefreshBoxFoamDataDelegateEvent;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 刷新最后一枪数据
|
|
|
|
|
/// </summary>
|
|
|
|
|
public delegate void RefreshLastShotDataDelegate(BoxLastShotRecord record);
|
|
|
|
|
public static event RefreshLastShotDataDelegate RefreshLastShotDataDelegateEvent;
|
|
|
|
|
|
|
|
|
|
private static readonly log4net.ILog logHelper = LogManager.GetLogger(typeof(Job_BoxFoamData_Quartz));
|
|
|
|
|
private readonly IBoxFoamDataServices _boxFoamDataServices;
|
|
|
|
|
private readonly IOldBoxFoamDataServices _oldBoxFoamDataServices;
|
|
|
|
|
|
|
|
|
|
private readonly IBoxLastShotRecordServices _lastShotRecordServices;
|
|
|
|
|
private static BoxLastShotRecord tempLastRecord = null;
|
|
|
|
|
public Job_BoxFoamLastData_Quartz(ISysTasksQzService SysTasksQzService, ISysJobLogService sysJobLogService,
|
|
|
|
|
IBoxFoamDataServices boxFoamDataServices, IOldBoxFoamDataServices oldBoxFoamDataServices)
|
|
|
|
|
IBoxFoamDataServices boxFoamDataServices, IOldBoxFoamDataServices oldBoxFoamDataServices, IBoxLastShotRecordServices boxLastShotRecordServices)
|
|
|
|
|
{
|
|
|
|
|
_SysTasksQzService = SysTasksQzService;
|
|
|
|
|
_boxFoamDataServices = boxFoamDataServices;
|
|
|
|
|
_oldBoxFoamDataServices = oldBoxFoamDataServices;
|
|
|
|
|
_lastShotRecordServices = boxLastShotRecordServices;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async Task Execute(IJobExecutionContext context)
|
|
|
|
|
{
|
|
|
|
|
await ExecuteJob(context, async () => await Run(context));
|
|
|
|
|
await ExecuteJob(context, async () => await BoxFoamDataRun(context));
|
|
|
|
|
// await ExecuteJob(context, async () => await Run(context));
|
|
|
|
|
// await ExecuteJob(context, async () => await BoxFoamDataRun(context));
|
|
|
|
|
await ExecuteJob(context, async () => await Collect(context));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 采集注料记录最近一枪
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="context"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public async Task Collect(IJobExecutionContext context)
|
|
|
|
|
{
|
|
|
|
|
await CollectLast();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async Task CollectLast()
|
|
|
|
|
{
|
|
|
|
|
var obj = PlcHelper.siemensList.FirstOrDefault(d => d.EquipName.Equals("Plc1"));
|
|
|
|
|
if (obj != null && obj.plc.IsConnected)
|
|
|
|
|
{
|
|
|
|
|
BoxLastShotRecord lastShotRecord = new BoxLastShotRecord();
|
|
|
|
|
byte[] info = obj.plc.ReadBytes("DB50.900", (ushort)87);
|
|
|
|
|
IByteTransform byteTransform = new RegularByteTransform();
|
|
|
|
|
lastShotRecord.System = "1";
|
|
|
|
|
lastShotRecord.BoxFixtureType = "test";
|
|
|
|
|
lastShotRecord.GunHead = Encoding.ASCII.GetString(info.Skip(0).Take(4).ToArray());
|
|
|
|
|
lastShotRecord.StationNumber = StringChange.bytesToHexStr(info.Skip(4).Take(2).ToArray(), 2);
|
|
|
|
|
lastShotRecord.MediumPressureCycleTime = StringChange.bytesToHexStr(info.Skip(6).Take(4).ToArray(), 4);
|
|
|
|
|
lastShotRecord.HighPressureCycleTime = StringChange.bytesToHexStr(info.Skip(10).Take(4).ToArray(), 4);
|
|
|
|
|
lastShotRecord.SetInjectionWeight = StringChange.bytesToHexStr(info.Skip(14).Take(4).ToArray(), 4);
|
|
|
|
|
lastShotRecord.InjectionMaterialRatio = StringChange.bytesToHexStr(info.Skip(18).Take(4).ToArray(), 4);
|
|
|
|
|
lastShotRecord.ActualInjectionWeight = StringChange.bytesToHexStr(info.Skip(22).Take(4).ToArray(), 4);
|
|
|
|
|
lastShotRecord.ActualInjectionMaterialRatio = StringChange.bytesToHexStr(info.Skip(26).Take(4).ToArray(), 4);
|
|
|
|
|
lastShotRecord.PolInjectionpressure = StringChange.bytesToHexStr(info.Skip(30).Take(4).ToArray(), 4);
|
|
|
|
|
lastShotRecord.IsoInjectionpressure = StringChange.bytesToHexStr(info.Skip(34).Take(4).ToArray(), 4);
|
|
|
|
|
lastShotRecord.PolInjectiontemperature = StringChange.bytesToHexStr(info.Skip(38).Take(4).ToArray(), 4);
|
|
|
|
|
lastShotRecord.IsoInjectiontemperature = StringChange.bytesToHexStr(info.Skip(42).Take(4).ToArray(), 4);
|
|
|
|
|
|
|
|
|
|
lastShotRecord.InjecPressureOfPOLGunHead = StringChange.bytesToHexStr(info.Skip(46).Take(4).ToArray(), 4);
|
|
|
|
|
lastShotRecord.InjecPressureOfISOGunHead = StringChange.bytesToHexStr(info.Skip(50).Take(4).ToArray(), 4);
|
|
|
|
|
lastShotRecord.POLInjecTemperatureOfGunHead = StringChange.bytesToHexStr(info.Skip(54).Take(4).ToArray(), 4);
|
|
|
|
|
lastShotRecord.ISOInjecTemperatureOfGunHead = StringChange.bytesToHexStr(info.Skip(58).Take(4).ToArray(), 4);
|
|
|
|
|
|
|
|
|
|
lastShotRecord.POLInjecFlowRate = StringChange.bytesToHexStr(info.Skip(62).Take(4).ToArray(), 4);
|
|
|
|
|
lastShotRecord.ISOInjecFlowRate = StringChange.bytesToHexStr(info.Skip(66).Take(4).ToArray(), 4);
|
|
|
|
|
lastShotRecord.HydraulicPressure = StringChange.bytesToHexStr(info.Skip(70).Take(4).ToArray(), 4);
|
|
|
|
|
lastShotRecord.HydraulicTemperature = StringChange.bytesToHexStr(info.Skip(74).Take(4).ToArray(), 4);
|
|
|
|
|
lastShotRecord.SmallPistonFiringTime = StringChange.bytesToHexStr(info.Skip(78).Take(4).ToArray(), 4);
|
|
|
|
|
lastShotRecord.SmallPistonGunShutdownTime = StringChange.bytesToHexStr(info.Skip(82).Take(4).ToArray(), 4);
|
|
|
|
|
lastShotRecord.InjectionStatus = StringChange.bytesToHexStr(info.Skip(86).Take(1).ToArray(), 1);
|
|
|
|
|
lastShotRecord.LastTime = DateTime.Now;
|
|
|
|
|
lastShotRecord.Createtime = DateTime.Now;
|
|
|
|
|
lastShotRecord.ProductLineCode = "111";
|
|
|
|
|
|
|
|
|
|
if (tempLastRecord == null)
|
|
|
|
|
{
|
|
|
|
|
//数据库查
|
|
|
|
|
tempLastRecord = _lastShotRecordServices.Query(x=>x.System == lastShotRecord.System).OrderByDescending(x=>x.Createtime).FirstOrDefault();
|
|
|
|
|
}
|
|
|
|
|
if (!tempLastRecord.SmallPistonGunShutdownTime.Equals(lastShotRecord.SmallPistonGunShutdownTime))
|
|
|
|
|
{
|
|
|
|
|
// 刷新页面
|
|
|
|
|
RefreshLastShotDataDelegateEvent?.Invoke(lastShotRecord);
|
|
|
|
|
//保存
|
|
|
|
|
_lastShotRecordServices.AddAsync(lastShotRecord);
|
|
|
|
|
tempLastRecord = lastShotRecord;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async Task Run(IJobExecutionContext context)
|
|
|
|
|