16#ifndef SFM_FLOW_METER_PROTOCOLS_HPP
17#define SFM_FLOW_METER_PROTOCOLS_HPP
30namespace sfm::detail {
35enum class StepKind : uint8_t {
50enum class Op : uint8_t {
69 StepKind kind{StepKind::Wait};
72 Error on_fail{Error::Bus};
76 std::array<uint8_t, kMaxWrite> bytes{};
80inline constexpr std::size_t kMaxSteps = 10;
83inline constexpr uint8_t kMaxPhases = 3;
88 std::array<Step, kMaxSteps> steps{};
96 const GasRow* gas{
nullptr};
99 uint16_t eeprom_base{0};
100 bool filter_on{
false};
102 bool conservative{
true};
105 bool serial_low{
true};
109inline constexpr uint8_t kWordBytes = 3;
112inline constexpr uint32_t kConservativeUs = 20000;
114inline constexpr uint32_t kPollIntervalUs = 1000;
117constexpr Step Write16(uint16_t cmd,
Error fail)
noexcept {
119 s.kind = StepKind::Write;
122 s.bytes[0] =
static_cast<uint8_t
>((
static_cast<uint32_t
>(cmd) >> 8U) & 0xFFU);
123 s.bytes[1] =
static_cast<uint8_t
>(
static_cast<uint32_t
>(cmd) & 0xFFU);
128constexpr Step Write8(uint8_t cmd,
Error fail)
noexcept {
130 s.kind = StepKind::Write;
139constexpr Step WriteArg(uint16_t cmd, uint16_t arg, uint8_t crc_init)
noexcept {
142 const auto high =
static_cast<uint8_t
>((
static_cast<uint32_t
>(arg) >> 8U) & 0xFFU);
143 const auto low =
static_cast<uint8_t
>(
static_cast<uint32_t
>(arg) & 0xFFU);
146 s.bytes[4] =
reg::Crc8(crc_init, high, low);
152constexpr Step WriteEeprom(uint16_t address)
noexcept {
154 s.kind = StepKind::Write;
157 const uint32_t aligned = (
static_cast<uint32_t
>(address) << 4U) & 0xFFFFU;
158 s.bytes[1] =
static_cast<uint8_t
>(aligned >> 8U);
159 s.bytes[2] =
static_cast<uint8_t
>(aligned & 0xFFU);
165constexpr Step ReadWords(uint8_t words,
Error fail,
bool stretch)
noexcept {
167 s.kind = stretch ? StepKind::ReadStretch : StepKind::Read;
168 s.len =
static_cast<uint8_t
>(
static_cast<uint32_t
>(words) * kWordBytes);
174constexpr Step Delay(uint32_t us)
noexcept {
176 s.kind = StepKind::Wait;
188constexpr Step PollCommand(
const PartInfo& p,
bool id =
false) noexcept {
212constexpr Step PollStep(
const PartInfo& p, uint32_t bound_us,
Error fail,
213 bool id =
false) noexcept {
214 Step s = PollCommand(p,
id);
215 s.kind = StepKind::Poll;
217 s.us = kPollIntervalUs;
218 const uint32_t tries = (bound_us / kPollIntervalUs) + 1U;
219 s.retries =
static_cast<uint8_t
>((tries < 255U) ? tries : 255U);
225constexpr void Add(Plan& plan,
const Step& step)
noexcept {
226 if (plan.count < kMaxSteps) {
227 plan.steps[plan.count] = step;
228 plan.count =
static_cast<uint8_t
>(plan.count + 1U);
229 if ((step.kind == StepKind::Read) || (step.kind == StepKind::ReadStretch)) {
230 plan.rx_len =
static_cast<uint8_t
>(plan.rx_len + step.len);
236constexpr void AddDelay(Plan& plan, uint32_t us)
noexcept {
238 Add(plan, Delay(us));
244inline constexpr uint32_t kSamplePeriodUs = 500;
250constexpr uint32_t SilenceBoundUs(
const PartInfo& p, uint32_t averaging)
noexcept {
252 const uint32_t period = n * kSamplePeriodUs;
253 return p.timing.first_sample_us + period + (period / 10U) + kPollIntervalUs;
257constexpr uint32_t ResetBoundUs(
const PartInfo& p,
bool conservative)
noexcept {
258 uint32_t bound = p.timing.power_up_us;
259 bound = (p.timing.soft_reset_us > bound) ? p.timing.soft_reset_us : bound;
260 bound = (p.timing.wake_us > bound) ? p.timing.wake_us : bound;
262 bound = (bound > kConservativeUs) ? bound : kConservativeUs;
266 return bound + (bound / 4U);
270constexpr uint32_t SoftResetUs(
const PartInfo& p,
bool conservative)
noexcept {
272 return (p.timing.soft_reset_us > kConservativeUs) ? p.timing.soft_reset_us : kConservativeUs;
274 return p.timing.soft_reset_us;
279constexpr uint16_t ResetAveraging(
const PartInfo& p)
noexcept {
284constexpr uint16_t IdentifierCommand(
const PartInfo& p)
noexcept {
292constexpr Plan InitIdentifierPlan(
const PartInfo& p,
const Request& rq)
noexcept {
297 Add(plan, PollStep(p, ResetBoundUs(p, rq.conservative),
Error::NoDevice, rq.poll_id));
298 AddDelay(plan, p.timing.stop_us);
300 AddDelay(plan, p.timing.id_read_us);
307constexpr Plan InitSf05Plan(
const PartInfo& p,
const Request& rq)
noexcept {
312 AddDelay(plan, SoftResetUs(p, rq.conservative));
326 ptr.optional = legacy;
327 word.optional = legacy;
336constexpr Plan InitSf04Plan(
const PartInfo& p)
noexcept {
345constexpr Plan AveragingPlan(
const PartInfo& p, uint16_t n)
noexcept {
348 Add(plan, WriteArg(cmd, n, p.crc_init));
354constexpr Plan InitSecondPlan(
const PartInfo& p,
const Request& rq)
noexcept {
362 return AveragingPlan(p, (rq.value ==
kAveragingDefault) ? ResetAveraging(p) : rq.value);
368constexpr Plan ScalePlan(
const PartInfo& p,
const Request& rq, uint8_t phase)
noexcept {
370 const uint16_t code = (rq.gas !=
nullptr) ? rq.gas->code : uint16_t{0};
398 }
else if (phase == 1U) {
413constexpr Plan LaunchPlan(
const PartInfo& p,
const Request& rq)
noexcept {
415 if ((rq.gas ==
nullptr) || (p.family ==
Family::Sf04)) {
421 }
else if (rq.gas->takes_argument) {
422 Add(plan, WriteArg(rq.gas->code, rq.value, p.crc_init));
424 Add(plan, WriteArg(rq.gas->code, rq.filter, p.crc_init));
428 AddDelay(plan, p.timing.first_sample_us);
433constexpr Plan SamplePlan(
const PartInfo& p,
const Request& rq)
noexcept {
459inline constexpr uint32_t kSf05TemperatureUs = 5000;
463constexpr Plan TemperaturePlan(
const PartInfo& p)
noexcept {
468 AddDelay(plan, kSf05TemperatureUs);
477constexpr Plan StopPlan(
const PartInfo& p)
noexcept {
483 AddDelay(plan, p.timing.stop_us);
492constexpr Plan WakePlan(
const PartInfo& p,
const Request& rq)
noexcept {
494 Add(plan, PollStep(p, ResetBoundUs(p, rq.conservative),
Error::Timeout, rq.poll_id));
495 AddDelay(plan, p.timing.stop_us);
500constexpr Plan SoftResetPlan(
const PartInfo& p,
const Request& rq)
noexcept {
504 gc.kind = StepKind::GeneralCall;
512 AddDelay(plan, SoftResetUs(p, rq.conservative));
513 Add(plan, PollStep(p, kPollIntervalUs * 4U,
Error::Timeout, rq.poll_id));
514 AddDelay(plan, p.timing.stop_us);
519constexpr Plan HardResetPlan(
const PartInfo& p,
const Request& rq)
noexcept {
523 low.kind = StepKind::ResetPin;
526 AddDelay(plan, p.timing.hard_reset_us);
528 high.kind = StepKind::ResetPin;
532 cycle.kind = StepKind::PowerCycle;
535 AddDelay(plan, p.timing.power_up_us);
536 Add(plan, PollStep(p, p.timing.power_up_us,
Error::Timeout, rq.poll_id));
537 AddDelay(plan, p.timing.stop_us);
542constexpr Plan ConcentrationPlan(
const PartInfo& p,
const Request& rq)
noexcept {
550constexpr Plan InitFirstPlan(
const PartInfo& p,
const Request& rq)
noexcept {
553 return InitSf05Plan(p, rq);
555 return InitSf04Plan(p);
563 return InitIdentifierPlan(p, rq);
568constexpr Plan WakeSecondPlan(
const PartInfo& p,
const Request& rq)
noexcept {
573constexpr Plan BuildSingle(
const PartInfo& p,
const Request& rq)
noexcept {
577 case Op::SetAveraging:
578 return AveragingPlan(p, rq.value);
586 return SoftResetPlan(p, rq);
588 return HardResetPlan(p, rq);
590 return SamplePlan(p, rq);
591 case Op::ReadTemperature:
592 return TemperaturePlan(p);
593 case Op::Concentration:
594 return ConcentrationPlan(p, rq);
598 case Op::ReadScaling:
608constexpr Plan Build(
const PartInfo& p,
const Request& rq, uint8_t phase)
noexcept {
612 return InitFirstPlan(p, rq);
614 return (phase == 1U) ? InitSecondPlan(p, rq) : Plan{};
619 return (phase == 2U) ? LaunchPlan(p, rq) : Plan{};
620 case Op::ReadScaling:
621 return ScalePlan(p, rq, phase);
624 return WakePlan(p, rq);
626 return (phase == 1U) ? WakeSecondPlan(p, rq) : Plan{};
629 case Op::SetAveraging:
634 case Op::ReadTemperature:
635 case Op::Concentration:
639 return (phase == 0U) ? BuildSingle(p, rq) : Plan{};
647 std::array<uint16_t, 6> w{};
660constexpr Result<Words> ParseWords(uint8_t crc_init, std::span<const uint8_t> rx)
noexcept {
661 if (rx.empty() || ((rx.size() % kWordBytes) != 0U) || (rx.size() >
kMaxRead)) {
665 const std::size_t count = rx.size() / kWordBytes;
666 for (std::size_t i = 0U; i < count; ++i) {
667 const uint8_t high = rx[i * kWordBytes];
668 const uint8_t low = rx[(i * kWordBytes) + 1U];
669 if (
reg::Crc8(crc_init, high, low) != rx[(i * kWordBytes) + 2U]) {
673 static_cast<uint16_t
>((
static_cast<uint32_t
>(high) << 8U) |
static_cast<uint32_t
>(low));
675 out.n =
static_cast<uint8_t
>(count);
680constexpr int32_t AsSigned(uint16_t word)
noexcept {
681 return (word >= 0x8000U) ? (
static_cast<int32_t
>(word) - 65536) :
static_cast<int32_t
>(word);
687inline constexpr int32_t kTemperatureMinMdegC = -60000;
688inline constexpr int32_t kTemperatureMaxMdegC = 150000;
692constexpr bool IsStuck(
const PartInfo& p, std::span<const uint8_t> rx)
noexcept {
695 for (
const uint8_t
byte : rx) {
696 zeros = zeros && (
byte == 0U);
697 ones = ones && (
byte == 0xFFU);
699 const bool zero_is_value = (p.gases.rows[0].scaling.offset == 0);
700 return ones || (zeros && !zero_is_value);
707 int32_t temperature{0};
709 bool has_temperature{
false};
710 bool has_status{
false};
711 bool has_flow2{
false};
715constexpr Frame DualFrame(
const Words& w)
noexcept {
717 f.flow =
static_cast<int32_t
>((
static_cast<uint32_t
>(w.w[0]) << 8U) |
718 (
static_cast<uint32_t
>(w.w[1]) >> 8U));
719 f.flow2 =
static_cast<int32_t
>(((
static_cast<uint32_t
>(w.w[1]) & 0xFFU) << 16U) |
720 static_cast<uint32_t
>(w.w[2]));
727constexpr Frame StatusFrame(
const PartInfo& p,
const Words& w)
noexcept {
729 f.flow = AsSigned(w.w[0]);
733 f.temperature = f.has_temperature ? AsSigned(w.w[1]) : 0;
745constexpr Result<Frame> DecodeFrame(
const PartInfo& p, std::span<const uint8_t> rx)
noexcept {
746 const Result<Words> words = ParseWords(p.crc_init, rx);
750 const Words& w = words.value;
751 if (IsStuck(p, rx) || ((w.n == 3U) && (w.w[0] == w.w[1]) && (w.w[1] == w.w[2]))) {
760 if ((
static_cast<uint32_t
>(w.w[0]) & 0x3U) != 0U) {
776struct StatusContext {
777 uint16_t gas_index{0};
778 uint16_t permille{0};
779 uint16_t averages{0};
781 bool filter_given{
false};
785constexpr bool NibbleLegal(
Family family, uint32_t nibble)
noexcept {
788 return (nibble <= 3U) || ((nibble >= 6U) && (nibble <= 8U));
790 return (nibble <= 4U) || (nibble == 10U);
811constexpr Error CheckStatus(
const PartInfo& p, uint16_t status,
const StatusContext& ctx)
noexcept {
812 const uint32_t nibble = reg::StatusCommand::Extract(status);
813 if (!NibbleLegal(p.family, nibble)) {
816 if (nibble != ctx.gas_index) {
820 const bool fixed = ctx.averages >= 1U;
821 const bool ok = ((reg::StatusFixedN::Extract(status) != 0U) == fixed) &&
822 (reg::StatusAverages::Extract(status) == ctx.averages) &&
823 ((reg::StatusFilterArg::Extract(status) != 0U) == ctx.filter_given);
831 const uint32_t conc = reg::StatusConcentration::Extract(status);
832 const uint32_t expected =
833 ctx.mixture ?
static_cast<uint32_t
>(ctx.permille) : uint32_t{reg::
kStatusPureGas};
834 if (conc != expected) {
837 const bool fixed = ctx.averages >= 1U;
842constexpr bool IsSmoothed(
const PartInfo& p, uint16_t status)
noexcept {
844 return has_bit && (reg::StatusSmoothing::Extract(status) != 0U);
848struct IdentityQuery {
849 const PartInfo* expected{
nullptr};
850 Family family{Family::Sf06};
852 bool accept_prototype{
false};
856constexpr uint32_t Join(uint16_t high, uint16_t low)
noexcept {
857 return (
static_cast<uint32_t
>(high) << 16U) |
static_cast<uint32_t
>(low);
870constexpr Result<ProductInfo> DecodeIdentifier(
const IdentityQuery& q, uint8_t crc_init,
871 std::span<const uint8_t> rx)
noexcept {
872 const Result<Words> words = ParseWords(crc_init, rx);
876 const Words& w = words.value;
878 info.product_id = Join(w.w[0], w.w[1]);
879 info.serial = Join(w.w[4], w.w[5]);
880 info.revision =
static_cast<uint8_t
>(info.product_id & 0xFFU);
881 const bool serial_stuck =
882 ((w.w[2] == 0U) && (w.w[3] == 0U) && (info.serial == 0U)) ||
883 ((w.w[2] == 0xFFFFU) && (w.w[3] == 0xFFFFU) && (info.serial == 0xFFFFFFFFU));
887 const PartInfo* row =
888 (q.expected !=
nullptr) ? q.expected :
FindById(q.family, info.product_id, q.address);
889 if ((row ==
nullptr) || ((info.product_id & row->id_mask) != row->id_value) ||
890 (row->family != q.family)) {
894 (row->id_mask != 0xFFFFFFFFU) && ((
static_cast<uint32_t
>(info.revision) >> 4U) == 8U);
895 if (info.prototype && !q.accept_prototype) {
898 info.variant = row->variant;
899 info.preliminary = row->preliminary;
905constexpr Result<ProductInfo> DecodeSerial(
const PartInfo& p,
906 std::span<const uint8_t> rx)
noexcept {
907 const Result<Words> words = ParseWords(p.crc_init, rx);
912 const uint16_t low = (words.value.n > 1U) ? words.value.w[1] : uint16_t{0};
913 info.serial = Join(words.value.w[0], low);
914 if ((info.serial == 0U) || (info.serial == 0xFFFFFFFFU)) {
917 info.variant = p.variant;
918 info.preliminary = p.preliminary;
924constexpr int32_t TableScale(
const Scaling& s)
noexcept {
925 return static_cast<int32_t
>(
926 DivideRounded(
static_cast<int64_t
>(s.num),
static_cast<int64_t
>(s.den)));
930constexpr bool ScalingMatches(
const ScalingInfo& got,
const Scaling& table,
932 if (got.scale == 0) {
938 const int32_t want = TableScale(table);
939 const int64_t diff = (got.scale > want) ? (
static_cast<int64_t
>(got.scale) - want)
940 : (static_cast<int64_t>(want) - got.scale);
941 const bool scale_ok =
943 return scale_ok && (got.offset == table.offset) && (got.unit == table.unit);
948constexpr Result<ScalingInfo> DecodeScaling(
const PartInfo& p,
949 std::span<const uint8_t> rx)
noexcept {
950 const Result<Words> words = ParseWords(p.crc_init, rx);
954 const Words& w = words.value;
956 info.scale =
static_cast<int32_t
>(w.w[0]);
959 info.offset =
static_cast<int32_t
>(w.w[1]);
969 info.offset = AsSigned(w.w[1]);
978constexpr uint16_t EepromBase(uint32_t field)
noexcept {
984constexpr Result<uint16_t> DecodeField(
const PartInfo& p, std::span<const uint8_t> rx,
985 bool user_register)
noexcept {
986 const Result<Words> words = ParseWords(p.crc_init, rx);
990 const uint32_t reg_value = words.value.w[0];
991 const uint32_t field = user_register ? ((reg_value >> 4U) & 0x7U) : (reg_value & 0x7U);
constexpr uint16_t kSf05Reset
Soft reset (SFM3x00).
Definition sfm_flow_meter_registers.hpp:69
constexpr uint16_t kSf05ScaleFlow
Flow scale factor.
Definition sfm_flow_meter_registers.hpp:70
constexpr uint16_t kCmdAveragingDual
SFM3505: configure averaging.
Definition sfm_flow_meter_registers.hpp:53
constexpr uint8_t kSf04ReadOnly2
Read read-only register 2.
Definition sfm_flow_meter_registers.hpp:81
constexpr uint8_t kSf04Eeprom
Read the EEPROM.
Definition sfm_flow_meter_registers.hpp:82
constexpr uint16_t kCmdReadScale
Read scale factor, offset and unit (argument).
Definition sfm_flow_meter_registers.hpp:54
constexpr uint16_t kSf05Flow
Start flow measurement / point at the flow.
Definition sfm_flow_meter_registers.hpp:67
constexpr uint16_t kCmdProductId
Read the product identifier (idle).
Definition sfm_flow_meter_registers.hpp:57
constexpr uint8_t kSf04UserRegister
Read the user register.
Definition sfm_flow_meter_registers.hpp:80
constexpr uint16_t kSf04EepromSerial
EEPROM address of the product serial number.
Definition sfm_flow_meter_registers.hpp:83
constexpr uint16_t kSf05Serial
Definition sfm_flow_meter_registers.hpp:72
constexpr uint8_t Crc8(uint8_t init, uint8_t high, uint8_t low) noexcept
CRC-8 of one 16-bit word as the chip computes it: polynomial 0x31 (x^8.
Definition sfm_flow_meter_registers.hpp:123
constexpr uint8_t kGeneralCallReset
Byte sent to address 0x00 to reset.
Definition sfm_flow_meter_registers.hpp:63
constexpr uint16_t kCmdSfxTemperature
SFx6000: point the read at the temperature.
Definition sfm_flow_meter_registers.hpp:61
constexpr uint16_t kCmdSfxScalePointer
SFx6000: point the read at the gas information.
Definition sfm_flow_meter_registers.hpp:59
constexpr uint16_t kSf04EepromScale
EEPROM address of the scale factor.
Definition sfm_flow_meter_registers.hpp:85
constexpr uint16_t kCmdAveraging
SF06 and SFM3304: configure averaging.
Definition sfm_flow_meter_registers.hpp:52
constexpr uint16_t kStatusPureGas
Status bits 9:0 of a pure gas.
Definition sfm_flow_meter_registers.hpp:96
constexpr uint16_t kCmdSleep
Enter sleep mode.
Definition sfm_flow_meter_registers.hpp:56
constexpr uint16_t kSf05SerialLow
Serial number, least significant word.
Definition sfm_flow_meter_registers.hpp:74
constexpr uint16_t kSf04FieldStride
EEPROM size of one calibration field.
Definition sfm_flow_meter_registers.hpp:87
constexpr uint8_t kSf04SoftReset
Soft reset.
Definition sfm_flow_meter_registers.hpp:79
constexpr uint16_t kCmdDeviceIdDual
SFM3505: read the device identifier.
Definition sfm_flow_meter_registers.hpp:58
constexpr uint16_t kSf05Temperature
Point at the temperature.
Definition sfm_flow_meter_registers.hpp:68
constexpr uint16_t kCmdResultPointer
Point the read at the result buffer.
Definition sfm_flow_meter_registers.hpp:50
constexpr uint16_t kCmdStop
Stop continuous measurement.
Definition sfm_flow_meter_registers.hpp:51
constexpr uint16_t kCmdUpdateConcentration
Update concentration, part 1 (argument).
Definition sfm_flow_meter_registers.hpp:48
constexpr uint8_t kSf04TriggerFlow
Trigger a flow measurement.
Definition sfm_flow_meter_registers.hpp:77
constexpr uint16_t kSf05OffsetFlow
Flow offset.
Definition sfm_flow_meter_registers.hpp:71
ScalingCheck
What ReadScaling() does when the sensor's scale or offset differs from the datasheet.
Definition sfm_flow_meter_types.hpp:302
Error
Why a call failed. Every call of the driver returns one of these in its Result.
Definition sfm_flow_meter_types.hpp:41
Family
The command-set family of a part. One protocol policy per family; every part is a row of data that na...
Definition sfm_flow_meter_types.hpp:207
constexpr uint16_t kAveragingDefault
Marks Config::averaging as "the family's reset value".
Definition sfm_flow_meter_types.hpp:425
@ Strict
Any difference or a wrong unit is DeviceFault.
@ Off
The sensor's values are used; only scale 0 and the unit are checked.
@ Bus
A write hook returned false.
@ Timeout
A bounded wait or poll ended: wake, reset, stretched read.
@ Sf06Dual
SFM3505: two 24-bit flows (air and oxygen) in one frame.
@ SFM3000_200_C
SFM3000-200-C, 5 V, address 0x40, legacy.
constexpr uint32_t kScaleRead
ReadScaling().
Definition sfm_flow_meter_parts.hpp:38
constexpr uint32_t kSoftResetCommand
SoftReset() is a command to the device.
Definition sfm_flow_meter_parts.hpp:48
constexpr uint32_t kGeneralCallReset
SoftReset() is the general call.
Definition sfm_flow_meter_parts.hpp:47
constexpr uint32_t kAveraging
SetAveraging().
Definition sfm_flow_meter_parts.hpp:39
constexpr uint32_t kResetPin
HardReset() pulses /RES (SFM4200).
Definition sfm_flow_meter_parts.hpp:50
constexpr uint32_t kFilterArg
The start command takes a filter argument.
Definition sfm_flow_meter_parts.hpp:52
constexpr uint32_t kTemperatureFrame
The frame carries the temperature.
Definition sfm_flow_meter_parts.hpp:44
constexpr const PartInfo * FindById(Family family, uint32_t id, uint8_t address) noexcept
The table row that a product identifier and address select inside one family.
Definition sfm_flow_meter_parts.hpp:546
constexpr std::size_t kMaxRead
Definition sfm_flow_meter_i2c_interface.hpp:68
constexpr int64_t DivideRounded(int64_t value, int64_t divisor) noexcept
Divide value by divisor rounding to nearest, ties away from zero.
Definition sfm_flow_meter_parts.hpp:628
constexpr bool Has(const PartInfo &part, uint32_t bits) noexcept
Definition sfm_flow_meter_parts.hpp:595
Compile-time helpers of the SFM_FLOW_METER driver: typed integer literals, exact hook matching,...
The I2C port of the SFM flow meter driver: the CRTP base, the I2cPort concept and the bus requirement...
The table of supported parts: one row of data per variant, the lookups, Validate() and the unit conve...
Command codes, status-word helpers and the CRC-8 of the SFM flow meters.
Public types of the SFM flow meter driver: errors, Result<T>, the families, variants and gases,...
static constexpr Result Failure(Error e) noexcept
A failed result.
Definition sfm_flow_meter_types.hpp:162
static constexpr Result Success(T v) noexcept
A successful result.
Definition sfm_flow_meter_types.hpp:154