#include #include #include #include #include "MainPanel.h" #include "STCLogContainer.h" #include "STControlEngine.h" #include "STRodCrate.h" #include #include #include #include #include #include using namespace PixLib; using namespace SctPixelRod; int main( int argc, char** argv ) { // process command line arguments QString pathToRootDB=""; bool autoInit = false; QString prlPath=""; bool singleCrateMode = true; for(int i=0;i syntax: load RootDB cfg file if(strcmp(argv[i],"-l")==0 && i<(argc-1)) pathToRootDB=argv[i+1]; // -i plus above option -> auto-init of all ROD/BOCs if(strcmp(argv[i],"-i")==0) autoInit = true; // -m -> run in multi-crate mode (experimentally for now!!!) if(strcmp(argv[i],"-m")==0) singleCrateMode = false; } // start root and QT application QRootApplication app( argc, argv ); // create logging facility STCLogContainer *log = new STCLogContainer( &app, "STC_Log_Facility" ); // create Engine STControlEngine *engine = new STControlEngine( &app, *log , 0, "main_engine", singleCrateMode ); // launch main GUI window MainPanel *Win = new MainPanel( *engine, *log, 0, "PixRodGUI" ); Win->show(); //int xpos = (int)QApplication::desktop()->width()-Win->width()-10; //Win->move(xpos,10); app.setMainWidget(Win); if(singleCrateMode){ // special mode: always have exactly one crate object, never changed, never deleted // create a crate on local host #ifdef WIN32 QString SBCname = gSystem->Getenv("COMPUTERNAME"); #else QString SBCname = gSystem->Getenv("HOSTNAME"); #endif engine->addCrate(SBCname.latin1()); } // RootDB file given on command line: load if(pathToRootDB!="") engine->init(pathToRootDB.latin1(), autoInit, 0); else engine->init(0,false,0); // executing our application int ret = 0; std::stringstream msg; try{ ret = app.exec(); } catch (SctPixelRod::VmeException& v) { msg << "VME-exception "; msg << v; } catch(SctPixelRod::BaseException& b){ msg << "Base exception "; msg << b; } catch(std::exception& s){ msg << "Std-lib exception "; msg << s.what(); } catch(...){ msg << "Unknown exception "; } if(msg.str()!="") std::cerr << msg.str() << " not caught during execution of main window." << std::endl; // cleaning up delete Win; // globalData is deleted by STControlEngine, which takes ownership delete engine; return ret; }