diff --git a/LaiPuLaser/Camera.cpp b/LaiPuLaser/Camera.cpp index 923aa8b..e153449 100644 --- a/LaiPuLaser/Camera.cpp +++ b/LaiPuLaser/Camera.cpp @@ -258,8 +258,8 @@ CMFCPropertyGridProperty *CCamera::CreatGridProperty() pPropertie->WriteRead(true);//读取保存的属性 //添加属性显示 - PropertyName = _T("视场2基准坐标x"); - Description = _T("CCD2 的视场基准点相对于平台原点的坐标(单位:mm)"); + PropertyName = _T("视场2相对坐标x"); + Description = _T("CCD2 的视场中心相对于CCD1中心的坐标(单位:mm)"); CMFCPropertyGridProperty* p1 = new CMFCPropertyGridProperty(PropertyName, (_variant_t)m_Coord2.x, Description); pGroup->AddSubItem(p1); @@ -277,8 +277,8 @@ CMFCPropertyGridProperty *CCamera::CreatGridProperty() pPropertie->WriteRead(true);//读取保存的属性 //添加属性显示 - PropertyName = _T("视场2基准坐标y"); - Description = _T("CCD2 的视场基准点相对于平台原点的坐标(单位:mm)"); + PropertyName = _T("视场2相对坐标y"); + Description = _T("CCD2 的视场中心相对于CCD1中心的坐标(单位:mm)"); CMFCPropertyGridProperty* p1 = new CMFCPropertyGridProperty(PropertyName, (_variant_t)m_Coord2.y, Description); pGroup->AddSubItem(p1); @@ -288,7 +288,7 @@ CMFCPropertyGridProperty *CCamera::CreatGridProperty() { //添加属性变量映射 - Name = _T("m_Size_w");//变量名字 + Name = _T("m_Size_w_pix");//变量名字 CPropertie *pPropertie = new CPropertie; pPropertie->SetpVal((void*)&m_Size.w); pPropertie->SetType(_PROP_TYPE_DOUBLE); @@ -299,7 +299,7 @@ CMFCPropertyGridProperty *CCamera::CreatGridProperty() //添加属性显示 PropertyName = _T("视场宽度"); - Description = _T("CCD 视场的实际宽度(单位:mm)"); + Description = _T("CCD 视场的实际像素宽度(单位:像素)"); CMFCPropertyGridProperty* p1 = new CMFCPropertyGridProperty(PropertyName, (_variant_t)m_Size.w, Description); pGroup->AddSubItem(p1); @@ -307,7 +307,7 @@ CMFCPropertyGridProperty *CCamera::CreatGridProperty() } { //添加属性变量映射 - Name = _T("m_Size_h");//变量名字 + Name = _T("m_Size_h_pix");//变量名字 CPropertie *pPropertie = new CPropertie; pPropertie->SetpVal((void*)&m_Size.h); pPropertie->SetType(_PROP_TYPE_DOUBLE); @@ -318,7 +318,7 @@ CMFCPropertyGridProperty *CCamera::CreatGridProperty() //添加属性显示 PropertyName = _T("视场高度"); - Description = _T("CCD 视场的实际高度(单位:mm)"); + Description = _T("CCD 视场的实际像素高度(单位:像素)"); CMFCPropertyGridProperty* p1 = new CMFCPropertyGridProperty(PropertyName, (_variant_t)m_Size.h, Description); pGroup->AddSubItem(p1); @@ -348,6 +348,7 @@ void CCamera::Draw(CDC* pDC) void CCamera::SetCoord(Dbxy pt) { m_Coord = pt; + //m_Coord2=pt+ //强制保存所有的属性到文件 gDevicePropertieMgr.SaveAllPropertie(); } @@ -377,7 +378,7 @@ Dbxy CCamera::GetCoord() { if (m_CamIndex != 0) { - return m_Coord2; + return m_Coord+m_Coord2; } else { @@ -410,13 +411,6 @@ Dbxy CCamera::CCDcoord2Platformcoord(Dbxy CCDpt) LogStr.Format(_T("CCDcoord2Platformcoord : CCD 返回值[x] = [%0.3f] ,[y] = [%0.3f]"),CCDpt.x,CCDpt.y); gLogMgr->WriteDebugLog(LogStr); - //像素坐标转换为mm 单位坐标----------------------- - if(m_bPixCoord) - { - CCDpt.x *= m_OnePixDis; - CCDpt.y *= m_OnePixDis; - } - if(((CCDpt.x<0)||(CCDpt.x>m_Size.w))||((CCDpt.y<0)||(CCDpt.y>m_Size.h)))//避免错误的返回值 { CString str = _T("定位抓取失败"); @@ -424,7 +418,15 @@ Dbxy CCamera::CCDcoord2Platformcoord(Dbxy CCDpt) Msg.SetMsg(str); throw Msg; } - + //像素坐标转换为mm 单位坐标----------------------- + if (m_bPixCoord) + { + CCDpt.x = CCDpt.x - (m_Size.w / 2); + CCDpt.y = (m_Size.h / 2)- CCDpt.y; + + CCDpt.x *= m_OnePixDis; + CCDpt.y *= m_OnePixDis; + } LogStr.Format(_T("[MM_Coordx] = [%0.3f] ,[MM_Coordy] = [%0.3f]"),CCDpt.x,CCDpt.y); gLogMgr->WriteDebugLog(LogStr); @@ -444,11 +446,11 @@ Dbxy CCamera::CCDcoord2Platformcoord(Dbxy CCDpt) pt.x -= PlatformPt.x; pt.y -= PlatformPt.y; #else - Dbxy CameraCoord = m_Coord; //GetCenterPt(); - if (m_CamIndex != 0) + Dbxy CameraCoord = GetCoord(); //GetCenterPt(); + /*if (m_CamIndex != 0) { CameraCoord = m_Coord2; - } + }*/ LogStr.Format(_T("[CameraCoord.x] = [%0.3f] ,[CameraCoord.y] = [%0.3f]"),CameraCoord.x,CameraCoord.y); gLogMgr->WriteDebugLog(LogStr); @@ -459,14 +461,17 @@ Dbxy CCamera::CCDcoord2Platformcoord(Dbxy CCDpt) } LogStr.Format(_T("[PlatformCoord.x] = [%0.3f] ,[PlatformCoord.y] = [%0.3f]"),PlatformPt.x,PlatformPt.y); gLogMgr->WriteDebugLog(LogStr); - CameraCoord.x = CameraCoord.x - PlatformPt.x; - CameraCoord.y = CameraCoord.y + PlatformPt.y; - LogStr.Format(_T("[CameraCoord_Now.x] = [%0.3f] ,[CameraCoord_Now.y] = [%0.3f]"),CameraCoord.x,CameraCoord.y); + + Dbxy TheoryPt; + TheoryPt.x = CameraCoord.x - PlatformPt.x; + TheoryPt.y = CameraCoord.y + PlatformPt.y; + + LogStr.Format(_T("[TheoryPtCoord_Now.x] = [%0.3f] ,[TheoryPtCoord_Now.y] = [%0.3f]"),CameraCoord.x,CameraCoord.y); gLogMgr->WriteDebugLog(LogStr); Dbxy pt; - pt.x = CameraCoord.x + CCDpt.x; - pt.y = CameraCoord.y - CCDpt.y; + pt.x = TheoryPt.x + CCDpt.x; + pt.y = TheoryPt.y + CCDpt.y; LogStr.Format(_T("[CatchPt.x] = [%0.3f] ,[CatchPt.y] = [%0.3f]"),pt.x,pt.y); gLogMgr->WriteDebugLog(LogStr); @@ -481,8 +486,8 @@ bool CCamera::CatchPtToPlatformcoord(Dbxy &pt) if(!m_bCatch)//不实际抓取 { ret = true; - CatchPt.x = 1296; - CatchPt.y = 972; + CatchPt.x = 1296; + CatchPt.y = 972; } else { diff --git a/LaiPuLaser/Camera.h b/LaiPuLaser/Camera.h index cb72c8b..6dee568 100644 --- a/LaiPuLaser/Camera.h +++ b/LaiPuLaser/Camera.h @@ -33,9 +33,10 @@ protected: bool m_bLeftTop;//基准点是否为左上角(false 为左下角) bool m_bPixCoord;//相机抓取的是否为像素坐标(基恩士返回的是mm 单位的值) +public: Dbxy m_Coord;//CCD 视场基准点相对于平台原点的坐标值(一般是左上角,或者左下角) Dbxy m_Coord2;//信利双头,有两个相机,此为CCD2坐标 - DbSize m_Size;//CCD 视场范围的实际尺寸(用来计算抓取定位的坐标值) + DbSize m_Size=DbSize(2592,1944);//CCD 视场范围的实际尺寸(用来计算抓取定位的坐标值) bool m_bRotatoPtByAngle;//是否根据相机的安装角度修正抓取结果 double m_Angle;//安装角度,相对于电机的X 轴(360 度角) diff --git a/LaiPuLaser/CommonFlowMgr.cpp b/LaiPuLaser/CommonFlowMgr.cpp index 26353e9..30c488d 100644 --- a/LaiPuLaser/CommonFlowMgr.cpp +++ b/LaiPuLaser/CommonFlowMgr.cpp @@ -1071,7 +1071,7 @@ bool CCommonFlowMgr::NormalMarkByPciCard(bool bSel, int times, int CyclicTimes) return false; } //移动到第一个area (不等待移动结束) -void CCommonFlowMgr::MoveToFirstArea() +void CCommonFlowMgr::MoveToFirstArea(Dbxy offset) { gLogMgr->WriteDebugLog("Fuc---->MoveToFirstArea"); CWorkCmdContainer CmdContainer; @@ -1096,8 +1096,8 @@ void CCommonFlowMgr::MoveToFirstArea() { Dbxy AreaRealBasePt = AreaVec[0].GetRealBasePt();//移动到实际位置 Dbxy MovePt;//移动点= area 的理论点 - MovePt.x = AreaRealBasePt.x; - MovePt.y = AreaRealBasePt.y; + MovePt.x = AreaRealBasePt.x+offset.x; + MovePt.y = AreaRealBasePt.y+offset.y; CWorkCmdMovePlatformXY *pCmd = new CWorkCmdMovePlatformXY(); pCmd->MoveToTargetPt(MovePt, TargetPt); pCmd->InWorkState(); @@ -1117,7 +1117,7 @@ bool CCommonFlowMgr::MultipleAreaMark(CProduct &Product, bool bSel) gLogMgr->WriteDebugLog("Fuc---->MultipleAreaMark : bSel = " + Bool2Str(bSel)); //先移动到第一个area (不等待移动结束) - MoveToFirstArea(); + MoveToFirstArea(Product.GetProductBasePt()); //搜集加工数据(这里比较耗费时间) gMarkAreaMgr->CollectWorkData(bSel, Product); @@ -1197,8 +1197,9 @@ bool CCommonFlowMgr::MultipleAreaMark(CProduct &Product, bool bSel) { Dbxy AreaRealBasePt = (*iter).GetRealBasePt();//移动到实际位置 Dbxy MovePt;//移动点= area 的理论点 - MovePt.x = AreaRealBasePt.x; - MovePt.y = AreaRealBasePt.y; + MovePt = AreaRealBasePt + Product.GetProductBasePt(); + /*MovePt.x = AreaRealBasePt.x; + MovePt.y = AreaRealBasePt.y;*/ CWorkCmdMovePlatformXY *pCmd = new CWorkCmdMovePlatformXY(); pCmd->MoveToTargetPt(MovePt, TargetPt); pCmd->InWorkState();//工作速度 @@ -1379,7 +1380,8 @@ void CCommonFlowMgr::CameraCatchTwoMark(CProduct &Product) Dbxy MarkPt2; if (gObjComponentMgr->GetTwoMarkPt(MarkPt1, MarkPt2))//从ObjComponent 中获取定位点 { - Product.SetTheoryMarkPt(MarkPt1, MarkPt2);//设置定位点 + Dbxy BasePt = Product.GetProductBasePt(); + Product.SetTheoryMarkPt(MarkPt1+BasePt, MarkPt2+BasePt);//设置定位点 CameraCatchMarkExt(Product); } else//没有两个定位点 @@ -1396,7 +1398,7 @@ bool CCommonFlowMgr::CameraCatchMark3(CProduct &Product) //获取mark 坐标的大致位置 Dbxy MarkPt3; //移动目标点(ccd 的中心) - Dbxy CameraPt = Camera.GetCenterPt(); + Dbxy CameraPt = Camera.GetCoord(); CWorkCmdInvoker Invoker; CWorkCmdContainer &CmdContainer = CWorkCmdContainer::GetInstance();//指令集 @@ -1413,21 +1415,15 @@ bool CCommonFlowMgr::CameraCatchMark3(CProduct &Product) CmdContainer.AddCmd(pCmd); } //如果有mark3 先识别mark3 - Product.SetbHasMarkPt3(false); + //Product.SetbHasMarkPt3(false); if (gObjComponentMgr->GetMark3Pt(MarkPt3)) { Product.SetbHasMarkPt3(true); - Product.SetTheoryMark3Pt(MarkPt3); + Product.SetTheoryMark3Pt(MarkPt3+Product.GetProductBasePt()); //移动mark 3 到CCD 中心 { CWorkCmdMovePlatformXY *pCmd = new CWorkCmdMovePlatformXY(); - Dbxy P2CatchMarkPos = MarkPt3; - if (Product.IsbNewAddProduct())//改造新增工件抓取定位时,需要偏移到位. - { - Dbxy NPoffset = GetNPOffset(); - P2CatchMarkPos.x += NPoffset.x; - P2CatchMarkPos.y += NPoffset.y; - } + Dbxy P2CatchMarkPos = MarkPt3 + Product.GetProductBasePt(); pCmd->MoveToTargetPt(P2CatchMarkPos, CameraPt); CmdContainer.AddCmd(pCmd); } @@ -1479,7 +1475,7 @@ bool CCommonFlowMgr::CameraCatchMarkExt(CProduct &Product) Product.GetMarkCoord(MarkPt1, MarkPt2); //移动目标点(ccd 的中心) - Dbxy CameraPt = Camera.GetCenterPt(); + Dbxy CameraPt = Camera.GetCoord(); CWorkCmdInvoker Invoker; CWorkCmdContainer &CmdContainer = CWorkCmdContainer::GetInstance();//指令集 @@ -1498,15 +1494,6 @@ bool CCommonFlowMgr::CameraCatchMarkExt(CProduct &Product) Dbxy P2CatchMarkPos1 = MarkPt1; Dbxy P2CatchMarkPos2 = MarkPt2; - if (Product.IsbNewAddProduct()) - { - Dbxy NPoffset = GetNPOffset(); - P2CatchMarkPos1.x += NPoffset.x; - P2CatchMarkPos1.y += NPoffset.y; - P2CatchMarkPos2.x += NPoffset.x; - P2CatchMarkPos2.y += NPoffset.y; - - } //识别mark1 和mark2 if (!Product.IsSetRealMarkPt1() || (Product.IsSetRealMarkPt1() && Product.IsSetRealMarkPt2())) diff --git a/LaiPuLaser/CommonFlowMgr.h b/LaiPuLaser/CommonFlowMgr.h index 3fca24a..f190272 100644 --- a/LaiPuLaser/CommonFlowMgr.h +++ b/LaiPuLaser/CommonFlowMgr.h @@ -63,7 +63,7 @@ public: private: void SetLightStateCmd(CWorkCmdContainer &CmdContainer,bool bStart); bool CameraCatchMarkExt(CProduct &Product); - void MoveToFirstArea(); + void MoveToFirstArea(Dbxy offset); private: CCamera *m_CurCamera;//当前使用的相机 int m_AlamDelay;//报警延时(ms) diff --git a/LaiPuLaser/DlgSW_XL_Flow.cpp b/LaiPuLaser/DlgSW_XL_Flow.cpp index 7fe6e73..47d05b3 100644 --- a/LaiPuLaser/DlgSW_XL_Flow.cpp +++ b/LaiPuLaser/DlgSW_XL_Flow.cpp @@ -716,7 +716,8 @@ void CDlgSW_XL_Flow::OnBnClickedAdjustProductPos() if (!gAuthorityMgr->CheckAuthority(_ADMIN,true)) return; - gProductMgr->SetProductCenterPt(); + //gProductMgr->SetProductCenterPt(); + gProductMgr->SetCamCoord(); //保存加工参数 gProgramCutMgr->SaveWorkParFile(); } diff --git a/LaiPuLaser/LaiPuLaser.cpp b/LaiPuLaser/LaiPuLaser.cpp index 704b88d..0a8384e 100644 --- a/LaiPuLaser/LaiPuLaser.cpp +++ b/LaiPuLaser/LaiPuLaser.cpp @@ -213,7 +213,9 @@ int CLaiPuLaserApp::ExitInstance() //TODO: 处理可能已添加的附加资源 AfxOleTerm(FALSE); gModuleDeviceMgr.OnExitApp(); - return CWinAppEx::ExitInstance(); + auto ret=CWinAppEx::ExitInstance(); + quick_exit(ret); + return ret; } // CLaiPuLaserApp 消息处理程序 diff --git a/LaiPuLaser/Laser.cpp b/LaiPuLaser/Laser.cpp index 1c1a372..753fc47 100644 --- a/LaiPuLaser/Laser.cpp +++ b/LaiPuLaser/Laser.cpp @@ -63,8 +63,8 @@ CMFCPropertyGridProperty *CLaser::CreatGridProperty() pPropertie->SetName(Name); pPropertie->WriteRead(true);//读取保存的属性 //添加属性显示 - PropertyName = _T("激光坐标X"); - Description = _T("激光中心相对原点的坐标X"); + PropertyName = _T("激光相对坐标X"); + Description = _T("激光中心相对CCD1中心的坐标X"); CMFCPropertyGridProperty* p1 = new CMFCPropertyGridProperty(PropertyName,(_variant_t)m_LaserCoord.x, Description); pGroup->AddSubItem(p1); gDevicePropertieMgr.Insert(p1, pPropertie); @@ -80,8 +80,8 @@ CMFCPropertyGridProperty *CLaser::CreatGridProperty() pPropertie->SetName(Name); pPropertie->WriteRead(true);//读取保存的属性 //添加属性显示 - PropertyName = _T("激光坐标Y"); - Description = _T("激光中心相对原点的坐标Y"); + PropertyName = _T("激光相对坐标Y"); + Description = _T("激光中心相对CCD1的坐标Y"); CMFCPropertyGridProperty* p1 = new CMFCPropertyGridProperty(PropertyName,(_variant_t)m_LaserCoord.y, Description); pGroup->AddSubItem(p1); gDevicePropertieMgr.Insert(p1, pPropertie); diff --git a/LaiPuLaser/Laser.h b/LaiPuLaser/Laser.h index 826b7ba..5cb270f 100644 --- a/LaiPuLaser/Laser.h +++ b/LaiPuLaser/Laser.h @@ -1,6 +1,6 @@ #pragma once #include "module.h" - +#include "CameraHawkvis.h" //激光 class CLaser :public CModule { @@ -12,7 +12,7 @@ public: virtual void WriteWorkFileExt(vector &LabVec); virtual void ReadWorkFile(CLabVecRang &LabVecRang); - Dbxy GetCoord(){return m_LaserCoord;}; + Dbxy GetCoord(){return m_LaserCoord+gCameraHawkvis->m_Coord;}; void SetCoord(Dbxy pt){m_LaserCoord = pt;}; int GetOpenDelay(){return m_OpenDelay;}; void SetOpenDelay(int n){m_OpenDelay = n;}; diff --git a/LaiPuLaser/MarkArea.cpp b/LaiPuLaser/MarkArea.cpp index ba68e82..cda2d8c 100644 --- a/LaiPuLaser/MarkArea.cpp +++ b/LaiPuLaser/MarkArea.cpp @@ -145,9 +145,8 @@ void CMarkArea::SetBasePt(Dbxy pt) //获取实际中心位置 Dbxy CMarkArea::GetRealBasePt() { - if (m_RealBasePt.Equal(Dbxy(0, 0))) + /*if (m_RealBasePt.Equal(Dbxy(0, 0)))*/ m_RealBasePt = m_BasePt; - return m_RealBasePt; } //计算实际中心点 diff --git a/LaiPuLaser/MotionCard_PCI1245.cpp b/LaiPuLaser/MotionCard_PCI1245.cpp index a92d10c..92ab272 100644 --- a/LaiPuLaser/MotionCard_PCI1245.cpp +++ b/LaiPuLaser/MotionCard_PCI1245.cpp @@ -784,7 +784,7 @@ Dbxy MotionCard_PCI1245::MovePlatformXY(Dbxy Coord) } gLogMgr->WriteDebugLog("Fuc---->MovePlatformXY 1245L"); CString strTemp; - strTemp.Format("Coord x : %f,Coord y : %f",Coord.y); + strTemp.Format("***[Move To]===>Coord x : %f,Coord y : %f", Coord.x,Coord.y); if (gLogMgr->IsDebuging()) { gLogMgr->LastTargetCoord = Coord; diff --git a/LaiPuLaser/Product.cpp b/LaiPuLaser/Product.cpp index 4e859dc..b0e9839 100644 --- a/LaiPuLaser/Product.cpp +++ b/LaiPuLaser/Product.cpp @@ -202,33 +202,33 @@ void CProduct::CalAffinePars() CString logstr; - Dbxy DataCenter = gObjComponentMgr->GetAllObjCenterPt(); + //Dbxy DataCenter = gObjComponentMgr->GetAllObjCenterPt(); /*Dbxy T2oft = Dbxy(0, 0); if (gCameraHawkvis->GetCamIndex()==1&&(!m_bNewAddProduct))//轨道2有额外偏移 (非新增那片) T2oft = gProgram_SZ_XL->GetTrack2Offset(); */ - o_TheoryMarkPt1 = m_TheoryMarkPt1-DataCenter; + //o_TheoryMarkPt1 = m_TheoryMarkPt1-DataCenter; logstr.Format("TheoryMarkPt1 Coord(%f,%f)", o_TheoryMarkPt1.x, o_TheoryMarkPt1.y); gLogMgr->WriteDebugLog(logstr); - o_TheoryMarkPt2 = m_TheoryMarkPt2 - DataCenter; + //o_TheoryMarkPt2 = m_TheoryMarkPt2 - DataCenter; logstr.Format("TheoryMarkPt2 Coord(%f,%f)", o_TheoryMarkPt2.x, o_TheoryMarkPt2.y); gLogMgr->WriteDebugLog(logstr); - o_TheoryMarkPt3 = m_TheoryMarkPt3 - DataCenter; + //o_TheoryMarkPt3 = m_TheoryMarkPt3 - DataCenter; logstr.Format("TheoryMarkPt3 Coord(%f,%f)", o_TheoryMarkPt3.x, o_TheoryMarkPt3.y); gLogMgr->WriteDebugLog(logstr); - o_RealMarkPt1 = m_RealMarkPt1 - DataCenter; + o_RealMarkPt1 = m_RealMarkPt1 - m_BasePt; logstr.Format("RealMarkPt1 Coord(%f,%f)", o_RealMarkPt1.x, o_RealMarkPt1.y); gLogMgr->WriteDebugLog(logstr); - o_RealMarkPt2 = m_RealMarkPt2 - DataCenter; + o_RealMarkPt2 = m_RealMarkPt2 - m_BasePt; logstr.Format("RealMarkPt2 Coord(%f,%f)", o_RealMarkPt2.x, o_RealMarkPt2.y); gLogMgr->WriteDebugLog(logstr); - o_RealMarkPt3 = m_RealMarkPt3 - DataCenter; + o_RealMarkPt3 = m_RealMarkPt3 - m_BasePt; logstr.Format("RealMarkPt3 Coord(%f,%f)", o_RealMarkPt3.x, o_RealMarkPt3.y); gLogMgr->WriteDebugLog(logstr); diff --git a/LaiPuLaser/ProductMgr.cpp b/LaiPuLaser/ProductMgr.cpp index 2df2910..a7378ef 100644 --- a/LaiPuLaser/ProductMgr.cpp +++ b/LaiPuLaser/ProductMgr.cpp @@ -791,4 +791,69 @@ void CProductMgr::SetProductCenterPt() MsgBox.Show("位置调整完成!"); } + +//通过设置product的中心点来控制默认抓取偏移 +//mark 1移动到CCD 中心,然后点调整 +void CProductMgr::SetCamCoord() +{ + + Dbxy MarkPt1; + Dbxy MarkPt2; + if (gObjComponentMgr->GetTwoMarkPt(MarkPt1, MarkPt2) == false) + { + CMsgBox MsgBox; + MsgBox.Show("没有定位点1!"); + return; + } + + //当前实际的坐标值 + Dbxy CurPlatCoord = gPlatformXY->GetCoord(); + + CProduct &Product = m_ProductVec[0]; + bool bETrackType_Track_2 = (CurPlatCoord.y > 200);//在X2 轴上调整 + //将数据移动到当前product 的基准点上 + //Dbxy CurBasePt = Product.GetProductBasePt(); + if (bETrackType_Track_2) + { + Dbxy Track2Offset = gProgram_SZ_XL->GetTrack2Offset(); + CurPlatCoord.x -= Track2Offset.x; + CurPlatCoord.y -= Track2Offset.y; + } + //gProgramCutMgr->MoveObjData(CurBasePt); + + + + CCamera &Camera = *gCameraHawkvis; + Dbxy CameraPt;// = Camera.GetCoord(); + + CameraPt.x = CurPlatCoord.x + MarkPt1.x; + CameraPt.y =MarkPt1.y- CurPlatCoord.y; + Camera.SetCoord(CameraPt); + + /*Dbxy PlatCoord;//MarkPt1 移到Camera 的理论坐标值 + PlatCoord.x = CameraPt.x - MarkPt1.x; + PlatCoord.y = MarkPt1.y - CameraPt.y; + + Dbxy Offset;//移动偏移量 + Offset.x = PlatCoord.x - CurPlatCoord.x; + Offset.y = CurPlatCoord.y - PlatCoord.y; + + CurBasePt.x += Offset.x; + CurBasePt.y += Offset.y; + + if (bETrackType_Track_2)//按轨道1 来设置 + { + Dbxy Track2Offset = gProgram_SZ_XL->GetTrack2Offset(); + CurBasePt.x -= Track2Offset.x; + CurBasePt.y -= Track2Offset.y; + } + + Product.SetBasePt(CurBasePt);*/ + + gDevicePropertieMgr.SaveAllPropertie(); + + CMsgBox MsgBox; + MsgBox.Show("位置调整完成!"); +} + #endif \ No newline at end of file diff --git a/LaiPuLaser/ProductMgr.h b/LaiPuLaser/ProductMgr.h index e178197..68cb796 100644 --- a/LaiPuLaser/ProductMgr.h +++ b/LaiPuLaser/ProductMgr.h @@ -47,6 +47,7 @@ public: void SetDefualtRect(DbRect r){m_DefualtRect = r;}; Dbxy GetDefualtBasePt(); void SetProductCenterPt(); + void SetCamCoord(); double GetMaxMarkDisDiff(){return m_MaxMarkDisDiff;}; double GetAdjustAngle() { return m_AngleAdjust; };//获取调整角度 private: diff --git a/LaiPuLaser/Program_SZ_XL.cpp b/LaiPuLaser/Program_SZ_XL.cpp index a1eec21..c4c97bb 100644 --- a/LaiPuLaser/Program_SZ_XL.cpp +++ b/LaiPuLaser/Program_SZ_XL.cpp @@ -463,7 +463,7 @@ CMFCPropertyGridProperty *CProgram_SZ_XL::CreatGridProperty() pPropertie->WriteRead(true);//读取保存的属性 //添加属性显示 - PropertyName = _T("轨道2抓取偏移X"); + PropertyName = _T("轨道2位置偏移X"); Description = _T("轨道2相对轨道1 的偏移量X"); CMFCPropertyGridProperty* p = new CMFCPropertyGridProperty(PropertyName, (_variant_t)m_Track2Offset.x, Description); //p->AllowEdit(FALSE);//不可修改 @@ -482,7 +482,7 @@ CMFCPropertyGridProperty *CProgram_SZ_XL::CreatGridProperty() pPropertie->WriteRead(true);//读取保存的属性 //添加属性显示 - PropertyName = _T("轨道2抓取偏移Y"); + PropertyName = _T("轨道2位置偏移Y"); Description = _T("轨道2相对轨道1 的偏移量Y"); CMFCPropertyGridProperty* p = new CMFCPropertyGridProperty(PropertyName, (_variant_t)m_Track2Offset.y, Description); //p->AllowEdit(FALSE);//不可修改 @@ -503,7 +503,7 @@ CMFCPropertyGridProperty *CProgram_SZ_XL::CreatGridProperty() pPropertie->WriteRead(true);//读取保存的属性 //添加属性显示 - PropertyName = _T("治具2抓取偏移X"); + PropertyName = _T("治具2位置偏移X"); Description = _T("轨道1上治具2相对治具1位置偏移量X"); CMFCPropertyGridProperty* p = new CMFCPropertyGridProperty(PropertyName, (_variant_t)m_NPCatchOffset1.x, Description); //p->AllowEdit(FALSE);//不可修改 @@ -522,7 +522,7 @@ CMFCPropertyGridProperty *CProgram_SZ_XL::CreatGridProperty() pPropertie->WriteRead(true);//读取保存的属性 //添加属性显示 - PropertyName = _T("治具2抓取偏移Y"); + PropertyName = _T("治具2位置偏移Y"); Description = _T("轨道1上治具2相对治具1位置偏移量Y"); CMFCPropertyGridProperty* p = new CMFCPropertyGridProperty(PropertyName, (_variant_t)m_NPCatchOffset1.y, Description); //p->AllowEdit(FALSE);//不可修改 @@ -543,7 +543,7 @@ CMFCPropertyGridProperty *CProgram_SZ_XL::CreatGridProperty() pPropertie->WriteRead(true);//读取保存的属性 //添加属性显示 - PropertyName = _T("治具4抓取偏移X"); + PropertyName = _T("治具4位置偏移X"); Description = _T("轨道2上治具4相对治具3位置偏移量X"); CMFCPropertyGridProperty* p = new CMFCPropertyGridProperty(PropertyName, (_variant_t)m_NPCatchOffset2.x, Description); //p->AllowEdit(FALSE);//不可修改 @@ -562,7 +562,7 @@ CMFCPropertyGridProperty *CProgram_SZ_XL::CreatGridProperty() pPropertie->WriteRead(true);//读取保存的属性 //添加属性显示 - PropertyName = _T("治具4抓取偏移Y"); + PropertyName = _T("治具4位置偏移Y"); Description = _T("轨道2上治具4相对治具3位置偏移量Y"); CMFCPropertyGridProperty* p = new CMFCPropertyGridProperty(PropertyName, (_variant_t)m_NPCatchOffset2.y, Description); //p->AllowEdit(FALSE);//不可修改 diff --git a/LaiPuLaser/Program_SZ_XL_TrackWorkFlow.cpp b/LaiPuLaser/Program_SZ_XL_TrackWorkFlow.cpp index 0fb0b41..257b0f5 100644 --- a/LaiPuLaser/Program_SZ_XL_TrackWorkFlow.cpp +++ b/LaiPuLaser/Program_SZ_XL_TrackWorkFlow.cpp @@ -145,7 +145,7 @@ void CTrackWorkFlow::ExecuteCurStep() MoveToWaitPos();//移动到等待位置 break; case _ETrack_Step_Mark_Waiting://等待加工 - CatchMark();//抓取定位 + CatchMarkNewly();//抓取定位 break; case _ETrack_Step_Catch_mark_End://等待加工 MarkProcess();//尝试启动加工 @@ -1085,6 +1085,188 @@ void CTrackWorkFlow::CatchMark() //恢复报警状态 gTrackWorkFlow1.RadAlamOnOff(false); } + +void CTrackWorkFlow::CatchMarkNewly() +{ + if (!gObjComponentMgr->GetTwoMarkPt(Dbxy(), Dbxy()))//获取定位点 + { + CMsgBox MsgBox; + MsgBox.Show("没有加工图形!"); + return; + } + //只有无锁定状态才能CatchMark + if (gCurLockTrackType != _ETrackType_NULL) + { + m_OldWorkStep = _ETrack_Step_NULL;//强制改变之前的状态 + return; + } + gCurLockTrackType = m_TrackType;//锁定当前轨道 + + //收集未移动前的数据 + gClientMgr->SendCmd_CollectData(); + //gMarkAreaMgr->CollectOrgWorkData(gProgram_SZ_XL->IsbSelMarkMode()); + thread t1(&CMarkAreaMgr::CollectOrgWorkData, gMarkAreaMgr, gProgram_SZ_XL->IsbSelMarkMode()); + t1.detach(); + + SetCurTrackWorkStep(_ETrack_Step_Catch_mark); + CString Log = m_TrackName + " CatchMark"; + gLogMgr->WriteDebugLog(Log); + + //真空吸附 + ProductCarrierOpenClose(false); + VacSorbOnOff(true); + + bool Ret = true; + Ret = IsJigOK(); + + if (gProgram_SZ_XL->IsbShieldMarking() == false)//屏蔽加工过程 + { + //切换平台XY 组编号 + ChangePlatXYGroupIdx(); + CProduct &Product = gProductMgr->GetProduct(m_ProductIdx); + + gObjComponentMgr->GetTwoMarkPt(Product.o_TheoryMarkPt1, Product.o_TheoryMarkPt2); + gObjComponentMgr->GetMark3Pt(Product.o_TheoryMarkPt3); + + //start----------料片2复制料片1信息------------start + CProduct Product2 = Product; + Product2.SetbNewAddProduct(true); + //end----------料片2复制料片1信息并偏移----------------end + + + ///--------------------抓取治具1上料片的定位点--------------------/// + //将数据移动到当前product 的基准点上 + Dbxy BasePt(0,0); + Product.SetBasePt(BasePt); + //轨道2 要偏移基准点 + if (m_TrackType == _ETrackType_Track_2) + { + Dbxy Track2Offset = gProgram_SZ_XL->GetTrack2Offset(); + BasePt.x = Track2Offset.x; + BasePt.y = Track2Offset.y; + Product.SetBasePt(BasePt);//发给副机的需记录,因为接收到Product2才移动数据 + } + + /* //移动obj + gProgramCutMgr->MoveObjData(BasePt); + //移动area + //计算所有obj 的中心点 + gObjComponentMgr->CalAllObjCenterPt(); + Dbxy AllObjCenterPt = gObjComponentMgr->GetAllObjCenterPt(); + gMarkAreaMgr->MoveAllAreaToTargetPt(AllObjCenterPt);*/ + + Product.ResetRealMarkPt(); + //识别定位点1 + if (Ret) + { + gCommonFlowMgr->CameraCatchTwoMark(Product);//只抓取一个点 + } + if (!Product.IsSetRealMarkPt1()) + { + Ret = false; + } + //识别定位点3 + Dbxy MarkPt3; + if (Ret&&gObjComponentMgr->GetMark3Pt(MarkPt3)) + { + Ret = gCommonFlowMgr->CameraCatchMark3(Product); + } + //识别定位点2 + if (Ret) + { + gCommonFlowMgr->CameraCatchTwoMark(Product);//只抓取一个点 + } + if (!Product.IsMarkReady())//mark 识别错误 + { + Ret = false; + } + + ///Start--------------------抓取治具2上料片的定位点--------------------/// + + Dbxy JigOft = gCommonFlowMgr->GetNPOffset(); + Product2.SetBasePt(JigOft + BasePt); + + Dbxy Product2MarkPt3; + + if (gClientMgr->IsbDisableServer())//屏蔽副机,则不抓取 + goto CatchProduct2Finished; + + Product2.ResetRealMarkPt(); + //识别定位点1 + if (Ret) + { + gCommonFlowMgr->CameraCatchTwoMark(Product2);//只抓取一个点 + if (!Product2.IsSetRealMarkPt1()) + { + Ret = false; + } + } + //识别定位点3 + if (gObjComponentMgr->GetMark3Pt(Product2MarkPt3) && Ret) + { + Ret = gCommonFlowMgr->CameraCatchMark3(Product2); + } + //识别定位点2 + if (Ret) + { + gCommonFlowMgr->CameraCatchTwoMark(Product2);//只抓取一个点 + } + + if (!Product2.IsMarkReady())//mark 识别错误 + { + Ret = false; + } + else + { + gClientMgr->SendCmd_ProductInfo(Product2); + } + ///End--------------------抓取治具2上料片的定位点--------------------End/// + + CatchProduct2Finished: + + //抓取失败时/非自动状态时 + if (Ret == false || m_bAutoWorking == false) + { + VacSorbOnOff(false);//真空放开 + //解除锁定 + gCurLockTrackType = _ETrackType_NULL; + } + } + + if (m_bAutoWorking) + { + if (Ret == false) + { + SetCurTrackWorkStep(_ETrack_Step_Catch_mark_Err); + } + else + { + SetCurTrackWorkStep(_ETrack_Step_Catch_mark_End); + } + } + else + { + //数据移动回默认的位置(防止area 移位) + gProgramCutMgr->MoveObjData(Dbxy(0, 0)); + gMarkAreaMgr->MoveAllAreaToTargetPt(Dbxy(0, 0)); + SetCurTrackWorkStep(_ETrack_Step_Stop); + //解除锁定 + if (m_TrackType == gCurLockTrackType) + { + gCurLockTrackType = _ETrackType_NULL; + } + } + + if (m_CurWorkStep != _ETrack_Step_Catch_mark_End)//异常停止时 + { + //数据移动回默认的位置(防止area 移位) + gProgramCutMgr->MoveObjData(Dbxy(0, 0)); + gMarkAreaMgr->MoveAllAreaToTargetPt(Dbxy(0, 0)); + } + //恢复报警状态 + gTrackWorkFlow1.RadAlamOnOff(false); +} + //加工过程 void CTrackWorkFlow::MarkProcess() { diff --git a/LaiPuLaser/Program_SZ_XL_TrackWorkFlow.h b/LaiPuLaser/Program_SZ_XL_TrackWorkFlow.h index 833379f..adf7d36 100644 --- a/LaiPuLaser/Program_SZ_XL_TrackWorkFlow.h +++ b/LaiPuLaser/Program_SZ_XL_TrackWorkFlow.h @@ -101,6 +101,7 @@ private: void ThrowEdge(); void UnLoad(); void CatchMark(); + void CatchMarkNewly(); void ChangePlatXYGroupIdx(); CString GetSendPlcMsgStr(ETrackPlcCmd PlcCmd); void WriteRecordTimesToFile(); diff --git a/LaiPuLaser/WorkCmdCameraCatch.cpp b/LaiPuLaser/WorkCmdCameraCatch.cpp index 474cb82..d72b322 100644 --- a/LaiPuLaser/WorkCmdCameraCatch.cpp +++ b/LaiPuLaser/WorkCmdCameraCatch.cpp @@ -35,12 +35,12 @@ bool CWorkCmdCameraCatch::Excute() //设置实际定位点的值 if(m_pProduct != NULL) { - if (m_pProduct->IsbNewAddProduct()) + /*if (m_pProduct->IsbNewAddProduct()) { Dbxy NPoffset = gCommonFlowMgr->GetNPOffset(); pt.x -= NPoffset.x; pt.y -= NPoffset.y; - } + }*/ if(m_bCatchMark3)//抓取的是mark3 { m_pProduct->SetRealMark3Pt(pt);