增加日志打印
This commit is contained in:
parent
957917bc4d
commit
84851bbb0d
@ -1,5 +1,6 @@
|
|||||||
using System.Collections.Concurrent;
|
using System.Collections.Concurrent;
|
||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
|
using System.Text.Json;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using Seyounth.Hyosung.Core.Agv;
|
using Seyounth.Hyosung.Core.Agv;
|
||||||
using Seyounth.Hyosung.Core.Plc;
|
using Seyounth.Hyosung.Core.Plc;
|
||||||
@ -74,19 +75,29 @@ public class HyosungRuntime(
|
|||||||
/// <exception cref="NotImplementedException"></exception>
|
/// <exception cref="NotImplementedException"></exception>
|
||||||
private async Task OnPlcRequestScanFixture(int fixtureId)
|
private async Task OnPlcRequestScanFixture(int fixtureId)
|
||||||
{
|
{
|
||||||
var fix = await hyosungScannerService.ScanFixtureAsync(fixtureId);
|
logger.LogInformation($"plc request scan fixture:{fixtureId}");
|
||||||
if (string.IsNullOrEmpty(fix))
|
try
|
||||||
|
{
|
||||||
|
var fix = await hyosungScannerService.ScanFixtureAsync(fixtureId);
|
||||||
|
if (string.IsNullOrEmpty(fix))
|
||||||
|
{
|
||||||
|
await hyosungPlcService.WriteScanFixtureResultAsync(fixtureId, false);
|
||||||
|
logger.LogInformation($"scan fixture{fixtureId} fail");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
await hyosungPlcService.WriteScanFixtureResultAsync(fixtureId, true, (short)Convert.ToInt32(fix));
|
||||||
|
logger.LogInformation($"scan fixture{fixtureId} success: {fix}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
await hyosungPlcService.WriteScanFixtureResultAsync(fixtureId, false);
|
await hyosungPlcService.WriteScanFixtureResultAsync(fixtureId, false);
|
||||||
logger.LogInformation($"scan fixture{fixtureId} fail");
|
logger.LogError(e, $"scan fixture{fixtureId} fail");
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
await hyosungPlcService.WriteScanFixtureResultAsync(fixtureId, true, (short)Convert.ToInt32(fix));
|
|
||||||
logger.LogInformation($"scan fixture{fixtureId} success: {fix}");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 处理PLC请求扫描纱事件
|
/// 处理PLC请求扫描纱事件
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -94,24 +105,33 @@ public class HyosungRuntime(
|
|||||||
private async Task OnPlcRequestScanProduct(int varietyId)
|
private async Task OnPlcRequestScanProduct(int varietyId)
|
||||||
{
|
{
|
||||||
logger.LogInformation($"plc request scan yarn qrcode");
|
logger.LogInformation($"plc request scan yarn qrcode");
|
||||||
var yarn = await hyosungScannerService.ScanYarnAsync(varietyId);
|
try
|
||||||
if (yarn is null)
|
|
||||||
{
|
{
|
||||||
await hyosungPlcService.WriteScanYarnResultAsync(false);
|
var yarn = await hyosungScannerService.ScanYarnAsync(varietyId);
|
||||||
logger.LogInformation($"scan yarn fail");
|
if (yarn is null)
|
||||||
return;
|
{
|
||||||
}
|
await hyosungPlcService.WriteScanYarnResultAsync(false);
|
||||||
|
logger.LogInformation($"scan yarn fail");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var variety = await varietyService.GetById(varietyId);
|
var variety = await varietyService.GetById(varietyId);
|
||||||
if (yarn.Lot != variety.Lot)
|
if (yarn.Lot != variety.Lot)
|
||||||
|
{
|
||||||
|
await hyosungPlcService.WriteScanYarnResultAsync(false);
|
||||||
|
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);
|
await hyosungPlcService.WriteScanYarnResultAsync(false);
|
||||||
logger.LogInformation($"scan yarn fail,lot not equal");
|
logger.LogError(e, $"scan yarn fail");
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
await yarnService.AddYarnAsync(yarn);
|
|
||||||
await hyosungPlcService.WriteScanYarnResultAsync(true, (short)varietyId, yarn.ScanCode);
|
|
||||||
logger.LogInformation($"scan yarn {yarn.ScanCode} success: qrcode[{yarn.QrCode}]");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -121,11 +141,19 @@ public class HyosungRuntime(
|
|||||||
/// <exception cref="NotImplementedException"></exception>
|
/// <exception cref="NotImplementedException"></exception>
|
||||||
private async Task OnPlcRequestLeavingProductionLine(PlcStackInfo info)
|
private async Task OnPlcRequestLeavingProductionLine(PlcStackInfo info)
|
||||||
{
|
{
|
||||||
//使托盘完成
|
logger.LogInformation($"plc request leaving production line");
|
||||||
await trayService.StorageAsync(info.TrayCode);
|
try
|
||||||
await hyosungAgvService.StorageAsync(info.TrayCode);
|
{
|
||||||
//标志下线已完成
|
await trayService.StorageAsync(info.TrayCode);
|
||||||
await hyosungPlcService.LeaveCompletedAsync();
|
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");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -138,25 +166,34 @@ public class HyosungRuntime(
|
|||||||
/// <exception cref="NotImplementedException"></exception>
|
/// <exception cref="NotImplementedException"></exception>
|
||||||
private async Task OnPlcNeedNewTrayCode(int index, int varietyId)
|
private async Task OnPlcNeedNewTrayCode(int index, int varietyId)
|
||||||
{
|
{
|
||||||
var tray = await trayService.GeneraNewTray(varietyId);
|
logger.LogInformation($"plc request new tray code:{index} {varietyId}");
|
||||||
var variety = await varietyService.GetById(varietyId);
|
try
|
||||||
var stackModel = new StackStationModel();
|
|
||||||
stackModel.TrayCode = tray.TrayCode;
|
|
||||||
stackModel.VarietyCode = variety.Code;
|
|
||||||
stackModel.Layers = variety.StackingLayers;
|
|
||||||
stackModel.TotalCount = variety.TotalCount;
|
|
||||||
stackModel.CurrentCount = 0;
|
|
||||||
stackModel.Yarns = new ObservableCollection<Yarn>();
|
|
||||||
if (index == 1)
|
|
||||||
{
|
{
|
||||||
Stack1 = stackModel;
|
var tray = await trayService.GeneraNewTray(varietyId);
|
||||||
}
|
var variety = await varietyService.GetById(varietyId);
|
||||||
else
|
var stackModel = new StackStationModel();
|
||||||
{
|
stackModel.TrayCode = tray.TrayCode;
|
||||||
Stack2 = stackModel;
|
stackModel.VarietyCode = variety.Code;
|
||||||
}
|
stackModel.Layers = variety.StackingLayers;
|
||||||
|
stackModel.TotalCount = variety.TotalCount;
|
||||||
|
stackModel.CurrentCount = 0;
|
||||||
|
stackModel.Yarns = new ObservableCollection<Yarn>();
|
||||||
|
if (index == 1)
|
||||||
|
{
|
||||||
|
Stack1 = stackModel;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Stack2 = stackModel;
|
||||||
|
}
|
||||||
|
|
||||||
await hyosungPlcService.WriteTrayCodeAsync(index, tray.TrayCode);
|
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>
|
/// <summary>
|
||||||
@ -167,30 +204,39 @@ public class HyosungRuntime(
|
|||||||
/// <exception cref="NotImplementedException"></exception>
|
/// <exception cref="NotImplementedException"></exception>
|
||||||
private async Task OnPlcPutCompleted(PlcStackingInfo arg)
|
private async Task OnPlcPutCompleted(PlcStackingInfo arg)
|
||||||
{
|
{
|
||||||
if (arg.TrayCode == Stack1.TrayCode)
|
logger.LogInformation($"plc put completed:{JsonSerializer.Serialize(arg)}");
|
||||||
|
try
|
||||||
{
|
{
|
||||||
Stack1.CurrentCount += arg.YarnCode.Count;
|
if (arg.TrayCode == Stack1.TrayCode)
|
||||||
|
{
|
||||||
|
Stack1.CurrentCount += arg.YarnCode.Count;
|
||||||
|
foreach (var yarnCode in arg.YarnCode)
|
||||||
|
{
|
||||||
|
Stack1.Yarns.Add(await yarnService.GetYarnByCodeAsync(yarnCode));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (arg.TrayCode == Stack2.TrayCode)
|
||||||
|
{
|
||||||
|
Stack2.CurrentCount += arg.YarnCode.Count;
|
||||||
|
foreach (var yarnCode in arg.YarnCode)
|
||||||
|
{
|
||||||
|
Stack2.Yarns.Add(await yarnService.GetYarnByCodeAsync(yarnCode));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
foreach (var yarnCode in arg.YarnCode)
|
foreach (var yarnCode in arg.YarnCode)
|
||||||
{
|
{
|
||||||
Stack1.Yarns.Add(await yarnService.GetYarnByCodeAsync(yarnCode));
|
await yarnService.BindTrayAsync(yarnCode, await trayService.GetIdByCode(arg.TrayCode));
|
||||||
|
logger.LogInformation($" stack yarn{yarnCode} succeed");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else if (arg.TrayCode == Stack2.TrayCode)
|
|
||||||
{
|
|
||||||
Stack2.CurrentCount += arg.YarnCode.Count;
|
|
||||||
foreach (var yarnCode in arg.YarnCode)
|
|
||||||
{
|
|
||||||
Stack2.Yarns.Add(await yarnService.GetYarnByCodeAsync(yarnCode));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (var yarnCode in arg.YarnCode)
|
await hyosungPlcService.WriteReceivedYarnCountAsync(arg.YarnCode.Count);
|
||||||
{
|
logger.LogInformation($"plc put completed success");
|
||||||
await yarnService.BindTrayAsync(yarnCode, await trayService.GetIdByCode(arg.TrayCode));
|
}
|
||||||
logger.LogInformation($" stack yarn{yarnCode} succeed");
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
logger.LogError(e, $"plc put completed fail");
|
||||||
}
|
}
|
||||||
|
|
||||||
await hyosungPlcService.WriteReceivedYarnCountAsync(arg.YarnCode.Count);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -201,27 +247,36 @@ public class HyosungRuntime(
|
|||||||
/// <exception cref="NotImplementedException"></exception>
|
/// <exception cref="NotImplementedException"></exception>
|
||||||
private async Task OnPlcRequestPackLineOption(string arg)
|
private async Task OnPlcRequestPackLineOption(string arg)
|
||||||
{
|
{
|
||||||
var tray = await trayService.GetByCode(arg);
|
logger.LogInformation($"plc request pack line option");
|
||||||
var variety = await varietyService.GetById(tray.VarietyId);
|
try
|
||||||
PackLineOption = new PackLineOption()
|
|
||||||
{
|
{
|
||||||
HeadCount = variety.StackHeadCount ?? 0,
|
var tray = await trayService.GetByCode(arg);
|
||||||
HasBox = variety.HasBox,
|
var variety = await varietyService.GetById(tray.VarietyId);
|
||||||
IsTop = variety.NeedTopBoard is NeedType.Need or NeedType.NotNeed
|
PackLineOption = new PackLineOption()
|
||||||
? variety.NeedTopBoard == NeedType.Need
|
{
|
||||||
: tray.IsEven && variety.NeedTopBoard == NeedType.EvenNeed,
|
HeadCount = variety.StackHeadCount ?? 0,
|
||||||
IsPack = variety.NeedPackStrap is NeedType.Need or NeedType.NotNeed
|
HasBox = variety.HasBox,
|
||||||
? variety.NeedPackStrap == NeedType.Need
|
IsTop = variety.NeedTopBoard is NeedType.Need or NeedType.NotNeed
|
||||||
: tray.IsEven && variety.NeedPackStrap == NeedType.EvenNeed,
|
? variety.NeedTopBoard == NeedType.Need
|
||||||
IsFilm = variety.NeedFilmWrapping is NeedType.Need or NeedType.NotNeed
|
: tray.IsEven && variety.NeedTopBoard == NeedType.EvenNeed,
|
||||||
? variety.NeedFilmWrapping == NeedType.Need
|
IsPack = variety.NeedPackStrap is NeedType.Need or NeedType.NotNeed
|
||||||
: tray.IsEven && variety.NeedFilmWrapping == NeedType.EvenNeed,
|
? variety.NeedPackStrap == NeedType.Need
|
||||||
IsLam = variety.NeedFilmCoating is NeedType.Need or NeedType.NotNeed
|
: tray.IsEven && variety.NeedPackStrap == NeedType.EvenNeed,
|
||||||
? variety.NeedFilmCoating == NeedType.Need
|
IsFilm = variety.NeedFilmWrapping is NeedType.Need or NeedType.NotNeed
|
||||||
: tray.IsEven && variety.NeedFilmCoating == NeedType.EvenNeed,
|
? variety.NeedFilmWrapping == NeedType.Need
|
||||||
TrayCode = arg
|
: tray.IsEven && variety.NeedFilmWrapping == NeedType.EvenNeed,
|
||||||
};
|
IsLam = variety.NeedFilmCoating is NeedType.Need or NeedType.NotNeed
|
||||||
await hyosungPlcService.WritePackLineOptionAsync(PackLineOption);
|
? variety.NeedFilmCoating == NeedType.Need
|
||||||
|
: tray.IsEven && variety.NeedFilmCoating == NeedType.EvenNeed,
|
||||||
|
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>
|
/// <summary>
|
||||||
@ -233,6 +288,7 @@ public class HyosungRuntime(
|
|||||||
/// <exception cref="NotImplementedException"></exception>
|
/// <exception cref="NotImplementedException"></exception>
|
||||||
private async Task OnPlcRequestPrintLabel(int arg1, string trayCode, int height)
|
private async Task OnPlcRequestPrintLabel(int arg1, string trayCode, int height)
|
||||||
{
|
{
|
||||||
|
logger.LogInformation($"plc request print label:{arg1} {trayCode} {height}");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (arg1 == 1)
|
if (arg1 == 1)
|
||||||
@ -248,9 +304,10 @@ public class HyosungRuntime(
|
|||||||
await hyosungWmsService.UpdateControlNo(variety, controlNo);
|
await hyosungWmsService.UpdateControlNo(variety, controlNo);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
await printer.PrintAsync(1, trayCode);
|
await printer.PrintAsync(2, trayCode);
|
||||||
|
|
||||||
await hyosungPlcService.WritePrintLabelResultAsync(arg1, true);
|
await hyosungPlcService.WritePrintLabelResultAsync(arg1, true);
|
||||||
|
logger.LogInformation($"plc request print label success");
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user