Skip to content

Commit 30346ae

Browse files
committed
Validate generator and loopback mode pair of values
1 parent 7728702 commit 30346ae

File tree

5 files changed

+37
-28
lines changed

5 files changed

+37
-28
lines changed

src/Cru/CruDmaChannel.h

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -126,37 +126,37 @@ class CruDmaChannel final : public DmaChannelPdaBase
126126
// These variables are configuration parameters
127127

128128
/// Reset level on initialization of channel
129-
ResetLevel::type mInitialResetLevel;
129+
const ResetLevel::type mInitialResetLevel;
130130

131131
/// Gives the type of loopback
132-
LoopbackMode::type mLoopbackMode;
132+
const LoopbackMode::type mLoopbackMode;
133133

134134
/// Enables the data generator
135-
bool mGeneratorEnabled;
135+
const bool mGeneratorEnabled;
136136

137137
/// Data pattern for the data generator
138-
GeneratorPattern::type mGeneratorPattern;
138+
const GeneratorPattern::type mGeneratorPattern;
139139

140140
/// Random data size
141-
bool mGeneratorDataSizeRandomEnabled;
141+
const bool mGeneratorDataSizeRandomEnabled;
142142

143143
/// Maximum number of events
144-
int mGeneratorMaximumEvents;
144+
const int mGeneratorMaximumEvents;
145145

146146
/// Initial value of the first data in a data block
147-
uint32_t mGeneratorInitialValue;
147+
const uint32_t mGeneratorInitialValue;
148148

149149
/// Sets the second word of each fragment when the data generator is used
150-
uint32_t mGeneratorInitialWord;
150+
const uint32_t mGeneratorInitialWord;
151151

152152
/// Random seed parameter in case the data generator is set to produce random data
153-
int mGeneratorSeed;
153+
const int mGeneratorSeed;
154154

155155
/// Length of data written to each page
156-
size_t mGeneratorDataSize;
156+
const size_t mGeneratorDataSize;
157157
};
158158

159159
} // namespace roc
160160
} // namespace AliceO2
161161

162-
#endif // ALICEO2_READOUTCARD_CRU_CRUDMACHANNEL_H_
162+
#endif // ALICEO2_READOUTCARD_CRU_CRUDMACHANNEL_H_

src/DmaChannelBase.cxx

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,6 @@
1313

1414
namespace AliceO2 {
1515
namespace roc {
16-
namespace {
17-
void checkParameters(const Parameters& parameters)
18-
{
19-
// Generator enabled is not allowed in conjunction with none loopback mode
20-
auto enabled = parameters.getGeneratorEnabled();
21-
auto loopback = parameters.getGeneratorLoopback();
22-
if (enabled && loopback && (*enabled && (*loopback == LoopbackMode::None))) {
23-
BOOST_THROW_EXCEPTION(
24-
InvalidParameterException() << ErrorInfo::Message("Generator enabled but 'None' loopback mode specified"));
25-
}
26-
}
27-
} // Anonymous namespace
2816

2917
namespace b = boost;
3018
namespace bfs = boost::filesystem;
@@ -42,7 +30,25 @@ void DmaChannelBase::checkChannelNumber(const AllowedChannels& allowedChannels)
4230
}
4331
}
4432

45-
DmaChannelBase::DmaChannelBase(CardDescriptor cardDescriptor, const Parameters& parameters,
33+
void DmaChannelBase::checkParameters(Parameters& parameters)
34+
{
35+
// Generator enabled is not allowed in conjunction with none loopback mode: default to Internal
36+
auto enabled = parameters.getGeneratorEnabled();
37+
auto loopback = parameters.getGeneratorLoopback();
38+
if (enabled && loopback && (*enabled && (*loopback == LoopbackMode::None))) {
39+
log("Generator enabled, defaulting to LoopbackMode = Internal", InfoLogger::InfoLogger::Debug);
40+
parameters.setGeneratorLoopback(LoopbackMode::Internal);
41+
}
42+
43+
// Generator disabled. Loopback mode should be set to None
44+
if (enabled && loopback && (!*enabled && (*loopback != LoopbackMode::None))){
45+
log("Generator disabled, defaulting to LoopbackMode = None", InfoLogger::InfoLogger::Debug);
46+
parameters.setGeneratorLoopback(LoopbackMode::None);
47+
}
48+
}
49+
50+
51+
DmaChannelBase::DmaChannelBase(CardDescriptor cardDescriptor, Parameters& parameters,
4652
const AllowedChannels& allowedChannels)
4753
: mCardDescriptor(cardDescriptor), mChannelNumber(parameters.getChannelNumberRequired())
4854
{

src/DmaChannelBase.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class DmaChannelBase: public DmaChannelInterface
3636
/// \param cardDescriptor Card descriptor
3737
/// \param parameters Parameters of the channel
3838
/// \param allowedChannels Channels allowed by this card type
39-
DmaChannelBase(CardDescriptor cardDescriptor, const Parameters& parameters,
39+
DmaChannelBase(CardDescriptor cardDescriptor, Parameters& parameters,
4040
const AllowedChannels& allowedChannels);
4141
virtual ~DmaChannelBase();
4242

@@ -109,6 +109,9 @@ class DmaChannelBase: public DmaChannelInterface
109109
/// Check if the channel number is valid
110110
void checkChannelNumber(const AllowedChannels& allowedChannels);
111111

112+
/// Check the validity of basic parameters
113+
void checkParameters(Parameters& parameters);
114+
112115
/// Type of the card
113116
const CardDescriptor mCardDescriptor;
114117

@@ -128,4 +131,4 @@ class DmaChannelBase: public DmaChannelInterface
128131
} // namespace roc
129132
} // namespace AliceO2
130133

131-
#endif // ALICEO2_SRC_READOUTCARD_DMACHANNELBASE_H_
134+
#endif // ALICEO2_SRC_READOUTCARD_DMACHANNELBASE_H_

src/DmaChannelPdaBase.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ CardDescriptor createCardDescriptor(const Parameters& parameters)
3030

3131
DmaChannelPdaBase::DmaChannelPdaBase(const Parameters& parameters,
3232
const AllowedChannels& allowedChannels)
33-
: DmaChannelBase(createCardDescriptor(parameters), parameters, allowedChannels), mDmaState(DmaState::STOPPED)
33+
: DmaChannelBase(createCardDescriptor(parameters), const_cast<Parameters&>(parameters), allowedChannels), mDmaState(DmaState::STOPPED)
3434
{
3535
// Initialize PDA & DMA objects
3636
Utilities::resetSmartPtr(mRocPciDevice, getCardDescriptor().pciAddress);

src/Dummy/DummyDmaChannel.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ constexpr size_t READY_QUEUE_SIZE = 32;
2424
constexpr auto endm = InfoLogger::InfoLogger::StreamOps::endm;
2525

2626
DummyDmaChannel::DummyDmaChannel(const Parameters& params)
27-
: DmaChannelBase(makeDummyDescriptor(), params, { 0, 1, 2, 3, 4, 5, 6, 7 }),
27+
: DmaChannelBase(makeDummyDescriptor(), const_cast<Parameters&>(params), { 0, 1, 2, 3, 4, 5, 6, 7 }),
2828
mTransferQueue(TRANSFER_QUEUE_SIZE), mReadyQueue(READY_QUEUE_SIZE)
2929
{
3030
getLogger() << "DummyDmaChannel::DummyDmaChannel(channel:" << params.getChannelNumberRequired() << ")"

0 commit comments

Comments
 (0)