本文整理汇总了C++中comma::csv::options::format方法的典型用法代码示例。如果您正苦于以下问题:C++ options::format方法的具体用法?C++ options::format怎么用?C++ options::format使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类comma::csv::options
的用法示例。
在下文中一共展示了options::format方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: read_block_impl_
static block_t* read_block_impl_( ::tbb::flow_control* flow = NULL )
{
static boost::array< block_t, 3 > blocks;
static boost::optional< block_t::pair_t > last;
static comma::uint32 block_id = 0;
block_t::pairs_t* points = new block_t::pairs_t;
while( true ) // quick and dirty, only if --discard
{
static comma::csv::input_stream< input_t > istream( std::cin, csv );
points->clear();
while( true )
{
if( last )
{
block_id = last->first.block;
points->push_back( *last );
last.reset();
}
if( is_shutdown || std::cout.bad() || std::cin.bad() || std::cin.eof() )
{
if( bursty_reader ) { bursty_reader->stop(); } // quick and dirty, it sucks...
if( flow ) { flow->stop(); }
break;
}
const input_t* p = istream.read();
if( !p ) { break; }
std::string line;
if( csv.binary() )
{
line.resize( csv.format().size() );
::memcpy( &line[0], istream.binary().last(), csv.format().size() );
}
else
{
line = comma::join( istream.ascii().last(), csv.delimiter );
}
last = std::make_pair( *p, line );
if( p->block != block_id ) { break; }
}
for( unsigned int i = 0; i < blocks.size(); ++i )
{
if( !blocks[i].empty ) { continue; }
blocks[i].clear();
blocks[i].id = block_id;
blocks[i].points.reset( points );
blocks[i].empty = false;
return &blocks[i];
}
}
}
示例2: intervals
intervals( const comma::command_line_options& options ) : options( options )
, csv( options )
, ocsv( options )
, ascii_csv( options )
, empty( traits< bound_type >::cast( options.optional< std::string >( "--empty" ) ) )
, intervals_only( options.exists( "--intervals-only" ) )
, use_limits( options.exists( "--limits,-l" ) )
{
if( csv.fields.empty() ) { csv.fields = comma::join( comma::csv::names< interval_t< From, To > >(), ',' ); }
if( ocsv.fields.empty() || intervals_only )
{
ocsv.fields = comma::join( comma::csv::names< interval_t< From, To > >(), ',' );
if( ocsv.binary() && ( intervals_only || append ) ) { ocsv.format( comma::csv::format::value< interval_t< From, To > >() ); }
}
ascii_csv.fields = ocsv.fields;
ascii_csv.quote = boost::none;
if( verbose ) { std::cerr << app_name << ": empty: "; empty ? std::cerr << *empty : std::cerr << "<none>"; std::cerr << std::endl; }
options.assert_mutually_exclusive( "overlap-count-min,overlap-count-max", "overlap-count" );
if( options.exists( "--overlap-count" ) )
{
min_overlap_count = max_overlap_count = options.value< unsigned int >( "--overlap-count" );
}
else
{
min_overlap_count = options.value( "--overlap-count-min", 0 );
max_overlap_count = options.value( "--overlap-count-max", std::numeric_limits< unsigned int >::max() );
}
}
示例3:
disparity::disparity ( const snark::imaging::camera_parser& left, const snark::imaging::camera_parser& right, unsigned int width, unsigned int height, const comma::csv::options& csv, bool input_rectified ):
m_rotation( right.rotation() * left.rotation().transpose() ),
m_translation( right.translation() - left.translation() ),
m_rectify( left.camera(), left.distortion(), right.camera(), right.distortion(), width, height, m_rotation, m_translation, input_rectified ),
m_input_rectified( input_rectified ),
m_serialization( csv.fields, csv.format() )
{
}
示例4:
template < typename It > static void output_( It it, It end )
{
for( ; it != end; ++it )
{
for( std::size_t i = 0; i < it->second.size() ; ++i )
{
std::cout.write( &( it->second[i][0] ), stdin_csv.binary() ? stdin_csv.format().size() : it->second[i].length() );
if( stdin_csv.flush ) { std::cout.flush(); }
}
}
}
示例5:
stereo::stereo ( const snark::imaging::camera_parser& left, const snark::imaging::camera_parser& right, unsigned int width, unsigned int height, const comma::csv::options& csv, bool input_rectified ):
m_rotation( right.rotation() * left.rotation().transpose() ),
m_translation( right.translation() - left.translation() ),
m_rectify( left.camera(), left.distortion(), right.camera(), right.distortion(), width, height, m_rotation, m_translation, input_rectified ),
m_input_rectified( input_rectified ),
m_frame_counter( 0 )
{
if( csv.binary() )
{
m_binary.reset( new comma::csv::binary< colored_point >( csv ) );
m_output.resize( csv.format().size() );
}
else
{
m_ascii.reset( new comma::csv::ascii< colored_point >( csv ) );
}
}
示例6: intervals
intervals( const comma::command_line_options& options ) : options( options )
, csv( options )
, ocsv( options )
, ascii_csv( options )
, empty( traits< bound_type >::cast( options.optional< std::string >( "--empty" ) ) )
, intervals_only( options.exists( "--intervals-only" ) )
, use_limits( options.exists( "--limits,-l" ) )
{
if( csv.fields.empty() ) { csv.fields = comma::join( comma::csv::names< interval_t< From, To > >(), ',' ); }
if( ocsv.fields.empty() || intervals_only )
{
ocsv.fields = comma::join( comma::csv::names< interval_t< From, To > >(), ',' );
if( ocsv.binary() && intervals_only ) { ocsv.format( comma::csv::format::value< interval_t< From, To > >() ); }
}
ascii_csv.fields = ocsv.fields;
ascii_csv.quote = boost::none;
if( verbose ) { std::cerr << app_name << ": empty: "; empty ? std::cerr << *empty : std::cerr << "<none>"; std::cerr << std::endl; }
}
示例7: sort
int sort( const comma::command_line_options& options )
{
input_t::map sorted_map;
input_t default_input;
std::vector< std::string > v = comma::split( stdin_csv.fields, ',' );
std::vector< std::string > order = options.exists("--order") ? comma::split( options.value< std::string >( "--order" ), ',' ) : v;
std::vector< std::string > w (v.size());
bool unique = options.exists("--unique,-u");
std::string first_line;
comma::csv::format f;
if( stdin_csv.binary() ) { f = stdin_csv.format(); }
else if( options.exists( "--format" ) ) { f = comma::csv::format( options.value< std::string >( "--format" ) ); }
else
{
while( std::cin.good() && first_line.empty() ) { std::getline( std::cin, first_line ); }
if( first_line.empty() ) { return 0; }
f = comma::csv::impl::unstructured::guess_format( first_line, stdin_csv.delimiter );
if( verbose ) { std::cerr << "csv-sort: guessed format: " << f.string() << std::endl; }
}
for( std::size_t i = 0; i < order.size(); ++i ) // quick and dirty, wasteful, but who cares
{
if (order[i].empty()) continue;
for( std::size_t k = 0; k < v.size(); ++k )
{
if( v[k].empty() || v[k] != order[i] )
{
if ( k + 1 == v.size())
{
std::cerr << "csv-sort: order field name \"" << order[i] << "\" not found in input fields \"" << stdin_csv.fields << "\"" << std::endl;
return 1;
}
continue;
}
std::string type = default_input.keys.append( f.offset( k ).type );
w[k] = "keys/" + type;
ordering_t o;
if ( type[0] == 's' ) { o.type = ordering_t::str_type; o.index = default_input.keys.strings.size() - 1; }
else if ( type[0] == 'l' ) { o.type = ordering_t::long_type; o.index = default_input.keys.longs.size() - 1; }
else if ( type[0] == 'd' ) { o.type = ordering_t::double_type; o.index = default_input.keys.doubles.size() - 1; }
else if ( type[0] == 't' ) { o.type = ordering_t::time_type; o.index = default_input.keys.time.size() - 1; }
else { std::cerr << "csv-sort: cannot sort on field " << v[k] << " of type \"" << type << "\"" << std::endl; return 1; }
ordering.push_back(o);
break;
}
}
stdin_csv.fields = comma::join( w, ',' );
if ( verbose ) { std::cerr << "csv-sort: fields: " << stdin_csv.fields << std::endl; }
comma::csv::input_stream< input_t > stdin_stream( std::cin, stdin_csv, default_input );
#ifdef WIN32
if( stdin_stream.is_binary() ) { _setmode( _fileno( stdout ), _O_BINARY ); }
#endif
if (!first_line.empty())
{
input_t::map::mapped_type& d = sorted_map[ comma::csv::ascii< input_t >(stdin_csv,default_input).get(first_line) ];
d.push_back( first_line + "\n" );
}
while( stdin_stream.ready() || ( std::cin.good() && !std::cin.eof() ) )
{
const input_t* p = stdin_stream.read();
if( !p ) { break; }
if( stdin_stream.is_binary() )
{
input_t::map::mapped_type& d = sorted_map[ *p ];
if (unique && !d.empty()) continue;
d.push_back( std::string() );
d.back().resize( stdin_csv.format().size() );
::memcpy( &d.back()[0], stdin_stream.binary().last(), stdin_csv.format().size() );
}
else
{
input_t::map::mapped_type& d = sorted_map[ *p ];
if (unique && !d.empty()) continue;
d.push_back( comma::join( stdin_stream.ascii().last(), stdin_csv.delimiter ) + "\n" );
}
}
if( options.exists( "--reverse,-r" ) ) { output_( sorted_map.rbegin(), sorted_map.rend() ); }
else { output_( sorted_map.begin(), sorted_map.end() ); }
return 0;
}
示例8: main
int main( int ac, char** av )
{
try
{
comma::command_line_options options( ac, av );
if( options.exists( "--help,-h" ) ) { usage(); }
verbose = options.exists( "--verbose,-v" );
bool is_or = options.exists( "--or" );
csv = comma::csv::options( options );
fields = comma::split( csv.fields, ',' );
if( fields.size() == 1 && fields[0].empty() ) { fields.clear(); }
std::vector< std::string > unnamed = options.unnamed( "--first-matching,--or,--sorted,--input-sorted,--not-matching,--output-all,--all,--strict,--verbose,-v", "-.*" );
//for( unsigned int i = 0; i < unnamed.size(); constraints_map.insert( std::make_pair( comma::split( unnamed[i], ';' )[0], unnamed[i] ) ), ++i );
bool strict = options.exists( "--strict" );
bool first_matching = options.exists( "--first-matching" );
bool not_matching = options.exists( "--not-matching" );
bool all = options.exists( "--output-all,--all" );
for( unsigned int i = 0; i < unnamed.size(); ++i )
{
std::string field = comma::split( unnamed[i], ';' )[0];
bool found = false;
for( unsigned int j = 0; j < fields.size() && !found; found = field == fields[j], ++j );
if( !found )
{
if( strict ) { std::cerr << "csv-select: on constraint: \"" << unnamed[i] << "\" field \"" << field << "\" not found in fields: " << csv.fields << std::endl; return 1; }
std::cerr << "csv-select: warning: on constraint: \"" << unnamed[i] << "\" field \"" << field << "\" not found in fields: " << csv.fields << std::endl;
continue;
}
constraints_map.insert( std::make_pair( field, unnamed[i] ) );
}
comma::signal_flag is_shutdown;
if( csv.binary() )
{
#ifdef WIN32
_setmode( _fileno( stdout ), _O_BINARY );
#endif
init_input( csv.format(), options );
comma::csv::binary_input_stream< input_t > istream( std::cin, csv, input );
while( !is_shutdown && ( istream.ready() || ( std::cin.good() && !std::cin.eof() ) ) )
{
const input_t* p = istream.read();
if( !p || p->done( is_or ) ) { break; }
char match = ( p->is_a_match( is_or ) == !not_matching ) ? 1 : 0;
if( match || all )
{
std::cout.write( istream.last(), csv.format().size() );
if( all ) { std::cout.write( &match, 1 ); }
if( csv.flush ) { std::cout.flush(); }
if( first_matching ) { break; }
}
}
}
else
{
std::string line;
while( !is_shutdown && std::cin.good() && !std::cin.eof() )
{
std::getline( std::cin, line );
line = comma::strip( line, '\r' ); // windows, sigh...
if( !line.empty() ) { break; }
}
if( line.empty() ) { return 0; }
comma::csv::format format = options.exists( "--format" )
? comma::csv::format( options.value< std::string >( "--format" ) )
: guess_format( line );
init_input( format, options );
comma::csv::ascii_input_stream< input_t > istream( std::cin, csv, input );
// todo: quick and dirty: no time to debug why the commented section does not work (but that's the right way)
std::istringstream iss( line );
comma::csv::ascii_input_stream< input_t > isstream( iss, csv, input );
const input_t* p = isstream.read();
if( !p || p->done( is_or ) ) { return 0; }
bool match = p->is_a_match( is_or ) == !not_matching;
if( match || all )
{
std::cout << line;
if( all ) { std::cout << csv.delimiter << match; }
std::cout << std::endl;
if( first_matching ) { return 0; }
}
while( !is_shutdown && ( istream.ready() || ( std::cin.good() && !std::cin.eof() ) ) )
{
const input_t* p = istream.read();
if( !p || p->done( is_or ) ) { break; }
bool match = p->is_a_match( is_or ) == !not_matching;
if( match || all )
{
std::cout << comma::join( istream.last(), csv.delimiter );
if( all ) { std::cout << csv.delimiter << match; }
std::cout << std::endl;
if( first_matching ) { return 0; }
}
}
}
return 0;
}
catch( std::exception& ex ) { std::cerr << "csv-select: caught: " << ex.what() << std::endl; }
catch( ... ) { std::cerr << "csv-select: unknown exception" << std::endl; }
return 1;
}
示例9: main
int main( int ac, char** av )
{
try
{
comma::command_line_options options( ac, av );
verbose = options.exists( "--verbose,-v" );
if( options.exists( "--help,-h" ) ) { usage( verbose ); }
csv = comma::csv::options( options );
csv.full_xpath = true;
ascii = comma::csv::ascii< Eigen::Vector3d >( "x,y,z", csv.delimiter );
const std::vector< std::string >& operations = options.unnamed( "--verbose,-v,--trace,--no-antialiasing,--next,--unit", "-.*" );
if( operations.size() != 1 ) { std::cerr << "points-calc: expected one operation, got " << operations.size() << ": " << comma::join( operations, ' ' ) << std::endl; return 1; }
const std::string& operation = operations[0];
if (vector_calc::has_operation(operation))
{
vector_calc::process(operation, options, csv);
return 0;
}
if( operation == "plane-intersection" )
{
plane_intersection::process(options, csv);
return 0;
}
if( operation == "distance" )
{
if( csv.has_field( "first" ) || csv.has_field( "second" )
|| csv.has_field( "first/x" ) || csv.has_field( "second/x" )
|| csv.has_field( "first/y" ) || csv.has_field( "second/y" )
|| csv.has_field( "first/z" ) || csv.has_field( "second/z" ) )
{
calculate_distance_for_pairs();
return 0;
}
if ( options.exists( "--next" ) ) { calculate_distance_next(); }
else { calculate_distance( false ); }
return 0;
}
if( operation == "cumulative-distance" )
{
calculate_distance( true );
return 0;
}
if( operation == "nearest" )
{
if( options.exists( "--point,--to" ) )
{
Eigen::Vector3d point = comma::csv::ascii< Eigen::Vector3d >().get( options.value< std::string >( "--point,--to" ) );
comma::csv::input_stream< Eigen::Vector3d > istream( std::cin, csv );
std::string record;
double min_distance = std::numeric_limits< double >::max();
while( istream.ready() || ( std::cin.good() && !std::cin.eof() ) )
{
const Eigen::Vector3d* p = istream.read();
if( !p ) { break; }
double d = ( *p - point ).norm();
if( d >= min_distance ) { continue; }
min_distance = d;
record = csv.binary() ? std::string( istream.binary().last(), csv.format().size() ) : comma::join( istream.ascii().last(), csv.delimiter );
}
if( !record.empty() ) { std::cout << record; }
if( csv.binary() ) { std::cout.write( reinterpret_cast< const char* >( &min_distance ), sizeof( double ) ); }
else { std::cout << csv.delimiter << min_distance << std::endl; }
return 0;
}
else
{
return 0;
}
}
if( operation == "thin" )
{
if( !options.exists( "--resolution" ) ) { std::cerr << "points-calc: --resolution is not specified " << std::endl; return 1; }
double resolution = options.value( "--resolution" , 0.0 );
thin( resolution );
return 0;
}
if( operation == "discretise" || operation == "discretize" )
{
if( !options.exists( "--step" ) ) { std::cerr << "points-calc: --step is not specified " << std::endl; return 1; }
double step = options.value( "--step" , 0.0 );
if( step <= 0 ) { std::cerr << "points-calc: expected positive step, got " << step << std::endl; return 1; }
// the last discretised point can be very close to the end of the interval, in which case the last two points can be identical in the output since ascii.put uses 12 digits by default
// setting --tolerance=1e-12 will not allow the last discretised point to be too close to the end of the interval and therefore the output will have two distinct points at the end
double tolerance = options.value( "--tolerance" , 0.0 );
if( tolerance < 0 ) { std::cerr << "points-calc: expected non-negative tolerance, got " << tolerance << std::endl; return 1; }
discretise( step, tolerance );
return 0;
}
if( operation == "local-max" || operation == "local-min" ) // todo: if( operation == "local-calc" ? )
{
double sign = operation == "local-max" ? 1 : -1;
if( csv.fields.empty() ) { csv.fields = "x,y,z,scalar"; }
csv.full_xpath = false;
bool has_id = csv.has_field( "id" );
comma::csv::input_stream< local_operation::point > istream( std::cin, csv );
std::deque< local_operation::record > records;
double radius = options.value< double >( "--radius" );
bool trace = options.exists( "--trace" );
Eigen::Vector3d resolution( radius, radius, radius );
//.........这里部分代码省略.........
示例10: output_input
static void output_input( std::ostream& os, const timestring_t& input )
{
if( stdin_csv.binary() ) { os.write( &input.second[0], stdin_csv.format().size() ); }
else { os << input.second; }
}
示例11: main
//.........这里部分代码省略.........
std::cerr << " point them to your pylon installation, e.g:" << std::endl;
std::cerr << " export PYLON_ROOT=/opt/pylon" << std::endl;
std::cerr << " export GENICAM_ROOT_V2_1=/opt/pylon/genicam" << std::endl;
return 1;
}
if( vm.count( "list-cameras" ) )
{
Pylon::DeviceInfoList_t devices;
factory.EnumerateDevices( devices );
for( unsigned int i = 0; i < devices.size(); ++i ) { std::cerr << devices[i].GetFullName() << std::endl; }
return 0;
}
timeout = timeout_seconds * 1000.0;
std::string filters = comma::join( boost::program_options::collect_unrecognized( parsed.options, boost::program_options::include_positional ), ';' );
options.header_only = vm.count( "header-only" );
options.no_header = vm.count( "no-header" );
csv = comma::csv::options( argc, argv );
bool chunk_mode = csv.has_field( "counters" ) // quick and dirty
|| csv.has_field( "adjusted-t" )
|| csv.has_field( "line" )
|| csv.has_field( "line-count" )
|| csv.has_field( "ticks" )
|| csv.has_field( "counters/adjusted-t" )
|| csv.has_field( "counters/line" )
|| csv.has_field( "counters/line-count" )
|| csv.has_field( "counters/ticks" );
if( chunk_mode )
{
if( vm.count( "encoder-ticks" ) == 0 ) { std::cerr << "basler-cat: chunk mode, please specify --encoder-ticks" << std::endl; return 1; }
if( !filters.empty() ) { std::cerr << "basler-cat: chunk mode, cannot handle filters; use: basler-cat | cv-cat <filters> instead" << std::endl; return 1; }
if( height != 1 && height != std::numeric_limits< unsigned int >::max() ) { std::cerr << "basler-cat: only --height=1 implemented in chunk mode" << std::endl; return 1; }
height = 1;
std::vector< std::string > v = comma::split( csv.fields, ',' );
std::string format;
for( unsigned int i = 0; i < v.size(); ++i )
{
if( v[i] == "t" ) { v[i] = "header/" + v[i]; format += "t"; }
else if( v[i] == "rows" || v[i] == "cols" || v[i] == "size" || v[i] == "type" ) { v[i] = "header/" + v[i]; format += "ui"; }
else if( v[i] == "adjusted-t" ) { v[i] = "counters/" + v[i]; format += "t"; }
else if( v[i] == "line-count" || v[i] == "ticks" ) { v[i] = "counters/" + v[i]; format += "ul"; }
else if( v[i] == "line" ) { v[i] = "counters/" + v[i]; format += "ui"; }
else { std::cerr << "basler-cat: expected field, got '" << v[i] << "'" << std::endl; return 1; }
}
csv.fields = comma::join( v, ',' );
csv.full_xpath = true;
csv.format( format );
}
if( !vm.count( "buffer" ) && vm.count( "discard" ) ) { discard = 1; }
Pylon::CBaslerGigECamera camera;
if( vm.count( "address" ) )
{
Pylon::CBaslerGigEDeviceInfo info;
info.SetIpAddress( address.c_str() );
camera.Attach( factory.CreateDevice( info ) );
}
else
{
Pylon::DeviceInfoList_t devices;
factory.EnumerateDevices( devices );
if( devices.empty() ) { std::cerr << "basler-cat: no camera found" << std::endl; return 1; }
std::cerr << "basler-cat: will connect to the first of " << devices.size() << " found device(s):" << std::endl;
for( unsigned int i = 0; i < devices.size(); ++i ) { std::cerr << " " << devices[i].GetFullName() << std::endl; }
camera.Attach( transport_layer->CreateDevice( devices[0] ) );
}
if( verbose ) { std::cerr << "basler-cat: initialized camera" << std::endl; }
if( verbose ) { std::cerr << "basler-cat: opening camera " << camera.GetDevice()->GetDeviceInfo().GetFullName() << "..." << std::endl; }
示例12: main
int main( int ac, char** av )
{
comma::command_line_options options( ac, av );
verbose = options.exists( "--verbose,-v" );
if( options.exists( "--help,-h" ) ) { usage(verbose); }
try
{
options.assert_mutually_exclusive("--tcp,--serial");
options.assert_mutually_exclusive("--laser,--serial");
scan_break = options.value< comma::uint32 > ( "--scan-break", 20 ); // time in us
num_of_scans = options.value< comma::uint32 > ( "--num-of-scans", 100 ); // time in us
reboot_on_error = options.exists( "--reboot-on-error" );
start_step=options.value<int>("--start-step", -1);
end_step=options.value<int>("--end-step", -1);
debug_verbose=options.exists("--debug");
frames=options.value<int>("--frames",-1);
omit_on_error = ! options.exists("--dont-omit-on-error");
bool permissive = options.exists( "--permissive" );
std::vector< std::string > unnamed = options.unnamed( "--output-fields,--output-format,--format,--verbose,-v,--flush,--reboot-on-error,--debug,--output-samples,--dont-omit-on-errork,--permissive",
"--frames,--scan-break,--num-of-scans,--start-step,--end-step,--serial,--port,--tcp,--laser,--fields,--binary,-b,--baud-rate,--set-baud-rate");
if(!unnamed.empty()) { std::cerr<<"invalid option(s):"<< comma::join(unnamed, ',') <<std::endl; return 1; }
scip2_device scip2;
ust_device<UST_SMALL_STEPS> ust_small( permissive );
ust_device<UST_MAX_STEPS> ust_max( permissive );
const bool serial = options.exists( "--serial");
laser_device& device = serial ? scip2 : (start_step ? (laser_device&)ust_small : (laser_device&)ust_max);
// Sets up output data
csv.fields = options.value< std::string >( "--fields", "" );
std::vector< std::string > v = comma::split( csv.fields, ',' );
for( std::size_t i = 0; i < v.size(); ++i ) // convenience shortcuts
{
if( v[i] == "i" ) { v[i] = "intensity"; }
else if( v[i] == "r" ) { v[i] = "range"; }
else if( v[i] == "b" ) { v[i] = "bearing"; }
else if( v[i] == "e" ) { v[i] = "elevation"; }
}
csv.fields = comma::join( v, ',' );
csv.full_xpath = false;
// see sick-ldmrs-to-csv
if( options.exists( "--output-format,--format" ) )
{
if( !options.exists("--tcp") && !options.exists("--serial") ) { std::cerr << name() << "please specify --serial or --tcp" << std::endl; return 1; }
if(serial) { std::cout << comma::csv::format::value< scip2_device::output_t >( csv.fields, false ) << std::endl; }
else { std::cout << comma::csv::format::value< snark::hokuyo::data_point >( csv.fields, false ) << std::endl; }
return 0;
}
if(options.exists("--output-fields"))
{
if( !options.exists("--tcp") && !options.exists("--serial") ) { std::cerr << name() << "please specify --serial or --tcp" << std::endl; return 1; }
if(!csv.fields.empty()) {std::cout<<csv.fields<<std::endl;}
else if(serial) { std::cout<<comma::join(comma::csv::names<scip2_device::output_t>(), ',')<<std::endl;}
else {std::cout<<comma::join(comma::csv::names<snark::hokuyo::data_point>(), ',')<<std::endl;}
return 0;
}
if( options.exists( "--binary,-b" ) )
{
if(serial) { csv.format( comma::csv::format::value< scip2_device::output_t >( csv.fields, false ) ); }
else { csv.format( comma::csv::format::value< snark::hokuyo::data_point >( csv.fields, false ) ); }
}
if( options.exists( "--output-samples" ) ) { output_samples(); return 0; }
device.init(options);
/// Connect to the laser
ios = device.connect();
device.setup(*ios);
if(serial)
{
if(debug_verbose) { ((serial_stream&)*ios).dump_setting(); }
// debug_msg("change serial settings");
// const char* ss_cmd="SS500000\n";
process(scip2);
}
else
{
if(start_step) { process(ust_small); } else { process(ust_max); }
}
}
catch( std::exception& ex ) { std::cerr << name() << ex.what() << std::endl; return 1; }
catch( ... ) { std::cerr << name() << "unknown exception" << std::endl; return 1; }
return 0;
}