增加导出DLL工程。

This commit is contained in:
TAO Cheng
2014-04-13 23:30:50 +08:00
parent a71aa9182f
commit 4bfd0a6a4c
32 changed files with 1154 additions and 146 deletions
@@ -277,7 +277,7 @@ usb_dev_handle* CKeyence_Proto::_open_usb_dev(void)
}
//******************************************************************************
SSI_STATUS_MOTION CKeyence_Proto::_usb_reset(void)
SSI_STATUS CKeyence_Proto::_usb_reset(void)
{
if (g_dev)
{
@@ -287,9 +287,9 @@ SSI_STATUS_MOTION CKeyence_Proto::_usb_reset(void)
else
{
ASSERT(0);
return SSI_STATUS_MOTION_TIMEOUT;
return SSI_STATUS_TIMEOUT;
}
return SSI_STATUS_MOTION_TIMEOUT;
return SSI_STATUS_TIMEOUT;
}
@@ -298,12 +298,12 @@ SSI_STATUS_MOTION CKeyence_Proto::_usb_reset(void)
// Send is direct and async.
// The receive thread will receive data and interpret it.
//******************************************************************************
SSI_STATUS_MOTION CKeyence_Proto::Init_MvUsb()
SSI_STATUS 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;
SSI_STATUS Status=SSI_STATUS_NORMAL;
UNREFERENCED_PARAMETER(Status);
/*if (g_pLogger->m_lLogMask & LOGACTIONS)
g_pLogger->SendAndFlushPerMode(_T("Enter Initialize Mv Usb\n"));
@@ -317,20 +317,20 @@ SSI_STATUS_MOTION CKeyence_Proto::Init_MvUsb()
{
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;
return SSI_STATUS_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;
return SSI_STATUS_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;
return SSI_STATUS_DATALINK_ERROR;
}
// ********************************************************************
@@ -413,13 +413,13 @@ SSI_STATUS_MOTION CKeyence_Proto::Init_MvUsb()
//if (g_pLogger->m_lLogMask & LOGACTIONS)
// g_pLogger->SendAndFlushPerMode(_T("Exit Initialize Usb\n"));
return SSI_STATUS_MOTION_NORMAL;
return SSI_STATUS_NORMAL;
}
//******************************************************************************
SSI_STATUS_MOTION CKeyence_Proto::Exit_MvUsb()
SSI_STATUS CKeyence_Proto::Exit_MvUsb()
{
SSI_STATUS_MOTION Status=SSI_STATUS_MOTION_NORMAL;
SSI_STATUS Status=SSI_STATUS_NORMAL;
//if (g_pLogger->m_lLogMask & LOGACTIONS)
// g_pLogger->SendAndFlushPerMode(_T("Enter Exit_MvUsb\n"));
@@ -500,7 +500,7 @@ SSI_STATUS_MOTION CKeyence_Proto::Exit_MvUsb()
// 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)
SSI_STATUS 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))
@@ -516,52 +516,52 @@ SSI_STATUS_MOTION CKeyence_Proto::_do_single_threaded_usb_comm(int iEP_Base)
Sleep(3);
}
TRACE1("=====_do_single_threaded_usb_comm(iEP) g_hProtoDoneEvents. %x\n", iEP_Base);
return SSI_STATUS_MOTION_NORMAL;
return SSI_STATUS_NORMAL;
}
//******************************************************************************
// This startup just kicks off the EP_KEYENCE_81 worker thread.
//******************************************************************************
SSI_STATUS_MOTION CKeyence_Proto::_start_machine()
SSI_STATUS 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;
return SSI_STATUS_NORMAL;
};
//===============================================================================
SSI_STATUS_MOTION CKeyence_Proto::_shutdown_machine()
SSI_STATUS CKeyence_Proto::_shutdown_machine()
{
g_machine.s_status._machine_running = false;
return SSI_STATUS_MOTION_NORMAL;
return SSI_STATUS_NORMAL;
};
//===============================================================================
// iEP = EP_KEYENCE_01 or EP_KEYENCE_02
//===============================================================================
SSI_STATUS_MOTION CKeyence_Proto::_submit_async_8x(int iEP_Base)
SSI_STATUS 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;
return SSI_STATUS_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_SETUP_ASYNC_CONTEXT_ERROR;
}
return SSI_STATUS_MOTION_NORMAL;
return SSI_STATUS_NORMAL;
}
//===============================================================================
// iEP_Base : EP_81_DATA_IDX/EP_82_DATA_IDX
//
//===============================================================================
SSI_STATUS_MOTION CKeyence_Proto::_reap_async_8x(int iEP_Base)
SSI_STATUS CKeyence_Proto::_reap_async_8x(int iEP_Base)
{
int _ret;
_ret = usb_reap_async(ep_buff[iEP_Base]._async_context, 1000);
@@ -575,16 +575,16 @@ SSI_STATUS_MOTION CKeyence_Proto::_reap_async_8x(int iEP_Base)
{
usb_free_async(&(ep_buff[iEP_Base]._async_context));
ASSERT(0);
return SSI_STATUS_MOTION_TIMEOUT;
return SSI_STATUS_TIMEOUT;
}
return SSI_STATUS_MOTION_NORMAL;
return SSI_STATUS_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)
SSI_STATUS CKeyence_Proto::_send_usb_data(int iEP_Base)
{
int _ret;
ep_buff[iEP_Base]._save_send_cmd = ep_buff[iEP_Base]._buffer[0];
@@ -595,13 +595,13 @@ SSI_STATUS_MOTION CKeyence_Proto::_send_usb_data(int iEP_Base)
_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;
return SSI_STATUS_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;
return SSI_STATUS_SETUP_ASYNC_CONTEXT_ERROR;
}
TRACE1("_submit_async_8x(EP:%X)\r\n", iEP_Base);
//
@@ -624,13 +624,13 @@ SSI_STATUS_MOTION CKeyence_Proto::_send_usb_data(int iEP_Base)
{
usb_free_async(&(ep_buff[iEP_Base]._async_context));
ASSERT(0);
return SSI_STATUS_MOTION_TIMEOUT;
return SSI_STATUS_TIMEOUT;
}
return SSI_STATUS_MOTION_NORMAL;
return SSI_STATUS_NORMAL;
}
//==============================================================
SSI_STATUS_MOTION CKeyence_Proto::_send_cmd_KEYENCE_CMD_GET_LASER_DATA()
SSI_STATUS 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);
@@ -648,13 +648,13 @@ SSI_STATUS_MOTION CKeyence_Proto::_send_usb_data(int iEP_Base)
_do_single_threaded_usb_comm(EP_01_CMD_IDX);
ReleaseMutex(g_hEP01_Serial_Mutex);
return SSI_STATUS_MOTION_NORMAL;
return SSI_STATUS_NORMAL;
};
//==============================================================
SSI_STATUS_MOTION CKeyence_Proto::_process_KEYENCE_CMD_GET_LASER_DATA()
SSI_STATUS CKeyence_Proto::_process_KEYENCE_CMD_GET_LASER_DATA()
{
return SSI_STATUS_MOTION_NORMAL;
return SSI_STATUS_NORMAL;
};