#include // for rand() function #include #include #include "uhal/uhal.hpp" int main(int argc, char* argv[]) { // PART 1: Argument parsing if (argc != 4) { std::cout << "Incorrect usage!" << std::endl; std::cout << "usage: print_node_attributes " << std::endl; return 1; } const std::string lConnectionFilePath = argv[1]; const std::string lDeviceId = argv[2]; const std::string lNodeName = argv[3]; // PART 2: Creating the HwInterface uhal::setLogLevelTo( uhal::Notice() ); uhal::ConnectionManager lConnectionMgr("file://" + lConnectionFilePath); uhal::HwInterface lHW = lConnectionMgr.getDevice(lDeviceId); // PART 3: Iterating over all nodes const uhal::Node& lTopNode = lHW.getNode(); std::cout << "Full list of nodes (from begin and end methods):" << std::endl; for (uhal::Node::const_iterator lIt=lTopNode.begin(); lIt != lTopNode.end(); lIt++) std::cout << " * " << lIt->getPath() << std::endl; std::cout << std::endl; std::cout << "Full list of nodes (via getNodes method):" << std::endl; std::vector lNodeIds = lTopNode.getNodes(); for (std::vector::const_iterator lIt=lNodeIds.begin(); lIt != lNodeIds.end(); lIt++) std::cout << " * " << *lIt << std::endl; std::cout << std::endl; const std::string lNodeRegex = ".*reg.*"; lNodeIds = lTopNode.getNodes(lNodeRegex); std::cout << lNodeIds.size() << " nodes have ID paths matching regex '" << lNodeRegex << "'" << std::endl; for (std::vector::const_iterator lIt=lNodeIds.begin(); lIt != lNodeIds.end(); lIt++) std::cout << " * " << *lIt << std::endl; std::cout << std::endl; // PART 4: Printing attributes of specific node const uhal::Node& lNode = lHW.getNode(lNodeName); std::cout << "Properties of node '" << lNodeName << "':" << std::endl; std::cout << " ID = '" << lNode.getId() << "'" << std::endl; std::cout << " ID path = '" << lNode.getPath() << "'" << std::endl; std::cout << " adddress = 0x" << std::hex << lNode.getAddress() << std::endl; std::cout << " mask = 0x" << std::hex << lNode.getMask() << std::endl; std::cout << " mode = " << lNode.getMode() << std::endl; std::cout << " permission = " << lNode.getPermission() << std::endl; std::cout << " size = " << lNode.getSize() << std::endl; std::cout << " tags = " << lNode.getTags() << std::endl; std::cout << " parameters = {"; for (boost::unordered_map::const_iterator lIt=lNode.getParameters().begin(); lIt != lNode.getParameters().end(); lIt++) { if (lIt != lNode.getParameters().begin()) std::cout << ", "; std::cout << "'" << lIt->first << "', '" << lIt->second << "'"; } std::cout << "}" << std::endl; return 0; }