Commit cbbfca3a LN

IO模块断开时手动重连

1 个父辈 9211d903
......@@ -32,13 +32,14 @@
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FrmLineStore));
this.tabControl1 = new System.Windows.Forms.TabControl();
this.tabPage1 = new System.Windows.Forms.TabPage();
this.chbSaveImage = new System.Windows.Forms.CheckBox();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.numTrayNum = new System.Windows.Forms.NumericUpDown();
this.btnClear = new System.Windows.Forms.Button();
this.label10 = new System.Windows.Forms.Label();
this.lblSelTrayNum = new System.Windows.Forms.Label();
this.panel1 = new System.Windows.Forms.Panel();
this.chbSaveImage = new System.Windows.Forms.CheckBox();
this.btnIOAutoCon = new System.Windows.Forms.Button();
this.btnShunt2Reset = new System.Windows.Forms.Button();
this.btnShuntReset = new System.Windows.Forms.Button();
this.groupBox2 = new System.Windows.Forms.GroupBox();
......@@ -88,10 +89,10 @@
this.toolStripSeparator6 = new System.Windows.Forms.ToolStripSeparator();
this.二维码学习ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator7 = new System.Windows.Forms.ToolStripSeparator();
this.iO模块状态ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator9 = new System.Windows.Forms.ToolStripSeparator();
this.toolStripMenuItem3 = new System.Windows.Forms.ToolStripMenuItem();
this.托盘初始化ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator9 = new System.Windows.Forms.ToolStripSeparator();
this.iO模块状态ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator14 = new System.Windows.Forms.ToolStripSeparator();
this.查看托盘信息ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator12 = new System.Windows.Forms.ToolStripSeparator();
......@@ -147,6 +148,7 @@
//
// tabPage1
//
this.tabPage1.Controls.Add(this.chbSaveImage);
this.tabPage1.Controls.Add(this.groupBox1);
this.tabPage1.Controls.Add(this.panel1);
this.tabPage1.Controls.Add(this.groupBox2);
......@@ -162,6 +164,19 @@
this.tabPage1.Text = "状态信息";
this.tabPage1.UseVisualStyleBackColor = true;
//
// chbSaveImage
//
this.chbSaveImage.AutoSize = true;
this.chbSaveImage.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.chbSaveImage.Location = new System.Drawing.Point(1201, 150);
this.chbSaveImage.Name = "chbSaveImage";
this.chbSaveImage.Size = new System.Drawing.Size(112, 24);
this.chbSaveImage.TabIndex = 203;
this.chbSaveImage.Text = "保存扫码图片";
this.chbSaveImage.UseVisualStyleBackColor = true;
this.chbSaveImage.Visible = false;
this.chbSaveImage.CheckedChanged += new System.EventHandler(this.chbSaveImage_CheckedChanged);
//
// groupBox1
//
this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
......@@ -170,7 +185,7 @@
this.groupBox1.Controls.Add(this.btnClear);
this.groupBox1.Controls.Add(this.label10);
this.groupBox1.Controls.Add(this.lblSelTrayNum);
this.groupBox1.Location = new System.Drawing.Point(720, 148);
this.groupBox1.Location = new System.Drawing.Point(720, 169);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(602, 81);
this.groupBox1.TabIndex = 284;
......@@ -221,32 +236,33 @@
//
// panel1
//
this.panel1.Controls.Add(this.chbSaveImage);
this.panel1.Controls.Add(this.btnIOAutoCon);
this.panel1.Controls.Add(this.btnShunt2Reset);
this.panel1.Controls.Add(this.btnShuntReset);
this.panel1.Location = new System.Drawing.Point(720, 4);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(165, 140);
this.panel1.Size = new System.Drawing.Size(165, 160);
this.panel1.TabIndex = 199;
//
// chbSaveImage
// btnIOAutoCon
//
this.chbSaveImage.AutoSize = true;
this.chbSaveImage.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.chbSaveImage.Location = new System.Drawing.Point(16, 10);
this.chbSaveImage.Name = "chbSaveImage";
this.chbSaveImage.Size = new System.Drawing.Size(112, 24);
this.chbSaveImage.TabIndex = 203;
this.chbSaveImage.Text = "保存扫码图片";
this.chbSaveImage.UseVisualStyleBackColor = true;
this.chbSaveImage.CheckedChanged += new System.EventHandler(this.chbSaveImage_CheckedChanged);
this.btnIOAutoCon.BackColor = System.Drawing.Color.White;
this.btnIOAutoCon.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnIOAutoCon.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnIOAutoCon.Location = new System.Drawing.Point(16, 105);
this.btnIOAutoCon.Name = "btnIOAutoCon";
this.btnIOAutoCon.Size = new System.Drawing.Size(133, 40);
this.btnIOAutoCon.TabIndex = 202;
this.btnIOAutoCon.Text = "开始重连IO模块";
this.btnIOAutoCon.UseVisualStyleBackColor = false;
this.btnIOAutoCon.Click += new System.EventHandler(this.btnIOAutoCon_Click);
//
// btnShunt2Reset
//
this.btnShunt2Reset.BackColor = System.Drawing.Color.White;
this.btnShunt2Reset.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnShunt2Reset.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnShunt2Reset.Location = new System.Drawing.Point(16, 88);
this.btnShunt2Reset.Location = new System.Drawing.Point(16, 58);
this.btnShunt2Reset.Name = "btnShunt2Reset";
this.btnShunt2Reset.Size = new System.Drawing.Size(133, 40);
this.btnShunt2Reset.TabIndex = 201;
......@@ -259,7 +275,7 @@
this.btnShuntReset.BackColor = System.Drawing.Color.White;
this.btnShuntReset.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnShuntReset.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnShuntReset.Location = new System.Drawing.Point(16, 41);
this.btnShuntReset.Location = new System.Drawing.Point(16, 11);
this.btnShuntReset.Name = "btnShuntReset";
this.btnShuntReset.Size = new System.Drawing.Size(133, 40);
this.btnShuntReset.TabIndex = 199;
......@@ -415,9 +431,9 @@
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.logBox.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.logBox.Location = new System.Drawing.Point(720, 235);
this.logBox.Location = new System.Drawing.Point(720, 253);
this.logBox.Name = "logBox";
this.logBox.Size = new System.Drawing.Size(600, 371);
this.logBox.Size = new System.Drawing.Size(600, 353);
this.logBox.TabIndex = 106;
this.logBox.Text = "";
this.logBox.VisibleChanged += new System.EventHandler(this.logBox_VisibleChanged);
......@@ -716,69 +732,69 @@
// toolStripSeparator6
//
this.toolStripSeparator6.Name = "toolStripSeparator6";
this.toolStripSeparator6.Size = new System.Drawing.Size(177, 6);
this.toolStripSeparator6.Size = new System.Drawing.Size(173, 6);
this.toolStripSeparator6.Visible = false;
//
// 二维码学习ToolStripMenuItem
//
this.二维码学习ToolStripMenuItem.Name = "二维码学习ToolStripMenuItem";
this.二维码学习ToolStripMenuItem.Size = new System.Drawing.Size(180, 26);
this.二维码学习ToolStripMenuItem.Size = new System.Drawing.Size(176, 26);
this.二维码学习ToolStripMenuItem.Text = "二维码学习";
this.二维码学习ToolStripMenuItem.Click += new System.EventHandler(this.二维码学习ToolStripMenuItem_Click);
//
// toolStripSeparator7
//
this.toolStripSeparator7.Name = "toolStripSeparator7";
this.toolStripSeparator7.Size = new System.Drawing.Size(177, 6);
this.toolStripSeparator7.Size = new System.Drawing.Size(173, 6);
//
// iO模块状态ToolStripMenuItem
//
this.iO模块状态ToolStripMenuItem.Name = "iO模块状态ToolStripMenuItem";
this.iO模块状态ToolStripMenuItem.Size = new System.Drawing.Size(176, 26);
this.iO模块状态ToolStripMenuItem.Text = "IO模块状态";
this.iO模块状态ToolStripMenuItem.Click += new System.EventHandler(this.iO模块状态ToolStripMenuItem_Click);
//
// toolStripSeparator9
//
this.toolStripSeparator9.Name = "toolStripSeparator9";
this.toolStripSeparator9.Size = new System.Drawing.Size(173, 6);
//
// toolStripMenuItem3
//
this.toolStripMenuItem3.Name = "toolStripMenuItem3";
this.toolStripMenuItem3.Size = new System.Drawing.Size(180, 26);
this.toolStripMenuItem3.Size = new System.Drawing.Size(176, 26);
this.toolStripMenuItem3.Text = "查看禁用托盘";
this.toolStripMenuItem3.Click += new System.EventHandler(this.toolStripMenuItem3_Click);
//
// 托盘初始化ToolStripMenuItem
//
this.托盘初始化ToolStripMenuItem.Name = "托盘初始化ToolStripMenuItem";
this.托盘初始化ToolStripMenuItem.Size = new System.Drawing.Size(180, 26);
this.托盘初始化ToolStripMenuItem.Size = new System.Drawing.Size(176, 26);
this.托盘初始化ToolStripMenuItem.Text = "托盘编码";
this.托盘初始化ToolStripMenuItem.Visible = false;
this.托盘初始化ToolStripMenuItem.Click += new System.EventHandler(this.托盘初始化ToolStripMenuItem_Click);
//
// toolStripSeparator9
//
this.toolStripSeparator9.Name = "toolStripSeparator9";
this.toolStripSeparator9.Size = new System.Drawing.Size(177, 6);
//
// iO模块状态ToolStripMenuItem
//
this.iO模块状态ToolStripMenuItem.Name = "iO模块状态ToolStripMenuItem";
this.iO模块状态ToolStripMenuItem.Size = new System.Drawing.Size(180, 26);
this.iO模块状态ToolStripMenuItem.Text = "IO模块状态";
this.iO模块状态ToolStripMenuItem.Click += new System.EventHandler(this.iO模块状态ToolStripMenuItem_Click);
//
// toolStripSeparator14
//
this.toolStripSeparator14.Name = "toolStripSeparator14";
this.toolStripSeparator14.Size = new System.Drawing.Size(177, 6);
this.toolStripSeparator14.Size = new System.Drawing.Size(173, 6);
//
// 查看托盘信息ToolStripMenuItem
//
this.查看托盘信息ToolStripMenuItem.Name = "查看托盘信息ToolStripMenuItem";
this.查看托盘信息ToolStripMenuItem.Size = new System.Drawing.Size(180, 26);
this.查看托盘信息ToolStripMenuItem.Size = new System.Drawing.Size(176, 26);
this.查看托盘信息ToolStripMenuItem.Text = "查看托盘信息";
this.查看托盘信息ToolStripMenuItem.Click += new System.EventHandler(this.btnTrayInfo_Click);
//
// toolStripSeparator12
//
this.toolStripSeparator12.Name = "toolStripSeparator12";
this.toolStripSeparator12.Size = new System.Drawing.Size(177, 6);
this.toolStripSeparator12.Size = new System.Drawing.Size(173, 6);
//
// 清空托盘信息ToolStripMenuItem
//
this.清空托盘信息ToolStripMenuItem.Name = "清空托盘信息ToolStripMenuItem";
this.清空托盘信息ToolStripMenuItem.Size = new System.Drawing.Size(180, 26);
this.清空托盘信息ToolStripMenuItem.Size = new System.Drawing.Size(176, 26);
this.清空托盘信息ToolStripMenuItem.Text = "清空托盘信息";
this.清空托盘信息ToolStripMenuItem.Click += new System.EventHandler(this.清空托盘信息ToolStripMenuItem_Click);
//
......@@ -952,7 +968,6 @@
this.groupBox1.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.numTrayNum)).EndInit();
this.panel1.ResumeLayout(false);
this.panel1.PerformLayout();
this.groupBox2.ResumeLayout(false);
this.groupBox2.PerformLayout();
this.groupBox3.ResumeLayout(false);
......@@ -1054,6 +1069,7 @@
private System.Windows.Forms.ToolStripMenuItem 启用分流横移2ToolStripMenuItem;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator19;
private System.Windows.Forms.ToolStripMenuItem 自动保存托盘信息ToolStripMenuItem;
private System.Windows.Forms.Button btnIOAutoCon;
}
}
......@@ -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)
{
......
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
{
if (AIOAutoConSetting.NeedAutoConnect())
{
Thread.Sleep(100);
if (_loop) Open();
}
}
}
}
......
......@@ -33,7 +33,6 @@ namespace OnlineStore.DeviceLibrary
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!