Skip to content

Commit e709c52

Browse files
committed
[config] Add URI support for the CRORC
1 parent a4e958a commit e709c52

File tree

3 files changed

+51
-5
lines changed

3 files changed

+51
-5
lines changed

crorc_template.cfg

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#############################################
2+
# readoutcard configuration file
3+
#
4+
# commments start with #
5+
# section names are in brackets []
6+
# settings are defined with key=value pairs
7+
#############################################
8+
9+
#############################################
10+
# global crorc settings
11+
#############################################
12+
13+
[crorc]
14+
# [true | false]
15+
dynamicOffset=true
16+
17+
# [0-255]
18+
timeFrameLength=255

cru_template.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ downstreamData=MIDTRG
3636
ponUpstream=false
3737

3838
# [0x0badcafe]
39-
onuAddress=0x0badcafe
39+
onuAddress=0x0badcaff
4040

4141
# [true | false]
4242
dynamicOffset=false

src/CardConfigurator.cxx

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ CardConfigurator::CardConfigurator(Parameters& parameters, bool forceConfigure)
4848
auto bar2 = ChannelFactory().getBar(parameters);
4949
bar2->configure(forceConfigure);
5050
} else if (cardType == CardType::Crorc) {
51-
parameters.setChannelNumber(0); // we need to change bar 0
51+
parameters.setChannelNumber(0); // we need to change to bar 0
5252
auto bar0 = ChannelFactory().getBar(parameters);
5353
bar0->configure(forceConfigure);
5454
}
@@ -68,11 +68,39 @@ void CardConfigurator::parseConfigUri(CardType::type cardType, std::string confi
6868
}
6969
}
7070

71-
void CardConfigurator::parseConfigUriCrorc(std::string /*configUri*/, Parameters& /*parameters*/) //TODO: Fill me
71+
/// configUri has to start with "ini://", "json://" or "consul://"
72+
void CardConfigurator::parseConfigUriCrorc(std::string configUri, Parameters& parameters)
7273
{
73-
Logger::get() << "Non-parameter configuration not supported for the CRORC yet" << LogErrorOps << endm;
74-
BOOST_THROW_EXCEPTION(Exception());
74+
bool dynamicOffset = false;
75+
uint32_t timeFrameLength = 0x100;
76+
77+
std::unique_ptr<o2::configuration::ConfigurationInterface> conf;
78+
try {
79+
conf = o2::configuration::ConfigurationFactory::getConfiguration(configUri);
80+
} catch (std::exception& e) {
81+
throw;
82+
}
83+
84+
auto tree = conf->getRecursive("");
85+
std::string group = "";
86+
try {
87+
for (auto it : tree) {
88+
group = it.first;
89+
auto subtree = it.second;
90+
91+
if (group == "crorc") { // Configure the CRORC
92+
dynamicOffset = subtree.get<bool>("dynamicOffset");
93+
timeFrameLength = subtree.get<int>("timeFrameLength");
94+
}
95+
96+
parameters.setDynamicOffsetEnabled(dynamicOffset);
97+
parameters.setTimeFrameLength(timeFrameLength);
98+
}
99+
} catch (...) {
100+
BOOST_THROW_EXCEPTION(ParseException() << ErrorInfo::ConfigParse(group));
101+
}
75102
}
103+
76104
/// configUri has to start with "ini://", "json://" or "consul://"
77105
void CardConfigurator::parseConfigUriCru(std::string configUri, Parameters& parameters)
78106
{

0 commit comments

Comments
 (0)