216 struct sigaction act;
220 act.sa_flags = SA_SIGINFO;
225 if( sigaction( SIGTERM, &act, 0 ) < 0 )
227 std::cerr <<
" (" << invokedName <<
"): error setting SIGTERM handler: " << strerror( errno ) <<
"\n";
232 if( sigaction( SIGQUIT, &act, 0 ) < 0 )
234 std::cerr <<
" (" << invokedName <<
"): error setting SIGQUIT handler: " << strerror( errno ) <<
"\n";
239 if( sigaction( SIGINT, &act, 0 ) < 0 )
241 std::cerr <<
" (" << invokedName <<
"): error setting SIGINT handler: " << strerror( errno ) <<
"\n";
253 mx::error_t errc = mx::ioutils::getFileNames<verboseT>(
m_files,
m_dir,
"",
"",
".xrif" );
257 mx::error_report<verboseT>( errc,
"getting list of xrif files" );
271 for(
size_t n = 0; n <
m_files.size(); ++n )
279 mx::error_report<verboseT>( mx::error_t::filenotfound,
"no xrif files found" );
288 mx::error_report<verboseT>( mx::error_t::allocerr,
"allocating xrif" );
303 char header[XRIF_HEADER_SIZE];
308 for(
long n = st; n != ed; n += stp )
311 FILE *fp_xrif = fopen(
m_files[n].c_str(),
"rb" );
315 mx::error_report<verboseT>( mx::errno2error_t( errno ),
"opening " +
m_files[n] );
319 if( ferror( fp_xrif ) || errno != 0 )
321 mx::error_report<verboseT>( mx::errno2error_t( errno ),
"error from fopen for " +
m_files[n] );
325 size_t nr = fread( header, 1, XRIF_HEADER_SIZE, fp_xrif );
328 if( nr != XRIF_HEADER_SIZE )
330 mx::error_report<verboseT>(mx::error_t::filererr,
"reading header of " +
m_files[n]);
334 uint32_t header_size;
335 xrif_read_header(
m_xrif, &header_size, header );
347 mx::error_report<verboseT>(mx::error_t::sizeerr,
"width mis-match in "+
m_files[n]);
352 mx::error_report<verboseT>(mx::error_t::sizeerr,
"height mis-match in "+
m_files[n]);
357 mx::error_report<verboseT>(mx::error_t::invalidconfig,
"width mis-match in "+
m_files[n]);
364 mx::error_report<verboseT>(mx::error_t::invalidarg,
"Cubes detected in " +
m_files[n]);
370 mx::error_report<verboseT>(mx::error_t::invalidarg,
"Only 16-bit unsigned integers (short) supported");
374 nframes +=
m_xrif->frames;
385 std::cerr <<
" (" << invokedName <<
"): exiting.\n";
395 std::cerr <<
" (" << invokedName <<
"): Reading " <<
m_numFrames <<
" frames in " << ( ed - st ) * stp <<
" file";
396 if( ( ed - st ) * stp > 1 )
418 for(
long n = st; n != ed; n += stp )
426 FILE *fp_xrif = fopen(
m_files[n].c_str(),
"rb" );
430 mx::error_report<verboseT>(mx::errno2error_t(errno),
"null ptr from fopen for " +
m_files[n] );
434 if( ferror( fp_xrif ) || errno != 0 )
436 mx::error_report<verboseT>(mx::errno2error_t(errno),
"error from fopen for " +
m_files[n] );
440 size_t nr = fread( header, 1, XRIF_HEADER_SIZE, fp_xrif );
442 if( nr != XRIF_HEADER_SIZE )
444 mx::error_report<verboseT>(mx::error_t::filererr,
"reading header of " +
m_files[n]);
449 uint32_t header_size;
450 xrif_read_header(
m_xrif, &header_size, header );
452 xrif_allocate_raw(
m_xrif );
454 xrif_allocate_reordered(
m_xrif );
456 nr = fread(
m_xrif->raw_buffer, 1,
m_xrif->compressed_size, fp_xrif );
465 if( nr !=
m_xrif->compressed_size )
467 mx::error_report<verboseT>(mx::error_t::filererr,
"reading data from " +
m_files[n]);
478 mx::improc::eigenCube<uint16_t> tmpc(
483 long ped = tmpc.planes();
486 pst = tmpc.planes() - 1;
490 for(
int p = pst; p != ped; p += stp )
492 m_frames.image( findex ) = tmpc.image( p );
503 std::cerr <<
" (" << invokedName <<
"): exiting.\n";
530 CIRCULAR_BUFFER | ZAXIS_TEMPORAL,
536 uint64_t next_cnt1 = 0;
543 double lastSend = mx::sys::get_curr_time();
553 clock_gettime( CLOCK_REALTIME, &
m_imageStream.md->writetime );
584 double ct = mx::sys::get_curr_time();
585 delta += 0.1 * ( ct - lastSend - 1.0 /
m_fps );
588 if( 1. /
m_fps - delta > 0 )
595 std::cerr <<
" (" << invokedName <<
"): exited normally.\n";