新增TC4000视频卡测试

This commit is contained in:
TAO Cheng
2013-05-29 11:08:59 +08:00
parent 752756f66e
commit 6af2627d32
23 changed files with 2995 additions and 371 deletions
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,460 @@
#pragma once
#ifndef __NEWDATASRUCT_H
#define __NEWDATASRUCT_H
#include<vector>
#include <math.h>
#define ROW 12 //所能输入的最多点数
#define COL ROW
using namespace std;
struct Mat
{
Mat()
{
m_pArr=NULL;
m_nRow=0;
m_nCol=0;
}
Mat(int row,int col)
{
if(row>0&&col>0)
{
m_nRow=row;
m_nCol=col;
m_pArr=new double[row*col]; //自动选取 automatism 自动化 automatization 边沿 edge fringe 边缘
}
else
{
m_nRow=0;
m_nCol=0;
m_pArr=NULL;
}
}
Mat(Mat& mat)
{
m_nRow=mat.m_nRow;
m_nCol=mat.m_nCol;
int length=m_nRow*m_nCol;
m_pArr=new double[length];
for(int i=0;i<length;i++)
m_pArr[i]=mat.m_pArr[i];
}
Mat& operator=(Mat& mat)
{
m_nRow=mat.m_nRow;
m_nCol=mat.m_nCol;
int length=m_nRow*m_nCol;
if(m_pArr)
delete []m_pArr;
m_pArr=new double[length];
for(int i=0;i<length;i++)
m_pArr[i]=mat.m_pArr[i];
return (*this);
}
void ReSet(int row,int col)
{
if(m_pArr)
delete []m_pArr;
m_nRow=row;
m_nCol=col;
m_pArr=new double[row*col];
}
void SetRow(int row)
{
if(m_pArr)
delete []m_pArr;
m_nRow=row;
if(m_nRow>0&&m_nCol>0)
m_pArr=new double[m_nRow*m_nCol];
}
void SetCol(int col)
{
if(m_pArr)
delete []m_pArr;
m_nCol=col;
if(m_nRow>0&&m_nCol>0)
m_pArr=new double[m_nRow*m_nCol];
}
BOOL SetData(int row,int col,double data)
{
if(row<0||row>=m_nRow||col<0||col>=m_nCol)
return FALSE;
m_pArr[row*m_nCol+col]=data;
return TRUE;
}
double GetData(int row,int col)
{
return m_pArr[row*m_nCol+col];
}
Mat TurnSet()
{
Mat temp(m_nCol,m_nRow);
for(int i=0;i<temp.m_nRow;i++)
for(int j=0;j<temp.m_nCol;j++)
temp.SetData(i,j,GetData(j,i));
return temp;
}
Mat operator *(Mat& mat)
{
Mat temp;
if(m_nCol!=mat.m_nRow)
return temp;
temp.ReSet(m_nRow,mat.m_nCol);
for(int i=0;i<m_nRow;i++)
{
for(int j=0;j<mat.m_nCol;j++)
{
temp.SetData(i,j,0.0);
for(int k=0;k<m_nCol;k++)
temp.SetData(i,j,temp.GetData(i,j)+GetData(i,k)*mat.GetData(k,j));
}
}
return temp;
}
BOOL IsEmpty()
{
return m_pArr==NULL;
}
~Mat()
{
if(m_pArr)
{
delete []m_pArr;
m_pArr=NULL;
}
}
double* m_pArr;
int m_nRow;
int m_nCol;
};
struct PointDB
{
double _x;
double _y;
PointDB()
{
_x=0.0;
_y=0.0;
}
PointDB(double x,double y)
{
_x=x;
_y=y;
}
PointDB operator-(PointDB& pot)
{
PointDB temp;
temp._x=_x-pot._x;
temp._y=_y-pot._y;
return temp;
}
PointDB operator+(PointDB& pot)
{
PointDB temp;
temp._x=_x+pot._x;
temp._y=_y+pot._y;
return temp;
}
PointDB operator/(double div)
{
PointDB temp;
temp._x=_x/div;
temp._y=_y/div;
return temp;
}
PointDB operator*(double mul)
{
PointDB temp;
temp._x=_x*mul;
temp._y=_y*mul;
return temp;
}
double length()
{
return sqrt(_x*_x+_y*_y);
}
BOOL operator ==(PointDB& pot)
{
return fabs(_x-pot._x)<0.0001&&fabs(_y-pot._y)<0.0001;
}
//PointDB& operator =(PointDB& pot)
//{
// _x=(double)pot._x;
// _y=(double)pot._y;
// return *this;
//}
PointDB operator=(PointDB pot) { _x=pot._x; _y=pot._y; return (*this); }
};
struct Point
{
int _x;
int _y;
Point() { _x=0; _y=0; }
Point(int x,int y) { _x=x; _y=y; }
Point(PointDB pot) { _x=(int)(pot._x+0.5); _y=(int)(pot._y+0.5); }
Point(CPoint pot) { _x=pot.x; _y=pot.y; }
void Empty() { _x=0; _y=0; }
BOOL IsEmpty() { return (_x==0&&_y==0); }
void Left(int i=1) { _x-=i; }
void Right(int i=1) { _x+=i; }
void Top(int i=1) { _y-=i; }
void Bottom(int i=1) { _y+=i; }
operator CPoint() { return CPoint(_x,_y); }
operator PointDB() { return PointDB(_x,_y); };
Point operator=(CPoint pot) { _x=pot.x; _y=pot.y; return (*this); }
Point operator=(Point pot) { _x=pot._x; _y=pot._y; return (*this); }
Point operator=(PointDB pot) { _x=(int)(pot._x+0.5); _y=(int)(pot._y+0.5); return (*this); }
BOOL operator==(Point& pot) { return _x==pot._x&&_y==pot._y; }
Point operator+(CPoint pot) { int x=_x+pot.x; int y=_y+pot.y; return Point(x,y); }
Point operator-(CPoint pot) { int x=_x-pot.x; int y=_y-pot.y; return Point(x,y); }
Point operator+(Point pot) { int x=_x+pot._x; int y=_y+pot._y; return Point(x,y); }
Point operator-(Point pot) { int x=_x-pot._x; int y=_y-pot._y; return Point(x,y); }
Point operator*(int mul) { int x=_x*mul; int y=_y*mul; return Point(x,y); }
Point operator*(double mul) { int x=(int)(_x*mul+0.5); int y=(int)(_y*mul+0.5); return Point(x,y); }
Point operator/(double mul) { int x=(int)(_x/mul+0.5); int y=(int)(_y/mul+0.5); return Point(x,y); }
Point operator/(int mul) { int x=_x/mul; int y=_y/mul; return Point(x,y); }
Point& operator +=(int add) { _x+=add; _y+=add; return *this; }
Point& operator /=(int mul) { _x/=mul; _y/=mul; return *this; }
double length() { return sqrt((double)(_x*_x+_y*_y)); }
};
struct PointEx:public PointDB
{
double _length;
PointEx& operator =(PointEx& pot) { _x=pot._x;_y=pot._y;_length=pot._length;return *this; }
PointEx& operator =(PointDB& pot) { _x=pot._x;_y=pot._y;_length=0.0;return *this; }
operator CRect() { return CRect((int)_x-2,(int)_y-2,(int)_x+2,(int)_y+2); }
};
struct SimpleLine
{
double k;
double m;
};
struct MYPIXEL
{
BYTE R;
BYTE G;
BYTE B;
};
struct Rect
{
int left;
int top;
int right;
int bottom;
void SetRect(int l,int t,int r,int b)
{
left=l;
top=t;
right=r;
bottom=b;
}
void SetRectEmpty()
{
left=0;
top=0;
right=0;
bottom=0;
}
Rect& operator=(CRect& rc)
{
left=rc.left;
top=rc.top;
right=rc.right;
bottom=rc.bottom;
return *this;
}
};
struct PointInt
{
INT x;
INT y;
PointInt()
{
x=0;
y=0;
}
PointInt(INT xPara,INT yPara)
{
this->x=xPara;
this->y=yPara;
}
PointInt operator+(PointInt& pot)
{
PointInt temp;
temp.x=x+pot.x;
temp.y=y+pot.y;
return temp;
}
PointInt operator*(INT mul)
{
PointInt temp;
temp.x=x*mul;
temp.y=y*mul;
return temp;
}
};
struct PointDB_New
{
double x;
double y;
PointDB_New()
{
x=0.0;
y=0.0;
}
PointDB_New(double xPara,double yPara)
{
this->x=xPara;
this->y=yPara;
}
PointDB_New operator+(PointDB_New& pot)
{
PointDB_New temp;
temp.x=x+pot.x;
temp.y=y+pot.y;
return temp;
}
PointDB_New operator-(PointDB_New& pot)
{
PointDB_New temp;
temp.x=x-pot.x;
temp.y=y-pot.y;
return temp;
}
PointDB_New operator+(CPoint& pot)
{
PointDB_New temp;
temp.x=x+(double)pot.x;
temp.y=y+(double)pot.y;
return temp;
}
PointDB_New operator-(CPoint& pot)
{
PointDB_New temp;
temp.x=x-(double)pot.x;
temp.y=y-(double)pot.y;
return temp;
}
PointDB_New operator*(double mul)
{
PointDB_New temp;
temp.x=x*mul;
temp.y=y*mul;
return temp;
}
PointDB_New& operator=(CPoint& pot)
{
x=(double)pot.x;
y=(double)pot.y;
return *this;
}
PointDB_New& operator=(PointDB_New& pot)
{
x=pot.x;
y=pot.y;
return *this;
}
double Length()
{
return sqrt(x*x+y*y);
}
};
typedef struct tagdrawpoint
{
double X_COOR;
double Y_COOR;
}DRAWPoint;
typedef struct{
double x;
double y;
double z;
}MY3DPoint/*点*//*,MY3DVector向量*/;
typedef struct Squ
{
double ppA[ROW][COL];
int row;
int col;
}Squ;
typedef struct tagpoint
{
double X;
double Y;
double R;
tagpoint operator=(tagpoint pot) { X=pot.X; Y=pot.Y; R=pot.R; return (*this); }
}READPOINT;
struct SetCtrl{
short THREAD_WIDTH; //线宽
short AVER_NUMS; //做一个平均值的个数
short RETURN_NUM_POINTS; //返回点数
short MIN_POINTS; //认为是曲线的最少点数
SetCtrl(void) {THREAD_WIDTH=5; AVER_NUMS=5; RETURN_NUM_POINTS=200; MIN_POINTS=100;}
};
struct LinkVec{
vector <Point> vec;
};
struct LinkVecDB{
vector <PointDB> vec;
};
typedef struct{
int x;
int y;
int value;
double r;
}PointDBV;
#endif
@@ -1,238 +1,74 @@
#include "StdAfx.h"
#include <WinDef.h>
#include <WinBase.h>
#include "..\Keyence\LkIF.h"
#include "dll.h"
#include "So7_Interface.h "
#define MAX_STORAGE_DATA_SIZE 65536
CSo7_Interface::CSo7_Interface()
{
m_bIsStorage=FALSE;
m_iSetOutNo=0;
m_StoredDataNumber=0;
m_NeedStorageDataNumber=0;
}
CSo7_Interface::~CSo7_Interface()
{
FreeLibrary(m_hImageDLL);
if(m_hImageDLL)
{
Pro_cmd(Exit_DLL,(LPARAM)&Image_Info);
Pro_cmd(VQUIT_DLL,(LPARAM)&Image_Info);
Pro_cmd(MCLOSE,(LPARAM)&Image_Info);
FreeLibrary(m_hImageDLL);
}
}
//========================================
void CSo7_Interface::KeyenceLaserInit(void)
void CSo7_Interface::InitDll(void)
{
m_hImageDLL=LoadLibrary(_T("Image.dll"));
if(m_hImageDLL)
{
m_pGetCalcData=(pLKIF_GetCalcData)GetProcAddress(m_hImageDLL,"LKIF_GetCalcData");
m_pDataStorageStart=(pLKIF_DataStorageStart)GetProcAddress(m_hImageDLL,"LKIF_DataStorageStart");
m_pDataStorageStop=(pLKIF_DataStorageStop)GetProcAddress(m_hImageDLL,"LKIF_DataStorageStop");
m_pDataStorageInit=(pLKIF_DataStorageInit)GetProcAddress(m_hImageDLL,"LKIF_DataStorageInit");
m_pDataStorageGetData=(pLKIF_DataStorageGetData)GetProcAddress(m_hImageDLL,"LKIF_DataStorageGetData");
m_pDataStorageGetStatus=(pLKIF_DataStorageGetStatus)GetProcAddress(m_hImageDLL,"LKIF_DataStorageGetStatus");
m_pSetDataStorage=(pLKIF_SetDataStorage)GetProcAddress(m_hImageDLL,"LKIF_SetDataStorage");
Pro_cmd=(PRO_CMD)GetProcAddress(m_hImageDLL,"Pro_Cmd");
m_pGET_LASER_STORED_DATA=(GET_LASER_STORED_DATA)GetProcAddress(m_hImageDLL,"GetLaserStoredData");
m_pPAUSE_SCAN_AND_GET_LASER_DATA=(PAUSE_SCAN_AND_GET_LASER_DATA)GetProcAddress(m_hImageDLL,"PauseScanAndGetLaserData");
m_pGET_SCAN_LASER_STORAGE_STATUS=(GET_SCAN_LASER_STORAGE_STATUS)GetProcAddress(m_hImageDLL,"GetKeyenceStorageStatus");
}
Pro_cmd(VINIT_DLL,(LPARAM)&Image_Info);
Pro_cmd(MINIT_USB,(LPARAM)&Image_Info);
}
//==============================================
void CSo7_Interface::Get_KeyenceLaserData(float *LaserValue1,float *LaserValue2)
{
*LaserValue1=10;
*LaserValue2=10;
LKIF_FLOATVALUE GetVal1,GetVal2;
if(m_pGetCalcData(&GetVal1,&GetVal2)!=1)
{
return ;
}
switch(GetVal1.FloatResult)
{
case LKIF_FLOATRESULT_RANGEOVER_P:
{
*LaserValue1=50;
break;
}
case LKIF_FLOATRESULT_RANGEOVER_N:
{
*LaserValue1=-50;
break;
}
case LKIF_FLOATRESULT_WAITING:
{
*LaserValue1=0;
break;
}
default:
{
*LaserValue1=GetVal1.Value;
break;
}
}
switch(GetVal2.FloatResult)
{
case LKIF_FLOATRESULT_RANGEOVER_P:
{
*LaserValue2=50;
break;
}
case LKIF_FLOATRESULT_RANGEOVER_N:
{
*LaserValue2=-50;
break;
}
case LKIF_FLOATRESULT_WAITING:
{
*LaserValue2=0;
break;
}
default:
{
*LaserValue2=GetVal2.Value;
break;
}
}
}
//==============================================
BOOL CSo7_Interface::StartStoreData(int _NeedStorageDataNumber,int _SampleTime)
//========================================
void CSo7_Interface::StartStoreData(void)
{
BOOL bStatus(FALSE);
GetStoreDataStatus();
if (!m_bIsStorage)
{
bStatus=m_pDataStorageInit();
if (_NeedStorageDataNumber<1)
{
_NeedStorageDataNumber=1;
}
else if (_NeedStorageDataNumber>65536)
{
_NeedStorageDataNumber=65536;
}
m_NeedStorageDataNumber=_NeedStorageDataNumber;
if (_SampleTime<0.4)
{
m_StorageCycle=LKIF_STORAGECYCLE_1;
}
else if (_SampleTime<1)
{
m_StorageCycle=LKIF_STORAGECYCLE_2;
}
else if (_SampleTime<2)
{
m_StorageCycle=LKIF_STORAGECYCLE_5;
}
else if (_SampleTime<4)
{
m_StorageCycle=LKIF_STORAGECYCLE_10;
}
else if (_SampleTime<10)
{
m_StorageCycle=LKIF_STORAGECYCLE_20;
}
else if (_SampleTime<20)
{
m_StorageCycle=LKIF_STORAGECYCLE_50;
}
else if (_SampleTime<40)
{
m_StorageCycle=LKIF_STORAGECYCLE_100;
}
else if (_SampleTime<100)
{
m_StorageCycle=LKIF_STORAGECYCLE_200;
}
else if (_SampleTime<200)
{
m_StorageCycle=LKIF_STORAGECYCLE_500;
}
else
{
m_StorageCycle=LKIF_STORAGECYCLE_1000;
}
bStatus=m_pSetDataStorage(LKIF_TARGETOUT_OUT1,m_NeedStorageDataNumber,m_StorageCycle);
if (bStatus)
{
bStatus=m_pDataStorageStart();
}
}
return bStatus;
};
//==============================================
BOOL CSo7_Interface::StopStoreData()
Image_Info.gScanLaserPntsNumber=500;
Image_Info.gScanLaserPntsSampleTime=20;
Pro_cmd(START_SCAN_LASER_POINTS,(LPARAM)&Image_Info);
}
//========================================
void CSo7_Interface::StopStoreData(void)
{
BOOL bStatus(FALSE);
GetStoreDataStatus();
if (m_bIsStorage)
{
bStatus=m_pDataStorageStop();
}
return bStatus;
};
//==============================================
BOOL CSo7_Interface::PauseScanAndGetData(float *GetStorageData,int *GetStorageNumber)
Pro_cmd(STOP_SCAN_LASER_POINTS,(LPARAM)&Image_Info);
}
//========================================
void CSo7_Interface::GetStorageStatus(void)
{
BOOL bStatus(FALSE);
GetStoreDataStatus();
if (m_bIsStorage)
{
bStatus=m_pDataStorageStop();
bStatus=GetStoredData(GetStorageData,GetStorageNumber);
bStatus=m_pDataStorageStart();
}
else
{
bStatus=GetStoredData(GetStorageData,GetStorageNumber);
}
return bStatus;
};
//==============================================
BOOL CSo7_Interface::GetStoredData(float *GetStorageData,int *GetStorageNumber)
int _bIsStorage(0),_StoredDataNumber(0);
Pro_cmd(GET_SCAN_LASER_STATUS,(LPARAM)&Image_Info);
_bIsStorage = Image_Info.gIsLaserStorage;
_StoredDataNumber= Image_Info.gLaserStoredNumber;
}
//========================================
void CSo7_Interface::GetStoredData(void)
{
BOOL bStatus(FALSE);
GetStoreDataStatus();
if (!m_bIsStorage)
{
LKIF_FLOATVALUE GetStorageValue[MAX_STORAGE_DATA_SIZE];
bStatus=m_pDataStorageGetData(m_iSetOutNo,m_StoredDataNumber,GetStorageValue,GetStorageNumber);
for(int i=0;i<*GetStorageNumber;i++)
{
switch(GetStorageValue[i].FloatResult)
{
case LKIF_FLOATRESULT_RANGEOVER_P:
{
*GetStorageData++=50;
break;
}
case LKIF_FLOATRESULT_RANGEOVER_N:
{
*GetStorageData++=-50;
break;
}
case LKIF_FLOATRESULT_WAITING:
{
*GetStorageData++=0;
break;
}
default:
{
*GetStorageData++=GetStorageValue[i].Value;
break;
}
}
}
}
return bStatus;
};
//==============================================
BOOL CSo7_Interface::GetStoreDataStatus()
float Laserval[1000];
int LaserNum(0);
m_pGET_LASER_STORED_DATA(Laserval,&LaserNum);
}
//========================================
void CSo7_Interface::PauseScanAndGetData(void)
{
BOOL bStatus(FALSE);
bStatus=m_pDataStorageGetStatus(m_iSetOutNo,&m_bIsStorage,&m_StoredDataNumber);
return bStatus;
};
float Laserval[1000];
int LaserNum(0);
m_pPAUSE_SCAN_AND_GET_LASER_DATA(Laserval,&LaserNum);
}
@@ -9,52 +9,34 @@
#pragma once
#endif // _MSC_VER > 1000
typedef int (WINAPI* pGetLaserStoredData) (float *GetStorageData,int *GetStorageNumber);
// Starting the Data Storage
typedef BOOL (WINAPI* pLKIF_DataStorageStart)(void);
// Stopping the Data Storage
typedef BOOL (WINAPI* pLKIF_DataStorageStop)(void);
// Initializing the Data Storage
typedef BOOL (WINAPI* pLKIF_DataStorageInit)(void);
// Outputting the Data Storage
typedef BOOL (WINAPI* pLKIF_DataStorageGetData)(IN int OutNo,IN int NumOutBuffer,OUT LKIF_FLOATVALUE *OutBuffer,OUT int *NumReceived);
// Data Storage Accumulation Status Output
typedef BOOL (WINAPI* pLKIF_DataStorageGetStatus)(IN int OutNo,OUT BOOL *IsStorage,OUT int *NumStorageData);
// Set Data Storage
typedef BOOL (WINAPI* pLKIF_SetDataStorage)(IN LKIF_TARGETOUT TargetOut,IN int NumStorage,IN LKIF_STORAGECYCLE StorageCycle);
typedef void (_cdecl*PRO_CMD)(int nCmd,LPARAM value);
typedef int (_cdecl*GET_LASER_STORED_DATA)(float *GetStorageData,int *GetStorageNumber);
typedef int (_cdecl*PAUSE_SCAN_AND_GET_LASER_DATA)(float *GetStorageData,int *GetStorageNumber);
typedef void (_cdecl*GET_SCAN_LASER_STORAGE_STATUS)(int& _bStatus,int& _StorageNumber);
//======================================================================================
class CSo7_Interface
{
protected:
int m_iSetOutNo;
int m_NeedStorageDataNumber;
LKIF_STORAGECYCLE m_StorageCycle;
HINSTANCE m_hImageDLL;
Dev_Info Image_Info;
public:
CSo7_Interface();
~CSo7_Interface();
//»ñÈ¡Êý¾ÝµÄº¯ÊýÖ¸Õë
pLKIF_GetCalcData m_pGetCalcData;
pLKIF_DataStorageStart m_pDataStorageStart;
pLKIF_DataStorageStop m_pDataStorageStop;
pLKIF_DataStorageInit m_pDataStorageInit;
pLKIF_DataStorageGetData m_pDataStorageGetData;
pLKIF_DataStorageGetStatus m_pDataStorageGetStatus;
pLKIF_SetDataStorage m_pSetDataStorage;
PRO_CMD Pro_cmd;
GET_LASER_STORED_DATA m_pGET_LASER_STORED_DATA;
PAUSE_SCAN_AND_GET_LASER_DATA m_pPAUSE_SCAN_AND_GET_LASER_DATA;
GET_SCAN_LASER_STORAGE_STATUS m_pGET_SCAN_LASER_STORAGE_STATUS;
void InitDll();
int m_StoredDataNumber;
BOOL m_bIsStorage;
void KeyenceLaserInit(void);
void Get_KeyenceLaserData(float *LaserValue1,float *LaserValue2);
BOOL StartStoreData(int _NeedStorageDataNumber,int _SampleTime);
BOOL StopStoreData();
BOOL GetStoreDataStatus();
BOOL GetStoredData(float *GetStorageData,int *GetStorageNumber);
BOOL PauseScanAndGetData(float *GetStorageData,int *GetStorageNumber);
void StartStoreData();
void StopStoreData();
void GetStorageStatus();
void GetStoredData();
void PauseScanAndGetData();
};
#endif