BASIS 2 Driver 0.1.0
API reference
Loading...
Searching...
No Matches
alicat_basis2_types.hpp
Go to the documentation of this file.
1
12#ifndef ALICAT_BASIS2_TYPES_HPP
13#define ALICAT_BASIS2_TYPES_HPP
14
15#include <array>
16#include <cstddef>
17#include <cstdint>
18
20#include "alicat_basis2_version.h"
21
23namespace alicat_basis2 {
24
37enum class [[nodiscard]] Error : uint8_t {
38 // Base set: the same names and values in every driver of the org (standards/driver.md).
39 Ok = 0,
41 1,
42 InvalidArgument = 2,
43 Bus = 3,
44 Timeout = 4,
46 5,
47 Crc = 6,
48 Busy =
49 7,
51 DeviceFault = 8,
53 9,
54 // Chip-specific values start at 16; each one is returned by some call (tests/test_errors.cpp).
55 BadReply = 16,
56 Rejected = 17,
57 OutOfRange = 18,
58 Overflow = 19,
59 VerifyMismatch = 20,
60 FirmwareTooOld = 21,
62 22,
64 23,
66};
67
68namespace detail {
71inline constexpr uint8_t kErrorLast = 24;
72} // namespace detail
73
79constexpr const char* ToString(Error error) noexcept {
80 switch (error) {
81 case Error::Ok:
82 return "Ok";
84 return "NotInitialized";
86 return "InvalidArgument";
87 case Error::Bus:
88 return "Bus";
89 case Error::Timeout:
90 return "Timeout";
92 return "DeviceIdMismatch";
93 case Error::Crc:
94 return "Crc";
95 case Error::Busy:
96 return "Busy";
98 return "DeviceFault";
100 return "Unsupported";
101 case Error::BadReply:
102 return "BadReply";
103 case Error::Rejected:
104 return "Rejected";
106 return "OutOfRange";
107 case Error::Overflow:
108 return "Overflow";
110 return "VerifyMismatch";
112 return "FirmwareTooOld";
114 return "StateUnknown";
116 return "RateLimited";
118 return "GuardNotConfirmed";
119 default:
120 break;
121 }
122 return "Unknown";
123}
124
127[[nodiscard]] constexpr uint32_t GetDriverVersionMajor() noexcept {
128 return static_cast<uint32_t>(ALICAT_BASIS2_VERSION_MAJOR);
129}
131[[nodiscard]] constexpr uint32_t GetDriverVersionMinor() noexcept {
132 return static_cast<uint32_t>(ALICAT_BASIS2_VERSION_MINOR);
133}
135[[nodiscard]] constexpr uint32_t GetDriverVersionPatch() noexcept {
136 return static_cast<uint32_t>(ALICAT_BASIS2_VERSION_PATCH);
137}
139[[nodiscard]] constexpr const char* GetDriverVersion() noexcept {
140 return ALICAT_BASIS2_VERSION_STRING;
141}
142
150template <typename T>
151struct [[nodiscard]] Result {
152 T value{};
153 Error error{Error::Ok};
154
156 [[nodiscard]] constexpr bool ok() const noexcept {
157 return error == Error::Ok;
158 }
160 constexpr explicit operator bool() const noexcept {
161 return ok();
162 }
163
169 static constexpr Result Success(T v) noexcept {
170 return {v, Error::Ok};
171 }
177 static constexpr Result Failure(Error e) noexcept {
178 Result r{};
179 r.error = e;
180 return r;
181 }
182};
183
185template <>
186struct [[nodiscard]] Result<void> {
187 Error error{Error::Ok};
188
190 [[nodiscard]] constexpr bool ok() const noexcept {
191 return error == Error::Ok;
192 }
194 constexpr explicit operator bool() const noexcept {
195 return ok();
196 }
197
199 static constexpr Result Success() noexcept {
200 return {Error::Ok};
201 }
207 static constexpr Result Failure(Error e) noexcept {
208 return {e};
209 }
210};
211
213enum class LogLevel : uint8_t {
214 Error = 0,
215 Warning,
216 Info,
217 Debug,
218};
219
221enum class Protocol : uint8_t {
222 Ascii = 0,
223 ModbusRtu = 1,
224};
225
227enum class DeviceKind : uint8_t {
228 Auto = 0,
229 Meter = 1,
230 Controller = 2,
231};
232
235enum class FrameLayout : uint8_t {
236 Auto = 0,
237 Meter = 1,
238 Controller = 2,
239};
240
242enum class UnknownFlagPolicy : uint8_t {
243 Report = 0,
244 Reject = 1,
245};
246
248enum class EchoMode : uint8_t {
249 None = 0,
250 Skip = 1,
251};
252
254enum class VerifyPolicy : uint8_t {
255 Off = 0,
256 WhenNoRamp =
257 1,
258};
259
261enum class FirmwareGate : uint8_t {
262 Enforce =
263 0,
264 Ignore = 1,
265};
266
269inline constexpr uint8_t kDecimalsUnset = 0xFF;
270
272inline constexpr std::size_t kMaxLine = 256;
273
327
328namespace detail {
330[[nodiscard]] constexpr bool LineFieldsOk(const Config& c) noexcept {
331 const bool id_ok = detail::IsUpper(c.unit_id);
332 const bool addr_ok = (c.modbus_address >= 1U) && (c.modbus_address <= 247U);
333 const bool baud_ok = (c.baud == 4800U) || (c.baud == 9600U) || (c.baud == 19200U) ||
334 (c.baud == 38400U) || (c.baud == 57600U) || (c.baud == 115200U);
335 return id_ok && addr_ok && baud_ok;
336}
337
339[[nodiscard]] constexpr bool EnumFieldsOk(const Config& c) noexcept {
340 return (static_cast<uint8_t>(c.protocol) <= 1U) && (static_cast<uint8_t>(c.kind) <= 2U) &&
341 (static_cast<uint8_t>(c.frame_layout) <= 2U) &&
342 (static_cast<uint8_t>(c.unknown_flags) <= 1U) && (static_cast<uint8_t>(c.echo) <= 1U) &&
343 (static_cast<uint8_t>(c.verify_setpoint) <= 1U) &&
344 (static_cast<uint8_t>(c.firmware_gate) <= 1U);
345}
346
348[[nodiscard]] constexpr bool ValueFieldsOk(const Config& c) noexcept {
349 const bool dec_ok =
350 ((c.modbus_flow_decimals <= 6U) || (c.modbus_flow_decimals == kDecimalsUnset)) &&
351 (c.setpoint_decimals <= 6U);
352 const bool temp_ok = c.temperature_min_c < c.temperature_max_c;
353 const bool time_ok = (c.processing_ms >= 1U) && (c.slow_command_ms >= c.processing_ms) &&
354 (c.restore_holdoff_ms >= 1U) && (c.flow_margin_permille >= 1000U);
355 return dec_ok && temp_ok && time_ok;
356}
357} // namespace detail
358
364[[nodiscard]] constexpr Error Validate(const Config& c) noexcept {
365 return (detail::LineFieldsOk(c) && detail::EnumFieldsOk(c) && detail::ValueFieldsOk(c))
366 ? Error::Ok
368}
369
375struct Decimal {
376 int64_t mantissa{0};
377 uint8_t decimals{0};
378
381 [[nodiscard]] constexpr double ToDouble() const noexcept {
382 double scale = 1.0;
383 for (uint8_t i = 0U; i < decimals; ++i) {
384 scale *= 10.0;
385 }
386 return static_cast<double>(mantissa) / scale;
387 }
388
390 [[nodiscard]] constexpr int64_t ToMilli() const noexcept {
391 int64_t m = mantissa;
392 uint8_t d = decimals;
393 while (d < 3U) {
394 m *= 10;
395 ++d;
396 }
397 int64_t div = 1;
398 for (uint8_t i = 3U; i < d; ++i) {
399 div *= 10;
400 }
401 if (div == 1) {
402 return m;
403 }
404 const int64_t half = div / 2;
405 return (m >= 0) ? ((m + half) / div) : -((-m + half) / div);
406 }
407
409 friend constexpr bool operator==(const Decimal&, const Decimal&) = default;
410};
411
414struct GasId {
415 uint8_t number{0};
417 friend constexpr bool operator==(const GasId&, const GasId&) = default;
418};
419
421namespace gas {
422inline constexpr GasId kAir{0};
423inline constexpr GasId kArgon{1};
424inline constexpr GasId kCarbonDioxide{2};
425inline constexpr GasId kNitrogen{3};
426inline constexpr GasId kOxygen{4};
427inline constexpr GasId kNitrousOxide{5};
428inline constexpr GasId kHydrogen{6};
429inline constexpr GasId kHelium{7};
430inline constexpr GasId kMethane{8};
431} // namespace gas
432
438[[nodiscard]] constexpr const char* GasName(uint8_t number) noexcept {
439 switch (number) {
440 case 0U:
441 return "Air";
442 case 1U:
443 return "Ar";
444 case 2U:
445 return "CO2";
446 case 3U:
447 return "N2";
448 case 4U:
449 return "O2";
450 case 5U:
451 return "N2O";
452 case 6U:
453 return "H2";
454 case 7U:
455 return "He";
456 case 8U:
457 return "CH4";
458 default:
459 break;
460 }
461 return nullptr;
462}
463
465enum class SetpointSource : uint8_t {
466 Analog = 0,
468 1,
469 UnsavedDigital = 2,
470};
471
473enum class TimeUnit : uint8_t {
474 Millisecond = 3,
475 Second = 4,
476 Minute = 5,
477};
478
480enum class TotalizerLimit : uint8_t {
481 HoldNoError = 0,
482 ResetNoError = 1,
483 HoldWithError = 2,
484 ResetWithError = 3,
485};
486
488enum class FullScaleItem : uint8_t {
489 Flow = 0,
490 TotalVolume = 1,
491 MaxTemperature = 2,
492};
493
495enum class DataItem : uint8_t {
496 Flow = 1,
497 Setpoint = 2,
498 Temperature = 4,
499 ValveDrive = 8,
500 Gas = 16,
501 TotalVolume = 32,
502 BatchRemaining = 64,
503 Status = 128,
504};
505
508[[nodiscard]] constexpr uint8_t operator|(DataItem a, DataItem b) noexcept {
509 return static_cast<uint8_t>(static_cast<uint32_t>(a) | static_cast<uint32_t>(b));
510}
512[[nodiscard]] constexpr uint8_t operator|(uint8_t a, DataItem b) noexcept {
513 return static_cast<uint8_t>(static_cast<uint32_t>(a) | static_cast<uint32_t>(b));
514}
515
517enum class TriggerMode : uint8_t {
518 OnSetpointChange = 1,
519 OnHoldChange = 2,
520 OnAverageRead = 4,
521};
522
524enum class Baud : uint8_t {
525 B4800 = 0,
526 B9600 = 1,
527 B19200 = 2,
528 B38400 = 3,
529 B57600 = 4,
530 B115200 = 5,
531};
532
534enum class CommandProtocol : uint8_t {
535 BasisProtocol2 = 0,
536 BasisProtocol1 = 1,
537};
538
540enum class FlowUnit : uint8_t {
541 Sccm = 0,
542 Nccm = 1,
543 Slpm = 2,
544 Nlpm = 3,
545 SmLs = 4,
546 NmLs = 5,
547 SmLm = 6,
548 NmLm = 7,
549 SLh = 8,
550 NLh = 9,
551 Sccs = 10,
552 Nccs = 11,
553 Sm3h = 12,
554 Nm3h = 13,
555 Sm3d = 14,
556 Nm3d = 15,
557 Scim = 16,
558 Scfm = 17,
559 Scfh = 18,
560 Scfd = 19,
561 Other = 20,
562};
563
566 bool mass_flow_over{false};
567 bool temperature_over{false};
568 bool totalizer_over{false};
569 bool valve_hold{false};
570 bool valve_thermal{false};
571 uint8_t unknown_count{0};
572
574 [[nodiscard]] constexpr bool AnyFault() const noexcept {
576 }
578 friend constexpr bool operator==(const StatusFlags&, const StatusFlags&) = default;
579};
580
587[[nodiscard]] constexpr StatusFlags StatusFromBits(uint32_t bits) noexcept {
588 StatusFlags s{};
589 s.mass_flow_over = (bits & 1U) != 0U;
590 s.temperature_over = (bits & 2U) != 0U;
591 s.totalizer_over = (bits & 4U) != 0U;
592 s.valve_hold = (bits & 8U) != 0U;
593 s.valve_thermal = (bits & 16U) != 0U;
594 s.unknown_count = ((bits & 0xFFFF'FFE0U) != 0U) ? 1U : 0U;
595 return s;
596}
597
613
615inline constexpr std::size_t kTextMax = 24;
616
618struct Text {
619 std::array<char, kTextMax + 1U> chars{};
620 uint8_t length{0};
621};
622
624struct Ramp {
626 uint8_t time_unit{0};
628 friend constexpr bool operator==(const Ramp&, const Ramp&) = default;
629};
630
632struct Gains {
633 uint16_t proportional{0};
634 uint16_t integral{0};
636 friend constexpr bool operator==(const Gains&, const Gains&) = default;
637};
638
646
655
664
670
672struct GasEntry {
673 uint8_t number{0};
674 uint16_t k_factor{0};
675 std::array<char, 7> label{};
676};
677
679struct GasTable {
680 std::array<GasEntry, 12> entries{};
681};
682
685struct GasList {
686 uint8_t count{0};
687 std::array<uint8_t, 12> numbers{};
688 bool raw{false};
690};
691
709
710namespace detail {
716struct Alternatives {
717 char id{'\0'};
718 uint8_t address{0};
719 uint32_t baud{0};
720 bool factory{false};
721};
722
727struct RecoverHeld {
728 bool abandoned{false};
729 bool unknown{false};
730 bool ready{false};
731 bool layout_known{false};
732 Identity identity{};
733 char unit_id{'A'};
734 uint8_t address{1};
735 uint32_t baud{38400};
736};
737} // namespace detail
738
740inline constexpr uint8_t kFlagCount = 5;
741
744namespace detail {
746[[nodiscard]] constexpr bool MaskValid(uint32_t mask) noexcept {
747 return (mask >= 1U) && (mask <= 255U);
748}
749template <>
750struct EnumLast<FlowUnit> {
751 static constexpr FlowUnit kValue = FlowUnit::Other;
752};
753template <>
754struct EnumLast<Baud> {
755 static constexpr Baud kValue = Baud::B115200;
756};
757template <>
758struct EnumLast<TotalizerLimit> {
759 static constexpr TotalizerLimit kValue = TotalizerLimit::ResetWithError;
760};
761template <>
762struct EnumLast<SetpointSource> {
763 static constexpr SetpointSource kValue = SetpointSource::UnsavedDigital;
764};
765template <>
766struct EnumLast<FullScaleItem> {
767 static constexpr FullScaleItem kValue = FullScaleItem::MaxTemperature;
768};
769} // namespace detail
770
771} // namespace alicat_basis2
772
773#endif // ALICAT_BASIS2_TYPES_HPP
Compile-time helpers of the ALICAT_BASIS2 driver: exact hook matching, typed register fields and enum...
The transaction machine of one serial line, shared by every instrument on it.
Definition alicat_basis2_uart_interface.hpp:169
Error
Why a call failed. Every call of the driver returns one of these in its Result.
Definition alicat_basis2_types.hpp:37
constexpr const char * GasName(uint8_t number) noexcept
The name of a gas of the nine of M p.15.
Definition alicat_basis2_types.hpp:438
constexpr std::size_t kTextMax
Maximum characters kept of a text reply.
Definition alicat_basis2_types.hpp:615
Baud
Serial speeds the instrument offers (NCB, Modbus 21; M p.17, p.25).
Definition alicat_basis2_types.hpp:524
TimeUnit
Time unit of the ramp command (SR r t, M p.12).
Definition alicat_basis2_types.hpp:473
TriggerMode
Measurement trigger bits (MT, Modbus 4200; M p.13 to 14).
Definition alicat_basis2_types.hpp:517
UnknownFlagPolicy
What happens with a flag token the manual does not list.
Definition alicat_basis2_types.hpp:242
DeviceKind
Whether the instrument is a meter (B series) or a controller (BC series).
Definition alicat_basis2_types.hpp:227
FrameLayout
Which data frame layout is accepted (assumption A2: a meter's frame is not shown in the manual).
Definition alicat_basis2_types.hpp:235
constexpr std::size_t kMaxLine
Largest line or frame the driver buffers: the gas list (GS *) reply can be this long.
Definition alicat_basis2_types.hpp:272
DataItem
Items of DV (a bit mask, M p.11).
Definition alicat_basis2_types.hpp:495
constexpr const char * GetDriverVersion() noexcept
The version as text, such as "0.1.0".
Definition alicat_basis2_types.hpp:139
constexpr uint32_t GetDriverVersionMinor() noexcept
Minor version of the driver.
Definition alicat_basis2_types.hpp:131
Protocol
The command protocol one Basis2 object speaks.
Definition alicat_basis2_types.hpp:221
CommandProtocol
Command protocol selector (P, Modbus 56).
Definition alicat_basis2_types.hpp:534
SetpointSource
Setpoint source (LSS, Modbus 516; M p.11 to 12 and p.19).
Definition alicat_basis2_types.hpp:465
TotalizerLimit
Totalizer limit behaviour (TC, Modbus 54; M p.16).
Definition alicat_basis2_types.hpp:480
FullScaleItem
The item read by FPF (M p.16).
Definition alicat_basis2_types.hpp:488
constexpr const char * ToString(Error error) noexcept
The name of an error, for logs.
Definition alicat_basis2_types.hpp:79
FlowUnit
Flow units (Modbus register 49, M p.26; M p.31).
Definition alicat_basis2_types.hpp:540
LogLevel
Severity passed to the optional Log() hook.
Definition alicat_basis2_types.hpp:213
FirmwareGate
Whether the firmware gates of the register and command tables are enforced.
Definition alicat_basis2_types.hpp:261
constexpr uint8_t operator|(DataItem a, DataItem b) noexcept
Union of DataItem bits.
Definition alicat_basis2_types.hpp:508
constexpr uint32_t GetDriverVersionPatch() noexcept
Patch version of the driver.
Definition alicat_basis2_types.hpp:135
EchoMode
Whether a half-duplex wiring that hears its own transmission is handled.
Definition alicat_basis2_types.hpp:248
constexpr Error Validate(const Config &c) noexcept
Check a configuration against the documented ranges.
Definition alicat_basis2_types.hpp:364
constexpr uint8_t kDecimalsUnset
"Not set" marker of Config::modbus_flow_decimals: Begin() fails in Modbus mode while it is.
Definition alicat_basis2_types.hpp:269
constexpr uint32_t GetDriverVersionMajor() noexcept
Major version of the driver, from the generated alicat_basis2_version.h.
Definition alicat_basis2_types.hpp:127
constexpr uint8_t kFlagCount
Position of the unit ID in a StatusFlags text: helper used by tests.
Definition alicat_basis2_types.hpp:740
constexpr StatusFlags StatusFromBits(uint32_t bits) noexcept
Decode status bits (Modbus register 2101 or an integer DV status): +1 MOV, +2 TOV,...
Definition alicat_basis2_types.hpp:587
VerifyPolicy
Whether a setpoint is read back after it was set.
Definition alicat_basis2_types.hpp:254
@ VerifyMismatch
The read-back after a setter differs from what was written.
@ Overflow
The reply exceeded the line buffer without a terminator.
@ StateUnknown
A guarded command may have changed the line settings and was not confirmed.
@ InvalidArgument
An argument or a Config field is out of range; nothing was sent.
@ OutOfRange
A decoded value is outside what the instrument can physically report.
@ DeviceIdMismatch
The reply carried another unit ID or Modbus address than the one addressed.
@ RateLimited
A saved-source setpoint change came sooner than the non-volatile memory allows.
@ Crc
Modbus CRC-16 mismatch; the whole frame is discarded.
@ GuardNotConfirmed
A guarded call was made with a confirmation token of the wrong kind.
@ Bus
Write() returned false; nothing is pending afterwards.
@ BadReply
The line does not match the command's reply grammar.
@ DeviceFault
Reserved for the instrument's own fault reports.
@ NotInitialized
EnsureInitialized() failed, or Begin() has not run where the call needs it.
@ Ok
The call succeeded.
@ Unsupported
The feature is absent in this mode, on this kind of instrument, or on this port.
@ Timeout
No complete reply line (or frame) within the computed time.
@ Rejected
The instrument answered with the error token ? or a Modbus exception reply.
@ FirmwareTooOld
The call needs a newer firmware than the identity says.
@ B38400
Code 3, the default.
@ B4800
Modbus code 0.
@ B57600
Code 4 (firmware 2.2.2).
@ B115200
Code 5 (firmware 2.2.2).
@ OnHoldChange
+2: a hold-percent change while held.
@ OnAverageRead
+4: reading the average flow starts the next measurement.
@ OnSetpointChange
+1: a digital setpoint change starts a measurement.
@ Report
Count it in StatusFlags::unknown_count and return the frame.
@ Reject
BadReply; no value is exposed.
@ Auto
Learn it at Begin() from the first data frame (five numbers: controller).
@ Meter
B series: no setpoint, no valve.
@ Auto
Learn from the first valid frame, reject a later frame of the other layout.
@ Ascii
"BASIS Protocol 2": ASCII lines, the default (M p.10 to 17).
@ ModbusRtu
Modbus RTU, functions 3, 6 and 16 (M p.18 to 27).
@ BasisProtocol2
The ASCII protocol this driver speaks.
@ BasisProtocol1
The older protocol; the driver does not speak it (A14).
@ Analog
a: the analog input; digital setpoint commands are not accepted.
@ UnsavedDigital
u: recommended for frequent changes.
@ SavedDigital
s: the last digital setpoint is used at power-up; wears non-volatile memory.
@ ResetWithError
Reset to zero, OVR.
@ ResetNoError
Reset to zero, no OVR.
@ HoldNoError
Keep at the maximum, no OVR.
@ HoldWithError
Keep at the maximum, OVR.
@ MaxTemperature
Maximum temperature.
@ TotalVolume
Largest total volume or batch.
@ Other
A label not in the table of M p.31; the raw text is kept.
@ Warning
Something unexpected that the driver recovered from.
@ Info
Lifecycle events.
@ Debug
Detail for bring-up.
@ Enforce
A call that needs a newer firmware than the identity says fails with FirmwareTooOld.
@ Ignore
Never refuse on the firmware version.
@ None
The reply is the first line.
@ Skip
A first line equal to the command just sent is dropped once.
@ WhenNoRamp
Read it back unless a setpoint ramp is active (the instrument then lags on purpose).
constexpr GasId kHydrogen
H2.
Definition alicat_basis2_types.hpp:428
constexpr GasId kArgon
Ar.
Definition alicat_basis2_types.hpp:423
constexpr GasId kNitrogen
N2.
Definition alicat_basis2_types.hpp:425
constexpr GasId kCarbonDioxide
CO2.
Definition alicat_basis2_types.hpp:424
constexpr GasId kAir
Clean dry air.
Definition alicat_basis2_types.hpp:422
constexpr GasId kOxygen
O2.
Definition alicat_basis2_types.hpp:426
constexpr GasId kNitrousOxide
N2O.
Definition alicat_basis2_types.hpp:427
constexpr GasId kHelium
He.
Definition alicat_basis2_types.hpp:429
constexpr GasId kMethane
CH4.
Definition alicat_basis2_types.hpp:430
The ALICAT_BASIS2 driver: everything it declares lives here; internals in detail.
Definition alicat_basis2.hpp:39
Result of ReadAverages(): the current or most recent measurement window.
Definition alicat_basis2_types.hpp:640
Decimal valve_drive
Modbus only (register 4209): instantaneous valve drive.
Definition alicat_basis2_types.hpp:644
Decimal temperature
Average temperature, C.
Definition alicat_basis2_types.hpp:642
uint32_t time_ms
ASCII: elapsed time; Modbus: samples x 2.5 ms.
Definition alicat_basis2_types.hpp:641
Decimal flow
Average flow.
Definition alicat_basis2_types.hpp:643
The driver's configuration. Every default is the instrument's factory value or a documented driver ch...
Definition alicat_basis2_types.hpp:279
uint32_t saved_setpoint_min_interval_ms
Minimum time between setpoints while the source is saved.
Definition alicat_basis2_types.hpp:317
uint8_t setpoint_decimals
Digits sent after the point in a setpoint.
Definition alicat_basis2_types.hpp:311
VerifyPolicy verify_setpoint
Whether a setpoint is read back.
Definition alicat_basis2_types.hpp:313
uint32_t baud
What the port runs at; sizes every timeout.
Definition alicat_basis2_types.hpp:287
uint16_t slow_command_ms
Reply wait of commands that may write non-volatile memory.
Definition alicat_basis2_types.hpp:293
uint16_t flow_margin_permille
Plausibility: the flow must not exceed the full scale times this over 1000.
Definition alicat_basis2_types.hpp:305
Protocol protocol
The protocol this object speaks.
Definition alicat_basis2_types.hpp:283
EchoMode echo
Whether a first line equal to the command is dropped (half-duplex wiring that hears itself).
Definition alicat_basis2_types.hpp:303
uint16_t restore_holdoff_ms
Quiet time after FACTORY RESTORE.
Definition alicat_basis2_types.hpp:295
int16_t temperature_max_c
Plausibility upper limit of the temperature, C.
Definition alicat_basis2_types.hpp:309
DeviceKind kind
Meter or controller; Auto learns it at Begin().
Definition alicat_basis2_types.hpp:289
UnknownFlagPolicy unknown_flags
What happens with a status flag the manual does not list.
Definition alicat_basis2_types.hpp:301
uint8_t modbus_address
Modbus address 1 to 247.
Definition alicat_basis2_types.hpp:285
uint16_t assume_firmware
0 unknown; else 256a + 16b + c, used when the instrument gives no firmware.
Definition alicat_basis2_types.hpp:321
uint16_t verify_tolerance_permille
Read-back tolerance in permille of the full scale.
Definition alicat_basis2_types.hpp:315
uint16_t processing_ms
Instrument turnaround added to every reply wait.
Definition alicat_basis2_types.hpp:291
uint8_t read_retries
Retries of a read after a failed transaction; writes never repeat.
Definition alicat_basis2_types.hpp:297
uint8_t modbus_flow_decimals
Required in Modbus mode: 0 to 6 (the decimals are not readable over Modbus).
Definition alicat_basis2_types.hpp:323
FirmwareGate firmware_gate
Whether the firmware gates of the register and command tables are enforced.
Definition alicat_basis2_types.hpp:319
int16_t temperature_min_c
Plausibility lower limit of the temperature, C.
Definition alicat_basis2_types.hpp:307
FrameLayout frame_layout
Which data frame layout is accepted.
Definition alicat_basis2_types.hpp:299
uint32_t full_scale_override_milli
0 learns the full scale at Begin(); else flow units times 1000.
Definition alicat_basis2_types.hpp:325
char unit_id
ASCII unit ID, A to Z (M p.10).
Definition alicat_basis2_types.hpp:281
An exact decimal number as the instrument printed it: +0021513.0 is {215130, 1}.
Definition alicat_basis2_types.hpp:375
uint8_t decimals
Digits after the point.
Definition alicat_basis2_types.hpp:377
int64_t mantissa
The number without its decimal point.
Definition alicat_basis2_types.hpp:376
constexpr double ToDouble() const noexcept
Definition alicat_basis2_types.hpp:381
constexpr int64_t ToMilli() const noexcept
Definition alicat_basis2_types.hpp:390
friend constexpr bool operator==(const Decimal &, const Decimal &)=default
Equal mantissa and equal decimal count (hidden friend, MISRA C++:2023 Rule 16.6.1).
One data frame (A) or a DV selection; present says which fields were read.
Definition alicat_basis2_types.hpp:599
Decimal flow
In the configured flow unit.
Definition alicat_basis2_types.hpp:602
Decimal setpoint
Same unit as the flow; controllers only.
Definition alicat_basis2_types.hpp:603
StatusFlags status
Flags.
Definition alicat_basis2_types.hpp:611
Decimal batch_remaining
Same unit as the total.
Definition alicat_basis2_types.hpp:607
uint8_t present
DataItem bits whose fields are set.
Definition alicat_basis2_types.hpp:600
Decimal valve_drive
Percent of full drive; controllers only.
Definition alicat_basis2_types.hpp:605
bool gas_known
The gas token was one of the nine names (or a number in Modbus mode).
Definition alicat_basis2_types.hpp:609
Decimal temperature
C.
Definition alicat_basis2_types.hpp:604
Decimal total
In the instrument's volume unit.
Definition alicat_basis2_types.hpp:606
std::array< char, 9 > gas_name
The gas token as printed (ASCII only), NUL terminated.
Definition alicat_basis2_types.hpp:610
GasId gas
Valid when gas_known.
Definition alicat_basis2_types.hpp:608
char unit_id
The unit ID of the reply, upper case.
Definition alicat_basis2_types.hpp:601
One reading of FPF: a value and its unit text.
Definition alicat_basis2_types.hpp:666
Text unit
The unit label as printed.
Definition alicat_basis2_types.hpp:668
Decimal value
The value.
Definition alicat_basis2_types.hpp:667
Closed-loop gains (LCG, Modbus 519 and 520).
Definition alicat_basis2_types.hpp:632
uint16_t integral
I gain.
Definition alicat_basis2_types.hpp:634
friend constexpr bool operator==(const Gains &, const Gains &)=default
Hidden-friend equality.
uint16_t proportional
P gain.
Definition alicat_basis2_types.hpp:633
One entry of the gas table of firmware 3.0.5 (Modbus 81 to 140, M p.26 to 27).
Definition alicat_basis2_types.hpp:672
uint16_t k_factor
4096 = 1.0.
Definition alicat_basis2_types.hpp:674
uint8_t number
Gas number 0 to 255.
Definition alicat_basis2_types.hpp:673
std::array< char, 7 > label
Up to six characters, NUL terminated.
Definition alicat_basis2_types.hpp:675
A gas number. Not a closed enumeration: the V3.0.5 gas table allows numbers up to 255 (A5).
Definition alicat_basis2_types.hpp:414
friend constexpr bool operator==(const GasId &, const GasId &)=default
Hidden-friend equality.
uint8_t number
The gas number (M p.15).
Definition alicat_basis2_types.hpp:415
Result of ReadGasList(): the parsed pairs, or the raw text when the grammar did not match (A5).
Definition alicat_basis2_types.hpp:685
Text text
Up to 24 characters of the reply.
Definition alicat_basis2_types.hpp:689
uint8_t count
Parsed entries.
Definition alicat_basis2_types.hpp:686
std::array< uint8_t, 12 > numbers
Gas numbers.
Definition alicat_basis2_types.hpp:687
bool raw
The text did not parse; text holds it.
Definition alicat_basis2_types.hpp:688
The whole gas table: twelve entries.
Definition alicat_basis2_types.hpp:679
std::array< GasEntry, 12 > entries
The entries.
Definition alicat_basis2_types.hpp:680
What Begin() learned: read-only knowledge of the instrument.
Definition alicat_basis2_types.hpp:693
bool full_scale_known
full_scale is set.
Definition alicat_basis2_types.hpp:700
DeviceKind kind
Meter or controller.
Definition alicat_basis2_types.hpp:694
Text serial
Serial number text.
Definition alicat_basis2_types.hpp:698
FlowUnit flow_unit
The unit learned from the FPF text or register 49.
Definition alicat_basis2_types.hpp:701
uint16_t firmware
256a + 16b + c.
Definition alicat_basis2_types.hpp:696
bool source_known
source is set.
Definition alicat_basis2_types.hpp:706
GasId gas
The gas at Begin().
Definition alicat_basis2_types.hpp:703
bool firmware_known
firmware is set.
Definition alicat_basis2_types.hpp:695
Text firmware_text
As printed.
Definition alicat_basis2_types.hpp:697
bool gas_known
gas is set.
Definition alicat_basis2_types.hpp:704
bool ramp_active
A ramp is configured, so a setpoint read-back lags.
Definition alicat_basis2_types.hpp:707
SetpointSource source
Last known source.
Definition alicat_basis2_types.hpp:705
Text unit_label
The label as printed.
Definition alicat_basis2_types.hpp:702
Decimal full_scale
Full scale flow.
Definition alicat_basis2_types.hpp:699
Result of ReadPreviousMeasurement() (Modbus only, registers 4210 to 4215).
Definition alicat_basis2_types.hpp:657
Decimal max_flow
Register 4211.
Definition alicat_basis2_types.hpp:659
uint16_t samples
Register 4212.
Definition alicat_basis2_types.hpp:660
Decimal min_flow
Register 4210.
Definition alicat_basis2_types.hpp:658
Decimal temperature
Register 4213, C.
Definition alicat_basis2_types.hpp:661
Decimal average_flow
Registers 4214 to 4215, signed 32-bit.
Definition alicat_basis2_types.hpp:662
Result of ReadRamp(): rate and time unit as the instrument reported them.
Definition alicat_basis2_types.hpp:624
friend constexpr bool operator==(const Ramp &, const Ramp &)=default
Hidden-friend equality.
Decimal rate
0 means ramping is disabled.
Definition alicat_basis2_types.hpp:625
uint8_t time_unit
3, 4 or 5 (TimeUnit); 0 in Modbus mode (the unit is fixed there).
Definition alicat_basis2_types.hpp:626
Result of ReadRanges().
Definition alicat_basis2_types.hpp:648
Decimal min_flow
Flow units.
Definition alicat_basis2_types.hpp:652
uint32_t time_ms
As Averages::time_ms.
Definition alicat_basis2_types.hpp:649
Decimal max_flow
Flow units.
Definition alicat_basis2_types.hpp:653
Decimal min_temperature
C.
Definition alicat_basis2_types.hpp:650
Decimal max_temperature
C.
Definition alicat_basis2_types.hpp:651
constexpr bool ok() const noexcept
Definition alicat_basis2_types.hpp:190
static constexpr Result Success() noexcept
Definition alicat_basis2_types.hpp:199
static constexpr Result Failure(Error e) noexcept
A failed result.
Definition alicat_basis2_types.hpp:207
The value of a call, or why there is none.
Definition alicat_basis2_types.hpp:151
Error error
Error::Ok on success.
Definition alicat_basis2_types.hpp:153
constexpr bool ok() const noexcept
Definition alicat_basis2_types.hpp:156
static constexpr Result Failure(Error e) noexcept
A failed result.
Definition alicat_basis2_types.hpp:177
static constexpr Result Success(T v) noexcept
A successful result.
Definition alicat_basis2_types.hpp:169
Status flags of a data frame or of Modbus register 2101 (M p.10, p.21).
Definition alicat_basis2_types.hpp:565
bool temperature_over
TOV, Modbus +2.
Definition alicat_basis2_types.hpp:567
friend constexpr bool operator==(const StatusFlags &, const StatusFlags &)=default
Hidden-friend equality.
uint8_t unknown_count
Flag tokens or bits the manual does not list.
Definition alicat_basis2_types.hpp:571
bool valve_thermal
VTM, Modbus +16: thermal management (an override, not a fault).
Definition alicat_basis2_types.hpp:570
constexpr bool AnyFault() const noexcept
Definition alicat_basis2_types.hpp:574
bool valve_hold
HLD, Modbus +8: valve held by the user (an override, not a fault).
Definition alicat_basis2_types.hpp:569
bool mass_flow_over
MOV, Modbus +1.
Definition alicat_basis2_types.hpp:566
bool totalizer_over
OVR, Modbus +4.
Definition alicat_basis2_types.hpp:568
A short text value (serial number, firmware, unit label), NUL terminated.
Definition alicat_basis2_types.hpp:618
std::array< char, kTextMax+1U > chars
The characters.
Definition alicat_basis2_types.hpp:619
uint8_t length
Their number.
Definition alicat_basis2_types.hpp:620