Commit c241504f authored by Georg Auzinger's avatar Georg Auzinger
Browse files

implemented easylogging in all executables in /src

parent 2e4d83d6
* GLOBAL:
FORMAT = "%datetime{%d.%M.%Y %H:%m} |%thread|%levshort| %msg"
FILENAME = "/tmp/logs/Ph2_USBInst.log"
FILENAME = "logs/Ph2_ACF.log"
ENABLED = true
TO_FILE = true
TO_STANDARD_OUTPUT = true
......@@ -9,16 +9,18 @@
MAX_LOG_FILE_SIZE = 2097152 ## Throw log files away after 2MB
* DEBUG:
FORMAT = "%datetime{%d.%M.%Y %H:%m} |%thread|%levshort|%file|%line| %msg"
FILENAME = "/tmp/logs/Ph2_USBInst_DEBUG.log"
FILENAME = "logs/Ph2_ACF_debug.log"
TO_STANDARD_OUTPUT = true
ENABLED = true ## We will set it to false after development completed
* WARNING:
FILENAME = "/tmp/logs/Ph2_USBInst-%datetime{%H:%m}"
FILENAME = "logs/Ph2_ACF_warn.log"
TO_STANDARD_OUTPUT = true
* VERBOSE:
FORMAT = "%datetime{%d/%M/%y} | %level-%vlevel | %msg"
## Error logs
* ERROR:
ENABLED = false
FILENAME = "/tmp/logs/Ph2_USBInst_ERROR.log"
FILENAME = "logs/Ph2_ACF_err.log"
TO_STANDARD_OUTPUT = true
* FATAL:
ENABLED = false
......@@ -4,6 +4,7 @@ calibrate
hybridtest
configure
datatest
pulseshape
cmtest
commission
fpgaconfig
......@@ -64,7 +64,7 @@ int main ( int argc, char* argv[] )
if ( result != ArgvParser::NoParserError )
{
LOG (ERROR) << cmd.parseErrorDescription ( result );
LOG (INFO) << cmd.parseErrorDescription ( result );
exit ( 1 );
}
......@@ -97,7 +97,7 @@ int main ( int argc, char* argv[] )
cTool.StartHttpServer();
cTool.ConfigureHw (outp);
LOG (INFO) << outp.str();
outp.clear();
outp.str ("");
//if ( !cOld )
//{
t.start();
......@@ -125,7 +125,7 @@ int main ( int argc, char* argv[] )
cPedeNoise.Inherit (&cTool);
cPedeNoise.ConfigureHw (outp);
LOG (INFO) << outp.str();
outp.clear();
outp.str ("");
cPedeNoise.Initialise(); // canvases etc. for fast calibration
cPedeNoise.measureNoise();
cPedeNoise.Validate();
......
......@@ -18,75 +18,90 @@ using namespace Ph2_System;
using namespace CommandLineProcessing;
int main( int argc, char* argv[] )
INITIALIZE_EASYLOGGINGPP
int main ( int argc, char* argv[] )
{
//configure the logger
el::Configurations conf ("settings/logger.conf");
el::Loggers::reconfigureAllLoggers (conf);
ArgvParser cmd;
// init
cmd.setIntroductoryDescription ( "CMS Ph2_ACF applicaton to take data and analyze it with respect to common mode noise" );
// error codes
cmd.addErrorCode ( 0, "Success" );
cmd.addErrorCode ( 1, "Error" );
// options
cmd.setHelpOption ( "h", "help", "Print this help page" );
cmd.defineOption ( "file", "Hw Description File . Default value: settings/CMTest2CBC.xml", ArgvParser::OptionRequiresValue /*| ArgvParser::OptionRequired*/ );
cmd.defineOptionAlternative ( "file", "f" );
cmd.defineOption ( "output", "Output Directory . Default value: Results/", ArgvParser::OptionRequiresValue /*| ArgvParser::OptionRequired*/ );
cmd.defineOptionAlternative ( "output", "o" );
cmd.defineOption ( "scan", "scan for noisy strips", ArgvParser::NoOptionAttribute );
cmd.defineOptionAlternative ( "scan", "s" );
ArgvParser cmd;
cmd.defineOption ( "batch", "Run the application in batch mode", ArgvParser::NoOptionAttribute );
cmd.defineOptionAlternative ( "batch", "b" );
// init
cmd.setIntroductoryDescription( "CMS Ph2_ACF applicaton to take data and analyze it with respect to common mode noise" );
// error codes
cmd.addErrorCode( 0, "Success" );
cmd.addErrorCode( 1, "Error" );
// options
cmd.setHelpOption( "h", "help", "Print this help page" );
cmd.defineOption ( "gui", "option only suitable when launching from gui", ArgvParser::NoOptionAttribute );
cmd.defineOptionAlternative ( "gui", "g" );
cmd.defineOption( "file", "Hw Description File . Default value: settings/CMTest2CBC.xml", ArgvParser::OptionRequiresValue /*| ArgvParser::OptionRequired*/ );
cmd.defineOptionAlternative( "file", "f" );
cmd.defineOption( "output", "Output Directory . Default value: Results/", ArgvParser::OptionRequiresValue /*| ArgvParser::OptionRequired*/ );
cmd.defineOptionAlternative( "output", "o" );
int result = cmd.parse ( argc, argv );
cmd.defineOption( "scan", "scan for noisy strips", ArgvParser::NoOptionAttribute );
cmd.defineOptionAlternative( "scan", "s" );
if ( result != ArgvParser::NoParserError )
{
LOG (INFO) << cmd.parseErrorDescription ( result );
exit ( 1 );
}
cmd.defineOption( "batch", "Run the application in batch mode", ArgvParser::NoOptionAttribute );
cmd.defineOptionAlternative( "batch", "b" );
bool isGui = ( cmd.foundOption ( "gui" ) ) ? true : false;
cmd.defineOption( "gui", "option only suitable when launching from gui", ArgvParser::NoOptionAttribute );
cmd.defineOptionAlternative( "gui", "g" );
// now query the parsing results
std::string cHWFile = ( cmd.foundOption ( "file" ) ) ? cmd.optionValue ( "file" ) : "settings/CMTest2CBC.xml";
std::string cDirectory = ( cmd.foundOption ( "output" ) ) ? cmd.optionValue ( "output" ) : "Results/";
cDirectory += "CMTest";
bool cScan = ( cmd.foundOption ( "scan" ) ) ? true : false;
bool batchMode = ( cmd.foundOption ( "batch" ) ) ? true : false;
int result = cmd.parse( argc, argv );
TApplication cApp ( "Root Application", &argc, argv );
if ( result != ArgvParser::NoParserError )
{
std::cout << cmd.parseErrorDescription( result );
exit( 1 );
}
bool isGui = ( cmd.foundOption( "gui" ) ) ? true : false;
if ( batchMode ) gROOT->SetBatch ( true );
else TQObject::Connect ( "TCanvas", "Closed()", "TApplication", &cApp, "Terminate()" );
// now query the parsing results
std::string cHWFile = ( cmd.foundOption( "file" ) ) ? cmd.optionValue( "file" ) : "settings/CMTest2CBC.xml";
std::string cDirectory = ( cmd.foundOption( "output" ) ) ? cmd.optionValue( "output" ) : "Results/";
cDirectory += "CMTest";
bool cScan = ( cmd.foundOption( "scan" ) ) ? true : false;
bool batchMode = ( cmd.foundOption( "batch" ) ) ? true : false;
std::stringstream outp;
CMTester cTester;
cTester.InitializeHw ( cHWFile, outp );
cTester.Initialize ();
cTester.InitializeSettings ( cHWFile, outp );
cTester.CreateResultDirectory ( cDirectory );
cTester.InitResultFile ( "CMTest" );
cTester.StartHttpServer ( 8082 );
LOG (INFO) << outp.str();
outp.str ("");
if ( !isGui ) cTester.ConfigureHw ( outp );
TApplication cApp( "Root Application", &argc, argv );
if ( batchMode ) gROOT->SetBatch( true );
else TQObject::Connect( "TCanvas", "Closed()", "TApplication", &cApp, "Terminate()" );
LOG (INFO) << outp.str();
outp.str ("");
CMTester cTester;
cTester.InitializeHw( cHWFile );
cTester.Initialize( );
cTester.InitializeSettings( cHWFile );
cTester.CreateResultDirectory( cDirectory );
cTester.InitResultFile( "CMTest" );
cTester.StartHttpServer( 8082 );
if ( !isGui ) cTester.ConfigureHw();
// Here comes our Part:
if ( cScan ) cTester.ScanNoiseChannels();
// Here comes our Part:
if ( cScan ) cTester.ScanNoiseChannels();
cTester.TakeData();
cTester.FinishRun();
cTester.SaveResults();
cTester.TakeData();
cTester.FinishRun();
cTester.SaveResults();
cTester.CloseResultFile();
cTester.Destroy();
if ( !batchMode ) cApp.Run();
if ( !batchMode ) cApp.Run();
return 0;
return 0;
}
......@@ -16,11 +16,17 @@ using namespace Ph2_System;
using namespace CommandLineProcessing;
INITIALIZE_EASYLOGGINGPP
int main ( int argc, char* argv[] )
{
//configure the logger
el::Configurations conf ("settings/logger.conf");
el::Loggers::reconfigureAllLoggers (conf);
ArgvParser cmd;
// init
cmd.setIntroductoryDescription ( "CMS Ph2_ACF Commissioning tool to perform the following procedures:\n-Timing / Latency scan\n-Threshold Scan\n-Stub Latency Scan" );
// error codes
......@@ -60,7 +66,7 @@ int main ( int argc, char* argv[] )
if ( result != ArgvParser::NoParserError )
{
std::cout << cmd.parseErrorDescription ( result );
LOG (INFO) << cmd.parseErrorDescription ( result );
exit ( 1 );
}
......@@ -94,13 +100,15 @@ int main ( int argc, char* argv[] )
else if ( cSignal ) cResultfile = "SignalScan";
else cResultfile = "Commissioning";
std::stringstream outp;
Tool cTool;
cTool.InitializeHw ( cHWFile );
cTool.InitializeSettings ( cHWFile );
cTool.InitializeHw ( cHWFile , outp);
cTool.InitializeSettings ( cHWFile, outp );
cTool.CreateResultDirectory ( cDirectory );
cTool.InitResultFile ( cResultfile );
cTool.StartHttpServer();
cTool.ConfigureHw();
cTool.ConfigureHw (outp);
LOG (INFO) << outp.str();
if ( cLatency || cStubLatency )
{
......@@ -124,9 +132,11 @@ int main ( int argc, char* argv[] )
else if ( cNoise )
{
outp.str ("");
PedeNoise cPedeNoise;
cPedeNoise.Inherit (&cTool);
cPedeNoise.ConfigureHw();
cPedeNoise.ConfigureHw (outp);
LOG (INFO) << outp.str();
cPedeNoise.Initialise(); // canvases etc. for fast calibration
cPedeNoise.measureNoise();
cPedeNoise.Validate();
......
......@@ -12,16 +12,20 @@ using namespace CommandLineProcessing;
//Class used to process events acquired by a parallel acquisition
INITIALIZE_EASYLOGGINGPP
void syntax ( int argc )
{
if ( argc > 4 ) std::cerr << RED << "ERROR: Syntax: calibrationtest VCth NEvents (HWDescriptionFile)" << std::endl;
else if ( argc < 3 ) std::cerr << RED << "ERROR: Syntax: calibrationtest VCth NEvents (HWDescriptionFile)" << std::endl;
else return;
}
//void syntax ( int argc )
//{
//if ( argc > 4 ) std::cerr << RED << "ERROR: Syntax: calibrationtest VCth NEvents (HWDescriptionFile)" << std::endl;
//else if ( argc < 3 ) std::cerr << RED << "ERROR: Syntax: calibrationtest VCth NEvents (HWDescriptionFile)" << std::endl;
//else return;
//}
int main ( int argc, char* argv[] )
{
//configure the logger
el::Configurations conf ("settings/logger.conf");
el::Loggers::reconfigureAllLoggers (conf);
int cVcth;
bool cRead;
......@@ -52,7 +56,7 @@ int main ( int argc, char* argv[] )
if ( result != ArgvParser::NoParserError )
{
std::cout << cmd.parseErrorDescription ( result );
LOG (ERROR) << cmd.parseErrorDescription ( result );
exit ( 1 );
}
......@@ -69,10 +73,15 @@ int main ( int argc, char* argv[] )
Timer t;
t.start();
cSystemController.InitializeHw ( cHWFile );
std::stringstream outp;
cSystemController.InitializeHw ( cHWFile, outp );
if (!cRead) cSystemController.ConfigureHw ( std::cout );
else std::cout << "Called with -r option, HW will not be configured!" << std::endl;
if (!cRead)
{
cSystemController.ConfigureHw (outp);
LOG (INFO) << outp.str();
}
else LOG (INFO) << "Called with -r option, HW will not be configured!" ;
t.stop();
t.show ( "Time to Initialize/configure the system: " );
......
......@@ -23,34 +23,39 @@ using namespace Ph2_System;
using namespace CommandLineProcessing;
using namespace std;
INITIALIZE_EASYLOGGINGPP
//Class used to process events acquired by a parallel acquisition
class AcqVisitor: public HwInterfaceVisitor
{
int cN;
public:
AcqVisitor()
{
cN = 0;
}
//void init(std::ofstream* pfSave, bool bText);
virtual void visit ( const Ph2_HwInterface::Event& pEvent )
{
cN++;
std::cout << ">>> Event #" << cN << std::endl;
std::cout << pEvent << std::endl;
}
};
void syntax ( int argc )
{
if ( argc > 4 ) std::cerr << RED << "ERROR: Syntax: calibrationtest VCth NEvents (HWDescriptionFile)" << std::endl;
else if ( argc < 3 ) std::cerr << RED << "ERROR: Syntax: calibrationtest VCth NEvents (HWDescriptionFile)" << std::endl;
else return;
}
//class AcqVisitor: public HwInterfaceVisitor
//{
//int cN;
//public:
//AcqVisitor()
//{
//cN = 0;
//}
////void init(std::ofstream* pfSave, bool bText);
//virtual void visit ( const Ph2_HwInterface::Event& pEvent )
//{
//cN++;
//std::cout << ">>> Event #" << cN << std::endl;
//std::cout << pEvent << std::endl;
//}
//};
//void syntax ( int argc )
//{
//if ( argc > 4 ) std::cerr << RED << "ERROR: Syntax: calibrationtest VCth NEvents (HWDescriptionFile)" << std::endl;
//else if ( argc < 3 ) std::cerr << RED << "ERROR: Syntax: calibrationtest VCth NEvents (HWDescriptionFile)" << std::endl;
//else return;
//}
int main ( int argc, char* argv[] )
{
//configure the logger
el::Configurations conf ("settings/logger.conf");
el::Loggers::reconfigureAllLoggers (conf);
int pEventsperVcth;
int cVcth;
......@@ -101,7 +106,7 @@ int main ( int argc, char* argv[] )
if ( result != ArgvParser::NoParserError )
{
std::cout << cmd.parseErrorDescription ( result );
LOG (INFO) << cmd.parseErrorDescription ( result );
exit ( 1 );
}
......@@ -129,10 +134,16 @@ int main ( int argc, char* argv[] )
t.start();
cSystemController.addFileHandler ( cOutputFile, 'w' );
cSystemController.InitializeHw ( cHWFile );
std::stringstream outp;
cSystemController.InitializeHw ( cHWFile, outp );
LOG (INFO) << outp.str();
outp.str ("");
if (!cmd.foundOption ("read") )
cSystemController.ConfigureHw ( std::cout, cmd.foundOption ( "ignoreI2c" ) );
{
cSystemController.ConfigureHw ( outp, cmd.foundOption ( "ignoreI2c" ) );
LOG (INFO) << outp.str();
}
t.stop();
t.show ( "Time to Initialize/configure the system: " );
......@@ -154,83 +165,86 @@ int main ( int argc, char* argv[] )
BeBoard* pBoard = cSystemController.fBoardVector.at ( 0 );
//if ( cmd.foundOption ( "parallel" ) )
//{
//uint32_t nbPacket = pBoard->getReg ( "pc_commands.CBC_DATA_PACKET_NUMBER" ), nbAcq = pEventsperVcth / ( nbPacket + 1 ) + ( pEventsperVcth % ( nbPacket + 1 ) != 0 ? 1 : 0 );
//std::cout << "Packet number=" << nbPacket << ", Nb events=" << pEventsperVcth << " -> Nb acquisition iterations=" << nbAcq << std::endl;
//AcqVisitor visitor;
//std::cout << "Press Enter to start the acquisition, press Enter again to stop it." << std::endl;
//std::cin.ignore();
//cSystemController.fBeBoardInterface->StartThread ( pBoard, nbAcq, &visitor );
//std::cin.ignore();
//cSystemController.fBeBoardInterface->StopThread ( pBoard );
//uint32_t nbPacket = pBoard->getReg ( "pc_commands.CBC_DATA_PACKET_NUMBER" ), nbAcq = pEventsperVcth / ( nbPacket + 1 ) + ( pEventsperVcth % ( nbPacket + 1 ) != 0 ? 1 : 0 );
//std::cout << "Packet number=" << nbPacket << ", Nb events=" << pEventsperVcth << " -> Nb acquisition iterations=" << nbAcq << std::endl;
//AcqVisitor visitor;
//std::cout << "Press Enter to start the acquisition, press Enter again to stop it." << std::endl;
//std::cin.ignore();
//cSystemController.fBeBoardInterface->StartThread ( pBoard, nbAcq, &visitor );
//std::cin.ignore();
//cSystemController.fBeBoardInterface->StopThread ( pBoard );
//}
//else
//{
t.start();
// make event counter start at 1 as does the L1A counter
uint32_t cN = 1;
uint32_t cNthAcq = 0;
t.start();
// make event counter start at 1 as does the L1A counter
uint32_t cN = 1;
uint32_t cNthAcq = 0;
if (!cmd.foundOption ( "read") )
cSystemController.fBeBoardInterface->Start ( pBoard );
if (!cmd.foundOption ( "read") )
cSystemController.fBeBoardInterface->Start ( pBoard );
Counter cCbcCounter;
pBoard->accept ( cCbcCounter );
uint32_t uFeMask = (1 << cCbcCounter.getNFe() ) - 1;
char arrSize[4];
Data data;
ParamSet* pPSet = nullptr;
if (cmd.foundOption ( "condition") )
{
pPSet = new ParamSet (cmd.optionValue ("condition") );
TrackerEvent::setI2CValuesForConditionData (pBoard, pPSet);
}
Counter cCbcCounter;
pBoard->accept ( cCbcCounter );
uint32_t uFeMask = (1 << cCbcCounter.getNFe() ) - 1;
char arrSize[4];
Data data;
ParamSet* pPSet = nullptr;
const std::vector<Event*>* pEvents ;
if (cmd.foundOption ( "condition") )
while ( cN <= pEventsperVcth )
{
if (cmd.foundOption ( "read") )
{
pPSet = new ParamSet (cmd.optionValue ("condition") );
TrackerEvent::setI2CValuesForConditionData (pBoard, pPSet);
FileHandler fFile (cmd.optionValue ("read"), 'r');
data.Set ( pBoard, fFile.readFile(), pEventsperVcth, false);
pEvents = &data.GetEvents ( pBoard);
}
else
{
uint32_t cPacketSize = cSystemController.fBeBoardInterface->ReadData ( pBoard, false );
const std::vector<Event*>* pEvents ;
pEvents = &cSystemController.GetEvents ( pBoard );
while ( cN <= pEventsperVcth )
{
if (cmd.foundOption ( "read") )
{
FileHandler fFile (cmd.optionValue ("read"), 'r');
data.Set ( pBoard, fFile.readFile(), pEventsperVcth, false);
pEvents = &data.GetEvents ( pBoard);
}
else
{
uint32_t cPacketSize = cSystemController.fBeBoardInterface->ReadData ( pBoard, false );
if ( cN + cPacketSize > pEventsperVcth )
cSystemController.fBeBoardInterface->Stop ( pBoard );
}
pEvents = &cSystemController.GetEvents ( pBoard );
if ( cN + cPacketSize > pEventsperVcth )
cSystemController.fBeBoardInterface->Stop ( pBoard );
}
for ( auto& ev : *pEvents )
{
LOG (INFO) << ">>> Event #" << cN++ ;
outp.str ("");
outp << *ev;
LOG (INFO) << outp.str();
for ( auto& ev : *pEvents )
if (filNewDaq.is_open() )
{
std::cout << ">>> Event #" << cN++ << std::endl;
std::cout << *ev << std::endl;
if (filNewDaq.is_open() )
{
TrackerEvent evtTracker (ev, pBoard->getNCbcDataSize(), uFeMask, cCbcCounter.getCbcMask(), cmd.foundOption ("read"), pPSet );
evtTracker.fillArrayWithSize (arrSize);
filNewDaq.write (arrSize, 4);
filNewDaq.write (evtTracker.getData(), evtTracker.getDaqSize() );
filNewDaq.flush();
}
TrackerEvent evtTracker (ev, pBoard->getNCbcDataSize(), uFeMask, cCbcCounter.getCbcMask(), cmd.foundOption ("read"), pPSet );
evtTracker.fillArrayWithSize (arrSize);
filNewDaq.write (arrSize, 4);
filNewDaq.write (evtTracker.getData(), evtTracker.getDaqSize() );
filNewDaq.flush();
}
cNthAcq++;
}
t.stop();
t.show ( "Time to take data:" );
delete pPSet;
cNthAcq++;
}
t.stop();
t.show ( "Time to take data:" );
delete pPSet;
//}
if (filNewDaq.is_open() )
filNewDaq.close();
cSystemController.Destroy();
}
......@@ -23,173 +23,210 @@ using namespace Ph2_System;
using namespace CommandLineProcessing;
using namespace std;
INITIALIZE_EASYLOGGINGPP
//Class used to process events acquired by a parallel acquisition
class AcqVisitor: public HwInterfaceVisitor
{
int cN;
int cN;
public:
AcqVisitor() {
cN = 0;
}
//void init(std::ofstream* pfSave, bool bText);
virtual void visit( const Ph2_HwInterface::Event& pEvent ) {
cN++;
std::cout << ">>> Event #" << cN << std::endl;
std::cout << pEvent << std::endl;
}
AcqVisitor()
{
cN = 0;
}
//void init(std::ofstream* pfSave, bool bText);
virtual void visit ( const Ph2_HwInterface::Event& pEvent )
{
cN++;
//use stringstream here for event?
LOG (INFO) << ">>> Event #" << cN ;
LOG (INFO) << pEvent ;
}
};
void syntax( int argc )
{
if ( argc > 4 ) std::cerr << RED << "ERROR: Syntax: calibrationtest VCth NEvents (HWDescriptionFile)" << std::endl;
else if ( argc < 3 ) std::cerr << RED << "ERROR: Syntax: calibrationtest VCth NEvents (HWDescriptionFile)" << std::endl;
else return;
}
//void syntax ( int argc )
//{
//if ( argc > 4 ) std::cerr << RED << "ERROR: Syntax: calibrationtest VCth NEvents (HWDescriptionFile)" << std::endl;
//else if ( argc < 3 ) std::cerr << RED << "ERROR: Syntax: calibrationtest VCth NEvents (HWDescriptionFile)" << std::endl;
//else return;
//}
void verifyImageName( const string& strImage, const vector<string>& lstNames){
if (lstNames.empty()){
if (strImage.compare("1")!=0 && strImage.compare("2")!=0){
cout<< "Error, invalid image name, should be 1 (golden) or 2 (user)"<<endl;
exit(1);
}
} else {
bool bFound=false;
for (int iName=0; iName<lstNames.size(); iName++){
if (!strImage.compare(lstNames[iName])){
bFound=true;
break;
}// else cout<<strImage<<"!="<<lstNames[iName]<<endl;
}
if (!bFound){