15 #include <visiontransfer/deviceenumeration.h>
16 #include <visiontransfer/imagetransfer.h>
17 #include <visiontransfer/imageset.h>
18 #include <visiontransfer/deviceparameters.h>
27 using namespace visiontransfer;
28 using namespace visiontransfer::param;
30 int main(
int argc,
const char** argv) {
36 if(devices.size() == 0) {
37 std::cout <<
"No devices discovered!" << std::endl;
42 std::cout <<
"Discovered devices:" << std::endl;
43 for(
unsigned int i = 0; i< devices.size(); i++) {
44 std::cout << devices[i].toString() << std::endl;
46 std::cout << std::endl;
57 std::cout << std::boolalpha << std::left;
58 std::cout <<
"Server-side Parameter Enumeration" << std::endl;
59 std::cout <<
"=================================" << std::endl << std::endl;
61 std::cout <<
"All " << allParams.size() <<
" parameters reported by server:" << std::endl;
62 for (ParameterSet::iterator it = allParams.begin(); it != allParams.end(); ++it) {
65 case ParameterValue::TYPE_INT: {
66 std::cout << std::setw(colW) << (param.
getUid()+
" (int)") <<
" = " << std::setw(valueW) << param.
getCurrent<
int>();
68 std::cout <<
" range " << param.
getMin<
int>() <<
"-" << param.
getMax<
int>();
76 std::cout <<
" options: ";
77 for (
int i=0; i<(int) opts.size(); ++i) {
78 std::cout << opts[i] <<
"(" << descr[i] <<
") ";
81 std::cout << std::endl;
84 case ParameterValue::TYPE_BOOL: {
85 std::cout << std::setw(colW) << (param.
getUid() +
" (bool)") <<
" = " << (param.
getCurrent<
bool>()?
"true":
"false") << std::endl;
88 case ParameterValue::TYPE_DOUBLE: {
89 std::cout << std::setw(colW) << (param.
getUid()+
" (double)") <<
" = " << std::setw(valueW) << param.
getCurrent<
double>();
91 std::cout <<
" range " << param.
getMin<
double>() <<
"-" << param.
getMax<
double>();
94 std::cout <<
" increment " << param.
getIncrement<
double>();
96 std::cout << std::endl;
99 case ParameterValue::TYPE_STRING: {
100 std::cout << std::setw(colW) << (param.
getUid() +
" (string)") <<
" = \"" << param.
getCurrent<std::string>() <<
"\"" << std::endl;
103 case ParameterValue::TYPE_SAFESTRING: {
104 std::cout << std::setw(colW) << (param.
getUid() +
" (safestring)") <<
" = \"" << param.
getCurrent<std::string>() <<
"\"" << std::endl;
107 case ParameterValue::TYPE_TENSOR: {
108 std::cout << std::setw(colW) << (param.
getUid() +
" (tensor) - shape: ");
110 if (i) std::cout <<
"x";
113 std::cout << std::endl;
116 std::cout << std::setw(colW) << (
" ");
117 std::cout <<
" - data: ";
120 std::cout << data[i] <<
" ";
121 if (((i+1)%perline)==0) {
122 std::cout << std::endl << std::setw(colW) << (
" ") <<
" ";
125 std::cout << std::endl;
128 case ParameterValue::TYPE_COMMAND: {
129 std::cout << std::setw(colW) << (param.
getUid() +
" (-> command trigger)") << std::endl;
143 std::cout << std::endl;
147 if (std::string(argv[1]) ==
"LOG") {
148 std::cout <<
"(Showing incoming parameter events - terminate with Ctrl-C ...)" << std::endl;
149 parameters.setParameterUpdateCallback([¶meters](
const std::string& uid) {
151 std::cout << uid <<
" := " << parameters.getParameter(uid).getCurrent<std::string>() << std::endl;
153 while (
true) std::this_thread::sleep_for(std::chrono::seconds(1));
155 std::string argname(argv[1]);
157 std::string val(argv[2]);
158 std::cout <<
"Sending request to set " << argname <<
" to " << val << std::endl;
159 parameters.setParameter(argname, val);
161 std::cout <<
"Requesting single parameter " << argname << std::endl;
162 std::cout <<
"-> cast as a string: " << parameters.getParameter(argname).getCurrent<std::string>() << std::endl;
166 std::cout <<
"You can launch this with a parameter name to get (and a value to set it)" << std::endl;
167 std::cout <<
" e.g. " << argv[0] <<
" operation_mode [2]" << std::endl;
168 std::cout <<
"or with 'LOG' as first argument to see continuous parameter updates" << std::endl;
169 std::cout << std::endl;
173 }
catch(
const std::exception& ex) {
180 std::cerr <<
"Exception occurred: " << ex.what() << std::endl;