Commit 16cc676d 几米阳光

1

1 个父辈 b93747cb
......@@ -345,10 +345,10 @@ namespace OnlineStore.AutoInOutStore
}
private void UpdateAutoPosition()
{
int inoutPosition = ACServerManager.GetTargetPosition(inout.DeviceName, inout.GetAxisValue());
if (!txtInOutPosition.Text.Equals(inoutPosition.ToString()))
int autoPosition = ACServerManager.GetTargetPosition(auto.DeviceName, auto.GetAxisValue());
if (!txtAutoPosition.Text.Equals(autoPosition.ToString()))
{
txtInOutPosition.Text = inoutPosition.ToString();
txtAutoPosition.Text = autoPosition.ToString();
}
}
private void btnAutoMove_MouseDown(object sender, MouseEventArgs e)
......
......@@ -334,7 +334,7 @@ namespace OnlineStore.AutoInOutStore
btnBatchInStore.Enabled = !dooIsOpen;
btnGetOutTray.Enabled = !dooIsOpen;
btnStartBatchInStore.Enabled = dooIsOpen;
btnBatchReset.Enabled = dooIsOpen;
btnBatchReset.Enabled = !dooIsOpen;
}
private void ReadPosistion()
......
......@@ -70,7 +70,7 @@ namespace OnlineStore.DeviceLibrary
// ------------------------------------------------------------------------
/// <summary>Response data event. This event is called when new data arrives</summary>
public delegate void ResponseData(string ip, ushort id, byte function, byte[] data,byte[] reviceData);
public delegate void ResponseData(string ip, ushort id, byte function, byte[] data, byte[] reviceData);
/// <summary>Response data event. This event is called when new data arrives</summary>
public event ResponseData OnResponseData;
/// <summary>Exception data event. This event is called when the data is incorrect</summary>
......@@ -106,11 +106,10 @@ namespace OnlineStore.DeviceLibrary
public MasterTcpClient()
{
}
private string IP = "";
public int TimeOutTime = 0;
public MasterTcpClient(string ip, ushort port)
{
this.IP = ip;
TimeOutTime = 2000;
connect(ip, port);
}
......@@ -119,6 +118,7 @@ namespace OnlineStore.DeviceLibrary
{
try
{
OnResponseData = null;
// Connect asynchronous client
socketClient = new Socket(IPAddress.Parse(ip).AddressFamily, SocketType.Stream, ProtocolType.Tcp);
if (TimeOutTime <= 0)
......@@ -127,6 +127,7 @@ namespace OnlineStore.DeviceLibrary
socketClient.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.SendTimeout, _timeout);
socketClient.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReceiveTimeout, _timeout);
socketClient.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.NoDelay, 1);
}
else
{
......@@ -153,11 +154,10 @@ namespace OnlineStore.DeviceLibrary
reviceTimer.Enabled = true;
_connected = true;
}
catch (System.IO.IOException error)
catch (Exception error)
{
LogUtil.info(LOGGER, "Connect to " + ip + ":" + port + " fail!");
_connected = false;
throw (error);
}
}
......@@ -171,7 +171,7 @@ namespace OnlineStore.DeviceLibrary
}
catch (Exception ex)
{
LOGGER.Error("IO模块["+IP+"]出错:" + ex.ToString());
LOGGER.Error("出错:" + ex.ToString());
}
}
......@@ -214,7 +214,7 @@ namespace OnlineStore.DeviceLibrary
}
dataLength = rdata[currStartIndex + lengthIndex];
allLength = lengthIndex + 1 + dataLength ;
allLength = lengthIndex + 1 + dataLength;
byte[] thisData = new byte[allLength];
Array.Copy(rdata, currStartIndex, thisData, 0, allLength);
......@@ -241,7 +241,7 @@ namespace OnlineStore.DeviceLibrary
LogUtil.debug(LOGGER, clientipe.ToString() + "收到数据(无需分包):" + str);
ushort id = BitConverter.ToUInt16(rdata, 0);
byte function = rdata[7];
DataProcess(clientipe.ToString(),id,function,rdata);
DataProcess(clientipe.ToString(), id, function, rdata);
}
}
}
......@@ -295,7 +295,6 @@ namespace OnlineStore.DeviceLibrary
}
catch (SocketException e)
{
LogUtil.error(LOGGER, "IO模块[" + IP + "]接收数据出现错误:" + e.ToString());
if (socketClient != null)
{
socketClient.Close();
......@@ -329,14 +328,8 @@ namespace OnlineStore.DeviceLibrary
{
if (socketClient.Connected)
{
try
{
socketClient.Shutdown(SocketShutdown.Both);
}
catch (Exception ex)
{
LogUtil.error(LOGGER, "IO模块[" + IP + "]dispose出错:" + ex.ToString());
}
try { socketClient.Shutdown(SocketShutdown.Both); }
catch { }
socketClient.Close();
}
socketClient = null;
......@@ -511,7 +504,9 @@ namespace OnlineStore.DeviceLibrary
// ------------------------------------------------------------------------
// Write asynchronous data
private void WriteAsyncData(byte[] write_data, ushort id)
public void WriteAsyncData(byte[] write_data, ushort id)
{
try
{
if (socketClient == null)
{
......@@ -527,7 +522,7 @@ namespace OnlineStore.DeviceLibrary
string str = "";
foreach (byte by in write_data)
{
str = str +" "+ by;
str = str + " " + by;
}
//LogUtil.info( clientipe.ToString()+"发送数据:" + str);
......@@ -537,12 +532,16 @@ namespace OnlineStore.DeviceLibrary
}
catch (SystemException error)
{
LogUtil.error(LOGGER, "IO模块 WriteAsyncData出错:" + error.ToString());
CallException(id, write_data[7], excExceptionConnectionLost, tcpSocketReviceBuffer);
}
}
else CallException(id, write_data[7], excExceptionConnectionLost, tcpSocketReviceBuffer);
}
catch (Exception ex)
{
LOGGER.Error("出错:" + ex.ToString());
}
}
// ------------------------------------------------------------------------
// Write asynchronous data acknowledge
......@@ -560,7 +559,8 @@ namespace OnlineStore.DeviceLibrary
return;
}
IPEndPoint clientipe = (IPEndPoint)socketClient.RemoteEndPoint;
if (result.IsCompleted == false) {
if (result.IsCompleted == false)
{
CallException(0xFF, 0xFF, excExceptionConnectionLost, tcpSocketReviceBuffer);
}
......@@ -587,7 +587,7 @@ namespace OnlineStore.DeviceLibrary
if (function > excExceptionOffset)
{
function -= excExceptionOffset;
CallException(id, function, tcpSocketReviceBuffer[8],tcpSocketReviceBuffer);
CallException(id, function, tcpSocketReviceBuffer[8], tcpSocketReviceBuffer);
}
// ------------------------------------------------------------
// Response data is regular data
......
......@@ -9,7 +9,7 @@ DI,吸盘气缸上升端,SuckingDisc_Up,206,192.168.200.11,0,吸盘气缸上升端,X07,DI-07,0
DI,吸盘气缸下降端,SuckingDisc_Down,207,192.168.200.11,0,吸盘气缸下降端,X08,DI-08,0,
DI,料盘宽度检测1,WidthCheck1,208,192.168.200.11,0,料盘宽度检测1,X09,DI-09,0,
DI,料盘宽度检测2,WidthCheck2,209,192.168.200.11,0,料盘宽度检测2,X10,DI-10,0,
DI,料盘检测1(上料机构),TrayCheck_LoadMaterial ,210,192.168.200.11,0,料盘检测1(上料机构),X11,DI-11,0,
DI,料盘检测1(上料机构),TrayCheck_LoadMaterial,210,192.168.200.11,0,料盘检测1(上料机构),X11,DI-11,0,
DI,上料机构出料检测,OutCheck,211,192.168.200.11,0,上料机构出料检测,X12,DI-12,0,
DI,门锁气缸打开端,BatchDoor_Open,212,192.168.200.11,0,门锁气缸打开端,X13,DI-13,0,
DI,门锁气缸关闭端,BatchDoor_Close,213,192.168.200.11,0,门锁气缸关闭端,X14,DI-14,0,
......@@ -31,10 +31,10 @@ DO,门锁气缸打开SOL,AutoDoor_Open,112,192.168.200.11,0,门锁气缸打开SOL,Y13,DO-13,
DO,门锁气缸关闭SOL,AutoDoor_Close,113,192.168.200.11,0,门锁气缸关闭SOL,Y14,DO-14,0,
,,,114,192.168.200.11,0,,Y15,DO-15,0,
,,,115,192.168.200.11,0,,Y16,DO-16,0,
DI,上料机构门关闭,DoorClose_LoadMaterial,200,192.168.200.12,0,上料机构门关闭,X17,DI-21,0,
DI,气压检测,Airpressure_Check,201,192.168.200.12,0,气压检测,X18,DI-22,0,
DI,吸盘压力确认信号,SuckingDisc_Air,202,192.168.200.12,0,吸盘压力确认信号,X19,DI-23,0,
DI,左侧门关闭,DoorColse_Single,203,192.168.200.12,0,左侧门关闭,X20,DI-24,0,
DI,上料机构门关闭,DoorClose_LoadMaterial,200,192.168.200.12,0,上料机构门关闭,X21,DI-21,0,
DI,气压检测,Airpressure_Check,201,192.168.200.12,0,气压检测,X22,DI-22,0,
DI,吸盘压力确认信号,SuckingDisc_Air,202,192.168.200.12,0,吸盘压力确认信号,X23,DI-23,0,
DI,左侧门关闭,DoorColse_Single,203,192.168.200.12,0,左侧门关闭,X24,DI-24,0,
,,,100,192.168.200.12,0,,Y17,DO-21,0,
,,,101,192.168.200.12,0,,Y18,DO-22,0,
,,,102,192.168.200.12,0,,Y19,DO-23,0,
......@@ -142,5 +142,5 @@ PRO,(轴五)上料轴最大限位,BatchAxis_PositionMax,0,,,,,,,
PRO,(轴五)上料轴P1速度,BatchAxis_P1_Speed,50,,,,,,,
,,,,,,,,,,
,,,,,,,,,,
PRO,IO模块对应的DI数量,IO_DILength,192.168.200.11#16;192.168.200.11#4,,,,,, ,
PRO,模块对应的DO数量,IO_DOLength,192.168.200.11#16;192.168.200.11#4,,,,,,,
PRO,IO模块对应的DI数量,IO_DILength,192.168.200.11#16;192.168.200.12#4,,,,,, ,
PRO,模块对应的DO数量,IO_DOLength,192.168.200.11#16;192.168.200.12#4,,,,,,,
......@@ -86,6 +86,7 @@ namespace OnlineStore.LoadCSVLibrary
Dictionary<string, string> proMap = CSVReaderBase.getConfigProAttributeMap(GetType());
List<string> checkProList = new List<string>(proMap.Keys);//用来检测attribute属性都应该要配置值
List<string> IoTypeList = IO_Type.GetTypeList();
foreach (ConfigBase con in configList)
{
if (con.ProType == ConfigItemType.AXIS || con.ProType == ConfigItemType.PRO)
......@@ -120,7 +121,7 @@ namespace OnlineStore.LoadCSVLibrary
}
else if (con.ProType == ConfigItemType.DI)
{
if (IO_Type.GetTypeList().Contains(con.ProName))
if (IoTypeList.Contains(con.ProName))
{
ConfigIO io = (ConfigIO)con;
if (!DIODeviceNameList.Contains(io.DeviceName) && io.GetIOAddr() >= 0)
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!