Line data Source code
1 : #include "tohost.hpp" 2 : #include "log.hpp" 3 : 4 : static volatile std::sig_atomic_t signal_status; 5 22 : void signal_handler(int s){signal_status = s;} 6 : 7 22 : int main(int argc, char** argv) 8 : { 9 22 : std::unique_ptr<ConfigFileToHost> c = std::make_unique<ConfigFileToHost>(); 10 22 : c->parse(argc, argv); 11 : 12 22 : auto th = ToHost<ConfigFileToHost, FileDevice, FileToHostBuffer>(std::move(c)); 13 : 14 44 : for (auto & dev_no : th.cfg->resource.device){ 15 22 : th.devices.emplace_back(new FileDevice(*th.cfg, dev_no)); 16 44 : for(int id : th.cfg->resource.dma_ids) { 17 22 : int unique_id = th.cfg->get_unique_dmaid(id, dev_no); 18 44 : th.dma_buffers.emplace( 19 : unique_id, 20 66 : new FileToHostBuffer(id, th.devices.back(), th.cfg->file, th.cfg->block_rate, th.cfg->repeat) 21 : ); 22 : } 23 : } 24 : 25 22 : th.start(); 26 : 27 22 : std::signal(SIGINT, signal_handler); 28 22 : std::signal(SIGTERM, signal_handler); 29 : 30 221 : while (signal_status == 0) { 31 177 : th.print_monitoring(); 32 177 : usleep(th.cfg->stats.monitoring_period_ms * 1000); 33 : } 34 22 : th.stop(); 35 22 : return 0; 36 22 : }