Machine Interface Utility:VER1.0
This commit is contained in:
@@ -0,0 +1,237 @@
|
||||
#include "StdAfx.h"
|
||||
#include <WinDef.h>
|
||||
#include <WinBase.h>
|
||||
#include "Keyence_Laser.h"
|
||||
|
||||
#define MAX_STORAGE_DATA_SIZE 65536
|
||||
|
||||
CKeyence_Laser::CKeyence_Laser()
|
||||
{
|
||||
m_bIsStorage=FALSE;
|
||||
m_iSetOutNo=0;
|
||||
m_StoredDataNumber=0;
|
||||
m_NeedStorageDataNumber=0;
|
||||
m_StorageCycle=LKIF_STORAGECYCLE_100;
|
||||
}
|
||||
|
||||
CKeyence_Laser::~CKeyence_Laser()
|
||||
{
|
||||
FreeLibrary(m_hLkif);
|
||||
}
|
||||
//========================================
|
||||
void CKeyence_Laser::KeyenceLaserInit(void)
|
||||
{
|
||||
m_hLkif=LoadLibrary(_T("LkIF.dll"));
|
||||
if(m_hLkif)
|
||||
{
|
||||
m_pGetCalcData=(pLKIF_GetCalcData)GetProcAddress(m_hLkif,"LKIF_GetCalcData");
|
||||
m_pDataStorageStart=(pLKIF_DataStorageStart)GetProcAddress(m_hLkif,"LKIF_DataStorageStart");
|
||||
m_pDataStorageStop=(pLKIF_DataStorageStop)GetProcAddress(m_hLkif,"LKIF_DataStorageStop");
|
||||
m_pDataStorageInit=(pLKIF_DataStorageInit)GetProcAddress(m_hLkif,"LKIF_DataStorageInit");
|
||||
m_pDataStorageGetData=(pLKIF_DataStorageGetData)GetProcAddress(m_hLkif,"LKIF_DataStorageGetData");
|
||||
m_pDataStorageGetStatus=(pLKIF_DataStorageGetStatus)GetProcAddress(m_hLkif,"LKIF_DataStorageGetStatus");
|
||||
m_pSetDataStorage=(pLKIF_SetDataStorage)GetProcAddress(m_hLkif,"LKIF_SetDataStorage");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
//==============================================
|
||||
void CKeyence_Laser::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 CKeyence_Laser::StartStoreData(int _NeedStorageDataNumber,int _SampleTime)
|
||||
{
|
||||
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 CKeyence_Laser::StopStoreData()
|
||||
{
|
||||
BOOL bStatus(FALSE);
|
||||
GetStoreDataStatus();
|
||||
if (m_bIsStorage)
|
||||
{
|
||||
bStatus=m_pDataStorageStop();
|
||||
}
|
||||
return bStatus;
|
||||
};
|
||||
//==============================================
|
||||
BOOL CKeyence_Laser::PauseScanAndGetData(float *GetStorageData,int *GetStorageNumber)
|
||||
{
|
||||
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 CKeyence_Laser::GetStoredData(float *GetStorageData,int *GetStorageNumber)
|
||||
{
|
||||
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 CKeyence_Laser::GetStoreDataStatus()
|
||||
{
|
||||
BOOL bStatus(FALSE);
|
||||
bStatus=m_pDataStorageGetStatus(m_iSetOutNo,&m_bIsStorage,&m_StoredDataNumber);
|
||||
return bStatus;
|
||||
};
|
||||
@@ -0,0 +1,61 @@
|
||||
// protocol for control SevenOcean's Machine
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
#ifndef AFX_KEYENCE__LASER_H__B422904C_2CEB_495B_B7BD_B45AB30286DD__INCLUDED_
|
||||
#define AFX_KEYENCE__LASER_H__B422904C_2CEB_495B_B7BD_B45AB30286DD__INCLUDED_
|
||||
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
|
||||
#include "LkIF.h"
|
||||
|
||||
typedef BOOL (WINAPI* pLKIF_GetCalcData)(OUT LKIF_FLOATVALUE *CalcData1,OUT LKIF_FLOATVALUE *CalcData2);
|
||||
// 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);
|
||||
|
||||
//======================================================================================
|
||||
class CKeyence_Laser
|
||||
{
|
||||
protected:
|
||||
int m_iSetOutNo;
|
||||
int m_NeedStorageDataNumber;
|
||||
LKIF_STORAGECYCLE m_StorageCycle;
|
||||
HINSTANCE m_hLkif;
|
||||
public:
|
||||
|
||||
CKeyence_Laser();
|
||||
~CKeyence_Laser();
|
||||
|
||||
//»ñÈ¡Êý¾ÝµÄº¯ÊýÖ¸Õë
|
||||
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;
|
||||
|
||||
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);
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,660 @@
|
||||
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "Keyence_Proto.h"
|
||||
#include "math.h"
|
||||
|
||||
|
||||
|
||||
#define MY_CONFIG 1
|
||||
#define MAX_DEVPATH_LENGTH 256
|
||||
#define ENDPOINT_TIMEOUT 500
|
||||
|
||||
//***** Static Data *****
|
||||
struct_Keyence_ep_buff CKeyence_Proto::ep_buff[lEPSIZE];
|
||||
|
||||
//================================================================
|
||||
int CKeyence_Proto::g_hEP81_Thread_State=THREAD_PAUSED;
|
||||
HANDLE CKeyence_Proto::g_hEP81_Thread_Id=NULL;
|
||||
|
||||
//================================================================
|
||||
int CKeyence_Proto::g_hEP82_Thread_State=THREAD_PAUSED;
|
||||
HANDLE CKeyence_Proto::g_hEP82_Thread_Id=NULL;
|
||||
|
||||
//================================================================
|
||||
int CKeyence_Proto::g_hEP01_Thread_State=THREAD_PAUSED;
|
||||
HANDLE CKeyence_Proto::g_hEP01_Thread_Id=NULL;
|
||||
HANDLE CKeyence_Proto::g_hEP01_Serial_Mutex;
|
||||
|
||||
//================================================================
|
||||
int CKeyence_Proto::g_hEP02_Thread_State=THREAD_PAUSED;
|
||||
HANDLE CKeyence_Proto::g_hEP02_Thread_Id=NULL;
|
||||
HANDLE CKeyence_Proto::g_hEP02_Serial_Mutex;
|
||||
|
||||
//================================================================
|
||||
struct_Keyence_machine CKeyence_Proto::g_machine;
|
||||
usb_dev_handle *CKeyence_Proto::g_dev=NULL;
|
||||
CLogger *CKeyence_Proto::g_pLogger;
|
||||
HANDLE CKeyence_Proto::g_hHomedEvent = NULL;
|
||||
|
||||
//===========================================================================
|
||||
// Worker Thread to serialize EP_KEYENCE_01 commands.
|
||||
//===========================================================================
|
||||
unsigned __stdcall CKeyence_Proto::g_EP01_Thread(LPVOID pThis)
|
||||
{
|
||||
CKeyence_Proto* _This = (CKeyence_Proto*)pThis;
|
||||
for (;;)
|
||||
{
|
||||
TRACE0("g_hSerialUsbThread in loop set.\n");
|
||||
if (g_hEP01_Thread_State == THREAD_EXIT)
|
||||
ExitThread(0);
|
||||
WaitForSingleObject(ep_buff[EP_01_CMD_IDX]._event,INFINITE);
|
||||
TRACE0("g_hSerialUsbThread obtained event.\n");
|
||||
switch (g_hEP01_Thread_State)
|
||||
{
|
||||
case THREAD_EXIT:
|
||||
{
|
||||
ExitThread(0);
|
||||
}
|
||||
case THREAD_PAUSED:
|
||||
break;
|
||||
case THREAD_RUNNING:
|
||||
{
|
||||
TRACE0("g_hSerialUsbThread processing _send_usb_data();\n");
|
||||
_This->_send_usb_data(EP_01_CMD_IDX);
|
||||
TRACE0("g_hSerialUsbThread return from _send_usb_data();\n");
|
||||
break;
|
||||
}
|
||||
default:
|
||||
ExitThread(0);
|
||||
}
|
||||
};
|
||||
g_hEP01_Thread_State = THREAD_EXIT;
|
||||
ExitThread(0);
|
||||
};
|
||||
|
||||
//===========================================================================
|
||||
// Worker Thread to serialize EP_KEYENCE_02 commands.
|
||||
//===========================================================================
|
||||
unsigned __stdcall CKeyence_Proto::g_EP02_Thread(LPVOID pThis)
|
||||
{
|
||||
CKeyence_Proto* _This = (CKeyence_Proto*)pThis;
|
||||
for (;;)
|
||||
{
|
||||
TRACE0("g_hEP02_Thread in loop set.\n");
|
||||
if (g_hEP02_Thread_State == THREAD_EXIT)
|
||||
ExitThread(0);
|
||||
WaitForSingleObject(ep_buff[EP_02_CMD_IDX]._event,INFINITE);
|
||||
TRACE0("g_hEP02_Thread obtained event.\n");
|
||||
switch (g_hEP02_Thread_State)
|
||||
{
|
||||
case THREAD_EXIT:
|
||||
{
|
||||
ExitThread(0);
|
||||
}
|
||||
case THREAD_PAUSED:
|
||||
break;
|
||||
case THREAD_RUNNING:
|
||||
{
|
||||
TRACE0("g_hEP02_Thread calling _send_usb_data. EP_KEYENCE_02; %x\n");
|
||||
_This->_send_usb_data(EP_02_CMD_IDX);
|
||||
TRACE0("g_hEP02_Thread return _send_usb_data. EP_KEYENCE_02; %x\n");
|
||||
break;
|
||||
}
|
||||
default:
|
||||
ExitThread(0);
|
||||
}
|
||||
};
|
||||
g_hEP02_Thread_State = THREAD_EXIT;
|
||||
ExitThread(0);
|
||||
};
|
||||
|
||||
//******************************************************************************
|
||||
// This is the worker thread to process USBD_TRANSFER_DIRECTION_IN
|
||||
//******************************************************************************
|
||||
unsigned __stdcall CKeyence_Proto::g_EP81_Thread(LPVOID pThis)
|
||||
{
|
||||
CKeyence_Proto* _This = (CKeyence_Proto*)pThis;
|
||||
for (;;)
|
||||
{
|
||||
WaitForSingleObject(ep_buff[EP_81_DATA_IDX]._event, INFINITE);
|
||||
switch (g_hEP81_Thread_State)
|
||||
{
|
||||
case THREAD_EXIT:
|
||||
{
|
||||
ExitThread(0);
|
||||
}
|
||||
case THREAD_PAUSED:
|
||||
break;
|
||||
case THREAD_RUNNING:
|
||||
{
|
||||
_This->_reap_async_8x(EP_81_DATA_IDX);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
ExitThread(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//******************************************************************************
|
||||
// This is the worker thread to process USBD_TRANSFER_DIRECTION_IN
|
||||
//******************************************************************************
|
||||
unsigned __stdcall CKeyence_Proto::g_EP82_Thread(LPVOID pThis)
|
||||
{
|
||||
CKeyence_Proto* _This = (CKeyence_Proto*)pThis;
|
||||
for (;;)
|
||||
{
|
||||
WaitForSingleObject(ep_buff[EP_82_DATA_IDX]._event, INFINITE);
|
||||
switch (g_hEP82_Thread_State)
|
||||
{
|
||||
case THREAD_EXIT:
|
||||
{
|
||||
ExitThread(0);
|
||||
}
|
||||
case THREAD_PAUSED:
|
||||
break;
|
||||
case THREAD_RUNNING:
|
||||
{
|
||||
_This->_reap_async_8x(EP_82_DATA_IDX);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
ExitThread(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
void CKeyence_Proto::Trace_EP_Buff(long lIndex)
|
||||
{
|
||||
UCHAR tmp[256];
|
||||
CString csTmp;
|
||||
memcpy(tmp, ep_buff[lIndex]._buffer, ep_buff[lIndex]._size);
|
||||
csTmp = _T("Trace_EP_Buff _59 ");
|
||||
for (int ii= 0 ; ii < ep_buff[lIndex]._size ; ++ii)
|
||||
{
|
||||
CString csTmpHex;
|
||||
csTmpHex.Format(_T("%2X"), tmp[ii] );
|
||||
csTmp += csTmpHex;
|
||||
}
|
||||
TRACE1("_process_KEYENCE_CMD_GET_INDEX_4E() Trace_EP_Buff %s \n", csTmp);
|
||||
}
|
||||
|
||||
|
||||
//******************************************************************************
|
||||
// Parse the data received based on the index (which EP are we processing).
|
||||
// The CCmdObj should only have one CMD_STATUS_PROCESSING.
|
||||
// Update CCmdObj _ep_01_status and _ep_81_status.
|
||||
// Update _status to CMD_STATUS_COMPLETE when both _ep_01_status and _ep_81_status
|
||||
// are CMD_STATUS_COMPLETE.
|
||||
//
|
||||
//******************************************************************************
|
||||
void CKeyence_Proto::_process_rcv_transfer_data(int iEP)
|
||||
{
|
||||
static long lRcvCnt = 0;
|
||||
static long lRcvCnt2 = 0;
|
||||
switch (iEP)
|
||||
{
|
||||
case EP_01_CMD_IDX :
|
||||
TRACE0("_process_rcv_transfer_data() : Update EP_01_CMD_IDX.\r\n");
|
||||
++lRcvCnt;
|
||||
break;
|
||||
case EP_81_DATA_IDX : //
|
||||
++lRcvCnt;
|
||||
TRACE0("_process_rcv_transfer_data() : Update EP_81_DATA_IDX status.\r\n");
|
||||
break;
|
||||
case EP_02_CMD_IDX :
|
||||
TRACE0("_process_rcv_transfer_data() : Update EP_02_CMD_IDX.\r\n");
|
||||
++lRcvCnt2;
|
||||
break;
|
||||
case EP_82_DATA_IDX :
|
||||
// parse result and put into its proper place.
|
||||
_process_KEYENCE_CMD_GET_LASER_DATA();
|
||||
++lRcvCnt2;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
};
|
||||
lRcvCnt = (lRcvCnt == 2) ? 0:lRcvCnt;
|
||||
lRcvCnt2 = (lRcvCnt2 == 2) ? 0:lRcvCnt2;
|
||||
};
|
||||
|
||||
|
||||
//******************************************************************************
|
||||
CKeyence_Proto::CKeyence_Proto()
|
||||
{
|
||||
ep_buff[EP_01_CMD_IDX]._ep = EP_KEYENCE_01;
|
||||
ep_buff[EP_81_DATA_IDX]._ep = EP_KEYENCE_81;
|
||||
ep_buff[EP_02_CMD_IDX]._ep = EP_KEYENCE_02;
|
||||
ep_buff[EP_82_DATA_IDX]._ep = EP_KEYENCE_82;
|
||||
|
||||
for (int i=0;i<lEPSIZE;i++)
|
||||
{
|
||||
ep_buff[i]._size = 0;
|
||||
ep_buff[i]._save_send_cmd = 99;
|
||||
ep_buff[i]._async_context = NULL;
|
||||
ep_buff[i]._buffer = (char *)malloc(MAX_BUFF_SIZE);
|
||||
ep_buff[i]._hProtoPending = false;
|
||||
ep_buff[i]._event = NULL;
|
||||
};
|
||||
|
||||
|
||||
g_pLogger = new CLogger(_T("UtilityDebug.Log"));
|
||||
};
|
||||
|
||||
//******************************************************************************
|
||||
CKeyence_Proto::~CKeyence_Proto()
|
||||
{
|
||||
for (int i=0;i<lEPSIZE;i++)
|
||||
{
|
||||
free(ep_buff[i]._buffer);
|
||||
};
|
||||
delete g_pLogger;
|
||||
g_pLogger = NULL;
|
||||
}
|
||||
|
||||
#pragma warning(disable:4996)
|
||||
//******************************************************************************
|
||||
|
||||
//******************************************************************************
|
||||
usb_dev_handle* CKeyence_Proto::_open_usb_dev(void)
|
||||
{
|
||||
struct usb_bus *bus = NULL;
|
||||
struct usb_device *dev = NULL;
|
||||
|
||||
for (bus = usb_get_busses(); bus; bus = bus->next)
|
||||
{
|
||||
for (dev = bus->devices; dev; dev = dev->next)
|
||||
{
|
||||
if (dev->descriptor.idVendor == KEYENCE_VID && dev->descriptor.idProduct == KEYENCE_PID)
|
||||
{
|
||||
return usb_open(dev);
|
||||
}
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
//******************************************************************************
|
||||
SSI_STATUS_MOTION CKeyence_Proto::_usb_reset(void)
|
||||
{
|
||||
if (g_dev)
|
||||
{
|
||||
usb_reset(g_dev);
|
||||
g_dev = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
ASSERT(0);
|
||||
return SSI_STATUS_MOTION_TIMEOUT;
|
||||
}
|
||||
return SSI_STATUS_MOTION_TIMEOUT;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//******************************************************************************
|
||||
// Send is direct and async.
|
||||
// The receive thread will receive data and interpret it.
|
||||
//******************************************************************************
|
||||
SSI_STATUS_MOTION CKeyence_Proto::Init_MvUsb()
|
||||
{
|
||||
// Set initial state of the machine
|
||||
g_machine.s_status._machine_running = false;
|
||||
|
||||
SSI_STATUS_MOTION Status=SSI_STATUS_MOTION_NORMAL;
|
||||
UNREFERENCED_PARAMETER(Status);
|
||||
/*if (g_pLogger->m_lLogMask & LOGACTIONS)
|
||||
g_pLogger->SendAndFlushPerMode(_T("Enter Initialize Mv Usb\n"));
|
||||
*/
|
||||
int usb_status = NULL;
|
||||
usb_init(); // initialize the library
|
||||
usb_status = usb_find_busses(); // find all busses
|
||||
usb_status = usb_find_devices(); // find all connected devices
|
||||
g_dev = _open_usb_dev();
|
||||
if (!g_dev)
|
||||
{
|
||||
MessageBox(NULL, _T("Unable to open device"), _T("Message"), MB_OK);
|
||||
g_pLogger->SendAndFlushPerMode(_T("Unable to open device %s"), usb_strerror());
|
||||
return SSI_STATUS_MOTION_DATALINK_ERROR;
|
||||
}
|
||||
|
||||
if (usb_set_configuration(g_dev, MY_CONFIG) < 0)
|
||||
{
|
||||
MessageBox(NULL, _T("Unable to SET CONFIGURATION"), _T("Message"), MB_OK);
|
||||
return SSI_STATUS_MOTION_DATALINK_ERROR;
|
||||
}
|
||||
|
||||
if (usb_claim_interface(g_dev, 0) < 0)
|
||||
{
|
||||
usb_close(g_dev);
|
||||
MessageBox(NULL, _T("Unable to CLAIM DEVICE"), _T("Message"), MB_OK);
|
||||
return SSI_STATUS_MOTION_DATALINK_ERROR;
|
||||
}
|
||||
|
||||
// ********************************************************************
|
||||
// This event is used to kick the Serial Usb Command process. This threading model
|
||||
// is important because the underlying library is not thread-safe.
|
||||
//
|
||||
ep_buff[EP_01_CMD_IDX]._event = CreateEvent(NULL, // default security attributes
|
||||
FALSE, // manual reset event object
|
||||
NULL, // signaled
|
||||
NULL); // unamed object
|
||||
|
||||
g_hEP01_Thread_Id = CreateThread( (LPSECURITY_ATTRIBUTES) NULL,
|
||||
0,
|
||||
(LPTHREAD_START_ROUTINE) g_EP01_Thread,
|
||||
(LPVOID) this,
|
||||
0,
|
||||
NULL);
|
||||
g_hEP01_Thread_State = THREAD_RUNNING;
|
||||
|
||||
|
||||
// ********************************************************************
|
||||
// This event is used to kick the Serial Usb Command process. This threading model
|
||||
// is important because the underlying library is not thread-safe.
|
||||
//
|
||||
ep_buff[EP_02_CMD_IDX]._event = CreateEvent(NULL, // default security attributes
|
||||
FALSE, // manual reset event object
|
||||
NULL, // signaled
|
||||
NULL); // unamed object
|
||||
|
||||
g_hEP02_Thread_Id = CreateThread( (LPSECURITY_ATTRIBUTES) NULL,
|
||||
0,
|
||||
(LPTHREAD_START_ROUTINE) g_EP02_Thread,
|
||||
(LPVOID) this,
|
||||
0,
|
||||
NULL);
|
||||
g_hEP02_Thread_State = THREAD_RUNNING;
|
||||
|
||||
// ********************************************************************
|
||||
// Prepare and start EP_KEYENCE_81 Thread - Use async commit.
|
||||
//
|
||||
ep_buff[EP_81_DATA_IDX]._event = CreateEvent(NULL, // default security attributes
|
||||
FALSE, // manual reset event object
|
||||
NULL, // signaled
|
||||
NULL); // unamed object
|
||||
g_hEP81_Thread_State = THREAD_PAUSED;
|
||||
g_hEP81_Thread_Id = CreateThread( (LPSECURITY_ATTRIBUTES) NULL,
|
||||
0,
|
||||
(LPTHREAD_START_ROUTINE) g_EP81_Thread,
|
||||
(LPVOID) this,
|
||||
0,
|
||||
NULL);
|
||||
g_hEP01_Serial_Mutex = CreateMutex(NULL, // default security attributes
|
||||
FALSE, // initial owner
|
||||
NULL); // name
|
||||
|
||||
// ********************************************************************
|
||||
// Prepare and start EP_KEYENCE_82 Thread - Use async commit.
|
||||
//
|
||||
ep_buff[EP_82_DATA_IDX]._event = CreateEvent(NULL, // default security attributes
|
||||
FALSE, // manual reset event object
|
||||
NULL, // signaled
|
||||
NULL); // unamed object
|
||||
g_hEP82_Thread_State = THREAD_PAUSED;
|
||||
g_hEP82_Thread_Id = CreateThread( (LPSECURITY_ATTRIBUTES) NULL,
|
||||
0,
|
||||
(LPTHREAD_START_ROUTINE) g_EP82_Thread,
|
||||
(LPVOID) this,
|
||||
0,
|
||||
NULL);
|
||||
g_hEP02_Serial_Mutex = CreateMutex(NULL, // default security attributes
|
||||
FALSE, // initial owner
|
||||
NULL); // name
|
||||
|
||||
|
||||
// *********************************************************************
|
||||
g_hHomedEvent = CreateEvent(NULL, // default security attributes
|
||||
TRUE, // manual reset event object
|
||||
FALSE, // initial state is signaled
|
||||
NULL); // unamed object
|
||||
|
||||
//if (g_pLogger->m_lLogMask & LOGACTIONS)
|
||||
// g_pLogger->SendAndFlushPerMode(_T("Exit Initialize Usb\n"));
|
||||
return SSI_STATUS_MOTION_NORMAL;
|
||||
}
|
||||
|
||||
//******************************************************************************
|
||||
SSI_STATUS_MOTION CKeyence_Proto::Exit_MvUsb()
|
||||
{
|
||||
SSI_STATUS_MOTION Status=SSI_STATUS_MOTION_NORMAL;
|
||||
//if (g_pLogger->m_lLogMask & LOGACTIONS)
|
||||
// g_pLogger->SendAndFlushPerMode(_T("Enter Exit_MvUsb\n"));
|
||||
|
||||
g_hEP81_Thread_State = THREAD_EXIT;
|
||||
g_hEP82_Thread_State = THREAD_EXIT;
|
||||
g_hEP01_Thread_State = THREAD_EXIT;
|
||||
g_hEP02_Thread_State = THREAD_EXIT;
|
||||
|
||||
SetEvent(ep_buff[EP_81_DATA_IDX]._event);
|
||||
if (g_hEP81_Thread_Id)
|
||||
{
|
||||
DWORD dwCode = STILL_ACTIVE;
|
||||
while (dwCode == STILL_ACTIVE)
|
||||
{
|
||||
GetExitCodeThread(g_hEP81_Thread_Id,&dwCode);
|
||||
Sleep(1);
|
||||
}
|
||||
}
|
||||
SetEvent(ep_buff[EP_82_DATA_IDX]._event);
|
||||
if (g_hEP82_Thread_Id)
|
||||
{
|
||||
DWORD dwCode = STILL_ACTIVE;
|
||||
while (dwCode == STILL_ACTIVE)
|
||||
{
|
||||
GetExitCodeThread(g_hEP82_Thread_Id,&dwCode);
|
||||
Sleep(1);
|
||||
}
|
||||
}
|
||||
SetEvent(ep_buff[EP_01_CMD_IDX]._event);
|
||||
if (g_hEP01_Thread_Id)
|
||||
{
|
||||
DWORD dwCode = STILL_ACTIVE;
|
||||
while (dwCode == STILL_ACTIVE)
|
||||
{
|
||||
GetExitCodeThread(g_hEP01_Thread_Id,&dwCode);
|
||||
Sleep(1);
|
||||
}
|
||||
}
|
||||
SetEvent(ep_buff[EP_02_CMD_IDX]._event);
|
||||
if (g_hEP02_Thread_Id)
|
||||
{
|
||||
DWORD dwCode = STILL_ACTIVE;
|
||||
while (dwCode == STILL_ACTIVE)
|
||||
{
|
||||
GetExitCodeThread(g_hEP02_Thread_Id,&dwCode);
|
||||
Sleep(1);
|
||||
}
|
||||
}
|
||||
|
||||
if (g_dev)
|
||||
{
|
||||
usb_release_interface(g_dev,0);
|
||||
usb_close(g_dev);
|
||||
g_dev = NULL;
|
||||
}
|
||||
SetEvent(ep_buff[EP_81_DATA_IDX]._event);
|
||||
CloseHandle(ep_buff[EP_81_DATA_IDX]._event);
|
||||
SetEvent(ep_buff[EP_82_DATA_IDX]._event);
|
||||
CloseHandle(ep_buff[EP_82_DATA_IDX]._event);
|
||||
g_hEP01_Thread_State = THREAD_EXIT;
|
||||
SetEvent(ep_buff[EP_01_CMD_IDX]._event);
|
||||
CloseHandle(ep_buff[EP_01_CMD_IDX]._event);
|
||||
g_hEP02_Thread_State = THREAD_EXIT;
|
||||
SetEvent(ep_buff[EP_02_CMD_IDX]._event);
|
||||
CloseHandle(ep_buff[EP_02_CMD_IDX]._event);
|
||||
ReleaseMutex(g_hEP01_Serial_Mutex);
|
||||
CloseHandle(g_hEP01_Serial_Mutex);
|
||||
ReleaseMutex(g_hEP02_Serial_Mutex);
|
||||
CloseHandle(g_hEP02_Serial_Mutex);
|
||||
|
||||
//if (g_pLogger->m_lLogMask & LOGACTIONS)
|
||||
// g_pLogger->SendAndFlushPerMode(_T("Exit Exit_MvUsb\n"));
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
//******************************************************************************
|
||||
// Kick the g_hEP01_Thread_Event to get the g_EP01_Thread going.
|
||||
// iEP = EP_KEYENCE_01 or EP_KEYENCE_02 = 0x01 or 0x02
|
||||
//******************************************************************************
|
||||
SSI_STATUS_MOTION CKeyence_Proto::_do_single_threaded_usb_comm(int iEP_Base)
|
||||
{
|
||||
TRACE1("=====_do_single_threaded_usb_comm(iEP) g_hEP01_Thread_Event. %x\n", iEP_Base);
|
||||
while ((ep_buff[iEP_Base]._hProtoPending == TRUE) || (ep_buff[iEP_Base+1]._hProtoPending == TRUE))
|
||||
{
|
||||
ASSERT(0);
|
||||
Sleep(3);
|
||||
}
|
||||
ep_buff[iEP_Base]._hProtoPending = ep_buff[iEP_Base+1]._hProtoPending = TRUE;
|
||||
TRACE1("=====_do_single_threaded_usb_comm(iEP_Base) SetEvent(g_hEP01_Thread_Event): %X \r\n", ep_buff[iEP_Base]._save_send_cmd);
|
||||
SetEvent(ep_buff[iEP_Base]._event);
|
||||
while ((ep_buff[iEP_Base]._hProtoPending == TRUE) || (ep_buff[iEP_Base+1]._hProtoPending == TRUE))
|
||||
{
|
||||
Sleep(3);
|
||||
}
|
||||
TRACE1("=====_do_single_threaded_usb_comm(iEP) g_hProtoDoneEvents. %x\n", iEP_Base);
|
||||
return SSI_STATUS_MOTION_NORMAL;
|
||||
}
|
||||
|
||||
//******************************************************************************
|
||||
// This startup just kicks off the EP_KEYENCE_81 worker thread.
|
||||
//******************************************************************************
|
||||
SSI_STATUS_MOTION CKeyence_Proto::_start_machine()
|
||||
{
|
||||
g_hEP81_Thread_State = THREAD_RUNNING;
|
||||
g_hEP82_Thread_State = THREAD_RUNNING;
|
||||
g_machine.s_status._machine_running = true;
|
||||
return SSI_STATUS_MOTION_NORMAL;
|
||||
};
|
||||
|
||||
//===============================================================================
|
||||
SSI_STATUS_MOTION CKeyence_Proto::_shutdown_machine()
|
||||
{
|
||||
g_machine.s_status._machine_running = false;
|
||||
return SSI_STATUS_MOTION_NORMAL;
|
||||
};
|
||||
|
||||
//===============================================================================
|
||||
// iEP = EP_KEYENCE_01 or EP_KEYENCE_02
|
||||
//===============================================================================
|
||||
SSI_STATUS_MOTION CKeyence_Proto::_submit_async_8x(int iEP_Base)
|
||||
{
|
||||
int _ret;
|
||||
_ret = usb_bulk_setup_async(g_dev, &(ep_buff[iEP_Base]._async_context), (unsigned char)ep_buff[iEP_Base]._ep);
|
||||
if (_ret < 0)
|
||||
{
|
||||
return SSI_STATUS_MOTION_SETUP_ASYNC_CONTEXT_ERROR;
|
||||
}
|
||||
_ret = usb_submit_async(ep_buff[iEP_Base]._async_context, ep_buff[iEP_Base]._buffer, ep_buff[iEP_Base]._size);
|
||||
if (_ret < 0)
|
||||
{
|
||||
printf("error usb_submit_async_ep_xx:\n%s\n", usb_strerror());
|
||||
return SSI_STATUS_MOTION_SETUP_ASYNC_CONTEXT_ERROR;
|
||||
}
|
||||
return SSI_STATUS_MOTION_NORMAL;
|
||||
}
|
||||
|
||||
//===============================================================================
|
||||
// iEP_Base : EP_81_DATA_IDX/EP_82_DATA_IDX
|
||||
//
|
||||
//===============================================================================
|
||||
SSI_STATUS_MOTION CKeyence_Proto::_reap_async_8x(int iEP_Base)
|
||||
{
|
||||
int _ret;
|
||||
_ret = usb_reap_async(ep_buff[iEP_Base]._async_context, 1000);
|
||||
if (_ret > 0)
|
||||
{
|
||||
_process_rcv_transfer_data(iEP_Base);
|
||||
usb_free_async(&(ep_buff[iEP_Base]._async_context));
|
||||
ep_buff[iEP_Base]._hProtoPending = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
usb_free_async(&(ep_buff[iEP_Base]._async_context));
|
||||
ASSERT(0);
|
||||
return SSI_STATUS_MOTION_TIMEOUT;
|
||||
}
|
||||
return SSI_STATUS_MOTION_NORMAL;
|
||||
}
|
||||
|
||||
//===============================================================================
|
||||
// _send_usb_data(iEP) sends data to the corresponding iEP channel.
|
||||
// iEP = EP_KEYENCE_01 / EP_KEYENCE_02 EP_KEYENCE_01 = 0x01; EP_KEYENCE_02 = 0x02;
|
||||
//===============================================================================
|
||||
SSI_STATUS_MOTION CKeyence_Proto::_send_usb_data(int iEP_Base)
|
||||
{
|
||||
int _ret;
|
||||
ep_buff[iEP_Base]._save_send_cmd = ep_buff[iEP_Base]._buffer[0];
|
||||
ep_buff[iEP_Base]._save_send_cmd0 = ep_buff[iEP_Base]._buffer[1];
|
||||
ep_buff[iEP_Base]._save_send_cmd1 = ep_buff[iEP_Base]._buffer[2];
|
||||
|
||||
TRACE3("_send_usb_data() iEP : %X - ep_buff[iEP]._save_send_cmd : %X ._buffer[0] : %X\r\n", iEP_Base, ep_buff[EP_01_CMD_IDX]._save_send_cmd, ep_buff[EP_81_DATA_IDX]._buffer[0]);
|
||||
_ret = usb_bulk_setup_async(g_dev, &(ep_buff[iEP_Base]._async_context), (unsigned char)ep_buff[iEP_Base]._ep);
|
||||
if (_ret < 0)
|
||||
{
|
||||
return SSI_STATUS_MOTION_SETUP_ASYNC_CONTEXT_ERROR;
|
||||
}
|
||||
_ret = usb_submit_async(ep_buff[iEP_Base]._async_context, ep_buff[iEP_Base]._buffer, ep_buff[iEP_Base]._size);//send data
|
||||
if (_ret < 0)
|
||||
{
|
||||
printf("error usb_submit_async_ep_xx:\n%s\n", usb_strerror());
|
||||
return SSI_STATUS_MOTION_SETUP_ASYNC_CONTEXT_ERROR;
|
||||
}
|
||||
TRACE1("_submit_async_8x(EP:%X)\r\n", iEP_Base);
|
||||
//
|
||||
ep_buff[iEP_Base+1]._save_send_cmd = ep_buff[iEP_Base+1]._buffer[0];
|
||||
ep_buff[iEP_Base+1]._save_send_cmd0 = ep_buff[iEP_Base+1]._buffer[1];
|
||||
ep_buff[iEP_Base+1]._save_send_cmd1 = ep_buff[iEP_Base+1]._buffer[2];
|
||||
//
|
||||
_submit_async_8x(iEP_Base+1); // Send EP_KEYENCE_81/EP_KEYENCE_82
|
||||
// Get ready to receive on EP_KEYENCE_81 or EP_KEYENCE_82
|
||||
SetEvent(ep_buff[iEP_Base+1]._event);
|
||||
// Get ready to receive on EP_KEYENCE_01 or EP_KEYENCE_02
|
||||
_ret = usb_reap_async(ep_buff[iEP_Base]._async_context, 10000);
|
||||
if (_ret > 0)
|
||||
{
|
||||
_process_rcv_transfer_data(iEP_Base);
|
||||
usb_free_async(&(ep_buff[iEP_Base]._async_context));
|
||||
ep_buff[iEP_Base]._hProtoPending = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
usb_free_async(&(ep_buff[iEP_Base]._async_context));
|
||||
ASSERT(0);
|
||||
return SSI_STATUS_MOTION_TIMEOUT;
|
||||
}
|
||||
return SSI_STATUS_MOTION_NORMAL;
|
||||
}
|
||||
|
||||
//==============================================================
|
||||
SSI_STATUS_MOTION CKeyence_Proto::_send_cmd_KEYENCE_CMD_GET_LASER_DATA()
|
||||
{
|
||||
WaitForSingleObject(g_hEP01_Serial_Mutex, INFINITE);
|
||||
memset(ep_buff[EP_01_CMD_IDX]._buffer, 0x00, MAX_BUFF_SIZE);
|
||||
|
||||
ep_buff[EP_01_CMD_IDX]._buffer[0] = 0x00;
|
||||
ep_buff[EP_01_CMD_IDX]._buffer[1] = 0x01;
|
||||
ep_buff[EP_01_CMD_IDX]._buffer[2] = 0x01;
|
||||
ep_buff[EP_01_CMD_IDX]._buffer[3] = 0x01;
|
||||
ep_buff[EP_01_CMD_IDX]._buffer[4] = 0x01;
|
||||
ep_buff[EP_01_CMD_IDX]._buffer[5] = 0x01;
|
||||
|
||||
|
||||
ep_buff[EP_01_CMD_IDX]._size = 0x0C;
|
||||
ep_buff[EP_82_DATA_IDX]._size = 0x45;
|
||||
|
||||
_do_single_threaded_usb_comm(EP_01_CMD_IDX);
|
||||
ReleaseMutex(g_hEP01_Serial_Mutex);
|
||||
return SSI_STATUS_MOTION_NORMAL;
|
||||
};
|
||||
|
||||
|
||||
//==============================================================
|
||||
SSI_STATUS_MOTION CKeyence_Proto::_process_KEYENCE_CMD_GET_LASER_DATA()
|
||||
{
|
||||
|
||||
return SSI_STATUS_MOTION_NORMAL;
|
||||
};
|
||||
@@ -0,0 +1,180 @@
|
||||
// protocol for control SevenOcean's Machine
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
#ifndef AFX_KEYENCE_Proto_H__B422904C_2CEB_495B_B7BD_B45AB30286DD__INCLUDED_
|
||||
#define AFX_KEYENCE_Proto_H__B422904C_2CEB_495B_B7BD_B45AB30286DD__INCLUDED_
|
||||
|
||||
#define KEYENCE_TRACE if ( g_pLogger && g_pLogger->m_lLogMask & LOGACTIONS ) g_pLogger->SendAndFlushPerMode
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
|
||||
#include "..\Tools\UsbUtility\logger.h"
|
||||
#include "..\..\..\..\..\ThirdParty\UsbSupport\LibUsb_Win\Include\lusb0_usb.h"
|
||||
#include "..\MicroVu\SsiStatus.h"
|
||||
|
||||
#define MAX_BUFF_SIZE 0x200
|
||||
|
||||
#define USB_ENDPOINT_TYPE_CONTROL 0
|
||||
#define USB_ENDPOINT_TYPE_ISOCHRONOUS 1
|
||||
#define USB_ENDPOINT_TYPE_BULK 2
|
||||
#define USB_ENDPOINT_TYPE_INTERRUPT 3
|
||||
|
||||
#define USB_DEVICE_DESCRIPTOR_TYPE 1
|
||||
#define USB_CONFIGURATION_DESCRIPTOR_TYPE 2
|
||||
|
||||
#define THREAD_RUNNING 0
|
||||
#define THREAD_PAUSED 1
|
||||
#define THREAD_EXIT -1
|
||||
|
||||
// Device configuration and interface id.
|
||||
#define KEYENCE_USB_CONFIG 1
|
||||
#define KEYENCE_USB_INTF 0
|
||||
|
||||
|
||||
#define EP_KEYENCE_01 0x01
|
||||
#define EP_KEYENCE_02 0x02
|
||||
#define EP_KEYENCE_03 0x03
|
||||
#define EP_KEYENCE_81 0x82
|
||||
#define EP_KEYENCE_82 0x81
|
||||
#define EP_KEYENCE_84 0x84
|
||||
|
||||
#define EP_01_CMD_IDX 0 // index to usb buffers
|
||||
#define EP_81_DATA_IDX 1 //
|
||||
#define EP_02_CMD_IDX 2 //
|
||||
#define EP_82_DATA_IDX 3 //
|
||||
#define EP_03_CMD_IDX 4 //
|
||||
#define EP_84_DATA_IDX 5 //
|
||||
|
||||
#define lEPSIZE 6
|
||||
#define MAXRINGS 5 // for MicroVu Vertex 220
|
||||
#define MAXSEGS 8
|
||||
|
||||
|
||||
#pragma pack(push)
|
||||
#pragma pack(1)
|
||||
//****************************************************************************************************
|
||||
// Set the _status to Idle after reply data has been received.
|
||||
// How to recover? In order to send data, _status must be Idle. If the system is not available
|
||||
// for 1 second, assume something wrong and treat it as "TimeOut".
|
||||
// Another way to do this is to lock this structure is to use a mutex to ensure single-threaded
|
||||
// access.
|
||||
//****************************************************************************************************
|
||||
//====================================================================================================
|
||||
struct struct_Keyence_machine
|
||||
{ // g_machine structure
|
||||
struct s_status
|
||||
{
|
||||
bool _machine_running;
|
||||
} s_status;
|
||||
|
||||
};
|
||||
|
||||
|
||||
#define KEYENCE_VID 0x0720
|
||||
#define KEYENCE_PID 0x000A
|
||||
|
||||
//****************************************************************************************************
|
||||
// Binary SevenOcean command structure, out going
|
||||
//
|
||||
//****************************************************************************************************
|
||||
#define pKEYENCE_CMD_01 ((s_KEYENCE_CMD_BUFF_01 *) ep_buff[EP_01_CMD_IDX]._buffer)
|
||||
|
||||
struct s_KEYENCE_CMD_BUFF_01
|
||||
{
|
||||
UCHAR uCmdByte;
|
||||
//----------------------------------------------------------------------
|
||||
// [endpoint 0x00000001] 00000060 : 530001010100fffe1d89ffff4d37fffebeee000000000000c34e0000021a0000003200000000000f423b000029fb0000138800000000003d08ee00030d4000030d40000000000000000000000000000000000000000000000000000000000000
|
||||
// *Command : 53 Move To -- X Y Z ZM Scale-0123511 -0045769 -0082194 00000000
|
||||
// *Speed : 00049998 00000538 00000050 00000000
|
||||
// *Unk1 : 00999995 00010747 00005000 00000000
|
||||
// *Unk2 : 03999982 00200000 00200000 00000000
|
||||
union
|
||||
{
|
||||
struct
|
||||
{
|
||||
BYTE uSubCmdByte;
|
||||
char data[9];
|
||||
}S_KEYENCE_CMD_MOVE_XYZ;
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
//======================
|
||||
struct struct_Keyence_ep_buff
|
||||
{
|
||||
int _ep;
|
||||
BYTE _save_send_cmd;
|
||||
BYTE _save_send_cmd0;
|
||||
BYTE _save_send_cmd1;
|
||||
char *_buffer; // MAX_BUFF_SIZE
|
||||
int _size;
|
||||
void *_async_context;
|
||||
BOOL _hProtoPending;
|
||||
HANDLE _event;
|
||||
};
|
||||
|
||||
|
||||
//======================================================================================
|
||||
class CKeyence_Proto
|
||||
{
|
||||
public:
|
||||
// EP 01/81 channel threads.
|
||||
static int g_hEP81_Thread_State;
|
||||
static unsigned __stdcall g_EP81_Thread(LPVOID pThis);
|
||||
static HANDLE g_hEP81_Thread_Id;
|
||||
|
||||
// EP 02/82 channel threads.
|
||||
static int g_hEP82_Thread_State;
|
||||
static unsigned __stdcall g_EP82_Thread(LPVOID pThis);
|
||||
static HANDLE g_hEP82_Thread_Id;
|
||||
//
|
||||
// g_hEP01_Thread_Event is used to kick a command
|
||||
//
|
||||
static int g_hEP01_Thread_State;
|
||||
static unsigned __stdcall g_EP01_Thread(LPVOID pThis);
|
||||
static HANDLE g_hEP01_Thread_Id;
|
||||
static HANDLE g_hEP01_Serial_Mutex; // EP01
|
||||
//
|
||||
static int g_hEP02_Thread_State;
|
||||
static unsigned __stdcall g_EP02_Thread(LPVOID pThis);
|
||||
static HANDLE g_hEP02_Thread_Id;
|
||||
static HANDLE g_hEP02_Serial_Mutex; // EP02
|
||||
|
||||
static HANDLE g_hHomedEvent;
|
||||
|
||||
//
|
||||
CKeyence_Proto();
|
||||
virtual ~CKeyence_Proto();
|
||||
|
||||
// Global Structures
|
||||
static struct_Keyence_ep_buff ep_buff[lEPSIZE];
|
||||
static struct_Keyence_machine g_machine;
|
||||
|
||||
static CLogger* g_pLogger;
|
||||
static usb_dev_handle *g_dev;
|
||||
|
||||
SSI_STATUS_MOTION Init_MvUsb();
|
||||
SSI_STATUS_MOTION Exit_MvUsb();
|
||||
static void Trace_EP_Buff(long lIndex);
|
||||
static void _process_rcv_transfer_data(int iEP);
|
||||
usb_dev_handle* _open_usb_dev(void);
|
||||
SSI_STATUS_MOTION _usb_reset(void);
|
||||
|
||||
SSI_STATUS_MOTION _start_machine();
|
||||
SSI_STATUS_MOTION _shutdown_machine();
|
||||
SSI_STATUS_MOTION _do_single_threaded_usb_comm(int iEP);
|
||||
SSI_STATUS_MOTION _submit_async_8x(int iEP_Base);
|
||||
SSI_STATUS_MOTION _reap_async_8x(int iEP_Base);
|
||||
SSI_STATUS_MOTION _send_usb_data(int iEP_Base);
|
||||
|
||||
SSI_STATUS_MOTION _send_cmd_KEYENCE_CMD_GET_LASER_DATA();
|
||||
static SSI_STATUS_MOTION _process_KEYENCE_CMD_GET_LASER_DATA();
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,320 @@
|
||||
#ifndef LKIF_INCLUDED
|
||||
#define LKIF_INCLUDED
|
||||
|
||||
#ifdef I_AM_LKIF
|
||||
#define EXP __declspec(dllexport)
|
||||
#else
|
||||
#define EXP __declspec(dllimport)
|
||||
#endif
|
||||
|
||||
extern "C"
|
||||
{
|
||||
// Measurement value structures
|
||||
typedef enum {
|
||||
LKIF_FLOATRESULT_VALID, // valid data
|
||||
LKIF_FLOATRESULT_RANGEOVER_P, // over range at positive (+) side
|
||||
LKIF_FLOATRESULT_RANGEOVER_N, // over range at negative (-) side
|
||||
LKIF_FLOATRESULT_WAITING, // comparator result
|
||||
} LKIF_FLOATRESULT;
|
||||
|
||||
typedef struct {
|
||||
LKIF_FLOATRESULT FloatResult; // valid or invalid data
|
||||
float Value; // measurement value during LKIF_FLOATRESULT_VALID.
|
||||
// Any other times will return an invalid value
|
||||
} LKIF_FLOATVALUE;
|
||||
///////////////////////////////////////////////
|
||||
// Measurement Control Command
|
||||
//
|
||||
// Measurement Value Output
|
||||
EXP BOOL WINAPI LKIF_GetCalcData(OUT LKIF_FLOATVALUE *CalcData1,OUT LKIF_FLOATVALUE *CalcData2);
|
||||
// Timing ON/OFF
|
||||
EXP BOOL WINAPI LKIF_SetTiming(IN int OutNo,IN BOOL IsOn);
|
||||
// Auto-zero ON/OFF
|
||||
EXP BOOL WINAPI LKIF_SetZero(IN int OutNo,IN BOOL IsOn);
|
||||
// Reset
|
||||
EXP BOOL WINAPI LKIF_SetReset(IN int OutNo);
|
||||
// Panel Lock
|
||||
EXP BOOL WINAPI LKIF_SetPanelLock(IN BOOL IsLock);
|
||||
// Program Change
|
||||
EXP BOOL WINAPI LKIF_SetProgramNo(IN int ProgramNo);
|
||||
// Program Check
|
||||
EXP BOOL WINAPI LKIF_GetProgramNo(OUT int *ProgramNo);
|
||||
// Statistical Results Output
|
||||
typedef struct {
|
||||
LKIF_FLOATVALUE ToleUpper; // tolerance upper limit
|
||||
LKIF_FLOATVALUE ToleLower; // tolerance lower limit
|
||||
LKIF_FLOATVALUE AverageValue; // average value
|
||||
LKIF_FLOATVALUE MaxValue; // maximum value
|
||||
LKIF_FLOATVALUE MinValue; // minimum value
|
||||
LKIF_FLOATVALUE DifValue; // maximum value - minimum value
|
||||
LKIF_FLOATVALUE SdValue; // standard deviation
|
||||
LONG DataCnt; // number of all data
|
||||
LONG HighDataCnt; // number of tolerance High data
|
||||
LONG GoDataCnt; // number of tolerance Go data
|
||||
LONG LowDataCnt; // number of tolerance Low data
|
||||
} LKIF_FIGUREDATA;
|
||||
EXP BOOL WINAPI LKIF_GetFigureData(IN int OutNo,OUT LKIF_FIGUREDATA *FigureData);
|
||||
// Clearing Statistics
|
||||
EXP BOOL WINAPI LKIF_ClearFigureData(void);
|
||||
// Starting the Data Storage
|
||||
EXP BOOL WINAPI LKIF_DataStorageStart(void);
|
||||
// Stopping the Data Storage
|
||||
EXP BOOL WINAPI LKIF_DataStorageStop(void);
|
||||
// Initializing the Data Storage
|
||||
EXP BOOL WINAPI LKIF_DataStorageInit(void);
|
||||
// Outputting the Data Storage
|
||||
EXP BOOL WINAPI LKIF_DataStorageGetData(IN int OutNo,IN int NumOutBuffer,OUT LKIF_FLOATVALUE *OutBuffer,OUT int *NumReceived);
|
||||
// Data Storage Accumulation Status Output
|
||||
EXP BOOL WINAPI LKIF_DataStorageGetStatus(IN int OutNo,OUT BOOL *IsStorage,OUT int *NumStorageData);
|
||||
// Receive Light Waveform
|
||||
EXP BOOL WINAPI LKIF_GetLight(IN int HeadNo,IN int PeekNo,OUT int *MeasurePosition,OUT int *NumReaded,OUT BYTE *Value);
|
||||
|
||||
///////////////////////////////////////////////
|
||||
// Change Parameter Command
|
||||
//
|
||||
// Display Panel Switch
|
||||
EXP BOOL WINAPI LKIF_SetPanel(IN int OutNo);
|
||||
// Set Tolerance
|
||||
EXP BOOL WINAPI LKIF_SetTolerance(IN int OutNo,IN int UpperLimit,IN int LowerLimit,IN int Hysteresis);
|
||||
// Set ABLE
|
||||
typedef enum {
|
||||
LKIF_ABLEMODE_AUTO, // automatic
|
||||
LKIF_ABLEMODE_MANUAL, // manual
|
||||
} LKIF_ABLEMODE;
|
||||
EXP BOOL WINAPI LKIF_SetAbleMode(IN int HeadNo,IN LKIF_ABLEMODE AbleMode);
|
||||
// Set ABLE Control Range
|
||||
EXP BOOL WINAPI LKIF_SetAbleMinMax(IN int HeadNo,IN int Min,IN int Max);
|
||||
// Set Measurement Mode
|
||||
typedef enum {
|
||||
LKIF_MEASUREMODE_NORMAL, // normal
|
||||
LKIF_MEASUREMODE_HALF_T, // translucent object
|
||||
LKIF_MEASUREMDOE_TRAN_1, // transparent object
|
||||
LKIF_MEASUREMODE_TRAN_2, // transparent object 2
|
||||
LKIF_MEASUREMODE_MRS, // multireflective object
|
||||
} LKIF_MEASUREMODE;
|
||||
EXP BOOL WINAPI LKIF_SetMeasureMode(IN int HeadNo,IN LKIF_MEASUREMODE MeasureMode);
|
||||
// Set Number of Times of Alarm Processing
|
||||
EXP BOOL WINAPI LKIF_SetNumAlarm(IN int HeadNo,IN int NumAlarm);
|
||||
// Set Alarm Level
|
||||
EXP BOOL WINAPI LKIF_SetAlarmLevel(IN int HeadNo,IN int AlarmLevel);
|
||||
// Starting the ABLE Calibration
|
||||
EXP BOOL WINAPI LKIF_AbleStart(IN int HeadNo);
|
||||
// Finishing the ABLE Calibration
|
||||
EXP BOOL WINAPI LKIF_AbleStop(void);
|
||||
// Stopping the ABLE Calibration
|
||||
EXP BOOL WINAPI LKIF_AbleCancel(void);
|
||||
// Set Mounting Mode
|
||||
typedef enum {
|
||||
LKIF_REFLECTIONMODE_DIFFUSION, // diffuse reflection
|
||||
LKIF_REFLECTIONMODE_MIRROR, // specular reflection
|
||||
} LKIF_REFLECTIONMODE;
|
||||
EXP BOOL WINAPI LKIF_SetReflectionMode(IN int HeadNo,IN LKIF_REFLECTIONMODE ReflectionMode);
|
||||
// Set Calculation Method
|
||||
typedef enum {
|
||||
LKIF_CALCMETHOD_HEADA, // head A
|
||||
LKIF_CALCMETHOD_HEADB, // head B
|
||||
LKIF_CALCMETHOD_HEAD_HEADA_PLUS_HEADB, // head A+head B
|
||||
LKIF_CALCMETHOD_HEAD_HEADA_MINUS_HEADB, // head A-head B
|
||||
LKIF_CALCMETHOD_HEAD_HEADA_TRANSPARENT, // head A transparent object
|
||||
LKIF_CALCMETHOD_HEAD_HEADB_TRANSPARENT, // head B transparent object
|
||||
} LKIF_CALCMETHOD;
|
||||
// Measurement target
|
||||
typedef enum {
|
||||
LKIF_CALCTARGET_PEAK_1, // peak 1
|
||||
LKIF_CALCTARGET_PEAK_2, // peak 2
|
||||
LKIF_CALCTARGET_PEAK_3, // peak 3
|
||||
LKIF_CALCTARGET_PEAK_4, // peak 4
|
||||
LKIF_CALCTARGET_PEAK_1_2, // peak 1-peak 2
|
||||
LKIF_CALCTARGET_PEAK_1_3, // peak 1-peak 3
|
||||
LKIF_CALCTARGET_PEAK_1_4, // peak 1-peak 4
|
||||
LKIF_CALCTARGET_PEAK_2_3, // peak 2-peak 3
|
||||
LKIF_CALCTARGET_PEAK_2_4, // peak 2-peak 4
|
||||
LKIF_CALCTARGET_PEAK_3_4, // peak 3-peak 4
|
||||
} LKIF_CALCTARGET;
|
||||
EXP BOOL WINAPI LKIF_SetCalcMethod(IN int OutNo,IN LKIF_CALCMETHOD CalcMethod,LKIF_CALCTARGET CalcTarget);
|
||||
// Set Scaling
|
||||
EXP BOOL WINAPI LKIF_SetScaling(IN int OutNo,IN int HeadNo,IN int InputValue1,IN int OutputValue1,IN int InputValue2,IN int OutputValue2);
|
||||
// Set Filter Mode
|
||||
typedef enum {
|
||||
LKIF_FILTERMODE_MOVING_AVERAGE, // moving average
|
||||
LKIF_FILTERMODE_LOWPASS, // low pass filter
|
||||
LKIF_FILTERMODE_HIGHPASS, // high pass filter
|
||||
} LKIF_FILTERMODE;
|
||||
EXP BOOL WINAPI LKIF_SetFilterMode(IN int OutNo,OUT LKIF_FILTERMODE FilterMode);
|
||||
// Set Number of Times for Averaging
|
||||
typedef enum {
|
||||
LKIF_AVERAGE_1, // 1 time
|
||||
LKIF_AVERAGE_4, //
|
||||
LKIF_AVERAGE_16, //
|
||||
LKIF_AVERAGE_64, //
|
||||
LKIF_AVERAGE_256, //
|
||||
LKIF_AVERAGE_1024, //
|
||||
LKIF_AVERAGE_4096, //
|
||||
LKIF_AVERAGE_16384, //
|
||||
LKIF_AVERAGE_65536, //
|
||||
LKIF_AVERAGE_262144, // 262144 times
|
||||
} LKIF_AVERAGE;
|
||||
EXP BOOL WINAPI LKIF_SetAverage(IN int OutNo,IN LKIF_AVERAGE Average);
|
||||
// Set Cutoff Frequency
|
||||
typedef enum {
|
||||
LKIF_CUTOFFFREQUENCY_1000, // 1000Hz
|
||||
LKIF_CUTOFFFREQUENCY_300, // 300Hz
|
||||
LKIF_CUTOFFFREQUENCY_100, // 100Hz
|
||||
LKIF_CUTOFFFREQUENCY_30, // 30Hz
|
||||
LKIF_CUTOFFFREQUENCY_10, // 10Hz
|
||||
LKIF_CUTOFFFREQUENCY_3, // 3Hz
|
||||
LKIF_CUTOFFFREQUENCY_1, // 1Hz
|
||||
LKIF_CUTOFFFREQUENCY_0_3, // 0.3Hz
|
||||
LKIF_CUTOFFFREQUENCY_0_1, // 0.1Hz
|
||||
} LKIF_CUTOFFFREQUENCY;
|
||||
EXP BOOL WINAPI LKIF_SetCutOffFrequency(IN int OutNo,IN LKIF_CUTOFFFREQUENCY CutOffFrequency);
|
||||
// Set Trigger Mode
|
||||
typedef enum {
|
||||
LKIF_TRIGGERMODE_EXT1, // external trigger 1
|
||||
LKIF_TRIGGERMODE_EXT2, // external trigger 2
|
||||
} LKIF_TRIGGERMODE;
|
||||
EXP BOOL WINAPI LKIF_SetTriggerMode(IN int OutNo,IN LKIF_TRIGGERMODE TriggerMode);
|
||||
// Set Offset
|
||||
EXP BOOL WINAPI LKIF_SetOffset(IN int OutNo,IN int Offset);
|
||||
// Set Analog Output Scaling
|
||||
EXP BOOL WINAPI LKIF_SetAnalogScaling(IN int OutNo,IN int InputValue1,IN int OutputVoltage1,IN int InputValue2,IN int OutputVoltage2);
|
||||
// Set Calculation Mode
|
||||
typedef enum {
|
||||
LKIF_CALCMODE_NORMAL, // normal
|
||||
LKIF_CALCMODE_PEAKHOLD, // peak hold
|
||||
LKIF_CALCMODE_BOTTOMHOLD, // bottom hold
|
||||
LKIF_CALCMODE_PEAKTOPEAKHOLD, // peak-to-peak hold
|
||||
LKIF_CALCMODE_SAMPLEHOLD, // sample hold
|
||||
LKIF_CALCMODE_AVERAGEHOLD, // average hold
|
||||
} LKIF_CALCMODE;
|
||||
EXP BOOL WINAPI LKIF_SetCalcMode(IN int OutNo,IN LKIF_CALCMODE CalcMode);
|
||||
// Set Minimum Display Unit
|
||||
typedef enum {
|
||||
LKIF_DISPLAYUNIT_0000_01MM, // 0.01mm
|
||||
LKIF_DISPLAYUNIT_000_001MM, // 0.001mm
|
||||
LKIF_DISPLAYUNIT_00_0001MM, // 0.0001mm
|
||||
LKIF_DISPLAYUNIT_0_00001MM, // 0.00001mm
|
||||
LKIF_DISPLAYUNIT_00000_1UM, // 0.1um
|
||||
LKIF_DISPLAYUNIT_0000_01UM, // 0.01um
|
||||
} LKIF_DISPLAYUNIT;
|
||||
EXP BOOL WINAPI LKIF_SetDisplayUnit(IN int OutNo,IN LKIF_DISPLAYUNIT DisplayUnit);
|
||||
// Set Analog-Through
|
||||
EXP BOOL WINAPI LKIF_SetAnalogThrough(IN int OutNo,IN BOOL IsOn);
|
||||
// Set Data Storage
|
||||
typedef enum {
|
||||
LKIF_TARGETOUT_NONE, // no target OUT
|
||||
LKIF_TARGETOUT_OUT1, // OUT1
|
||||
LKIF_TARGETOUT_OUT2, // OUT2
|
||||
LKIF_TARGETOUT_BOTH, // OUT1 and OUT2
|
||||
} LKIF_TARGETOUT;
|
||||
typedef enum {
|
||||
LKIF_STORAGECYCLE_1, // sampling rate x 1
|
||||
LKIF_STORAGECYCLE_2, // sampling rate x 2
|
||||
LKIF_STORAGECYCLE_5, // sampling rate x 5
|
||||
LKIF_STORAGECYCLE_10, // sampling rate x 10
|
||||
LKIF_STORAGECYCLE_20, // sampling rate x 20
|
||||
LKIF_STORAGECYCLE_50, // sampling rate x 50
|
||||
LKIF_STORAGECYCLE_100, // sampling rate x 100
|
||||
LKIF_STORAGECYCLE_200, // sampling rate x 200
|
||||
LKIF_STORAGECYCLE_500, // sampling rate x 500
|
||||
LKIF_STORAGECYCLE_1000, // sampling rate x 1000
|
||||
} LKIF_STORAGECYCLE;
|
||||
EXP BOOL WINAPI LKIF_SetDataStorage(IN LKIF_TARGETOUT TargetOut,IN int NumStorage,IN LKIF_STORAGECYCLE StorageCycle);
|
||||
// Set Sampling Rate
|
||||
typedef enum {
|
||||
LKIF_SAMPLINGCYCLE_20USEC, // 20us
|
||||
LKIF_SAMPLINGCYCLE_50USEC, // 50us
|
||||
LKIF_SAMPLINGCYCLE_100USEC, // 100us
|
||||
LKIF_SAMPLINGCYCLE_200USEC, // 200us
|
||||
LKIF_SAMPLINGCYCLE_500USEC, // 500us
|
||||
LKIF_SAMPLINGCYCLE_1MSEC, // 1ms
|
||||
} LKIF_SAMPLINGCYCLE;
|
||||
EXP BOOL WINAPI LKIF_SetSamplingCycle(IN LKIF_SAMPLINGCYCLE SamplingCycle);
|
||||
// Set Mutual Interference Prevention
|
||||
EXP BOOL WINAPI LKIF_SetMutualInterferencePrevention(IN BOOL IsOn);
|
||||
// Set Timing Synchronization
|
||||
typedef enum {
|
||||
LKIF_SYNCHRONIZATION_ASYNCHRONOUS, // asynchronous
|
||||
LKIF_SYNCHRONIZATION_SYNCHRONIZED, // synchronous
|
||||
} LKIF_SYNCHRONIZATION;
|
||||
EXP BOOL WINAPI LKIF_SetTimingSynchronization(IN LKIF_SYNCHRONIZATION Synchronization);
|
||||
// Set Comparator Output Format
|
||||
typedef enum {
|
||||
LKIF_TOLERANCE_COMPARATOR_OUTPUT_FORMAT_NORMAL, // normal
|
||||
LKIF_TOLERANCE_COMPARATOR_OUTPUT_FORMAT_HOLD, // hold
|
||||
LKIF_TOLERANCE_COMPARATOR_OUTPUT_FORMAT_OFF_DELAY, // off-delay
|
||||
} LKIF_TOLERANCE_COMPARATOR_OUTPUT_FORMAT;
|
||||
EXP BOOL WINAPI LKIF_SetToleranceComparatorOutputFormat(IN LKIF_TOLERANCE_COMPARATOR_OUTPUT_FORMAT ToleranceComparatorOutputFormat);
|
||||
// Set Strobe Time
|
||||
typedef enum {
|
||||
LKIF_STOROBETIME_2MS, // 2ms
|
||||
LKIF_STOROBETIME_5MS, // 5ms
|
||||
LKIF_STOROBETIME_10MS, // 10ms
|
||||
LKIF_STOROBETIME_20MS, // 20ms
|
||||
} LKIF_STOROBETIME;
|
||||
EXP BOOL WINAPI LKIF_SetStorobeTime(IN LKIF_STOROBETIME StorobeTime);
|
||||
///////////////////////////////////////////////
|
||||
// Check Parameter Command
|
||||
//
|
||||
// Display Panel Check
|
||||
EXP BOOL WINAPI LKIF_GetPanel(OUT int *OutNo);
|
||||
// Get Tolerance
|
||||
EXP BOOL WINAPI LKIF_GetTolerance(IN int OutNo,OUT int *UpperLimit,OUT int *LowerLimit,OUT int *Hysteresis);
|
||||
// Get ABLE
|
||||
EXP BOOL WINAPI LKIF_GetAbleMode(IN int HeadNo,OUT LKIF_ABLEMODE *AbleMode);
|
||||
// ABLE Control Range
|
||||
EXP BOOL WINAPI LKIF_GetAbleMinMax(IN int HeadNo,OUT int *Min,OUT int *Max);
|
||||
// Get Measurement Mode
|
||||
EXP BOOL WINAPI LKIF_GetMeasureMode(IN int HeadNo,OUT LKIF_MEASUREMODE *MeasureMode);
|
||||
// Get Number of Times of Alarm Processing
|
||||
EXP BOOL WINAPI LKIF_GetNumAlarm(IN int HeadNo,OUT int *NumAlarm);
|
||||
// Get Alarm Level
|
||||
EXP BOOL WINAPI LKIF_GetAlarmLevel(IN int HeadNo,OUT int *AlarmLevel);
|
||||
// Get Mounting Mode
|
||||
EXP BOOL WINAPI LKIF_GetReflectionMode(IN int HeadNo,OUT LKIF_REFLECTIONMODE *ReflectionMode);
|
||||
// Get Calculation Method
|
||||
EXP BOOL WINAPI LKIF_GetCalcMethod(IN int OutNo,OUT LKIF_CALCMETHOD *CalcMethod,LKIF_CALCTARGET *CalcTarget);
|
||||
// Get Scaling
|
||||
EXP BOOL WINAPI LKIF_GetScaling(IN int OutNo,IN int HeadNo,OUT int *InputValue1,OUT int *OutputValue1,OUT int *InputValue2,OUT int *OutputValue2);
|
||||
// Get Filter Mode
|
||||
EXP BOOL WINAPI LKIF_GetFilterMode(IN int OutNo,OUT LKIF_FILTERMODE *FilterMode);
|
||||
// Get Number of Times for Averaging
|
||||
EXP BOOL WINAPI LKIF_GetAverage(IN int OutNo,OUT LKIF_AVERAGE *Average);
|
||||
// Get Cutoff Frequency
|
||||
EXP BOOL WINAPI LKIF_GetCutOffFrequency(IN int OutNo,OUT LKIF_CUTOFFFREQUENCY *CutOffFrequency);
|
||||
// Get Trigger Mode
|
||||
EXP BOOL WINAPI LKIF_GetTriggerMode(IN int OutNo,OUT LKIF_TRIGGERMODE *TriggerMode);
|
||||
// Get Offset
|
||||
EXP BOOL WINAPI LKIF_GetOffset(IN int OutNo,IN int *Offset);
|
||||
// Get Analog Output Scaling
|
||||
EXP BOOL WINAPI LKIF_GetAnalogScaling(IN int OutNo,OUT int *InputValue1,OUT int *OutputVoltage1,OUT int *InputValue2,OUT int *OutputVoltage2);
|
||||
// Get Calculation Mode
|
||||
EXP BOOL WINAPI LKIF_GetCalcMode(IN int OutNo,OUT LKIF_CALCMODE *CalcMode);
|
||||
// Get Minimum Display Unit
|
||||
EXP BOOL WINAPI LKIF_GetDisplayUnit(IN int OutNo,OUT LKIF_DISPLAYUNIT *DisplayUnit);
|
||||
// Analog-Through
|
||||
EXP BOOL WINAPI LKIF_GetAnalogThrough(IN int OutNo,OUT BOOL *IsOn);
|
||||
// Get Data Storage
|
||||
EXP BOOL WINAPI LKIF_GetDataStorage(IN LKIF_TARGETOUT *TargetOut,OUT int *NumStorage,OUT LKIF_STORAGECYCLE *StorageCycle);
|
||||
// Get Sampling Rate
|
||||
EXP BOOL WINAPI LKIF_GetSamplingCycle(OUT LKIF_SAMPLINGCYCLE *SamplingCycle);
|
||||
// Get Mutual Interference Prevention
|
||||
EXP BOOL WINAPI LKIF_GetMutualInterferencePrevention(OUT BOOL *IsOn);
|
||||
// Get Timing Synchronization
|
||||
EXP BOOL WINAPI LKIF_GetTimingSynchronization(OUT LKIF_SYNCHRONIZATION *Synchronization);
|
||||
// Get Comparator Output Format
|
||||
EXP BOOL WINAPI LKIF_GetToleranceComparatorOutputFormat(OUT LKIF_TOLERANCE_COMPARATOR_OUTPUT_FORMAT *ToleranceComparatorOutputFormat);
|
||||
// Get Strobe Time
|
||||
EXP BOOL WINAPI LKIF_GetStorobeTime(OUT LKIF_STOROBETIME *StorobeTime);
|
||||
///////////////////////////////////////////////
|
||||
// Mode Change Command
|
||||
//
|
||||
// Mode Switch
|
||||
typedef enum {
|
||||
LKIF_MODE_NORMAL, // normal mode
|
||||
LKIF_MODE_COMMUNICATION, // setting mode
|
||||
} LKIF_MODE;
|
||||
EXP BOOL WINAPI LKIF_SetMode(IN LKIF_MODE Mode);
|
||||
} // extern "C"
|
||||
|
||||
#endif // LKIF_INCLUDED
|
||||
Reference in New Issue
Block a user