using Autofac.Core;
|
using HslCommunication;
|
using HslCommunication.Core;
|
using Microsoft.VisualBasic.FileIO;
|
using Quartz;
|
using SixLabors.ImageSharp.PixelFormats;
|
using System;
|
using System.Collections.Generic;
|
using System.ComponentModel;
|
using System.Linq;
|
using System.Reflection;
|
using System.Text;
|
using System.Threading.Tasks;
|
using WIDESEAWCS_BasicInfoService;
|
using WIDESEAWCS_Communicator;
|
using WIDESEAWCS_Core.Helper;
|
using WIDESEAWCS_QuartzJob;
|
using WIDESEAWCS_QuartzJob.DeviceBase;
|
using WIDESEAWCS_QuartzJob.StackerCrane.Enum;
|
|
namespace WIDESEAWCS_Tasks
|
{
|
[DisallowConcurrentExecution]
|
public class PLCJob : JobBase, IJob
|
{
|
private readonly IBoxingService _boxingService;
|
private readonly IBoxingDetailService _boxingDetailService;
|
private readonly IFormulaService _formulaService;
|
private readonly IFormulaDetailService _formulaDetailService;
|
private readonly IProcessInfoService _processInfoService;
|
public PLCJob(IBoxingService boxingService, IBoxingDetailService boxingDetailService, IFormulaService formulaService, IFormulaDetailService formulaDetailService, IProcessInfoService processInfoService)
|
{
|
_boxingService = boxingService;
|
_boxingDetailService = boxingDetailService;
|
_formulaService = formulaService;
|
_formulaDetailService = formulaDetailService;
|
_processInfoService = processInfoService;
|
}
|
|
public Task Execute(IJobExecutionContext context)
|
{
|
|
bool flag = context.JobDetail.JobDataMap.TryGetValue("JobParams", out object? value);
|
if (flag && value != null)
|
{
|
if (value is OtherDevice)
|
{
|
OtherDevice device = (OtherDevice)value;
|
try
|
{
|
var Heart = device.GetValue<R_PLCDBName, bool>(R_PLCDBName.rboolHeart);
|
var EMG = device.GetValue<R_PLCDBName, bool>(R_PLCDBName.rboolEMG);
|
var AutoExecuting = device.GetValue<R_PLCDBName, bool>(R_PLCDBName.rboolAutoExecuting);
|
var OnlineExecuting = device.GetValue<R_PLCDBName, bool>(R_PLCDBName.rboolOnlineExecuting);
|
var Error = device.GetValue<R_PLCDBName, bool>(R_PLCDBName.rboolError);
|
if (Heart && !EMG && AutoExecuting && OnlineExecuting && !Error)
|
{
|
#region 上线扫码
|
var Location1ScanStart = device.GetValue<R_PLCDBName, bool>(R_PLCDBName.rboolLocation1ScanStart);
|
var Location1ScanDone = device.GetValue<W_PLCDBName, bool>(W_PLCDBName.wboolLocation1ScanDone);
|
if (Location1ScanStart && !Location1ScanDone)//控制扫码枪扫描托盘码,根据托盘码查询组盘数据,判断托盘绑定成品是否已绑定所有所需零件
|
{
|
device.SetValue(W_PLCDBName.wboolLocation1ScanDone, true);
|
}
|
else if (!Location1ScanDone && Location1ScanStart)
|
{
|
device.SetValue(W_PLCDBName.wboolLocation1ScanDone, false);
|
}
|
#endregion
|
|
|
#region 压装扫码
|
var Location2ScanStart = device.GetValue<R_PLCDBName, bool>(R_PLCDBName.rboolLocation2ScanStart);
|
if (Location2ScanStart)//控制扫码枪扫描托盘码,根据托盘码查询托盘绑定成品加工所需数据,写入PLC
|
{
|
|
}
|
#endregion
|
|
#region 检测扫码
|
var Location3ScanStart = device.GetValue<R_PLCDBName, bool>(R_PLCDBName.rboolLocation3ScanStart);
|
#endregion
|
|
#region 下线扫码
|
var Location4ScanStart = device.GetValue<R_PLCDBName, bool>(R_PLCDBName.rboolLocation4ScanStart);
|
#endregion
|
}
|
|
|
//var a = _boxingService.Repository.QueryFirst(x => x.PalletCode == "1232123");
|
//WriteInfo(device.DeviceName, "infoLog");
|
|
//WriteDebug(device.DeviceName, "debugLog");
|
}
|
catch (Exception ex)
|
{
|
WriteError(device.DeviceName, "错误", ex);
|
}
|
}
|
}
|
return Task.CompletedTask;
|
}
|
}
|
|
|
}
|