Commit 2e4d83d6 authored by Georg Auzinger's avatar Georg Auzinger
Browse files

first round of degubbing, fixed an important bug in systemcontroller related to file handler

parent fd6ad38d
......@@ -7,6 +7,8 @@ latex
html
html/
latex/
logs/
logs/*
*.bin
*.raw
Results/
......
......@@ -6,7 +6,7 @@
#include <vector>
#include <stdint.h>
#include <iostream>
#include "../Utils/easylogging++"
#include "../Utils/easylogging++.h"
typedef std::map<std::string, uint32_t> RegMap;
......
......@@ -78,7 +78,7 @@ namespace Ph2_HwDescription {
}
else
{
LOG (IFNO) << "Error:The BeBoard: " << +fBeId
LOG (INFO) << "Error:The BeBoard: " << +fBeId
<< " doesn't have the module " << +pModuleId ;
return false;
}
......
......@@ -87,7 +87,7 @@ namespace Ph2_HwInterface {
//LOG(INFO) << "FMC2 present : " << ReadReg ( "status.fmc2_present" ) ;
uint32_t cVersionMajor = ReadReg ( "firm_id.firmware_major" );
uint32_t cVersionMinor = ReadReg ( "firm_id.firmware_minor" );
LOG (INFO) << "FW version : " << cVersionMajor << "." << cVersionMinor << "." << ReadReg ( "firm_id.firmware_build" ) ;
LOG (INFO) << "FW version : " << cVersionMajor << "." << cVersionMinor << "." << std::to_string (ReadReg ( "firm_id.firmware_build" ) ) ;
uhal::ValWord<uint32_t> cBoardType = ReadReg ( "board_id" );
......
......@@ -78,11 +78,11 @@ namespace Ph2_HwInterface {
uint32_t GlibFWInterface::getBoardInfo()
{
LOG (INFO) << "FMC1 present : " << ReadReg ( "status.fmc1_present" ) ;
LOG (INFO) << "FMC2 present : " << ReadReg ( "status.fmc2_present" ) ;
LOG (INFO) << "FMC1 present : " << std::to_string (ReadReg ( "status.fmc1_present" ) ) ;
LOG (INFO) << "FMC2 present : " << std::to_string (ReadReg ( "status.fmc2_present" ) ) ;
uint32_t cVersionMajor = ReadReg ( "firm_id.firmware_major" );
uint32_t cVersionMinor = ReadReg ( "firm_id.firmware_minor" );
LOG (INFO) << "FW version : " << cVersionMajor << "." << cVersionMinor << "." << ReadReg ( "firm_id.firmware_build" ) ;
LOG (INFO) << "FW version : " << cVersionMajor << "." << cVersionMinor << "." << std::to_string (ReadReg ( "firm_id.firmware_build" ) ) ;
uhal::ValWord<uint32_t> cBoardType = ReadReg ( "board_id" );
......
......@@ -20,6 +20,7 @@
#include "BeBoardFWInterface.h"
#include "../HWDescription/Module.h"
#include "../Utils/Visitor.h"
#include "../Utils/easylogging++.h"
using namespace Ph2_HwDescription;
......
......@@ -90,7 +90,7 @@ namespace Ph2_HwInterface {
uint32_t cVersionMajor, cVersionMinor;
cVersionMajor = ReadReg ( "user_stat.version.ver_major" );
cVersionMinor = ReadReg ( "user_stat.version.ver_minor" );
LOG (INFO) << "FW version : " << cVersionMajor << "." << cVersionMinor << "." << ReadReg ( "user_stat.version.ver_build" ) ;
LOG (INFO) << "FW version : " << cVersionMajor << "." << cVersionMinor << "." << std::to_string (ReadReg ( "user_stat.version.ver_build" ) ) ;
uhal::ValWord<uint32_t> cBoardType = ReadReg ( "sys_regs.board_id" );
......
......@@ -90,7 +90,7 @@ namespace Ph2_HwInterface {
uint32_t cVersionMajor, cVersionMinor;
cVersionMajor = ReadReg ( "user_stat.version.ver_major" );
cVersionMinor = ReadReg ( "user_stat.version.ver_minor" );
LOG (INFO) << "FW version : " << cVersionMajor << "." << cVersionMinor << "." << ReadReg ( "user_stat.version.ver_build" ) ;
LOG (INFO) << "FW version : " << cVersionMajor << "." << cVersionMinor << "." << std::to_string (ReadReg ( "user_stat.version.ver_build" ) ) ;
uhal::ValWord<uint32_t> cBoardType = ReadReg ( "sys_regs.board_id" );
......
......@@ -227,10 +227,12 @@ namespace Ph2_System {
for ( pugi::xml_node nSettings = doc.child ( "Settings" ); nSettings; nSettings = nSettings.next_sibling() )
{
os << std::endl;
for ( pugi::xml_node nSetting = nSettings.child ( "Setting" ); nSetting; nSetting = nSetting.next_sibling() )
{
pSettingsMap[nSetting.attribute ( "name" ).value()] = convertAnyInt ( nSetting.first_child().value() );
os << RED << "Setting" << RESET << " --" << BOLDCYAN << nSetting.attribute ( "name" ).value() << RESET << ":" << BOLDYELLOW << convertAnyInt ( nSetting.first_child().value() ) << RESET << std:: endl;
os << RED << "Setting" << RESET << " --" << BOLDCYAN << nSetting.attribute ( "name" ).value() << RESET << ":" << BOLDYELLOW << convertAnyInt ( nSetting.first_child().value() ) << RESET << std:: endl;
}
}
}
......
......@@ -17,7 +17,8 @@ using namespace Ph2_HwInterface;
namespace Ph2_System {
SystemController::SystemController()
: fFileHandler (nullptr)
: fFileHandler (nullptr),
fWriteHandlerEnabled (false)
{
}
......@@ -67,7 +68,7 @@ namespace Ph2_System {
void SystemController::InitializeHw ( const std::string& pFilename, std::ostream& os )
{
this->fParser.parseHW (pFilename, fBeBoardFWMap, fBoardVector, os);
this->fParser.parseHW (pFilename, fBeBoardFWMap, fBoardVector, os );
fBeBoardInterface = new BeBoardInterface ( fBeBoardFWMap );
fCbcInterface = new CbcInterface ( fBeBoardFWMap );
......@@ -78,7 +79,7 @@ namespace Ph2_System {
void SystemController::InitializeSettings ( const std::string& pFilename, std::ostream& os )
{
this->fParser.parseSettings (pFilename, fSettingsMap, os);
this->fParser.parseSettings (pFilename, fSettingsMap, os );
}
void SystemController::ConfigureHw ( std::ostream& os , bool bIgnoreI2c )
......
......@@ -134,17 +134,17 @@ namespace Ph2_System {
* \param pFilename : HW Description file
*\param os : ostream to dump output
*/
void InitializeHw ( const std::string& pFilename, std::ostream& os );
void InitializeHw ( const std::string& pFilename, std::ostream& os = std::cout );
/*!
* \brief Initialize the settings
* \param pFilename : settings file
*\param os : ostream to dump output
*/
void InitializeSettings ( const std::string& pFilename, std::ostream& os );
void InitializeSettings ( const std::string& pFilename, std::ostream& os = std::cout );
/*!
* \brief Configure the Hardware with XML file indicated values
*/
void ConfigureHw ( std::ostream& os , bool bIgnoreI2c = false );
void ConfigureHw ( std::ostream& os = std::cout , bool bIgnoreI2c = false );
/*!
* \brief Run a DAQ
* \param pBeBoard
......
<?xml version='1.0' encoding='utf-8'?>
<HwDescription>
<BeBoard Id="0" boardType="GLIB">
<!-- <connection id="board" uri="ipbusudp-2.0://192.168.000.163:50001" address_table="file://settings/address_table_2CBC.xml" /> -->
<connection id="board" uri="chtcp-2.0://cmsuptracker002:10203?target=192.168.0.175:50001" address_table="file://settings/address_table_2CBC.xml" />
<connection id="board" uri="ipbusudp-2.0://192.168.000.163:50001" address_table="file://settings/address_table_2CBC.xml" />
<!--<connection id="board" uri="chtcp-2.0://cmsuptracker002:10203?target=192.168.0.175:50001" address_table="file://settings/address_table_2CBC.xml" />-->
<FW_Version NCbcDataSize="4" />
<Module FeId="0" FMCId="0" ModuleId="0" Status="1">
<Global_CBC_Register name="VCth"> 0x76 </Global_CBC_Register>
......@@ -12,9 +12,9 @@
<!--<Global_CBC_Register name="TestPulsePot">0xE0</Global_CBC_Register>-->
<!--<Global_CBC_Register name="SelTestPulseDel&ChanGroup">0x00</Global_CBC_Register>-->
<CBC_Files path="./Results/Calibration_Electron_23-05-16_17:45/" />
<CBC Id="0" configfile="FE0CBC0.txt" />
<CBC Id="1" configfile="FE0CBC1.txt" />
<CBC_Files path="./settings/" />
<CBC Id="0" configfile="Cbc_default_hole.txt" />
<CBC Id="1" configfile="Cbc_default_hole.txt" />
<!--<CBC_Files path="./Results/Calibration_Hole_27-04-16_17:55/" />-->
<!--<CBC Id="0" configfile="FE0CBC0.txt" />-->
......
*
!*.*
\ No newline at end of file
*.o
systemtest
calibrate
hybridtest
configure
datatest
cmtest
commission
fpgaconfig
......@@ -7,7 +7,6 @@
#include "../HWDescription/Definition.h"
#include "../tools/Calibration.h"
#include "../tools/PedeNoise.h"
#include "../tools/OldCalibration.h"
#include "../Utils/argvparser.h"
#include "TROOT.h"
#include "TApplication.h"
......@@ -21,9 +20,14 @@ 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
......@@ -60,7 +64,7 @@ int main ( int argc, char* argv[] )
if ( result != ArgvParser::NoParserError )
{
std::cout << cmd.parseErrorDescription ( result );
LOG (ERROR) << cmd.parseErrorDescription ( result );
exit ( 1 );
}
......@@ -85,12 +89,15 @@ int main ( int argc, char* argv[] )
//create a genereic Tool Object, I can then construct all other tools from that using the Inherit() method
//this tool stays on the stack and lives until main finishes - all other tools will update the HWStructure from cTool
Tool cTool;
cTool.InitializeHw ( cHWFile );
cTool.InitializeSettings ( cHWFile );
std::stringstream outp;
cTool.InitializeHw ( cHWFile, outp );
cTool.InitializeSettings ( cHWFile, outp );
cTool.CreateResultDirectory ( cDirectory );
cTool.InitResultFile ( "CalibrationResults" );
cTool.StartHttpServer();
cTool.ConfigureHw();
cTool.ConfigureHw (outp);
LOG (INFO) << outp.str();
outp.clear();
//if ( !cOld )
//{
t.start();
......@@ -116,7 +123,9 @@ int main ( int argc, char* argv[] )
//tool provides an Inherit(Tool* pTool) for this purpose
PedeNoise cPedeNoise;
cPedeNoise.Inherit (&cTool);
cPedeNoise.ConfigureHw();
cPedeNoise.ConfigureHw (outp);
LOG (INFO) << outp.str();
outp.clear();
cPedeNoise.Initialise(); // canvases etc. for fast calibration
cPedeNoise.measureNoise();
cPedeNoise.Validate();
......@@ -129,27 +138,6 @@ int main ( int argc, char* argv[] )
cTool.SaveResults();
cTool.CloseResultFile();
cTool.Destroy();
//introduce a separate Destroy method for tool? And delete objects there?
//}
//else
//{
//t.start();
//OldCalibration cCalibration( cCalibrateTGrp );
//cCalibration.InitializeHw( cHWFile );
//cCalibration.InitializeSettings( cHWFile );
//cCalibration.CreateResultDirectory( cDirectory );
//cCalibration.InitResultFile( "CalibrationResults" );
//cCalibration.StartHttpServer();
//cCalibration.Initialise( ); // canvases etc. for fast calibration
//if ( cVplus ) cCalibration.ScanVplus();
//cCalibration.ScanOffset();
//cCalibration.SaveResults();
//t.stop();
//t.show( "Time to Calibrate the system: " );
//}
if ( !batchMode ) cApp.Run();
......
......@@ -7,59 +7,71 @@
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 system test application" );
// 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/HWDescription_2CBC.xml", ArgvParser::OptionRequiresValue /*| ArgvParser::OptionRequired*/ );
cmd.defineOptionAlternative ( "file", "f" );
ArgvParser cmd;
cmd.defineOption ( "configure", "Configure HW", ArgvParser::NoOptionAttribute );
cmd.defineOptionAlternative ( "configure", "c" );
// init
cmd.setIntroductoryDescription( "CMS Ph2_ACF system test application" );
// error codes
cmd.addErrorCode( 0, "Success" );
cmd.addErrorCode( 1, "Error" );
// options
cmd.setHelpOption( "h", "help", "Print this help page" );
int result = cmd.parse ( argc, argv );
cmd.defineOption( "file", "Hw Description File . Default value: settings/HWDescription_2CBC.xml", ArgvParser::OptionRequiresValue /*| ArgvParser::OptionRequired*/ );
cmd.defineOptionAlternative( "file", "f" );
if ( result != ArgvParser::NoParserError )
{
std::cout << cmd.parseErrorDescription ( result );
exit ( 1 );
}
cmd.defineOption( "configure", "Configure HW", ArgvParser::NoOptionAttribute );
cmd.defineOptionAlternative( "configure", "c" );
// now query the parsing results
std::string cHWFile = ( cmd.foundOption ( "file" ) ) ? cmd.optionValue ( "file" ) : "settings/HWDescription_2CBC.xml";
bool cConfigure = ( cmd.foundOption ( "configure" ) ) ? true : false;
int result = cmd.parse( argc, argv );
if ( result != ArgvParser::NoParserError )
{
std::cout << cmd.parseErrorDescription( result );
exit( 1 );
}
// now query the parsing results
std::string cHWFile = ( cmd.foundOption( "file" ) ) ? cmd.optionValue( "file" ) : "settings/HWDescription_2CBC.xml";
bool cConfigure = ( cmd.foundOption( "configure" ) ) ? true : false;
std::stringstream outp;
SystemController cSystemController;
cSystemController.InitializeHw ( cHWFile, outp );
cSystemController.InitializeSettings ( cHWFile, outp );
LOG (INFO) << outp.str();
outp.clear();
SystemController cSystemController;
cSystemController.InitializeHw( cHWFile );
cSystemController.InitializeSettings( cHWFile );
if ( cConfigure ) cSystemController.ConfigureHw();
if ( cConfigure ) cSystemController.ConfigureHw (outp);
LOG (INFO) << outp.str();
//Timer t;
//t.start();
//for(uint8_t cVcth = 0x00; cVcth < 0xFF; cVcth++)
//{
//std::vector<std::pair<std::string, uint8_t>> cRegVec;
//cRegVec.push_back({"VCth", cVcth});
//cRegVec.push_back({"TriggerLatency", 255 - cVcth});
//std::cout << "Writing Vcth " << +cVcth << " Trigger Lat:" << 255-cVcth << std::endl;
//cSystemController.fCbcInterface->WriteBroadcastMultReg(cSystemController.fBoardVector.at(0)->fModuleVector.at(0), cRegVec);
//CbcRegReader cReader(cSystemController.fCbcInterface, "TriggerLatency");
//cSystemController.accept(cReader);
//std::vector<std::pair<std::string, uint8_t>> cRegVec;
//cRegVec.push_back({"VCth", cVcth});
//cRegVec.push_back({"TriggerLatency", 255 - cVcth});
//std::cout << "Writing Vcth " << +cVcth << " Trigger Lat:" << 255-cVcth << std::endl;
//cSystemController.fCbcInterface->WriteBroadcastMultReg(cSystemController.fBoardVector.at(0)->fModuleVector.at(0), cRegVec);
//CbcRegReader cReader(cSystemController.fCbcInterface, "TriggerLatency");
//cSystemController.accept(cReader);
//}
//t.stop();
//t.show("Time to loop VCth from 0 to ff with broadcast:");
std::cout << "*** End of the System test ***" << std::endl;
LOG (INFO) << "*** End of the System test ***" ;
cSystemController.Destroy();
return 0;
return 0;
}
......@@ -24,6 +24,7 @@
#include "TCanvas.h"
#include "../Utils/ConsoleColor.h"
#include "../Utils/Utilities.h"
#include "../Utils/easylogging++.h"
/*!
......@@ -33,7 +34,7 @@
struct Channel
{
Channel( uint8_t pBeId, uint8_t pFeId, uint8_t pCbcId, uint8_t pChannelId );
Channel ( uint8_t pBeId, uint8_t pFeId, uint8_t pCbcId, uint8_t pChannelId );
~Channel();
// members
......@@ -74,32 +75,32 @@ struct Channel
* \brief set the Offset of the Channel object: this is not propagated to HW
* \param pOffset: set the fOffset member to pOffset
*/
void setOffset( uint8_t pOffset );
void setOffset ( uint8_t pOffset );
/*!
* \brief Initialize the Histogram and Fit for the Channel
* \param pParameter: the current parameter that is being varied for storing in file
* \param pValue: the value of pParameter
*/
void initializeHist( uint8_t pValue, TString pParameter );
void initializeHist ( uint8_t pValue, TString pParameter );
/*!
*brief Initialize the TGraph to store the PulseShapeMeasurement
*param pTitle: the Title for the TGraph
*/
void initializePulse( TString pTitle );
void initializePulse ( TString pTitle );
/*!
*\ brief: set a point on the Test Pulse Graph
*\ param x: xCoordinate
*\ param y: yCoordinate
*/
void setPulsePoint( double x, double y )
void setPulsePoint ( double x, double y )
{
fPulse->SetPoint( fPulse->GetN(), x, y );
fPulse->SetPoint ( fPulse->GetN(), x, y );
}
/*!
* \brief fill the histogram
* \param pVcth: the bin at which to fill the histogram (normally Vcth value)
*/
void fillHist( uint8_t pVcth );
void fillHist ( uint8_t pVcth );
/*!
* \brief fit the SCurve Histogram with the Fit object
......@@ -109,7 +110,7 @@ struct Channel
* \param pValue: the value of pParameter
*\param pResutlfile: pointer to the ROOT file where the results are supposed to be stored
*/
void fitHist( uint32_t pEventsperVcth, bool pHole, uint8_t pValue, TString pParameter, TFile* pResultfile );
void fitHist ( uint32_t pEventsperVcth, bool pHole, uint8_t pValue, TString pParameter, TFile* pResultfile );
/*!
* \brief differentiate the SCurve Histogram with the Derivative object
......@@ -119,7 +120,7 @@ struct Channel
* \param pValue: the value of pParameter
*\param pResutlfile: pointer to the ROOT file where the results are supposed to be stored
*/
void differentiateHist( uint32_t pEventsperVcth, bool pHole, uint8_t pValue, TString pParameter, TFile* pResultfile );
void differentiateHist ( uint32_t pEventsperVcth, bool pHole, uint8_t pValue, TString pParameter, TFile* pResultfile );
/*!
* \brief reset the Histogram and Fit objects
......@@ -129,7 +130,7 @@ struct Channel
struct TestGroup
{
TestGroup( uint8_t pBeId, uint8_t pFeId, uint8_t pCbcId, uint8_t pGroupId );
TestGroup ( uint8_t pBeId, uint8_t pFeId, uint8_t pCbcId, uint8_t pGroupId );
uint8_t fBeId;
uint8_t fFeId;
......@@ -140,27 +141,27 @@ struct TestGroup
struct TestGroupGraph
{
TestGroupGraph();
TestGroupGraph( uint8_t pBeId, uint8_t pFeId, uint8_t pCbcId, uint8_t pGroupId );
void FillVplusVcthGraph( uint8_t& pVplus, double pPedestal, double pNoise );
TestGroupGraph ( uint8_t pBeId, uint8_t pFeId, uint8_t pCbcId, uint8_t pGroupId );
void FillVplusVcthGraph ( uint8_t& pVplus, double pPedestal, double pNoise );
TGraphErrors* fVplusVcthGraph;
};
struct TestGroupComparer
{
bool operator()( const TestGroup& g1, const TestGroup& g2 ) const
bool operator() ( const TestGroup& g1, const TestGroup& g2 ) const
{
if ( g1.fBeId == g2.fBeId )
{
if ( g1.fFeId == g2.fFeId )
{
if ( g1.fCbcId == g2.fCbcId )
return g1.fGroupId < g2.fGroupId;
else return g1.fCbcId < g2.fCbcId;
}
else return g1.fFeId < g2.fFeId;
}
else return g1.fBeId < g2.fBeId;
if ( g1.fBeId == g2.fBeId )
{
if ( g1.fFeId == g2.fFeId )
{
if ( g1.fCbcId == g2.fCbcId )
return g1.fGroupId < g2.fGroupId;
else return g1.fCbcId < g2.fCbcId;
}
else return g1.fFeId < g2.fFeId;
}
else return g1.fBeId < g2.fBeId;
}
};
......
......@@ -606,7 +606,9 @@ void HybridTester::TestRegisters()
start_time = time (0);
char* stop = ctime (&start_time);
LOG (INFO) << "stop: " << stop ;
ConfigureHw();
std::stringstream ss;
ConfigureHw (ss);
LOG (INFO) << ss.str();
}
void HybridTester::DisplayGroupsContent (std::array<std::vector<std::array<int, 5>>, 8> pShortedGroupsArray)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment