init files
This commit is contained in:
@@ -0,0 +1,94 @@
|
||||
#include "Hd_LightSourceModule_CST.h"
|
||||
|
||||
Hd_LightSourceModule_CST::Hd_LightSourceModule_CST()
|
||||
{
|
||||
}
|
||||
|
||||
Hd_LightSourceModule_CST::~Hd_LightSourceModule_CST()
|
||||
{
|
||||
DestroyIpConnection(handle);
|
||||
}
|
||||
//在这里data是CHX_XXXX 即通道几,亮度几
|
||||
bool Hd_LightSourceModule_CST::writeData(std::vector<cv::Mat>& mat, QByteArray& data)
|
||||
{
|
||||
int index = QString(data.mid(2, 1)).toInt();
|
||||
int value = QString(data.mid(4)).toInt();
|
||||
auto res = SetDigitalValue(index, value, handle);
|
||||
if (res != SUCCESS)
|
||||
{
|
||||
qCritical() << " [Error] " << "Set CST Intensity Error";
|
||||
isOpenFlag = false;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
//在这里params是SN
|
||||
bool Hd_LightSourceModule_CST::initParas(QByteArray& params)
|
||||
{
|
||||
if (!searchDevice())
|
||||
return false;
|
||||
if (!SNtoIP.contains(params))
|
||||
{
|
||||
qCritical() << " [Error] " << "CST Init Params Invaild";
|
||||
return false;
|
||||
}
|
||||
auto res = ConnectIP((char*)SNtoIP[params].toStdString().c_str(), 3, &handle);
|
||||
if (res != SUCCESS)
|
||||
{
|
||||
qCritical() << " [Error] " << "Connect CST Device Error";
|
||||
return false;
|
||||
}
|
||||
isOpenFlag = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Hd_LightSourceModule_CST::checkStatus()
|
||||
{
|
||||
return isOpenFlag;
|
||||
}
|
||||
|
||||
bool Hd_LightSourceModule_CST::searchDevice()
|
||||
{
|
||||
//搜索设备
|
||||
Adapter_prm adapter[20];
|
||||
int length;
|
||||
GetAdapter(&length, adapter);
|
||||
Host_prm hostprm;
|
||||
int concount = 0;
|
||||
for (int i = 0; i < length; i++)
|
||||
{
|
||||
int controllercount;
|
||||
memset(&hostprm, 0, sizeof(hostprm));
|
||||
GetHost(&controllercount, &hostprm, adapter[i].cIp);
|
||||
if (controllercount)
|
||||
{
|
||||
Controller_prm controlprm;
|
||||
auto res = GetConfigure(hostprm.cMac, &controlprm, adapter[i].cIp);
|
||||
SNtoIP[hostprm.cSn + 3] = controlprm.cIp;
|
||||
}
|
||||
concount += controllercount;
|
||||
}
|
||||
if(concount)
|
||||
return true;
|
||||
else
|
||||
{
|
||||
qCritical() << " [Error] " << "CST Device Count 0";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Hd_LightSourceModule_CST* create()
|
||||
{
|
||||
qDebug() << "[INFO] " << "Hd_LightSourceModule_CST create success!";
|
||||
return new Hd_LightSourceModule_CST;
|
||||
}
|
||||
|
||||
void destory(Hd_LightSourceModule_CST* ptr)
|
||||
{
|
||||
if (ptr)
|
||||
{
|
||||
delete ptr;
|
||||
ptr = nullptr;
|
||||
}
|
||||
qDebug() << "[INFO] " << "Hd_LightSourceModule_CST destory success!";
|
||||
}
|
||||
Reference in New Issue
Block a user