Commit ad5b7d80 LN

扫码改回task方式

1 个父辈 96b0eb0d
此文件类型无法预览
......@@ -184,7 +184,10 @@ namespace OnlineStore.DeviceLibrary
if (IOValue(IO_Type.Location_Check3).Equals(IO_VALUE.HIGH))
{
LogUtil.info(Name + "启动时长皮带线定位信号亮,触发一次扫码");
NewTypeScan(true);
Task.Factory.StartNew(delegate
{
NewTypeScan(true);
}, TaskCreationOptions.LongRunning);
}
else
{
......@@ -518,8 +521,8 @@ namespace OnlineStore.DeviceLibrary
IsInScanCode = true;
LastScanTime=DateTime.Now;
string LastCode = "";
Task.Factory.StartNew(delegate
{
//Task.Factory.StartNew(delegate
//{
if (isfirst)
{
StationInfo_NG = new StationTrayInfo(IO_VALUE.HIGH);
......@@ -575,7 +578,7 @@ namespace OnlineStore.DeviceLibrary
LogUtil.info(hengyiName + " 扫码工位 : 扫码结束 ," + StationInfo_Scan.ToStr + " IsInScanCode = " + IsInScanCode);
}
}
}, TaskCreationOptions.LongRunning);
//}, TaskCreationOptions.LongRunning);
}
private void UpdateScanInfo(IO_VALUE value,string code)
......
......@@ -758,23 +758,24 @@ namespace OnlineStore.DeviceLibrary
}
else if (MoveInfo.MoveStep.Equals(LineMoveStep.FI_13_ScanCode))
{
//if (ScanCodeTask == null || ScanCodeTask.IsCompleted)
//{
if (ScanCodeTask == null || ScanCodeTask.IsCompleted)
{
MoveInfo.NextMoveStep(LineMoveStep.FI_14_CylinderTake);
InLog("料盘移栽" + MoveInfo.SLog + ":上料横移取料端");
CylinderMove(MoveInfo, IO_Type.SL_MoveCylinder_Give, IO_Type.SL_MoveCylinder_Take);
ClearTimeoutAlarm("扫码执行结束超时");
//}
//else if (MoveInfo.IsTimeOut(60))
//{
// WarnMsg = MoveInfo.Name + "[" + MoveInfo.MoveStep + "] 扫码执行结束超时 [" + Math.Round(MoveInfo.StepSpan().TotalSeconds, 1) + "]秒";
// LogUtil.error(WarnMsg, DeviceID * 1000 + 30);
// Alarm(LineAlarmType.IoSingleTimeOut);
//}
}
else if (MoveInfo.IsTimeOut(60))
{
WarnMsg = MoveInfo.Name + "[" + MoveInfo.MoveStep + "] 扫码执行结束超时 [" + Math.Round(MoveInfo.StepSpan().TotalSeconds, 1) + "]秒";
LogUtil.error(WarnMsg, DeviceID * 1000 + 30);
Alarm(LineAlarmType.IoSingleTimeOut);
}
}
else if (MoveInfo.MoveStep.Equals(LineMoveStep.FI_14_CylinderTake))
{
MoveInfo.NextMoveStep(LineMoveStep.FI_15_UpdownAxisToP3);
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(500));
InLog("料盘移栽" + MoveInfo.SLog + ":升降轴到P3");
UpdownAxis.AbsMove(MoveInfo, Config.UpDownAxisP3, Config.UpdownAxis_P3Speed);
}
......@@ -1278,17 +1279,17 @@ namespace OnlineStore.DeviceLibrary
CylinderMove(MoveInfo, IO_Type.SL_MoveCylinder_Down, IO_Type.SL_MoveCylinder_Up);
}
}
//private Task ScanCodeTask = null;
private Task ScanCodeTask = null;
private void FI_13_ScanCode()
{
if (CylinderIsOk(IO_Type.SL_MoveCylinder_Take,IO_Type.SL_MoveCylinder_Give))
if (CylinderIsOk(IO_Type.SL_MoveCylinder_Take, IO_Type.SL_MoveCylinder_Give))
{
MoveInfo.NextMoveStep(LineMoveStep.FI_13_ScanCode);
bool isScan = ConfigAppSettings.GetIntValue(Setting_Init.NeedScanCode).Equals(1);
LastCodeList = new List<string>();
//ScanCodeTask = null;
ScanCodeTask = null;
if (NextCodeList.Count > 0)
{
InLog("料盘移栽" + MoveInfo.SLog + ":开始扫码:使用预扫码");
......@@ -1304,28 +1305,28 @@ namespace OnlineStore.DeviceLibrary
InLog("料盘移栽" + MoveInfo.SLog + ":开始扫码");
MoveInfo.OneWaitCanEndStep = true;
MoveInfo.WaitList.Add(WaitResultInfo.WaitFeedScanCode());
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(20000));
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(7000));
try
{
//ScanCodeTask = Task.Factory.StartNew(delegate
//{
LastCodeList = CodeManager.CameraScan(Config.GetCameraList(), Name);
bool hasRightCode = CodeManager.HasRightCode(LastCodeList.ToArray());
if (!hasRightCode)
ScanCodeTask = Task.Factory.StartNew(delegate
{
LastCodeList = CodeManager.CameraScan(Config.GetCameraList(), Name, false, 3000);
}
//return LastCodeList;
//});
LastCodeList = CodeManager.CameraScan(Config.GetCameraList(), Name);
bool hasRightCode = CodeManager.HasRightCode(LastCodeList.ToArray());
if (!hasRightCode)
{
LastCodeList = CodeManager.CameraScan(Config.GetCameraList(), Name, false, 3000);
}
return LastCodeList;
});
}
catch (Exception ex)
{
LogUtil.error("FI_13_ScanCode扫码出错:", ex);
}
finally
{
MoveInfo.EndStepWait();
}
//finally
//{
// MoveInfo.EndStepWait();
//}
}
else
{
......
......@@ -520,16 +520,14 @@ namespace OnlineStore.DeviceLibrary
}
LastEndTime = DateTime.Now;
IOManager.IOMove(MoveDO, IO_VALUE.LOW, subType);
if (!isRestart)
{
Task.Factory.StartNew(delegate
{
turnEnd?.Invoke(result.Equals(""));
});
}
InTurn = false;
WaitCheckDI_High = false;
CheckDIHigh = false;
if (!isRestart)
{
turnEnd?.Invoke(result.Equals(""));
}
return result;
}
}
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!