From 7ad1324d8ba1b23e5aea57b0c1b09b6a8e945ed4 Mon Sep 17 00:00:00 2001 From: bestlqiang Date: Thu, 3 Dec 2020 15:14:46 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=B2=E5=8F=A3=E5=8F=91=E9=80=81=E6=8C=87?= =?UTF-8?q?=E4=BB=A4=E5=89=8D=E5=85=88=E6=B8=85=E7=90=86=E7=BC=93=E5=86=B2?= =?UTF-8?q?=E5=8C=BA=20=E6=A3=80=E6=B5=8B=E6=B2=BB=E5=85=B7=E5=88=B0?= =?UTF-8?q?=E4=BD=8D=20=E6=A3=80=E6=B5=8B=E6=8E=A8=E5=87=BA=E5=AE=8C?= =?UTF-8?q?=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- LaiPuLaser/CommPortClass.h | 3 ++- LaiPuLaser/CommPortMgr.cpp | 4 ++++ LaiPuLaser/CommPortMgr.h | 1 + LaiPuLaser/Program_SZ_XL.cpp | 1 + LaiPuLaser/Program_SZ_XL_TrackWorkFlow.cpp | 16 ++++++---------- 5 files changed, 14 insertions(+), 11 deletions(-) diff --git a/LaiPuLaser/CommPortClass.h b/LaiPuLaser/CommPortClass.h index f27a218..f4f31ec 100644 --- a/LaiPuLaser/CommPortClass.h +++ b/LaiPuLaser/CommPortClass.h @@ -519,7 +519,8 @@ OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | _dwIOMode,NULL); } return IsOpen(); } - //设置串口 +public: + //设置(重置)串口 virtual bool SetupPort() { if (!IsOpen()) diff --git a/LaiPuLaser/CommPortMgr.cpp b/LaiPuLaser/CommPortMgr.cpp index 3cf375d..6b95e1d 100644 --- a/LaiPuLaser/CommPortMgr.cpp +++ b/LaiPuLaser/CommPortMgr.cpp @@ -118,6 +118,10 @@ void CCommPortMgr::WriteBuf(LPVOID Buffer, DWORD dwBufferLength) //gLogMgr->WriteDebugLog(str); m_Com.Write(Buffer,dwBufferLength); } +void CCommPortMgr::ClearCache() +{ + m_Com.SetupPort(); +} //关闭串口 void CCommPortMgr::Close() { diff --git a/LaiPuLaser/CommPortMgr.h b/LaiPuLaser/CommPortMgr.h index 043b176..ca2d23f 100644 --- a/LaiPuLaser/CommPortMgr.h +++ b/LaiPuLaser/CommPortMgr.h @@ -13,6 +13,7 @@ public: void SetWnd(HWND hWnd); void Write(const char *szBuffer); void WriteBuf(LPVOID Buffer, DWORD dwBufferLength); + void ClearCache();//重置读写缓冲区 CString ReadStr(); CString ReadBuf(char *szBuffer,DWORD dwBufferLength); int Read(LPVOID Buffer, DWORD dwBufferLength); diff --git a/LaiPuLaser/Program_SZ_XL.cpp b/LaiPuLaser/Program_SZ_XL.cpp index 3f625d7..a1eec21 100644 --- a/LaiPuLaser/Program_SZ_XL.cpp +++ b/LaiPuLaser/Program_SZ_XL.cpp @@ -1769,6 +1769,7 @@ bool CProgram_SZ_XL::SendMsgToLoadDevice(ETrackType TrackType, ETrackWorkStep Wo { char Buf[BUF_LEN]; int len = CreatBuf(Buf, StrOn); + m_LoadDeviceCOM.ClearCache(); m_LoadDeviceCOM.WriteBuf(Buf, len); //gLogMgr->WriteDebugLog("SendMsgToLoadDevice: "+StrOn); /* Sleep(100); diff --git a/LaiPuLaser/Program_SZ_XL_TrackWorkFlow.cpp b/LaiPuLaser/Program_SZ_XL_TrackWorkFlow.cpp index 63b21bc..cfc1e81 100644 --- a/LaiPuLaser/Program_SZ_XL_TrackWorkFlow.cpp +++ b/LaiPuLaser/Program_SZ_XL_TrackWorkFlow.cpp @@ -638,6 +638,7 @@ bool CTrackWorkFlow::SendMsgToPlc(ETrackPlcCmd PlcCmd, bool bStopReadMsg) { char * buf = Msg.GetBuffer(); int len = Msg.GetLength(); + m_TrackCOM.ClearCache(); m_TrackCOM.WriteBuf(buf, len);//发送 //gLogMgr->WriteDebugLog("SendMsgToPlc==>" + Msg); } @@ -690,9 +691,9 @@ bool CTrackWorkFlow::PushJigOut() SendMsgToPlc(PlcCmd, false); m_bPushJigOut = false; int cnt = 0; - while (cnt < 50 && (!m_bPushJigOut)) + while (cnt < 200 && (!m_bPushJigOut)) { - Sleep(200); + Sleep(100); cnt++; } if (cnt == 200) @@ -710,7 +711,7 @@ bool CTrackWorkFlow::IsJigOK() { return true; } - return true; + //return true; ETrackPlcCmd PlcCmd; PlcCmd = _ETrack_PlcCmd_Check_Jig_In; @@ -1305,12 +1306,9 @@ void CTrackWorkFlow::UnLoad() logstr.Format("等待[下料机] 运动至[%s]下载具位.", str); gLogMgr->WriteDebugLog(logstr); - - //int cnt = 0; - while ((!m_bPushJigReady) )//&& cnt < 400) + while ((!m_bPushJigReady) ) { Sleep(300); - //cnt++; } /*if (cnt == 400) { @@ -1327,8 +1325,7 @@ void CTrackWorkFlow::UnLoad() { SetCurTrackWorkStep(_ETrack_Step_Unload_Err); return; - } - Sleep(500); + } if (gProgram_SZ_XL->SendMsgToLoadDevice(m_TrackType, _ETrack_Step_PushOut_Finished, true) == false) { SetCurTrackWorkStep(_ETrack_Step_Unload_Err); @@ -1336,7 +1333,6 @@ void CTrackWorkFlow::UnLoad() gLogMgr->WriteDebugLog(Log); return; } - Sleep(500); //平台移动到 送回空治具的位置 MoveToPos(_ETrack_Step_WaitBack); gProgram_SZ_XL->SendMsgToLoadDevice(m_TrackType, _ETrack_Step_WaitBack, true);//告诉下料机,我已到可回治具位