feat: 补充TCS-AGV调度方法
This commit is contained in:
67
MisDataFunction/Function1054/Methods/TcsAgvDispatch.cs
Normal file
67
MisDataFunction/Function1054/Methods/TcsAgvDispatch.cs
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
using System;
|
||||||
|
using System.Threading;
|
||||||
|
using MesServerWork;
|
||||||
|
using MisDataSaveDate;
|
||||||
|
using MisDataSaveDate.Helper;
|
||||||
|
|
||||||
|
namespace MesServerFunctions
|
||||||
|
{
|
||||||
|
public partial class FunctionMES
|
||||||
|
{
|
||||||
|
private class TcsAgvDispatchContext
|
||||||
|
{
|
||||||
|
public DeviceDriver_BasicData.CustomeEvetnArgs EventArgs { get; set; }
|
||||||
|
public string ActionType { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
private void fun_TcsAgvDispatch(DeviceDriver_BasicData.CustomeEvetnArgs e, string actionType)
|
||||||
|
{
|
||||||
|
ThreadPool.QueueUserWorkItem(TcsAgvDispatch, new TcsAgvDispatchContext
|
||||||
|
{
|
||||||
|
EventArgs = e,
|
||||||
|
ActionType = actionType
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void TcsAgvDispatch(object state)
|
||||||
|
{
|
||||||
|
string opName = "";
|
||||||
|
try
|
||||||
|
{
|
||||||
|
TcsAgvDispatchContext context = state as TcsAgvDispatchContext;
|
||||||
|
if (context == null || context.EventArgs == null)
|
||||||
|
{
|
||||||
|
throw new Exception("TCS任务参数为空");
|
||||||
|
}
|
||||||
|
|
||||||
|
opName = Convert.ToString(context.EventArgs.OpName);
|
||||||
|
if (string.IsNullOrWhiteSpace(opName))
|
||||||
|
{
|
||||||
|
throw new Exception("PLC事件未包含工位号");
|
||||||
|
}
|
||||||
|
|
||||||
|
int completionCode = context.ActionType == "插" ? 400 : 401;
|
||||||
|
MIS_BASE.WritePLC(completionCode, opName, false);
|
||||||
|
|
||||||
|
TCSAGV_CallResult result = TCSAGV_BusinessLogic.DispatchStationTask(
|
||||||
|
opName, context.ActionType, "", "PLC_AUTO", "PLC自动", "", true);
|
||||||
|
if (!result.Success)
|
||||||
|
{
|
||||||
|
throw new Exception(result.Message);
|
||||||
|
}
|
||||||
|
|
||||||
|
string logText = "TCS" + context.ActionType + "任务已下发:工位=" + opName
|
||||||
|
+ ",外部任务编号=" + result.ExternalCode;
|
||||||
|
ApiLogHelper.SaveMesLog(opName, logText, MesLogType.INFO);
|
||||||
|
SendMessage.AsyncSendMessage_Notice(opName, logText);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
string logText = "TCS插拔任务下发失败:" + ex.Message;
|
||||||
|
ApiLogHelper.SaveMesLog(opName, logText, MesLogType.ERROR);
|
||||||
|
SendMessage.AsyncSendMessage_Notice(opName, logText);
|
||||||
|
MyLog4Net.MyLogHelper.Error("Function1054_TcsAgvDispatch", logText + Environment.NewLine + ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user