Commit 5e93ab72 LN

与流水线通信格式修改。

1 个父辈 a8c49f96
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
<add key="HumitureControllerType" value="0"/> <add key="HumitureControllerType" value="0"/>
<add key="UseAIOBOX" value="1"/> <add key="UseAIOBOX" value="1"/>
<!--流水线地址和端口配置--> <!--流水线地址和端口配置-->
<add key ="LineServerIp" value ="192.168.1.113"/> <add key ="LineServerIp" value ="192.168.1.110"/>
<add key ="LineServerPort" value ="5246"/> <add key ="LineServerPort" value ="5246"/>
<!--是否调试状态--> <!--是否调试状态-->
<add key ="IsInDebug" value ="1"/> <add key ="IsInDebug" value ="1"/>
......
...@@ -1363,7 +1363,8 @@ namespace OnlineStore.ACSingleStore ...@@ -1363,7 +1363,8 @@ namespace OnlineStore.ACSingleStore
{ {
ss = StoreStatus.Debugging; ss = StoreStatus.Debugging;
} }
LineConnect.SendHeart(StoreManager.Config.Id, StoreManager.Config.CID, (int)ss, (int)StoreRunStatus.Runing, hasTray,(int)StoreAlarmType.None); StoreSendBean bean = new StoreSendBean(StoreManager.Config.Id, StoreManager.Config.CID, (int)ss, (int)StoreRunStatus.Runing, hasTray, (int)StoreAlarmType.None);
LineConnect.SendHeart(bean);
} }
private void chbDebug_CheckedChanged(object sender, EventArgs e) private void chbDebug_CheckedChanged(object sender, EventArgs e)
......
...@@ -77,12 +77,12 @@ namespace OnlineStore.Common ...@@ -77,12 +77,12 @@ namespace OnlineStore.Common
private static List<string> lasErrorLogList = new List<string>(); private static List<string> lasErrorLogList = new List<string>();
private static int errCount = 5; private static int errCount = 5;
public static void error(ILog log, string errorMsg,int type) public static void error(ILog log, string errorMsg,int type,int spanSeconds=10)
{ {
if (lastErrorLogTime.ContainsKey(type)) if (lastErrorLogTime.ContainsKey(type))
{ {
TimeSpan span = DateTime.Now - lastErrorLogTime[type]; TimeSpan span = DateTime.Now - lastErrorLogTime[type];
if (span.TotalSeconds < 10) if (span.TotalSeconds < spanSeconds)
{ {
return; return;
} }
......
...@@ -154,7 +154,7 @@ namespace OnlineStore.Common ...@@ -154,7 +154,7 @@ namespace OnlineStore.Common
if (m_clientSocket != null) if (m_clientSocket != null)
{ {
m_clientSocket.Close(); m_clientSocket.Close();
LogUtil.info(LOGGER, "Socket closed!"); LogUtil.debug(LOGGER, "Socket closed!");
} }
}catch(Exception ex) }catch(Exception ex)
{ {
...@@ -176,9 +176,9 @@ namespace OnlineStore.Common ...@@ -176,9 +176,9 @@ namespace OnlineStore.Common
catch (Exception ex) catch (Exception ex)
{ {
isInProcess = false; isInProcess = false;
LogUtil.error("重连处理出错:" + ex.ToString()); LogUtil.error(LOGGER, "重连处理出错:" + ex.ToString(),9,180);
} }
} }
/// <summary> /// <summary>
/// 断开连接 /// 断开连接
......
...@@ -115,7 +115,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -115,7 +115,7 @@ namespace OnlineStore.DeviceLibrary
Alarm(StoreAlarmType.SuddenStop, "1", WarnMsg, StoreMoveType.None); Alarm(StoreAlarmType.SuddenStop, "1", WarnMsg, StoreMoveType.None);
} }
} }
} }
} }
/// <summary> /// <summary>
...@@ -148,7 +148,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -148,7 +148,7 @@ namespace OnlineStore.DeviceLibrary
public override bool StartRun() public override bool StartRun()
{ {
LogUtil.info(LOGGER, StoreName + "开始启动,启动时间:" + StartTime.ToString()); LogUtil.info(LOGGER, StoreName + "开始启动,启动时间:" + StartTime.ToString());
autoNext = false; autoNext = false;
mainTimer.Enabled = false; mainTimer.Enabled = false;
alarmType = StoreAlarmType.None; alarmType = StoreAlarmType.None;
...@@ -184,7 +184,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -184,7 +184,7 @@ namespace OnlineStore.DeviceLibrary
} }
else else
{ {
if ( suddenBtn.Equals(IO_VALUE.LOW)) if (suddenBtn.Equals(IO_VALUE.LOW))
{ {
LogUtil.error(LOGGER, " (" + StoreName + ")启动出现错误:急停没开 !启动失败!"); LogUtil.error(LOGGER, " (" + StoreName + ")启动出现错误:急停没开 !启动失败!");
} }
...@@ -202,7 +202,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -202,7 +202,7 @@ namespace OnlineStore.DeviceLibrary
{ {
isNoAirCheck = false; isNoAirCheck = false;
isInSuddenDown = false; isInSuddenDown = false;
WarnMsg = ""; WarnMsg = "";
CurrInOutACount = 0; CurrInOutACount = 0;
CurrInOutCount = 0; CurrInOutCount = 0;
IOManager.IOMove(IO_Type.Alarm_HddLed, IO_VALUE.LOW); IOManager.IOMove(IO_Type.Alarm_HddLed, IO_VALUE.LOW);
...@@ -214,9 +214,9 @@ namespace OnlineStore.DeviceLibrary ...@@ -214,9 +214,9 @@ namespace OnlineStore.DeviceLibrary
StoreMove.NextMoveStep(StoreMoveStep.BOX_H_InOutBack); StoreMove.NextMoveStep(StoreMoveStep.BOX_H_InOutBack);
ACAxisHomeMove(Config.InOut_Axis); ACAxisHomeMove(Config.InOut_Axis);
LogUtil.info(LOGGER, StoreName + "开始原点返回,先把进出轴回原点"); LogUtil.info(LOGGER, StoreName + "开始原点返回,先把进出轴回原点");
StoreMove.WaitList.Add(WaitResultInfo.WaitTime(2000)); StoreMove.WaitList.Add(WaitResultInfo.WaitTime(2000));
} }
public void MoveToP1() public void MoveToP1()
{ {
//压紧轴回原点,叉子回到P1,关闭门旋转轴和升降轴回到P1 //压紧轴回原点,叉子回到P1,关闭门旋转轴和升降轴回到P1
...@@ -231,7 +231,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -231,7 +231,7 @@ namespace OnlineStore.DeviceLibrary
public override void Reset() public override void Reset()
{ {
Reset(true); Reset(true);
} }
public void Reset(bool isNeedClearAuto) public void Reset(bool isNeedClearAuto)
{ {
CurrInOutCount = 0; CurrInOutCount = 0;
...@@ -251,7 +251,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -251,7 +251,7 @@ namespace OnlineStore.DeviceLibrary
ACServerManager.SuddenStop(Config.UpDown_Axis.DeviceName, Config.UpDown_Axis.GetAxisValue()); ACServerManager.SuddenStop(Config.UpDown_Axis.DeviceName, Config.UpDown_Axis.GetAxisValue());
ACServerManager.SuddenStop(Config.InOut_Axis.DeviceName, Config.InOut_Axis.GetAxisValue()); ACServerManager.SuddenStop(Config.InOut_Axis.DeviceName, Config.InOut_Axis.GetAxisValue());
isInSuddenDown = false; isInSuddenDown = false;
isNoAirCheck = false; isNoAirCheck = false;
alarmType = StoreAlarmType.None; alarmType = StoreAlarmType.None;
storeRunStatus = StoreRunStatus.Reset; storeRunStatus = StoreRunStatus.Reset;
storeStatus = StoreStatus.ResetMove; storeStatus = StoreStatus.ResetMove;
...@@ -268,7 +268,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -268,7 +268,7 @@ namespace OnlineStore.DeviceLibrary
if (IsHasCompress_Axis || Config.IsHasLocationCylinder.Equals(0)) if (IsHasCompress_Axis || Config.IsHasLocationCylinder.Equals(0))
{ {
InoutStartReset(); InoutStartReset();
} }
else else
{ {
...@@ -283,11 +283,11 @@ namespace OnlineStore.DeviceLibrary ...@@ -283,11 +283,11 @@ namespace OnlineStore.DeviceLibrary
{ {
string portName = Config.InOut_Axis.DeviceName; string portName = Config.InOut_Axis.DeviceName;
int slvAddr = Config.InOut_Axis.GetAxisValue(); int slvAddr = Config.InOut_Axis.GetAxisValue();
StoreMove.NextMoveStep(StoreMoveStep.BOX_H_InOutBack); StoreMove.NextMoveStep(StoreMoveStep.BOX_H_InOutBack);
LogUtil.info(LOGGER, StoreName + "复位中,进出轴开始原点返回"); LogUtil.info(LOGGER, StoreName + "复位中,进出轴开始原点返回");
ACAxisHomeMove(Config.InOut_Axis); ACAxisHomeMove(Config.InOut_Axis);
StoreMove.WaitList.Add(WaitResultInfo.WaitTime(2000)); StoreMove.WaitList.Add(WaitResultInfo.WaitTime(2000));
} }
/// <summary> /// <summary>
/// 复位处理 /// 复位处理
...@@ -304,7 +304,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -304,7 +304,7 @@ namespace OnlineStore.DeviceLibrary
} }
switch (StoreMove.MoveStep) switch (StoreMove.MoveStep)
{ {
case StoreMoveStep.BOX_H_LocationCylinderBack: case StoreMoveStep.BOX_H_LocationCylinderBack:
InoutStartReset(); InoutStartReset();
break; break;
case StoreMoveStep.BOX_H_InOutMove: case StoreMoveStep.BOX_H_InOutMove:
...@@ -335,7 +335,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -335,7 +335,7 @@ namespace OnlineStore.DeviceLibrary
LogUtil.info(LOGGER, StoreName + "复位中: 压紧轴,旋转轴,上下轴开始 原点返回"); LogUtil.info(LOGGER, StoreName + "复位中: 压紧轴,旋转轴,上下轴开始 原点返回");
StoreMove.NextMoveStep(StoreMoveStep.BOX_H_OtherAxisBack); StoreMove.NextMoveStep(StoreMoveStep.BOX_H_OtherAxisBack);
if (IsHasCompress_Axis) if (IsHasCompress_Axis)
{ {
ACAxisHomeMove(Config.Comp_Axis); ACAxisHomeMove(Config.Comp_Axis);
} }
ACAxisHomeMove(Config.Middle_Axis); ACAxisHomeMove(Config.Middle_Axis);
...@@ -347,8 +347,8 @@ namespace OnlineStore.DeviceLibrary ...@@ -347,8 +347,8 @@ namespace OnlineStore.DeviceLibrary
LogUtil.info(LOGGER, StoreName + "复位中:旋转轴运动到P1,上下轴走到P1,压紧轴到P1!"); LogUtil.info(LOGGER, StoreName + "复位中:旋转轴运动到P1,上下轴走到P1,压紧轴到P1!");
ACAxisMove(Config.Middle_Axis, Config.MiddleAxis_P1_Position, Config.MiddleAxis_P1_Speed); ACAxisMove(Config.Middle_Axis, Config.MiddleAxis_P1_Position, Config.MiddleAxis_P1_Speed);
ACAxisMove(Config.UpDown_Axis, Config.UpDownAxis_DoorOPosition_P1, Config.UpDownAxis_P1_Speed); ACAxisMove(Config.UpDown_Axis, Config.UpDownAxis_DoorOPosition_P1, Config.UpDownAxis_P1_Speed);
ComMoveToPosition(Config.CompressAxis_P1_Position,Config.CompAxis_P1_Speed); ComMoveToPosition(Config.CompressAxis_P1_Position, Config.CompAxis_P1_Speed);
break; break;
case StoreMoveStep.BOX_H_MiddleAxisToP1: case StoreMoveStep.BOX_H_MiddleAxisToP1:
LogUtil.info(LOGGER, StoreName + "复位完成"); LogUtil.info(LOGGER, StoreName + "复位完成");
...@@ -365,7 +365,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -365,7 +365,7 @@ namespace OnlineStore.DeviceLibrary
StoreMove.NextMoveStep(StoreMoveStep.BOX_M_H_TOP1_CompressHome); StoreMove.NextMoveStep(StoreMoveStep.BOX_M_H_TOP1_CompressHome);
LogUtil.info(LOGGER, StoreName + "到待机状态,压紧轴回原点,关闭舱门"); LogUtil.info(LOGGER, StoreName + "到待机状态,压紧轴回原点,关闭舱门");
if (IsHasCompress_Axis) if (IsHasCompress_Axis)
{ {
ACAxisHomeMove(Config.Comp_Axis); ACAxisHomeMove(Config.Comp_Axis);
} }
//关闭舱门 //关闭舱门
...@@ -376,7 +376,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -376,7 +376,7 @@ namespace OnlineStore.DeviceLibrary
LogUtil.info(LOGGER, StoreName + "复位中:旋转轴运动到P1,上下轴走到P1,压紧轴到P1!"); LogUtil.info(LOGGER, StoreName + "复位中:旋转轴运动到P1,上下轴走到P1,压紧轴到P1!");
ACAxisMove(Config.Middle_Axis, Config.MiddleAxis_P1_Position, Config.MiddleAxis_P1_Speed); ACAxisMove(Config.Middle_Axis, Config.MiddleAxis_P1_Position, Config.MiddleAxis_P1_Speed);
ACAxisMove(Config.UpDown_Axis, Config.UpDownAxis_DoorOPosition_P1, Config.UpDownAxis_P1_Speed); ACAxisMove(Config.UpDown_Axis, Config.UpDownAxis_DoorOPosition_P1, Config.UpDownAxis_P1_Speed);
ComMoveToPosition(Config.CompressAxis_P1_Position,Config.CompAxis_P1_Speed); ComMoveToPosition(Config.CompressAxis_P1_Position, Config.CompAxis_P1_Speed);
break; break;
case StoreMoveStep.BOX_M_H_TOP1_OtherAxisToP1: case StoreMoveStep.BOX_M_H_TOP1_OtherAxisToP1:
LogUtil.info(LOGGER, StoreName + "到待机状态完成"); LogUtil.info(LOGGER, StoreName + "到待机状态完成");
...@@ -391,31 +391,31 @@ namespace OnlineStore.DeviceLibrary ...@@ -391,31 +391,31 @@ namespace OnlineStore.DeviceLibrary
default: break; default: break;
} }
} }
private void ComMoveToPosition(int targetPosition ,int targetSpeed) private void ComMoveToPosition(int targetPosition, int targetSpeed)
{ {
if (IsHasCompress_Axis) if (IsHasCompress_Axis)
{ {
ACAxisMove(Config.Comp_Axis, targetPosition, targetSpeed); ACAxisMove(Config.Comp_Axis, targetPosition, targetSpeed);
} }
} }
public void OpenDoor(bool IsWait=true) public void OpenDoor(bool IsWait = true)
{ {
if (Config.HasDoor.Equals(1)) if (Config.HasDoor.Equals(1))
{ {
Thread.Sleep(60); Thread.Sleep(60);
IOManager.IOMove(IO_Type.Door_Down, IO_VALUE.LOW); IOManager.IOMove(IO_Type.Door_Down, IO_VALUE.LOW);
IOManager.IOMove(IO_Type.Door_Up, IO_VALUE.HIGH); IOManager.IOMove(IO_Type.Door_Up, IO_VALUE.HIGH);
if (IsWait) if (IsWait)
{ {
StoreMove.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.Door_Down, IO_VALUE.LOW)); StoreMove.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.Door_Down, IO_VALUE.LOW));
StoreMove.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.Door_Up, IO_VALUE.HIGH)); StoreMove.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.Door_Up, IO_VALUE.HIGH));
} }
} }
} }
public void CloseDoor(bool IsWait=true) public void CloseDoor(bool IsWait = true)
{ {
if (Config.HasDoor.Equals(1)) if (Config.HasDoor.Equals(1))
{ {
...@@ -475,7 +475,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -475,7 +475,7 @@ namespace OnlineStore.DeviceLibrary
LogUtil.info(LOGGER, StoreName + "原点返回中 :压紧轴,旋转轴,上下轴开始原点返回"); LogUtil.info(LOGGER, StoreName + "原点返回中 :压紧轴,旋转轴,上下轴开始原点返回");
StoreMove.NextMoveStep(StoreMoveStep.BOX_H_OtherAxisBack); StoreMove.NextMoveStep(StoreMoveStep.BOX_H_OtherAxisBack);
if (IsHasCompress_Axis) if (IsHasCompress_Axis)
{ {
ACAxisHomeMove(Config.Comp_Axis); ACAxisHomeMove(Config.Comp_Axis);
} }
ACAxisHomeMove(Config.Middle_Axis); ACAxisHomeMove(Config.Middle_Axis);
...@@ -487,7 +487,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -487,7 +487,7 @@ namespace OnlineStore.DeviceLibrary
LogUtil.info(LOGGER, StoreName + "回原点:旋转轴运动到P1,上下轴到P1,压紧轴到P1!"); LogUtil.info(LOGGER, StoreName + "回原点:旋转轴运动到P1,上下轴到P1,压紧轴到P1!");
ACAxisMove(Config.Middle_Axis, Config.MiddleAxis_P1_Position, Config.MiddleAxis_P1_Speed); ACAxisMove(Config.Middle_Axis, Config.MiddleAxis_P1_Position, Config.MiddleAxis_P1_Speed);
ACAxisMove(Config.UpDown_Axis, Config.UpDownAxis_DoorOPosition_P1, Config.UpDownAxis_P1_Speed); ACAxisMove(Config.UpDown_Axis, Config.UpDownAxis_DoorOPosition_P1, Config.UpDownAxis_P1_Speed);
ComMoveToPosition(Config.CompressAxis_P1_Position,Config.CompAxis_P1_Speed); ComMoveToPosition(Config.CompressAxis_P1_Position, Config.CompAxis_P1_Speed);
break; break;
case StoreMoveStep.BOX_H_MiddleAxisToP1: case StoreMoveStep.BOX_H_MiddleAxisToP1:
LogUtil.info(LOGGER, StoreName + "回原点完成"); LogUtil.info(LOGGER, StoreName + "回原点完成");
...@@ -673,7 +673,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -673,7 +673,7 @@ namespace OnlineStore.DeviceLibrary
StoreMove.EndMove(); StoreMove.EndMove();
StopMove(true); StopMove(true);
storeStatus = StoreStatus.SuddenStop; storeStatus = StoreStatus.SuddenStop;
} }
} }
private bool InProcess = false; private bool InProcess = false;
//private DateTime preProcessTime = DateTime.Now; //private DateTime preProcessTime = DateTime.Now;
...@@ -935,10 +935,10 @@ namespace OnlineStore.DeviceLibrary ...@@ -935,10 +935,10 @@ namespace OnlineStore.DeviceLibrary
} }
} }
} }
} }
} }
public void TimerProcess() public void TimerProcess()
{ {
try try
...@@ -950,7 +950,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -950,7 +950,7 @@ namespace OnlineStore.DeviceLibrary
ShowTimeLog("BusyMoveProcess"); ShowTimeLog("BusyMoveProcess");
} }
else if (storeRunStatus.Equals(StoreRunStatus.Runing)) else if (storeRunStatus.Equals(StoreRunStatus.Runing))
{ {
ShowTimeLog("判断是否需要出入库"); ShowTimeLog("判断是否需要出入库");
AutoResetProcess(); AutoResetProcess();
...@@ -965,7 +965,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -965,7 +965,7 @@ namespace OnlineStore.DeviceLibrary
LOGGER.Error(StoreName + "定时处理出错", ex); LOGGER.Error(StoreName + "定时处理出错", ex);
} }
} }
private DateTime preIoTimerOutTime = DateTime.Now; private DateTime preIoTimerOutTime = DateTime.Now;
/// <summary> /// <summary>
...@@ -1183,7 +1183,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -1183,7 +1183,7 @@ namespace OnlineStore.DeviceLibrary
#region 入库命令处理 #region 入库命令处理
private void ReviceInStoreProcess(string message, Operation resultOperation) private void ReviceInStoreProcess(string message, Operation resultOperation)
{ {
Dictionary<string, string> data = resultOperation.data; Dictionary<string, string> data = resultOperation.data;
...@@ -1215,8 +1215,8 @@ namespace OnlineStore.DeviceLibrary ...@@ -1215,8 +1215,8 @@ namespace OnlineStore.DeviceLibrary
} }
//TODO:判断BOX是否处于可以入库状态,如果调试或急停中,需要返回给服务器; //TODO:判断BOX是否处于可以入库状态,如果调试或急停中,需要返回给服务器;
if (CanStarInOut()) if (CanStarInOut())
{ {
InOutStoreParam param = new InOutStoreParam(message, posId, plateH, plateW, 0); InOutStoreParam param = new InOutStoreParam(message, posId, plateH, plateW, 0);
StartInStoreMove(param); StartInStoreMove(param);
//如果当前正在出入库中,需要记录下来,等待空闲时执行 //如果当前正在出入库中,需要记录下来,等待空闲时执行
LogUtil.info(LOGGER, StoreName + " 收到服务器入库命令:库位号【" + posId + "】二维码【" + message + "】 开始入库!"); LogUtil.info(LOGGER, StoreName + " 收到服务器入库命令:库位号【" + posId + "】二维码【" + message + "】 开始入库!");
...@@ -1224,35 +1224,94 @@ namespace OnlineStore.DeviceLibrary ...@@ -1224,35 +1224,94 @@ namespace OnlineStore.DeviceLibrary
else else
{ {
LogUtil.info(LOGGER, StoreName + " 收到服务器入库命令:库位号【" + posId + "】二维码【" + message + "】 正在忙碌中,无法入库!"); LogUtil.info(LOGGER, StoreName + " 收到服务器入库命令:库位号【" + posId + "】二维码【" + message + "】 正在忙碌中,无法入库!");
} }
} }
} }
public bool ReviceLineCheckInStoreCMD(string posId, string plateH, string plateW, string message)
{
string logName = "入库库位验证【 " + message + "】【" + posId + "】:";
try
{
if (storeRunStatus.Equals(StoreRunStatus.Wait))
{
LogUtil.info(LOGGER, logName+ " 设备未启动,验证失败");
return false;
}
// CodeMsg = "收到二维码【 " + message + "】,发送给服务器获取入库PosID";
LogUtil.debug(LOGGER, logName+"发送给服务器验证入库PosID");
//发送扫码内容到服务器进行入库操作
Operation operation = getLineBoxStatus();
operation.op = 1;
operation.data = new Dictionary<string, string>() { { "code", message }, { "boxId", StoreID.ToString() } };
operation.data.Add("inPos", posId);
string server = ConfigAppSettings.GetValue(Setting_Init.http_server);
Operation resultOperation = HttpHelper.Post(StoreManager.GetPostApi(server), operation, false);
if (resultOperation == null)
{
// CodeMsg = "二维码【" + message + "】没有收到服务器反馈";
LogUtil.info(LOGGER, logName + " 没有收到服务器反馈 ");
}
else if (!string.IsNullOrEmpty(resultOperation.msg))
{
//如果有提示消息,直接显示提示
LogUtil.info(LOGGER, logName + "服务器反馈 :" + resultOperation.msg);
}
else if (resultOperation.op.Equals(1))
{
LogUtil.info(LOGGER, logName + " 成功");
return true;
}
}
catch (Exception ex)
{
LogUtil.info(LOGGER, logName + " 出错:" + ex.ToString());
}
return false;
}
public void ReviceLineInStoreCMD(string posId, string plateH, string plateW, string message) public void ReviceLineInStoreCMD(string posId, string plateH, string plateW, string message)
{ {
string logName = "流水线入库命令【 " + message + "】【" + posId + "】:";
if (!LineConnect.WaitInStoreList.Contains(posId))
{
LogUtil.error(logName + "库位未验证通过,重新验证库位");
bool result = ReviceLineCheckInStoreCMD(posId, plateH, plateW, message);
if (!result)
{
return;
}
}
else
{
LineConnect.WaitInStoreList.Remove(posId);
}
//根据发送的posId获取位置列表 //根据发送的posId获取位置列表
ACStorePosition position = CSVPositionReader<ACStorePosition>.GetPositon(posId); ACStorePosition position = CSVPositionReader<ACStorePosition>.GetPositon(posId);
if (position == null) if (position == null)
{ //出入库没有找到服务器发送的库位,需要打印日志方便查询原因 { //出入库没有找到服务器发送的库位,需要打印日志方便查询原因
WarnMsg = "入库未找到库位:二维码【" + message + "】库位【" + posId + "】 "; WarnMsg = "入库未找到库位:二维码【" + message + "】库位【" + posId + "】 ";
LogUtil.error(LOGGER, "收到流水线入库:入库未找到库位:二维码【" + message + "】库位【" + posId + "】"); LogUtil.error(logName + "未找到库位");
LogUtil.info(LOGGER, "收到流水线入库:入库未找到库位:二维码【" + message + "】库位【" + posId + "】"); // LogUtil.info(LOGGER, "收到流水线入库:入库未找到库位:二维码【" + message + "】库位【" + posId + "】");
return; return;
} }
//TODO:判断BOX是否处于可以入库状态,如果调试或急停中,需要返回给服务器; //TODO:判断BOX是否处于可以入库状态,如果调试或急停中,需要返回给服务器;
if (CanStarInOut()) if (CanStarInOut())
{ {
InOutStoreParam param = new InOutStoreParam(message, posId, plateH, plateW, 0); InOutStoreParam param = new InOutStoreParam(message, posId, plateH, plateW, 0);
LogUtil.info(logName + " 开始入库!");
StartInStoreMove(param); StartInStoreMove(param);
//如果当前正在出入库中,需要记录下来,等待空闲时执行 //如果当前正在出入库中,需要记录下来,等待空闲时执行
LogUtil.info(LOGGER, StoreName + " 收到流水线入库:库位号【" + posId + "】二维码【" + message + "】 开始入库!");
} }
else else
{ {
LogUtil.info(LOGGER, StoreName + " 收到流水线入库:库位号【" + posId + "】二维码【" + message + "】 正在忙碌中,无法入库!"); LogUtil.info(logName + " 正在忙碌中,无法入库!");
} }
} }
#endregion #endregion
...@@ -1388,7 +1447,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -1388,7 +1447,7 @@ namespace OnlineStore.DeviceLibrary
#endregion #endregion
#region 与服务器通信定时器,每1秒向服务器通知一次状态,同时执行出库操作 #region 与服务器通信定时器,每1秒向服务器通知一次状态,同时执行出库操作
private string CodeMsg = ""; private string CodeMsg = "";
private bool isInProcess = false; private bool isInProcess = false;
public void server_connect_timer_Tick(object sender, EventArgs e) public void server_connect_timer_Tick(object sender, EventArgs e)
...@@ -1408,7 +1467,8 @@ namespace OnlineStore.DeviceLibrary ...@@ -1408,7 +1467,8 @@ namespace OnlineStore.DeviceLibrary
{ {
ss = (int)StoreStatus.Debugging; ss = (int)StoreStatus.Debugging;
} }
LineConnect.SendHeart(Config.Id, Config.CID, (int)ss, (int)storeRunStatus, hasTray, (int)alarmType); StoreSendBean store=new StoreSendBean(Config.Id,Config.CID, (int)ss, (int)storeRunStatus, hasTray, (int)alarmType);
LineConnect.SendHeart(store);
} }
if (StoreManager.IsConnectServer) if (StoreManager.IsConnectServer)
{ {
......
...@@ -654,7 +654,11 @@ namespace OnlineStore.DeviceLibrary ...@@ -654,7 +654,11 @@ namespace OnlineStore.DeviceLibrary
{ {
ss = (int)StoreStatus.Debugging; ss = (int)StoreStatus.Debugging;
} }
LineConnect.OutStoreEnd(Config.Id, Config.CID, (int)storeStatus, (int)storeRunStatus, hasTray,(int)alarmType, StoreMove.MoveParam.PositionNum, StoreMove.MoveParam.PlateH,StoreMove.MoveParam.PlateW); StoreSendBean store = new StoreSendBean(Config.Id, Config.CID, (int)storeStatus, (int)storeRunStatus, hasTray, (int)alarmType);
store.PosId = StoreMove.MoveParam.PositionNum;
store.PlateH = StoreMove.MoveParam.PlateH;
store.PlateW = StoreMove.MoveParam.PlateW;
LineConnect.OutStoreEnd(store);
} }
else if (StoreMove.MoveStep == StoreMoveStep.SO_13_GoBack) else if (StoreMove.MoveStep == StoreMoveStep.SO_13_GoBack)
{ {
......
...@@ -9,8 +9,9 @@ namespace OnlineStore.DeviceLibrary ...@@ -9,8 +9,9 @@ namespace OnlineStore.DeviceLibrary
{ {
public class LineConnect public class LineConnect
{ {
private static int ClientKeepSecond = 10;
private static TcpClient client = null; private static TcpClient client = null;
public static List<string> WaitInStoreList = new List<string>();
public static void StartConnect() public static void StartConnect()
{ {
string lineServer = ConfigAppSettings.GetValue(Setting_Init.LineServerIp); string lineServer = ConfigAppSettings.GetValue(Setting_Init.LineServerIp);
...@@ -21,6 +22,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -21,6 +22,7 @@ namespace OnlineStore.DeviceLibrary
return; return;
} }
client = new TcpClient(); client = new TcpClient();
bool result = client.StartConnect(lineServer, linePort, HandlerMsg,2000); bool result = client.StartConnect(lineServer, linePort, HandlerMsg,2000);
} }
...@@ -45,7 +47,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -45,7 +47,7 @@ namespace OnlineStore.DeviceLibrary
return seq; return seq;
} }
public static void SendHeart(int id,string cid,int ss,int runs,int doorHasTray,int alarmType) public static void SendHeart(StoreSendBean store)
{ {
if (client == null) if (client == null)
{ {
...@@ -53,24 +55,16 @@ namespace OnlineStore.DeviceLibrary ...@@ -53,24 +55,16 @@ namespace OnlineStore.DeviceLibrary
} }
try try
{ {
List<object> paramList = new List<object>(); store.Cmd = cmd_heart;
paramList.Add(cmd_heart); string heartMsg = ToParamStr(store);
paramList.Add(id);
paramList.Add(cid);
paramList.Add(nextSeq());
paramList.Add(ss);
paramList.Add(runs);
paramList.Add(doorHasTray);
paramList.Add(alarmType);
string heartMsg = ToParamStr(paramList);
client.send(heartMsg); client.send(heartMsg);
}catch(Exception ex) } catch (Exception ex)
{ {
LogUtil.error("SendHeart 出错:"+ex.ToString()); LogUtil.error("SendHeart 出错:" + ex.ToString());
} }
} }
public static void OutStoreEnd(int id, string cid, int ss, int runs, int doorHasTray, int alarmType,string posid, string plateH, string plateW)
public static void OutStoreEnd(StoreSendBean store)
{ {
if (client == null) if (client == null)
{ {
...@@ -78,71 +72,74 @@ namespace OnlineStore.DeviceLibrary ...@@ -78,71 +72,74 @@ namespace OnlineStore.DeviceLibrary
} }
try try
{ {
List<object> paramList = new List<object>(); store.Cmd = cmd_outend;
paramList.Add(cmd_outend); string msg = ToParamStr(store);
paramList.Add(id); client.send(msg);
paramList.Add(cid);
paramList.Add(nextSeq());
paramList.Add(ss);
paramList.Add(runs);
paramList.Add(doorHasTray);
paramList.Add(alarmType);
paramList.Add(posid);
paramList.Add(plateH);
paramList.Add(plateW);
//string heartMsg = cmd_outend + cmd_spilt + id + cmd_spilt + cid + cmd_spilt + nextSeq() + cmd_spilt + ss + cmd_spilt + runs + cmd_spilt + doorHasTray+ cmd_spilt + posid + cmd_spilt;
//string msg = heartMsg + posid + cmd_spilt + plateH + cmd_spilt + plateW + cmd_spilt + "\r";
string msg = ToParamStr(paramList);
client.send(msg );
} }
catch (Exception ex) catch (Exception ex)
{ {
LogUtil.error("OutStoreEnd 出错:" + ex.ToString()); LogUtil.error("OutStoreEnd 出错:" + ex.ToString());
} }
} }
private static string ToParamStr(StoreSendBean store)
{
return JsonHelper.SerializeObject(store)+"\r";
}
private static string ToParamStr(List<object> paramList) private static string ToParamStr(List<object> paramList)
{ {
string result = ""; string result = "";
foreach(object str in paramList) foreach (object str in paramList)
{ {
result += str + cmd_spilt.ToString(); result += str + cmd_spilt.ToString();
} }
return result+"\r"; return result + "\r";
} }
private static void HandlerMsg(string message) private static void HandlerMsg(string message)
{ {
try try
{ {
string[] msgArray = message.Split(cmd_spilt); message = message.Replace("\r", "");
if (msgArray.Length > 2) StoreReviceBean reviceInfo = JsonHelper.DeserializeJsonToObject<StoreReviceBean>(message);
//string[] msgArray = message.Split(cmd_spilt);
if (reviceInfo == null)
{
LogUtil.debug("收到消息:" + message + ",解析失败");
}
else
{ {
string cmd = msgArray[0]; string cmd = reviceInfo.Cmd;
int canStartOut = Convert.ToInt32(msgArray[1]); CanOutStore = reviceInfo.CanOutStore.Equals(1);
CanOutStore = canStartOut.Equals(1);
LastUpdateTime = DateTime.Now; LastUpdateTime = DateTime.Now;
if (cmd.Equals(cmd_startIn)) if (cmd.Equals(cmd_startIn))
{ {
LogUtil.info("收到流水线入库消息:" + message); LogUtil.info("收到流水线入库消息:" + message);
string posId = msgArray[2]; //string posId = reviceInfo.PosId;
string plateH = msgArray[3]; //string plateH = reviceInfo.PlateH
string plateW = msgArray[4]; //string plateW = msgArray[4];
string code = msgArray[5]; //string code = msgArray[5];
StoreManager.Store.ReviceLineInStoreCMD(posId, plateH, plateW, code); StoreManager.Store.ReviceLineInStoreCMD(reviceInfo.PosId,reviceInfo.PlateH,reviceInfo.PlateW,reviceInfo.WareCode);
} }
else if (cmd.Equals(cmd_updateDebug)) else if (cmd.Equals(cmd_updateDebug))
{ {
int isDebug = Convert.ToInt32(msgArray[2]); int isDebug = reviceInfo.IsDebug;
LogUtil.info("收到流水线更改调试状态=" + isDebug); LogUtil.info("收到流水线更改调试状态=" + isDebug);
StoreManager.Store.IsDebug = isDebug.Equals(1) ? true : false; StoreManager.Store.IsDebug = isDebug.Equals(1) ? true : false;
ConfigAppSettings.SaveValue(Setting_Init.IsInDebug, isDebug); ConfigAppSettings.SaveValue(Setting_Init.IsInDebug, isDebug);
LogUtil.info("切换调试状态= " + isDebug + ";"); LogUtil.info("切换调试状态= " + isDebug + ";");
} }
else else if (cmd.Equals(cmd_checStartIn))
{ {
LogUtil.debug("收到消息:" + message); LogUtil.info("收到流水线入库库位验证消息:" + message);
bool result = StoreManager.Store.ReviceLineCheckInStoreCMD(reviceInfo.PosId, reviceInfo.PlateH, reviceInfo.PlateW, reviceInfo.WareCode);
if (result)
{
LineConnect.WaitInStoreList.Add(reviceInfo.PosId);
}
} }
} }
} }
catch (Exception ex) catch (Exception ex)
...@@ -151,12 +148,13 @@ namespace OnlineStore.DeviceLibrary ...@@ -151,12 +148,13 @@ namespace OnlineStore.DeviceLibrary
} }
} }
public static char cmd_spilt = ';'; public static char cmd_spilt = ';';
private static string cmd_heart = "heart"; public static string cmd_heart = "heart";
private static string cmd_outend = "outend"; private static string cmd_outend = "outend";
private static string cmd_startIn = "starIn"; private static string cmd_startIn = "starIn";
private static string cmd_updateDebug = "updateDebug"; private static string cmd_updateDebug = "updateDebug";
private static bool CanOutStore = false; private static bool CanOutStore = false;
public static DateTime LastUpdateTime = new DateTime(0); public static DateTime LastUpdateTime = new DateTime(0);
public static string cmd_checStartIn = "cmd_checStartIn";
public static bool IsConnect() public static bool IsConnect()
{ {
if (client == null) if (client == null)
...@@ -173,11 +171,45 @@ namespace OnlineStore.DeviceLibrary ...@@ -173,11 +171,45 @@ namespace OnlineStore.DeviceLibrary
public static bool CanStartOut() public static bool CanStartOut()
{ {
TimeSpan span = DateTime.Now - LastUpdateTime; TimeSpan span = DateTime.Now - LastUpdateTime;
if (span.TotalSeconds < 3 && CanOutStore) if (span.TotalSeconds < ClientKeepSecond && CanOutStore)
{ {
return true; return true;
} }
return false; return false;
} }
} }
public class StoreReviceBean
{
public string Cmd = "";
public int CanOutStore = 0;
public string PosId = "";
public string PlateH = "0";
public string PlateW = "0";
public string WareCode = "";
public int IsDebug = 0;
}
public class StoreSendBean
{
public StoreSendBean(int id, string cid, int ss, int runs, int doorHasTray, int alarmType)
{
this.StoreId = id;
this.Cid = cid;
this.SStatus = ss;
this.SRunStatus = runs;
this.DoorHasTray = doorHasTray;
this.AlarmType = alarmType;
this.Seq = LineConnect.nextSeq();
}
public string Cmd =LineConnect. cmd_heart;
public int StoreId = 0;
public string Cid = "";
public int Seq = 0;
public int SStatus = 0;
public int SRunStatus = 0;
public int DoorHasTray = 0;
public int AlarmType = 0;
public string PosId = "";
public string PlateH = "0";
public string PlateW = "0";
}
} }
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!