Skip to content

Commit

Permalink
TeliVideo: Add some more debug output.
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenlovegrove committed Dec 12, 2016
1 parent 81181fe commit 77f0a75
Showing 1 changed file with 45 additions and 47 deletions.
92 changes: 45 additions & 47 deletions src/video/drivers/teli.cpp
Expand Up @@ -59,130 +59,122 @@ class TeliSystem
}
};

std::string GetNodeValStr(Teli::CAM_HANDLE cam, Teli::CAM_NODE_HANDLE node)
std::string GetNodeValStr(Teli::CAM_HANDLE cam, Teli::CAM_NODE_HANDLE node, std::string node_str)
{
Teli::TC_NODE_TYPE node_type;
Teli::CAM_API_STATUS st = Teli::Nd_GetType(cam, node, &node_type);
if(st != Teli::CAM_API_STS_SUCCESS) {
throw std::runtime_error("TeliSDK: Unable to get Teli node type.");
}

Teli::CAM_API_STATUS status;

switch(node_type) {
case Teli::TC_NODE_TYPE_INTEGER:
{
int64_t val;
Teli::CAM_API_STATUS st = Teli::Nd_GetIntValue(cam, node, &val);
if(st == Teli::CAM_API_STS_SUCCESS) {
status = Teli::Nd_GetIntValue(cam, node, &val);
if(status == Teli::CAM_API_STS_SUCCESS) {
return pangolin::Convert<std::string, int64_t>::Do(val);
}else{
throw std::runtime_error("TeliSDK: Unable to get Teli parameter");
}
break;
}
case Teli::TC_NODE_TYPE_BOOLEAN:
{
bool8_t val;
Teli::CAM_API_STATUS st = Teli::Nd_GetBoolValue(cam, node, &val);
if(st == Teli::CAM_API_STS_SUCCESS) {
status = Teli::Nd_GetBoolValue(cam, node, &val);
if(status == Teli::CAM_API_STS_SUCCESS) {
return pangolin::Convert<std::string, bool8_t>::Do(val);
}else{
throw std::runtime_error("TeliSDK: Unable to get Teli parameter");
}
break;
}
case Teli::TC_NODE_TYPE_FLOAT:
{
float64_t val;
Teli::CAM_API_STATUS st = Teli::Nd_GetFloatValue(cam, node, &val);
if(st == Teli::CAM_API_STS_SUCCESS) {
status = Teli::Nd_GetFloatValue(cam, node, &val);
if(status == Teli::CAM_API_STS_SUCCESS) {
return pangolin::Convert<std::string, float64_t>::Do(val);
}else{
throw std::runtime_error("TeliSDK: Unable to get Teli parameter");
}
break;
}
case Teli::TC_NODE_TYPE_STRING:
{
uint32_t buffer_size = 10*1024;
char* buffer = new char[buffer_size];
Teli::CAM_API_STATUS st = Teli::Nd_GetStrValue(cam, node, buffer, &buffer_size);
status = Teli::Nd_GetStrValue(cam, node, buffer, &buffer_size);
std::string val(buffer);
delete[] buffer;
if(st == Teli::CAM_API_STS_SUCCESS) {
if(status == Teli::CAM_API_STS_SUCCESS) {
return val;
}else{
throw std::runtime_error("TeliSDK: Unable to get Teli parameter");
}
break;
}
case Teli::TC_NODE_TYPE_ENUMERATION:
{
uint32_t buffer_size = 10*1024;
char* buffer = new char[buffer_size];
Teli::CAM_API_STATUS st = Teli::Nd_GetEnumStrValue(cam, node, buffer, &buffer_size);
status = Teli::Nd_GetEnumStrValue(cam, node, buffer, &buffer_size);
std::string val(buffer);
if(st == Teli::CAM_API_STS_SUCCESS) {
if(status == Teli::CAM_API_STS_SUCCESS) {
return val;
}else{
throw std::runtime_error("TeliSDK: Unable to get Teli parameter");
}
break;
}
case Teli::TC_NODE_TYPE_COMMAND:
case Teli::TC_NODE_TYPE_REGISTER:
case Teli::TC_NODE_TYPE_CATEGORY:
case Teli::TC_NODE_TYPE_ENUM_ENTRY:
case Teli::TC_NODE_TYPE_PORT:
default:
throw std::runtime_error("TeliSDK: Unsupported node_type: " + node_type);
throw VideoException("TeliSDK: Unsupported node_type: " + node_type);
}

if(status != Teli::CAM_API_STS_SUCCESS) {
Teli::CAM_GENICAM_ERR_MSG psErrMsg;
Teli::Misc_GetLastGenICamError(&psErrMsg);
throw VideoException("TeliSDK: Unable to get Teli parameter, " + node_str, psErrMsg.pszDescription);
}else{
throw VideoException("TeliSDK: Unable to get Teli parameter, " + node_str);
}
}

void SetNodeValStr(Teli::CAM_HANDLE cam, Teli::CAM_NODE_HANDLE node, std::string val_str)
void SetNodeValStr(Teli::CAM_HANDLE cam, Teli::CAM_NODE_HANDLE node, std::string node_str, std::string val_str)
{
Teli::TC_NODE_TYPE node_type;
Teli::CAM_API_STATUS st = Teli::Nd_GetType(cam, node, &node_type);
if(st != Teli::CAM_API_STS_SUCCESS) {
throw std::runtime_error("TeliSDK: Unable to get Teli node type.");
throw VideoException("TeliSDK: Unable to get Teli node type.");
}

Teli::CAM_API_STATUS status = Teli::CAM_API_STS_SUCCESS;

switch(node_type) {
case Teli::TC_NODE_TYPE_INTEGER:
{
const int64_t val = pangolin::Convert<int64_t, std::string>::Do(val_str);
Teli::CAM_API_STATUS st = Teli::Nd_SetIntValue(cam, node, val);
if(st != Teli::CAM_API_STS_SUCCESS) {
throw std::runtime_error("TeliSDK: Unable to set Teli parameter");
}
status = Teli::Nd_SetIntValue(cam, node, val);
break;
}
case Teli::TC_NODE_TYPE_BOOLEAN:
{
const bool8_t val = pangolin::Convert<bool8_t, std::string>::Do(val_str);
Teli::CAM_API_STATUS st = Teli::Nd_SetBoolValue(cam, node, val);
if(st != Teli::CAM_API_STS_SUCCESS) {
throw std::runtime_error("TeliSDK: Unable to set Teli parameter");
}
status = Teli::Nd_SetBoolValue(cam, node, val);
break;
}
case Teli::TC_NODE_TYPE_FLOAT:
{
const float64_t val = pangolin::Convert<float64_t, std::string>::Do(val_str);
Teli::CAM_API_STATUS st = Teli::Nd_SetFloatValue(cam, node, val);
if(st != Teli::CAM_API_STS_SUCCESS) {
throw std::runtime_error("TeliSDK: Unable to set Teli parameter");
}
status = Teli::Nd_SetFloatValue(cam, node, val);
break;
}
case Teli::TC_NODE_TYPE_STRING:
{
Teli::CAM_API_STATUS st = Teli::Nd_SetStrValue(cam, node, val_str.c_str());
if(st != Teli::CAM_API_STS_SUCCESS) {
throw std::runtime_error("TeliSDK: Unable to set Teli parameter");
}
status = Teli::Nd_SetStrValue(cam, node, val_str.c_str());
break;
}
case Teli::TC_NODE_TYPE_ENUMERATION:
{
Teli::CAM_API_STATUS st = Teli::Nd_SetEnumStrValue(cam, node, val_str.c_str());
if(st != Teli::CAM_API_STS_SUCCESS) {
throw std::runtime_error("TeliSDK: Unable to set Teli parameter");
}
status = Teli::Nd_SetEnumStrValue(cam, node, val_str.c_str());
break;
}
case Teli::TC_NODE_TYPE_COMMAND:
Expand All @@ -191,7 +183,13 @@ void SetNodeValStr(Teli::CAM_HANDLE cam, Teli::CAM_NODE_HANDLE node, std::string
case Teli::TC_NODE_TYPE_ENUM_ENTRY:
case Teli::TC_NODE_TYPE_PORT:
default:
throw std::runtime_error("TeliSDK: Unsupported node_type: " + node_type);
throw VideoException("TeliSDK: Unsupported node_type: " + node_type);
}

if(status != Teli::CAM_API_STS_SUCCESS) {
Teli::CAM_GENICAM_ERR_MSG psErrMsg;
Teli::Misc_GetLastGenICamError(&psErrMsg);
throw VideoException("TeliSDK: Unable to set Teli parameter, " + node_str, psErrMsg.pszDescription);
}
}

Expand Down Expand Up @@ -266,7 +264,7 @@ std::string TeliVideo::GetParameter(const std::string& name)
Teli::CAM_NODE_HANDLE node;
Teli::CAM_API_STATUS st = Teli::Nd_GetNode(cam, name.c_str(), &node);
if( st == Teli::CAM_API_STS_SUCCESS) {
return GetNodeValStr(cam, node);
return GetNodeValStr(cam, node, name);
}else{
throw std::runtime_error("TeliSDK: Unable to get reference to node:" + name);
}
Expand All @@ -277,7 +275,7 @@ void TeliVideo::SetParameter(const std::string& name, const std::string& value)
Teli::CAM_NODE_HANDLE node;
Teli::CAM_API_STATUS st = Teli::Nd_GetNode(cam, name.c_str(), &node);
if( st == Teli::CAM_API_STS_SUCCESS) {
SetNodeValStr(cam, node, value);
SetNodeValStr(cam, node, name, value);
}else{
throw std::runtime_error("TeliSDK: Unable to get reference to node:" + name);
}
Expand Down

0 comments on commit 77f0a75

Please sign in to comment.