Commit c2ca5243 几米阳光

光栅修改

1 个父辈 9100311f
...@@ -208,9 +208,9 @@ namespace OnlineStore.DeviceLibrary ...@@ -208,9 +208,9 @@ namespace OnlineStore.DeviceLibrary
if (data == null) if (data == null)
{ {
return; return;
} }
byte[] returnData = SendCommand(portName, data, 50, 8); byte[] returnData = SendCommand(portName, data, 50, 8);
if (returnData!=null) if (returnData != null)
{ {
string strSend = ""; string strSend = "";
for (int i = 0; i < returnData.Length; i++) for (int i = 0; i < returnData.Length; i++)
...@@ -231,6 +231,10 @@ namespace OnlineStore.DeviceLibrary ...@@ -231,6 +231,10 @@ namespace OnlineStore.DeviceLibrary
/// <returns>返回值的长度</returns> /// <returns>返回值的长度</returns>
public static byte[] SendCommand(string portName, byte[] data, int outTime, int reviceLength) public static byte[] SendCommand(string portName, byte[] data, int outTime, int reviceLength)
{ {
if (outTime > 80)
{
outTime = 80;
}
byte[] returnData = null; byte[] returnData = null;
try try
......
...@@ -3,6 +3,7 @@ using OnlineStore.Common; ...@@ -3,6 +3,7 @@ using OnlineStore.Common;
using OnlineStore.LoadCSVLibrary; using OnlineStore.LoadCSVLibrary;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading; using System.Threading;
...@@ -725,27 +726,29 @@ namespace OnlineStore.DeviceLibrary ...@@ -725,27 +726,29 @@ namespace OnlineStore.DeviceLibrary
//} //}
} }
private bool InProcess = false; private bool InProcess = false;
private DateTime preProcessTime = DateTime.Now; //private DateTime preProcessTime = DateTime.Now;
private bool IsChongfu = false; private bool IsChongfu = false;
private Stopwatch stopwatch = new Stopwatch();
protected override void timersTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e) protected override void timersTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{ {
if (InProcess) if (InProcess)
{ {
TimeSpan span = DateTime.Now - preProcessTime; //TimeSpan span = DateTime.Now - preProcessTime;
if (span.TotalMinutes < 1) if (stopwatch.Elapsed.TotalMinutes < 1)
{ {
return; return;
} }
else else
{ {
LogUtil.error("主定时器:InProcess已等待" + span.ToString() + "重新处理"); LogUtil.error("主定时器:InProcess已等待" + stopwatch.Elapsed.ToString() + "重新处理");
IsChongfu = true; IsChongfu = true;
} }
} }
try try
{ {
InProcess = true; InProcess = true;
preProcessTime = DateTime.Now; //preProcessTime = DateTime.Now;
stopwatch.Restart();
IoCheckProcess(); IoCheckProcess();
ShowTimeLog("IoCheckProcess"); ShowTimeLog("IoCheckProcess");
TimerProcess(); TimerProcess();
...@@ -769,7 +772,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -769,7 +772,7 @@ namespace OnlineStore.DeviceLibrary
{ {
if (IsChongfu) if (IsChongfu)
{ {
LogUtil.info("【" + info + "】 处理完成,耗时:" + (DateTime.Now - preProcessTime).ToString()); LogUtil.info("【" + info + "】 处理完成,耗时:" + stopwatch.Elapsed.ToString());
} }
} }
//private void LedProcess() //private void LedProcess()
...@@ -1002,34 +1005,61 @@ namespace OnlineStore.DeviceLibrary ...@@ -1002,34 +1005,61 @@ namespace OnlineStore.DeviceLibrary
//} //}
} }
private int NeedCheckSafetyLight = 0; private object safetyInProcess="";
/// <summary> /// <summary>
/// 光栅处理 /// 光栅处理
/// </summary> /// </summary>
private void SafetyLightProcess() private void SafetyLightProcess()
{ {
//遮挡光栅信号 if (Monitor.TryEnter(safetyInProcess))
if (KNDIOValue(IO_Type.SafetyLightCurtains).Equals(IO_VALUE.LOW)) {
{ try
if (StoreMove.MoveType.Equals(StoreMoveType.OutStore)&&StoreMove.MoveStep.Equals(StoreMoveStep.SO_10_DeviceToDoor))
{ {
if (NeedCheckSafetyLight.Equals(1)) //遮挡光栅信号
if (KNDIOValue(IO_Type.SafetyLightCurtains).Equals(IO_VALUE.LOW))
{ {
ACServerManager.SuddenStop(Config.InOut_Axis.DeviceName, Config.InOut_Axis.GetAxisValue()); if (NeedCheckSafetyLight.Equals(1))
NeedCheckSafetyLight = 2; {
if (StoreMove.MoveType.Equals(StoreMoveType.OutStore) && StoreMove.MoveStep.Equals(StoreMoveStep.SO_10_DeviceToDoor))
{
NeedCheckSafetyLight = 2;
LOGGER.Info("出库SO_10_DeviceToDoor运动中,光栅被遮挡,停止进出轴运动");
ACServerManager.SuddenStop(Config.InOut_Axis.DeviceName, Config.InOut_Axis.GetAxisValue());
}
else if (StoreMove.MoveType.Equals(StoreMoveType.InStore) && StoreMove.MoveStep.Equals(StoreMoveStep.SI_05_DeviceToDoor))
{
NeedCheckSafetyLight = 2;
LOGGER.Info("入库SI_05_DeviceToDoor运动中,光栅被遮挡,停止进出轴运动");
ACServerManager.SuddenStop(Config.InOut_Axis.DeviceName, Config.InOut_Axis.GetAxisValue());
}
}
} }
} else
}
else
{
if (StoreMove.MoveType.Equals(StoreMoveType.OutStore) && StoreMove.MoveStep.Equals(StoreMoveStep.SO_10_DeviceToDoor))
{
if (NeedCheckSafetyLight.Equals(2))
{ {
SO_10_DeviceToDoorPro(); if (NeedCheckSafetyLight.Equals(2))
{
if (StoreMove.MoveType.Equals(StoreMoveType.OutStore) && StoreMove.MoveStep.Equals(StoreMoveStep.SO_10_DeviceToDoor))
{
LOGGER.Info("出库SO_10_DeviceToDoor运动中,光栅已恢复,继续进出轴运动");
SO_10_DeviceToDoorPro();
}
else if (StoreMove.MoveType.Equals(StoreMoveType.InStore) && StoreMove.MoveStep.Equals(StoreMoveStep.SI_05_DeviceToDoor))
{
LOGGER.Info("入库SI_05_DeviceToDoor运动中,光栅已恢复,继续进出轴运动");
SI_05_DeviceToDoor();
}
}
} }
} }
} catch (Exception ex)
{
LogUtil.error("光栅处理出错:" + ex.ToString());
}
finally
{
Monitor.Exit(safetyInProcess);
}
}
} }
public void TimerProcess() public void TimerProcess()
{ {
...@@ -1221,7 +1251,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -1221,7 +1251,7 @@ namespace OnlineStore.DeviceLibrary
//在回原点,复位,出入库时,检测报警间隔减小 //在回原点,复位,出入库时,检测报警间隔减小
if (storeRunStatus.Equals(StoreRunStatus.Busy) || storeRunStatus.Equals(StoreRunStatus.HomeMoving) || storeRunStatus.Equals(StoreRunStatus.Reset)) if (storeRunStatus.Equals(StoreRunStatus.Busy) || storeRunStatus.Equals(StoreRunStatus.HomeMoving) || storeRunStatus.Equals(StoreRunStatus.Reset))
{ {
if (span.TotalSeconds < 0.5) if (span.TotalSeconds < 1)
{ {
return false; return false;
} }
......
...@@ -297,6 +297,13 @@ namespace OnlineStore.DeviceLibrary ...@@ -297,6 +297,13 @@ namespace OnlineStore.DeviceLibrary
OpenDoorAndWait(); OpenDoorAndWait();
InOutBackToP1(moveP.InOut_P1); InOutBackToP1(moveP.InOut_P1);
} }
private void SI_05_DeviceToDoor()
{
InStoreLog("入库:SI_05 叉子进入入料口,进出轴至P2(进料口取料点) ");
StoreMove.NextMoveStep(StoreMoveStep.SI_05_DeviceToDoor);
ACAxisMove(Config.InOut_Axis, StoreMove.MoveParam.MoveP.InOut_P2, Config.InOutAxis_P2_Speed);
NeedCheckSafetyLight = 1;
}
protected override void InStoreProcess() protected override void InStoreProcess()
{ {
LineMoveP moveP = StoreMove.MoveParam.MoveP; LineMoveP moveP = StoreMove.MoveParam.MoveP;
...@@ -350,19 +357,19 @@ namespace OnlineStore.DeviceLibrary ...@@ -350,19 +357,19 @@ namespace OnlineStore.DeviceLibrary
} }
else else
{ {
InStoreLog("入库:SI_05 叉子进入入料口,进出轴至P2(进料口取料点) "); SI_05_DeviceToDoor();
StoreMove.NextMoveStep(StoreMoveStep.SI_05_DeviceToDoor);
ACAxisMove(Config.InOut_Axis, moveP.InOut_P2, Config.InOutAxis_P2_Speed);
} }
} }
else if (StoreMove.MoveStep == StoreMoveStep.SI_04_CompressWare) else if (StoreMove.MoveStep == StoreMoveStep.SI_04_CompressWare)
{ {
InStoreLog("入库:SI_05 叉子进入入料口,进出轴至P2(进料口取料点) "); //InStoreLog("入库:SI_05 叉子进入入料口,进出轴至P2(进料口取料点) ");
StoreMove.NextMoveStep(StoreMoveStep.SI_05_DeviceToDoor); //StoreMove.NextMoveStep(StoreMoveStep.SI_05_DeviceToDoor);
ACAxisMove(Config.InOut_Axis, moveP.InOut_P2, Config.InOutAxis_P2_Speed); //ACAxisMove(Config.InOut_Axis, moveP.InOut_P2, Config.InOutAxis_P2_Speed);
SI_05_DeviceToDoor();
} }
else if (StoreMove.MoveStep == StoreMoveStep.SI_05_DeviceToDoor) else if (StoreMove.MoveStep == StoreMoveStep.SI_05_DeviceToDoor)
{ {
NeedCheckSafetyLight = 0;
InStoreLog("入库:SI_06 拿物品,压紧轴至P2(压紧点)) 升降轴至P7(进料口取料缓冲点) "); InStoreLog("入库:SI_06 拿物品,压紧轴至P2(压紧点)) 升降轴至P7(进料口取料缓冲点) ");
StoreMove.NextMoveStep(StoreMoveStep.SI_06_DoorWarToDevice); StoreMove.NextMoveStep(StoreMoveStep.SI_06_DoorWarToDevice);
ComMoveToPosition(moveP.ComPress_P2); ComMoveToPosition(moveP.ComPress_P2);
...@@ -661,7 +668,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -661,7 +668,7 @@ namespace OnlineStore.DeviceLibrary
{ {
OutStoreLog("出库:SO_11 放下物品,升降轴至P8(进料口出料缓冲点) "); OutStoreLog("出库:SO_11 放下物品,升降轴至P8(进料口出料缓冲点) ");
StoreMove.NextMoveStep(StoreMoveStep.SO_11_DevicePutWare); StoreMove.NextMoveStep(StoreMoveStep.SO_11_DevicePutWare);
NeedCheckSafetyLight = 0;
ComMoveToPosition(moveP.ComPress_P1); ComMoveToPosition(moveP.ComPress_P1);
//if (IsHasCompress_Axis) //if (IsHasCompress_Axis)
//{ //{
......
...@@ -44,6 +44,8 @@ namespace OnlineStore.DeviceLibrary ...@@ -44,6 +44,8 @@ namespace OnlineStore.DeviceLibrary
/// 是否没有检测到气压 /// 是否没有检测到气压
/// </summary> /// </summary>
public bool isNoAirCheck = false; public bool isNoAirCheck = false;
protected int NeedCheckSafetyLight = 0;
/// <summary> /// <summary>
/// 是否再报警中 /// 是否再报警中
/// </summary> /// </summary>
...@@ -92,34 +94,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -92,34 +94,7 @@ namespace OnlineStore.DeviceLibrary
{ {
return new TimeSpan(0); return new TimeSpan(0);
} }
} }
///// <summary>
///// 获取轴已运行时间
///// </summary>
///// <returns></returns>
//public TimeSpan GetAxisRunTime(int axisNo)
//{
// TimeSpan span = new TimeSpan(0);
// try
// {
// if (AxisRunTimeMap.ContainsKey(axisNo))
// {
// Dictionary<DateTime, DateTime> moveMap = AxisRunTimeMap[axisNo];
// if (moveMap != null && moveMap.Count > 0)
// {
// foreach (DateTime key in moveMap.Keys)
// {
// span += moveMap[key] - key;
// }
// }
// }
// }
// catch (Exception ex)
// {
// LogUtil.error(LOGGER, ex.ToString());
// }
// return span;
//}
protected void AddAxisMoveTime(ConfigMoveAxis axis) protected void AddAxisMoveTime(ConfigMoveAxis axis)
{ {
...@@ -276,18 +251,36 @@ namespace OnlineStore.DeviceLibrary ...@@ -276,18 +251,36 @@ namespace OnlineStore.DeviceLibrary
string deviceName = moveAxis.DeviceName; string deviceName = moveAxis.DeviceName;
short axisNo = moveAxis.GetAxisValue(); short axisNo = moveAxis.GetAxisValue();
bool isOk = ACServerManager.GetBusyStatus(deviceName, axisNo).Equals(0); //如果是进出轴,并且光栅被遮挡,直接返回false
if (NeedCheckSafetyLight.Equals(2))
{
if (StoreMove.MoveStep.Equals(StoreMoveStep.SO_10_DeviceToDoor) ||
StoreMove.MoveStep.Equals(StoreMoveStep.SI_05_DeviceToDoor))
{
return false;
}
}
bool isOk = ACServerManager.GetBusyStatus(deviceName, axisNo).Equals(0);
int outCount = ACServerManager.GetActualtPosition(deviceName, axisNo); int outCount = ACServerManager.GetActualtPosition(deviceName, axisNo);
int errorCount = Math.Abs(outCount - targetPosition); int errorCount = Math.Abs(outCount - targetPosition);
if (isOk) if (isOk)
{ {
if (errorCount > moveAxis.CanErrorCountMax) if (errorCount > moveAxis.CanErrorCountMax)
{ {
if (NeedCheckSafetyLight.Equals(2))
{
if (StoreMove.MoveStep.Equals(StoreMoveStep.SO_10_DeviceToDoor) ||
StoreMove.MoveStep.Equals(StoreMoveStep.SI_05_DeviceToDoor))
{
return false;
}
}
//判断是否需要重新运动 //判断是否需要重新运动
if (StoreMove.CanWhileCount > 0) if (StoreMove.CanWhileCount > 0)
{ {
LogUtil.error(LOGGER, moveAxis.DisplayStr+ "目标位置[" + targetPosition + "]当前位置[" + outCount + LogUtil.error(LOGGER, moveAxis.DisplayStr + "目标位置[" + targetPosition + "]当前位置[" + outCount +
"],误差过大,重新开始运动,剩余[" + StoreMove.CanWhileCount + "]次"); "],误差过大,重新开始运动,剩余[" + StoreMove.CanWhileCount + "]次");
//LogUtil.error(LOGGER, StoreName + " storeMoveStep=" + StoreMove.MoveStep + moveAxis.DisplayStr + "目标位置[" + targetPosition + "]重新开始运动"); //LogUtil.error(LOGGER, StoreName + " storeMoveStep=" + StoreMove.MoveStep + moveAxis.DisplayStr + "目标位置[" + targetPosition + "]重新开始运动");
ACServerManager.AbsMove(moveAxis.DeviceName, moveAxis.GetAxisValue(), targetPosition, targetSpeed); ACServerManager.AbsMove(moveAxis.DeviceName, moveAxis.GetAxisValue(), targetPosition, targetSpeed);
...@@ -304,7 +297,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -304,7 +297,7 @@ namespace OnlineStore.DeviceLibrary
} }
else else
{ {
return true; return true;
} }
} }
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!