Skip to content

Commit ea194de

Browse files
committed
allow for unreadable command nodes
1 parent bed6f20 commit ea194de

File tree

3 files changed

+13
-11
lines changed

3 files changed

+13
-11
lines changed

spinnaker_camera_driver/src/genicam_utils.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ void get_nodemap_as_string(std::stringstream & ss, Spinnaker::CameraPtr cam)
4646
ss << s;
4747
}
4848

49-
static std::optional<CNodePtr> find_node(const std::string & path, CNodePtr & node, bool debug)
49+
static std::optional<CNodePtr> find_node(const std::string & path, CNodePtr & node, bool debug, bool allow_unreadable)
5050
{
5151
// split off first part
5252
auto pos = path.find("/");
@@ -72,12 +72,12 @@ static std::optional<CNodePtr> find_node(const std::string & path, CNodePtr & no
7272
if (std::string(childNode->GetName().c_str()) == token) {
7373
// no slash in name, this is a leaf node
7474
const bool is_leaf_node = (pos == std::string::npos);
75-
if (is_readable(childNode)) {
75+
if (allow_unreadable || is_readable(childNode)) {
7676
if (is_leaf_node) {
7777
return (childNode);
7878
} else {
7979
const std::string rest = path.substr(pos + 1);
80-
return (find_node(rest, childNode, debug));
80+
return (find_node(rest, childNode, debug, allow_unreadable));
8181
}
8282
} else {
8383
return (CNodePtr(nullptr)); // found, but not readable
@@ -90,11 +90,11 @@ static std::optional<CNodePtr> find_node(const std::string & path, CNodePtr & no
9090
return (std::nullopt);
9191
}
9292

93-
std::optional<CNodePtr> find_node(const std::string & path, Spinnaker::CameraPtr cam, bool debug)
93+
std::optional<CNodePtr> find_node(const std::string & path, Spinnaker::CameraPtr cam, bool debug, bool allow_unreadable)
9494
{
9595
INodeMap & appLayerNodeMap = cam->GetNodeMap();
9696
CNodePtr rootNode = appLayerNodeMap.GetNode("Root");
97-
return (find_node(path, rootNode, debug));
97+
return (find_node(path, rootNode, debug, allow_unreadable));
9898
}
9999
} // namespace genicam_utils
100100
} // namespace spinnaker_camera_driver

spinnaker_camera_driver/src/genicam_utils.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ namespace genicam_utils
2929
{
3030
void get_nodemap_as_string(std::stringstream & ss, Spinnaker::CameraPtr cam);
3131
std::optional<Spinnaker::GenApi::CNodePtr> find_node(
32-
const std::string & path, Spinnaker::CameraPtr cam, bool debug);
32+
const std::string & path, Spinnaker::CameraPtr cam, bool debug, bool allow_unreadable = false);
3333
} // namespace genicam_utils
3434
} // namespace spinnaker_camera_driver
3535

spinnaker_camera_driver/src/spinnaker_wrapper_impl.cpp

+7-5
Original file line numberDiff line numberDiff line change
@@ -247,15 +247,17 @@ std::string SpinnakerWrapperImpl::setInt(const std::string & nn, int val, int *
247247

248248
std::string SpinnakerWrapperImpl::execute(const std::string & nn)
249249
{
250-
const auto np = genicam_utils::find_node(nn, camera_, debug_);
250+
const auto np = genicam_utils::find_node(nn, camera_, debug_, true);
251251
if (!np) {
252252
return ("node " + nn + " not found!");
253253
}
254-
std::string msg;
255-
if (!common_checks(*np, nn, &msg)) {
256-
return (msg);
257-
}
258254
auto p = static_cast<GenApi::CCommandPtr>(*np);
255+
if (!is_available(p)) {
256+
return ("node " + nn + " not available!");
257+
}
258+
if (!is_writable(p)) {
259+
return ("node " + nn + " not writeable");
260+
}
259261
p->Execute();
260262
return ("OK");
261263
}

0 commit comments

Comments
 (0)