You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

115 lines
3.4 KiB
C#

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

using Aucma.Core.Palletiz.Models;
using Aucma.Core.Palletiz.ViewModels;
using log4net;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace Aucma.Core.Palletiz.Business
{
public class ControlStackingScan
{
private static readonly log4net.ILog log = LogManager.GetLogger(typeof(ControlStackingScan));
#region 首页提示事件
public delegate void HandPalletizDelegate(string mesg, string color);
public static event HandPalletizDelegate? HandPalletizDelegateEvent;
#endregion
#region 下传分垛信息
/// <summary>
/// 下传分垛信息
/// </summary>
/// <returns></returns>
public static bool DownLoadInInfo(StackInfoModel TempStackInInfo)
{
bool ResultFlag = false;
try
{
#region 下传入库货道信息
//下传信息包含 目的货道、物料编码、工艺编码
bool wresult1 = WriteData();
if (!wresult1)
{
log.Info("下传分垛信息出现异常请检查PLC连接.");
HandPalletizDelegateEvent?.Invoke("下传分垛信息出现异常请检查PLC连接.","Red");
return false;
}
string TempStr = "下传分垛信息出现完成等待PLC反馈......";
HandPalletizDelegateEvent?.Invoke(TempStr, "White");
log.Info(TempStr);
string Infostr = "";
//返回结果处理
while (true)
{
Thread.Sleep(200);
Infostr = string.Format("下传分垛信息成功,成功接收反馈信息.");
//创建入库记录及任务
//SysBusinessFunction.WriteLog(Infostr);
//SysBusinessFunction.OperationTipsAdd(Infostr);
//SysBusinessFunction.AssemblyTaryInfo.Tips = Infostr;
//SysBusinessFunction.TempStackingInfo.MsgInfo = Infostr;
ResultFlag = true;
break;
}
#endregion
}
catch (Exception ex)
{
log.Error("error:接收返回消息异常!具体原因:" + ex.Message);
}
finally
{
}
return ResultFlag;
}
#endregion
//下传数据
public static bool WriteData()
{
bool TempResult = true;
//写入三菱PLC
if (TempResult)
{
try
{
//获取扫码器给到的成品码
//根据成品码获读取货道、最后一次物料入库的角度
//根据角度设定给当前物料设置角度
//下发给PLC:货道号、角度
//是否下传成功,成功后将信息保存到入库记录中
do
{
} while (true);
}
catch
{
}
finally
{
TempResult = true;
}
}
return TempResult;
}
}
}