Commit 74efec2b LN

AIO的dll更新,托盘处理修改

1 个父辈 2411414f
......@@ -114,7 +114,6 @@
<summary>
连接
</summary>
<returns></returns>
</member>
<member name="M:Asa.IOModule.AIOBOX.Close">
<summary>
......
......@@ -156,6 +156,12 @@ agv客户端启动时需要设置状态为none
横移机构优化,上一个托盘准备离开时,下一个托盘就可以进入。
20200227
AIO的dll更新,增加重连功能。
托盘横移过程中,提前下降第一个横移顶升。
上料模块,只有料盘到达流水线上方后才拦截托盘。
......
......@@ -716,7 +716,7 @@ namespace OnlineStore.DeviceLibrary
TrayManager.UpdateTrayInfo(currTrayNum, true, ReelType.InStore, param, "扫码失败");
}
//从服务器获取库位号
string result = SServerManager.CodeReceived(Name, currTrayNum, LastCodeList, LastHeight, LastWidth,CurrShelfId);
string result = SServerManager.CodeReceived(Name, currTrayNum, LastCodeList, LastHeight, LastWidth,CurrShelfId,DeviceID);
if (!result.Equals(""))
{
InOutParam param = new InOutParam(currTrayNum, code, "", LastHeight, LastWidth, true);
......@@ -1086,8 +1086,9 @@ namespace OnlineStore.DeviceLibrary
if (trayCanUse && runStatus.Equals(LineRunStatus.Busy) && MoveInfo.MoveType.Equals(LineMoveType.InStore))
{
//入料执行中, 且需要空托盘
if (MoveInfo.MoveStep >= LineMoveStep.FI_11_CylinderUp && MoveInfo.MoveStep <= LineMoveStep.FI_20_WaitTray)
{
if (MoveInfo.MoveStep >= LineMoveStep.FI_20_WaitTray && MoveInfo.MoveStep <= LineMoveStep.FI_20_WaitTray)
//if (MoveInfo.MoveStep >= LineMoveStep.FI_11_CylinderUp && MoveInfo.MoveStep <= LineMoveStep.FI_20_WaitTray)
{
if (NeedSaveParam)
{
CheckParam = param;
......
......@@ -284,9 +284,10 @@ namespace OnlineStore.DeviceLibrary
}
if (sidesWayNum.Equals(2))
{
LineMoveInfo moveInfo = FeedingEquipMap[104].SecondMoveInfo;
if (SW23_MoveInfo.MoveType.Equals(LineMoveType.None))
{
LineMoveInfo moveInfo = FeedingEquipMap[104].SecondMoveInfo;
if (moveInfo.MoveType.Equals(LineMoveType.None))
{
return true;
......@@ -297,6 +298,10 @@ namespace OnlineStore.DeviceLibrary
{
return true;
}
} else if (SW23_MoveInfo.MoveStep .Equals( LineMoveStep.SW12_WaitTrayGo)
&& moveInfo.MoveType.Equals(LineMoveType.None))
{
return true;
}
}
else if (sidesWayNum.Equals(3) && runStatus <= LineRunStatus.Wait)
......@@ -307,9 +312,10 @@ namespace OnlineStore.DeviceLibrary
if (sidesWayNum.Equals(4))
{
LineMoveInfo moveInfo = FeedingEquipMap[101].SecondMoveInfo;
if (SW41_MoveInfo.MoveType.Equals(LineMoveType.None))
{
LineMoveInfo moveInfo = FeedingEquipMap[101].SecondMoveInfo;
if (moveInfo.MoveType.Equals(LineMoveType.None))
{
return true;
......@@ -321,6 +327,11 @@ namespace OnlineStore.DeviceLibrary
return true;
}
}
else if (SW41_MoveInfo.Equals( LineMoveStep.SW12_WaitTrayGo)
&& moveInfo.MoveType.Equals(LineMoveType.None))
{
return true;
}
}
else if (sidesWayNum.Equals(3) && runStatus <= LineRunStatus.Wait)
{
......@@ -591,14 +602,15 @@ namespace OnlineStore.DeviceLibrary
else if (SW41_MoveInfo.MoveStep.Equals(LineMoveStep.SW07_DriveMotorMove))
{
SW41_MoveInfo.NextMoveStep(LineMoveStep.SW08_WaitOutCheck);
SWLog("横移轨道41:等待托盘到达出口 ");
SWLog("横移轨道41:收到SW1_TrayCheck,先顶升4下降,等待托盘到达出口 ");
CylinderMove(null, IO_Type.SW4_TopCylinder_Up, IO_Type.SW4_TopCylinder_Down);
SW41_MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(300));
SW41_MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.SW1_TrayCheck, IO_VALUE.HIGH));
}
else if (SW41_MoveInfo.MoveStep.Equals(LineMoveStep.SW08_WaitOutCheck))
{
SW41_MoveInfo.NextMoveStep(LineMoveStep.SW09_WatOutFixture2);
SWLog("横移轨道41:再次验证托盘是否在出口处 ");
SWLog("横移轨道41:再次验证托盘是否在出口处 ");
SW41_MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(300));
SW41_MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.SW1_TrayCheck, IO_VALUE.HIGH));
......@@ -748,7 +760,8 @@ namespace OnlineStore.DeviceLibrary
else if (SW23_MoveInfo.MoveStep.Equals(LineMoveStep.SW07_DriveMotorMove))
{
SW23_MoveInfo.NextMoveStep(LineMoveStep.SW08_WaitOutCheck);
SWLog("横移轨道23:等待托盘到达出口 ");
SWLog("横移轨道23:收到 SW3_TrayCheck,先顶升2下降,,等待托盘到达出口 ");
CylinderMove(null, IO_Type.SW2_TopCylinder_Up, IO_Type.SW2_TopCylinder_Down);
SW23_MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(300));
SW23_MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.SW3_TrayCheck, IO_VALUE.HIGH));
}
......
......@@ -29,82 +29,82 @@ namespace OnlineStore.DeviceLibrary
private object DILock = "";
private object DOLock = "";
private List<string> IoIPLIst = new List<string>();
private System.Timers.Timer conTimer = null;
// private List<string> IoIPLIst = new List<string>();
// private System.Timers.Timer conTimer = null;
public override void ConnectionIOList(List<string> DIONameList)
{
if (conTimer == null)
{
conTimer = new System.Timers.Timer();
conTimer.AutoReset = true;
conTimer.Interval = 10000;
conTimer.Elapsed += ConTimer_Elapsed;
}
conTimer.Enabled = false;
IoIPLIst = new List<string>(DIONameList);
conCount = 3;
//if (conTimer == null)
//{
// conTimer = new System.Timers.Timer();
// conTimer.AutoReset = true;
// conTimer.Interval = 10000;
// conTimer.Elapsed += ConTimer_Elapsed;
//}
//conTimer.Enabled = false;
// IoIPLIst = new List<string>(DIONameList);
// conCount = 3;
foreach (string ip in DIONameList)
{
ConnectionIP(ip);
}
if (IoIPLIst.Count > 0)
{
//启动定时器,1一分钟重连一次
conTimer.Start();
}
//if (IoIPLIst.Count > 0)
//{
// //启动定时器,1一分钟重连一次
// conTimer.Start();
//}
}
private bool isProcess = false;
private DateTime lastTime = DateTime.Now;
private void ConTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
TimeSpan span = DateTime.Now - lastTime;
if(span.TotalMinutes< IoIPLIst .Count&& isProcess)
{
return;
}
isProcess = true;
lastTime = DateTime.Now;
try
{
//判断是否还在连接
foreach(AIOBOX box in AIOMap.Values)
{
if (!box.IsConn)
{
if (IoIPLIst.Contains(box.IP).Equals(false))
{
LogUtil.info("IO模块【"+box.IP+"】已断开,加入集合等待重连");
IoIPLIst.Add(box.IP);
}
}
}
}catch(Exception ex)
{
LogUtil.error("AOI 判断是否需要重连 出错",ex);
}
try
{
List<string> list = new List<string>(IoIPLIst);
if (list.Count > 0)
{
LogUtil.info("开始重连IO模块 ------------" );
conCount = 1;
foreach (string ip in list)
{
ConnectionIP(ip);
}
LogUtil.info("结束重连IO模块 ------------");
}
GC.Collect();
}catch(Exception ex)
{
LogUtil.error("AOI ConTimer_Elapsed 出错: ",ex);
}
isProcess = false;
}
private int conCount = 3;
//private void ConTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
//{
// TimeSpan span = DateTime.Now - lastTime;
// if(span.TotalMinutes< IoIPLIst .Count&& isProcess)
// {
// return;
// }
// isProcess = true;
// lastTime = DateTime.Now;
// try
// {
// //判断是否还在连接
// foreach(AIOBOX box in AIOMap.Values)
// {
// if (!box.IsConn)
// {
// if (IoIPLIst.Contains(box.IP).Equals(false))
// {
// LogUtil.info("IO模块【"+box.IP+"】已断开,加入集合等待重连");
// IoIPLIst.Add(box.IP);
// }
// }
// }
// }catch(Exception ex)
// {
// LogUtil.error("AOI 判断是否需要重连 出错",ex);
// }
// try
// {
// List<string> list = new List<string>(IoIPLIst);
// if (list.Count > 0)
// {
// LogUtil.info("开始重连IO模块 ------------" );
// conCount = 1;
// foreach (string ip in list)
// {
// ConnectionIP(ip);
// }
// LogUtil.info("结束重连IO模块 ------------");
// }
// GC.Collect();
// }catch(Exception ex)
// {
// LogUtil.error("AOI ConTimer_Elapsed 出错: ",ex);
// }
// isProcess = false;
//}
// private int conCount = 3;
public void ConnectionIP(string ioIp)
{
AIOBOX aioBox = null;
......@@ -121,7 +121,7 @@ namespace OnlineStore.DeviceLibrary
}
catch (Exception ex)
{
LogUtil.error("关闭Io模块【" + ioIp + "】出错:" ,ex);
LogUtil.error("关闭Io模块【" + ioIp + "】出错:", ex);
}
AIOMap.Remove(ioIp);
}
......@@ -150,7 +150,7 @@ namespace OnlineStore.DeviceLibrary
{
// Create new modbus master and add event functions
aioBox = new AIOBOX();
aioBox.LogPath(Application.StartupPath + @"\logs\aio\", LogType.OnlyError);
aioBox.IP = ioIp;
......@@ -165,35 +165,38 @@ namespace OnlineStore.DeviceLibrary
aioBox.DI_Changed_Event += AioBox_DI_Changed_Event; ;
aioBox.DO_Changed_Event += AioBox_DO_Changed_Event;
// aioBox.Log_Out_Event += AioBox_Log_Out_Event;
//aioBox.Log_RxTx_Event += AioBox_Log_RxTx_Event;
LogUtil.debug("开始连接" + logName + ",尝试重连3次");
for (int i = 1; i <= conCount; i++)
{
bool result = aioBox.Connect();
if (result)
{
LogUtil.info("第【" + i + "】次连接 " + logName + " 成功:" + aioBox.ErrInfo);
if (IoIPLIst.Contains(ioIp))
{
IoIPLIst.Remove(ioIp);
}
AIOMap.Add(ioIp, aioBox);
Thread.Sleep(10);
//读取所有的DO
ReadAllDI(ioIp, 0);
break;
}
else
{
LogUtil.error("第【" + i + "】次连接 " + logName + " 失败:" + aioBox.ErrInfo + "");
}
Thread.Sleep(5);
GC.Collect();
}
// LogUtil.debug("开始连接" + logName + ",尝试重连3次");
// for (int i = 1; i <= conCount; i++)
//{
LogUtil.info("开始连接:" + logName + ":" + aioBox.ErrInfo);
aioBox.Connect();
//bool result = aioBox.Connect();
//if (result)
//{
// LogUtil.info("第【" + i + "】次连接 " + logName + " 成功:" + aioBox.ErrInfo);
//if (IoIPLIst.Contains(ioIp))
//{
// IoIPLIst.Remove(ioIp);
//}
AIOMap.Add(ioIp, aioBox);
Thread.Sleep(5);
//读取所有的DO
ReadAllDI(ioIp, 0);
// break;
//}
//else
//{
// LogUtil.error("第【" + i + "】次连接 " + logName + " 失败:" + aioBox.ErrInfo + "");
//}
Thread.Sleep(5);
GC.Collect();
// }
}
catch (Exception error)
{
......@@ -201,17 +204,17 @@ namespace OnlineStore.DeviceLibrary
}
}
private void AioBox_Reconnect_Event(AIOBOX box, int times, ref bool conn, Dictionary<string, string> dict)
{
conn = true;
string msg = "重连AIO块【" + box.IP + "】次数:" + times + "【" + box.ErrInfo + "】,连接信息如下\r\n";
foreach (string key in dict.Keys)
{
msg = msg + "\t" + "[" + key + "]=[" + dict[key] + "],";
}
LogUtil.error(msg);
//private void AioBox_Reconnect_Event(AIOBOX box, int times, ref bool conn, Dictionary<string, string> dict)
//{
// conn = true;
// string msg = "重连AIO块【" + box.IP + "】次数:" + times + "【" + box.ErrInfo + "】,连接信息如下\r\n";
// foreach (string key in dict.Keys)
// {
// msg = msg + "\t" + "[" + key + "]=[" + dict[key] + "],";
// }
// LogUtil.error(msg);
}
//}
private DateTime lastLogTime = DateTime.Now;
......@@ -232,7 +235,7 @@ namespace OnlineStore.DeviceLibrary
}
catch (Exception ex)
{
LogUtil.error("AioBox_DI_Changed_Event出错:",ex);
LogUtil.error("AioBox_DI_Changed_Event出错:", ex);
}
}
private void AioBox_DO_Changed_Event(AIOBOX box, Box_Sta[] sta)
......@@ -244,7 +247,7 @@ namespace OnlineStore.DeviceLibrary
}
catch (Exception ex)
{
LogUtil.error("AioBox_DO_Changed_Event出错:",ex);
LogUtil.error("AioBox_DO_Changed_Event出错:", ex);
}
}
......@@ -336,7 +339,7 @@ namespace OnlineStore.DeviceLibrary
DOValueMap.Add(ip, newList);
}
}
}
}
}
......@@ -348,7 +351,7 @@ namespace OnlineStore.DeviceLibrary
{
ushort length = LineManager.Config.GetDOLength(aio.IP);
for (ushort i = 0; i < length; i++)
{
{
aio.WriteDO(i, Box_Sta.Off);
}
}
......@@ -364,7 +367,7 @@ namespace OnlineStore.DeviceLibrary
}
catch (Exception ex)
{
LogUtil.error("aio.Close出错:",ex);
LogUtil.error("aio.Close出错:", ex);
}
}
AIOMap.Clear();
......@@ -390,36 +393,36 @@ namespace OnlineStore.DeviceLibrary
}
catch (Exception ex)
{
LOGGER.Error("AIO WriteSingleDO [" + ioIp + "] [" + StartAddress + "] 出错啦:",ex);
LOGGER.Error("AIO WriteSingleDO [" + ioIp + "] [" + StartAddress + "] 出错啦:", ex);
}
}
public override void WriteSingleDO(string ioIp, byte slaveId, ushort StartAddress, IO_VALUE onOff, int mSeconds )
public override void WriteSingleDO(string ioIp, byte slaveId, ushort StartAddress, IO_VALUE onOff, int mSeconds)
{
try
{
{
AIOBOX aioBox = getAIO(ioIp);
if (aioBox != null)
{
Box_Sta currBox_Sta = GetBox_Sta(onOff);
aioBox.WriteDO(StartAddress, currBox_Sta);
//写入之后,等待指定间隔后回写
System.Timers.Timer mytimer = new System.Timers.Timer(mSeconds);
mytimer.Elapsed += (o1, e1) =>
//写入之后,等待指定间隔后回写
System.Timers.Timer mytimer = new System.Timers.Timer(mSeconds);
mytimer.Elapsed += (o1, e1) =>
{
try
{
aioBox.WriteDO(StartAddress, aioBox.ReverseStatus(currBox_Sta));
LogUtil.debug(LOGGER, "**********定时回写入 IO [" + ioIp + "] [" + StartAddress + "]值" + aioBox.ReverseStatus(currBox_Sta) + "】:");
}
catch (Exception ex)
{
try
{
aioBox.WriteDO(StartAddress, aioBox.ReverseStatus(currBox_Sta));
LogUtil.debug(LOGGER, "**********定时回写入 IO [" + ioIp + "] [" + StartAddress + "]值" + aioBox.ReverseStatus(currBox_Sta) + "】:");
}
catch (Exception ex)
{
LogUtil.error(LOGGER, "**********定时回写入 出错:" ,ex);
}
};
mytimer.AutoReset = false;//设置是否自动重启,即自动执行多次;
mytimer.Enabled = true;//是否执行System.Timers.Timer.Elapsed事件mytask;
LogUtil.error(LOGGER, "**********定时回写入 出错:", ex);
}
};
mytimer.AutoReset = false;//设置是否自动重启,即自动执行多次;
mytimer.Enabled = true;//是否执行System.Timers.Timer.Elapsed事件mytask;
}
else
{
......@@ -472,7 +475,7 @@ namespace OnlineStore.DeviceLibrary
AIOBOX aioBox = getAIO(ioIP);
if (aioBox != null)
{
Box_Sta sta = Box_Sta.Off;
Box_Sta sta = Box_Sta.Off;
if (DOValueMap.ContainsKey(ioIP) && DOValueMap[ioIP].Count > StartAddress)
{
sta = DOValueMap[ioIP][StartAddress];
......@@ -487,7 +490,7 @@ namespace OnlineStore.DeviceLibrary
}
catch (Exception ex)
{
LogUtil.error("GetDOValue [" + ioIP + "] [" + StartAddress + "] 出错:",ex);
LogUtil.error("GetDOValue [" + ioIP + "] [" + StartAddress + "] 出错:", ex);
}
return value;
}
......@@ -519,7 +522,7 @@ namespace OnlineStore.DeviceLibrary
}
catch (Exception ex)
{
LogUtil.error("GetDIValue [" + ioIP + "] [" + StartAddress + "] 出错:",ex);
LogUtil.error("GetDIValue [" + ioIP + "] [" + StartAddress + "] 出错:", ex);
}
return value;
}
......@@ -539,11 +542,11 @@ namespace OnlineStore.DeviceLibrary
}
catch (Exception ex)
{
LogUtil.error(LOGGER, " GetIOValue [" + configIO.IO_IP + "] [" + configIO.GetIOAddr() + "] 获取数据出错:",ex);
LogUtil.error(LOGGER, " GetIOValue [" + configIO.IO_IP + "] [" + configIO.GetIOAddr() + "] 获取数据出错:", ex);
}
return value;
}
private Box_Sta GetBox_Sta(IO_VALUE onOff)
{
if (onOff.Equals(IO_VALUE.HIGH))
......
......@@ -161,7 +161,7 @@ namespace OnlineStore.DeviceLibrary
{
IdList.Add(i);
}
for (int i = 1; i <= 11; i++)
for (int i = 1; i <= 10; i++)
{
IdList.Add(i);
}
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!