186 lines
4.0 KiB
C++
186 lines
4.0 KiB
C++
|
|
//#include <iostream>
|
|||
|
|
//
|
|||
|
|
//
|
|||
|
|
//
|
|||
|
|
//#include "phoskey_ss.h"
|
|||
|
|
//
|
|||
|
|
//#include <Windows.h>
|
|||
|
|
//
|
|||
|
|
//#include <vector>
|
|||
|
|
//
|
|||
|
|
//int devId = 3;
|
|||
|
|
//
|
|||
|
|
//void HighSpeedDataCallBack(const int32_t* buffer, uint32_t size, uint32_t count, uint32_t notify, uint32_t user)
|
|||
|
|
//{
|
|||
|
|
// printf("HighSpeedDataCallBack -------\n");
|
|||
|
|
// printf("size = %d \n", int(size));
|
|||
|
|
// printf("count = %d \n", int(count));
|
|||
|
|
// printf("user = %d \n", int(user));
|
|||
|
|
// printf("notify = %d \n", int(notify));
|
|||
|
|
//
|
|||
|
|
// if (notify != -1)
|
|||
|
|
// {
|
|||
|
|
// if (notify & 0x07 == 1)
|
|||
|
|
// {
|
|||
|
|
// printf("批处理超时 \n");
|
|||
|
|
// return;
|
|||
|
|
// }
|
|||
|
|
// }
|
|||
|
|
//
|
|||
|
|
// uint32_t profileSize = (uint32_t)(size / sizeof(uint32_t)); //轮廓宽度
|
|||
|
|
// printf("profileSize = %d \n", int(profileSize));
|
|||
|
|
//
|
|||
|
|
// int BatchCount = GLX8_2_ProfilePointSetCount(devId, nullptr);
|
|||
|
|
// printf("BatchCount = %d \n", BatchCount);
|
|||
|
|
//
|
|||
|
|
// //数据拷贝
|
|||
|
|
// std::vector<int32_t> bufferArray;
|
|||
|
|
// bufferArray.resize(profileSize * count);
|
|||
|
|
//
|
|||
|
|
// memcpy(bufferArray.data(), buffer, (profileSize * count) * sizeof(int32_t));
|
|||
|
|
//
|
|||
|
|
// printf("bufferArray[0] = %d \n", bufferArray[0]);
|
|||
|
|
//
|
|||
|
|
// std::vector<uint32_t> Encoders;
|
|||
|
|
// Encoders.resize(count);
|
|||
|
|
//
|
|||
|
|
// int Rc = GLX8_2_GetEncoder(devId, nullptr, Encoders.data());
|
|||
|
|
// if (Rc != 0)
|
|||
|
|
// {
|
|||
|
|
// printf("获取编码器数据错误 \n");
|
|||
|
|
// return;
|
|||
|
|
// }
|
|||
|
|
//
|
|||
|
|
// printf("Encoders[0] = %d\n", Encoders[0]);
|
|||
|
|
//}
|
|||
|
|
//
|
|||
|
|
//int main()
|
|||
|
|
//{
|
|||
|
|
// system("chcp 65001");
|
|||
|
|
//
|
|||
|
|
// GLX8_2_Initialize();
|
|||
|
|
//
|
|||
|
|
// GLX8_2_ETHERNET_CONFIG cnf;
|
|||
|
|
// cnf.abyIpAddress[0] = 192;
|
|||
|
|
// cnf.abyIpAddress[1] = 168;
|
|||
|
|
// cnf.abyIpAddress[2] = 1;
|
|||
|
|
// cnf.abyIpAddress[3] = 10;
|
|||
|
|
//
|
|||
|
|
//
|
|||
|
|
// int res = GLX8_2_EthernetOpen(devId, &cnf);
|
|||
|
|
// if (res != 0)
|
|||
|
|
// {
|
|||
|
|
// printf("连接相机失败! \n");
|
|||
|
|
// return -1;
|
|||
|
|
// }
|
|||
|
|
//
|
|||
|
|
//
|
|||
|
|
// res = GLX8_2_HighSpeedDataEthernetCommunicationInitalize(devId, &cnf, 7, HighSpeedDataCallBack, 0, 123456);
|
|||
|
|
// if (res != 0)
|
|||
|
|
// {
|
|||
|
|
// printf("启动高速失败! \n");
|
|||
|
|
// return -1;
|
|||
|
|
// }
|
|||
|
|
//
|
|||
|
|
//
|
|||
|
|
// Sleep(5000);
|
|||
|
|
// GLX8_2_StartMeasure(devId, 0);
|
|||
|
|
//
|
|||
|
|
// while (true)
|
|||
|
|
// {
|
|||
|
|
// Sleep(2000);
|
|||
|
|
// }
|
|||
|
|
//
|
|||
|
|
// return 0;
|
|||
|
|
//}
|
|||
|
|
|
|||
|
|
|
|||
|
|
/*
|
|||
|
|
高速回调接口,现在软件上面设置需要的触发方式,批处理设置ON
|
|||
|
|
先打开相机 GLX8_2_EthernetOpen
|
|||
|
|
注册回调函数 GLX8_2_SetBatchOneTimeDataHandler
|
|||
|
|
防止程序退出
|
|||
|
|
*/
|
|||
|
|
|
|||
|
|
#include <iostream>
|
|||
|
|
#include "phoskey_ss.h"
|
|||
|
|
#include <vector>
|
|||
|
|
#include <memory>
|
|||
|
|
#include <string.h>
|
|||
|
|
#include <thread>
|
|||
|
|
|
|||
|
|
int devId = 3;
|
|||
|
|
|
|||
|
|
// glx8_stop_watch sw;
|
|||
|
|
|
|||
|
|
void HighSpeedDataCallBack(const GLX8_2_STR_CALLBACK_INFO* info, const int32_t* DataObj)
|
|||
|
|
{
|
|||
|
|
printf("HighSpeedDataCallBack -------\n");
|
|||
|
|
//sw.stop();
|
|||
|
|
//printf("[%s] time = %f ms\n", LINETOOLSOBJ->getCurrentTimeWithMilliseconds().c_str(), sw.elapsed_ms());
|
|||
|
|
|
|||
|
|
std::vector<int32_t> heightdatas;
|
|||
|
|
heightdatas.resize(info->BatchPoints * info->xPoints);
|
|||
|
|
|
|||
|
|
int32_t* bdatas = GLX8_2_GetBatchProfilePoint((void*)DataObj, 0);
|
|||
|
|
if (bdatas)
|
|||
|
|
{
|
|||
|
|
memcpy(heightdatas.data(), bdatas, heightdatas.size() * 4);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
int32_t* bdatas = GLX8_2_GetBatchProfilePoint((void*)DataObj, 0);
|
|||
|
|
if (bdatas)
|
|||
|
|
{
|
|||
|
|
memcpy(heightdatas.data(), bdatas, heightdatas.size() * 4);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
int main()
|
|||
|
|
{
|
|||
|
|
//sw.start();
|
|||
|
|
system("chcp 65001");
|
|||
|
|
|
|||
|
|
GLX8_2_Initialize();
|
|||
|
|
|
|||
|
|
GLX8_2_ETHERNET_CONFIG cnf;
|
|||
|
|
cnf.abyIpAddress[0] = 192;
|
|||
|
|
cnf.abyIpAddress[1] = 168;
|
|||
|
|
cnf.abyIpAddress[2] = 1;
|
|||
|
|
cnf.abyIpAddress[3] = 10;
|
|||
|
|
|
|||
|
|
|
|||
|
|
int res = GLX8_2_EthernetOpen(devId, &cnf);
|
|||
|
|
if (res != 0)
|
|||
|
|
{
|
|||
|
|
printf("连接相机失败! \n");
|
|||
|
|
return -1;
|
|||
|
|
}
|
|||
|
|
// 设置批处理
|
|||
|
|
|
|||
|
|
// 设置数量
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
res = GLX8_2_SetBatchOneTimeDataHandler(devId, HighSpeedDataCallBack);
|
|||
|
|
if (res != 0)
|
|||
|
|
{
|
|||
|
|
printf("启动高速失败! \n");
|
|||
|
|
return -1;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/*Sleep(5000);
|
|||
|
|
printf("exit...\n");
|
|||
|
|
GLX8_2_CommClose(devId);
|
|||
|
|
printf("exit end...\n");*/
|
|||
|
|
|
|||
|
|
while (true)
|
|||
|
|
{
|
|||
|
|
std::this_thread::sleep_for(std::chrono::milliseconds(5000));
|
|||
|
|
GLX8_2_StartMeasure(devId, 0);
|
|||
|
|
printf("GLX8_2_StartMeasure");
|
|||
|
|
//sw.restart();
|
|||
|
|
//printf("[%s] GLX8_2_StartMeasure...\n", LINETOOLSOBJ->getCurrentTimeWithMilliseconds().c_str());
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return 0;
|
|||
|
|
}
|