|
|
@ -47,7 +47,7 @@ namespace Admin.Core.Tasks
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// await ExecuteJob(context, async () => await Run(context));
|
|
|
|
// await ExecuteJob(context, async () => await Run(context));
|
|
|
|
// await ExecuteJob(context, async () => await BoxFoamDataRun(context));
|
|
|
|
// await ExecuteJob(context, async () => await BoxFoamDataRun(context));
|
|
|
|
await ExecuteJob(context, async () => await Collect(context));
|
|
|
|
await ExecuteJob(context, async () => await Collect(context));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
@ -57,9 +57,14 @@ namespace Admin.Core.Tasks
|
|
|
|
/// <returns></returns>
|
|
|
|
/// <returns></returns>
|
|
|
|
public async Task Collect(IJobExecutionContext context)
|
|
|
|
public async Task Collect(IJobExecutionContext context)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
await CollectLast();
|
|
|
|
CollectLast();
|
|
|
|
}
|
|
|
|
// CollectMachine();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
|
|
/// 采集最后一枪数据
|
|
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
public async Task CollectLast()
|
|
|
|
public async Task CollectLast()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var obj = PlcHelper.siemensList.FirstOrDefault(d => d.EquipName.Equals("Plc1"));
|
|
|
|
var obj = PlcHelper.siemensList.FirstOrDefault(d => d.EquipName.Equals("Plc1"));
|
|
|
@ -86,7 +91,7 @@ namespace Admin.Core.Tasks
|
|
|
|
lastShotRecord.SetWeight = StringChange.bytesToHexStr(info.Skip(42).Take(4).ToArray(), 4);
|
|
|
|
lastShotRecord.SetWeight = StringChange.bytesToHexStr(info.Skip(42).Take(4).ToArray(), 4);
|
|
|
|
lastShotRecord.SetRatio = StringChange.bytesToHexStr(info.Skip(46).Take(4).ToArray(), 4);
|
|
|
|
lastShotRecord.SetRatio = StringChange.bytesToHexStr(info.Skip(46).Take(4).ToArray(), 4);
|
|
|
|
lastShotRecord.PourWeight = StringChange.bytesToHexStr(info.Skip(50).Take(4).ToArray(), 4);
|
|
|
|
lastShotRecord.PourWeight = StringChange.bytesToHexStr(info.Skip(50).Take(4).ToArray(), 4);
|
|
|
|
lastShotRecord.PourRatio = StringChange.bytesToHexStr(info.Skip(54).Take(4).ToArray(), 4);
|
|
|
|
lastShotRecord.PourRatio = StringChange.bytesToHexStr(info.Skip(54).Take(4).ToArray(), 4);
|
|
|
|
lastShotRecord.MpTime = StringChange.bytesToHexStr(info.Skip(58).Take(4).ToArray(), 4);
|
|
|
|
lastShotRecord.MpTime = StringChange.bytesToHexStr(info.Skip(58).Take(4).ToArray(), 4);
|
|
|
|
lastShotRecord.HpTime = StringChange.bytesToHexStr(info.Skip(62).Take(4).ToArray(), 4);
|
|
|
|
lastShotRecord.HpTime = StringChange.bytesToHexStr(info.Skip(62).Take(4).ToArray(), 4);
|
|
|
|
lastShotRecord.HydrPress = StringChange.bytesToHexStr(info.Skip(66).Take(4).ToArray(), 4);
|
|
|
|
lastShotRecord.HydrPress = StringChange.bytesToHexStr(info.Skip(66).Take(4).ToArray(), 4);
|
|
|
@ -94,16 +99,16 @@ namespace Admin.Core.Tasks
|
|
|
|
lastShotRecord.MixpistOn = StringChange.bytesToHexStr(info.Skip(74).Take(4).ToArray(), 4);
|
|
|
|
lastShotRecord.MixpistOn = StringChange.bytesToHexStr(info.Skip(74).Take(4).ToArray(), 4);
|
|
|
|
lastShotRecord.MixpistOff = StringChange.bytesToHexStr(info.Skip(78).Take(4).ToArray(), 4);
|
|
|
|
lastShotRecord.MixpistOff = StringChange.bytesToHexStr(info.Skip(78).Take(4).ToArray(), 4);
|
|
|
|
lastShotRecord.TotalYield = StringChange.bytesToHexStr(info.Skip(82).Take(4).ToArray(), 4);
|
|
|
|
lastShotRecord.TotalYield = StringChange.bytesToHexStr(info.Skip(82).Take(4).ToArray(), 4);
|
|
|
|
lastShotRecord.PourEnd = StringChange.bytesToHexStr(info.Skip(87).Take(4).ToArray(), 4);
|
|
|
|
lastShotRecord.PourEnd = StringChange.bytesToHexStr(info.Skip(87).Take(1).ToArray(), 1);
|
|
|
|
lastShotRecord.CreateTime = DateTime.Now;
|
|
|
|
lastShotRecord.CreateTime = DateTime.Now;
|
|
|
|
#endregion
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
if (tempLastRecord == null)
|
|
|
|
if (tempLastRecord == null)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
//数据库查
|
|
|
|
//数据库查
|
|
|
|
tempLastRecord = _lastShotRecordServices.Query(x=>x.System == lastShotRecord.System && x.ProductLineCode==lastShotRecord.ProductLineCode && x.GunCode==lastShotRecord.GunCode).OrderByDescending(x=>x.CreateTime).FirstOrDefault();
|
|
|
|
tempLastRecord = _lastShotRecordServices.Query(x => x.System == lastShotRecord.System && x.ProductLineCode == lastShotRecord.ProductLineCode && x.GunCode == lastShotRecord.GunCode).OrderByDescending(x => x.CreateTime).FirstOrDefault();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!tempLastRecord.MixpistOff.Equals(lastShotRecord.MixpistOff))
|
|
|
|
if (tempLastRecord == null || !tempLastRecord.MixpistOff.Equals(lastShotRecord.MixpistOff))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// 刷新页面
|
|
|
|
// 刷新页面
|
|
|
|
RefreshLastShotDataDelegateEvent?.Invoke(lastShotRecord);
|
|
|
|
RefreshLastShotDataDelegateEvent?.Invoke(lastShotRecord);
|
|
|
@ -111,14 +116,24 @@ namespace Admin.Core.Tasks
|
|
|
|
_lastShotRecordServices.AddAsync(lastShotRecord);
|
|
|
|
_lastShotRecordServices.AddAsync(lastShotRecord);
|
|
|
|
tempLastRecord = lastShotRecord;
|
|
|
|
tempLastRecord = lastShotRecord;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
|
|
/// 采集设备其他数据
|
|
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
|
|
public async Task CollectMachine()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var obj = PlcHelper.siemensList.FirstOrDefault(d => d.EquipName.Equals("Plc1"));
|
|
|
|
|
|
|
|
if (obj != null && obj.plc.IsConnected)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
byte[] info = obj.plc.ReadBytes("DB50.896", (ushort)88);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public async Task Run(IJobExecutionContext context)
|
|
|
|
public async Task Run(IJobExecutionContext context)
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
await SaveData();
|
|
|
|
await SaveData();
|
|
|
|
}
|
|
|
|
}
|
|
|
|