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 下传分垛信息 /// /// 下传分垛信息 /// /// 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; } } }