Commit 9ee96ea1 几米阳光

1

1 个父辈 b1c37f0f
...@@ -33,6 +33,18 @@ ...@@ -33,6 +33,18 @@
自动读取DO事件触发 自动读取DO事件触发
</summary> </summary>
</member> </member>
<member name="T:Asa.IOModule.AIOBOX.Log_Out">
<summary>
日志输出
</summary>
<param name="box"></param>
<param name="s"></param>
</member>
<member name="E:Asa.IOModule.AIOBOX.Log_Out_Event">
<summary>
日志输出事件
</summary>
</member>
<member name="M:Asa.IOModule.AIOBOX.#ctor"> <member name="M:Asa.IOModule.AIOBOX.#ctor">
<summary> <summary>
AIOBOX AIOBOX
...@@ -78,6 +90,11 @@ ...@@ -78,6 +90,11 @@
自动读取DO状态,触发DO_Changed_Event 自动读取DO状态,触发DO_Changed_Event
</summary> </summary>
</member> </member>
<member name="P:Asa.IOModule.AIOBOX.LogOut">
<summary>
日志输出
</summary>
</member>
<member name="P:Asa.IOModule.AIOBOX.Type"> <member name="P:Asa.IOModule.AIOBOX.Type">
<summary> <summary>
IO模块类型 IO模块类型
...@@ -194,6 +211,11 @@ ...@@ -194,6 +211,11 @@
自动读取DIO线程 自动读取DIO线程
</summary> </summary>
</member> </member>
<member name="M:Asa.IOModule.AIOBOX.LogPrint">
<summary>
日志输出线程
</summary>
</member>
<member name="T:Asa.IOModule.Reg"> <member name="T:Asa.IOModule.Reg">
<summary> <summary>
IO模块寄存器 IO模块寄存器
......
...@@ -54,10 +54,23 @@ ...@@ -54,10 +54,23 @@
<conversionPattern value="[%date][%t]%-5p %m%n" /> <conversionPattern value="[%date][%t]%-5p %m%n" />
</layout> </layout>
</appender> </appender>
<root> <appender name="AIOBOXLog" type="log4net.Appender.RollingFileAppender">
<file value="logs/AIOBOX1.log" />
<appendToFile value="true" />
<rollingStyle value="Date" />
<datePattern value="yyyy-MM-dd" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="[%date][%t] %m%n" />
</layout>
</appender>
<logger name="RollingLogFileAppender">
<level value="Info" /> <level value="Info" />
<appender-ref ref="RollingLogFileAppender" /> <appender-ref ref="RollingLogFileAppender" />
</root> </logger>
<logger name="AIOBOXLog">
<level value="Info" />
<appender-ref ref="AIOBOXLog" />
</logger>
</log4net> </log4net>
<startup> <startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" /> <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
......
...@@ -13,8 +13,8 @@ namespace OnlineStore.Common ...@@ -13,8 +13,8 @@ namespace OnlineStore.Common
{ {
private static LogUtil instance = new LogUtil(); private static LogUtil instance = new LogUtil();
public delegate void ShowLog(string msg, Color color); public delegate void ShowLog(string msg, Color color);
public static readonly ILog LOGGER = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); public static readonly ILog LOGGER = LogManager.GetLogger("RollingLogFileAppender");
public static readonly ILog AIOLog = LogManager.GetLogger("AIOBOXLog");
public static Dictionary<int, DateTime> lastErrorLogTime = new Dictionary<int, DateTime>(); public static Dictionary<int, DateTime> lastErrorLogTime = new Dictionary<int, DateTime>();
public static System.Windows.Forms.RichTextBox logBox = null; public static System.Windows.Forms.RichTextBox logBox = null;
...@@ -22,8 +22,7 @@ namespace OnlineStore.Common ...@@ -22,8 +22,7 @@ namespace OnlineStore.Common
public static int showCount = 20; public static int showCount = 20;
public static bool debug_opened = false; public static bool debug_opened = false;
public static void info(ILog log,string msg ) public static void info(ILog log,string msg )
{ {
if (log == null) if (log == null)
......
...@@ -36,8 +36,8 @@ ...@@ -36,8 +36,8 @@
<Prefer32Bit>false</Prefer32Bit> <Prefer32Bit>false</Prefer32Bit>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="AIOBOX"> <Reference Include="Asa.IOModule.AIOBOX">
<HintPath>..\..\dll\AIOBOX.dll</HintPath> <HintPath>..\..\dll\Asa.IOModule.AIOBOX.dll</HintPath>
</Reference> </Reference>
<Reference Include="CodeLibrary"> <Reference Include="CodeLibrary">
<HintPath>..\..\dll\CodeLibrary.dll</HintPath> <HintPath>..\..\dll\CodeLibrary.dll</HintPath>
......
...@@ -3,11 +3,12 @@ using System; ...@@ -3,11 +3,12 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;
using System.Text; using System.Text;
using Asa.AIOBOX;
using System.Threading; using System.Threading;
using OnlineStore.Common; using OnlineStore.Common;
using OnlineStore.LoadCSVLibrary; using OnlineStore.LoadCSVLibrary;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace OnlineStore.DeviceLibrary namespace OnlineStore.DeviceLibrary
{ {
...@@ -17,18 +18,18 @@ namespace OnlineStore.DeviceLibrary ...@@ -17,18 +18,18 @@ namespace OnlineStore.DeviceLibrary
//public static uint DefaultDOCount = 16; //public static uint DefaultDOCount = 16;
public readonly ILog LOGGER = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); public readonly ILog LOGGER = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
public Dictionary<string, AIOBOX> AIOMap = new Dictionary<string, AIOBOX>(); public Dictionary<string, AIOBOX_32> AIOMap = new Dictionary<string, AIOBOX_32>();
public string DefaultIP = ""; public string DefaultIP = "";
public Dictionary<string, List<Box_Sta>> DIValueMap = new Dictionary<string, List<Box_Sta>>(); public Dictionary<string, List<Status>> DIValueMap = new Dictionary<string, List<Status>>();
public Dictionary<string, List<Box_Sta>> DOValueMap = new Dictionary<string, List<Box_Sta>>(); public Dictionary<string, List<Status>> DOValueMap = new Dictionary<string, List<Status>>();
private object DIMapLock = ""; private object DIMapLock = "";
private object DOMapLock = ""; private object DOMapLock = "";
public System.Timers.Timer timer = null; public System.Timers.Timer timer = null;
private object DILock = ""; private object DILock = "";
private object DOLock = ""; private object DOLock = "";
public void ConnectionIP(string ioIp ) public void ConnectionIP(string ioIp )
{ {
AIOBOX aioBox = null; AIOBOX_32 aioBox = null;
if (AIOMap.ContainsKey(ioIp)) if (AIOMap.ContainsKey(ioIp))
{ {
aioBox = AIOMap[ioIp]; aioBox = AIOMap[ioIp];
...@@ -51,20 +52,11 @@ namespace OnlineStore.DeviceLibrary ...@@ -51,20 +52,11 @@ namespace OnlineStore.DeviceLibrary
try try
{ {
// Create new modbus master and add event functions // Create new modbus master and add event functions
aioBox = new AIOBOX(); aioBox = new AIOBOX_32();
aioBox.IP = ioIp; aioBox.IP = ioIp;
DefaultIP = ioIp; DefaultIP = ioIp;
aioBox.AutoReadDI = true; aioBox.AutoReadDI = true;
aioBox.AutoReadDO = true; aioBox.AutoReadDO = true;
if (StoreManager.Config.GetDILength(ioIp).Equals(8))
{
aioBox.Type = Box_Type.DIO_16;
}
else
{
aioBox.Type = Box_Type.DIO_32;
}
aioBox.DI_Changed_Event += AioBox_DI_Changed_Event; ; aioBox.DI_Changed_Event += AioBox_DI_Changed_Event; ;
aioBox.DO_Changed_Event += AioBox_DO_Changed_Event; aioBox.DO_Changed_Event += AioBox_DO_Changed_Event;
LogUtil.info("开始连接IO模块【" + ioIp + "】,尝试重连三次"); LogUtil.info("开始连接IO模块【" + ioIp + "】,尝试重连三次");
...@@ -94,7 +86,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -94,7 +86,7 @@ namespace OnlineStore.DeviceLibrary
} }
} }
private void AioBox_DI_Changed_Event(AIOBOX box, Box_Sta[] sta) private void AioBox_DI_Changed_Event(AIOBOX_32 box, Status[] sta)
{ {
try try
{ {
...@@ -105,7 +97,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -105,7 +97,7 @@ namespace OnlineStore.DeviceLibrary
LogUtil.error("AioBox_DI_Changed_Event出错:" + ex.ToString()); LogUtil.error("AioBox_DI_Changed_Event出错:" + ex.ToString());
} }
} }
private void AioBox_DO_Changed_Event(AIOBOX box, Box_Sta[] sta) private void AioBox_DO_Changed_Event(AIOBOX_32 box, Status[] sta)
{ {
try try
{ {
...@@ -117,14 +109,14 @@ namespace OnlineStore.DeviceLibrary ...@@ -117,14 +109,14 @@ namespace OnlineStore.DeviceLibrary
} }
} }
private void UpdateAllDI(string ip, Box_Sta[] sta) private void UpdateAllDI(string ip, Status[] sta)
{ {
if (sta != null && sta.Length >= StoreManager.Config.GetDILength(ip)) if (sta != null && sta.Length >= StoreManager.Config.GetDILength(ip))
{ {
bool needUpdate = false; bool needUpdate = false;
List<Box_Sta> newList = new List<Box_Sta>(); List<Status> newList = new List<Status>();
newList.AddRange(sta); newList.AddRange(sta);
List<Box_Sta> oldList = null; List<Status> oldList = null;
DIValueMap.TryGetValue(ip, out oldList); DIValueMap.TryGetValue(ip, out oldList);
if (oldList == null || oldList.Count.Equals(newList.Count).Equals(false)) if (oldList == null || oldList.Count.Equals(newList.Count).Equals(false))
{ {
...@@ -154,14 +146,14 @@ namespace OnlineStore.DeviceLibrary ...@@ -154,14 +146,14 @@ namespace OnlineStore.DeviceLibrary
} }
} }
} }
private void UpdateAllDO(string ip, Box_Sta[] sta) private void UpdateAllDO(string ip, Status[] sta)
{ {
if (sta != null && sta.Length >= StoreManager.Config.GetDOLength(ip)) if (sta != null && sta.Length >= StoreManager.Config.GetDOLength(ip))
{ {
bool needUpdate = false; bool needUpdate = false;
List<Box_Sta> newList = new List<Box_Sta>(); List<Status> newList = new List<Status>();
newList.AddRange(sta); newList.AddRange(sta);
List<Box_Sta> oldList = null; List<Status> oldList = null;
DOValueMap.TryGetValue(ip, out oldList); DOValueMap.TryGetValue(ip, out oldList);
if (oldList == null || oldList.Count.Equals(newList.Count).Equals(false)) if (oldList == null || oldList.Count.Equals(newList.Count).Equals(false))
{ {
...@@ -200,7 +192,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -200,7 +192,7 @@ namespace OnlineStore.DeviceLibrary
foreach (string io in list) foreach (string io in list)
{ {
//判断是否连接,如果没有连接自动重连 //判断是否连接,如果没有连接自动重连
AIOBOX clinet = AIOMap[io]; AIOBOX_32 clinet = AIOMap[io];
if (!clinet.IsConn) if (!clinet.IsConn)
{ {
LogUtil.error(LOGGER, io + "当前没有连上:" + clinet.ErrInfo); LogUtil.error(LOGGER, io + "当前没有连上:" + clinet.ErrInfo);
...@@ -225,20 +217,20 @@ namespace OnlineStore.DeviceLibrary ...@@ -225,20 +217,20 @@ namespace OnlineStore.DeviceLibrary
//关闭所有的DO //关闭所有的DO
public override void CloseAllDO() public override void CloseAllDO()
{ {
foreach (AIOBOX aio in AIOMap.Values) foreach (AIOBOX_32 aio in AIOMap.Values)
{ {
Box_Sta[] Box_Staes = new Box_Sta[16]; Status[] statuses = new Status[16];
for(int i = 0; i < 16; i++) for(int i = 0; i < 16; i++)
{ {
Box_Staes[i] = Box_Sta.Off; statuses[i] = Status.Off;
} }
aio.WriteDO( Box_Addr.DI_1, Box_Staes); aio.WriteDO(Addr.DI_1, statuses);
} }
} }
public override void CloseAllConnection() public override void CloseAllConnection()
{ {
foreach (AIOBOX aio in AIOMap.Values) foreach (AIOBOX_32 aio in AIOMap.Values)
{ {
aio.Close(); aio.Close();
} }
...@@ -249,14 +241,14 @@ namespace OnlineStore.DeviceLibrary ...@@ -249,14 +241,14 @@ namespace OnlineStore.DeviceLibrary
try try
{ {
AIOBOX aioBox = getAIO(ioIp); AIOBOX_32 aioBox = getAIO(ioIp);
if (aioBox != null) if (aioBox != null)
{ {
Box_Addr add = GetAddr(StartAddress); Addr add = GetAddr(StartAddress);
for (int i = 1; i <= 3; i++) for (int i = 1; i <= 3; i++)
{ {
bool result = aioBox.WriteDO(GetAddr(StartAddress), GetBox_Sta(onOff)); bool result = aioBox.WriteDO(GetAddr(StartAddress), GetStatus(onOff));
if (!result) if (!result)
{ {
LogUtil.error("AIO WriteSingleDO [" + StartAddress + "] 第" + i + "次失败:" + aioBox.ErrInfo); LogUtil.error("AIO WriteSingleDO [" + StartAddress + "] 第" + i + "次失败:" + aioBox.ErrInfo);
...@@ -282,12 +274,12 @@ namespace OnlineStore.DeviceLibrary ...@@ -282,12 +274,12 @@ namespace OnlineStore.DeviceLibrary
try try
{ {
AIOBOX aioBox = getAIO(ioIp); AIOBOX_32 aioBox = getAIO(ioIp);
Box_Sta currBox_Sta = GetBox_Sta(onOff); Status currStatus = GetStatus(onOff);
if (aioBox != null) if (aioBox != null)
{ {
Box_Addr add = GetAddr(StartAddress); Addr add = GetAddr(StartAddress);
aioBox.WriteDO(GetAddr(StartAddress), currBox_Sta); aioBox.WriteDO(GetAddr(StartAddress), currStatus);
//写入之后,等待指定间隔后回写 //写入之后,等待指定间隔后回写
System.Timers.Timer mytimer = new System.Timers.Timer(mSeconds); System.Timers.Timer mytimer = new System.Timers.Timer(mSeconds);
...@@ -295,8 +287,8 @@ namespace OnlineStore.DeviceLibrary ...@@ -295,8 +287,8 @@ namespace OnlineStore.DeviceLibrary
{ {
try try
{ {
aioBox.WriteDO(GetAddr(StartAddress), aioBox.ReverseStatus(currBox_Sta)); aioBox.WriteDO(GetAddr(StartAddress), aioBox.ReverseStatus(currStatus));
LogUtil.debug(LOGGER, "**********定时回写入 IO【" + ioIp + "," + StartAddress + ",值" + aioBox.ReverseStatus(currBox_Sta) + "】:"); LogUtil.debug(LOGGER, "**********定时回写入 IO【" + ioIp + "," + StartAddress + ",值" + aioBox.ReverseStatus(currStatus) + "】:");
} }
catch (Exception ex) catch (Exception ex)
{ {
...@@ -320,11 +312,18 @@ namespace OnlineStore.DeviceLibrary ...@@ -320,11 +312,18 @@ namespace OnlineStore.DeviceLibrary
{ {
try try
{ {
AIOBOX aioBox = getAIO(ioIp); AIOBOX_32 aioBox = getAIO(ioIp);
if (aioBox != null) if (aioBox != null)
{ {
Box_Sta[] allDi = aioBox.ReadDI(Box_Addr.DI_1, StoreManager.Config.GetDILength(ioIp)); Status[] allDi;
UpdateAllDI(ioIp, allDi); if (aioBox.ReadDI(Addr.DI_1, StoreManager.Config.GetDILength(ioIp), out allDi))
{
UpdateAllDI(ioIp, allDi);
}
else
{
LogUtil.error("读取所有DI出错:" + aioBox.ErrInfo);
}
} }
} }
catch (Exception ex) catch (Exception ex)
...@@ -336,11 +335,18 @@ namespace OnlineStore.DeviceLibrary ...@@ -336,11 +335,18 @@ namespace OnlineStore.DeviceLibrary
{ {
try try
{ {
AIOBOX aioBox = getAIO(ioIp); AIOBOX_32 aioBox = getAIO(ioIp);
if (aioBox != null) if (aioBox != null)
{ {
Box_Sta[] allDO = aioBox.ReadDO(Box_Addr.DO_1, StoreManager.Config.GetDOLength(ioIp)); Status[] allDO;
UpdateAllDO(ioIp, allDO); if (aioBox.ReadDO(Addr.DO_1, StoreManager.Config.GetDOLength(ioIp), out allDO))
{
UpdateAllDO(ioIp, allDO);
}
else
{
LogUtil.error("读取所有DO出错:" + aioBox.ErrInfo);
}
} }
} }
catch (Exception ex) catch (Exception ex)
...@@ -353,19 +359,19 @@ namespace OnlineStore.DeviceLibrary ...@@ -353,19 +359,19 @@ namespace OnlineStore.DeviceLibrary
IO_VALUE value = IO_VALUE.LOW; IO_VALUE value = IO_VALUE.LOW;
try try
{ {
AIOBOX aioBox = getAIO(ioIP); AIOBOX_32 aioBox = getAIO(ioIP);
if (aioBox != null) if (aioBox != null)
{ {
Box_Sta sta = Box_Sta.Off; Status status = Status.Off;
Box_Addr addr = GetAddr(StartAddress); Addr addr = GetAddr(StartAddress);
int index = (int)StartAddress - (int)StoreManager.Config.GetDILength(ioIP); int index =(int)StartAddress - (int)StoreManager.Config.GetDILength(ioIP);
if (DOValueMap.ContainsKey(ioIP) && DOValueMap[ioIP].Count > index) if (DOValueMap.ContainsKey(ioIP) && DOValueMap[ioIP].Count>index)
{ {
sta = DOValueMap[ioIP][index]; status = DOValueMap[ioIP][index];
} }
else else
{ sta = aioBox.ReadDO(addr); } { aioBox.ReadDO(addr, out status); }
if (sta.Equals(Box_Sta.On)) if (status.Equals(Status.On))
{ {
value = IO_VALUE.HIGH; value = IO_VALUE.HIGH;
} }
...@@ -383,21 +389,21 @@ namespace OnlineStore.DeviceLibrary ...@@ -383,21 +389,21 @@ namespace OnlineStore.DeviceLibrary
IO_VALUE value = IO_VALUE.LOW; IO_VALUE value = IO_VALUE.LOW;
try try
{ {
AIOBOX aioBox = getAIO(ioIP); AIOBOX_32 aioBox = getAIO(ioIP);
if (aioBox != null) if (aioBox != null)
{ {
Box_Sta sta = Box_Sta.Off; Status status = Status.Off;
Box_Addr addr = GetAddr(StartAddress); Addr addr = GetAddr(StartAddress);
int index = StartAddress; int index = StartAddress;
if (DIValueMap.ContainsKey(ioIP) && DIValueMap[ioIP].Count> index) if (DIValueMap.ContainsKey(ioIP) && DIValueMap[ioIP].Count> index)
{ {
sta = DIValueMap[ioIP][index]; status = DIValueMap[ioIP][index];
} }
else else
{ {
sta= aioBox.ReadDI(addr ); aioBox.ReadDI(addr, out status);
} }
if (sta.Equals(Box_Sta.On)) if (status.Equals(Status.On))
{ {
value = IO_VALUE.HIGH; value = IO_VALUE.HIGH;
} }
...@@ -430,25 +436,25 @@ namespace OnlineStore.DeviceLibrary ...@@ -430,25 +436,25 @@ namespace OnlineStore.DeviceLibrary
return value; return value;
} }
private Box_Addr GetAddr(ushort StartAddress) private Addr GetAddr(ushort StartAddress)
{ {
return (Box_Addr)(StartAddress ); return (Addr)(StartAddress );
} }
private Box_Sta GetBox_Sta(IO_VALUE onOff) private Status GetStatus(IO_VALUE onOff)
{ {
if (onOff.Equals(IO_VALUE.HIGH)) if (onOff.Equals(IO_VALUE.HIGH))
{ {
return Box_Sta.On; return Status.On;
} }
else else
{ {
return Box_Sta.Off; return Status.Off;
} }
} }
private AIOBOX getAIO(string ioIp) private AIOBOX_32 getAIO(string ioIp)
{ {
AIOBOX aioBox = null; AIOBOX_32 aioBox = null;
if (AIOMap.ContainsKey(ioIp)) if (AIOMap.ContainsKey(ioIp))
{ {
aioBox = AIOMap[ioIp]; aioBox = AIOMap[ioIp];
......
...@@ -3,12 +3,12 @@ using System; ...@@ -3,12 +3,12 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;
using System.Text; using System.Text;
using Asa.AIOBOX;
using System.Threading; using System.Threading;
using OnlineStore.Common; using OnlineStore.Common;
using OnlineStore.LoadCSVLibrary; using OnlineStore.LoadCSVLibrary;
using System.Threading.Tasks; using System.Threading.Tasks;
using Asa.IOModule;
namespace OnlineStore.DeviceLibrary namespace OnlineStore.DeviceLibrary
{ {
...@@ -18,18 +18,18 @@ namespace OnlineStore.DeviceLibrary ...@@ -18,18 +18,18 @@ namespace OnlineStore.DeviceLibrary
//public static uint DefaultDOCount = 16; //public static uint DefaultDOCount = 16;
public readonly ILog LOGGER = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); public readonly ILog LOGGER = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
public Dictionary<string, AIOBOX_32> AIOMap = new Dictionary<string, AIOBOX_32>(); public Dictionary<string, AIOBOX> AIOMap = new Dictionary<string, AIOBOX>();
public string DefaultIP = ""; public string DefaultIP = "";
public Dictionary<string, List<Status>> DIValueMap = new Dictionary<string, List<Status>>(); public Dictionary<string, List<Box_Sta>> DIValueMap = new Dictionary<string, List<Box_Sta>>();
public Dictionary<string, List<Status>> DOValueMap = new Dictionary<string, List<Status>>(); public Dictionary<string, List<Box_Sta>> DOValueMap = new Dictionary<string, List<Box_Sta>>();
private object DIMapLock = ""; private object DIMapLock = "";
private object DOMapLock = ""; private object DOMapLock = "";
public System.Timers.Timer timer = null; public System.Timers.Timer timer = null;
private object DILock = ""; private object DILock = "";
private object DOLock = ""; private object DOLock = "";
public void ConnectionIP(string ioIp ) public void ConnectionIP(string ioIp )
{ {
AIOBOX_32 aioBox = null; AIOBOX aioBox = null;
if (AIOMap.ContainsKey(ioIp)) if (AIOMap.ContainsKey(ioIp))
{ {
aioBox = AIOMap[ioIp]; aioBox = AIOMap[ioIp];
...@@ -52,13 +52,23 @@ namespace OnlineStore.DeviceLibrary ...@@ -52,13 +52,23 @@ namespace OnlineStore.DeviceLibrary
try try
{ {
// Create new modbus master and add event functions // Create new modbus master and add event functions
aioBox = new AIOBOX_32(); aioBox = new AIOBOX();
aioBox.IP = ioIp; aioBox.IP = ioIp;
DefaultIP = ioIp; DefaultIP = ioIp;
aioBox.AutoReadDI = true; aioBox.AutoReadDI = true;
aioBox.AutoReadDO = true; aioBox.AutoReadDO = true;
aioBox.LogOut = true;
if (StoreManager.Config.GetDILength(ioIp).Equals(8))
{
aioBox.Type = Box_Type.DIO_16;
}
else
{
aioBox.Type = Box_Type.DIO_32;
}
aioBox.DI_Changed_Event += AioBox_DI_Changed_Event; ; aioBox.DI_Changed_Event += AioBox_DI_Changed_Event; ;
aioBox.DO_Changed_Event += AioBox_DO_Changed_Event; aioBox.DO_Changed_Event += AioBox_DO_Changed_Event;
aioBox.Log_Out_Event += AioBox_Log_Out_Event;
LogUtil.info("开始连接IO模块【" + ioIp + "】,尝试重连三次"); LogUtil.info("开始连接IO模块【" + ioIp + "】,尝试重连三次");
for (int i = 1; i <= 3; i++) for (int i = 1; i <= 3; i++)
{ {
...@@ -86,7 +96,15 @@ namespace OnlineStore.DeviceLibrary ...@@ -86,7 +96,15 @@ namespace OnlineStore.DeviceLibrary
} }
} }
private void AioBox_DI_Changed_Event(AIOBOX_32 box, Status[] sta) private void AioBox_Log_Out_Event(AIOBOX box, string[] s)
{
foreach (string str in s)
{
LogUtil.AIOLog.Info( "["+box.IP+"]"+ str);
}
}
private void AioBox_DI_Changed_Event(AIOBOX box, Box_Sta[] sta)
{ {
try try
{ {
...@@ -97,7 +115,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -97,7 +115,7 @@ namespace OnlineStore.DeviceLibrary
LogUtil.error("AioBox_DI_Changed_Event出错:" + ex.ToString()); LogUtil.error("AioBox_DI_Changed_Event出错:" + ex.ToString());
} }
} }
private void AioBox_DO_Changed_Event(AIOBOX_32 box, Status[] sta) private void AioBox_DO_Changed_Event(AIOBOX box, Box_Sta[] sta)
{ {
try try
{ {
...@@ -109,14 +127,14 @@ namespace OnlineStore.DeviceLibrary ...@@ -109,14 +127,14 @@ namespace OnlineStore.DeviceLibrary
} }
} }
private void UpdateAllDI(string ip, Status[] sta) private void UpdateAllDI(string ip, Box_Sta[] sta)
{ {
if (sta != null && sta.Length >= StoreManager.Config.GetDILength(ip)) if (sta != null && sta.Length >= StoreManager.Config.GetDILength(ip))
{ {
bool needUpdate = false; bool needUpdate = false;
List<Status> newList = new List<Status>(); List<Box_Sta> newList = new List<Box_Sta>();
newList.AddRange(sta); newList.AddRange(sta);
List<Status> oldList = null; List<Box_Sta> oldList = null;
DIValueMap.TryGetValue(ip, out oldList); DIValueMap.TryGetValue(ip, out oldList);
if (oldList == null || oldList.Count.Equals(newList.Count).Equals(false)) if (oldList == null || oldList.Count.Equals(newList.Count).Equals(false))
{ {
...@@ -146,14 +164,14 @@ namespace OnlineStore.DeviceLibrary ...@@ -146,14 +164,14 @@ namespace OnlineStore.DeviceLibrary
} }
} }
} }
private void UpdateAllDO(string ip, Status[] sta) private void UpdateAllDO(string ip, Box_Sta[] sta)
{ {
if (sta != null && sta.Length >= StoreManager.Config.GetDOLength(ip)) if (sta != null && sta.Length >= StoreManager.Config.GetDOLength(ip))
{ {
bool needUpdate = false; bool needUpdate = false;
List<Status> newList = new List<Status>(); List<Box_Sta> newList = new List<Box_Sta>();
newList.AddRange(sta); newList.AddRange(sta);
List<Status> oldList = null; List<Box_Sta> oldList = null;
DOValueMap.TryGetValue(ip, out oldList); DOValueMap.TryGetValue(ip, out oldList);
if (oldList == null || oldList.Count.Equals(newList.Count).Equals(false)) if (oldList == null || oldList.Count.Equals(newList.Count).Equals(false))
{ {
...@@ -192,7 +210,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -192,7 +210,7 @@ namespace OnlineStore.DeviceLibrary
foreach (string io in list) foreach (string io in list)
{ {
//判断是否连接,如果没有连接自动重连 //判断是否连接,如果没有连接自动重连
AIOBOX_32 clinet = AIOMap[io]; AIOBOX clinet = AIOMap[io];
if (!clinet.IsConn) if (!clinet.IsConn)
{ {
LogUtil.error(LOGGER, io + "当前没有连上:" + clinet.ErrInfo); LogUtil.error(LOGGER, io + "当前没有连上:" + clinet.ErrInfo);
...@@ -217,20 +235,20 @@ namespace OnlineStore.DeviceLibrary ...@@ -217,20 +235,20 @@ namespace OnlineStore.DeviceLibrary
//关闭所有的DO //关闭所有的DO
public override void CloseAllDO() public override void CloseAllDO()
{ {
foreach (AIOBOX_32 aio in AIOMap.Values) foreach (AIOBOX aio in AIOMap.Values)
{ {
Status[] statuses = new Status[16]; Box_Sta[] Box_Staes = new Box_Sta[16];
for(int i = 0; i < 16; i++) for(int i = 0; i < 16; i++)
{ {
statuses[i] = Status.Off; Box_Staes[i] = Box_Sta.Off;
} }
aio.WriteDO(Addr.DI_1, statuses); aio.WriteDO( Box_Addr.DI_1, Box_Staes);
} }
} }
public override void CloseAllConnection() public override void CloseAllConnection()
{ {
foreach (AIOBOX_32 aio in AIOMap.Values) foreach (AIOBOX aio in AIOMap.Values)
{ {
aio.Close(); aio.Close();
} }
...@@ -241,14 +259,14 @@ namespace OnlineStore.DeviceLibrary ...@@ -241,14 +259,14 @@ namespace OnlineStore.DeviceLibrary
try try
{ {
AIOBOX_32 aioBox = getAIO(ioIp); AIOBOX aioBox = getAIO(ioIp);
if (aioBox != null) if (aioBox != null)
{ {
Addr add = GetAddr(StartAddress); Box_Addr add = GetAddr(StartAddress);
for (int i = 1; i <= 3; i++) for (int i = 1; i <= 3; i++)
{ {
bool result = aioBox.WriteDO(GetAddr(StartAddress), GetStatus(onOff)); bool result = aioBox.WriteDO(GetAddr(StartAddress), GetBox_Sta(onOff));
if (!result) if (!result)
{ {
LogUtil.error("AIO WriteSingleDO [" + StartAddress + "] 第" + i + "次失败:" + aioBox.ErrInfo); LogUtil.error("AIO WriteSingleDO [" + StartAddress + "] 第" + i + "次失败:" + aioBox.ErrInfo);
...@@ -274,12 +292,12 @@ namespace OnlineStore.DeviceLibrary ...@@ -274,12 +292,12 @@ namespace OnlineStore.DeviceLibrary
try try
{ {
AIOBOX_32 aioBox = getAIO(ioIp); AIOBOX aioBox = getAIO(ioIp);
Status currStatus = GetStatus(onOff); Box_Sta currBox_Sta = GetBox_Sta(onOff);
if (aioBox != null) if (aioBox != null)
{ {
Addr add = GetAddr(StartAddress); Box_Addr add = GetAddr(StartAddress);
aioBox.WriteDO(GetAddr(StartAddress), currStatus); aioBox.WriteDO(GetAddr(StartAddress), currBox_Sta);
//写入之后,等待指定间隔后回写 //写入之后,等待指定间隔后回写
System.Timers.Timer mytimer = new System.Timers.Timer(mSeconds); System.Timers.Timer mytimer = new System.Timers.Timer(mSeconds);
...@@ -287,8 +305,8 @@ namespace OnlineStore.DeviceLibrary ...@@ -287,8 +305,8 @@ namespace OnlineStore.DeviceLibrary
{ {
try try
{ {
aioBox.WriteDO(GetAddr(StartAddress), aioBox.ReverseStatus(currStatus)); aioBox.WriteDO(GetAddr(StartAddress), aioBox.ReverseStatus(currBox_Sta));
LogUtil.debug(LOGGER, "**********定时回写入 IO【" + ioIp + "," + StartAddress + ",值" + aioBox.ReverseStatus(currStatus) + "】:"); LogUtil.debug(LOGGER, "**********定时回写入 IO【" + ioIp + "," + StartAddress + ",值" + aioBox.ReverseStatus(currBox_Sta) + "】:");
} }
catch (Exception ex) catch (Exception ex)
{ {
...@@ -312,18 +330,11 @@ namespace OnlineStore.DeviceLibrary ...@@ -312,18 +330,11 @@ namespace OnlineStore.DeviceLibrary
{ {
try try
{ {
AIOBOX_32 aioBox = getAIO(ioIp); AIOBOX aioBox = getAIO(ioIp);
if (aioBox != null) if (aioBox != null)
{ {
Status[] allDi; Box_Sta[] allDi = aioBox.ReadDI(Box_Addr.DI_1, StoreManager.Config.GetDILength(ioIp));
if (aioBox.ReadDI(Addr.DI_1, StoreManager.Config.GetDILength(ioIp), out allDi)) UpdateAllDI(ioIp, allDi);
{
UpdateAllDI(ioIp, allDi);
}
else
{
LogUtil.error("读取所有DI出错:" + aioBox.ErrInfo);
}
} }
} }
catch (Exception ex) catch (Exception ex)
...@@ -335,18 +346,11 @@ namespace OnlineStore.DeviceLibrary ...@@ -335,18 +346,11 @@ namespace OnlineStore.DeviceLibrary
{ {
try try
{ {
AIOBOX_32 aioBox = getAIO(ioIp); AIOBOX aioBox = getAIO(ioIp);
if (aioBox != null) if (aioBox != null)
{ {
Status[] allDO; Box_Sta[] allDO = aioBox.ReadDO(Box_Addr.DO_1, StoreManager.Config.GetDOLength(ioIp));
if (aioBox.ReadDO(Addr.DO_1, StoreManager.Config.GetDOLength(ioIp), out allDO)) UpdateAllDO(ioIp, allDO);
{
UpdateAllDO(ioIp, allDO);
}
else
{
LogUtil.error("读取所有DO出错:" + aioBox.ErrInfo);
}
} }
} }
catch (Exception ex) catch (Exception ex)
...@@ -359,19 +363,19 @@ namespace OnlineStore.DeviceLibrary ...@@ -359,19 +363,19 @@ namespace OnlineStore.DeviceLibrary
IO_VALUE value = IO_VALUE.LOW; IO_VALUE value = IO_VALUE.LOW;
try try
{ {
AIOBOX_32 aioBox = getAIO(ioIP); AIOBOX aioBox = getAIO(ioIP);
if (aioBox != null) if (aioBox != null)
{ {
Status status = Status.Off; Box_Sta sta = Box_Sta.Off;
Addr addr = GetAddr(StartAddress); Box_Addr addr = GetAddr(StartAddress);
int index =(int)StartAddress - (int)StoreManager.Config.GetDILength(ioIP); int index = (int)StartAddress - (int)StoreManager.Config.GetDILength(ioIP);
if (DOValueMap.ContainsKey(ioIP) && DOValueMap[ioIP].Count>index) if (DOValueMap.ContainsKey(ioIP) && DOValueMap[ioIP].Count > index)
{ {
status = DOValueMap[ioIP][index]; sta = DOValueMap[ioIP][index];
} }
else else
{ aioBox.ReadDO(addr, out status); } { sta = aioBox.ReadDO(addr); }
if (status.Equals(Status.On)) if (sta.Equals(Box_Sta.On))
{ {
value = IO_VALUE.HIGH; value = IO_VALUE.HIGH;
} }
...@@ -389,21 +393,21 @@ namespace OnlineStore.DeviceLibrary ...@@ -389,21 +393,21 @@ namespace OnlineStore.DeviceLibrary
IO_VALUE value = IO_VALUE.LOW; IO_VALUE value = IO_VALUE.LOW;
try try
{ {
AIOBOX_32 aioBox = getAIO(ioIP); AIOBOX aioBox = getAIO(ioIP);
if (aioBox != null) if (aioBox != null)
{ {
Status status = Status.Off; Box_Sta sta = Box_Sta.Off;
Addr addr = GetAddr(StartAddress); Box_Addr addr = GetAddr(StartAddress);
int index = StartAddress; int index = StartAddress;
if (DIValueMap.ContainsKey(ioIP) && DIValueMap[ioIP].Count> index) if (DIValueMap.ContainsKey(ioIP) && DIValueMap[ioIP].Count> index)
{ {
status = DIValueMap[ioIP][index]; sta = DIValueMap[ioIP][index];
} }
else else
{ {
aioBox.ReadDI(addr, out status); sta= aioBox.ReadDI(addr );
} }
if (status.Equals(Status.On)) if (sta.Equals(Box_Sta.On))
{ {
value = IO_VALUE.HIGH; value = IO_VALUE.HIGH;
} }
...@@ -436,25 +440,25 @@ namespace OnlineStore.DeviceLibrary ...@@ -436,25 +440,25 @@ namespace OnlineStore.DeviceLibrary
return value; return value;
} }
private Addr GetAddr(ushort StartAddress) private Box_Addr GetAddr(ushort StartAddress)
{ {
return (Addr)(StartAddress ); return (Box_Addr)(StartAddress );
} }
private Status GetStatus(IO_VALUE onOff) private Box_Sta GetBox_Sta(IO_VALUE onOff)
{ {
if (onOff.Equals(IO_VALUE.HIGH)) if (onOff.Equals(IO_VALUE.HIGH))
{ {
return Status.On; return Box_Sta.On;
} }
else else
{ {
return Status.Off; return Box_Sta.Off;
} }
} }
private AIOBOX_32 getAIO(string ioIp) private AIOBOX getAIO(string ioIp)
{ {
AIOBOX_32 aioBox = null; AIOBOX aioBox = null;
if (AIOMap.ContainsKey(ioIp)) if (AIOMap.ContainsKey(ioIp))
{ {
aioBox = AIOMap[ioIp]; aioBox = AIOMap[ioIp];
......
...@@ -340,7 +340,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -340,7 +340,7 @@ namespace OnlineStore.DeviceLibrary
} }
private void SI_03_AxisToP1(LineMoveP moveP) private void SI_03_AxisToP1(LineMoveP moveP)
{ {
InStoreLog("入库:SI_03 所有轴回到待机点,轴2、轴1 动作到P1, 轴4动作至P3,等待吸盘处于上升位置"); InStoreLog("入库:SI_03 所有轴回待机点,轴2、轴1 到P1, 轴4到P3,吸盘在上升端");
StoreMove.NextMoveStep(StoreMoveStep.SI_03_ReturnHome); StoreMove.NextMoveStep(StoreMoveStep.SI_03_ReturnHome);
bool needMove = false; bool needMove = false;
if (!ShuoKeControls.IsInPosition(Config.CompressAxis_Slv, moveP.ComPress_P3)) if (!ShuoKeControls.IsInPosition(Config.CompressAxis_Slv, moveP.ComPress_P3))
...@@ -368,7 +368,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -368,7 +368,7 @@ namespace OnlineStore.DeviceLibrary
} }
private void SI_02_Move(LineMoveP moveP) private void SI_02_Move(LineMoveP moveP)
{ {
InStoreLog("入库:SI_02_ 进出轴(叉子)动作至P1"); InStoreLog("入库:SI_02_ 进出轴至P1");
StoreMove.NextMoveStep(StoreMoveStep.SI_02_InOutAxisHome); StoreMove.NextMoveStep(StoreMoveStep.SI_02_InOutAxisHome);
bool result = InOutBackToP1(moveP.InOut_P1); bool result = InOutBackToP1(moveP.InOut_P1);
if (!result) if (!result)
...@@ -418,7 +418,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -418,7 +418,7 @@ namespace OnlineStore.DeviceLibrary
{ {
if (!StoreMove.IsNeedInStore) if (!StoreMove.IsNeedInStore)
{ {
InStoreLog("送出料盘:SI_21 ,需要操作人员拿走料盘,升降轴到门口位置P7 "); InStoreLog("送出料盘:SI_21 ,升降轴到门口位置P7 ");
StoreMove.NextMoveStep(StoreMoveStep.SI_21_DeviceToDoor); StoreMove.NextMoveStep(StoreMoveStep.SI_21_DeviceToDoor);
ACAxisMove(Config.UpDown_Axis, moveP.UpDown_Door_P7, Config.UpDownAxis_P7_Speed); ACAxisMove(Config.UpDown_Axis, moveP.UpDown_Door_P7, Config.UpDownAxis_P7_Speed);
} }
...@@ -427,14 +427,14 @@ namespace OnlineStore.DeviceLibrary ...@@ -427,14 +427,14 @@ namespace OnlineStore.DeviceLibrary
if (IsHasCompress_Axis) if (IsHasCompress_Axis)
{ {
int targetPosition = moveP.UpDown_P1 - Config.UpDownAxis_DownValue; int targetPosition = moveP.UpDown_P1 - Config.UpDownAxis_DownValue;
InStoreLog("入库:SI_06 压紧轴压紧,压紧轴到P2,升降轴稍微下降【" + Config.UpDownAxis_DownValue + "】,目标位置【" + targetPosition + "】 "); InStoreLog("入库:SI_06 压紧轴压紧,压紧轴到P2,升降轴下降【" + Config.UpDownAxis_DownValue + "】目标【" + targetPosition + "】 ");
StoreMove.NextMoveStep(StoreMoveStep.SI_06_CompressWork); StoreMove.NextMoveStep(StoreMoveStep.SI_06_CompressWork);
ComMoveToPosition(moveP.ComPress_P2, true); ComMoveToPosition(moveP.ComPress_P2, true);
ACAxisMove(Config.UpDown_Axis, targetPosition, Config.UpDownAxis_P4_Speed); ACAxisMove(Config.UpDown_Axis, targetPosition, Config.UpDownAxis_P4_Speed);
} }
else else
{ {
InStoreLog("入库:SI_07 叉子返回,进出轴至P1(待机点) "); InStoreLog("入库:SI_07 叉子返回,进出轴至P1 ");
StoreMove.NextMoveStep(StoreMoveStep.SI_07_DeviceBackFromDoor); StoreMove.NextMoveStep(StoreMoveStep.SI_07_DeviceBackFromDoor);
InOutBackToP1(moveP.InOut_P1); InOutBackToP1(moveP.InOut_P1);
} }
...@@ -449,7 +449,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -449,7 +449,7 @@ namespace OnlineStore.DeviceLibrary
//} //}
//else if (StoreMove.MoveStep == StoreMoveStep.SI_061_UpdownAxisDown) //else if (StoreMove.MoveStep == StoreMoveStep.SI_061_UpdownAxisDown)
{ {
InStoreLog("入库:SI_07 叉子返回,进出轴至P1(待机点) "); InStoreLog("入库:SI_07 叉子返回,进出轴至P1 ");
StoreMove.NextMoveStep(StoreMoveStep.SI_07_DeviceBackFromDoor); StoreMove.NextMoveStep(StoreMoveStep.SI_07_DeviceBackFromDoor);
InOutBackToP1(moveP.InOut_P1); InOutBackToP1(moveP.InOut_P1);
} }
...@@ -516,14 +516,14 @@ namespace OnlineStore.DeviceLibrary ...@@ -516,14 +516,14 @@ namespace OnlineStore.DeviceLibrary
} }
else if (StoreMove.MoveStep == StoreMoveStep.SI_12_PutWareToBag) else if (StoreMove.MoveStep == StoreMoveStep.SI_12_PutWareToBag)
{ {
InStoreLog("入库:SI_13 叉子从库位返回,进出轴至P1(待机点) "); InStoreLog("入库:SI_13 叉子从库位返回,进出轴至P1(待机点) ");
StoreMove.NextMoveStep(StoreMoveStep.SI_13_InoutBack); StoreMove.NextMoveStep(StoreMoveStep.SI_13_InoutBack);
InOutBackToP1(moveP.InOut_P1); InOutBackToP1(moveP.InOut_P1);
} }
else if (StoreMove.MoveStep == StoreMoveStep.SI_13_InoutBack) else if (StoreMove.MoveStep == StoreMoveStep.SI_13_InoutBack)
{ {
InStoreLog("入库:SI_14 返回待机点,轴2/轴1/轴4动作至P3(待机点))"); InStoreLog("入库:SI_14 返回待机点,轴2/轴1到P1,轴4到P3");
StoreMove.NextMoveStep(StoreMoveStep.SI_14_GoBack); StoreMove.NextMoveStep(StoreMoveStep.SI_14_GoBack);
ComMoveToPosition(moveP.ComPress_P3); ComMoveToPosition(moveP.ComPress_P3);
ACAxisMove(Config.Middle_Axis, moveP.Middle_P1, Config.MiddleAxis_P1_Speed); ACAxisMove(Config.Middle_Axis, moveP.Middle_P1, Config.MiddleAxis_P1_Speed);
...@@ -543,7 +543,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -543,7 +543,7 @@ namespace OnlineStore.DeviceLibrary
#region 送出料盘处理 #region 送出料盘处理
else if (StoreMove.MoveStep == StoreMoveStep.SI_21_DeviceToDoor) else if (StoreMove.MoveStep == StoreMoveStep.SI_21_DeviceToDoor)
{ {
InStoreLog("送出料盘:SI_21 ,需要操作人员拿走料盘,进出轴(叉子)到仓门出料点P4 "); InStoreLog("送出料盘:SI_21 ,进出轴到仓门出料点P4 ");
StoreMove.NextMoveStep(StoreMoveStep.SI_22_InoutToDoor); StoreMove.NextMoveStep(StoreMoveStep.SI_22_InoutToDoor);
ACAxisMove(Config.InOut_Axis, moveP.InOut_P4, Config.InOutAxis_P2_Speed); ACAxisMove(Config.InOut_Axis, moveP.InOut_P4, Config.InOutAxis_P2_Speed);
StoreMove.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.SafetyLightCurtains, IO_VALUE.HIGH)); StoreMove.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.SafetyLightCurtains, IO_VALUE.HIGH));
...@@ -553,7 +553,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -553,7 +553,7 @@ namespace OnlineStore.DeviceLibrary
{ {
if (IOManager.IOValue(IO_Type.SafetyLightCurtains).Equals(IO_VALUE.HIGH)) if (IOManager.IOValue(IO_Type.SafetyLightCurtains).Equals(IO_VALUE.HIGH))
{ {
InStoreLog("送出料盘:SI_22 ,需要操作人员拿走料盘,打开仓门 "); InStoreLog("送出料盘:SI_22 ,打开仓门 ");
StoreMove.NextMoveStep(StoreMoveStep.SI_23_OpenDoor); StoreMove.NextMoveStep(StoreMoveStep.SI_23_OpenDoor);
OpenDoorAndWait(); OpenDoorAndWait();
} }
...@@ -572,7 +572,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -572,7 +572,7 @@ namespace OnlineStore.DeviceLibrary
{ {
if (IOManager.IOValue(IO_Type.SafetyLightCurtains).Equals(IO_VALUE.HIGH)) if (IOManager.IOValue(IO_Type.SafetyLightCurtains).Equals(IO_VALUE.HIGH))
{ {
InStoreLog("送出料盘:SI_13 叉子从库位中返回,进出轴动作至P1(待机点) "); InStoreLog("送出料盘:SI_13 叉子从库位返回,进出轴到P1(待机点) ");
// 5= 入仓位完成(料仓Box把料盘放入对应的库位中,装置还未恢复原始状态) // 5= 入仓位完成(料仓Box把料盘放入对应的库位中,装置还未恢复原始状态)
string posId = StoreMove.MoveParam != null ? StoreMove.MoveParam.PositionNum : ""; string posId = StoreMove.MoveParam != null ? StoreMove.MoveParam.PositionNum : "";
lastPosId = ""; lastPosId = "";
...@@ -699,7 +699,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -699,7 +699,7 @@ namespace OnlineStore.DeviceLibrary
{ {
StoreMove.TimeOutSeconds = 120; StoreMove.TimeOutSeconds = 120;
ACAxisMove(Config.Batch_Axis, targetValue, Config.BatchAxis_P1_Speed); ACAxisMove(Config.Batch_Axis, targetValue, Config.BatchAxis_P1_Speed);
OutStoreLog("出库:SO_03 批量上下料轴下降【" + outDownPosition + "】目标【" + targetValue + "】 "); OutStoreLog("出库:SO_03 批量轴下降【" + outDownPosition + "】目标【" + targetValue + "】 ");
} }
else else
{ {
...@@ -755,7 +755,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -755,7 +755,7 @@ namespace OnlineStore.DeviceLibrary
if (IOManager.IOValue(IO_Type.TrayCheck_Fixture).Equals(IO_VALUE.LOW)) if (IOManager.IOValue(IO_Type.TrayCheck_Fixture).Equals(IO_VALUE.LOW))
{ {
string posId = StoreMove.MoveParam != null ? StoreMove.MoveParam.PositionNum : ""; string posId = StoreMove.MoveParam != null ? StoreMove.MoveParam.PositionNum : "";
LogUtil.error("出库【" + posId + "】过程中叉子已从库位退出,未检测到叉子料盘信号 "); LogUtil.error("出库【" + posId + "】取料完成后,未检测到叉子料盘信号 ");
} }
if (IsHasCompress_Axis || Config.IsHasLocationCylinder.Equals(0)) if (IsHasCompress_Axis || Config.IsHasLocationCylinder.Equals(0))
{ {
......
...@@ -161,7 +161,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -161,7 +161,7 @@ namespace OnlineStore.DeviceLibrary
AutoBaitingStatus = StoreRunStatus.Reset; AutoBaitingStatus = StoreRunStatus.Reset;
StoreMove.NewMove(StoreMoveType.StoreReset); StoreMove.NewMove(StoreMoveType.StoreReset);
StoreMove.NextMoveStep(StoreMoveStep.AUTO_R00_Start); StoreMove.NextMoveStep(StoreMoveStep.AUTO_R00_Start);
LogUtil.info(Name + "开始复位,是否需要入库【" + AutomaticBaiting.IsNeedStartInout + "】,上料轴是否需要回原点【"+AutomaticBaiting.IsNeedAxisHome+"】"); LogUtil.info(Name + "开始复位,是否入库【" + AutomaticBaiting.IsNeedStartInout + "】,上料轴回原点【"+AutomaticBaiting.IsNeedAxisHome+"】");
return true; return true;
} }
...@@ -195,7 +195,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -195,7 +195,7 @@ namespace OnlineStore.DeviceLibrary
if (ACServerManager.GetAlarmStatus(StoreManager.Config.Batch_Axis.DeviceName, StoreManager.Config.Batch_Axis.GetAxisValue()).Equals(1)) if (ACServerManager.GetAlarmStatus(StoreManager.Config.Batch_Axis.DeviceName, StoreManager.Config.Batch_Axis.GetAxisValue()).Equals(1))
{ {
isClearAlarm = true; isClearAlarm = true;
LogUtil.info(Name + "复位中:批量上下料轴清理报警"); LogUtil.debug(Name + "复位中:批量上下料轴清理报警");
ACServerManager.AlarmClear(StoreManager.Config.Batch_Axis.DeviceName, StoreManager.Config.Batch_Axis.GetAxisValue()); ACServerManager.AlarmClear(StoreManager.Config.Batch_Axis.DeviceName, StoreManager.Config.Batch_Axis.GetAxisValue());
Thread.Sleep(100); Thread.Sleep(100);
} }
...@@ -219,7 +219,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -219,7 +219,7 @@ namespace OnlineStore.DeviceLibrary
if (IOManager.IOValue(IO_Type.TrayCheck_LoadMaterial).Equals(IO_VALUE.LOW)) if (IOManager.IOValue(IO_Type.TrayCheck_LoadMaterial).Equals(IO_VALUE.LOW))
//if (ACServerManager.GetLimitPositiveSingle(StoreManager.Config.Batch_Axis).Equals(1)) //if (ACServerManager.GetLimitPositiveSingle(StoreManager.Config.Batch_Axis).Equals(1))
{ {
LogUtil.info(Name + "复位中: 没有料盘,不需要上料,上料轴回0点"); LogUtil.info(Name + "复位中: 没有料盘,不需要上料,上料轴回点");
StoreMove.NextMoveStep(StoreMoveStep.AUTO_R04_AutoBack); StoreMove.NextMoveStep(StoreMoveStep.AUTO_R04_AutoBack);
StoreMove.TimeOutSeconds = 120; StoreMove.TimeOutSeconds = 120;
ACAxisHomeMove(StoreManager.Config.Batch_Axis); ACAxisHomeMove(StoreManager.Config.Batch_Axis);
...@@ -255,7 +255,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -255,7 +255,7 @@ namespace OnlineStore.DeviceLibrary
if (IsNeedStartInout) if (IsNeedStartInout)
{ {
StoreMove.NextMoveStep(StoreMoveStep.AUTO_R03_AutoAxisHome); StoreMove.NextMoveStep(StoreMoveStep.AUTO_R03_AutoAxisHome);
LogUtil.info(Name + "复位中:需要检测是否有料盘,批量轴匀速上升速度【" + StoreManager.Config.Batch_Axis.TargetSpeed + "】"); LogUtil.info(Name + "复位中:检测是否有料盘,批量轴匀速上升【" + StoreManager.Config.Batch_Axis.TargetSpeed + "】");
ACAxisSpeedMove(StoreManager.Config.Batch_Axis, StoreManager.Config.Batch_Axis.TargetSpeed,IO_Type.TrayCheck_LoadMaterial); ACAxisSpeedMove(StoreManager.Config.Batch_Axis, StoreManager.Config.Batch_Axis.TargetSpeed,IO_Type.TrayCheck_LoadMaterial);
} }
else else
...@@ -355,7 +355,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -355,7 +355,7 @@ namespace OnlineStore.DeviceLibrary
if (IOManager.IOValue(IO_Type.SuckingDisc_Air).Equals(IO_VALUE.HIGH)) if (IOManager.IOValue(IO_Type.SuckingDisc_Air).Equals(IO_VALUE.HIGH))
{ {
StoreMove.NextMoveStep(StoreMoveStep.AUTO_I07_BatchAxisUp); StoreMove.NextMoveStep(StoreMoveStep.AUTO_I07_BatchAxisUp);
LogUtil.info(Name + "入料: 批量上下料轴上升速度【" + StoreManager.Config.BatchAxis_SlowSpeed + "】"); LogUtil.info(Name + "入料: 批量轴匀速上升【" + StoreManager.Config.BatchAxis_SlowSpeed + "】");
ACAxisSpeedMove(StoreManager.Config.Batch_Axis, StoreManager.Config.BatchAxis_SlowSpeed, IO_Type.TrayCheck_LoadMaterial); ACAxisSpeedMove(StoreManager.Config.Batch_Axis, StoreManager.Config.BatchAxis_SlowSpeed, IO_Type.TrayCheck_LoadMaterial);
CylinderMove(IO_Type.SuckingDisc_Up, IO_Type.SuckingDisc_Down, true); CylinderMove(IO_Type.SuckingDisc_Up, IO_Type.SuckingDisc_Down, true);
if (StoreManager.Config.Default_TrayWidth.Equals(7)) if (StoreManager.Config.Default_TrayWidth.Equals(7))
...@@ -413,7 +413,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -413,7 +413,7 @@ namespace OnlineStore.DeviceLibrary
{ {
StoreMove.NextMoveStep(StoreMoveStep.AUTO_I08_GetPosId); StoreMove.NextMoveStep(StoreMoveStep.AUTO_I08_GetPosId);
LogUtil.info(Name + "入料: 从服务器获取入库PosId,尺寸:【" + LastWidth + "*" + LastHeight + "】二维码【" + LastCode + "】"); LogUtil.debug(Name + "入料: 从服务器获取入库PosId,尺寸:【" + LastWidth + "*" + LastHeight + "】二维码【" + LastCode + "】");
GetInStorePosId(ProcessMsg()); GetInStorePosId(ProcessMsg());
StoreMove.WaitList.Add(WaitResultInfo.WaitTime(3000)); StoreMove.WaitList.Add(WaitResultInfo.WaitTime(3000));
...@@ -434,12 +434,12 @@ namespace OnlineStore.DeviceLibrary ...@@ -434,12 +434,12 @@ namespace OnlineStore.DeviceLibrary
if (StoreManager.Store.StoreMove.MoveType.Equals(StoreMoveType.InStore) || (!LastPosId.Equals(""))) if (StoreManager.Store.StoreMove.MoveType.Equals(StoreMoveType.InStore) || (!LastPosId.Equals("")))
{ {
StoreMove.NextMoveStep(StoreMoveStep.AUTO_I09_WaitTrayLeave); StoreMove.NextMoveStep(StoreMoveStep.AUTO_I09_WaitTrayLeave);
LogUtil.info(Name + "入料: 开始入【" + LastPosId + "】,等待料盘拿走"); LogUtil.info(Name + "入料: 开始入【" + LastPosId + "】,等待料盘拿走");
StoreMove.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.SuckingDisc_Air, IO_VALUE.LOW)); StoreMove.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.SuckingDisc_Air, IO_VALUE.LOW));
} }
else else
{ {
LogUtil.info(Name + "入料: 未获取到PosID或启动入库失败,尺寸:【" + LastWidth + "*" + LastHeight + "】将料盘送出,等待料盘拿走"); LogUtil.info(Name + "入料: 入库失败,尺寸:【" + LastWidth + "*" + LastHeight + "】将料盘送出,等待料盘拿走");
SendTrayOut(); SendTrayOut();
} }
} }
...@@ -487,7 +487,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -487,7 +487,7 @@ namespace OnlineStore.DeviceLibrary
addHeight = StoreManager.Config.LastTrayAddHeight; addHeight = StoreManager.Config.LastTrayAddHeight;
} }
LastHeight += addHeight; LastHeight += addHeight;
LogUtil.info(Name + "入料: 计算盘高:上升前【" + StartMovePosition + "】实时【" + EndMovePosition + "】补充【" + addHeight + "】计算后高度【" + LastHeight + "】"); LogUtil.debug(Name + "入料: 计算盘高:上升前【" + StartMovePosition + "】实时【" + EndMovePosition + "】补充【" + addHeight + "】计算后高度【" + LastHeight + "】");
if (LastHeight < 0) if (LastHeight < 0)
{ {
LastHeight = StoreManager.Config.GetDefaultHeight(); LastHeight = StoreManager.Config.GetDefaultHeight();
......
...@@ -284,7 +284,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -284,7 +284,7 @@ namespace OnlineStore.DeviceLibrary
} }
else else
{ {
LogUtil.info("扫到二维码:" + LastCode); LogUtil.debug("扫到二维码:" + LastCode);
} }
IOManager.IOMove(IO_Type.CameraLight_Power, IO_VALUE.LOW); IOManager.IOMove(IO_Type.CameraLight_Power, IO_VALUE.LOW);
// StoreManager.Store.onCodeReceived(message); // StoreManager.Store.onCodeReceived(message);
...@@ -368,14 +368,14 @@ namespace OnlineStore.DeviceLibrary ...@@ -368,14 +368,14 @@ namespace OnlineStore.DeviceLibrary
if (StoreManager.Store.storeRunStatus.Equals(StoreRunStatus.Wait)) if (StoreManager.Store.storeRunStatus.Equals(StoreRunStatus.Wait))
{ {
LogUtil.info(Name + "收到二维码【 " + message + "】,设备未启动,不需要发送服务器"); LogUtil.info(Name + "【 " + message + "】,设备未启动,不需要发送服务器");
return; return;
} }
//开启服务器日志 //开启服务器日志
//HttpHelper.isLog = 1; //HttpHelper.isLog = 1;
LogUtil.info(Name + "收到二维码【 " + message + "】,发送给服务器获取入库PosID"); LogUtil.info(Name + "【 " + message + "】,发送给服务器获取入库PosID");
//发送扫码内容到服务器进行入库操作 //发送扫码内容到服务器进行入库操作
Operation operation = StoreManager.Store.getLineBoxStatus(); Operation operation = StoreManager.Store.getLineBoxStatus();
operation.op = 1; operation.op = 1;
...@@ -386,7 +386,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -386,7 +386,7 @@ namespace OnlineStore.DeviceLibrary
if (StoreManager.Store.autoNext && (!String.IsNullOrEmpty(autoposId))) if (StoreManager.Store.autoNext && (!String.IsNullOrEmpty(autoposId)))
{ {
operation.data.Add(ParamDefine.inPos, autoposId); operation.data.Add(ParamDefine.inPos, autoposId);
LogUtil.info("添加自动入库库位号:"+autoposId); LogUtil.debug("添加自动入库库位号:"+autoposId);
} }
string server = ConfigAppSettings.GetValue(Setting_Init.http_server); string server = ConfigAppSettings.GetValue(Setting_Init.http_server);
Operation resultOperation = HttpHelper.Post(StoreManager.GetPostApi(server), operation, false); Operation resultOperation = HttpHelper.Post(StoreManager.GetPostApi(server), operation, false);
...@@ -428,7 +428,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -428,7 +428,7 @@ namespace OnlineStore.DeviceLibrary
if (position == null) if (position == null)
{ //出入库没有找到服务器发送的库位,需要打印日志方便查询原因 { //出入库没有找到服务器发送的库位,需要打印日志方便查询原因
WarnMsg = ResourceControl.GetString(ResourceControl.InStoreNoPosition, "入库未找到库位:") + "【" + message + "】【" + posId + "】 "; WarnMsg = ResourceControl.GetString(ResourceControl.InStoreNoPosition, "入库未找到库位:") + "【" + message + "】【" + posId + "】 ";
LogUtil.error("收到服务器入库命令:入库未找到库位:二维码【" + message + "】库位【" + posId + "】"); LogUtil.error("服务器反馈 入库未找到库位:二维码【" + message + "】库位【" + posId + "】");
return; return;
} }
//TODO:判断BOX是否处于可以入库状态,如果调试或急停中,需要返回给服务器; //TODO:判断BOX是否处于可以入库状态,如果调试或急停中,需要返回给服务器;
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!