Files
salmanoff/stimBuffApis/livoxGen1/pcloudAmbienceQualeIfaceApi.h
T
hayodea 632a227985 DAPS: Add intrin specs to nontrin specs
We no longer do intrin specs as a separate stimbuff; rather now we
do them as a specifier segment within the pipeline spec of a normal
nontrin spec.
2026-04-18 12:02:27 -04:00

84 lines
2.1 KiB
C++

#ifndef _LIVOX_GEN1_PCLOUD_AMBIENCE_QUALE_IFACE_API_H
#define _LIVOX_GEN1_PCLOUD_AMBIENCE_QUALE_IFACE_API_H
#include <cstdint>
#include <memory>
#include <optional>
#include <stdexcept>
#include <string>
#include <user/deviceAttachmentSpec.h>
namespace smo {
namespace stim_buff {
enum ParamComparatorOp
{
OP_CMP_GT,
OP_CMP_LT,
};
struct ParamComparator
{
ParamComparatorOp op;
uint32_t value;
bool operator()(float passbandMetricVal) const
{
switch (op)
{
case OP_CMP_GT:
return passbandMetricVal > static_cast<float>(value);
case OP_CMP_LT:
return passbandMetricVal < static_cast<float>(value);
}
throw std::runtime_error("Unsupported ParamComparatorOp");
}
};
struct PcloudAmbiencePassbandComparators
{
std::optional<ParamComparator> lt;
std::optional<ParamComparator> gt;
};
/* Both `passband-count-lt-val` and `passband-count-gt-val` are permitted
* simultaneously on a pcloudAmbience qualeIfaceApi: the lt comparator
* typically feeds a postrin(...) segment (triggering on unusually low
* counts), and the gt comparator typically feeds a negtrin(...) segment
* (triggering on unusually high counts).
*/
inline PcloudAmbiencePassbandComparators parsePcloudAmbiencePassbandComparators(
const std::shared_ptr<device::DeviceAttachmentSpec>& deviceAttachmentSpec)
{
const auto& params = deviceAttachmentSpec->qualeIfaceApiParams;
constexpr int kParamNotSpecified = -1;
const int gtVal = device::DeviceAttachmentSpec::parseOptionalParamAsInt(
params, "passband-count-gt-val", kParamNotSpecified);
const int ltVal = device::DeviceAttachmentSpec::parseOptionalParamAsInt(
params, "passband-count-lt-val", kParamNotSpecified);
PcloudAmbiencePassbandComparators out;
if (gtVal != kParamNotSpecified)
{
out.gt = ParamComparator{
.op = OP_CMP_GT,
.value = static_cast<uint32_t>(gtVal),
};
}
if (ltVal != kParamNotSpecified)
{
out.lt = ParamComparator{
.op = OP_CMP_LT,
.value = static_cast<uint32_t>(ltVal),
};
}
return out;
}
} // namespace stim_buff
} // namespace smo
#endif // _LIVOX_GEN1_PCLOUD_AMBIENCE_QUALE_IFACE_API_H