int main(int argc, char *arg[]) { int port = atoi(arg[1]); std::string fileSystemPrefix = std::string(arg[2]); Logger logger("Application"); std::shared_ptr< ClientsMap<int, ClientManager *> > clients = std::make_shared< ClientsMap<int, ClientManager *> >("Clients"); FileManager fileManager(fileSystemPrefix); PlaylistManager playlistManager(fileSystemPrefix); Dispatcher *dispatcher = new Dispatcher(fileManager, playlistManager, clients); std::thread dispatcherThread = std::thread(&Dispatcher::start, dispatcher); logger.log("Dispatcher has been created"); ConnectionManager connectionManager(dispatcher, port, clients); std::thread connectionManagerThread = std::thread(&ConnectionManager::start, &connectionManager); logger.log("ConnectionManager has been created"); SoundProcessor soundProcessor(fileManager, playlistManager, clients); std::thread soundProcessorThread = std::thread(&SoundProcessor::stream, &soundProcessor); logger.log("SoundProcessor has been created"); connectionManagerThread.join(); dispatcherThread.join(); soundProcessorThread.join(); delete dispatcher; logger.log("Has been closed"); return 0; }
void TCPServer::await_stop_signal() { ssignals.async_wait( [this](boost::system::error_code /*ec*/, int /*signo*/) { acceptor.close(); //clean all the connections connectionManager().stopAll(); stop(); }); }
void TCPServer::accept() { acceptor.async_accept( socket, [this](boost::system::error_code ec) { if (!acceptor.is_open()) { return; } //wrap it if (!ec) { LOG(geryon::util::Log::DEBUG) << "Executing connMgr::start"; connectionManager().start(std::move(socket), iosrvc); } else { LOG(geryon::util::Log::ERROR) << "Server >>" << serverName << ": Problem executing accept(), error code:" << ec; } accept(); }); }
INT frontend_init_wfd() { for(int i=0;i<12;i++){ if(amc13_rider_odb[i].board.rider_enabled){ numWFDs++; } } uhal::ConnectionManager connectionManager( "file://connection.xml;" ); dbprintf("%s(%d): read xml connection file \n", __func__, __LINE__); printf("numWFDs = %d\n",numWFDs); char wfdname[8]; for(int i=0; i<numWFDs; i++){ sprintf(wfdname,"wfd_%i",i); wfd[i] = new uhal::HwInterface(connectionManager.getDevice(wfdname)); } dbprintf("%s(%d): read xml address table file \n", __func__, __LINE__); //std::cout << "reading content of status register..." << std::endl; //uhal::ValWord<uint32_t> result = wfd[0]->getNode("status").read(); //wfd[0]->dispatch(); //std::cout << "contents of status register: 0x" << std::hex << result.value() << std::dec <<std::endl; for (int ri = 0; ri<numWFDs; ri++){ wfd[ri]->getNode("ctrl.rst").write(1); wfd[ri]->dispatch(); //reset twice wfd[ri]->getNode("ctrl.rst").write(1); wfd[ri]->dispatch(); } amc13lib.AMC13_Reset(amc13); //system("python reset.py"); //printf("Reset Rider, wait 30s ... \n"); //sleep(30); //start programming channels //system("python start_prog_chan.py"); /* for (int ri = 0; ri<numWFDs; ri++){ //Start programming channel FPGAs from flash wfd[ri]->getNode("ctrl.start_prog_chan").write(1); wfd[ri]->dispatch(); // turn the signal off again wfd[ri]->getNode("ctrl.start_prog_chan").write(0); wfd[ri]->dispatch(); }*/ /*obsolete flash programming wfd[0]->getNode("ctrl.start_prog_chan").write(1); wfd[0]->dispatch(); // turn the signal off again wfd[0]->getNode("ctrl.start_prog_chan").write(0); wfd[0]->dispatch(); printf("programming channels, wait 30s...\n"); sleep(30); */ //configure channels // system("python configure_channels.py"); //int burst_count = 65536; //int burst_count = 1000; for (int wfd_i=0; wfd_i< numWFDs; wfd_i++) { //enable all 5 channels wfd[wfd_i]->getNode("ctrl.enable0").write(1); wfd[wfd_i]->getNode("ctrl.enable1").write(1); wfd[wfd_i]->getNode("ctrl.enable2").write(1); wfd[wfd_i]->getNode("ctrl.enable3").write(1); wfd[wfd_i]->getNode("ctrl.enable4").write(1); wfd[wfd_i]->dispatch(); printf("Rider%i channels enabled\n",0); // set the burst count for each channel riderlib->WR_REG(wfd[wfd_i],"chan0",0x00000002,amc13_rider_odb[wfd_i].board.burst_count); riderlib->WR_REG(wfd[wfd_i],"chan1",0x00000002,amc13_rider_odb[wfd_i].board.burst_count); riderlib->WR_REG(wfd[wfd_i],"chan2",0x00000002,amc13_rider_odb[wfd_i].board.burst_count); riderlib->WR_REG(wfd[wfd_i],"chan3",0x00000002,amc13_rider_odb[wfd_i].board.burst_count); riderlib->WR_REG(wfd[wfd_i],"chan4",0x00000002,amc13_rider_odb[wfd_i].board.burst_count); printf("Set burst count for Rider%i to %i\n",0,amc13_rider_odb[wfd_i].board.burst_count); } /* if(rc0.value() !=3 || rc1.value() !=3 || rc2.value() !=3 || rc3.value() !=3 || rc4.value() !=3){ // there was an error sending WR_REG command to one of the channels! printf("riderlib->WR_REG error: buffer size: "); if( rc0.value() != 3) printf(" Channel 0: 0x%04x\n",rc0.value()); if( rc1.value() != 3) printf(" Channel 1: 0x%04x\n",rc1.value()); if( rc2.value() != 3) printf(" Channel 2: 0x%04x\n",rc2.value()); if( rc3.value() != 3) printf(" Channel 3: 0x%04x\n",rc3.value()); if( rc4.value() != 3) printf(" Channel 4: 0x%04x\n",rc4.value()); break; }*/ //read back the burst count register for each channel to make sure they are set correctly /* rc0 = RD_REG(wfd[wfd_i],"chan0",0x00000002); rc1 = RD_REG(wfd[wfd_i],"chan1",0x00000002); rc2 = RD_REG(wfd[wfd_i],"chan2",0x00000002); rc3 = RD_REG(wfd[wfd_i],"chan3",0x00000002); rc4 = RD_REG(wfd[wfd_i],"chan4",0x00000002); if(rc0!=2 || rc1!=2 || rc2!=2 || rc3!=2 || rc4!=2){ // there was an error sending RD_REG command to one of the channels! printff("WR_REG error: buffer size: "); if( rc0 != 2) printf(" Channel 0: 0x%04x\n",rc0); if( rc1 != 2) printf(" Channel 1: 0x%04x\n",rc0); if( rc2 != 2) printf(" Channel 2: 0x%04x\n",rc0); if( rc3 != 2) printf(" Channel 3: 0x%04x\n",rc0); if( rc4 != 2) printf(" Channel 4: 0x%04x\n",rc0); break; }*/ /* wfd[0]->getNode("aurora.clksynth.cntrl").write(0x00000000); wfd[0]->getNode("aurora.clksynth.reg7pre").write(0x00000017); wfd[0]->getNode("aurora.clksynth.reg0").write(0x01010000); wfd[0]->getNode("aurora.clksynth.reg1").write(0x01010001); wfd[0]->getNode("aurora.clksynth.reg2").write(0x01010002); wfd[0]->getNode("aurora.clksynth.reg3").write(0x01010003); wfd[0]->getNode("aurora.clksynth.reg4").write(0x01010004); wfd[0]->getNode("aurora.clksynth.reg5").write(0x00000005); wfd[0]->getNode("aurora.clksynth.reg6").write(0x08000076); wfd[0]->getNode("aurora.clksynth.reg7").write(0x00000007); wfd[0]->getNode("aurora.clksynth.reg8").write(0x00000008); wfd[0]->getNode("aurora.clksynth.reg9").write(0x00a22a09); wfd[0]->getNode("aurora.clksynth.reg10").write(0x0150000a); wfd[0]->getNode("aurora.clksynth.reg11").write(0x006500cb); wfd[0]->getNode("aurora.clksynth.reg12").write(0xa00200ac); wfd[0]->getNode("aurora.clksynth.reg13").write(0x0a04000d); wfd[0]->getNode("aurora.clksynth.reg14").write(0x1900004e); wfd[0]->getNode("aurora.clksynth.reg15").write(0x108000ff); wfd[0]->getNode("aurora.clksynth.cntrl").write(0x00000001); wfd[0]->dispatch(); */ /*The following is the configuration settings used in the SLAC 2014 test beam run std::cout<< "Setting buffer size on five channels:" << std::endl; riderlib->WR_REG(wfd[wfd_i],"chan0",0x00000002,0x00000010); riderlib->WR_REG(wfd[wfd_i],"chan1",0x00000002,0x00000010); riderlib->WR_REG(wfd[wfd_i],"chan2",0x00000002,0x00000010); riderlib->WR_REG(wfd[wfd_i],"chan3",0x00000002,0x00000010); riderlib->WR_REG(wfd[wfd_i],"chan4",0x00000002,0x00000010); std::cout<< "Setting channel number on five channels:"<< std::endl; riderlib->WR_REG(wfd[wfd_i],"chan0",0x00000003,0x00000000); riderlib->WR_REG(wfd[wfd_i],"chan1",0x00000003,0x00000001); riderlib->WR_REG(wfd[wfd_i],"chan2",0x00000003,0x00000002); riderlib->WR_REG(wfd[wfd_i],"chan3",0x00000003,0x00000003); riderlib->WR_REG(wfd[wfd_i],"chan4",0x00000003,0x00000004); std::cout << "Setting post trigger count on five channels:" << std::endl; riderlib->WR_REG(wfd[wfd_i],"chan0",0x00000004,0x00000000); riderlib->WR_REG(wfd[wfd_i],"chan1",0x00000004,0x00000000); riderlib->WR_REG(wfd[wfd_i],"chan2",0x00000004,0x00000000); riderlib->WR_REG(wfd[wfd_i],"chan3",0x00000004,0x00000000); riderlib->WR_REG(wfd[wfd_i],"chan4",0x00000004,0x00000000); } */ //configure channels return SUCCESS; }