Psyllid  v1.12.4
Project 8 Data Acquisisition Software
roach_daq_1chan.cc
Go to the documentation of this file.
1 /*
2  * single_value_daq.cc
3  *
4  * Created on: Dec 28, 2015
5  * Author: nsoblath
6  */
7 
8 #include "event_builder.hh"
10 #include "tf_roach_receiver.hh"
11 #include "triggered_writer.hh"
12 
13 #include "diptera.hh"
14 
15 #include "logger.hh"
16 
17 #include <memory>
18 #include <signal.h>
19 
20 using std::unique_ptr;
21 
22 using namespace psyllid;
23 
24 LOGGER( plog, "roach_daq_1chan" );
25 
26 scarab::cancelable* f_cancelable = nullptr;
27 
28 void cancel( int )
29 {
30  LINFO( plog, "Attempting to cancel" );
31  if( f_cancelable != nullptr ) f_cancelable->cancel();
32  return;
33 }
34 
35 int main()
36 {
37  try
38  {
39  //unique_ptr< ::midge::diptera > t_root;
40  midge::diptera* t_root = new midge::diptera();
41 
42  tf_roach_receiver* t_udpr = new tf_roach_receiver();
43  t_udpr->set_name( "udpr" );
44  t_udpr->set_time_length( 10 );
45  t_root->add( t_udpr );
46 
48  t_fmt->set_name( "fmt" );
49  t_fmt->set_threshold_ampl_snr( 2.0 );
50  t_root->add( t_fmt );
51 
52  event_builder* t_eb = new event_builder();
53  t_eb->set_name( "eb" );
54  t_eb->set_pretrigger( 1 );
55  t_eb->set_skip_tolerance( 0 );
56  t_root->add( t_eb );
57 
58  triggered_writer* t_ew = new triggered_writer();
59  t_ew->set_name( "ew" );
60  // set parameters
61  t_root->add( t_ew );
62 
63  t_root->join( "udpr.out_0:ew.in_0" );
64  t_root->join( "udpr.out_1:fmt.in_0" );
65  t_root->join( "fmt.out_0:eb.in_0" );
66  t_root->join( "eb.out_0:ew.in_1" );
67 
68  // set up signal handling for canceling with ctrl-c
69  f_cancelable = t_udpr;
70  signal( SIGINT, cancel );
71 
72  std::exception_ptr t_e_ptr = t_root->run( "udpr:fmt:eb:ew" );
73 
74  if( t_e_ptr ) std::rethrow_exception( t_e_ptr );
75 
76  // un-setup signal handling
77  f_cancelable = nullptr;
78 
79  delete t_root;
80  }
81  catch( std::exception& e )
82  {
83  LERROR( plog, "Exception caught: " << e.what() );
84  }
85 
86  return 0;
87 }
88 
89 
static scarab::logger plog("batch_executor")
void cancel(int)
void set_threshold_ampl_snr(double a_ampl_snr)
A transformer that considers a sequence of triggered packets and decides what constitutes a contiguou...
int main()
A transformer to receive raw blocks of memory, parse them, and distribute them as time and frequency ...
A consumer to that writes triggered time ROACH packets to an egg file.
LOGGER(plog, "egg_writer")
scarab::cancelable * f_cancelable