Commit cbbfca3a LN

IO模块断开时手动重连

1 个父辈 9211d903
......@@ -558,6 +558,7 @@ namespace OnlineStore.AssemblyLine
{
aGVCancelStateToolStripMenuItem.Text = "AGV cancelState";
}
btnIOAutoCon.Enabled = (AIOAutoConSetting.autoConnect.Equals(false));
lblStatus.Text = lineBean.GetRunStr() + canScanCode;
string time = LineManager.Line.alarmType.Equals(LineAlarmType.None) ? "" : LineManager.Line.LastAlarmTime.ToLongTimeString();
string warnMsg = LineManager.Line.WarnMsg.Equals("") ? "" : time + LineManager.Line.WarnMsg + "\r\n";
......@@ -567,7 +568,10 @@ namespace OnlineStore.AssemblyLine
{
warnMsg += TrayManager.TrayErrorMsg + "\r\n";
}
if (lineBean.IOErrorMsg.Equals("").Equals(false))
{
warnMsg += lineBean.IOErrorMsg + "\r\n";
}
foreach (EquipBase move in lineBean.AllEquipMap.Values)
{
if (move.WarnMsg.Equals("").Equals(false))
......@@ -1340,5 +1344,11 @@ namespace OnlineStore.AssemblyLine
}
LogUtil.info(Name + " 点击:" + 自动保存托盘信息ToolStripMenuItem.Text);
}
private void btnIOAutoCon_Click(object sender, EventArgs e)
{
LogUtil.info("用户点击了:" + btnIOAutoCon.Text);
AIOAutoConSetting.SetAutoConnect(true, 3);
}
}
}
......@@ -87,6 +87,7 @@
<Compile Include="baan\AxisBean.cs" />
<Compile Include="baan\WaitUtil.cs" />
<Compile Include="deviceLibrary\halcon\CodeManager.cs" />
<Compile Include="deviceLibrary\IO\AIOBOX\AIOAutoConSetting.cs" />
<Compile Include="deviceLibrary\IO\AIOBOX\AIOBOX.cs" />
<Compile Include="deviceLibrary\IO\AIOBOX\AIOBOXManager.cs" />
<Compile Include="deviceLibrary\IO\IOManager.cs" />
......
......@@ -47,6 +47,8 @@ namespace OnlineStore.DeviceLibrary
/// </summary>
public Line_Config Config { get; set; }
public string IOErrorMsg = "";
#region 初始化
public List<string> cioList = new List<string>();
// public List<string> rfidList = new List<string>();
......@@ -59,6 +61,8 @@ namespace OnlineStore.DeviceLibrary
{
lineConfig.IOSingle_TimerOut = 5000;
}
AIOAutoConSetting.SetAutoConnect(true, 0);
Init();
InitTimer();
baseConfig = lineConfig;
......@@ -991,6 +995,8 @@ namespace OnlineStore.DeviceLibrary
}
msg = moveEquip.Name + "复位结束";
isOk = false;
AIOAutoConSetting.SetAutoConnect(false);
LogUtil.info("环形线复位结束,设置IO模块自动连接=false");
break;
}
else
......@@ -1093,6 +1099,18 @@ namespace OnlineStore.DeviceLibrary
{
alarmList.Add(new AlarmMsg(Name, "line." + alarmType, WarnMsg));
}
string ioMsg = AIOBOXManager.instance.GetIoErrorMsg();
if (!IOErrorMsg.Equals(ioMsg))
{
LogUtil.info($"IO模块报警变化:[{IOErrorMsg}]->[{ioMsg}]");
IOErrorMsg = ioMsg;
}
if (String.IsNullOrEmpty(IOErrorMsg).Equals(false))
{
alarmList.Add(new AlarmMsg(Name, "line.IO" , IOErrorMsg));
}
int num = TrayDisableManager.GetDisableList().Count;
if (num >= 5)
{
......@@ -1124,7 +1142,7 @@ namespace OnlineStore.DeviceLibrary
conIsPro = false;
}
}
public MoveEquip GetMoveByDId(int deviceId)
......
using OnlineStore.Common;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace OnlineStore.DeviceLibrary
{
public class AIOAutoConSetting
{
public static bool autoConnect = true;
private static DateTime StartAutoConTime = DateTime.Now;
private static int AutoMinutes = -1;
public static void SetAutoConnect(bool autoCon, int minute=0)
{
autoConnect = autoCon;
StartAutoConTime = DateTime.Now;
AutoMinutes = minute;
LogUtil.info($"AIOAutoConSetting:autoCon={autoCon},minute={minute}");
}
public static bool NeedAutoConnect()
{
if (autoConnect)
{
if (AutoMinutes <= 0)
{
return true;
}
DateTime endConTime = StartAutoConTime.AddMinutes(AutoMinutes);
if (DateTime.Now <= endConTime)
{
return true;
}
else
{
autoConnect = false;
LogUtil.info($"AIOAutoConSetting:StartAutoConTime={StartAutoConTime},minute={AutoMinutes},自动重连IO模块结束");
}
}
return false;
}
}
}
using OnlineStore.Common;
using OnlineStore.DeviceLibrary;
using System;
using System.Collections.Generic;
using System.Net;
......@@ -620,8 +621,12 @@ namespace Asa.IOModule
}
else
{
Thread.Sleep(100);
if (_loop) Open();
if (AIOAutoConSetting.NeedAutoConnect())
{
Thread.Sleep(100);
if (_loop) Open();
}
}
}
}
......
......@@ -30,10 +30,9 @@ namespace OnlineStore.DeviceLibrary
//private object DILock = "";
//private object DOLock = "";
public override void ConnectionIOList(List<string> DIONameList)
{
foreach (string ip in DIONameList)
{
ConnectionIP(ip);
......@@ -41,7 +40,23 @@ namespace OnlineStore.DeviceLibrary
}
private bool isProcess = false;
private DateTime lastTime = DateTime.Now;
public override string GetIoErrorMsg()
{
string msg = "";
List<AIOBOX> lists = new List<AIOBOX>(AIOMap.Values);
foreach (AIOBOX aio in lists)
{
if (!aio.IsConn)
{
msg += $"[{aio.IP}]";
}
}
if (!String.IsNullOrEmpty(msg))
{
msg = "IO模块" + msg + "未连接";
}
return msg;
}
public void ConnectionIP(string ioIp)
{
AIOBOX aioBox = null;
......
......@@ -203,5 +203,7 @@ namespace OnlineStore.DeviceLibrary
public abstract bool IsConnect(string ip);
public abstract string GetIoErrorMsg();
}
}
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!