Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Irene Mateos Dominguez
Ph2_ACF
Commits
ae6f7722
Commit
ae6f7722
authored
Oct 14, 2016
by
Georg Auzinger
Browse files
added easylogging to AMC13 classes
parent
318125ac
Changes
6
Hide whitespace changes
Inline
Side-by-side
AMC13/Amc13Controller.cc
View file @
ae6f7722
...
...
@@ -12,32 +12,32 @@ Amc13Controller::~Amc13Controller()
delete
fAmc13Interface
;
}
void
Amc13Controller
::
InitializeAmc13
(
const
std
::
string
&
pFilename
,
std
::
ostream
&
os
)
void
Amc13Controller
::
InitializeAmc13
(
const
std
::
string
&
pFilename
,
std
::
ostream
&
os
)
{
if
(
pFilename
.
find
(
".xml"
)
!=
std
::
string
::
npos
)
parseAmc13xml
(
pFilename
,
os
);
else
std
::
cerr
<<
"Could not parse settings file "
<<
pFilename
<<
" - it is not .xml!"
<<
std
::
endl
;
if
(
pFilename
.
find
(
".xml"
)
!=
std
::
string
::
npos
)
parseAmc13xml
(
pFilename
,
os
);
else
LOG
(
ERROR
)
<<
"Could not parse settings file "
<<
pFilename
<<
" - it is not .xml!"
;
}
void
Amc13Controller
::
ConfigureAmc13
(
std
::
ostream
&
os
)
void
Amc13Controller
::
ConfigureAmc13
(
std
::
ostream
&
os
)
{
os
<<
BOLDGREEN
<<
"Configuring Amc13!"
<<
RESET
<<
std
::
endl
;
// no need to pass the Amc13 memory description as there is only 1, I just keep it for reference and update accordingly!
fAmc13Interface
->
ConfigureAmc13
();
}
void
Amc13Controller
::
HaltAmc13
(
std
::
ostream
&
os
)
void
Amc13Controller
::
HaltAmc13
(
std
::
ostream
&
os
)
{
os
<<
BOLDGREEN
<<
"Halting Amc13!"
<<
RESET
<<
std
::
endl
;
fAmc13Interface
->
HaltAMC13
();
}
void
Amc13Controller
::
parseAmc13xml
(
const
std
::
string
&
pFilename
,
std
::
ostream
&
os
)
void
Amc13Controller
::
parseAmc13xml
(
const
std
::
string
&
pFilename
,
std
::
ostream
&
os
)
{
pugi
::
xml_document
doc
;
int
i
,
j
;
pugi
::
xml_parse_result
result
=
doc
.
load_file
(
pFilename
.
c_str
()
);
pugi
::
xml_parse_result
result
=
doc
.
load_file
(
pFilename
.
c_str
()
);
if
(
!
result
)
{
...
...
@@ -47,122 +47,142 @@ void Amc13Controller::parseAmc13xml(const std::string& pFilename, std::ostream&
}
os
<<
"
\n
"
;
for
(
i
=
0
;
i
<
80
;
i
++
)
os
<<
"*"
;
os
<<
"
\n
"
;
for
(
j
=
0
;
j
<
40
;
j
++
)
os
<<
" "
;
os
<<
BOLDRED
<<
"AMC13 Settings "
<<
RESET
<<
std
::
endl
;
for
(
i
=
0
;
i
<
80
;
i
++
)
os
<<
"*"
;
os
<<
"
\n
"
;
// no clue why I have to loop but that's what it is!
for
(
pugi
::
xml_node
cAmc13node
=
doc
.
child
(
"HwDescription"
).
child
(
"AMC13"
);
cAmc13node
;
cAmc13node
=
cAmc13node
.
next_sibling
(
"AMC13"
)
)
for
(
pugi
::
xml_node
cAmc13node
=
doc
.
child
(
"HwDescription"
).
child
(
"AMC13"
);
cAmc13node
;
cAmc13node
=
cAmc13node
.
next_sibling
(
"AMC13"
)
)
{
os
<<
BOLDCYAN
<<
cAmc13node
.
name
()
<<
RESET
<<
std
::
endl
;
// now create a new AMC13 Description Object
if
(
fAmc13
!=
nullptr
)
delete
fAmc13
;
fAmc13
=
new
Amc13Description
();
std
::
string
cUri1
,
cUri2
;
std
::
string
cAddressT1
,
cAddressT2
;
// finally find the connection nodes and construct the proper Amc13FWInterface
for
(
pugi
::
xml_node
Amc13Connection
=
cAmc13node
.
child
(
"connection"
);
Amc13Connection
;
Amc13Connection
=
Amc13Connection
.
next_sibling
(
"connection"
)
)
for
(
pugi
::
xml_node
Amc13Connection
=
cAmc13node
.
child
(
"connection"
);
Amc13Connection
;
Amc13Connection
=
Amc13Connection
.
next_sibling
(
"connection"
)
)
{
if
(
std
::
string
(
Amc13Connection
.
attribute
(
"id"
).
value
())
==
"T1"
)
if
(
std
::
string
(
Amc13Connection
.
attribute
(
"id"
).
value
()
)
==
"T1"
)
{
cUri1
=
std
::
string
(
Amc13Connection
.
attribute
(
"uri"
).
value
());
cAddressT1
=
std
::
string
(
Amc13Connection
.
attribute
(
"address_table"
).
value
());
cUri1
=
std
::
string
(
Amc13Connection
.
attribute
(
"uri"
).
value
()
);
cAddressT1
=
std
::
string
(
Amc13Connection
.
attribute
(
"address_table"
).
value
()
);
}
else
if
(
std
::
string
(
Amc13Connection
.
attribute
(
"id"
).
value
())
==
"T2"
)
else
if
(
std
::
string
(
Amc13Connection
.
attribute
(
"id"
).
value
()
)
==
"T2"
)
{
cUri2
=
std
::
string
(
Amc13Connection
.
attribute
(
"uri"
).
value
());
cAddressT2
=
std
::
string
(
Amc13Connection
.
attribute
(
"address_table"
).
value
());
cUri2
=
std
::
string
(
Amc13Connection
.
attribute
(
"uri"
).
value
()
);
cAddressT2
=
std
::
string
(
Amc13Connection
.
attribute
(
"address_table"
).
value
()
);
}
os
<<
BOLDBLUE
<<
"|"
<<
"----"
<<
"Board Id: "
<<
BOLDYELLOW
<<
Amc13Connection
.
attribute
(
"id"
).
value
()
<<
BOLDBLUE
<<
" URI: "
<<
BOLDYELLOW
<<
Amc13Connection
.
attribute
(
"uri"
).
value
()
<<
BOLDBLUE
<<
" Address Table: "
<<
BOLDYELLOW
<<
Amc13Connection
.
attribute
(
"address_table"
).
value
()
<<
RESET
<<
std
::
endl
;
os
<<
BOLDBLUE
<<
"|"
<<
"----"
<<
"Board Id: "
<<
BOLDYELLOW
<<
Amc13Connection
.
attribute
(
"id"
).
value
()
<<
BOLDBLUE
<<
" URI: "
<<
BOLDYELLOW
<<
Amc13Connection
.
attribute
(
"uri"
).
value
()
<<
BOLDBLUE
<<
" Address Table: "
<<
BOLDYELLOW
<<
Amc13Connection
.
attribute
(
"address_table"
).
value
()
<<
RESET
<<
std
::
endl
;
}
// here loop over the Register nodes and add them to the AMC13Description object!
for
(
pugi
::
xml_node
Amc13RegNode
=
cAmc13node
.
child
(
"Register"
);
Amc13RegNode
;
Amc13RegNode
=
Amc13RegNode
.
next_sibling
(
"Register"
)
)
for
(
pugi
::
xml_node
Amc13RegNode
=
cAmc13node
.
child
(
"Register"
);
Amc13RegNode
;
Amc13RegNode
=
Amc13RegNode
.
next_sibling
(
"Register"
)
)
{
std
::
string
regname
=
std
::
string
(
Amc13RegNode
.
attribute
(
"name"
).
value
());
std
::
string
regname
=
std
::
string
(
Amc13RegNode
.
attribute
(
"name"
).
value
()
);
os
<<
BOLDCYAN
<<
"|"
<<
"----"
<<
Amc13RegNode
.
name
()
<<
" "
<<
Amc13RegNode
.
attribute
(
"tounge"
).
name
()
<<
" : "
<<
Amc13RegNode
.
attribute
(
"tounge"
).
value
()
<<
" - name: "
<<
regname
<<
" "
<<
BOLDRED
<<
convertAnyInt
(
Amc13RegNode
.
first_child
().
value
()
)
<<
RESET
<<
std
::
endl
;
os
<<
BOLDCYAN
<<
"|"
<<
"----"
<<
Amc13RegNode
.
name
()
<<
" "
<<
Amc13RegNode
.
attribute
(
"tounge"
).
name
()
<<
" : "
<<
Amc13RegNode
.
attribute
(
"tounge"
).
value
()
<<
" - name: "
<<
regname
<<
" "
<<
BOLDRED
<<
convertAnyInt
(
Amc13RegNode
.
first_child
().
value
())
<<
RESET
<<
std
::
endl
;
if
(
std
::
string
(
Amc13RegNode
.
attribute
(
"tounge"
).
value
())
==
"T1"
)
fAmc13
->
setReg
(
1
,
regname
,
convertAnyInt
(
Amc13RegNode
.
first_child
().
value
()
)
);
else
if
(
std
::
string
(
Amc13RegNode
.
attribute
(
"tounge"
).
value
())
==
"T2"
)
fAmc13
->
setReg
(
2
,
regname
,
convertAnyInt
(
Amc13RegNode
.
first_child
().
value
()
)
);
if
(
std
::
string
(
Amc13RegNode
.
attribute
(
"tounge"
).
value
()
)
==
"T1"
)
fAmc13
->
setReg
(
1
,
regname
,
convertAnyInt
(
Amc13RegNode
.
first_child
().
value
()
)
);
else
if
(
std
::
string
(
Amc13RegNode
.
attribute
(
"tounge"
).
value
()
)
==
"T2"
)
fAmc13
->
setReg
(
2
,
regname
,
convertAnyInt
(
Amc13RegNode
.
first_child
().
value
()
)
);
}
// now get all the properties and add to the Amc13Description object
fAmc13
->
setAMCMask
(
parseAMCMask
(
cAmc13node
.
child
(
"AMCmask"
),
s
td
::
cout
)
);
fAmc13
->
setTrigger
(
parseTrigger
(
cAmc13node
.
child
(
"Trigger"
),
s
td
::
cout
)
);
fAmc13
->
setAMCMask
(
parseAMCMask
(
cAmc13node
.
child
(
"AMCmask"
),
o
s
)
);
fAmc13
->
setTrigger
(
parseTrigger
(
cAmc13node
.
child
(
"Trigger"
),
o
s
)
);
for
(
pugi
::
xml_node
cBGOnode
=
cAmc13node
.
child
(
"BGO"
);
cBGOnode
;
cBGOnode
=
cBGOnode
.
next_sibling
(
"BGO"
))
{
fAmc13
->
addBGO
(
parseBGO
(
cBGOnode
,
std
::
cout
)
);
}
for
(
pugi
::
xml_node
cBGOnode
=
cAmc13node
.
child
(
"BGO"
);
cBGOnode
;
cBGOnode
=
cBGOnode
.
next_sibling
(
"BGO"
)
)
fAmc13
->
addBGO
(
parseBGO
(
cBGOnode
,
os
)
);
//now just parse the TTC Simulator Node!
for
(
pugi
::
xml_node
cBGOnode
=
cAmc13node
.
child
(
"TTCSimulator"
);
cBGOnode
;
cBGOnode
=
cBGOnode
.
next_sibling
(
"TTCSimulator"
))
for
(
pugi
::
xml_node
cBGOnode
=
cAmc13node
.
child
(
"TTCSimulator"
);
cBGOnode
;
cBGOnode
=
cBGOnode
.
next_sibling
(
"TTCSimulator"
)
)
{
int
cTTCSimulator
=
convertAnyInt
(
cBGOnode
.
first_child
().
value
());
int
cTTCSimulator
=
convertAnyInt
(
cBGOnode
.
first_child
().
value
()
);
bool
cTTCSim
;
if
(
cTTCSimulator
==
0
)
cTTCSim
=
false
;
else
cTTCSim
=
true
;
fAmc13
->
setTTCSimulator
(
cTTCSim
);
fAmc13
->
setTTCSimulator
(
cTTCSim
);
os
<<
BOLDCYAN
<<
"|"
<<
"----"
<<
cBGOnode
.
name
()
<<
" "
<<
cTTCSimulator
<<
RESET
<<
std
::
endl
;
// now instantiate the AMC13Interface & provide it with the correct HWDescription object so I don't need to pass it around all the time!
if
(
fAmc13Interface
!=
nullptr
)
delete
fAmc13Interface
;
fAmc13Interface
=
new
Amc13Interface
(
cUri1
,
cAddressT1
,
cUri2
,
cAddressT2
);
fAmc13Interface
->
setAmc13Description
(
fAmc13
);
fAmc13Interface
=
new
Amc13Interface
(
cUri1
,
cAddressT1
,
cUri2
,
cAddressT2
);
fAmc13Interface
->
setAmc13Description
(
fAmc13
);
}
}
}
std
::
vector
<
int
>
Amc13Controller
::
parseAMCMask
(
pugi
::
xml_node
pNode
,
std
::
ostream
&
os
)
std
::
vector
<
int
>
Amc13Controller
::
parseAMCMask
(
pugi
::
xml_node
pNode
,
std
::
ostream
&
os
)
{
std
::
vector
<
int
>
cVec
;
if
(
std
::
string
(
pNode
.
name
())
==
"AMCmask"
)
if
(
std
::
string
(
pNode
.
name
()
)
==
"AMCmask"
)
{
//for ( pugi::xml_node cNode = pNode.child( "AMCmask" ); cNode; cNode = cNode.next_sibling("AMCmask") )
//{
std
::
string
cList
=
std
::
string
(
pNode
.
attribute
(
"enable"
).
value
());
std
::
string
cList
=
std
::
string
(
pNode
.
attribute
(
"enable"
).
value
()
);
std
::
string
ctoken
;
std
::
stringstream
cStr
(
cList
);
std
::
stringstream
cStr
(
cList
);
os
<<
BOLDCYAN
<<
"|"
<<
"----"
<<
"List of Enabled AMCs: "
;
while
(
std
::
getline
(
cStr
,
ctoken
,
','
))
while
(
std
::
getline
(
cStr
,
ctoken
,
','
)
)
{
cVec
.
push_back
(
convertAnyInt
(
ctoken
.
c_str
()
));
cVec
.
push_back
(
convertAnyInt
(
ctoken
.
c_str
()
)
);
os
<<
GREEN
<<
ctoken
<<
BOLDCYAN
<<
", "
;
}
os
<<
RESET
<<
std
::
endl
;
}
return
cVec
;
}
BGO
*
Amc13Controller
::
parseBGO
(
pugi
::
xml_node
pNode
,
std
::
ostream
&
os
)
BGO
*
Amc13Controller
::
parseBGO
(
pugi
::
xml_node
pNode
,
std
::
ostream
&
os
)
{
BGO
*
cBGO
=
nullptr
;
if
(
std
::
string
(
pNode
.
name
())
==
"BGO"
)
if
(
std
::
string
(
pNode
.
name
()
)
==
"BGO"
)
{
cBGO
=
new
BGO
(
convertAnyInt
(
pNode
.
attribute
(
"command"
).
value
()),
bool
(
convertAnyInt
(
pNode
.
attribute
(
"repeat"
).
value
()
)
),
convertAnyInt
(
pNode
.
attribute
(
"prescale"
).
value
()
),
convertAnyInt
(
pNode
.
attribute
(
"bx"
).
value
())
);
cBGO
=
new
BGO
(
convertAnyInt
(
pNode
.
attribute
(
"command"
).
value
()
),
bool
(
convertAnyInt
(
pNode
.
attribute
(
"repeat"
).
value
()
)
),
convertAnyInt
(
pNode
.
attribute
(
"prescale"
).
value
()
),
convertAnyInt
(
pNode
.
attribute
(
"bx"
).
value
()
)
);
os
<<
BOLDCYAN
<<
"|"
<<
"----"
<<
"BGO : command "
<<
cBGO
->
fCommand
<<
" repeat "
<<
cBGO
->
fRepeat
<<
" Prescale "
<<
cBGO
->
fPrescale
<<
" start BX "
<<
cBGO
->
fBX
<<
RESET
<<
std
::
endl
;
}
return
cBGO
;
}
Trigger
*
Amc13Controller
::
parseTrigger
(
pugi
::
xml_node
pNode
,
std
::
ostream
&
os
)
Trigger
*
Amc13Controller
::
parseTrigger
(
pugi
::
xml_node
pNode
,
std
::
ostream
&
os
)
{
Trigger
*
cTrg
=
nullptr
;
if
(
std
::
string
(
pNode
.
name
())
==
"Trigger"
)
if
(
std
::
string
(
pNode
.
name
()
)
==
"Trigger"
)
{
cTrg
=
new
Trigger
(
bool
(
pNode
.
attribute
(
"local"
).
value
()),
convertAnyInt
(
pNode
.
attribute
(
"mode"
).
value
()),
convertAnyInt
(
pNode
.
attribute
(
"rate"
).
value
()),
convertAnyInt
(
pNode
.
attribute
(
"burst"
).
value
()),
convertAnyInt
(
pNode
.
attribute
(
"rules"
).
value
()
)
);
cTrg
=
new
Trigger
(
bool
(
pNode
.
attribute
(
"local"
).
value
()
),
convertAnyInt
(
pNode
.
attribute
(
"mode"
).
value
()
),
convertAnyInt
(
pNode
.
attribute
(
"rate"
).
value
()
),
convertAnyInt
(
pNode
.
attribute
(
"burst"
).
value
()
),
convertAnyInt
(
pNode
.
attribute
(
"rules"
).
value
()
)
);
os
<<
BOLDGREEN
<<
"|"
<<
"----"
<<
"Trigger Config : Local "
<<
cTrg
->
fLocal
<<
" Mode "
<<
cTrg
->
fMode
<<
" Rate "
<<
cTrg
->
fRate
<<
" Burst "
<<
cTrg
->
fBurst
<<
" Rules "
<<
cTrg
->
fRules
<<
RESET
<<
std
::
endl
;
}
return
cTrg
;
}
AMC13/Amc13Controller.h
View file @
ae6f7722
...
...
@@ -11,32 +11,32 @@
class
Amc13Controller
{
public:
public:
Amc13Controller
();
~
Amc13Controller
();
void
InitializeAmc13
(
const
std
::
string
&
pFilename
,
std
::
ostream
&
os
=
std
::
cout
);
void
ConfigureAmc13
(
std
::
ostream
&
os
=
std
::
cout
);
void
HaltAmc13
(
std
::
ostream
&
os
=
std
::
cout
);
public:
void
InitializeAmc13
(
const
std
::
string
&
pFilename
,
std
::
ostream
&
os
);
void
ConfigureAmc13
(
std
::
ostream
&
os
);
void
HaltAmc13
(
std
::
ostream
&
os
);
public:
Amc13Interface
*
fAmc13Interface
;
Amc13Description
*
fAmc13
;
private:
private:
// Private methods for parsing!
void
parseAmc13xml
(
const
std
::
string
&
pFilename
,
std
::
ostream
&
os
=
std
::
cout
);
void
parseAmc13xml
(
const
std
::
string
&
pFilename
,
std
::
ostream
&
os
);
// low level helpers to parse specific xml TAGS
std
::
vector
<
int
>
parseAMCMask
(
pugi
::
xml_node
pNode
,
std
::
ostream
&
os
=
std
::
cout
);
BGO
*
parseBGO
(
pugi
::
xml_node
pNode
,
std
::
ostream
&
os
=
std
::
cout
);
Trigger
*
parseTrigger
(
pugi
::
xml_node
pNode
,
std
::
ostream
&
os
=
std
::
cout
);
std
::
vector
<
int
>
parseAMCMask
(
pugi
::
xml_node
pNode
,
std
::
ostream
&
os
);
BGO
*
parseBGO
(
pugi
::
xml_node
pNode
,
std
::
ostream
&
os
);
Trigger
*
parseTrigger
(
pugi
::
xml_node
pNode
,
std
::
ostream
&
os
);
// a little helper to deal with strings
uint32_t
convertAnyInt
(
const
char
*
pRegValue
)
uint32_t
convertAnyInt
(
const
char
*
pRegValue
)
{
if
(
std
::
string
(
pRegValue
).
find
(
"0x"
)
!=
std
::
string
::
npos
)
return
static_cast
<
uint32_t
>
(
strtoul
(
pRegValue
,
0
,
16
)
);
else
return
static_cast
<
uint32_t
>
(
strtoul
(
pRegValue
,
0
,
10
)
);
if
(
std
::
string
(
pRegValue
).
find
(
"0x"
)
!=
std
::
string
::
npos
)
return
static_cast
<
uint32_t
>
(
strtoul
(
pRegValue
,
0
,
16
)
);
else
return
static_cast
<
uint32_t
>
(
strtoul
(
pRegValue
,
0
,
10
)
);
}
};
...
...
AMC13/Amc13Description.cc
View file @
ae6f7722
...
...
@@ -12,51 +12,57 @@ Amc13Description::Amc13Description()
Amc13Description
::~
Amc13Description
()
{
delete
fTrigger
;
for
(
auto
&
cBGO
:
fBGOs
)
delete
cBGO
;
fBGOs
.
clear
();
fAMCMask
.
clear
();
fT1map
.
clear
();
fT2map
.
clear
();
}
uint32_t
Amc13Description
::
getReg
(
int
pTounge
,
std
::
string
&
pReg
)
uint32_t
Amc13Description
::
getReg
(
int
pTounge
,
std
::
string
&
pReg
)
{
RegMap
cMap
=
(
pTounge
==
1
)
?
fT1map
:
fT2map
;
auto
cReg
=
cMap
.
find
(
pReg
);
if
(
cReg
==
std
::
end
(
cMap
))
std
::
cout
<<
"The AMC13 does not have a register "
<<
pReg
<<
" in the memory map for Tounge "
<<
pTounge
<<
std
::
endl
;
auto
cReg
=
cMap
.
find
(
pReg
);
if
(
cReg
==
std
::
end
(
cMap
)
)
LOG
(
INFO
)
<<
"The AMC13 does not have a register "
<<
pReg
<<
" in the memory map for Tounge "
<<
pTounge
;
else
return
cReg
->
second
;
}
void
Amc13Description
::
setReg
(
int
pTounge
,
std
::
string
&
pReg
,
uint32_t
pValue
)
void
Amc13Description
::
setReg
(
int
pTounge
,
std
::
string
&
pReg
,
uint32_t
pValue
)
{
RegMap
cMap
=
(
pTounge
==
1
)
?
fT1map
:
fT2map
;
auto
cReg
=
cMap
.
find
(
pReg
);
if
(
cReg
==
std
::
end
(
cMap
)
)
cMap
.
insert
(
{
pReg
,
pValue
}
);
auto
cReg
=
cMap
.
find
(
pReg
);
if
(
cReg
==
std
::
end
(
cMap
)
)
cMap
.
insert
(
{
pReg
,
pValue
}
);
else
cReg
->
second
=
pValue
;
}
void
Amc13Description
::
setAMCMask
(
const
std
::
vector
<
int
>&
pMask
)
void
Amc13Description
::
setAMCMask
(
const
std
::
vector
<
int
>&
pMask
)
{
fAMCMask
=
pMask
;
}
void
Amc13Description
::
setTrigger
(
bool
pLocal
,
int
pMode
,
int
pRate
,
int
pBurst
,
int
pRules
)
void
Amc13Description
::
setTrigger
(
bool
pLocal
,
int
pMode
,
int
pRate
,
int
pBurst
,
int
pRules
)
{
if
(
fTrigger
!=
nullptr
)
{
std
::
cout
<<
"Warning, overwriting another Trigger object!"
<<
std
::
endl
;
LOG
(
INFO
)
<<
"Warning, overwriting another Trigger object!"
;
delete
fTrigger
;
}
fTrigger
=
new
Trigger
(
pLocal
,
pMode
,
pRate
,
pBurst
,
pRules
);
fTrigger
=
new
Trigger
(
pLocal
,
pMode
,
pRate
,
pBurst
,
pRules
);
}
void
Amc13Description
::
setTrigger
(
Trigger
*
pTrigger
)
void
Amc13Description
::
setTrigger
(
Trigger
*
pTrigger
)
{
if
(
fTrigger
!=
nullptr
)
{
std
::
cout
<<
"Warning, overwriting another Trigger object!"
<<
std
::
endl
;
LOG
(
INFO
)
<<
"Warning, overwriting another Trigger object!"
;
delete
fTrigger
;
}
fTrigger
=
pTrigger
;
}
...
...
@@ -65,38 +71,38 @@ Trigger* Amc13Description::getTrigger()
return
fTrigger
;
}
void
Amc13Description
::
setTTCSimulator
(
bool
pSimulate
)
void
Amc13Description
::
setTTCSimulator
(
bool
pSimulate
)
{
fSimulate
=
pSimulate
;
}
void
Amc13Description
::
addBGO
(
int
pCommand
,
bool
pRepeat
,
int
pPrescale
,
int
pBX
)
void
Amc13Description
::
addBGO
(
int
pCommand
,
bool
pRepeat
,
int
pPrescale
,
int
pBX
)
{
int
cSize
=
fBGOs
.
size
();
if
(
cSize
>
4
)
std
::
cout
<<
"Warning, AMC13XG only supports 4 user-defined BGOs - adding this one will have no effect!"
<<
std
::
endl
;
if
(
cSize
>
4
)
LOG
(
INFO
)
<<
"Warning, AMC13XG only supports 4 user-defined BGOs - adding this one will have no effect!"
;
else
{
BGO
*
cBGO
=
new
BGO
(
pCommand
,
pRepeat
,
pPrescale
,
pBX
);
fBGOs
.
push_back
(
cBGO
);
BGO
*
cBGO
=
new
BGO
(
pCommand
,
pRepeat
,
pPrescale
,
pBX
);
fBGOs
.
push_back
(
cBGO
);
}
}
void
Amc13Description
::
addBGO
(
BGO
*
pBGO
)
void
Amc13Description
::
addBGO
(
BGO
*
pBGO
)
{
int
cSize
=
fBGOs
.
size
();
if
(
cSize
>
4
)
std
::
cout
<<
"Warning, AMC13XG only supports 4 user-defined BGOs - adding this one will have no effect!"
<<
std
::
endl
;
if
(
cSize
>
4
)
LOG
(
INFO
)
<<
"Warning, AMC13XG only supports 4 user-defined BGOs - adding this one will have no effect!"
;
else
{
fBGOs
.
push_back
(
pBGO
);
}
fBGOs
.
push_back
(
pBGO
);
}
BGO
*
Amc13Description
::
getBGO
(
int
pPos
)
BGO
*
Amc13Description
::
getBGO
(
int
pPos
)
{
if
(
pPos
>
3
)
{
std
::
cout
<<
"AMC13XG only supports 4 custom BGOs, ID > 3 is not allowed!"
<<
std
::
endl
;
LOG
(
INFO
)
<<
"AMC13XG only supports 4 custom BGOs, ID > 3 is not allowed!"
;
return
nullptr
;
}
else
return
fBGOs
.
at
(
pPos
);
else
return
fBGOs
.
at
(
pPos
);
}
AMC13/Amc13Description.h
View file @
ae6f7722
...
...
@@ -6,6 +6,7 @@
#include <vector>
#include <stdint.h>
#include <iostream>
#include "../Utils/easylogging++"
typedef
std
::
map
<
std
::
string
,
uint32_t
>
RegMap
;
...
...
@@ -15,29 +16,29 @@ struct BGO;
class
Amc13Description
{
public:
public:
Amc13Description
();
~
Amc13Description
();
uint32_t
getReg
(
int
pTounge
,
std
::
string
&
pReg
);
void
setReg
(
int
pTounge
,
std
::
string
&
pReg
,
uint32_t
pValue
);
RegMap
getRegMap
(
int
pTounge
)
uint32_t
getReg
(
int
pTounge
,
std
::
string
&
pReg
);
void
setReg
(
int
pTounge
,
std
::
string
&
pReg
,
uint32_t
pValue
);
RegMap
getRegMap
(
int
pTounge
)
{
return
(
pTounge
==
1
)
?
fT1map
:
fT2map
;
}
int
Id
;
void
setTrigger
(
bool
pLocal
,
int
pType
,
int
pRate
,
int
pBurst
,
int
pRules
);
void
setTrigger
(
Trigger
*
pTrigger
);
void
setTrigger
(
bool
pLocal
,
int
pType
,
int
pRate
,
int
pBurst
,
int
pRules
);
void
setTrigger
(
Trigger
*
pTrigger
);
Trigger
*
getTrigger
();
void
addBGO
(
int
pCommand
,
bool
pRepeat
,
int
pPrescale
,
int
pBX
);
void
addBGO
(
BGO
*
pBGO
);
BGO
*
getBGO
(
int
pPos
);
void
addBGO
(
int
pCommand
,
bool
pRepeat
,
int
pPrescale
,
int
pBX
);
void
addBGO
(
BGO
*
pBGO
);
BGO
*
getBGO
(
int
pPos
);
void
setAMCMask
(
const
std
::
vector
<
int
>&
pMask
);
void
setTTCSimulator
(
bool
pSimulate
);
public:
void
setAMCMask
(
const
std
::
vector
<
int
>&
pMask
);
void
setTTCSimulator
(
bool
pSimulate
);
public:
RegMap
fT1map
;
RegMap
fT2map
;
std
::
vector
<
int
>
fAMCMask
;
...
...
@@ -48,7 +49,7 @@ public:
struct
BGO
{
BGO
(
int
pCommand
,
bool
pRepeat
,
int
pPrescale
,
int
pBX
)
:
fCommand
(
pCommand
),
fRepeat
(
pRepeat
),
fPrescale
(
pPrescale
),
fBX
(
pBX
)
{}
BGO
(
int
pCommand
,
bool
pRepeat
,
int
pPrescale
,
int
pBX
)
:
fCommand
(
pCommand
),
fRepeat
(
pRepeat
),
fPrescale
(
pPrescale
),
fBX
(
pBX
)
{}
int
fCommand
;
bool
fRepeat
;
int
fPrescale
;
...
...
@@ -57,7 +58,7 @@ struct BGO
struct
Trigger
{
Trigger
(
bool
pLocal
,
int
pMode
,
int
pRate
,
int
pBurst
,
int
pRules
)
:
fLocal
(
pLocal
),
fMode
(
pMode
),
fRate
(
pRate
),
fBurst
(
pBurst
),
fRules
(
pRules
)
{}
Trigger
(
bool
pLocal
,
int
pMode
,
int
pRate
,
int
pBurst
,
int
pRules
)
:
fLocal
(
pLocal
),
fMode
(
pMode
),
fRate
(
pRate
),
fBurst
(
pBurst
),
fRules
(
pRules
)
{}
bool
fLocal
;
int
fMode
;
int
fRate
;
...
...
AMC13/Amc13Interface.cc
View file @
ae6f7722
...
...
@@ -29,21 +29,23 @@ void Amc13Interface::ConfigureAmc13()
uint32_t
cMask
=
0
;
// first reset the 2 boards
std
::
cout
<<
"Resetting T1, T2 & all counters!"
<<
std
::
endl
;
LOG
(
INFO
)
<<
"Resetting T1, T2 & all counters!"
;
fAMC13
->
reset
(
amc13
::
AMC13Simple
::
T1
);
fAMC13
->
reset
(
amc13
::
AMC13Simple
::
T2
);
// now reset the counters
fAMC13
->
resetCounters
();
// now enable the AMC inputs as specified in the config File
std
::
cout
<<
"Enabling TTC links for the following AMCs: "
<<
std
::
endl
;
LOG
(
INFO
)
<<
"Enabling TTC links for the following AMCs: "
;
std
::
stringstream
ss
;
for
(
auto
&
cAMC
:
fDescription
->
fAMCMask
)
{
setBit
(
cMask
,
cAMC
,
true
);
s
td
::
cout
<<
cAMC
<<
", "
;
s
s
<<
cAMC
<<
", "
;
}
std
::
cout
<<
std
::
endl
;
LOG
(
INFO
)
<<
ss
.
str
()
;
fAMC13
->
AMCInputEnable
(
cMask
);
//now configure the BGOs, loop through the list, get the properties and call the function
...
...
@@ -55,7 +57,7 @@ void Amc13Interface::ConfigureAmc13()
{
this
->
configureBGO
(
cIndex
,
uint8_t
(
cBGO
->
fCommand
),
uint16_t
(
cBGO
->
fBX
),
uint16_t
(
cBGO
->
fPrescale
),
cBGO
->
fRepeat
);
this
->
enableBGO
(
cIndex
);
std
::
cout
<<
"Configured & enabling BGO Channel "
<<
cIndex
<<
" : Command: "
<<
cBGO
->
fCommand
<<
" BX: "
<<
cBGO
->
fBX
<<
" Prescale: "
<<
cBGO
->
fPrescale
<<
" Repetetive: "
<<
cBGO
->
fRepeat
<<
std
::
endl
;
LOG
(
INFO
)
<<
"Configured & enabling BGO Channel "
<<
cIndex
<<
" : Command: "
<<
cBGO
->
fCommand
<<
" BX: "
<<
cBGO
->
fBX
<<
" Prescale: "
<<
cBGO
->
fPrescale
<<
" Repetetive: "
<<
cBGO
->
fRepeat
;
cIndex
++
;
}
}
...
...
@@ -68,14 +70,14 @@ void Amc13Interface::ConfigureAmc13()
//Edit GA: not sure if this is actually required
fAMC13
->
write
(
amc13
::
AMC13Simple
::
T1
,
"CONF.LOCAL_TRIG.FAKE_DATA_ENABLE"
,
1
);
std
::
cout
<<
"Configuring local L1A: Mode: "
<<
fDescription
->
fTrigger
->
fMode
<<
" Rate: "
<<
fDescription
->
fTrigger
->
fRate
<<
" Burst: "
<<
fDescription
->
fTrigger
->
fBurst
<<
" Rules: "
<<
fDescription
->
fTrigger
->
fRules
<<
std
::
endl
;
LOG
(
INFO
)
<<
"Configuring local L1A: Mode: "
<<
fDescription
->
fTrigger
->
fMode
<<
" Rate: "
<<
fDescription
->
fTrigger
->
fRate
<<
" Burst: "
<<
fDescription
->
fTrigger
->
fBurst
<<
" Rules: "
<<
fDescription
->
fTrigger
->
fRules
;
}
// if TTC simulator is enabled, the loopback fiber is required and no external TTC stream will be received, the Triggers are local by definition
if
(
fDescription
->
fSimulate
)
{
fAMC13
->
localTtcSignalEnable
(
fDescription
->
fSimulate
);
std
::
cout
<<
RED
<<
"AMC13 configured to use local TTC simulator - don't forget to plug the loopback fibre!"
<<
RESET
<<
std
::
endl
;
LOG
(
INFO
)
<<
RED
<<
"AMC13 configured to use local TTC simulator - don't forget to plug the loopback fibre!"
<<
RESET
;
}
//now need to iterate the two maps of Registers and write them
...
...
@@ -85,7 +87,7 @@ void Amc13Interface::ConfigureAmc13()
for
(
auto
&
cReg
:
fDescription
->
fT2map
)
fAMC13
->
write
(
amc13
::
AMC13Simple
::
T2
,
cReg
.
first
,
cReg
.
second
);
std
::
cout
<<
GREEN
<<
"AMC13 successfully configured!"
<<
RESET
<<
std
::
endl
;
LOG
(
INFO
)
<<
GREEN
<<
"AMC13 successfully configured!"
<<
RESET
;
}
...
...
@@ -138,7 +140,7 @@ void Amc13Interface::DumpHistory (int pNlastEntries)
std
::
vector
<
uint32_t
>
cVec
=
fAMC13
->
getTTCHistory
(
pNlastEntries
);
//now decode the Info in here!
std
::
cout
<<
BOLDRED
<<
"TTC History showing the last "
<<
pNlastEntries
<<
" items!"
<<
RESET
<<
std
::
endl
;
LOG
(
INFO
)
<<
BOLDRED
<<
"TTC History showing the last "
<<
pNlastEntries
<<
" items!"
<<
RESET
;
for
(
int
index
=
0
;
index
<
cVec
.
size
()
/
4
;
index
++
)
{
...
...
@@ -148,18 +150,18 @@ void Amc13Interface::DumpHistory (int pNlastEntries)
uint32_t
cBX
=
cVec
.
at
(
index
*
4
+
2
);
uint32_t
cEvent
=
cVec
.
at
(
index
*
4
+
3
);
std
::
cout
<<
"Command: "
<<
(
cCommand
&
0xFF
)
<<
" - Orbit: "
<<
cOrbit
<<
" - BX: "
<<
(
cBX
&
0x7FF
)
<<
" - Event Nr: "
<<
(
cEvent
&
0x00FFFFFF
)
<<
std
::
endl
;
LOG
(
INFO
)
<<
"Command: "
<<
(
cCommand
&
0xFF
)
<<
" - Orbit: "
<<
cOrbit
<<
" - BX: "
<<
(
cBX
&
0x7FF
)
<<
" - Event Nr: "
<<
(
cEvent
&
0x00FFFFFF
)
;
}
}
void
Amc13Interface
::
DumpTriggers
(
int
pNlastEntries
)
{
if
(
pNlastEntries
>
127
)
std
::
cerr
<<
"Only last 128 Events available in L1A history buffer!"
<<
std
::
endl
;
if
(
pNlastEntries
>
127
)
std
::
cerr
<<
"Only last 128 Events available in L1A history buffer!"
;
std
::
vector
<
uint32_t
>
cVec
=
fAMC13
->
getL1AHistory
(
pNlastEntries
);
//now decode the Info in here!
std
::
cout
<<
BOLDRED
<<
"L1A History showing the last "
<<
pNlastEntries
<<
" items!"
<<
RESET
<<
std
::
endl
;
LOG
(
INFO
)
<<
BOLDRED
<<
"L1A History showing the last "
<<
pNlastEntries
<<
" items!"
<<
RESET
;
for
(
int
index
=
0
;
index
<
cVec
.
size
()
/
4
;
index
++
)
{
...
...
@@ -169,13 +171,13 @@ void Amc13Interface::DumpTriggers (int pNlastEntries)
uint32_t
cEventNr
=
cVec
.
at
(
index
*
4
+
2
);
uint32_t
cFlags
=
cVec
.
at
(
index
*
4
+
3
);
std
::
cout
<<
"Orbit: "
<<
cOrbit
<<
" - Bunch: "
<<
(
cBunch
&
0xFFF
)
<<
" - Event Nr: "
<<
(
cEventNr
&
0xFFFFFF
)
<<
" - Flags: "
<<
cFlags
<<
std
::
endl
;
LOG
(
INFO
)
<<
"Orbit: "
<<
cOrbit
<<
" - Bunch: "
<<
(
cBunch
&
0xFFF
)
<<
" - Event Nr: "
<<
(
cEventNr
&
0xFFFFFF
)
<<
" - Flags: "
<<
cFlags
;
}
}
void
Amc13Interface
::
HaltAMC13
()
{
std
::
cout
<<
"Resetting T1, T2 & all counters!"
<<
std
::
endl
;
LOG
(
INFO
)
<<
"Resetting T1, T2 & all counters!"
;
fAMC13
->
reset
(
amc13
::
AMC13Simple
::
T1
);
fAMC13
->
reset
(
amc13
::
AMC13Simple
::
T2
);
// now reset the counters
...
...
@@ -184,7 +186,7 @@ void Amc13Interface::HaltAMC13()
void
Amc13Interface
::
ResetAMC13
()
{
std
::
cout
<<
"Resetting T1, T2 & all counters! - Remind Georg to add OC0 and EC0 when you read this!"
<<
std
::
endl
;
LOG
(
INFO
)
<<
"Resetting T1, T2 & all counters! - Remind Georg to add OC0 and EC0 when you read this!"
;
fAMC13
->
reset
(
amc13
::
AMC13Simple
::
T1
);
fAMC13
->
reset
(
amc13
::
AMC13Simple
::
T2
);
// now reset the counters
...
...
@@ -246,17 +248,17 @@ std::vector<uint32_t> Amc13Interface::getBGOConfig (int pChan)
std
::
vector
<
uint32_t
>
pBuf
;