Skip to content

Commit

Permalink
Complete checks for usage of an afe
Browse files Browse the repository at this point in the history
  • Loading branch information
mroda88 committed Nov 25, 2024
1 parent f76f28a commit 61d2b17
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 4 deletions.
11 changes: 7 additions & 4 deletions schema/appmodel/PDS.schema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@

<oks-schema>

<info name="" type="" num-of-items="9" oks-format="schema" oks-version="862f2957270" created-by="mroda" created-on="theta.ph.liv.ac.uk" creation-time="20241011T123346" last-modified-by="maroda" last-modified-on="np04-srv-015.cern.ch" last-modification-time="20241125T111845"/>
<info name="" type="" num-of-items="9" oks-format="schema" oks-version="862f2957270" created-by="mroda" created-on="theta.ph.liv.ac.uk" creation-time="20241011T123346" last-modified-by="maroda" last-modified-on="np04-srv-015.cern.ch" last-modification-time="20241125T112947"/>

<include>
<file path="schema/confmodel/dunedaq.schema.xml"/>
Expand Down Expand Up @@ -147,6 +147,12 @@
<method name="get_afe" description="retrieve the correct afe configuration">
<method-implementation language="c++" prototype="const DaphneV2AFE &amp; get_afe( size_t id) const " body=""/>
</method>
<method name="is_channel_used" description="check if a channel is turned on">
<method-implementation language="c++" prototype="bool is_channel_used(size_t ch) const" body=""/>
</method>
<method name="is_afe_used" description="check if an AFE is used">
<method-implementation language="c++" prototype="bool is_afe_used(size_t ch) const" body=""/>
</method>
</class>

<class name="DaphneV2Channel">
Expand All @@ -162,9 +168,6 @@
<attribute name="slot" description="slot of the board" type="u16" is-not-null="yes"/>
<relationship name="daphne_conf" class-type="DaphneConf" low-cc="one" high-cc="one" is-composite="no" is-exclusive="no" is-dependent="no"/>
<relationship name="board_conf" class-type="DaphneV2BoardConf" low-cc="one" high-cc="one" is-composite="yes" is-exclusive="yes" is-dependent="yes"/>
<method name="channel_used" description="check if a channel has been used">
<method-implementation language="c++" prototype="bool channel_used(uint8_t channel) const" body="return false;"/>
</method>
</class>

<class name="DaphneV2LNA" description="info to generate Reg52 value">
Expand Down
25 changes: 25 additions & 0 deletions src/DaphneApplication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,17 @@ uint16_t DaphneConf::get_board_slot(const std::string & ip) const {
return it->at("slot").get<uint16_t>();
}

bool
DaphneV2BoardConf::is_channel_used(size_t ch) const {

for ( auto ch_p : get_active_channels() ) {
if ( ch_p->get_channel_id() == ch ) {
return true;
}
}

return false;
}

const DaphneV2Channel &
DaphneV2BoardConf::get_channel(size_t ch) const {
Expand All @@ -179,9 +190,23 @@ DaphneV2BoardConf::get_channel(size_t ch) const {
return *get_default_channel();
}

bool
DaphneV2BoardConf::is_afe_used(size_t afe) const {

auto begin = afe*8;
auto end = (afe+1)*8;
for ( size_t i = begin; i < end; ++i) {
if( is_channel_used(i) ) return true;
}

return false;
}

const DaphneV2AFE &
DaphneV2BoardConf::get_afe(size_t ch) const {

if ( ! is_afe_used(ch) ) return *get_default_afe();

for ( auto afe_p : get_active_afes() ) {
if ( afe_p->get_afe_id() == ch ) {
return *afe_p;
Expand Down

0 comments on commit 61d2b17

Please sign in to comment.