Commit 4dfa6eca LN

1

1 个父辈 7f566ced
位置,优先级,高度,宽度,料仓ID,旋转轴位置P101,升降轴低点P101,升降轴高点P102,进出轴位置P101
1#S_1_4,1,8,7,1,211783,51884,55245,81000
1#S_1_5,2,8,7,1,211783,67807,71168,81000
1#S_1_6,3,8,7,1,211783,83730,87091,81000
1#S_1_7,4,8,7,1,211783,99653,103014,81000
1#S_1_8,5,8,7,1,211783,115576,118937,81000
1#S_1_9,6,8,7,1,211783,131499,134860,81000
1#S_1_10,7,8,7,1,211783,147422,150783,81000
1#S_1_11,8,8,7,1,211783,163345,166706,81000
1#S_1_12,9,8,7,1,211783,179268,182629,81000
1#S_1_13,10,8,7,1,211783,195191,198552,81000
1#S_1_14,11,8,7,1,211783,211114,214475,81000
1#S_1_15,12,8,7,1,211783,227037,230398,81000
1#S_1_16,13,8,7,1,211783,242960,246321,81000
1#S_1_17,14,8,7,1,211783,258883,262244,81000
1#S_1_18,15,8,7,1,211783,274806,278167,81000
1#S_1_19,16,8,7,1,211783,289000,294090,81000
1#S_1_20,17,8,7,1,211783,304652,310013,81000
1#S_1_21,18,8,7,1,211783,320575,325936,81000
1#S_1_22,19,8,7,1,211783,336498,341859,81000
1#S_2_3,20,8,7,1,211783,385700,389433,81000
1#S_2_4,21,8,7,1,211783,403000,405356,81000
1#S_2_5,22,8,7,1,211783,418345,421279,81000
1#S_2_6,23,8,7,1,211783,434000,437202,81000
1#S_2_7,24,8,7,1,211783,450000,453125,81000
1#S_2_8,25,8,7,1,211783,465900,469048,81000
1#S_2_9,26,8,7,1,211783,481800,484971,81000
1#S_2_10,27,8,7,1,211783,497660,500894,81000
1#S_2_11,28,8,7,1,211783,513600,516817,81000
1#S_2_12,29,8,7,1,211783,529200,532740,81000
1#S_2_13,30,8,7,1,211783,545100,548663,81000
1#S_2_14,31,8,7,1,211783,560500,564586,81000
1#S_2_15,32,8,7,1,211783,575500,580509,81000
1#S_2_16,33,8,7,1,211783,591500,596432,81000
1#S_2_17,34,8,7,1,211783,606000,612355,81000
1#S_2_18,35,8,7,1,211783,621000,628278,81000
,,,,,,,,
2#S_1_4,1,8,7,2,211783,51884,55245,81000
2#S_1_5,2,8,7,2,211783,67807,71168,81000
2#S_1_6,3,8,7,2,211783,83730,87091,81000
2#S_1_7,4,8,7,2,211783,99653,103014,81000
2#S_1_8,5,8,7,2,211783,115576,118937,81000
2#S_1_9,6,8,7,2,211783,131499,134860,81000
2#S_1_10,7,8,7,2,211783,147422,150783,81000
2#S_1_11,8,8,7,2,211783,163345,166706,81000
2#S_1_12,9,8,7,2,211783,179268,182629,81000
2#S_1_13,10,8,7,2,211783,195191,198552,81000
2#S_1_14,11,8,7,2,211783,211114,214475,81000
2#S_1_15,12,8,7,2,211783,227037,230398,81000
2#S_1_16,13,8,7,2,211783,242960,246321,81000
2#S_1_17,14,8,7,2,211783,258883,262244,81000
2#S_1_18,15,8,7,2,211783,274806,278167,81000
2#S_1_19,16,8,7,2,211783,289000,294090,81000
2#S_1_20,17,8,7,2,211783,304652,310013,81000
2#S_1_21,18,8,7,2,211783,320575,325936,81000
2#S_1_22,19,8,7,2,211783,336498,341859,81000
2#S_2_3,20,8,7,2,211783,385700,389433,81000
2#S_2_4,21,8,7,2,211783,403000,405356,81000
2#S_2_5,22,8,7,2,211783,418345,421279,81000
2#S_2_6,23,8,7,2,211783,434000,437202,81000
2#S_2_7,24,8,7,2,211783,450000,453125,81000
2#S_2_8,25,8,7,2,211783,465900,469048,81000
2#S_2_9,26,8,7,2,211783,481800,484971,81000
2#S_2_10,27,8,7,2,211783,497660,500894,81000
2#S_2_11,28,8,7,2,211783,513600,516817,81000
2#S_2_12,29,8,7,2,211783,529200,532740,81000
2#S_2_13,30,8,7,2,211783,545100,548663,81000
2#S_2_14,31,8,7,2,211783,560500,564586,81000
2#S_2_15,32,8,7,2,211783,575500,580509,81000
2#S_2_16,33,8,7,2,211783,591500,596432,81000
2#S_2_17,34,8,7,2,211783,606000,612355,81000
2#S_2_18,35,8,7,2,211783,621000,628278,81000
1#S_1_1,1,8,7,1,211783,51884,55245,81000
1#S_1_2,2,8,7,1,211783,67807,71168,81000
1#S_1_3,3,8,7,1,211783,83730,87091,81000
1#S_1_4,4,8,7,1,211783,99653,103014,81000
1#S_1_5,5,8,7,1,211783,115576,118937,81000
1#S_1_6,6,8,7,1,211783,131499,134860,81000
1#S_1_7,7,8,7,1,211783,147422,150783,81000
1#S_1_8,8,8,7,1,211783,163345,166706,81000
1#S_1_9,9,8,7,1,211783,179268,182629,81000
......@@ -33,15 +33,17 @@ namespace OnlineStore.DeviceLibrary
public override void ConnectionIOList(List<string> DIONameList)
{
if (conTimer == null)
{
conTimer = new System.Timers.Timer();
conTimer.AutoReset = true;
conTimer.Interval = 60000;
conTimer.Interval = 10000;
conTimer.Elapsed += ConTimer_Elapsed;
}
conTimer.Enabled = false;
IoIPLIst = new List<string>(DIONameList);
conCount = 3;
foreach (string ip in DIONameList)
{
ConnectionIP(ip);
......@@ -52,39 +54,76 @@ namespace OnlineStore.DeviceLibrary
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.ToString());
}
try
{
List<string> list = new List<string>(IoIPLIst);
if (list.Count > 0)
{
LogUtil.info("开始重连IO模块 ------------");
conCount = 1;
foreach (string ip in list)
{
LogUtil.info("重连AOI :" + ip);
ConnectionIP(ip);
}
LogUtil.info("结束重连IO模块 ------------");
}
GC.Collect();
}
catch (Exception ex)
{
LogUtil.error("AOI ConTimer_Elapsed 出错: " + ex.ToString());
}
isProcess = false;
}
private int conCount = 3;
public void ConnectionIP(string ioIp)
{
AIOBOX aioBox = null;
if (AIOMap.ContainsKey(ioIp))
{
aioBox = AIOMap[ioIp];
try
{
if (null != aioBox)
{
aioBox.Close();
aioBox = null;
}
}
catch (Exception ex)
{
LogUtil.error("关闭Io模块【" + ioIp + "】出错:" + ex);
}
AIOMap.Remove(ioIp);
}
if (DIValueMap.ContainsKey(ioIp))
......@@ -112,6 +151,7 @@ namespace OnlineStore.DeviceLibrary
{
// Create new modbus master and add event functions
aioBox = new AIOBOX();
// aioBox.LogPath( Application.StartupPath+@"\logs\aio\");
aioBox.IP = ioIp;
// bool rtn = aioBox.AutoIP(ioIp);
......@@ -119,36 +159,39 @@ namespace OnlineStore.DeviceLibrary
aioBox.SetInput(Asa.IOModule.Box_Type.DI, DILength);
aioBox.SetOutput(Asa.IOModule.Box_Type.DO, DOLength);
//DI主动上传
aioBox.AutoReadInput(true);
aioBox.AutoReadOutput(true, DOMS);
aioBox.AutoReadInput(true, DIMS);
aioBox.AutoReadOutput(false, DOMS);
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;
AIOMap.Add(ioIp, aioBox);
LogUtil.debug("开始连接" + logName + ",尝试重连5次");
for (int i = 1; i <= 3; i++)
LogUtil.debug("开始连接" + logName + ",尝试重连3次");
for (int i = 1; i <= conCount; i++)
{
bool result = aioBox.Connect();
if (result)
{
LogUtil.info("第【" + i + "】次连接 " + logName + " 成功:" + aioBox.ErrInfo);
Thread.Sleep(10);
//读取所有的DO
ReadAllDI(ioIp, 0);
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(2);
Thread.Sleep(5);
GC.Collect();
}
}
......@@ -177,7 +220,7 @@ namespace OnlineStore.DeviceLibrary
{
foreach (string str in s)
{
// LogUtil.AIOLog.Debug("[" + box.IP + "]" + str);
LogUtil.AIOLog.Debug("[" + box.IP + "]" + str);
}
}
......@@ -294,17 +337,6 @@ namespace OnlineStore.DeviceLibrary
}
}
}
//else
//{
// if (sta == null)
// {
// LogUtil.error("UpdateAllDO ip[" + ip + "], sta=null");
// }
// else
// {
// LogUtil.error(" UpdateAllDO ip[" + ip + "], sta.Length=" + sta.Length);
// }
//}
}
......@@ -317,9 +349,6 @@ namespace OnlineStore.DeviceLibrary
ushort length = StoreManager.Config.GetDOLength(aio.IP);
for (ushort i = 0; i < length; i++)
{
// ushort u = (ushort)(i + length);
// ushort u = (ushort)(i );
// Box_Addr addr = GetAddr(u);
aio.WriteDO(i, Box_Sta.Off);
}
}
......@@ -329,8 +358,15 @@ namespace OnlineStore.DeviceLibrary
{
foreach (AIOBOX aio in AIOMap.Values)
{
try
{
aio.Close();
}
catch (Exception ex)
{
LogUtil.error("aio.Close出错:" + ex.ToString());
}
}
AIOMap.Clear();
}
public override void WriteSingleDO(string ioIp, byte slaveId, ushort StartAddress, IO_VALUE onOff)
......@@ -343,18 +379,18 @@ namespace OnlineStore.DeviceLibrary
{
// Box_Addr add = GetAddr(StartAddress);
for (int i = 1; i <= 3; i++)
{
// for (int i = 1; i <= 3; i++)
//{
bool result = aioBox.WriteDO(StartAddress, GetBox_Sta(onOff));
if (!result)
{
LogUtil.error("AIO WriteSingleDO [" + StartAddress + "] 第" + i + "次失败:" + aioBox.ErrInfo);
}
else
{
break;
}
LogUtil.error("AIO WriteSingleDO [" + ioIp + "] [" + StartAddress + "] 失败:" + aioBox.ErrInfo);
}
// else
// {
// break;
// }
//}
}
else
{
......@@ -363,19 +399,17 @@ namespace OnlineStore.DeviceLibrary
}
catch (Exception ex)
{
LOGGER.Error("出错啦:" + ex.ToString());
LOGGER.Error("AIO WriteSingleDO [" + ioIp + "] [" + StartAddress + "] 出错啦:" + ex.ToString());
}
}
public override void WriteSingleDO(string ioIp, byte slaveId, ushort StartAddress, IO_VALUE onOff, int mSeconds)
{
try
{
AIOBOX aioBox = getAIO(ioIp);
Box_Sta currBox_Sta = GetBox_Sta(onOff);
if (aioBox != null)
{
// Box_Addr add = GetAddr(StartAddress);
Box_Sta currBox_Sta = GetBox_Sta(onOff);
aioBox.WriteDO(StartAddress, currBox_Sta);
//写入之后,等待指定间隔后回写
......@@ -385,7 +419,7 @@ namespace OnlineStore.DeviceLibrary
try
{
aioBox.WriteDO(StartAddress, aioBox.ReverseStatus(currBox_Sta));
LogUtil.debug(LOGGER, "**********定时回写入 IO【" + ioIp + "," + StartAddress + ",值" + aioBox.ReverseStatus(currBox_Sta) + "】:");
LogUtil.debug(LOGGER, "**********定时回写入 IO [" + ioIp + "] [" + StartAddress + "]值" + aioBox.ReverseStatus(currBox_Sta) + "】:");
}
catch (Exception ex)
{
......@@ -394,15 +428,16 @@ namespace OnlineStore.DeviceLibrary
};
mytimer.AutoReset = false;//设置是否自动重启,即自动执行多次;
mytimer.Enabled = true;//是否执行System.Timers.Timer.Elapsed事件mytask;
}
else
{
LogUtil.error(LOGGER, "WriteSingleDO出错 没有连接IO模块:" + ioIp);
LogUtil.error(LOGGER, "AIO WriteSingleDO [" + ioIp + "] [" + StartAddress + "] 出错 没有连接IO模块:" + ioIp);
}
}
catch (Exception ex)
{
LogUtil.error("WriteSingleDO 出错:" + ioIp);
LogUtil.error("AIO WriteSingleDO [" + ioIp + "] [" + StartAddress + "] 出错:" + ioIp);
}
}
public override void ReadAllDI(string ioIp, byte slaveId)
......@@ -418,7 +453,7 @@ namespace OnlineStore.DeviceLibrary
}
catch (Exception ex)
{
LogUtil.error("ReadAllDI出错:" + ioIp);
LogUtil.error("ReadAllDI [" + ioIp + "]出错:" + ioIp);
}
}
public override void ReadAllDO(string ioIp, byte slaveId)
......@@ -435,7 +470,7 @@ namespace OnlineStore.DeviceLibrary
}
catch (Exception ex)
{
LogUtil.error("ReadAllDO出错:" + ioIp);
LogUtil.error("ReadAllDO [" + ioIp + "]出错:" + ioIp);
}
}
public override IO_VALUE GetDOValue(string ioIP, byte slaveId, ushort StartAddress)
......@@ -447,9 +482,6 @@ namespace OnlineStore.DeviceLibrary
if (aioBox != null)
{
Box_Sta sta = Box_Sta.Off;
// Box_Addr addr = GetAddr(StartAddress);
// int index = (int)StartAddress - (int)StoreManager.Config.GetDILength(ioIP);
if (DOValueMap.ContainsKey(ioIP) && DOValueMap[ioIP].Count > StartAddress)
{
sta = DOValueMap[ioIP][StartAddress];
......@@ -464,7 +496,7 @@ namespace OnlineStore.DeviceLibrary
}
catch (Exception ex)
{
LogUtil.error("GetDOValue 出错:" + ex.ToString());
LogUtil.error("GetDOValue [" + ioIP + "] [" + StartAddress + "] 出错:" + ex.ToString());
}
return value;
}
......@@ -496,7 +528,7 @@ namespace OnlineStore.DeviceLibrary
}
catch (Exception ex)
{
LogUtil.error("GetDIValue 出错:" + ex.ToString());
LogUtil.error("GetDIValue [" + ioIP + "] [" + StartAddress + "] 出错:" + ex.ToString());
}
return value;
}
......@@ -507,24 +539,20 @@ namespace OnlineStore.DeviceLibrary
{
if (configIO.ProType.Equals(ConfigItemType.DI))
{
return GetDIValue(configIO.DeviceName, configIO.SlaveID, configIO.GetIOAddr());
return GetDIValue(configIO.IO_IP, configIO.SlaveID, configIO.GetIOAddr());
}
else if (configIO.ProType.Equals(ConfigItemType.DO))
{
return GetDOValue(configIO.DeviceName, configIO.SlaveID, configIO.GetIOAddr());
return GetDOValue(configIO.IO_IP, configIO.SlaveID, configIO.GetIOAddr());
}
}
catch (Exception ex)
{
LogUtil.error(LOGGER, " GetIOValue 获取数据出错:" + ex.ToString());
LogUtil.error(LOGGER, " GetIOValue [" + configIO.IO_IP + "] [" + configIO.GetIOAddr() + "] 获取数据出错:" + ex.ToString());
}
return value;
}
//private Box_Addr GetAddr(ushort StartAddress)
//{
// return (Box_Addr)(StartAddress);
//}
private Box_Sta GetBox_Sta(IO_VALUE onOff)
{
if (onOff.Equals(IO_VALUE.HIGH))
......@@ -546,5 +574,18 @@ namespace OnlineStore.DeviceLibrary
}
return aioBox;
}
public override bool IsConnect(string ip)
{
if (AIOMap.ContainsKey(ip))
{
if (AIOMap[ip].IsConn)
{
return true;
}
return false;
}
return false;
}
}
}
......@@ -176,6 +176,6 @@ namespace OnlineStore.DeviceLibrary
public abstract void CloseAllDO();
public abstract void CloseAllConnection();
public abstract bool IsConnect(string ip);
}
}
......@@ -101,7 +101,7 @@ namespace OnlineStore.DeviceLibrary
/// <summary>
/// 判断Io模块是否连接
/// </summary>
public static bool IsConnection(string ip)
public override bool IsConnect(string ip)
{
try
{
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!