增加日志打印
This commit is contained in:
parent
957917bc4d
commit
84851bbb0d
@ -1,5 +1,6 @@
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Text.Json;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Seyounth.Hyosung.Core.Agv;
|
||||
using Seyounth.Hyosung.Core.Plc;
|
||||
@ -73,6 +74,9 @@ public class HyosungRuntime(
|
||||
/// <returns></returns>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
private async Task OnPlcRequestScanFixture(int fixtureId)
|
||||
{
|
||||
logger.LogInformation($"plc request scan fixture:{fixtureId}");
|
||||
try
|
||||
{
|
||||
var fix = await hyosungScannerService.ScanFixtureAsync(fixtureId);
|
||||
if (string.IsNullOrEmpty(fix))
|
||||
@ -86,6 +90,13 @@ public class HyosungRuntime(
|
||||
logger.LogInformation($"scan fixture{fixtureId} success: {fix}");
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
await hyosungPlcService.WriteScanFixtureResultAsync(fixtureId, false);
|
||||
logger.LogError(e, $"scan fixture{fixtureId} fail");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 处理PLC请求扫描纱事件
|
||||
@ -94,6 +105,8 @@ public class HyosungRuntime(
|
||||
private async Task OnPlcRequestScanProduct(int varietyId)
|
||||
{
|
||||
logger.LogInformation($"plc request scan yarn qrcode");
|
||||
try
|
||||
{
|
||||
var yarn = await hyosungScannerService.ScanYarnAsync(varietyId);
|
||||
if (yarn is null)
|
||||
{
|
||||
@ -109,10 +122,17 @@ public class HyosungRuntime(
|
||||
logger.LogInformation($"scan yarn fail,lot not equal");
|
||||
return;
|
||||
}
|
||||
|
||||
await yarnService.AddYarnAsync(yarn);
|
||||
await hyosungPlcService.WriteScanYarnResultAsync(true, (short)varietyId, yarn.ScanCode);
|
||||
logger.LogInformation($"scan yarn {yarn.ScanCode} success: qrcode[{yarn.QrCode}]");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
await hyosungPlcService.WriteScanYarnResultAsync(false);
|
||||
logger.LogError(e, $"scan yarn fail");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 处理PLC请求下线事件
|
||||
@ -121,11 +141,19 @@ public class HyosungRuntime(
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
private async Task OnPlcRequestLeavingProductionLine(PlcStackInfo info)
|
||||
{
|
||||
//使托盘完成
|
||||
logger.LogInformation($"plc request leaving production line");
|
||||
try
|
||||
{
|
||||
await trayService.StorageAsync(info.TrayCode);
|
||||
await hyosungAgvService.StorageAsync(info.TrayCode);
|
||||
//标志下线已完成
|
||||
await hyosungPlcService.LeaveCompletedAsync();
|
||||
logger.LogInformation($"plc leaving production line success");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
logger.LogError(e, $"plc leaving production line fail");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -137,6 +165,9 @@ public class HyosungRuntime(
|
||||
/// <returns></returns>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
private async Task OnPlcNeedNewTrayCode(int index, int varietyId)
|
||||
{
|
||||
logger.LogInformation($"plc request new tray code:{index} {varietyId}");
|
||||
try
|
||||
{
|
||||
var tray = await trayService.GeneraNewTray(varietyId);
|
||||
var variety = await varietyService.GetById(varietyId);
|
||||
@ -157,6 +188,12 @@ public class HyosungRuntime(
|
||||
}
|
||||
|
||||
await hyosungPlcService.WriteTrayCodeAsync(index, tray.TrayCode);
|
||||
logger.LogInformation($"plc request new tray code success: {tray.TrayCode}");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
logger.LogError(e, $"plc request new tray code fail");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -166,6 +203,9 @@ public class HyosungRuntime(
|
||||
/// <returns></returns>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
private async Task OnPlcPutCompleted(PlcStackingInfo arg)
|
||||
{
|
||||
logger.LogInformation($"plc put completed:{JsonSerializer.Serialize(arg)}");
|
||||
try
|
||||
{
|
||||
if (arg.TrayCode == Stack1.TrayCode)
|
||||
{
|
||||
@ -191,6 +231,12 @@ public class HyosungRuntime(
|
||||
}
|
||||
|
||||
await hyosungPlcService.WriteReceivedYarnCountAsync(arg.YarnCode.Count);
|
||||
logger.LogInformation($"plc put completed success");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
logger.LogError(e, $"plc put completed fail");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -200,6 +246,9 @@ public class HyosungRuntime(
|
||||
/// <returns></returns>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
private async Task OnPlcRequestPackLineOption(string arg)
|
||||
{
|
||||
logger.LogInformation($"plc request pack line option");
|
||||
try
|
||||
{
|
||||
var tray = await trayService.GetByCode(arg);
|
||||
var variety = await varietyService.GetById(tray.VarietyId);
|
||||
@ -222,6 +271,12 @@ public class HyosungRuntime(
|
||||
TrayCode = arg
|
||||
};
|
||||
await hyosungPlcService.WritePackLineOptionAsync(PackLineOption);
|
||||
logger.LogInformation($"plc request pack line option success");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
logger.LogError(e, $"plc request pack line option fail");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -233,6 +288,7 @@ public class HyosungRuntime(
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
private async Task OnPlcRequestPrintLabel(int arg1, string trayCode, int height)
|
||||
{
|
||||
logger.LogInformation($"plc request print label:{arg1} {trayCode} {height}");
|
||||
try
|
||||
{
|
||||
if (arg1 == 1)
|
||||
@ -248,9 +304,10 @@ public class HyosungRuntime(
|
||||
await hyosungWmsService.UpdateControlNo(variety, controlNo);
|
||||
}
|
||||
else
|
||||
await printer.PrintAsync(1, trayCode);
|
||||
await printer.PrintAsync(2, trayCode);
|
||||
|
||||
await hyosungPlcService.WritePrintLabelResultAsync(arg1, true);
|
||||
logger.LogInformation($"plc request print label success");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user