DASpec:genericize synonymous param parsing
This commit is contained in:
@@ -84,29 +84,14 @@ getStimulusProducer(
|
||||
static size_t parseNDgramsPerFrame(
|
||||
const std::shared_ptr<smo::device::DeviceAttachmentSpec>& spec)
|
||||
{
|
||||
size_t nDgramsPerFrame = 84; // Default: 84 datagrams per frame
|
||||
const std::vector<std::string> nDgramsPerFrameParamNames = {
|
||||
"n-dgrams-per-frame",
|
||||
"num-dgrams-per-frame"
|
||||
};
|
||||
|
||||
// Loop through synonyms in reverse order; lattermost synonym wins.
|
||||
for (auto synIt = nDgramsPerFrameParamNames.rbegin();
|
||||
synIt != nDgramsPerFrameParamNames.rend(); ++synIt)
|
||||
{
|
||||
const auto& paramName = *synIt;
|
||||
try {
|
||||
nDgramsPerFrame = static_cast<size_t>(
|
||||
smo::device::DeviceAttachmentSpec::parseRequiredParamAsInt(
|
||||
spec->stimBuffApiParams, paramName));
|
||||
break; // Found and parsed successfully
|
||||
} catch (const std::exception&) {
|
||||
// Parameter not found or parse error, continue to next synonym
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
return nDgramsPerFrame;
|
||||
return static_cast<size_t>(
|
||||
smo::device::DeviceAttachmentSpec::parseOptionalParamAsIntWithSynonyms(
|
||||
spec->stimBuffApiParams, nDgramsPerFrameParamNames, 84));
|
||||
}
|
||||
|
||||
// LivoxProto1DllState constructor implementation
|
||||
|
||||
@@ -110,7 +110,6 @@ void produceStimFrameAck(void)
|
||||
static int parseHistbuffMs(
|
||||
const std::shared_ptr<device::DeviceAttachmentSpec>& spec)
|
||||
{
|
||||
int histbuffMs = 30000; // Default: 30000ms (30 seconds)
|
||||
const std::vector<std::string> histbuffParamNames = {
|
||||
"history-buffer-duration-ms",
|
||||
"hist-buff-duration-ms",
|
||||
@@ -118,23 +117,8 @@ static int parseHistbuffMs(
|
||||
"histbuff-ms"
|
||||
};
|
||||
|
||||
// Loop through synonyms in reverse order; lattermost synonym wins.
|
||||
for (auto synIt = histbuffParamNames.rbegin();
|
||||
synIt != histbuffParamNames.rend(); ++synIt)
|
||||
{
|
||||
const auto& paramName = *synIt;
|
||||
try {
|
||||
histbuffMs = device::DeviceAttachmentSpec
|
||||
::parseRequiredParamAsInt(
|
||||
spec->qualeIfaceApiParams, paramName);
|
||||
break; // Found and parsed successfully
|
||||
} catch (const std::exception&) {
|
||||
// Parameter not found or parse error, continue to next synonym
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
return histbuffMs;
|
||||
return device::DeviceAttachmentSpec::parseOptionalParamAsIntWithSynonyms(
|
||||
spec->qualeIfaceApiParams, histbuffParamNames, 30000);
|
||||
}
|
||||
|
||||
std::shared_ptr<StimulusBuffer>
|
||||
|
||||
Reference in New Issue
Block a user