Commit 6484b6f1 LN

bug修改

1 个父辈 7576c1ca
...@@ -260,7 +260,7 @@ namespace OnlineStore ...@@ -260,7 +260,7 @@ namespace OnlineStore
{ {
if (ResourceMap != null) if (ResourceMap != null)
{ {
if (!ResourceMap.ContainsKey(CurrLanguage)) if (!ResourceMap.ContainsKey(language))
{ {
if (ShowMsg) if (ShowMsg)
{ {
...@@ -270,9 +270,9 @@ namespace OnlineStore ...@@ -270,9 +270,9 @@ namespace OnlineStore
} }
else else
{ {
if (ResourceMap[CurrLanguage].ContainsKey(id.Trim())) if (ResourceMap[language].ContainsKey(id.Trim()))
{ {
return ResourceMap[CurrLanguage][id]; return ResourceMap[language][id];
} }
else else
{ {
......
...@@ -95,4 +95,10 @@ DeCodeType=解码类型,0=halcon,1=zxing解码 西安料仓解析方式。2= ...@@ -95,4 +95,10 @@ DeCodeType=解码类型,0=halcon,1=zxing解码 西安料仓解析方式。2=
20200114 在RC1258-ACSingleStore 的基础上新建分支,扫码枪改为datalogic扫码枪。 20200114 在RC1258-ACSingleStore 的基础上新建分支,扫码枪改为datalogic扫码枪。
20200210中英文功能修改,与服务器通信增加msgEn,表示英文提示消息。
\ No newline at end of file \ No newline at end of file
20200210中英文功能修改,与服务器通信增加msgEn,表示英文提示消息。
20200222
1.发给服务器的英文错误,英文内容和中文一样。
2.自动出入库修改,先当前库位入库,然后出库,再继续下一个库位。
3.扫码枪重连修改。
\ No newline at end of file \ No newline at end of file
...@@ -12,6 +12,10 @@ namespace OnlineStore.Common ...@@ -12,6 +12,10 @@ namespace OnlineStore.Common
{ {
public class TcpClient public class TcpClient
{ {
private static string ServerIp = "";
private static int ServerPort = 0;
private System.Timers.Timer ReConnectTimer = null;
public static readonly ILog LOGGER = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); public static readonly ILog LOGGER = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
public delegate void HandleMessage(string message); public delegate void HandleMessage(string message);
...@@ -77,13 +81,30 @@ namespace OnlineStore.Common ...@@ -77,13 +81,30 @@ namespace OnlineStore.Common
#endregion #endregion
} }
/// <summary> /// <summary>
/// 是否在运行中
/// </summary>
/// <returns></returns>
public bool IsRun()
{
return ReConnectTimer.Enabled;
}
/// <summary>
/// 连接服务器 /// 连接服务器
/// </summary> /// </summary>
public bool connect(string serverIP, int serverPort, HandleMessage HandleMessage) public bool StartConnect(string serverIP, int serverPort, HandleMessage HandleMessage, int ReConnectMs = 0)
{ {
m_clientSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); m_clientSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
IPEndPoint remoteEndPoint = new IPEndPoint(IPAddress.Parse(serverIP), serverPort); IPEndPoint remoteEndPoint = new IPEndPoint(IPAddress.Parse(serverIP), serverPort);
onReceived = HandleMessage;
ServerIp = serverIP;
ServerPort = serverPort;
ReConnectTimer = new System.Timers.Timer();
ReConnectTimer.Interval = ReConnectMs;
if (ReConnectMs > 0)
{
ReConnectTimer.AutoReset = true;
ReConnectTimer.Elapsed += ReConnectTimer_Elapsed;
}
try try
{ {
m_clientSocket.Connect(remoteEndPoint); m_clientSocket.Connect(remoteEndPoint);
...@@ -92,6 +113,7 @@ namespace OnlineStore.Common ...@@ -92,6 +113,7 @@ namespace OnlineStore.Common
m_clientSocket.BeginReceive(m_receiveBuffer, 0, m_receiveBuffer.Length, 0, new AsyncCallback(ReceiveCallBack), null); m_clientSocket.BeginReceive(m_receiveBuffer, 0, m_receiveBuffer.Length, 0, new AsyncCallback(ReceiveCallBack), null);
onReceived = HandleMessage; onReceived = HandleMessage;
LogUtil.info(LOGGER, "Connect to " + serverIP + ":" + serverPort + " success!"); LogUtil.info(LOGGER, "Connect to " + serverIP + ":" + serverPort + " success!");
ReConnectTimer.Start();
return true; return true;
} }
else else
...@@ -101,25 +123,78 @@ namespace OnlineStore.Common ...@@ -101,25 +123,78 @@ namespace OnlineStore.Common
} }
catch (Exception ex) catch (Exception ex)
{ {
LogUtil.error(LOGGER,"Connect to " + serverIP + ":" + serverPort + " fail!" + ex.ToString(),3); LogUtil.error(LOGGER, "Connect to " + serverIP + ":" + serverPort + " fail!" + ex.ToString(), 3);
m_clientSocket = null; m_clientSocket = null;
} }
ReConnectTimer.Start();
return false; return false;
} }
private bool isInProcess = false;
private void ReConnectTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
try
{
if (isInProcess)
{
return;
}
isInProcess = true;
if (m_clientSocket != null)
{
if (m_clientSocket.Connected)
{
isInProcess = false;
return;
}
}
try
{
if (m_clientSocket != null)
{
m_clientSocket.Close();
LogUtil.debug(LOGGER, "Socket closed!");
}
}
catch (Exception ex)
{
LogUtil.error("m_clientSocket.Close Error" + ex.ToString());
}
m_clientSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
IPEndPoint remoteEndPoint = new IPEndPoint(IPAddress.Parse(ServerIp), ServerPort);
m_clientSocket.Connect(remoteEndPoint);
if (m_clientSocket.Connected)
{
m_clientSocket.BeginReceive(m_receiveBuffer, 0, m_receiveBuffer.Length, 0, new AsyncCallback(ReceiveCallBack), null);
LogUtil.info(LOGGER, "Connect to " + ServerIp + ":" + ServerPort + " success!");
}
isInProcess = false;
}
catch (Exception ex)
{
isInProcess = false;
LogUtil.error(LOGGER, "重连处理出错:" + ex.ToString(), 9);
}
}
/// <summary> /// <summary>
/// 断开连接 /// 断开连接
/// </summary> /// </summary>
public void close() public void close()
{ {
ReConnectTimer.Stop();
if (m_clientSocket != null) if (m_clientSocket != null)
{ {
m_clientSocket.Close(); m_clientSocket.Close();
LogUtil.info(LOGGER,"Socket closed!"); LogUtil.info(LOGGER, "Socket closed!");
} }
else else
{ {
LogUtil.error(LOGGER,"No socket is running!"); LogUtil.error(LOGGER, "No socket is running!");
} }
} }
...@@ -135,7 +210,7 @@ namespace OnlineStore.Common ...@@ -135,7 +210,7 @@ namespace OnlineStore.Common
{ {
m_clientSocket.Send(sendBuffer); m_clientSocket.Send(sendBuffer);
LogUtil.debug(LOGGER,"Send >> " + strSendData); LogUtil.debug(LOGGER, "Send >> " + strSendData);
} }
} }
...@@ -153,8 +228,9 @@ namespace OnlineStore.Common ...@@ -153,8 +228,9 @@ namespace OnlineStore.Common
} }
catch (Exception ex) catch (Exception ex)
{ {
LogUtil.error(LOGGER,"socket received error:" + ex.ToString(),4); LogUtil.error(LOGGER, "socket received error:" + ex.ToString(), 4);
} }
} }
} }
} }
...@@ -1743,7 +1743,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -1743,7 +1743,7 @@ namespace OnlineStore.DeviceLibrary
{ {
LOGGER.Error("定时给服务器发送消息出错:", ex); LOGGER.Error("定时给服务器发送消息出错:", ex);
} }
dlScanSocket.TimerCheck(); // dlScanSocket.TimerCheck();
} }
HumitureController.QueryData(); HumitureController.QueryData();
HumidityProcess(); HumidityProcess();
......
...@@ -793,28 +793,28 @@ namespace OnlineStore.DeviceLibrary ...@@ -793,28 +793,28 @@ namespace OnlineStore.DeviceLibrary
} }
if (storeMoveType.Equals(StoreMoveType.InStore)) if (storeMoveType.Equals(StoreMoveType.InStore))
{ {
int newIndex = autoPositionIndex - 1; // int newIndex = autoPositionIndex - 1;
//if (autoJiange == 0) //if (autoJiange == 0)
//{ //{
// newIndex = autoPositionIndex; // newIndex = autoPositionIndex;
//} //}
if (newIndex < 0) //if (newIndex < 0)
{ //{
if (AutoStartIndex >= 0 && AutoStartIndex < PositionNumList.Count) // if (AutoStartIndex >= 0 && AutoStartIndex < PositionNumList.Count)
{ // {
newIndex = AutoStartIndex; // newIndex = AutoStartIndex;
LogUtil.info(LOGGER, StoreName + "下一个索引不存在,重新开始自动出入库,索引【" + AutoStartIndex + "】"); // LogUtil.info(LOGGER, StoreName + "下一个索引不存在,重新开始自动出入库,索引【" + AutoStartIndex + "】");
} // }
else // else
{ // {
autoNext = false; // autoNext = false;
autoMsg = "自动出入库结束!"; // autoMsg = "自动出入库结束!";
LogUtil.info(LOGGER, StoreName + "下一个索引不存在,自动 出入库结束!"); // LogUtil.info(LOGGER, StoreName + "下一个索引不存在,自动 出入库结束!");
} // }
} //}
else //else
{ //{
autoPositionIndex = newIndex; // autoPositionIndex = newIndex;
string posid = PositionNumList[autoPositionIndex]; string posid = PositionNumList[autoPositionIndex];
//判断是否需要重置 //判断是否需要重置
...@@ -838,7 +838,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -838,7 +838,7 @@ namespace OnlineStore.DeviceLibrary
autoMsg = "自动出库:" + posid; autoMsg = "自动出库:" + posid;
StartOutStoreMove(new InOutStoreParam("", posid)); StartOutStoreMove(new InOutStoreParam("", posid));
} }
} //}
} }
else if (storeMoveType.Equals(StoreMoveType.OutStore)) else if (storeMoveType.Equals(StoreMoveType.OutStore))
{ {
...@@ -857,9 +857,10 @@ namespace OnlineStore.DeviceLibrary ...@@ -857,9 +857,10 @@ namespace OnlineStore.DeviceLibrary
LogUtil.info(LOGGER, StoreName + "下一个索引不存在,自动 出入库结束!"); LogUtil.info(LOGGER, StoreName + "下一个索引不存在,自动 出入库结束!");
} }
} }
else if(autoNext)
{ {
string posid = PositionNumList[newIndex]; autoPositionIndex = newIndex;
string posid = PositionNumList[autoPositionIndex];
//判断是否需要重置 //判断是否需要重置
if (CurrInOutACount >= Config.Box_ResetACount) if (CurrInOutACount >= Config.Box_ResetACount)
{ {
......
...@@ -40,7 +40,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -40,7 +40,7 @@ namespace OnlineStore.DeviceLibrary
{ {
scannerSocket = new TcpClient(); scannerSocket = new TcpClient();
} }
result = scannerSocket.connect(ScannerIP, ScannerPort, new TcpClient.HandleMessage(onCodeReceived)); result = scannerSocket.StartConnect(ScannerIP, ScannerPort, new TcpClient.HandleMessage(onCodeReceived),2000);
if (result) if (result)
{ {
isScannerRun = true; isScannerRun = true;
...@@ -53,14 +53,14 @@ namespace OnlineStore.DeviceLibrary ...@@ -53,14 +53,14 @@ namespace OnlineStore.DeviceLibrary
} }
return result; return result;
} }
public void TimerCheck() //public void TimerCheck()
{ //{
if (!scannerSocket.IsConnected()) // if (!scannerSocket.IsConnected())
{ // {
StartConnect( false ); // StartConnect( false );
LogUtil.info( "重新连接扫码枪【" + ScannerIP + "】 "); // LogUtil.info( "重新连接扫码枪【" + ScannerIP + "】 ");
} // }
} //}
/// <summary> /// <summary>
/// 停止扫码枪 /// 停止扫码枪
/// </summary> /// </summary>
...@@ -101,21 +101,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -101,21 +101,7 @@ namespace OnlineStore.DeviceLibrary
protected virtual void onCodeReceived(string message) protected virtual void onCodeReceived(string message)
{ {
try try
{ {
//message = message.Replace("\r", "");
//message = message.Replace("\n", "");
//char a = (char)02;
//message = message.Replace(a.ToString(), "");
//message = message.Trim();
//if (!string.IsNullOrEmpty(message))
//{
// LogUtil.info("收到DL数据<< \n" + message);
//}
//else
//{
// LogUtil.error("没有收到二维码信息,请重新放入料盘");
// return;
//}
message = message.Trim(); message = message.Trim();
message = message.Replace("\r", ""); message = message.Replace("\r", "");
message = message.Replace("\n", ""); message = message.Replace("\n", "");
......
...@@ -104,7 +104,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -104,7 +104,7 @@ namespace OnlineStore.DeviceLibrary
public string GetRunStr(StoreRunStatus runStatus ) public string GetRunStr(StoreRunStatus runStatus)
{ {
string sta = ResourceControl.GetString(ResourceControl.Run, "运行中"); string sta = ResourceControl.GetString(ResourceControl.Run, "运行中");
string aa = ""; string aa = "";
...@@ -165,7 +165,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -165,7 +165,7 @@ namespace OnlineStore.DeviceLibrary
aa = ResourceControl.GetString(ResourceControl.OutStoreFailed, "出库失败") + "(" + WarnObj.WarnMsg + ")"; aa = ResourceControl.GetString(ResourceControl.OutStoreFailed, "出库失败") + "(" + WarnObj.WarnMsg + ")";
break; break;
} }
if (!aa.Equals("")) if (!String.IsNullOrEmpty(aa))
{ {
return sta + "_" + aa; return sta + "_" + aa;
} }
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!