15 #include <visiontransfer/deviceenumeration.h> 16 #include <visiontransfer/imagetransfer.h> 17 #include <visiontransfer/imageset.h> 18 #include <visiontransfer/deviceparameters.h> 27 int main(
int argc,
const char** argv) {
33 if(devices.size() == 0) {
34 std::cout <<
"No devices discovered!" << std::endl;
39 std::cout <<
"Discovered devices:" << std::endl;
40 for(
unsigned int i = 0; i< devices.size(); i++) {
41 std::cout << devices[i].toString() << std::endl;
43 std::cout << std::endl;
53 std::cout << std::boolalpha << std::left;
54 std::cout <<
"Server-side Parameter Enumeration" << std::endl;
55 std::cout <<
"=================================" << std::endl << std::endl;
56 std::map<std::string, ParameterInfo> all_params = parameters.getAllParameters();
57 std::cout <<
"All " << all_params.size() <<
" parameters reported by server:" << std::endl;
58 for (std::map<std::string, ParameterInfo>::iterator it = all_params.begin(); it != all_params.end(); ++it) {
60 ParameterInfo::ParameterType t = param.
getType();
62 case ParameterInfo::TYPE_INT: {
63 std::cout << std::setw(colW) << (param.
getName()+
" (int)") <<
" = " << std::setw(valueW) << param.
getValue<
int>();
65 std::cout <<
" range " << param.
getMin<
int>() <<
"-" << param.
getMax<
int>();
66 if (param.
getInc<
int>() != 1) {
67 std::cout <<
", increment " << param.
getInc<
int>();
70 std::cout << std::endl;
73 case ParameterInfo::TYPE_BOOL: {
74 std::cout << std::setw(colW) << (param.
getName() +
" (bool)") <<
" = " << (param.
getValue<
bool>()?
"true":
"false") << std::endl;
77 case ParameterInfo::TYPE_DOUBLE: {
78 std::cout << std::setw(colW) << (param.
getName()+
" (double)") <<
" = " << std::setw(valueW) << param.
getValue<
double>();
80 std::cout <<
" range " << param.
getMin<
double>() <<
"-" << param.
getMax<
double>();
82 std::cout << std::endl;
87 std::cout << std::endl;
91 std::string argname(argv[1]);
93 double val = atof(argv[2]);
94 std::cout <<
"Sending request to set " << argname <<
" to " << val << std::endl;
95 parameters.setNamedParameter(argname, val);
97 std::cout <<
"Requesting single parameter " << argname << std::endl;
98 std::cout <<
"-> cast as a double: " << parameters.getNamedParameter<
double>(argname) << std::endl;
101 std::cout <<
"You can launch this with a parameter name to get (and a value to set it)" << std::endl;
102 std::cout <<
" e.g. " << argv[0] <<
" operation_mode [2]" << std::endl;
106 }
catch(
const std::exception& ex) {
107 std::cerr <<
"Exception occurred: " << ex.what() << std::endl;
DeviceList discoverDevices()
Discovers new devices and returns the list of all devices that have been found.
T getMin() const
Returns the minimum parameter value, cast to the desired type (int, double or bool) ...
std::string getName() const
Returns the string representation of the parameter name.
T getInc() const
Returns the increment of the parameter (i.e. increment for raising / lowering the value)...
Allows for configuration of the parameters of a Nerian stereo device through a network connection...
ParameterType getType() const
Returns the type of the parameter.
T getValue() const
Returns the current parameter value, cast to the desired type (int, double or bool) ...
T getMax() const
Returns the maximum parameter value, cast to the desired type (int, double or bool) ...
Allows for the discovery of devices in the network.