|
|
|
|
#include "StdAfx.h"
|
|
|
|
|
#include "CameraKeyence.h"
|
|
|
|
|
#include "SocketMgr.h"
|
|
|
|
|
#include "LogMgr.h"
|
|
|
|
|
#include "Propertie.h"
|
|
|
|
|
#include "PropertieMgr.h"
|
|
|
|
|
#include "AuthorityMgr.h"
|
|
|
|
|
#include "GlobalFunction.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define SEND_MASSAGE_TO_CCD_DELAYE_TIME 500//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2>CCD <20><><EFBFBD><EFBFBD><EFBFBD>շ<EFBFBD><D5B7><EFBFBD><EFBFBD>ĵȴ<C4B5><C8B4><EFBFBD>ʱ
|
|
|
|
|
|
|
|
|
|
CCameraKeyence *gCameraKeyence = new CCameraKeyence;
|
|
|
|
|
CCameraKeyence::CCameraKeyence(void)
|
|
|
|
|
:m_IPAddrStr("192.168.0.10")//CCD <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>IP<49><50>ַ
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CCameraKeyence::~CCameraKeyence(void)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
#if 1
|
|
|
|
|
CMFCPropertyGridProperty *CCameraKeyence::CreatGridProperty()
|
|
|
|
|
{
|
|
|
|
|
CString PropertyName;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
CString Description;//<2F><><EFBFBD><EFBFBD>
|
|
|
|
|
CString Path = _T("DaHenCCD");;//<2F>洢·<E6B4A2><C2B7>
|
|
|
|
|
CString Name;
|
|
|
|
|
//-------------------------------------------------------------------------------//
|
|
|
|
|
PropertyName = _T("CCD ");
|
|
|
|
|
CMFCPropertyGridProperty* pGroup = new CMFCPropertyGridProperty(PropertyName);
|
|
|
|
|
|
|
|
|
|
//<2F>Ȱѹ<C8B0>ͬ<EFBFBD>趨<EFBFBD>ӽ<EFBFBD><D3BD><EFBFBD>
|
|
|
|
|
CMFCPropertyGridProperty* pBase = CCamera::CreatGridProperty();
|
|
|
|
|
pGroup->AddSubItem(pBase);
|
|
|
|
|
//-------------------------------------------------------------------------------//
|
|
|
|
|
PropertyName = _T("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>趨");
|
|
|
|
|
CMFCPropertyGridProperty* pGroup1 = new CMFCPropertyGridProperty(PropertyName);
|
|
|
|
|
if(gAuthorityMgr->CheckAuthority(_FACTORY))
|
|
|
|
|
{
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ա<EFBFBD><D4B1><EFBFBD>ӳ<EFBFBD><D3B3>
|
|
|
|
|
Name = _T("m_IPAddrStr");//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
CPropertie *pPropertie = new CPropertie;
|
|
|
|
|
pPropertie->SetpVal((void*)&m_IPAddrStr);
|
|
|
|
|
pPropertie->SetType(_PROP_TYPE_STRING);
|
|
|
|
|
pPropertie->SetpModule(this);
|
|
|
|
|
pPropertie->SetPath(Path);
|
|
|
|
|
pPropertie->SetName(Name);
|
|
|
|
|
pPropertie->WriteRead(true);//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ
|
|
|
|
|
PropertyName = _T("CCD <20><><EFBFBD><EFBFBD>IP <20><>ַ");
|
|
|
|
|
Description = _T("CCD <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>IP <20><>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>͵<EFBFBD><CDB5><EFBFBD>ͨ<EFBFBD><CDA8>");
|
|
|
|
|
CMFCPropertyGridProperty* p1 = new CMFCPropertyGridProperty(PropertyName, (_variant_t)m_IPAddrStr, Description);
|
|
|
|
|
pGroup1->AddSubItem(p1);
|
|
|
|
|
gDevicePropertieMgr.Insert(p1, pPropertie);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pGroup->AddSubItem(pGroup1);
|
|
|
|
|
return pGroup;
|
|
|
|
|
}
|
|
|
|
|
void CCameraKeyence::ExportPar(ofstream *pFile)
|
|
|
|
|
{
|
|
|
|
|
CCamera::ExportPar(pFile);
|
|
|
|
|
|
|
|
|
|
(*pFile)<<"[ģ<><C4A3>] [CCameraKeyence]------------------------------------------------"<<endl;
|
|
|
|
|
(*pFile)<<"[CCD <20><><EFBFBD><EFBFBD>IP <20><>ַ][m_IPAddrStr] = "<<m_IPAddrStr<<endl;
|
|
|
|
|
}
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>ӳ<EFBFBD><D3B3><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
Dbxy CCameraKeyence::GetCoord()
|
|
|
|
|
{
|
|
|
|
|
Dbxy pt;
|
|
|
|
|
pt.x = m_Coord.x + m_Size.w/2;
|
|
|
|
|
pt.y = m_Coord.y - m_Size.h/2;
|
|
|
|
|
return pt;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
#if 1
|
|
|
|
|
bool CCameraKeyence::CatchPoint(Dbxy &pt)
|
|
|
|
|
{
|
|
|
|
|
if(gSocketMgr->Connect(m_IPAddrStr,8500))
|
|
|
|
|
{
|
|
|
|
|
gSocketMgr->Send("T1\r",strlen("T1\r")+1);
|
|
|
|
|
Sleep(SEND_MASSAGE_TO_CCD_DELAYE_TIME);
|
|
|
|
|
char recvBuf[100];//<2F><><EFBFBD>ؽ<EFBFBD><D8BD><EFBFBD>
|
|
|
|
|
gSocketMgr->Receive(recvBuf,sizeof(recvBuf));
|
|
|
|
|
CString str = recvBuf;
|
|
|
|
|
gLogMgr->WriteDebugLog(str);
|
|
|
|
|
gSocketMgr->Close();
|
|
|
|
|
//<2F><>ȡCCD <20><><EFBFBD>ؽ<EFBFBD><D8BD><EFBFBD><EFBFBD>е<EFBFBD><D0B5><EFBFBD>ֵ
|
|
|
|
|
double arr[20];
|
|
|
|
|
if(GetNumFromRecvBuf(recvBuf,arr))
|
|
|
|
|
{
|
|
|
|
|
Dbxy CCDpt(arr[0],arr[1]);
|
|
|
|
|
if(IsDbxyZero(CCDpt))
|
|
|
|
|
return false;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
//<2F><>ȡCCD <20><><EFBFBD>ؽ<EFBFBD><D8BD><EFBFBD><EFBFBD>е<EFBFBD><D0B5><EFBFBD>ֵ
|
|
|
|
|
BOOL CCameraKeyence::GetNumFromRecvBuf(char* recvBuf,double *arr)
|
|
|
|
|
{
|
|
|
|
|
CString Str = recvBuf;
|
|
|
|
|
int CommaPosPer;//<2F><>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD>ŵ<EFBFBD>λ<EFBFBD><CEBB>
|
|
|
|
|
CommaPosPer = Str.Find(",",0);
|
|
|
|
|
if(CommaPosPer == -1)//û<>ҵ<EFBFBD>ֱ<EFBFBD>ӷ<EFBFBD><D3B7><EFBFBD>
|
|
|
|
|
{
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int idx = 0;
|
|
|
|
|
int CommaPosNext = CommaPosPer;
|
|
|
|
|
do
|
|
|
|
|
{
|
|
|
|
|
CommaPosNext = Str.Find(",",CommaPosPer+1);//<2F><>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD>ŵ<EFBFBD>λ<EFBFBD><CEBB>
|
|
|
|
|
if(CommaPosNext==-1)//<2F><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>
|
|
|
|
|
{
|
|
|
|
|
CString Str1(recvBuf+CommaPosPer+1);
|
|
|
|
|
arr[idx] = atof(Str1);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
CString Str1(recvBuf+CommaPosPer+1,CommaPosNext-CommaPosPer);
|
|
|
|
|
arr[idx] = atof(Str1);
|
|
|
|
|
}
|
|
|
|
|
CommaPosPer = CommaPosNext;
|
|
|
|
|
idx++;
|
|
|
|
|
}while(CommaPosNext!=-1);
|
|
|
|
|
|
|
|
|
|
//δ<><CEB4><EFBFBD>mark <20><>
|
|
|
|
|
if((Str[0]!= 'T' && Str[1]!='1'))
|
|
|
|
|
{
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#if 1
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD>CCD <20><>Դ
|
|
|
|
|
void CCameraKeyence::OpenCCDLight()
|
|
|
|
|
{
|
|
|
|
|
if(gSocketMgr->Connect(m_IPAddrStr,8500))
|
|
|
|
|
{
|
|
|
|
|
gSocketMgr->Send("CLV,2,100\r",strlen("CLV,1,100\r")+1);
|
|
|
|
|
Sleep(SEND_MASSAGE_TO_CCD_DELAYE_TIME);
|
|
|
|
|
gSocketMgr->Close();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//<2F>ر<EFBFBD>CCD <20><>Դ
|
|
|
|
|
void CCameraKeyence::CloseCCDLight()
|
|
|
|
|
{
|
|
|
|
|
if(gSocketMgr->Connect(m_IPAddrStr,8500))
|
|
|
|
|
{
|
|
|
|
|
gSocketMgr->Send("CLV,2,0\r",strlen("CLV,1,0\r")+1);
|
|
|
|
|
Sleep(SEND_MASSAGE_TO_CCD_DELAYE_TIME);
|
|
|
|
|
gSocketMgr->Close();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//<2F>л<EFBFBD>CCD <20>ij<EFBFBD><C4B3><EFBFBD>"PW," & CStr(sd) & "," & nnn & Chr(13) & Chr(10)
|
|
|
|
|
void CCameraKeyence::ChangeCCDScene()
|
|
|
|
|
{
|
|
|
|
|
#if 0
|
|
|
|
|
CGraphSoftView* pView= m_pView;
|
|
|
|
|
if(pView->GetDocument()->m_CurrOpenFileName=="")
|
|
|
|
|
return;
|
|
|
|
|
DEBUG_LOG_START
|
|
|
|
|
pView->m_DebugLogFile<< "Function :[ChangeCCDScene][<5B>Զ<EFBFBD><D4B6>л<EFBFBD>CCD <20><><EFBFBD><EFBFBD>]"<<endl;
|
|
|
|
|
DEBUG_LOG_END
|
|
|
|
|
|
|
|
|
|
pView->m_CommunicationManager.SocketConnect();
|
|
|
|
|
CString str1 = "PW,1,";
|
|
|
|
|
CString str2 = str1 + pView->GetDocument()->m_CurrOpenFileName+"\r";
|
|
|
|
|
pView->m_CommunicationManager.m_SocketClient.Send(str2,str2.GetLength()+1,0);
|
|
|
|
|
DEBUG_LOG_START
|
|
|
|
|
pView->m_DebugLogFile<< "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: "<<str2<<endl;
|
|
|
|
|
DEBUG_LOG_END
|
|
|
|
|
Sleep(SEND_MASSAGE_TO_CCD_DELAYE_TIME);
|
|
|
|
|
pView->m_CommunicationManager.SocketClose();
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
//<2F>л<EFBFBD><D0BB><EFBFBD>ǰ<EFBFBD><C7B0>ʾ<EFBFBD><CABE>CCD <20><><EFBFBD><EFBFBD>idx(1~4) Ϊ0 <20><>ʾ<EFBFBD><CABE>ʾȫ<CABE><C8AB>
|
|
|
|
|
bool CCameraKeyence::ChangeCCDScreen(int idx)
|
|
|
|
|
{
|
|
|
|
|
if(gSocketMgr->Connect(m_IPAddrStr,8500))
|
|
|
|
|
{
|
|
|
|
|
if(idx == 1)
|
|
|
|
|
{
|
|
|
|
|
gLogMgr->WriteDebugLog("ChangeCCDScreen id = 1");
|
|
|
|
|
gSocketMgr->Send("VW,0,1\r",strlen("VW,0,1\r")+1);
|
|
|
|
|
}
|
|
|
|
|
if(idx == 2)
|
|
|
|
|
{
|
|
|
|
|
gLogMgr->WriteDebugLog("ChangeCCDScreen id = 2");
|
|
|
|
|
gSocketMgr->Send("VW,0,2\r",strlen("VW,0,1\r")+1);
|
|
|
|
|
}
|
|
|
|
|
Sleep(SEND_MASSAGE_TO_CCD_DELAYE_TIME);
|
|
|
|
|
char recvBuf[100];//<2F><><EFBFBD>ؽ<EFBFBD><D8BD><EFBFBD>
|
|
|
|
|
gSocketMgr->Receive(recvBuf,sizeof(recvBuf));
|
|
|
|
|
CString str = recvBuf;
|
|
|
|
|
gLogMgr->WriteDebugLog(str);
|
|
|
|
|
|
|
|
|
|
gSocketMgr->Close();
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
#endif
|