Commit 6484b6f1 LN

bug修改

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