Sign in

    moonbit-modbus

    A portable Modbus RTU, ASCII, and TCP protocol stack with device simulation and gateway primitives for MoonBit.

    modbus
    industrial
    protocol
    rtu
    ascii
    tcp
    plc
    Download zip
    Version
    0.2.2
    License
    Apache-2.0
    Last updated
    last month
    Downloads
    19

    #moonbit-modbus

    moonbit-modbus 是一个面向工业设备接入的 MoonBit Modbus 协议栈。它把 PDU、RTU、ASCII 和 TCP MBAP 统一到同一套类型安全 API,并提供设备内存、客户端事务、轮询、网关和虚拟链路等可组合模块,适合 PLC、变频器、仪表、数据采集器和协议测试工具。

    #核心能力

    • 协议编解码:Modbus RTU、ASCII、TCP,CRC16、LRC、MBAP 事务标识和异常响应。
    • 功能码覆盖:线圈、离散输入、保持寄存器、输入寄存器的读写,以及掩码写、读写组合、诊断、事件计数器、文件记录、设备识别和 FIFO。
    • 流式处理:有界增量解析器支持分段输入、多帧输入和坏帧恢复,避免无界缓存。
    • 设备与内存:寄存器/线圈 bank、地址空间、schema、文件记录存储、设备状态和异常统计。
    • 应用层服务:设备 profile、缩放校准、质量管线、告警引擎、历史聚合、维护工单、设备库存和快照对账。
    • 集成组件:客户端重试与超时、请求规划、轮询分组合并、命令中心、事务批处理、网关策略、租约和事件总线。
    • 运行保障:协议准入防护、容量账本、可靠性熔断、确定性故障场景、健康汇总、指标导出和配置迁移回滚。
    • 工程质量:无第三方运行时依赖,支持 native、wasm 和 wasm-gc 目标;公共接口生成 .mbti 文件并由 CI 校验。

    #快速开始

    需要已安装 MoonBit stable 工具链。仓库根目录执行:

    moon update moon check --target all --deny-warn moon test --target all --deny-warn moon run cmd/main

    最小 API 示例:

    ///|
    let request = @moonbit-modbus.read_holding(1, 0, 4)

    ///|
    let rtu_bytes = @moonbit-modbus.encode_rtu(request)

    ///|
    let parsed = @moonbit-modbus.decode_rtu(rtu_bytes)

    增量解析示例:

    ///|
    let parser = @moonbit-modbus.IncrementalParser::new(@moonbit-modbus.rtu_mode())

    ///|
    let frames = parser.feed(rtu_bytes)

    #CLI

    仓库包含两个可直接运行的示例程序:

    # 展示请求编码、虚拟设备处理和响应格式化 moon run --target native cmd/main # 运行 1000 次 CRC、RTU、TCP 和设备读工作负载 moon run --target native cmd/bench

    cmd/bench 输出确定性的迭代次数、成功数、失败数和处理字节数;独立的端到端命令耗时记录在 BENCHMARK.md。

    #架构

    代码按协议边界拆分为几个层次:

    1. types.mbt、validation.mbt 和 limits.mbt 定义公共类型、功能码、异常码和边界规则。
    2. codec.mbt、checksum.mbt、parser.mbt 和 frame_text.mbt 负责 PDU/ADU 编解码、校验和流式解析。
    3. functions.mbt、responses.mbt、coils.mbt、register_codec.mbt 和 file_records.mbt 提供功能码与数据表示。
    4. banks.mbt、device.mbt、register_schema.mbt 和 address_space.mbt 组成可测试的设备内存层。
    5. client.mbt、transport.mbt、polling.mbt、poll_groups.mbt、gateway.mbt、gateway_policy.mbt、server_pool.mbt 和 simulation.mbt 提供系统集成能力。
    6. profiles.mbt、scaling.mbt、quality_pipeline.mbt、alarms.mbt、historian.mbt、maintenance.mbt、device_inventory.mbt 和 device_services.mbt 提供设备应用层能力。
    7. commands.mbt、transaction_batch.mbt、scheduler.mbt、lease_manager.mbt、event_bus.mbt、protocol_guard.mbt 和 capacity.mbt 负责控制面编排与资源边界。
    8. reliability.mbt、analytics.mbt、fleet_health.mbt、observability.mbt、transport_metrics.mbt、scenarios.mbt、data_migration.mbt 和 frame_contracts.mbt 提供运维、验证和可观测性。

    核心层只依赖 MoonBit 标准能力;真实串口和 TCP socket 可在上层适配,而不改变协议模型和测试夹具。

    #基准

    基准使用 native 目标和固定的 1000 次迭代,覆盖 CRC16、RTU 编解码往返、TCP 编解码往返和设备读路径。结果分为确定性工作量统计与主机端到端耗时两部分,避免把不同机器的时钟结果伪装成协议吞吐率。复现实验方法和原始测量值见 BENCHMARK.md。

    #测试

    测试覆盖正常路径和边界路径,包括:

    • 地址、单位号、数量、PDU/ADU 长度、字节计数和广播请求边界;
    • CRC/LRC、ASCII/TCP/RTU 错帧、分段输入、多帧输入和截断输入;
    • 线圈 bit packing、寄存器字节序、32/64 位数值、游标越界和写入器容量;
    • 设备读写、异常响应、busy 状态、文件记录、设备识别、客户端事务和网关映射;
    • schema、轮询分组、批处理、事务回滚、配置迁移、租约、协议准入、事件死信、设备快照对账和文本帧工具;
    • 拓扑路径、可靠性熔断、告警迟滞、质量边界、维护到期、确定性故障注入和容量超限。

    本地质量门槛:

    moon fmt --check moon info moon check --target all --deny-warn moon test --target all --deny-warn

    #CI

    .github/workflows/check.yml 在 Ubuntu、macOS 和 Windows 上安装 MoonBit stable,执行 moon update、格式检查、全目标检查、构建、测试、CLI smoke test 和 .mbti 清洁工作树校验。.github/workflows/publish.yml 仅支持手动触发,用于在配置发布凭据后执行 Mooncakes 发布流程。

    #许可证

    本项目采用 Apache-2.0 许可证。协议实现依据公开的 Modbus 应用协议与串行链路规范重新实现,源码和测试夹具均保留在本仓库中。

    AccessOperation

    pub(all) enum AccessOperation {
    ReadOperation
    WriteOperation
    DiagnosticsOperation
    IdentificationOperation
    } derive(Eq,
    Debug
    )

    High-level operation guarded by an access policy.

    AccessPolicy

    pub(all) struct AccessPolicy {
    rules : Array[AccessRule]
    max_rules : Int
    default_allow : Bool
    }

    A first-match access policy with an explicit default decision.

    AccessPolicy::add

    fn AccessPolicy::add(self : AccessPolicy, rule : AccessRule) -> Result[Unit, ModbusError]

    AccessPolicy::allows

    fn AccessPolicy::allows(self : AccessPolicy, role : AccessRole, operation : AccessOperation, frame : Frame) -> Bool

    AccessPolicy::decision

    fn AccessPolicy::decision(self : AccessPolicy, role : AccessRole, operation : AccessOperation, frame : Frame) -> Result[Unit, ModbusError]

    AccessPolicy::length

    fn AccessPolicy::length(self : AccessPolicy) -> Int

    AccessPolicy::new

    fn AccessPolicy::new(default_allow? : Bool, max_rules? : Int) -> Result[AccessPolicy, ModbusError]

    AccessPolicy::remove

    fn AccessPolicy::remove(self : AccessPolicy, name : String) -> Result[AccessRule, ModbusError]

    AccessPolicy::rules

    AccessPolicy::set_default

    fn AccessPolicy::set_default(self : AccessPolicy, allow : Bool) -> Unit

    AccessPolicy::summary

    fn AccessPolicy::summary(self : AccessPolicy) -> String

    AccessRole

    pub(all) enum AccessRole {
    Observer
    Operator
    Engineer
    Administrator
    } derive(Eq,
    Debug
    )

    Role used by a deployment policy.

    AccessRule

    pub(all) struct AccessRule {
    name : String
    role : AccessRole
    operation : AccessOperation
    unit_start : Byte
    unit_end : Byte
    functions : Array[Byte]
    enabled : Bool
    }

    A rule matching unit ids and function codes.

    AccessRule::enabled

    fn AccessRule::enabled(self : AccessRule) -> Bool

    AccessRule::matches

    fn AccessRule::matches(self : AccessRule, role : AccessRole, operation : AccessOperation, frame : Frame) -> Bool

    AccessRule::name

    fn AccessRule::name(self : AccessRule) -> String

    AccessRule::new

    fn AccessRule::new(name : String, role : AccessRole, operation : AccessOperation, unit_start : Byte, unit_end : Byte, functions : Array[Byte]) -> Result[AccessRule, ModbusError]

    AccessRule::operation

    fn AccessRule::operation(self : AccessRule) -> AccessOperation

    AccessRule::role

    fn AccessRule::role(self : AccessRule) -> AccessRole

    AccessRule::set_enabled

    fn AccessRule::set_enabled(self : AccessRule, value : Bool) -> Unit

    AccessRule::summary

    fn AccessRule::summary(self : AccessRule) -> String

    AddressAllocator

    pub struct AddressAllocator {
    capacity : Int
    used : Array[AddressRange]
    }

    A first-fit allocator for contiguous register or coil ranges.

    AddressAllocator::allocate

    fn AddressAllocator::allocate(self : AddressAllocator, length : Int) -> Result[AddressRange, ModbusError]

    AddressAllocator::free_capacity

    fn AddressAllocator::free_capacity(self : AddressAllocator) -> Int

    AddressAllocator::new

    fn AddressAllocator::new(capacity : Int) -> Result[AddressAllocator, ModbusError]

    AddressAllocator::release

    fn AddressAllocator::release(self : AddressAllocator, range : AddressRange) -> Result[Unit, ModbusError]

    AddressAllocator::snapshot

    AddressAllocator::used_capacity

    fn AddressAllocator::used_capacity(self : AddressAllocator) -> Int

    AddressAllocator::used_count

    fn AddressAllocator::used_count(self : AddressAllocator) -> Int

    AddressRange

    pub(all) struct AddressRange {
    start : UInt16
    length : Int
    }

    A half-open address range in the Modbus 16-bit address space.

    AddressRange::contains

    fn AddressRange::contains(self : AddressRange, address : UInt16) -> Bool

    AddressRange::contains_range

    fn AddressRange::contains_range(self : AddressRange, other : AddressRange) -> Bool

    AddressRange::end_exclusive

    fn AddressRange::end_exclusive(self : AddressRange) -> Int

    AddressRange::length

    fn AddressRange::length(self : AddressRange) -> Int

    AddressRange::new

    fn AddressRange::new(start : UInt16, length : Int) -> Result[AddressRange, ModbusError]

    AddressRange::offset

    fn AddressRange::offset(self : AddressRange, address : UInt16) -> Result[Int, ModbusError]

    AddressRange::overlaps

    fn AddressRange::overlaps(self : AddressRange, other : AddressRange) -> Bool

    AddressRange::slice

    fn AddressRange::slice(self : AddressRange, offset : Int, length : Int) -> Result[AddressRange, ModbusError]

    AddressRange::split

    fn AddressRange::split(self : AddressRange, segment_length : Int) -> Result[Array[AddressRange], ModbusError]

    Split a range into non-overlapping segments of at most segment_length.

    AddressRange::start

    fn AddressRange::start(self : AddressRange) -> UInt16

    Aggregation

    pub(all) enum Aggregation {
    LastValue
    MinimumValue
    MaximumValue
    SumValue
    AverageValue
    CountValue
    } derive(Eq,
    Debug
    )

    Aggregation used when reducing samples for a dashboard or export.

    AlarmCondition

    pub(all) enum AlarmCondition {
    Below
    AtOrBelow
    Equal
    NotEqual
    AtOrAbove
    Above
    Outside
    Inside
    } derive(Eq,
    Debug
    )

    Comparison used by an alarm rule.

    AlarmEngine

    pub(all) struct AlarmEngine {
    instances : Array[AlarmInstance]
    events : Array[AlarmEvent]
    max_events : Int
    next_sequence : Int
    }

    A bounded alarm engine suitable for a device server or polling loop.

    AlarmEngine::acknowledge

    fn AlarmEngine::acknowledge(self : AlarmEngine, rule_id : String, operator : String, timestamp : Int) -> Result[AlarmEvent, ModbusError]

    AlarmEngine::active

    AlarmEngine::active_count

    fn AlarmEngine::active_count(self : AlarmEngine) -> Int

    AlarmEngine::add_rule

    fn AlarmEngine::add_rule(self : AlarmEngine, rule : AlarmRule) -> Result[Unit, ModbusError]

    AlarmEngine::clear_events

    fn AlarmEngine::clear_events(self : AlarmEngine) -> Unit

    AlarmEngine::evaluate

    fn AlarmEngine::evaluate(self : AlarmEngine, point_id : String, value : Int, timestamp : Int) -> Result[Array[AlarmEvent], ModbusError]

    AlarmEngine::event_count

    fn AlarmEngine::event_count(self : AlarmEngine) -> Int

    AlarmEngine::events

    fn AlarmEngine::events(self : AlarmEngine) -> Array[AlarmEvent]

    AlarmEngine::events_for_point

    fn AlarmEngine::events_for_point(self : AlarmEngine, point_id : String) -> Array[AlarmEvent]

    AlarmEngine::instance

    fn AlarmEngine::instance(self : AlarmEngine, rule_id : String) -> AlarmInstance?

    AlarmEngine::new

    fn AlarmEngine::new(max_events? : Int) -> Result[AlarmEngine, ModbusError]

    AlarmEngine::remove_rule

    fn AlarmEngine::remove_rule(self : AlarmEngine, rule_id : String) -> Result[Unit, ModbusError]

    AlarmEngine::reset

    fn AlarmEngine::reset(self : AlarmEngine) -> Unit

    AlarmEngine::rule_count

    fn AlarmEngine::rule_count(self : AlarmEngine) -> Int

    AlarmEngine::shelve

    fn AlarmEngine::shelve(self : AlarmEngine, rule_id : String, timestamp : Int) -> Result[AlarmEvent, ModbusError]

    AlarmEngine::summary

    fn AlarmEngine::summary(self : AlarmEngine) -> String

    AlarmEngine::unshelve

    fn AlarmEngine::unshelve(self : AlarmEngine, rule_id : String, timestamp : Int) -> Result[AlarmEvent, ModbusError]

    AlarmEvent

    pub(all) struct AlarmEvent {
    sequence : Int
    rule_id : String
    point_id : String
    state : AlarmState
    value : Int
    timestamp : Int
    severity : AlarmSeverity
    message : String
    } derive(
    Debug
    )

    An event emitted when an alarm lifecycle changes.

    AlarmEvent::message

    fn AlarmEvent::message(self : AlarmEvent) -> String

    AlarmEvent::point_id

    fn AlarmEvent::point_id(self : AlarmEvent) -> String

    AlarmEvent::rule_id

    fn AlarmEvent::rule_id(self : AlarmEvent) -> String

    AlarmEvent::sequence

    fn AlarmEvent::sequence(self : AlarmEvent) -> Int

    AlarmEvent::severity

    fn AlarmEvent::severity(self : AlarmEvent) -> AlarmSeverity

    AlarmEvent::state

    fn AlarmEvent::state(self : AlarmEvent) -> AlarmState

    AlarmEvent::summary

    fn AlarmEvent::summary(self : AlarmEvent) -> String

    AlarmEvent::timestamp

    fn AlarmEvent::timestamp(self : AlarmEvent) -> Int

    AlarmEvent::value

    fn AlarmEvent::value(self : AlarmEvent) -> Int

    AlarmInstance

    pub(all) struct AlarmInstance {
    rule : AlarmRule
    state : AlarmState
    pending_since : Int?
    clearing_since : Int?
    last_value : Int
    last_timestamp : Int
    transitions : Int
    acknowledger : String?
    }

    Internal state retained for one rule.

    AlarmInstance::acknowledge

    fn AlarmInstance::acknowledge(self : AlarmInstance, operator : String) -> Result[Unit, ModbusError]

    AlarmInstance::acknowledger

    fn AlarmInstance::acknowledger(self : AlarmInstance) -> String?

    AlarmInstance::evaluate

    fn AlarmInstance::evaluate(self : AlarmInstance, value : Int, timestamp : Int, sequence : Int) -> AlarmTransition

    Evaluate one new sample and update the instance lifecycle.

    AlarmInstance::id

    fn AlarmInstance::id(self : AlarmInstance) -> String

    AlarmInstance::is_active

    fn AlarmInstance::is_active(self : AlarmInstance) -> Bool

    AlarmInstance::last_timestamp

    fn AlarmInstance::last_timestamp(self : AlarmInstance) -> Int

    AlarmInstance::last_value

    fn AlarmInstance::last_value(self : AlarmInstance) -> Int

    AlarmInstance::new

    AlarmInstance::point_id

    fn AlarmInstance::point_id(self : AlarmInstance) -> String

    AlarmInstance::rule

    AlarmInstance::shelve

    fn AlarmInstance::shelve(self : AlarmInstance) -> Result[Unit, ModbusError]

    AlarmInstance::state

    AlarmInstance::transitions

    fn AlarmInstance::transitions(self : AlarmInstance) -> Int

    AlarmInstance::unshelve

    fn AlarmInstance::unshelve(self : AlarmInstance) -> Unit

    AlarmMonitor

    pub(all) struct AlarmMonitor {
    threshold : Threshold
    state : ThresholdState
    transitions : Int
    last_value : Int?
    }

    Stateful threshold monitor that counts state transitions.

    AlarmMonitor::last_value

    fn AlarmMonitor::last_value(self : AlarmMonitor) -> Int?

    AlarmMonitor::new

    fn AlarmMonitor::new(threshold : Threshold) -> AlarmMonitor

    AlarmMonitor::observe

    fn AlarmMonitor::observe(self : AlarmMonitor, value : Int) -> ThresholdState

    AlarmMonitor::reset

    fn AlarmMonitor::reset(self : AlarmMonitor) -> Unit

    AlarmMonitor::state

    AlarmMonitor::threshold

    fn AlarmMonitor::threshold(self : AlarmMonitor) -> Threshold

    AlarmMonitor::transitions

    fn AlarmMonitor::transitions(self : AlarmMonitor) -> Int

    AlarmRule

    pub(all) struct AlarmRule {
    id : String
    point_id : String
    condition : AlarmCondition
    low : Int
    high : Int
    severity : AlarmSeverity
    activation_delay : Int
    clear_delay : Int
    hysteresis : Int
    enabled : Bool
    }

    A declarative threshold rule attached to a profile point.

    AlarmRule::activation_delay

    fn AlarmRule::activation_delay(self : AlarmRule) -> Int

    AlarmRule::clear_delay

    fn AlarmRule::clear_delay(self : AlarmRule) -> Int

    AlarmRule::clear_matches

    fn AlarmRule::clear_matches(self : AlarmRule, value : Int) -> Bool

    AlarmRule::condition

    fn AlarmRule::condition(self : AlarmRule) -> AlarmCondition

    AlarmRule::enabled

    fn AlarmRule::enabled(self : AlarmRule) -> Bool

    AlarmRule::high

    fn AlarmRule::high(self : AlarmRule) -> Int

    AlarmRule::hysteresis

    fn AlarmRule::hysteresis(self : AlarmRule) -> Int

    AlarmRule::id

    fn AlarmRule::id(self : AlarmRule) -> String

    AlarmRule::low

    fn AlarmRule::low(self : AlarmRule) -> Int

    AlarmRule::matches

    fn AlarmRule::matches(self : AlarmRule, value : Int) -> Bool

    AlarmRule::new

    fn AlarmRule::new(id : String, point_id : String, condition : AlarmCondition, low : Int, high : Int, severity : AlarmSeverity, activation_delay? : Int, clear_delay? : Int, hysteresis? : Int) -> Result[AlarmRule, ModbusError]

    AlarmRule::point_id

    fn AlarmRule::point_id(self : AlarmRule) -> String

    AlarmRule::set_enabled

    fn AlarmRule::set_enabled(self : AlarmRule, enabled : Bool) -> Unit

    AlarmRule::severity

    fn AlarmRule::severity(self : AlarmRule) -> AlarmSeverity

    AlarmRule::summary

    fn AlarmRule::summary(self : AlarmRule) -> String

    AlarmSeverity

    pub(all) enum AlarmSeverity {
    Informational
    Warning
    Critical
    } derive(Eq,
    Debug
    )

    Severity assigned to an operational alarm.

    AlarmState

    pub(all) enum AlarmState {
    Normal
    Pending
    Active
    Acknowledged
    Clearing
    Shelved
    } derive(Eq,
    Debug
    )

    Lifecycle state of an alarm instance.

    AlarmTransition

    pub(all) enum AlarmTransition {
    Unchanged(AlarmState)
    Changed(AlarmEvent)
    } derive(
    Debug
    )

    A deterministic transition result used by polling and UI layers.

    AnalyticsReport

    pub(all) struct AnalyticsReport {
    direction : TrendDirection
    average : Int
    minimum : Int
    maximum : Int
    slope : Int
    anomalies : Int
    p95 : Int
    }

    Combined trend and distribution report.

    AnalyticsReport::anomalies

    fn AnalyticsReport::anomalies(self : AnalyticsReport) -> Int

    AnalyticsReport::average

    fn AnalyticsReport::average(self : AnalyticsReport) -> Int

    AnalyticsReport::direction

    AnalyticsReport::maximum

    fn AnalyticsReport::maximum(self : AnalyticsReport) -> Int

    AnalyticsReport::minimum

    fn AnalyticsReport::minimum(self : AnalyticsReport) -> Int

    AnalyticsReport::p95

    fn AnalyticsReport::p95(self : AnalyticsReport) -> Int

    AnalyticsReport::slope

    fn AnalyticsReport::slope(self : AnalyticsReport) -> Int

    AnalyticsRule

    pub(all) struct AnalyticsRule {
    id : String
    lower : Int?
    upper : Int?
    spike_delta : Int
    flatline_delta : Int
    flatline_count : Int
    }

    A limit and deviation rule applied to a series.

    AnalyticsRule::evaluate

    fn AnalyticsRule::evaluate(self : AnalyticsRule, window : AnalyticsWindow) -> Array[ValueAnomaly]

    AnalyticsRule::flatline_count

    fn AnalyticsRule::flatline_count(self : AnalyticsRule) -> Int

    AnalyticsRule::flatline_delta

    fn AnalyticsRule::flatline_delta(self : AnalyticsRule) -> Int

    AnalyticsRule::id

    fn AnalyticsRule::id(self : AnalyticsRule) -> String

    AnalyticsRule::lower

    fn AnalyticsRule::lower(self : AnalyticsRule) -> Int?

    AnalyticsRule::new

    fn AnalyticsRule::new(id : String, lower? : Int, upper? : Int, spike_delta? : Int, flatline_delta? : Int, flatline_count? : Int) -> Result[AnalyticsRule, ModbusError]

    AnalyticsRule::spike_delta

    fn AnalyticsRule::spike_delta(self : AnalyticsRule) -> Int

    AnalyticsRule::upper

    fn AnalyticsRule::upper(self : AnalyticsRule) -> Int?

    AnalyticsSample

    pub(all) struct AnalyticsSample {
    timestamp : Int
    value : Int
    quality : ReadingQuality
    }

    A timestamped value used by trend and anomaly calculations.

    AnalyticsSample::new

    fn AnalyticsSample::new(timestamp : Int, value : Int, quality? : ReadingQuality) -> Result[AnalyticsSample, ModbusError]

    AnalyticsSample::quality

    AnalyticsSample::timestamp

    fn AnalyticsSample::timestamp(self : AnalyticsSample) -> Int

    AnalyticsSample::usable

    fn AnalyticsSample::usable(self : AnalyticsSample) -> Bool

    AnalyticsSample::value

    fn AnalyticsSample::value(self : AnalyticsSample) -> Int

    AnalyticsWindow

    pub(all) struct AnalyticsWindow {
    id : String
    capacity : Int
    samples : Array[AnalyticsSample]
    dropped : Int
    }

    A bounded time series with deterministic order guarantees.

    AnalyticsWindow::append

    fn AnalyticsWindow::append(self : AnalyticsWindow, sample : AnalyticsSample) -> Result[Unit, ModbusError]

    AnalyticsWindow::at

    fn AnalyticsWindow::at(self : AnalyticsWindow, index : Int) -> Result[AnalyticsSample, ModbusError]

    AnalyticsWindow::average

    fn AnalyticsWindow::average(self : AnalyticsWindow) -> Result[Int, ModbusError]

    AnalyticsWindow::capacity

    fn AnalyticsWindow::capacity(self : AnalyticsWindow) -> Int

    AnalyticsWindow::direction

    fn AnalyticsWindow::direction(self : AnalyticsWindow, threshold : Int) -> Result[TrendDirection, ModbusError]

    AnalyticsWindow::dropped

    fn AnalyticsWindow::dropped(self : AnalyticsWindow) -> Int

    AnalyticsWindow::first

    AnalyticsWindow::id

    fn AnalyticsWindow::id(self : AnalyticsWindow) -> String

    AnalyticsWindow::last

    AnalyticsWindow::length

    fn AnalyticsWindow::length(self : AnalyticsWindow) -> Int

    AnalyticsWindow::maximum

    fn AnalyticsWindow::maximum(self : AnalyticsWindow) -> Result[Int, ModbusError]

    AnalyticsWindow::minimum

    fn AnalyticsWindow::minimum(self : AnalyticsWindow) -> Result[Int, ModbusError]

    AnalyticsWindow::new

    fn AnalyticsWindow::new(id : String, capacity? : Int) -> Result[AnalyticsWindow, ModbusError]

    AnalyticsWindow::range

    fn AnalyticsWindow::range(self : AnalyticsWindow) -> Result[Int, ModbusError]

    AnalyticsWindow::slope

    fn AnalyticsWindow::slope(self : AnalyticsWindow) -> Result[Int, ModbusError]

    AnalyticsWindow::usable_values

    fn AnalyticsWindow::usable_values(self : AnalyticsWindow) -> Array[Int]

    AnomalyKind

    pub(all) enum AnomalyKind {
    UpperLimitAnomaly
    LowerLimitAnomaly
    SpikeAnomaly
    FlatlineAnomaly
    RateAnomaly
    } derive(Eq,
    Debug
    )

    Reason a sample was flagged by an analytics rule.

    AuditEntry

    pub(all) struct AuditEntry {
    sequence : Int
    direction : String
    mode : Mode
    transaction_id : UInt16
    summary : FrameSummary
    outcome : String
    }

    A trace record suitable for debugging a gateway or device exchange.

    AuditLog

    pub struct AuditLog {
    entries : Array[AuditEntry]
    max_entries : Int
    next_sequence : Int
    }

    AuditLog::clear

    fn AuditLog::clear(self : AuditLog) -> Unit

    AuditLog::length

    fn AuditLog::length(self : AuditLog) -> Int

    AuditLog::new

    fn AuditLog::new(max_entries? : Int) -> Result[AuditLog, ModbusError]

    AuditLog::record

    fn AuditLog::record(self : AuditLog, direction : String, mode : Mode, transaction_id : UInt16, frame : Frame, outcome : String) -> Unit

    AuditLog::snapshot

    fn AuditLog::snapshot(self : AuditLog) -> Array[AuditEntry]

    BatchItem

    pub(all) struct BatchItem {
    id : Int
    request : Frame
    }

    A named request in a batch operation.

    BatchItem::new

    fn BatchItem::new(id : Int, request : Frame) -> Result[BatchItem, ModbusError]

    BatchPlan

    pub struct BatchPlan {
    items : Array[BatchItem]
    max_items : Int
    }

    An ordered batch plan used to pipeline independent requests.

    BatchPlan::add

    fn BatchPlan::add(self : BatchPlan, item : BatchItem) -> Result[Unit, ModbusError]

    BatchPlan::execute

    fn BatchPlan::execute(self : BatchPlan, device : Device) -> Array[BatchResult]

    Execute an ordered plan against a deterministic device.

    BatchPlan::item

    fn BatchPlan::item(self : BatchPlan, index : Int) -> Result[BatchItem, ModbusError]

    BatchPlan::length

    fn BatchPlan::length(self : BatchPlan) -> Int

    BatchPlan::new

    fn BatchPlan::new(max_items? : Int) -> Result[BatchPlan, ModbusError]

    BatchPlan::snapshot

    fn BatchPlan::snapshot(self : BatchPlan) -> Array[BatchItem]

    BatchResult

    pub(all) enum BatchResult {
    Completed(Int, Frame)
    Failed(Int, ModbusError)
    }

    The result of executing one batch item.

    BenchmarkResult

    pub(all) struct BenchmarkResult {
    name : String
    iterations : Int
    successful : Int
    failed : Int
    bytes : Int
    }

    Deterministic benchmark counters emitted by the command-line benchmark.

    BenchmarkResult::operations

    fn BenchmarkResult::operations(self : BenchmarkResult) -> Int

    BenchmarkResult::success_rate

    fn BenchmarkResult::success_rate(self : BenchmarkResult) -> Float

    BenchmarkResult::summary

    fn BenchmarkResult::summary(self : BenchmarkResult) -> String

    BitVector

    pub(all) struct BitVector {
    length : Int
    storage : Array[Byte]
    }

    A mutable bounded bit vector for coils and discrete inputs.

    BitVector::bit_and

    fn BitVector::bit_and(self : BitVector, other : BitVector) -> Result[BitVector, ModbusError]

    Apply a bitwise AND to two equally sized vectors.

    BitVector::byte_length

    fn BitVector::byte_length(self : BitVector) -> Int

    BitVector::copy

    fn BitVector::copy(self : BitVector) -> BitVector

    Copy a bit vector and keep its logical length.

    BitVector::count

    fn BitVector::count(self : BitVector) -> Int

    BitVector::equal

    fn BitVector::equal(self : BitVector, other : BitVector) -> Bool

    Compare two bit vectors including their logical lengths.

    BitVector::fill

    fn BitVector::fill(self : BitVector, value : Bool) -> Unit

    BitVector::from_bits

    fn BitVector::from_bits(values : Array[Bool]) -> BitVector

    BitVector::get

    fn BitVector::get(self : BitVector, index : Int) -> Result[Bool, ModbusError]

    BitVector::length

    fn BitVector::length(self : BitVector) -> Int

    BitVector::new

    fn BitVector::new(length : Int) -> Result[BitVector, ModbusError]

    Create a zero-filled bit vector.

    BitVector::not

    fn BitVector::not(self : BitVector) -> BitVector

    Invert all logical bits, keeping padding bits clear.

    BitVector::or

    fn BitVector::or(self : BitVector, other : BitVector) -> Result[BitVector, ModbusError]

    Apply a bitwise OR to two equally sized vectors.

    BitVector::pack_range

    fn BitVector::pack_range(self : BitVector, start : Int, quantity : Int) -> Result[Array[Byte], ModbusError]

    Pack a range of bits from a vector for a Modbus response.

    BitVector::set

    fn BitVector::set(self : BitVector, index : Int, value : Bool) -> Result[Unit, ModbusError]

    BitVector::shift_left

    fn BitVector::shift_left(self : BitVector, distance : Int) -> Result[BitVector, ModbusError]

    Shift logical bits left, dropping values that fall outside the vector.

    BitVector::shift_right

    fn BitVector::shift_right(self : BitVector, distance : Int) -> Result[BitVector, ModbusError]

    Shift logical bits right, dropping values that fall outside the vector.

    BitVector::to_bits

    fn BitVector::to_bits(self : BitVector) -> Array[Bool]

    BitVector::to_bytes

    fn BitVector::to_bytes(self : BitVector) -> Array[Byte]

    BitVector::unpack_into

    fn BitVector::unpack_into(self : BitVector, start : Int, quantity : Int, bytes : Array[Byte]) -> Result[Unit, ModbusError]

    Replace a range of bits from packed input bytes.

    BridgeAction

    pub(all) enum BridgeAction {
    ForwardBridge
    RewriteBridge
    DenyBridge
    AuditBridge
    RateLimitBridge
    } derive(Eq,
    Debug
    )

    Action taken when a frame matches a gateway policy rule.

    BridgeDecision

    pub(all) struct BridgeDecision {
    rule_id : String?
    action : BridgeAction
    frame : Frame?
    reason : String
    matched : Bool
    }

    Result of applying one gateway rule to a frame.

    BridgeDecision::action

    BridgeDecision::frame

    fn BridgeDecision::frame(self : BridgeDecision) -> Frame?

    BridgeDecision::matched

    fn BridgeDecision::matched(rule : ServiceBridgeRule, action : BridgeAction, frame : Frame?, reason : String) -> BridgeDecision

    BridgeDecision::matched_rule

    fn BridgeDecision::matched_rule(self : BridgeDecision) -> Bool

    BridgeDecision::new

    fn BridgeDecision::new(action : BridgeAction, reason : String) -> BridgeDecision

    BridgeDecision::reason

    fn BridgeDecision::reason(self : BridgeDecision) -> String

    BridgeDecision::rule_id

    fn BridgeDecision::rule_id(self : BridgeDecision) -> String?

    ByteQueue

    pub struct ByteQueue {
    data : Array[Byte]
    max_length : Int
    }

    A bounded byte queue for adapters that receive arbitrary chunk sizes.

    ByteQueue::clear

    fn ByteQueue::clear(self : ByteQueue) -> Unit

    ByteQueue::contains_sequence

    fn ByteQueue::contains_sequence(self : ByteQueue, pattern : Array[Byte]) -> Bool

    ByteQueue::find

    fn ByteQueue::find(self : ByteQueue, value : Byte) -> Int?

    ByteQueue::is_empty

    fn ByteQueue::is_empty(self : ByteQueue) -> Bool

    ByteQueue::length

    fn ByteQueue::length(self : ByteQueue) -> Int

    ByteQueue::new

    fn ByteQueue::new(max_length? : Int) -> Result[ByteQueue, ModbusError]

    ByteQueue::peek

    fn ByteQueue::peek(self : ByteQueue, index : Int) -> Result[Byte, ModbusError]

    ByteQueue::push

    fn ByteQueue::push(self : ByteQueue, bytes : Array[Byte]) -> Result[Unit, ModbusError]

    ByteQueue::push_byte

    fn ByteQueue::push_byte(self : ByteQueue, byte : Byte) -> Result[Unit, ModbusError]

    ByteQueue::remaining

    fn ByteQueue::remaining(self : ByteQueue) -> Int

    ByteQueue::snapshot

    fn ByteQueue::snapshot(self : ByteQueue) -> Array[Byte]

    ByteQueue::take

    fn ByteQueue::take(self : ByteQueue, count : Int) -> Result[Array[Byte], ModbusError]

    ByteQueue::take_all

    fn ByteQueue::take_all(self : ByteQueue) -> Array[Byte]

    CalibrationCurve

    pub(all) struct CalibrationCurve {
    samples : Array[CalibrationSample]
    max_samples : Int
    clamp : Bool
    }

    A monotonic calibration curve for sensors with non-linear error.

    CalibrationCurve::add

    fn CalibrationCurve::add(self : CalibrationCurve, sample : CalibrationSample) -> Result[Unit, ModbusError]

    CalibrationCurve::convert

    fn CalibrationCurve::convert(self : CalibrationCurve, raw : Int) -> Result[Int, ModbusError]

    CalibrationCurve::convert_many

    fn CalibrationCurve::convert_many(self : CalibrationCurve, values : Array[Int]) -> Result[Array[Int], ModbusError]

    CalibrationCurve::length

    fn CalibrationCurve::length(self : CalibrationCurve) -> Int

    CalibrationCurve::new

    fn CalibrationCurve::new(max_samples? : Int, clamp? : Bool) -> Result[CalibrationCurve, ModbusError]

    CalibrationCurve::raw_max

    fn CalibrationCurve::raw_max(self : CalibrationCurve) -> Result[Int, ModbusError]

    CalibrationCurve::raw_min

    fn CalibrationCurve::raw_min(self : CalibrationCurve) -> Result[Int, ModbusError]

    CalibrationCurve::sample

    fn CalibrationCurve::sample(self : CalibrationCurve, index : Int) -> Result[CalibrationSample, ModbusError]

    CalibrationCurve::snapshot

    CalibrationSample

    pub(all) struct CalibrationSample {
    raw : Int
    engineering : Int
    }

    A calibration sample used to build a piecewise-linear curve.

    CalibrationSample::engineering

    fn CalibrationSample::engineering(self : CalibrationSample) -> Int

    CalibrationSample::new

    fn CalibrationSample::new(raw : Int, engineering : Int) -> CalibrationSample

    CalibrationSample::raw

    fn CalibrationSample::raw(self : CalibrationSample) -> Int

    CapabilitySet

    pub(all) struct CapabilitySet {
    functions : Array[Byte]
    modes : Array[Mode]
    max_pdu : Int
    broadcasts : Bool
    }

    A set of capabilities expected from a server or gateway.

    CapabilitySet::add_function

    fn CapabilitySet::add_function(self : CapabilitySet, function : Byte) -> Result[Unit, ModbusError]

    CapabilitySet::add_mode

    fn CapabilitySet::add_mode(self : CapabilitySet, mode : Mode) -> Unit

    CapabilitySet::broadcasts

    fn CapabilitySet::broadcasts(self : CapabilitySet) -> Bool

    CapabilitySet::coverage

    fn CapabilitySet::coverage(self : CapabilitySet, expected : Array[Byte]) -> Int

    CapabilitySet::functions

    fn CapabilitySet::functions(self : CapabilitySet) -> Array[Byte]

    CapabilitySet::max_pdu

    fn CapabilitySet::max_pdu(self : CapabilitySet) -> Int

    CapabilitySet::modes

    fn CapabilitySet::modes(self : CapabilitySet) -> Array[Mode]

    CapabilitySet::new

    fn CapabilitySet::new(max_pdu? : Int, broadcasts? : Bool) -> Result[CapabilitySet, ModbusError]

    CapabilitySet::supports_function

    fn CapabilitySet::supports_function(self : CapabilitySet, function : Byte) -> Bool

    CapabilitySet::supports_mode

    fn CapabilitySet::supports_mode(self : CapabilitySet, mode : Mode) -> Bool

    CapabilitySet::validate_frame

    fn CapabilitySet::validate_frame(self : CapabilitySet, frame : Frame) -> Result[Unit, ModbusError]

    CapacityLedger

    pub(all) struct CapacityLedger {
    limits : Array[CapacityLimit]
    reservations : Array[CapacityReservation]
    max_reservations : Int
    sequence : Int
    }

    Multi-resource ledger for admission control.

    CapacityLedger::add_limit

    fn CapacityLedger::add_limit(self : CapacityLedger, limit : CapacityLimit) -> Result[Unit, ModbusError]

    CapacityLedger::expire

    fn CapacityLedger::expire(self : CapacityLedger, now : Int, age : Int) -> Result[Int, ModbusError]

    Expire all reservations older than a caller-supplied age.

    CapacityLedger::export_lines

    fn CapacityLedger::export_lines(self : CapacityLedger) -> Array[String]

    Human-readable capacity table for health endpoints.

    CapacityLedger::limit

    CapacityLedger::limit_count

    fn CapacityLedger::limit_count(self : CapacityLedger) -> Int

    CapacityLedger::new

    fn CapacityLedger::new(max_reservations? : Int) -> Result[CapacityLedger, ModbusError]

    CapacityLedger::pressure

    Return resources currently above their soft limit.

    CapacityLedger::release

    fn CapacityLedger::release(self : CapacityLedger, reservation_id : String) -> Result[Unit, ModbusError]

    Release a previously issued reservation exactly once.

    CapacityLedger::reservation_count

    fn CapacityLedger::reservation_count(self : CapacityLedger) -> Int

    CapacityLedger::reserve

    fn CapacityLedger::reserve(self : CapacityLedger, resource : CapacityResource, amount : Int, now : Int) -> Result[CapacityReservation, ModbusError]

    Reserve one resource atomically and create an expirable token.

    CapacityLedger::reset

    fn CapacityLedger::reset(self : CapacityLedger) -> Unit

    Reset all limits and reservation tokens after a controlled restart.

    CapacityLimit

    pub(all) struct CapacityLimit {
    resource : CapacityResource
    name : String
    soft_limit : Int
    hard_limit : Int
    used : Int
    }

    A named resource limit with soft and hard thresholds.

    CapacityLimit::available

    fn CapacityLimit::available(self : CapacityLimit) -> Int

    CapacityLimit::hard_limit

    fn CapacityLimit::hard_limit(self : CapacityLimit) -> Int

    CapacityLimit::name

    fn CapacityLimit::name(self : CapacityLimit) -> String

    CapacityLimit::new

    fn CapacityLimit::new(resource : CapacityResource, name : String, soft_limit : Int, hard_limit : Int) -> Result[CapacityLimit, ModbusError]

    CapacityLimit::over_hard

    fn CapacityLimit::over_hard(self : CapacityLimit) -> Bool

    CapacityLimit::over_soft

    fn CapacityLimit::over_soft(self : CapacityLimit) -> Bool

    CapacityLimit::release

    fn CapacityLimit::release(self : CapacityLimit, amount : Int) -> Result[Unit, ModbusError]

    CapacityLimit::reserve

    fn CapacityLimit::reserve(self : CapacityLimit, amount : Int) -> Result[Unit, ModbusError]

    CapacityLimit::reset

    fn CapacityLimit::reset(self : CapacityLimit) -> Unit

    CapacityLimit::resource

    CapacityLimit::soft_limit

    fn CapacityLimit::soft_limit(self : CapacityLimit) -> Int

    CapacityLimit::used

    fn CapacityLimit::used(self : CapacityLimit) -> Int

    CapacityReservation

    pub(all) struct CapacityReservation {
    id : String
    resource : CapacityResource
    amount : Int
    created_at : Int
    released : Bool
    }

    A reservation returned to a caller so releases can be audited.

    CapacityReservation::amount

    fn CapacityReservation::amount(self : CapacityReservation) -> Int

    CapacityReservation::created_at

    fn CapacityReservation::created_at(self : CapacityReservation) -> Int

    CapacityReservation::id

    fn CapacityReservation::id(self : CapacityReservation) -> String

    CapacityReservation::mark_released

    fn CapacityReservation::mark_released(self : CapacityReservation) -> Result[Unit, ModbusError]

    CapacityReservation::new

    fn CapacityReservation::new(id : String, resource : CapacityResource, amount : Int, created_at : Int) -> Result[CapacityReservation, ModbusError]

    CapacityReservation::released

    fn CapacityReservation::released(self : CapacityReservation) -> Bool

    CapacityReservation::resource

    CapacityResource

    pub(all) enum CapacityResource {
    InFlightRequests
    PollRegisters
    CaptureBytes
    CommandQueue
    HistorianSamples
    AlarmEvents
    } derive(Eq,
    Debug
    )

    Resource tracked by a gateway or device service budget.

    CaptureDirection

    pub(all) enum CaptureDirection {
    Received
    Transmitted
    Internal
    } derive(Eq,
    Debug
    )

    Direction of a frame in a transport capture.

    CaptureFilter

    pub(all) struct CaptureFilter {
    mode : Mode?
    unit_id : Byte?
    function : Byte?
    direction : CaptureDirection?
    status : CaptureStatus?
    start_time : Int?
    end_time : Int?
    }

    Filter used to query a capture ring without decoding records again.

    CaptureFilter::between

    fn CaptureFilter::between(self : CaptureFilter, start : Int, end : Int) -> Result[CaptureFilter, ModbusError]

    CaptureFilter::matches

    fn CaptureFilter::matches(self : CaptureFilter, record : CaptureRecord) -> Bool

    CaptureFilter::new

    CaptureFilter::with_direction

    fn CaptureFilter::with_direction(self : CaptureFilter, direction : CaptureDirection) -> CaptureFilter

    CaptureFilter::with_function

    fn CaptureFilter::with_function(self : CaptureFilter, function : Byte) -> CaptureFilter

    CaptureFilter::with_mode

    fn CaptureFilter::with_mode(self : CaptureFilter, mode : Mode) -> CaptureFilter

    CaptureFilter::with_status

    fn CaptureFilter::with_status(self : CaptureFilter, status : CaptureStatus) -> CaptureFilter

    CaptureFilter::with_unit

    fn CaptureFilter::with_unit(self : CaptureFilter, unit_id : Byte) -> CaptureFilter

    CaptureRecord

    pub(all) struct CaptureRecord {
    id : Int
    timestamp : Int
    mode : Mode
    transaction_id : UInt16
    direction : CaptureDirection
    bytes : Array[Byte]
    frame : Frame?
    status : CaptureStatus
    note : String
    }

    A single timestamped wire record.

    CaptureRecord::bytes

    fn CaptureRecord::bytes(self : CaptureRecord) -> Array[Byte]

    CaptureRecord::direction

    CaptureRecord::frame

    fn CaptureRecord::frame(self : CaptureRecord) -> Frame?

    CaptureRecord::from_frame

    fn CaptureRecord::from_frame(id : Int, timestamp : Int, mode : Mode, transaction_id : UInt16, direction : CaptureDirection, frame : Frame, note? : String) -> Result[CaptureRecord, ModbusError]

    CaptureRecord::function

    fn CaptureRecord::function(self : CaptureRecord) -> Byte?

    CaptureRecord::id

    fn CaptureRecord::id(self : CaptureRecord) -> Int

    CaptureRecord::is_valid

    fn CaptureRecord::is_valid(self : CaptureRecord) -> Bool

    CaptureRecord::mode

    fn CaptureRecord::mode(self : CaptureRecord) -> Mode

    CaptureRecord::new

    fn CaptureRecord::new(id : Int, timestamp : Int, mode : Mode, transaction_id : UInt16, direction : CaptureDirection, bytes : Array[Byte], note? : String) -> Result[CaptureRecord, ModbusError]

    CaptureRecord::note

    fn CaptureRecord::note(self : CaptureRecord) -> String

    CaptureRecord::status

    CaptureRecord::summary

    fn CaptureRecord::summary(self : CaptureRecord) -> String

    CaptureRecord::timestamp

    fn CaptureRecord::timestamp(self : CaptureRecord) -> Int

    CaptureRecord::transaction_id

    fn CaptureRecord::transaction_id(self : CaptureRecord) -> UInt16

    CaptureRecord::unit_id

    fn CaptureRecord::unit_id(self : CaptureRecord) -> Byte?

    CaptureRing

    pub(all) struct CaptureRing {
    records : Array[CaptureRecord]
    max_records : Int
    next_id : Int
    lost : Int
    }

    A bounded rolling store for protocol captures.

    CaptureRing::byte_count

    fn CaptureRing::byte_count(self : CaptureRing) -> Int

    CaptureRing::capacity

    fn CaptureRing::capacity(self : CaptureRing) -> Int

    CaptureRing::clear

    fn CaptureRing::clear(self : CaptureRing) -> Unit

    CaptureRing::corrupt_count

    fn CaptureRing::corrupt_count(self : CaptureRing) -> Int

    CaptureRing::decoded_count

    fn CaptureRing::decoded_count(self : CaptureRing) -> Int

    CaptureRing::get

    fn CaptureRing::get(self : CaptureRing, index : Int) -> Result[CaptureRecord, ModbusError]

    CaptureRing::latest

    fn CaptureRing::latest(self : CaptureRing) -> CaptureRecord?

    CaptureRing::length

    fn CaptureRing::length(self : CaptureRing) -> Int

    CaptureRing::lost

    fn CaptureRing::lost(self : CaptureRing) -> Int

    CaptureRing::new

    fn CaptureRing::new(max_records? : Int) -> Result[CaptureRing, ModbusError]

    CaptureRing::push

    fn CaptureRing::push(self : CaptureRing, timestamp : Int, mode : Mode, transaction_id : UInt16, direction : CaptureDirection, bytes : Array[Byte], note? : String) -> Result[CaptureRecord, ModbusError]

    CaptureRing::push_frame

    fn CaptureRing::push_frame(self : CaptureRing, timestamp : Int, mode : Mode, transaction_id : UInt16, direction : CaptureDirection, frame : Frame, note? : String) -> Result[CaptureRecord, ModbusError]

    CaptureRing::query

    fn CaptureRing::query(self : CaptureRing, filter : CaptureFilter) -> Array[CaptureRecord]

    CaptureRing::snapshot

    fn CaptureRing::snapshot(self : CaptureRing) -> Array[CaptureRecord]

    CaptureRing::summary

    fn CaptureRing::summary(self : CaptureRing) -> String

    CaptureStatus

    pub(all) enum CaptureStatus {
    Decoded
    Undecoded
    Corrupt
    Truncated
    } derive(Eq,
    Debug
    )

    Integrity state retained with a captured byte sequence.

    CircuitGuard

    pub(all) struct CircuitGuard {
    name : String
    failure_threshold : Int
    recovery_after : Int
    probe_limit : Int
    state : CircuitGuardState
    consecutive_failures : Int
    opened_at : Int?
    probes : Int
    }

    A circuit breaker with failure threshold and recovery probes.

    CircuitGuard::allow

    fn CircuitGuard::allow(self : CircuitGuard, now : Int) -> Result[Bool, ModbusError]

    CircuitGuard::consecutive_failures

    fn CircuitGuard::consecutive_failures(self : CircuitGuard) -> Int

    CircuitGuard::failure_threshold

    fn CircuitGuard::failure_threshold(self : CircuitGuard) -> Int

    CircuitGuard::force_close

    fn CircuitGuard::force_close(self : CircuitGuard) -> Unit

    CircuitGuard::force_open

    fn CircuitGuard::force_open(self : CircuitGuard, now : Int) -> Result[Unit, ModbusError]

    CircuitGuard::name

    fn CircuitGuard::name(self : CircuitGuard) -> String

    CircuitGuard::new

    fn CircuitGuard::new(name : String, failure_threshold : Int, recovery_after : Int, probe_limit? : Int) -> Result[CircuitGuard, ModbusError]

    CircuitGuard::opened_at

    fn CircuitGuard::opened_at(self : CircuitGuard) -> Int?

    CircuitGuard::record_failure

    fn CircuitGuard::record_failure(self : CircuitGuard, now : Int) -> Result[Unit, ModbusError]

    CircuitGuard::record_success

    fn CircuitGuard::record_success(self : CircuitGuard) -> Unit

    CircuitGuard::recovery_after

    fn CircuitGuard::recovery_after(self : CircuitGuard) -> Int

    CircuitGuard::state

    CircuitGuardState

    pub(all) enum CircuitGuardState {
    ClosedCircuit
    OpenCircuit
    HalfOpenCircuit
    } derive(Eq,
    Debug
    )

    State of a circuit guard protecting a device or route.

    Client

    pub struct Client {
    mode : Mode
    config : ClientConfig
    next_transaction : UInt16
    pending : Array[PendingExchange]
    }

    A stateful protocol client that does not assume a particular socket runtime.

    Client::accept

    fn Client::accept(self : Client, request : ClientRequest, bytes : Array[Byte]) -> Result[Frame, ModbusError]

    Accept bytes from the transport and correlate them with a pending request.

    Client::accept_frame

    fn Client::accept_frame(self : Client, request : ClientRequest, transaction_id : UInt16, response : Frame) -> Result[Frame, ModbusError]

    Accept an already decoded response frame.

    Client::allocate_transaction

    fn Client::allocate_transaction(self : Client) -> UInt16

    Allocate a non-zero transaction id for TCP and a stable zero id for serial modes.

    Client::attempts

    fn Client::attempts(self : Client, transaction_id : UInt16) -> Int

    Return a request's retry count, or zero when it is not tracked.

    Client::begin

    fn Client::begin(self : Client, frame : Frame) -> Result[ClientRequest, ModbusError]

    Begin an exchange at logical tick zero.

    Client::begin_at

    fn Client::begin_at(self : Client, frame : Frame, now : Int) -> Result[ClientRequest, ModbusError]

    Begin an exchange at a caller-supplied logical tick.

    Client::cancel

    fn Client::cancel(self : Client, transaction_id : UInt16) -> Result[Unit, ModbusError]

    Client::completed_count

    fn Client::completed_count(self : Client) -> Int

    Client::config

    fn Client::config(self : Client) -> ClientConfig

    Client::expire

    fn Client::expire(self : Client, now : Int) -> Array[UInt16]

    Mark all timed-out exchanges as failed and return their transaction ids.

    Client::failed_count

    fn Client::failed_count(self : Client) -> Int

    Client::mode

    fn Client::mode(self : Client) -> Mode

    Client::new

    fn Client::new(mode : Mode, config? : ClientConfig) -> Client

    Client::next_transaction

    fn Client::next_transaction(self : Client) -> UInt16

    Client::pending_active

    fn Client::pending_active(self : Client) -> Int

    Client::pending_request

    fn Client::pending_request(self : Client, transaction_id : UInt16) -> PendingExchange?

    Find a pending request by transaction id.

    Client::pending_snapshot

    fn Client::pending_snapshot(self : Client) -> Array[PendingExchange]

    Return a copy of all pending records for an external scheduler.

    Client::retry_due

    fn Client::retry_due(self : Client, now : Int) -> Array[UInt16]

    Return pending exchanges that can be retried at a logical tick.

    ClientConfig

    pub(all) struct ClientConfig {
    timeout_ticks : Int
    retries : Int
    max_pending : Int
    strict_unit : Bool
    }

    Client retry and framing policy.

    ClientRequest

    pub(all) struct ClientRequest {
    transaction_id : UInt16
    frame : Frame
    bytes : Array[Byte]
    }

    A request prepared for a transport adapter.

    ClientRequest::encoded_length

    fn ClientRequest::encoded_length(self : ClientRequest) -> Int

    ClientResult

    pub(all) enum ClientResult {
    Success(Frame)
    Exception(ExceptionCode)
    }

    A decoded client result with a typed success/exception branch.

    CoilBank

    pub(all) struct CoilBank {
    start : UInt16
    bits : BitVector
    writable : Bool
    }

    A bounded coil/discrete-input bank backed by a bit vector.

    CoilBank::clear

    fn CoilBank::clear(self : CoilBank) -> Unit

    CoilBank::contains

    fn CoilBank::contains(self : CoilBank, address : UInt16, quantity : Int) -> Bool

    CoilBank::fill

    fn CoilBank::fill(self : CoilBank, value : Bool) -> Unit

    CoilBank::get

    fn CoilBank::get(self : CoilBank, address : UInt16) -> Result[Bool, ModbusError]

    CoilBank::is_writable

    fn CoilBank::is_writable(self : CoilBank) -> Bool

    CoilBank::length

    fn CoilBank::length(self : CoilBank) -> Int

    CoilBank::new

    fn CoilBank::new(start : UInt16, length : Int, writable? : Bool) -> Result[CoilBank, ModbusError]

    CoilBank::read

    fn CoilBank::read(self : CoilBank, address : UInt16, quantity : Int) -> Result[Array[Bool], ModbusError]

    CoilBank::set

    fn CoilBank::set(self : CoilBank, address : UInt16, value : Bool) -> Result[Unit, ModbusError]

    CoilBank::snapshot

    fn CoilBank::snapshot(self : CoilBank) -> Array[Bool]

    CoilBank::snapshot_bytes

    fn CoilBank::snapshot_bytes(self : CoilBank) -> Array[Byte]

    CoilBank::start

    fn CoilBank::start(self : CoilBank) -> UInt16

    CoilBank::write

    fn CoilBank::write(self : CoilBank, address : UInt16, values : Array[Bool]) -> Result[Unit, ModbusError]

    CommandArgument

    pub(all) struct CommandArgument {
    key : String
    value : String
    }

    A typed key/value argument supplied by a UI, rule, or automation.

    CommandArgument::as_bool

    fn CommandArgument::as_bool(self : CommandArgument) -> Result[Bool, ModbusError]

    CommandArgument::as_int

    fn CommandArgument::as_int(self : CommandArgument) -> Result[Int, ModbusError]

    CommandArgument::key

    fn CommandArgument::key(self : CommandArgument) -> String

    CommandArgument::new

    fn CommandArgument::new(key : String, value : String) -> Result[CommandArgument, ModbusError]

    CommandArgument::value

    fn CommandArgument::value(self : CommandArgument) -> String

    CommandAuditEntry

    pub(all) struct CommandAuditEntry {
    sequence : Int
    command_id : String
    principal : String
    device_id : String
    operation : String
    state : DeviceCommandState
    timestamp : Int
    detail : String
    }

    Immutable audit event for compliance exports.

    CommandAuditEntry::command_id

    fn CommandAuditEntry::command_id(self : CommandAuditEntry) -> String

    CommandAuditEntry::detail

    fn CommandAuditEntry::detail(self : CommandAuditEntry) -> String

    CommandAuditEntry::device_id

    fn CommandAuditEntry::device_id(self : CommandAuditEntry) -> String

    CommandAuditEntry::new

    fn CommandAuditEntry::new(sequence : Int, command : DeviceCommand, state : DeviceCommandState, timestamp : Int, detail? : String) -> Result[CommandAuditEntry, ModbusError]

    CommandAuditEntry::operation

    fn CommandAuditEntry::operation(self : CommandAuditEntry) -> String

    CommandAuditEntry::principal

    fn CommandAuditEntry::principal(self : CommandAuditEntry) -> String

    CommandAuditEntry::sequence

    fn CommandAuditEntry::sequence(self : CommandAuditEntry) -> Int

    CommandAuditEntry::state

    CommandAuditEntry::timestamp

    fn CommandAuditEntry::timestamp(self : CommandAuditEntry) -> Int

    CommandCenter

    pub(all) struct CommandCenter {
    queue : Array[DeviceCommand]
    completed : Array[CommandExecution]
    audit : Array[CommandAuditEntry]
    max_queue : Int
    max_audit : Int
    sequence : Int
    }

    Central queue and audit log used by a control-plane service.

    CommandCenter::audit_count

    fn CommandCenter::audit_count(self : CommandCenter) -> Int

    CommandCenter::cancel

    fn CommandCenter::cancel(self : CommandCenter, command_id : String, timestamp : Int) -> Result[Unit, ModbusError]

    CommandCenter::completed_count

    fn CommandCenter::completed_count(self : CommandCenter) -> Int

    CommandCenter::find_audit

    fn CommandCenter::find_audit(self : CommandCenter, command_id : String) -> Array[CommandAuditEntry]

    CommandCenter::finish

    fn CommandCenter::finish(self : CommandCenter, command : DeviceCommand, execution : CommandExecution) -> Result[Unit, ModbusError]

    Complete a dispatched command and retain its result for inspection.

    CommandCenter::new

    fn CommandCenter::new(max_queue? : Int, max_audit? : Int) -> Result[CommandCenter, ModbusError]

    CommandCenter::next

    fn CommandCenter::next(self : CommandCenter, timestamp : Int) -> Result[DeviceCommand, ModbusError]

    CommandCenter::queue_count

    fn CommandCenter::queue_count(self : CommandCenter) -> Int

    CommandCenter::recent

    fn CommandCenter::recent(self : CommandCenter, limit : Int) -> Result[Array[CommandAuditEntry], ModbusError]

    CommandCenter::state_counts

    fn CommandCenter::state_counts(self : CommandCenter) -> Array[Int]

    CommandCenter::submit

    fn CommandCenter::submit(self : CommandCenter, command : DeviceCommand, timestamp : Int) -> Result[Unit, ModbusError]

    CommandExecution

    pub(all) struct CommandExecution {
    command_id : String
    state : DeviceCommandState
    started_at : Int
    finished_at : Int
    response : Frame?
    error : ModbusError?
    message : String
    }

    Result returned by a transport or a simulated execution backend.

    CommandExecution::command_id

    fn CommandExecution::command_id(self : CommandExecution) -> String

    CommandExecution::duration

    fn CommandExecution::duration(self : CommandExecution) -> Int

    CommandExecution::error

    CommandExecution::finished_at

    fn CommandExecution::finished_at(self : CommandExecution) -> Int

    CommandExecution::message

    fn CommandExecution::message(self : CommandExecution) -> String

    CommandExecution::new

    fn CommandExecution::new(command_id : String, state : DeviceCommandState, started_at : Int, finished_at : Int, response? : Frame, error? : ModbusError, message? : String) -> Result[CommandExecution, ModbusError]

    CommandExecution::response

    fn CommandExecution::response(self : CommandExecution) -> Frame?

    CommandExecution::started_at

    fn CommandExecution::started_at(self : CommandExecution) -> Int

    CommandExecution::state

    ConfigEntry

    pub(all) struct ConfigEntry {
    key : String
    value : ConfigValue
    source : String
    revision : Int
    }

    A key/value pair in a runtime configuration snapshot.

    ConfigEntry::display

    fn ConfigEntry::display(self : ConfigEntry, redact? : Bool) -> String

    ConfigEntry::key

    fn ConfigEntry::key(self : ConfigEntry) -> String

    ConfigEntry::new

    fn ConfigEntry::new(key : String, value : ConfigValue, source? : String, revision? : Int) -> Result[ConfigEntry, ModbusError]

    ConfigEntry::revision

    fn ConfigEntry::revision(self : ConfigEntry) -> Int

    ConfigEntry::source

    fn ConfigEntry::source(self : ConfigEntry) -> String

    ConfigEntry::value

    fn ConfigEntry::value(self : ConfigEntry) -> ConfigValue

    ConfigKind

    pub(all) enum ConfigKind {
    Text
    Integer
    Boolean
    ModeValue
    ByteSequence
    } derive(Eq,
    Debug
    )

    Type constraint for a runtime configuration key.

    ConfigOperation

    pub(all) enum ConfigOperation {
    SetValue(String, ConfigValue)
    RemoveValue(String)
    } derive(
    Debug
    )

    A change applied to a runtime configuration.

    ConfigSchema

    pub(all) struct ConfigSchema {
    specs : Array[ConfigSpec]
    max_specs : Int
    }

    A collection of configuration specifications.

    ConfigSchema::add

    fn ConfigSchema::add(self : ConfigSchema, spec : ConfigSpec) -> Result[Unit, ModbusError]

    ConfigSchema::find

    fn ConfigSchema::find(self : ConfigSchema, key : String) -> ConfigSpec?

    ConfigSchema::get

    fn ConfigSchema::get(self : ConfigSchema, index : Int) -> Result[ConfigSpec, ModbusError]

    ConfigSchema::length

    fn ConfigSchema::length(self : ConfigSchema) -> Int

    ConfigSchema::new

    fn ConfigSchema::new(max_specs? : Int) -> Result[ConfigSchema, ModbusError]

    ConfigSchema::snapshot

    fn ConfigSchema::snapshot(self : ConfigSchema) -> Array[ConfigSpec]

    ConfigSchema::validate_values

    fn ConfigSchema::validate_values(self : ConfigSchema, values : Array[ConfigEntry]) -> Result[Unit, ModbusError]

    ConfigSpec

    pub(all) struct ConfigSpec {
    key : String
    kind : ConfigKind
    required : Bool
    default_value : ConfigValue?
    min_integer : Int?
    max_integer : Int?
    min_length : Int
    max_length : Int
    secret : Bool
    description : String
    }

    A schema entry describing a single configurable field.

    ConfigSpec::default_value

    fn ConfigSpec::default_value(self : ConfigSpec) -> ConfigValue?

    ConfigSpec::description

    fn ConfigSpec::description(self : ConfigSpec) -> String

    ConfigSpec::key

    fn ConfigSpec::key(self : ConfigSpec) -> String

    ConfigSpec::kind

    fn ConfigSpec::kind(self : ConfigSpec) -> ConfigKind

    ConfigSpec::new

    fn ConfigSpec::new(key : String, kind : ConfigKind, required? : Bool, default_value? : ConfigValue, min_integer? : Int, max_integer? : Int, min_length? : Int, max_length? : Int, secret? : Bool, description? : String) -> Result[ConfigSpec, ModbusError]

    ConfigSpec::required

    fn ConfigSpec::required(self : ConfigSpec) -> Bool

    ConfigSpec::secret

    fn ConfigSpec::secret(self : ConfigSpec) -> Bool

    ConfigSpec::summary

    fn ConfigSpec::summary(self : ConfigSpec) -> String

    ConfigSpec::validate

    fn ConfigSpec::validate(self : ConfigSpec, value : ConfigValue) -> Result[Unit, ModbusError]

    ConfigValue

    pub(all) enum ConfigValue {
    TextValue(String)
    IntegerValue(Int)
    BooleanValue(Bool)
    ModeValue(Mode)
    ByteSequenceValue(Array[Byte])
    } derive(
    Debug
    )

    A configuration value represented without a dynamic runtime dependency.

    ConfigValue::as_boolean

    fn ConfigValue::as_boolean(self : ConfigValue) -> Result[Bool, ModbusError]

    ConfigValue::as_bytes

    fn ConfigValue::as_bytes(self : ConfigValue) -> Result[Array[Byte], ModbusError]

    ConfigValue::as_integer

    fn ConfigValue::as_integer(self : ConfigValue) -> Result[Int, ModbusError]

    ConfigValue::as_mode

    fn ConfigValue::as_mode(self : ConfigValue) -> Result[Mode, ModbusError]

    ConfigValue::as_text

    fn ConfigValue::as_text(self : ConfigValue) -> Result[String, ModbusError]

    ConfigValue::display

    fn ConfigValue::display(self : ConfigValue, redact? : Bool) -> String

    ConfigValue::kind

    fn ConfigValue::kind(self : ConfigValue) -> ConfigKind

    ConformanceResult

    pub(all) struct ConformanceResult {
    name : String
    passed : Bool
    detail : String
    }

    A vector execution result.

    ConformanceSuite

    pub struct ConformanceSuite {
    vectors : Array[ConformanceVector]
    }

    A reusable conformance suite.

    ConformanceSuite::add

    fn ConformanceSuite::add(self : ConformanceSuite, vector : ConformanceVector) -> Unit

    ConformanceSuite::length

    fn ConformanceSuite::length(self : ConformanceSuite) -> Int

    ConformanceSuite::new

    ConformanceSuite::run

    ConformanceVector

    pub(all) struct ConformanceVector {
    name : String
    mode : Mode
    bytes : Array[Byte]
    expected_function : Byte?
    expected_error : ModbusError?
    }

    A portable conformance vector for transport and frame decoders.

    ConformanceVector::invalid

    fn ConformanceVector::invalid(name : String, mode : Mode, bytes : Array[Byte], expected_error : ModbusError) -> ConformanceVector

    ConformanceVector::valid

    fn ConformanceVector::valid(name : String, mode : Mode, bytes : Array[Byte], expected_function : Byte) -> ConformanceVector

    ContractResult

    pub(all) enum ContractResult {
    ContractPass
    ContractUnitMismatch
    ContractFunctionMismatch
    ContractLengthMismatch
    ContractDataMismatch
    ContractException
    } derive(Eq,
    Debug
    )

    Contract check result for a request/response pair.

    Counter

    pub(all) struct Counter {
    name : String
    value : Int
    }

    A small integer counter used for protocol telemetry.

    Counter::add

    fn Counter::add(self : Counter, amount : Int) -> Result[Unit, ModbusError]

    Counter::inc

    fn Counter::inc(self : Counter) -> Unit

    Counter::name

    fn Counter::name(self : Counter) -> String

    Counter::new

    fn Counter::new(name : String) -> Counter

    Counter::reset

    fn Counter::reset(self : Counter) -> Unit

    Counter::value

    fn Counter::value(self : Counter) -> Int

    Crc16State

    pub(all) struct Crc16State {
    value : UInt16
    }

    Incremental CRC16 accumulator for serial readers.

    Crc16State::finalize

    fn Crc16State::finalize(self : Crc16State) -> UInt16

    Crc16State::finalize_bytes

    fn Crc16State::finalize_bytes(self : Crc16State) -> Array[Byte]

    Crc16State::new

    fn Crc16State::new() -> Crc16State

    Crc16State::update

    fn Crc16State::update(self : Crc16State, bytes : Array[Byte]) -> Unit

    Crc16State::update_byte

    fn Crc16State::update_byte(self : Crc16State, byte : Byte) -> Unit

    Device

    pub struct Device {
    unit_id : Byte
    memory : DeviceMemory
    file_store : FileRecordStore
    server_id : Array[Byte]
    event_count : UInt16
    busy : Bool
    exception_count : Int
    }

    A protocol-level Modbus device backed by four bounded data tables.

    Device::event_count

    fn Device::event_count(self : Device) -> UInt16

    Device::exception_count

    fn Device::exception_count(self : Device) -> Int

    Device::file_store

    fn Device::file_store(self : Device) -> FileRecordStore

    Device::handle

    fn Device::handle(self : Device, request : Frame) -> Result[Frame, ModbusError]

    Handle a request and return a normal or exception response.

    Device::health

    fn Device::health(self : Device) -> DeviceHealth

    Device::is_busy

    fn Device::is_busy(self : Device) -> Bool

    Device::memory

    fn Device::memory(self : Device) -> DeviceMemory

    Device::new

    fn Device::new(unit_id : Byte, coil_capacity? : Int, register_capacity? : Int) -> Result[Device, ModbusError]

    Create a device with configurable table capacities.

    Device::serve

    fn Device::serve(self : Device, request : Frame) -> Result[DeviceResponse, ModbusError]

    Handle a request while making broadcast no-response semantics explicit.

    Device::server_id

    fn Device::server_id(self : Device) -> Array[Byte]

    Device::set_busy

    fn Device::set_busy(self : Device, busy : Bool) -> Unit

    Device::set_server_id

    fn Device::set_server_id(self : Device, values : Array[Byte]) -> Result[Unit, ModbusError]

    Device::unit_id

    fn Device::unit_id(self : Device) -> Byte

    DeviceCommand

    pub(all) struct DeviceCommand {
    id : String
    device_id : String
    unit_id : Byte
    kind : DeviceCommandKind
    function : Byte
    address : UInt16
    quantity : Int
    arguments : Array[CommandArgument]
    principal : String
    reason : String
    timeout : Int
    state : DeviceCommandState
    created_at : Int
    }

    Definition and authorization context for one device operation.

    DeviceCommand::add_argument

    fn DeviceCommand::add_argument(self : DeviceCommand, argument : CommandArgument) -> Result[Unit, ModbusError]

    DeviceCommand::address

    fn DeviceCommand::address(self : DeviceCommand) -> UInt16

    DeviceCommand::argument

    fn DeviceCommand::argument(self : DeviceCommand, key : String) -> CommandArgument?

    DeviceCommand::argument_count

    fn DeviceCommand::argument_count(self : DeviceCommand) -> Int

    DeviceCommand::created_at

    fn DeviceCommand::created_at(self : DeviceCommand) -> Int

    DeviceCommand::device_id

    fn DeviceCommand::device_id(self : DeviceCommand) -> String

    DeviceCommand::function

    fn DeviceCommand::function(self : DeviceCommand) -> Byte

    DeviceCommand::id

    fn DeviceCommand::id(self : DeviceCommand) -> String

    DeviceCommand::is_terminal

    fn DeviceCommand::is_terminal(self : DeviceCommand) -> Bool

    DeviceCommand::is_write

    fn DeviceCommand::is_write(self : DeviceCommand) -> Bool

    DeviceCommand::kind

    DeviceCommand::new

    fn DeviceCommand::new(id : String, device_id : String, unit_id : Byte, kind : DeviceCommandKind, function : Byte, address : UInt16, quantity : Int, principal : String, reason : String, created_at : Int, timeout? : Int) -> Result[DeviceCommand, ModbusError]

    DeviceCommand::principal

    fn DeviceCommand::principal(self : DeviceCommand) -> String

    DeviceCommand::quantity

    fn DeviceCommand::quantity(self : DeviceCommand) -> Int

    DeviceCommand::reason

    fn DeviceCommand::reason(self : DeviceCommand) -> String

    DeviceCommand::request

    fn DeviceCommand::request(self : DeviceCommand) -> Result[Frame, ModbusError]

    Build a PDU for commands represented directly by standard Modbus writes.

    DeviceCommand::set_state

    fn DeviceCommand::set_state(self : DeviceCommand, state : DeviceCommandState) -> Result[Unit, ModbusError]

    DeviceCommand::state

    DeviceCommand::timeout

    fn DeviceCommand::timeout(self : DeviceCommand) -> Int

    DeviceCommand::unit_id

    fn DeviceCommand::unit_id(self : DeviceCommand) -> Byte

    DeviceCommand::verify_address

    fn DeviceCommand::verify_address(self : DeviceCommand) -> Bool

    DeviceCommandKind

    pub(all) enum DeviceCommandKind {
    WriteCoilCommand
    WriteRegisterCommand
    WriteCoilsCommand
    WriteRegistersCommand
    ReadVerificationCommand
    ClearAlarmCommand
    RestartDeviceCommand
    CustomCommand
    } derive(Eq,
    Debug
    )

    Kind of operator command accepted by the control plane.

    DeviceCommandState

    pub(all) enum DeviceCommandState {
    Queued
    Validating
    Dispatched
    Acknowledged
    Rejected
    TimedOut
    FailedCommand
    CancelledCommand
    } derive(Eq,
    Debug
    )

    Lifecycle of a command from admission to audit completion.

    DeviceHealth

    pub(all) struct DeviceHealth {
    unit_id : Byte
    event_count : UInt16
    exception_count : Int
    busy : Bool
    }

    A compact device health snapshot for dashboards and polling logs.

    DeviceIdCategory

    pub(all) enum DeviceIdCategory {
    Basic
    Regular
    Extended
    Individual(Byte)
    } derive(Eq,
    Debug
    )

    Device-identification access category used by MEI type 0x0E.

    DeviceIdCategory::to_byte

    fn DeviceIdCategory::to_byte(category : DeviceIdCategory) -> Byte

    DeviceIdObject

    pub(all) struct DeviceIdObject {
    object_id : Byte
    value : String
    }

    One TLV object returned by a device-identification response.

    DeviceIdObject::new

    fn DeviceIdObject::new(object_id : Byte, value : String) -> Result[DeviceIdObject, ModbusError]

    DeviceIdentification

    pub(all) struct DeviceIdentification {
    category : DeviceIdCategory
    conformity : Byte
    more_follows : Bool
    next_object_id : Byte
    objects : Array[DeviceIdObject]
    }

    Parsed MEI device-identification response metadata.

    DeviceIdentityCatalog

    pub struct DeviceIdentityCatalog {
    category : DeviceIdCategory
    objects : Array[DeviceIdObject]
    conformity : Byte
    }

    A reusable identity catalogue for virtual devices.

    DeviceIdentityCatalog::add

    fn DeviceIdentityCatalog::add(self : DeviceIdentityCatalog, object : DeviceIdObject) -> Result[Unit, ModbusError]

    DeviceIdentityCatalog::length

    DeviceIdentityCatalog::new

    DeviceIdentityCatalog::objects

    DeviceIdentityCatalog::response

    fn DeviceIdentityCatalog::response(self : DeviceIdentityCatalog, request : Frame) -> Result[Frame, ModbusError]

    DeviceIdentityCatalog::set_conformity

    fn DeviceIdentityCatalog::set_conformity(self : DeviceIdentityCatalog, conformity : Byte) -> Unit

    DeviceInventory

    pub(all) struct DeviceInventory {
    devices : Array[InventoryDevice]
    max_devices : Int
    revision : Int
    }

    A fleet inventory with lookup and stale-device reporting.

    DeviceInventory::add

    fn DeviceInventory::add(self : DeviceInventory, device : InventoryDevice) -> Result[Unit, ModbusError]

    DeviceInventory::by_state

    fn DeviceInventory::by_state(self : DeviceInventory, state : InventoryState) -> Array[String]

    Return devices by lifecycle state.

    DeviceInventory::by_tag

    fn DeviceInventory::by_tag(self : DeviceInventory, tag : String) -> Array[String]

    DeviceInventory::by_vendor

    fn DeviceInventory::by_vendor(self : DeviceInventory, vendor : String) -> Array[String]

    DeviceInventory::count

    fn DeviceInventory::count(self : DeviceInventory) -> Int

    DeviceInventory::export_lines

    fn DeviceInventory::export_lines(self : DeviceInventory) -> Array[String]

    Stable tabular export for provisioning and support tools.

    DeviceInventory::get

    fn DeviceInventory::get(self : DeviceInventory, id : String) -> InventoryDevice?

    DeviceInventory::mark_stale

    fn DeviceInventory::mark_stale(self : DeviceInventory, now : Int, timeout : Int) -> Result[Int, ModbusError]

    Mark devices stale or offline using one common fleet timestamp.

    DeviceInventory::new

    fn DeviceInventory::new(max_devices? : Int) -> Result[DeviceInventory, ModbusError]

    DeviceInventory::remove

    fn DeviceInventory::remove(self : DeviceInventory, id : String) -> Result[InventoryDevice, ModbusError]

    DeviceInventory::revision

    fn DeviceInventory::revision(self : DeviceInventory) -> Int

    DeviceMemory

    pub(all) struct DeviceMemory {
    coils : CoilBank
    discrete_inputs : CoilBank
    input_registers : RegisterBank
    holding_registers : RegisterBank
    }

    The four standard Modbus data tables exposed by a device.

    DeviceMemory::clear

    fn DeviceMemory::clear(self : DeviceMemory) -> Unit

    DeviceMemory::coils

    fn DeviceMemory::coils(self : DeviceMemory) -> CoilBank

    DeviceMemory::discrete_inputs

    fn DeviceMemory::discrete_inputs(self : DeviceMemory) -> CoilBank

    DeviceMemory::holding_registers

    fn DeviceMemory::holding_registers(self : DeviceMemory) -> RegisterBank

    DeviceMemory::input_registers

    fn DeviceMemory::input_registers(self : DeviceMemory) -> RegisterBank

    DeviceMemory::load_discrete

    fn DeviceMemory::load_discrete(self : DeviceMemory, address : UInt16, values : Array[Bool]) -> Result[Unit, ModbusError]

    DeviceMemory::load_holding

    fn DeviceMemory::load_holding(self : DeviceMemory, address : UInt16, values : Array[UInt16]) -> Result[Unit, ModbusError]

    DeviceMemory::load_input

    fn DeviceMemory::load_input(self : DeviceMemory, address : UInt16, values : Array[UInt16]) -> Result[Unit, ModbusError]

    DeviceMemory::new

    fn DeviceMemory::new(coil_capacity? : Int, register_capacity? : Int) -> Result[DeviceMemory, ModbusError]

    Create a device memory map with all tables starting at address zero.

    DeviceProfile

    pub(all) struct DeviceProfile {
    name : String
    model : String
    unit_id : Byte
    revision : String
    points : Array[ProfilePoint]
    max_points : Int
    }

    A named set of points belonging to one device model.

    DeviceProfile::add_point

    fn DeviceProfile::add_point(self : DeviceProfile, point : ProfilePoint) -> Result[Unit, ModbusError]

    DeviceProfile::find

    fn DeviceProfile::find(self : DeviceProfile, id : String) -> ProfilePoint?

    DeviceProfile::model

    fn DeviceProfile::model(self : DeviceProfile) -> String

    DeviceProfile::name

    fn DeviceProfile::name(self : DeviceProfile) -> String

    DeviceProfile::new

    fn DeviceProfile::new(name : String, model : String, unit_id : Byte, revision? : String, max_points? : Int) -> Result[DeviceProfile, ModbusError]

    DeviceProfile::point

    fn DeviceProfile::point(self : DeviceProfile, index : Int) -> Result[ProfilePoint, ModbusError]

    DeviceProfile::point_count

    fn DeviceProfile::point_count(self : DeviceProfile) -> Int

    DeviceProfile::points

    DeviceProfile::points_in_area

    fn DeviceProfile::points_in_area(self : DeviceProfile, area : ProfileArea) -> Array[ProfilePoint]

    DeviceProfile::read_requests

    fn DeviceProfile::read_requests(self : DeviceProfile) -> Result[Array[Frame], ModbusError]

    DeviceProfile::remove_point

    fn DeviceProfile::remove_point(self : DeviceProfile, id : String) -> Result[ProfilePoint, ModbusError]

    DeviceProfile::revision

    fn DeviceProfile::revision(self : DeviceProfile) -> String

    DeviceProfile::summary

    fn DeviceProfile::summary(self : DeviceProfile) -> String

    DeviceProfile::unit_id

    fn DeviceProfile::unit_id(self : DeviceProfile) -> Byte

    DeviceProfile::validate

    fn DeviceProfile::validate(self : DeviceProfile) -> Result[Unit, ModbusError]

    DeviceProfile::writable_points

    fn DeviceProfile::writable_points(self : DeviceProfile) -> Array[ProfilePoint]

    DeviceReliability

    pub(all) struct DeviceReliability {
    device_id : String
    window : ReliabilityWindow
    circuit : CircuitGuard
    last_seen : Int?
    total_requests : Int
    total_successes : Int
    }

    Current availability and latency indicators for a device.

    DeviceReliability::allow_request

    fn DeviceReliability::allow_request(self : DeviceReliability, now : Int) -> Result[Bool, ModbusError]

    DeviceReliability::average_latency

    fn DeviceReliability::average_latency(self : DeviceReliability) -> Int

    DeviceReliability::device_id

    fn DeviceReliability::device_id(self : DeviceReliability) -> String

    DeviceReliability::failure_breakdown

    fn DeviceReliability::failure_breakdown(self : DeviceReliability) -> Array[Int]

    DeviceReliability::health_score

    fn DeviceReliability::health_score(self : DeviceReliability, now : Int) -> Result[Int, ModbusError]

    Return a health score from 0 (offline) to 100 (healthy).

    DeviceReliability::last_seen

    fn DeviceReliability::last_seen(self : DeviceReliability) -> Int?

    DeviceReliability::new

    fn DeviceReliability::new(device_id : String, window_width : Int, failure_threshold : Int, recovery_after : Int) -> Result[DeviceReliability, ModbusError]

    DeviceReliability::record

    fn DeviceReliability::record(self : DeviceReliability, sample : ReliabilitySample) -> Result[Unit, ModbusError]

    Record one outcome and update breaker state atomically from the caller's view.

    DeviceReliability::state

    DeviceReliability::success_rate

    fn DeviceReliability::success_rate(self : DeviceReliability) -> Int

    DeviceReliability::total_requests

    fn DeviceReliability::total_requests(self : DeviceReliability) -> Int

    DeviceReliability::total_successes

    fn DeviceReliability::total_successes(self : DeviceReliability) -> Int

    DeviceResponse

    pub(all) enum DeviceResponse {
    Reply(Frame)
    NoReply
    }

    A response returned by a virtual or embedded device service.

    DeviceService

    pub(all) struct DeviceService {
    id : String
    device_id : String
    kind : DeviceServiceKind
    endpoint : String
    state : DeviceServiceState
    started_at : Int?
    stopped_at : Int?
    restart_count : Int
    tags : Array[String]
    }

    Registration record for a long-lived device-facing service.

    DeviceService::add_tag

    fn DeviceService::add_tag(self : DeviceService, tag : String) -> Result[Unit, ModbusError]

    DeviceService::device_id

    fn DeviceService::device_id(self : DeviceService) -> String

    DeviceService::drain

    fn DeviceService::drain(self : DeviceService) -> Result[Unit, ModbusError]

    DeviceService::endpoint

    fn DeviceService::endpoint(self : DeviceService) -> String

    DeviceService::fail

    fn DeviceService::fail(self : DeviceService, timestamp : Int) -> Result[Unit, ModbusError]

    DeviceService::id

    fn DeviceService::id(self : DeviceService) -> String

    DeviceService::kind

    DeviceService::new

    fn DeviceService::new(id : String, device_id : String, kind : DeviceServiceKind, endpoint : String) -> Result[DeviceService, ModbusError]

    DeviceService::restart

    fn DeviceService::restart(self : DeviceService, timestamp : Int) -> Result[Unit, ModbusError]

    DeviceService::restart_count

    fn DeviceService::restart_count(self : DeviceService) -> Int

    DeviceService::start

    fn DeviceService::start(self : DeviceService, timestamp : Int) -> Result[Unit, ModbusError]

    DeviceService::started_at

    fn DeviceService::started_at(self : DeviceService) -> Int?

    DeviceService::state

    DeviceService::stop

    fn DeviceService::stop(self : DeviceService, timestamp : Int) -> Result[Unit, ModbusError]

    DeviceService::stopped_at

    fn DeviceService::stopped_at(self : DeviceService) -> Int?

    DeviceService::tag_count

    fn DeviceService::tag_count(self : DeviceService) -> Int

    DeviceServiceKind

    pub(all) enum DeviceServiceKind {
    PollingService
    CommandService
    AlarmService
    HistorianService
    GatewayService
    DiagnosticsService
    } derive(Eq,
    Debug
    )

    Kind of service hosted by the integration layer.

    DeviceServiceRegistry

    pub(all) struct DeviceServiceRegistry {
    services : Array[DeviceService]
    snapshots : Array[DeviceSnapshot]
    max_services : Int
    max_snapshots : Int
    }

    Registry for services and latest snapshots.

    DeviceServiceRegistry::export_summary

    fn DeviceServiceRegistry::export_summary(self : DeviceServiceRegistry) -> Array[String]

    Return a stable line-oriented snapshot for diagnostics and support bundles.

    DeviceServiceRegistry::failed

    fn DeviceServiceRegistry::failed(self : DeviceServiceRegistry) -> Array[String]

    DeviceServiceRegistry::for_device

    fn DeviceServiceRegistry::for_device(self : DeviceServiceRegistry, device_id : String) -> Array[DeviceService]

    DeviceServiceRegistry::new

    fn DeviceServiceRegistry::new(max_services? : Int, max_snapshots? : Int) -> Result[DeviceServiceRegistry, ModbusError]

    DeviceServiceRegistry::put_snapshot

    fn DeviceServiceRegistry::put_snapshot(self : DeviceServiceRegistry, snapshot : DeviceSnapshot) -> Result[Unit, ModbusError]

    DeviceServiceRegistry::register

    fn DeviceServiceRegistry::register(self : DeviceServiceRegistry, service : DeviceService) -> Result[Unit, ModbusError]

    DeviceServiceRegistry::running

    fn DeviceServiceRegistry::running(self : DeviceServiceRegistry) -> Array[String]

    DeviceServiceRegistry::service

    fn DeviceServiceRegistry::service(self : DeviceServiceRegistry, id : String) -> DeviceService?

    DeviceServiceRegistry::service_count

    fn DeviceServiceRegistry::service_count(self : DeviceServiceRegistry) -> Int

    DeviceServiceRegistry::snapshot

    fn DeviceServiceRegistry::snapshot(self : DeviceServiceRegistry, device_id : String) -> DeviceSnapshot?

    DeviceServiceRegistry::snapshot_count

    fn DeviceServiceRegistry::snapshot_count(self : DeviceServiceRegistry) -> Int

    DeviceServiceState

    pub(all) enum DeviceServiceState {
    ServiceCreated
    ServiceStarting
    ServiceRunning
    ServiceDraining
    ServiceStopped
    ServiceFailed
    } derive(Eq,
    Debug
    )

    Lifecycle of an application service attached to a device.

    DeviceSnapshot

    pub(all) struct DeviceSnapshot {
    device_id : String
    captured_at : Int
    values : Array[SnapshotValue]
    sequence : Int
    complete : Bool
    }

    A consistent set of point values from one acquisition cycle.

    DeviceSnapshot::add

    fn DeviceSnapshot::add(self : DeviceSnapshot, value : SnapshotValue) -> Result[Unit, ModbusError]

    DeviceSnapshot::captured_at

    fn DeviceSnapshot::captured_at(self : DeviceSnapshot) -> Int

    DeviceSnapshot::complete

    fn DeviceSnapshot::complete(self : DeviceSnapshot) -> Bool

    DeviceSnapshot::device_id

    fn DeviceSnapshot::device_id(self : DeviceSnapshot) -> String

    DeviceSnapshot::diff

    fn DeviceSnapshot::diff(self : DeviceSnapshot, previous : DeviceSnapshot) -> Array[String]

    DeviceSnapshot::finish

    fn DeviceSnapshot::finish(self : DeviceSnapshot, expected : Int) -> Result[Unit, ModbusError]

    DeviceSnapshot::get

    fn DeviceSnapshot::get(self : DeviceSnapshot, point_id : String) -> SnapshotValue?

    DeviceSnapshot::good_count

    fn DeviceSnapshot::good_count(self : DeviceSnapshot) -> Int

    DeviceSnapshot::new

    fn DeviceSnapshot::new(device_id : String, captured_at : Int, sequence : Int) -> Result[DeviceSnapshot, ModbusError]

    DeviceSnapshot::quality

    DeviceSnapshot::sequence

    fn DeviceSnapshot::sequence(self : DeviceSnapshot) -> Int

    DeviceSnapshot::value_count

    fn DeviceSnapshot::value_count(self : DeviceSnapshot) -> Int

    DiagnosticCategory

    pub(all) enum DiagnosticCategory {
    Framing
    Addressing
    FunctionSupport
    Payload
    Timing
    Capacity
    Configuration
    Interoperability
    } derive(Eq,
    Debug
    )

    Category assigned to a diagnostic finding.

    DiagnosticIssue

    pub(all) struct DiagnosticIssue {
    code : String
    category : DiagnosticCategory
    severity : DiagnosticSeverity
    message : String
    context : String
    suggestion : String
    }

    One actionable finding from a diagnostic pass.

    DiagnosticIssue::category

    DiagnosticIssue::code

    fn DiagnosticIssue::code(self : DiagnosticIssue) -> String

    DiagnosticIssue::context

    fn DiagnosticIssue::context(self : DiagnosticIssue) -> String

    DiagnosticIssue::message

    fn DiagnosticIssue::message(self : DiagnosticIssue) -> String

    DiagnosticIssue::new

    fn DiagnosticIssue::new(code : String, category : DiagnosticCategory, severity : DiagnosticSeverity, message : String, context? : String, suggestion? : String) -> Result[DiagnosticIssue, ModbusError]

    DiagnosticIssue::severity

    DiagnosticIssue::suggestion

    fn DiagnosticIssue::suggestion(self : DiagnosticIssue) -> String

    DiagnosticIssue::summary

    fn DiagnosticIssue::summary(self : DiagnosticIssue) -> String

    DiagnosticReport

    pub(all) struct DiagnosticReport {
    name : String
    issues : Array[DiagnosticIssue]
    max_issues : Int
    inspected : Int
    }

    A report collected from one or more protocol checks.

    DiagnosticReport::add

    fn DiagnosticReport::add(self : DiagnosticReport, issue : DiagnosticIssue) -> Result[Unit, ModbusError]

    DiagnosticReport::clear

    fn DiagnosticReport::clear(self : DiagnosticReport) -> Unit

    DiagnosticReport::count_category

    fn DiagnosticReport::count_category(self : DiagnosticReport, category : DiagnosticCategory) -> Int

    DiagnosticReport::count_severity

    fn DiagnosticReport::count_severity(self : DiagnosticReport, severity : DiagnosticSeverity) -> Int

    DiagnosticReport::has_errors

    fn DiagnosticReport::has_errors(self : DiagnosticReport) -> Bool

    DiagnosticReport::has_warnings

    fn DiagnosticReport::has_warnings(self : DiagnosticReport) -> Bool

    DiagnosticReport::inspect_one

    fn DiagnosticReport::inspect_one(self : DiagnosticReport, frame : Frame) -> Result[Unit, ModbusError]

    DiagnosticReport::inspect_wire

    fn DiagnosticReport::inspect_wire(self : DiagnosticReport, mode : Mode, bytes : Array[Byte]) -> Unit

    DiagnosticReport::inspected

    fn DiagnosticReport::inspected(self : DiagnosticReport) -> Int

    DiagnosticReport::issues

    DiagnosticReport::length

    fn DiagnosticReport::length(self : DiagnosticReport) -> Int

    DiagnosticReport::name

    fn DiagnosticReport::name(self : DiagnosticReport) -> String

    DiagnosticReport::new

    fn DiagnosticReport::new(name? : String, max_issues? : Int) -> Result[DiagnosticReport, ModbusError]

    DiagnosticReport::ok

    fn DiagnosticReport::ok(self : DiagnosticReport) -> Bool

    DiagnosticReport::summary

    fn DiagnosticReport::summary(self : DiagnosticReport) -> String

    DiagnosticSeverity

    pub(all) enum DiagnosticSeverity {
    Note
    WarningFinding
    ErrorFinding
    } derive(Eq,
    Debug
    )

    Severity of a diagnostic finding.

    EncodedAdu

    pub(all) struct EncodedAdu {
    mode : Mode
    transaction_id : UInt16
    bytes : Array[Byte]
    }

    An encoded ADU that can be handed to a socket or serial adapter.

    EncodedAdu::bytes

    fn EncodedAdu::bytes(self : EncodedAdu) -> Array[Byte]

    EncodedAdu::decode

    fn EncodedAdu::decode(self : EncodedAdu) -> Result[Frame, ModbusError]

    EncodedAdu::mode

    fn EncodedAdu::mode(self : EncodedAdu) -> Mode

    EncodedAdu::new

    fn EncodedAdu::new(mode : Mode, transaction_id : UInt16, frame : Frame) -> Result[EncodedAdu, ModbusError]

    EncodedAdu::transaction_id

    fn EncodedAdu::transaction_id(self : EncodedAdu) -> UInt16

    EndpointConfig

    pub(all) enum EndpointConfig {
    Serial(SerialConfig)
    Tcp(TcpConfig)
    }

    A transport endpoint configuration.

    EndpointConfig::mode

    fn EndpointConfig::mode(config : EndpointConfig) -> Mode

    EndpointConfig::name

    fn EndpointConfig::name(config : EndpointConfig) -> String

    EndpointHealth

    pub(all) struct EndpointHealth {
    unit_id : Byte
    ready : Bool
    event_count : UInt16
    exceptions : Int
    requests : Int
    responses : Int
    errors : Int
    }

    Aggregated endpoint health used by operations dashboards.

    EndpointRuntime

    pub(all) struct EndpointRuntime {
    config : EndpointConfig
    state : EndpointState
    opened_at : Int
    last_error : ModbusError?
    reconnects : Int
    frames_in : Int
    frames_out : Int
    }

    Runtime state tracked independently from operating-system handles.

    EndpointRuntime::backoff

    fn EndpointRuntime::backoff(self : EndpointRuntime) -> Unit

    EndpointRuntime::close

    fn EndpointRuntime::close(self : EndpointRuntime) -> Unit

    EndpointRuntime::config

    EndpointRuntime::fail

    fn EndpointRuntime::fail(self : EndpointRuntime, error : ModbusError) -> Unit

    EndpointRuntime::frames_in

    fn EndpointRuntime::frames_in(self : EndpointRuntime) -> Int

    EndpointRuntime::frames_out

    fn EndpointRuntime::frames_out(self : EndpointRuntime) -> Int

    EndpointRuntime::last_error

    fn EndpointRuntime::last_error(self : EndpointRuntime) -> ModbusError?

    EndpointRuntime::new

    EndpointRuntime::open

    fn EndpointRuntime::open(self : EndpointRuntime, now : Int) -> Result[Unit, ModbusError]

    EndpointRuntime::reconnects

    fn EndpointRuntime::reconnects(self : EndpointRuntime) -> Int

    EndpointRuntime::record_in

    fn EndpointRuntime::record_in(self : EndpointRuntime) -> Result[Unit, ModbusError]

    EndpointRuntime::record_out

    fn EndpointRuntime::record_out(self : EndpointRuntime) -> Result[Unit, ModbusError]

    EndpointRuntime::state

    EndpointRuntime::uptime

    fn EndpointRuntime::uptime(self : EndpointRuntime, now : Int) -> Int

    EndpointState

    pub(all) enum EndpointState {
    Closed
    Connecting
    Ready
    Backoff
    Faulted
    } derive(Eq,
    Debug
    )

    Lifecycle state of a transport endpoint.

    EngineeringUnit

    pub(all) enum EngineeringUnit {
    Unitless
    Percent
    Celsius
    Fahrenheit
    Pascal
    Kilopascal
    Volt
    Ampere
    Hertz
    Rpm
    Meter
    Millimeter
    LiterPerMinute
    } derive(Eq,
    Debug
    )

    Physical unit associated with an engineering value.

    EventDelivery

    pub(all) enum EventDelivery {
    EventPending
    EventDelivered
    EventFailed
    EventDeadLetter
    } derive(Eq,
    Debug
    )

    Delivery state used by durable event consumers.

    EventSubscription

    pub(all) struct EventSubscription {
    id : String
    source : String?
    kind : ServiceEventKind?
    enabled : Bool
    }

    Subscription filter for one consumer.

    EventSubscription::enabled

    fn EventSubscription::enabled(self : EventSubscription) -> Bool

    EventSubscription::id

    fn EventSubscription::id(self : EventSubscription) -> String

    EventSubscription::matches

    fn EventSubscription::matches(self : EventSubscription, event : ServiceEvent) -> Bool

    EventSubscription::new

    fn EventSubscription::new(id : String, source? : String, kind? : ServiceEventKind) -> Result[EventSubscription, ModbusError]

    EventSubscription::set_enabled

    fn EventSubscription::set_enabled(self : EventSubscription, enabled : Bool) -> Unit

    ExceptionCode

    pub(all) enum ExceptionCode {
    IllegalFunction
    IllegalDataAddress
    IllegalDataValue
    ServerDeviceFailure
    Acknowledge
    ServerDeviceBusy
    NegativeAcknowledge
    MemoryParityError
    GatewayPathUnavailable
    GatewayTargetFailedToRespond
    UnknownException(Byte)
    } derive(Eq,
    Debug
    )

    Standard exception codes returned by a Modbus server.

    ExceptionCode::to_byte

    fn ExceptionCode::to_byte(code : ExceptionCode) -> Byte

    ExchangeEnvelope

    pub(all) struct ExchangeEnvelope {
    source : String
    destination : String
    adu : EncodedAdu
    }

    A transport-neutral request envelope.

    ExchangeEnvelope::new

    fn ExchangeEnvelope::new(source : String, destination : String, adu : EncodedAdu) -> ExchangeEnvelope

    ExchangeEnvelope::size

    fn ExchangeEnvelope::size(self : ExchangeEnvelope) -> Int

    ExchangeState

    pub(all) enum ExchangeState {
    Pending
    Completed
    Failed
    Cancelled
    } derive(Eq,
    Debug
    )

    Lifecycle of a client-side exchange.

    FaultMode

    pub(all) enum FaultMode {
    NoFault
    DropResponse
    CorruptCrc
    CorruptLrc
    WrongTransaction
    BusyDevice
    InvalidFunction
    } derive(Eq,
    Debug
    )

    Deterministic fault modes for protocol integration tests.

    FileRecordReference

    pub(all) struct FileRecordReference {
    reference_type : Byte
    file_number : UInt16
    record_number : UInt16
    record_length : UInt16
    }

    A Modbus file-record selector.

    FileRecordReference::encoded_length

    fn FileRecordReference::encoded_length(_self : FileRecordReference) -> Int

    FileRecordReference::new

    fn FileRecordReference::new(file_number : UInt16, record_number : UInt16, record_length : UInt16, reference_type? : Byte) -> Result[FileRecordReference, ModbusError]

    FileRecordStore

    pub(all) struct FileRecordStore {
    records : Array[FileRecordWrite]
    max_records : Int
    }

    A bounded in-memory store for file records used by simulators.

    FileRecordStore::clear

    fn FileRecordStore::clear(self : FileRecordStore) -> Unit

    FileRecordStore::get

    fn FileRecordStore::get(self : FileRecordStore, reference : FileRecordReference) -> Result[Array[UInt16], ModbusError]

    FileRecordStore::length

    fn FileRecordStore::length(self : FileRecordStore) -> Int

    FileRecordStore::new

    fn FileRecordStore::new(max_records? : Int) -> Result[FileRecordStore, ModbusError]

    FileRecordStore::put

    fn FileRecordStore::put(self : FileRecordStore, record : FileRecordWrite) -> Result[Unit, ModbusError]

    FileRecordWrite

    pub(all) struct FileRecordWrite {
    reference : FileRecordReference
    values : Array[UInt16]
    }

    A file-record write item combines a selector and its register payload.

    FileRecordWrite::new

    fn FileRecordWrite::new(reference : FileRecordReference, values : Array[UInt16]) -> Result[FileRecordWrite, ModbusError]

    FirmwareConstraint

    pub(all) struct FirmwareConstraint {
    vendor : String
    model : String
    minimum : String
    recommended : String
    }

    A small firmware compatibility constraint.

    FirmwareConstraint::matches

    fn FirmwareConstraint::matches(self : FirmwareConstraint, device : InventoryDevice) -> Bool

    FirmwareConstraint::minimum

    fn FirmwareConstraint::minimum(self : FirmwareConstraint) -> String

    FirmwareConstraint::new

    fn FirmwareConstraint::new(vendor : String, model : String, minimum : String, recommended : String) -> Result[FirmwareConstraint, ModbusError]

    FirmwareConstraint::recommended

    fn FirmwareConstraint::recommended(self : FirmwareConstraint) -> String

    FleetHealthRollup

    pub(all) struct FleetHealthRollup {
    contributions : Array[HealthContribution]
    score : Int
    state : FleetHealthState
    timestamp : Int
    }

    Weighted score calculation used by operator dashboards.

    FleetHealthRollup::add

    fn FleetHealthRollup::add(self : FleetHealthRollup, contribution : HealthContribution) -> Result[Unit, ModbusError]

    FleetHealthRollup::contribution

    fn FleetHealthRollup::contribution(self : FleetHealthRollup, source : String) -> HealthContribution?

    FleetHealthRollup::contribution_count

    fn FleetHealthRollup::contribution_count(self : FleetHealthRollup) -> Int

    FleetHealthRollup::contributions

    FleetHealthRollup::export_lines

    fn FleetHealthRollup::export_lines(self : FleetHealthRollup) -> Array[String]

    A serializable health line for logs and support bundles.

    FleetHealthRollup::new

    fn FleetHealthRollup::new(timestamp : Int) -> Result[FleetHealthRollup, ModbusError]

    FleetHealthRollup::recalculate

    fn FleetHealthRollup::recalculate(self : FleetHealthRollup) -> Unit

    FleetHealthRollup::remove

    fn FleetHealthRollup::remove(self : FleetHealthRollup, source : String) -> Result[HealthContribution, ModbusError]

    FleetHealthRollup::score

    fn FleetHealthRollup::score(self : FleetHealthRollup) -> Int

    FleetHealthRollup::state

    FleetHealthRollup::timestamp

    fn FleetHealthRollup::timestamp(self : FleetHealthRollup) -> Int

    FleetHealthState

    pub(all) enum FleetHealthState {
    FleetHealthy
    FleetDegraded
    FleetCritical
    FleetEmpty
    } derive(Eq,
    Debug
    )

    Fleet-level state derived from reliability, services, and inventory.

    Frame

    pub(all) struct Frame {
    unit_id : Byte
    pdu : Pdu
    }

    A decoded frame, including the unit identifier.

    Frame::data_length

    fn Frame::data_length(self : Frame) -> Int

    Frame::function_code

    fn Frame::function_code(self : Frame) -> FunctionCode

    Frame::is_exception

    fn Frame::is_exception(self : Frame) -> Bool

    Frame::new

    fn Frame::new(unit_id : Byte, function : Byte, data : Array[Byte]) -> Frame

    FrameContract

    pub(all) struct FrameContract {
    id : String
    function : Byte
    request_min : Int
    request_max : Int
    response_min : Int
    response_max : Int
    require_echo : Bool
    }

    Expected shape of one application data unit.

    FrameContract::check

    fn FrameContract::check(self : FrameContract, request : Frame, response : Frame) -> ContractResult

    Validate a response against this function-level contract.

    FrameContract::function

    fn FrameContract::function(self : FrameContract) -> Byte

    FrameContract::id

    fn FrameContract::id(self : FrameContract) -> String

    FrameContract::new

    fn FrameContract::new(id : String, function : Byte, request_min : Int, request_max : Int, response_min : Int, response_max : Int, require_echo? : Bool) -> Result[FrameContract, ModbusError]

    FrameContract::request_max

    fn FrameContract::request_max(self : FrameContract) -> Int

    FrameContract::request_min

    fn FrameContract::request_min(self : FrameContract) -> Int

    FrameContract::require_echo

    fn FrameContract::require_echo(self : FrameContract) -> Bool

    FrameContract::response_max

    fn FrameContract::response_max(self : FrameContract) -> Int

    FrameContract::response_min

    fn FrameContract::response_min(self : FrameContract) -> Int

    FrameContractCatalog

    pub(all) struct FrameContractCatalog {
    contracts : Array[FrameContract]
    max_contracts : Int
    }

    A catalog of frame contracts used by server and gateway adapters.

    FrameContractCatalog::add

    fn FrameContractCatalog::add(self : FrameContractCatalog, contract : FrameContract) -> Result[Unit, ModbusError]

    FrameContractCatalog::check

    fn FrameContractCatalog::check(self : FrameContractCatalog, request : Frame, response : Frame) -> Result[ContractResult, ModbusError]

    FrameContractCatalog::check_all

    Check all known standard functions and return the first failure.

    FrameContractCatalog::count

    FrameContractCatalog::find

    fn FrameContractCatalog::find(self : FrameContractCatalog, function : Byte) -> FrameContract?

    FrameContractCatalog::new

    fn FrameContractCatalog::new(max_contracts? : Int) -> Result[FrameContractCatalog, ModbusError]

    FrameFingerprint

    pub(all) struct FrameFingerprint {
    unit_id : Byte
    function : Byte
    data_length : Int
    checksum : Int
    }

    Immutable frame fingerprint for duplicate detection.

    FrameFingerprint::checksum

    fn FrameFingerprint::checksum(self : FrameFingerprint) -> Int

    FrameFingerprint::data_length

    fn FrameFingerprint::data_length(self : FrameFingerprint) -> Int

    FrameFingerprint::from_frame

    fn FrameFingerprint::from_frame(frame : Frame) -> FrameFingerprint

    FrameFingerprint::function

    fn FrameFingerprint::function(self : FrameFingerprint) -> Byte

    FrameFingerprint::same

    fn FrameFingerprint::same(self : FrameFingerprint, other : FrameFingerprint) -> Bool

    FrameFingerprint::unit_id

    fn FrameFingerprint::unit_id(self : FrameFingerprint) -> Byte

    FrameSequence

    pub struct FrameSequence {
    frames : Array[Frame]
    max_frames : Int
    }

    A bounded ordered collection of frames for gateways and batch adapters.

    FrameSequence::encoded_bytes

    fn FrameSequence::encoded_bytes(self : FrameSequence, mode : Mode) -> Int

    FrameSequence::filter_function

    fn FrameSequence::filter_function(self : FrameSequence, function : Byte) -> Array[Frame]

    FrameSequence::filter_unit

    fn FrameSequence::filter_unit(self : FrameSequence, unit_id : Byte) -> Array[Frame]

    FrameSequence::get

    fn FrameSequence::get(self : FrameSequence, index : Int) -> Result[Frame, ModbusError]

    FrameSequence::length

    fn FrameSequence::length(self : FrameSequence) -> Int

    FrameSequence::new

    fn FrameSequence::new(max_frames? : Int) -> Result[FrameSequence, ModbusError]

    FrameSequence::push

    fn FrameSequence::push(self : FrameSequence, frame : Frame) -> Result[Unit, ModbusError]

    FrameSequence::snapshot

    fn FrameSequence::snapshot(self : FrameSequence) -> Array[Frame]

    FrameSequence::validate

    fn FrameSequence::validate(self : FrameSequence, allow_broadcast : Bool) -> Result[Unit, ModbusError]

    FrameStream

    pub struct FrameStream {
    mode : Mode
    parser : IncrementalParser
    queue : ByteQueue
    chunks : Int
    frames : Int
    }

    A frame stream combines a byte queue with the protocol parser.

    FrameStream::chunks

    fn FrameStream::chunks(self : FrameStream) -> Int

    FrameStream::finish

    fn FrameStream::finish(self : FrameStream) -> Result[Frame, ModbusError]

    FrameStream::frames

    fn FrameStream::frames(self : FrameStream) -> Int

    FrameStream::mode

    fn FrameStream::mode(self : FrameStream) -> Mode

    FrameStream::new

    fn FrameStream::new(mode : Mode, role? : ParserRole, max_buffer? : Int, max_frame? : Int) -> Result[FrameStream, ModbusError]

    FrameStream::push

    fn FrameStream::push(self : FrameStream, bytes : Array[Byte]) -> Result[Array[Frame], ModbusError]

    FrameStream::reset

    fn FrameStream::reset(self : FrameStream) -> Unit

    FrameSummary

    pub(all) struct FrameSummary {
    unit_id : Byte
    function : Byte
    data_length : Int
    exception : Bool
    }

    A compact description useful for logs and metrics.

    FrameTextLog

    pub struct FrameTextLog {
    entries : Array[String]
    max_entries : Int
    }

    A bounded text trace used by CLI tools and embedded diagnostics.

    FrameTextLog::clear

    fn FrameTextLog::clear(self : FrameTextLog) -> Unit

    FrameTextLog::length

    fn FrameTextLog::length(self : FrameTextLog) -> Int

    FrameTextLog::lines

    fn FrameTextLog::lines(self : FrameTextLog) -> Array[String]

    FrameTextLog::new

    fn FrameTextLog::new(max_entries? : Int) -> Result[FrameTextLog, ModbusError]

    FrameTextLog::push

    fn FrameTextLog::push(self : FrameTextLog, line : String) -> Unit

    FrameTextLog::record

    fn FrameTextLog::record(self : FrameTextLog, direction : String, frame : Frame) -> Unit

    FrameTextLog::record_wire

    fn FrameTextLog::record_wire(self : FrameTextLog, direction : String, mode : Mode, transaction_id : UInt16, frame : Frame) -> Unit

    FunctionCode

    pub(all) enum FunctionCode {
    ReadCoils
    ReadDiscreteInputs
    ReadHoldingRegisters
    ReadInputRegisters
    WriteSingleCoil
    WriteSingleRegister
    ReadExceptionStatus
    Diagnostics
    GetCommEventCounter
    GetCommEventLog
    ReportServerId
    WriteMultipleCoils
    WriteMultipleRegisters
    ReportServerIdExtended
    ReadFileRecord
    WriteFileRecord
    MaskWriteRegister
    ReadWriteMultipleRegisters
    ReadFifoQueue
    EncapsulatedInterface
    Unknown(Byte)
    } derive(Eq,
    Debug
    )

    The function codes defined by the Modbus application protocol.

    FunctionCode::to_byte

    fn FunctionCode::to_byte(code : FunctionCode) -> Byte

    Return the numeric representation of a typed function code.

    FunctionDescriptor

    pub(all) struct FunctionDescriptor {
    function : Byte
    name : String
    request_min : Int
    request_max : Int
    response_variable : Bool
    writable : Bool
    description : String
    }

    Metadata used by configuration UIs and validation tools.

    FunctionDescriptor::description

    fn FunctionDescriptor::description(self : FunctionDescriptor) -> String

    FunctionDescriptor::function

    fn FunctionDescriptor::function(self : FunctionDescriptor) -> Byte

    FunctionDescriptor::is_write

    fn FunctionDescriptor::is_write(self : FunctionDescriptor) -> Bool

    FunctionDescriptor::name

    fn FunctionDescriptor::name(self : FunctionDescriptor) -> String

    FunctionDescriptor::supports_request

    fn FunctionDescriptor::supports_request(self : FunctionDescriptor, length : Int) -> Bool

    Gateway

    pub struct Gateway {
    rules : Array[GatewayRule]
    forwarded : Int
    rejected : Int
    translated : Int
    }

    A deterministic frame gateway that rewrites unit ids and register/coil addresses.

    Gateway::add_rule

    fn Gateway::add_rule(self : Gateway, rule : GatewayRule) -> Result[Unit, ModbusError]

    Gateway::forwarded_count

    fn Gateway::forwarded_count(self : Gateway) -> Int

    Gateway::new

    fn Gateway::new() -> Gateway

    Gateway::rejected_count

    fn Gateway::rejected_count(self : Gateway) -> Int

    Gateway::reset_metrics

    fn Gateway::reset_metrics(self : Gateway) -> Unit

    Gateway::reverse

    fn Gateway::reverse(self : Gateway, request : Frame, response : Frame) -> Result[Frame, ModbusError]

    Translate a response back to the source address space.

    Gateway::rule_count

    fn Gateway::rule_count(self : Gateway) -> Int

    Gateway::rules

    fn Gateway::rules(self : Gateway) -> Array[GatewayRule]

    Gateway::translate

    fn Gateway::translate(self : Gateway, frame : Frame) -> Result[Frame, ModbusError]

    Translate one request according to the first matching rule.

    Gateway::translated_count

    fn Gateway::translated_count(self : Gateway) -> Int

    GatewayPolicyTable

    pub(all) struct GatewayPolicyTable {
    policies : Array[ServiceGatewayPolicy]
    max_policies : Int
    }

    Fleet-level route table for selecting one policy by endpoint pair.

    GatewayPolicyTable::add

    fn GatewayPolicyTable::add(self : GatewayPolicyTable, policy : ServiceGatewayPolicy) -> Result[Unit, ModbusError]

    GatewayPolicyTable::count

    fn GatewayPolicyTable::count(self : GatewayPolicyTable) -> Int

    GatewayPolicyTable::evaluate

    fn GatewayPolicyTable::evaluate(self : GatewayPolicyTable, source : String, destination : String, frame : Frame) -> Result[BridgeDecision, ModbusError]

    GatewayPolicyTable::find

    fn GatewayPolicyTable::find(self : GatewayPolicyTable, source : String, destination : String) -> ServiceGatewayPolicy?

    GatewayPolicyTable::new

    fn GatewayPolicyTable::new(max_policies? : Int) -> Result[GatewayPolicyTable, ModbusError]

    GatewayPolicyTable::routes

    fn GatewayPolicyTable::routes(self : GatewayPolicyTable) -> Array[String]

    GatewayRoute

    pub(all) struct GatewayRoute {
    name : String
    gateway : Gateway
    device : Device
    client : Client
    }

    A gateway route that combines a rule set, client, and virtual device.

    GatewayRoute::add_rule

    fn GatewayRoute::add_rule(self : GatewayRoute, rule : GatewayRule) -> Result[Unit, ModbusError]

    GatewayRoute::exchange

    fn GatewayRoute::exchange(self : GatewayRoute, request : Frame) -> Result[Frame, ModbusError]

    GatewayRoute::metrics

    fn GatewayRoute::metrics(self : GatewayRoute) -> (Int, Int, Int)

    GatewayRoute::name

    fn GatewayRoute::name(self : GatewayRoute) -> String

    GatewayRoute::new

    fn GatewayRoute::new(name : String, mode : Mode, device : Device) -> GatewayRoute

    GatewayRule

    pub(all) struct GatewayRule {
    source_unit : Byte
    target_unit : Byte
    function : Byte
    source_start : UInt16
    target_start : UInt16
    span : Int
    enabled : Bool
    }

    Address mapping rule for a protocol gateway.

    GatewayRule::enable

    fn GatewayRule::enable(self : GatewayRule, enabled : Bool) -> Unit

    GatewayRule::matches

    fn GatewayRule::matches(self : GatewayRule, frame : Frame) -> Bool

    GatewayRule::new

    fn GatewayRule::new(source_unit : Byte, target_unit : Byte, function : Byte, source_start : UInt16, target_start : UInt16, span : Int) -> Result[GatewayRule, ModbusError]

    GuardDecision

    pub(all) enum GuardDecision {
    AdmitFrame
    RejectFrame
    DeferFrame
    DuplicateFrame
    QuotaFrame
    OversizeFrame
    } derive(Eq,
    Debug
    )

    Decision made before a frame enters a server or gateway pipeline.

    GuardEvent

    pub(all) struct GuardEvent {
    sequence : Int
    timestamp : Int
    peer : String
    decision : GuardDecision
    reason : GuardReason
    unit_id : Byte
    function : Byte
    frame_bytes : Int
    fingerprint : FrameFingerprint
    }

    Admission event retained for metrics and support diagnostics.

    GuardEvent::decision

    fn GuardEvent::decision(self : GuardEvent) -> GuardDecision

    GuardEvent::fingerprint

    fn GuardEvent::fingerprint(self : GuardEvent) -> FrameFingerprint

    GuardEvent::frame_bytes

    fn GuardEvent::frame_bytes(self : GuardEvent) -> Int

    GuardEvent::function

    fn GuardEvent::function(self : GuardEvent) -> Byte

    GuardEvent::new

    fn GuardEvent::new(sequence : Int, timestamp : Int, peer : String, decision : GuardDecision, reason : GuardReason, frame : Frame) -> Result[GuardEvent, ModbusError]

    GuardEvent::peer

    fn GuardEvent::peer(self : GuardEvent) -> String

    GuardEvent::reason

    fn GuardEvent::reason(self : GuardEvent) -> GuardReason

    GuardEvent::sequence

    fn GuardEvent::sequence(self : GuardEvent) -> Int

    GuardEvent::timestamp

    fn GuardEvent::timestamp(self : GuardEvent) -> Int

    GuardEvent::unit_id

    fn GuardEvent::unit_id(self : GuardEvent) -> Byte

    GuardReason

    pub(all) enum GuardReason {
    GuardAccepted
    GuardBadUnit
    GuardBadFunction
    GuardBadLength
    GuardDuplicate
    GuardRateLimited
    GuardTooLarge
    GuardUnknownPeer
    } derive(Eq,
    Debug
    )

    Reason included in a protocol admission record.

    HealthContribution

    pub(all) struct HealthContribution {
    source : String
    score : Int
    weight : Int
    detail : String
    }

    A weighted health contribution from one subsystem.

    HealthContribution::detail

    fn HealthContribution::detail(self : HealthContribution) -> String

    HealthContribution::new

    fn HealthContribution::new(source : String, score : Int, weight : Int, detail : String) -> Result[HealthContribution, ModbusError]

    HealthContribution::score

    fn HealthContribution::score(self : HealthContribution) -> Int

    HealthContribution::source

    fn HealthContribution::source(self : HealthContribution) -> String

    HealthContribution::weight

    fn HealthContribution::weight(self : HealthContribution) -> Int

    Historian

    pub(all) struct Historian {
    series : Array[TagSeries]
    max_points : Int
    per_point_capacity : Int
    }

    A bounded multi-point historian.

    Historian::aggregate

    fn Historian::aggregate(self : Historian, point_id : String, start : Int, end : Int, aggregation : Aggregation) -> Result[Int, ModbusError]

    Historian::append

    fn Historian::append(self : Historian, sample : TagSample) -> Result[Unit, ModbusError]

    Historian::clear

    fn Historian::clear(self : Historian) -> Unit

    Historian::ensure_point

    fn Historian::ensure_point(self : Historian, point_id : String) -> Result[Unit, ModbusError]

    Historian::get

    fn Historian::get(self : Historian, point_id : String) -> TagSeries?

    Historian::new

    fn Historian::new(max_points? : Int, per_point_capacity? : Int) -> Result[Historian, ModbusError]

    Historian::point_count

    fn Historian::point_count(self : Historian) -> Int

    Historian::query

    fn Historian::query(self : Historian, point_id : String, start : Int, end : Int) -> Result[Array[TagSample], ModbusError]

    Historian::remove

    fn Historian::remove(self : Historian, point_id : String) -> Result[TagSeries, ModbusError]

    Historian::series_snapshot

    fn Historian::series_snapshot(self : Historian) -> Array[TagSeries]

    Historian::summary

    fn Historian::summary(self : Historian) -> String

    Historian::total_samples

    fn Historian::total_samples(self : Historian) -> Int

    HistoryBucket

    pub(all) struct HistoryBucket {
    start : Int
    end : Int
    count : Int
    minimum : Int
    maximum : Int
    sum : Int
    }

    A fixed interval bucket for downsampled exports.

    HistoryBucket::add

    fn HistoryBucket::add(self : HistoryBucket, value : Int) -> Unit

    HistoryBucket::average

    fn HistoryBucket::average(self : HistoryBucket) -> Int

    HistoryBucket::contains

    fn HistoryBucket::contains(self : HistoryBucket, timestamp : Int) -> Bool

    HistoryBucket::count

    fn HistoryBucket::count(self : HistoryBucket) -> Int

    HistoryBucket::end

    fn HistoryBucket::end(self : HistoryBucket) -> Int

    HistoryBucket::maximum

    fn HistoryBucket::maximum(self : HistoryBucket) -> Int

    HistoryBucket::minimum

    fn HistoryBucket::minimum(self : HistoryBucket) -> Int

    HistoryBucket::new

    fn HistoryBucket::new(start : Int, width : Int, first : Int) -> Result[HistoryBucket, ModbusError]

    HistoryBucket::start

    fn HistoryBucket::start(self : HistoryBucket) -> Int

    IncrementalParser

    pub struct IncrementalParser {
    mode : Mode
    role : ParserRole
    buffer : Array[Byte]
    max_frame : Int
    frames_seen : Int
    errors_seen : Int
    }

    A bounded incremental parser for stream transports.

    IncrementalParser::buffered

    fn IncrementalParser::buffered(self : IncrementalParser) -> Int

    Return the number of bytes waiting in the parser.

    IncrementalParser::errors_seen

    fn IncrementalParser::errors_seen(self : IncrementalParser) -> Int

    IncrementalParser::feed

    fn IncrementalParser::feed(self : IncrementalParser, input : Array[Byte]) -> Result[Array[Frame], ModbusError]

    Feed bytes and return every complete frame currently available.

    IncrementalParser::feed_byte

    fn IncrementalParser::feed_byte(self : IncrementalParser, byte : Byte) -> Result[Array[Frame], ModbusError]

    Feed a single byte without allocating an input array at the call site.

    IncrementalParser::finish

    fn IncrementalParser::finish(self : IncrementalParser) -> Result[Frame, ModbusError]

    Finish a serial frame at an externally supplied RTU silent interval.

    IncrementalParser::frames_seen

    fn IncrementalParser::frames_seen(self : IncrementalParser) -> Int

    IncrementalParser::max_frame

    fn IncrementalParser::max_frame(self : IncrementalParser) -> Int

    IncrementalParser::mode

    IncrementalParser::new

    fn IncrementalParser::new(mode : Mode, max_frame? : Int, role? : ParserRole) -> IncrementalParser

    Create a stream parser. max_frame prevents unbounded input growth.

    IncrementalParser::reset

    fn IncrementalParser::reset(self : IncrementalParser) -> Unit

    Discard buffered bytes after a transport reset.

    IncrementalParser::role

    IncrementalParser::set_max_frame

    fn IncrementalParser::set_max_frame(self : IncrementalParser, max_frame : Int) -> Result[Unit, ModbusError]

    Change the maximum frame size for a parser that is already in use.

    IncrementalParser::take_buffer

    fn IncrementalParser::take_buffer(self : IncrementalParser) -> Array[Byte]

    Take the current buffered bytes and reset the parser.

    InventoryDevice

    pub(all) struct InventoryDevice {
    id : String
    label : String
    vendor : String
    model : String
    serial : String
    firmware : String
    unit_id : Byte
    transport : String
    state : InventoryState
    last_seen : Int?
    tags : Array[String]
    }

    Firmware and identity metadata used by fleet operations.

    InventoryDevice::add_tag

    fn InventoryDevice::add_tag(self : InventoryDevice, tag : String) -> Result[Unit, ModbusError]

    InventoryDevice::firmware

    fn InventoryDevice::firmware(self : InventoryDevice) -> String

    InventoryDevice::has_tag

    fn InventoryDevice::has_tag(self : InventoryDevice, tag : String) -> Bool

    InventoryDevice::id

    fn InventoryDevice::id(self : InventoryDevice) -> String

    InventoryDevice::label

    fn InventoryDevice::label(self : InventoryDevice) -> String

    InventoryDevice::last_seen

    fn InventoryDevice::last_seen(self : InventoryDevice) -> Int?

    InventoryDevice::mark_seen

    fn InventoryDevice::mark_seen(self : InventoryDevice, timestamp : Int) -> Result[Unit, ModbusError]

    InventoryDevice::model

    fn InventoryDevice::model(self : InventoryDevice) -> String

    InventoryDevice::new

    fn InventoryDevice::new(id : String, label : String, vendor : String, model : String, serial : String, firmware : String, unit_id : Byte, transport : String) -> Result[InventoryDevice, ModbusError]

    InventoryDevice::serial

    fn InventoryDevice::serial(self : InventoryDevice) -> String

    InventoryDevice::set_state

    fn InventoryDevice::set_state(self : InventoryDevice, state : InventoryState) -> Unit

    InventoryDevice::stale

    fn InventoryDevice::stale(self : InventoryDevice, now : Int, timeout : Int) -> Result[Bool, ModbusError]

    InventoryDevice::state

    InventoryDevice::transport

    fn InventoryDevice::transport(self : InventoryDevice) -> String

    InventoryDevice::unit_id

    fn InventoryDevice::unit_id(self : InventoryDevice) -> Byte

    InventoryDevice::vendor

    fn InventoryDevice::vendor(self : InventoryDevice) -> String

    InventoryState

    pub(all) enum InventoryState {
    InventoryDiscovered
    InventoryProvisioned
    InventoryOnline
    InventoryOffline
    InventoryRetired
    } derive(Eq,
    Debug
    )

    Lifecycle state of an enrolled industrial device.

    JobPriority

    pub(all) enum JobPriority {
    Background
    NormalPriority
    HighPriority
    Emergency
    } derive(Eq,
    Debug
    )

    Priority used by the application-level request scheduler.

    JobScheduler

    pub(all) struct JobScheduler {
    jobs : Array[ScheduledJob]
    max_jobs : Int
    now : Int
    dispatched : Int
    completed : Int
    failed : Int
    cancelled : Int
    }

    A bounded scheduler with priority-aware due-job selection.

    JobScheduler::add

    fn JobScheduler::add(self : JobScheduler, job : ScheduledJob) -> Result[Unit, ModbusError]

    JobScheduler::cancel

    fn JobScheduler::cancel(self : JobScheduler, id : String) -> Result[Unit, ModbusError]

    JobScheduler::cancelled

    fn JobScheduler::cancelled(self : JobScheduler) -> Int

    JobScheduler::complete

    fn JobScheduler::complete(self : JobScheduler, id : String, now : Int) -> Result[Unit, ModbusError]

    JobScheduler::completed

    fn JobScheduler::completed(self : JobScheduler) -> Int

    JobScheduler::dispatch

    fn JobScheduler::dispatch(self : JobScheduler, now : Int) -> Result[ScheduledJob, ModbusError]

    JobScheduler::dispatched

    fn JobScheduler::dispatched(self : JobScheduler) -> Int

    JobScheduler::due_count

    fn JobScheduler::due_count(self : JobScheduler, now : Int) -> Int

    JobScheduler::fail

    fn JobScheduler::fail(self : JobScheduler, id : String, error : ModbusError, now : Int) -> Result[Bool, ModbusError]

    JobScheduler::failed

    fn JobScheduler::failed(self : JobScheduler) -> Int

    JobScheduler::find

    fn JobScheduler::find(self : JobScheduler, id : String) -> ScheduledJob?

    JobScheduler::get

    fn JobScheduler::get(self : JobScheduler, index : Int) -> Result[ScheduledJob, ModbusError]

    JobScheduler::length

    fn JobScheduler::length(self : JobScheduler) -> Int

    JobScheduler::new

    fn JobScheduler::new(max_jobs? : Int) -> Result[JobScheduler, ModbusError]

    JobScheduler::next_due

    fn JobScheduler::next_due(self : JobScheduler, now : Int) -> ScheduledJob?

    JobScheduler::now

    fn JobScheduler::now(self : JobScheduler) -> Int

    JobScheduler::remove

    fn JobScheduler::remove(self : JobScheduler, id : String) -> Result[ScheduledJob, ModbusError]

    JobScheduler::reschedule

    fn JobScheduler::reschedule(self : JobScheduler, id : String, due_at : Int) -> Result[Unit, ModbusError]

    JobScheduler::reset_metrics

    fn JobScheduler::reset_metrics(self : JobScheduler) -> Unit

    JobScheduler::snapshot

    fn JobScheduler::snapshot(self : JobScheduler) -> Array[ScheduledJob]

    JobScheduler::snapshot_metrics

    fn JobScheduler::snapshot_metrics(self : JobScheduler) -> SchedulerSnapshot

    JobScheduler::state_count

    fn JobScheduler::state_count(self : JobScheduler, state : JobState) -> Int

    JobScheduler::summary

    fn JobScheduler::summary(self : JobScheduler) -> String

    JobState

    pub(all) enum JobState {
    Ready
    InFlight
    Waiting
    Completed
    Failed
    Cancelled
    } derive(Eq,
    Debug
    )

    Lifecycle state of a scheduled request.

    LatencyHistogram

    pub(all) struct LatencyHistogram {
    bounds : Array[Int]
    counts : Array[Int]
    total : Int
    sum : Int
    }

    Fixed latency buckets, expressed in logical ticks.

    LatencyHistogram::bucket_counts

    fn LatencyHistogram::bucket_counts(self : LatencyHistogram) -> Array[Int]

    LatencyHistogram::mean

    fn LatencyHistogram::mean(self : LatencyHistogram) -> Float

    LatencyHistogram::new

    fn LatencyHistogram::new(bounds : Array[Int]) -> Result[LatencyHistogram, ModbusError]

    LatencyHistogram::observe

    fn LatencyHistogram::observe(self : LatencyHistogram, ticks : Int) -> Result[Unit, ModbusError]

    LatencyHistogram::sum

    fn LatencyHistogram::sum(self : LatencyHistogram) -> Int

    LatencyHistogram::total

    fn LatencyHistogram::total(self : LatencyHistogram) -> Int

    LeaseManager

    pub(all) struct LeaseManager {
    leases : Array[ResourceLease]
    max_leases : Int
    default_duration : Int
    sequence : Int
    }

    Manages exclusive resource ownership across client workers.

    LeaseManager::acquire

    fn LeaseManager::acquire(self : LeaseManager, resource : String, owner : String, now : Int, priority? : Int) -> Result[ResourceLease, ModbusError]

    Acquire a resource if no active lease has a higher or equal priority.

    LeaseManager::active_resources

    fn LeaseManager::active_resources(self : LeaseManager, now : Int) -> Result[Array[String], ModbusError]

    Return resource names with an active owner.

    LeaseManager::compact

    fn LeaseManager::compact(self : LeaseManager, before : Int) -> Result[Int, ModbusError]

    Clean up old terminal leases while retaining recent history.

    LeaseManager::count

    fn LeaseManager::count(self : LeaseManager) -> Int

    LeaseManager::default_duration

    fn LeaseManager::default_duration(self : LeaseManager) -> Int

    LeaseManager::expire

    fn LeaseManager::expire(self : LeaseManager, now : Int) -> Result[Int, ModbusError]

    Expire inactive leases and return their count.

    LeaseManager::find

    fn LeaseManager::find(self : LeaseManager, resource : String) -> ResourceLease?

    LeaseManager::new

    fn LeaseManager::new(max_leases? : Int, default_duration? : Int) -> Result[LeaseManager, ModbusError]

    LeaseManager::owned_by

    fn LeaseManager::owned_by(self : LeaseManager, owner : String, now : Int) -> Result[Array[String], ModbusError]

    Return active leases for a given owner.

    LeaseManager::release

    fn LeaseManager::release(self : LeaseManager, lease_id : String, owner : String) -> Result[Unit, ModbusError]

    Release a lease at the end of a request or connection.

    LeaseManager::renew

    fn LeaseManager::renew(self : LeaseManager, lease_id : String, owner : String, now : Int, duration? : Int) -> Result[Unit, ModbusError]

    Renew a lease only for its current owner.

    LeaseState

    pub(all) enum LeaseState {
    LeaseAvailable
    LeaseHeld
    LeaseExpired
    LeaseRevoked
    } derive(Eq,
    Debug
    )

    Ownership state for a serial line, TCP endpoint, or device command lane.

    MaintenanceKind

    pub(all) enum MaintenanceKind {
    Inspection
    Calibration
    Cleaning
    FirmwareUpdate
    CableReplacement
    PreventiveService
    CorrectiveRepair
    } derive(Eq,
    Debug
    )

    Type of maintenance activity tracked for a field device.

    MaintenancePlanner

    pub(all) struct MaintenancePlanner {
    plans : Array[ServicePlan]
    records : Array[ServiceRecord]
    work_orders : Array[MaintenanceWorkOrder]
    max_records : Int
    max_orders : Int
    }

    Plan and audit maintenance across multiple devices.

    MaintenancePlanner::add_plan

    fn MaintenancePlanner::add_plan(self : MaintenancePlanner, plan : ServicePlan) -> Result[Unit, ModbusError]

    MaintenancePlanner::add_record

    fn MaintenancePlanner::add_record(self : MaintenancePlanner, record : ServiceRecord) -> Result[Unit, ModbusError]

    MaintenancePlanner::add_work_order

    fn MaintenancePlanner::add_work_order(self : MaintenancePlanner, order : MaintenanceWorkOrder) -> Result[Unit, ModbusError]

    MaintenancePlanner::complete_order

    fn MaintenancePlanner::complete_order(self : MaintenancePlanner, order_id : String, timestamp : Int, note? : String) -> Result[Unit, ModbusError]

    Complete a linked order and update the corresponding service plan.

    MaintenancePlanner::due_plans

    fn MaintenancePlanner::due_plans(self : MaintenancePlanner, now : Int) -> Result[Array[String], ModbusError]

    Return plans due or overdue at a timestamp.

    MaintenancePlanner::generate_due

    fn MaintenancePlanner::generate_due(self : MaintenancePlanner, now : Int) -> Result[Int, ModbusError]

    Generate due work orders for plans that have not been scheduled at now.

    MaintenancePlanner::history_count

    fn MaintenancePlanner::history_count(self : MaintenancePlanner, asset_id : String, start : Int, end : Int) -> Result[Int, ModbusError]

    Count service records for an asset within a time range.

    MaintenancePlanner::new

    fn MaintenancePlanner::new(max_records? : Int, max_orders? : Int) -> Result[MaintenancePlanner, ModbusError]

    MaintenancePlanner::open_orders

    fn MaintenancePlanner::open_orders(self : MaintenancePlanner, now : Int, overdue_only? : Bool) -> Result[Array[String], ModbusError]

    Return the IDs of open work orders, optionally limited to overdue work.

    MaintenancePlanner::plan

    fn MaintenancePlanner::plan(self : MaintenancePlanner, id : String) -> ServicePlan?

    MaintenancePlanner::plan_count

    fn MaintenancePlanner::plan_count(self : MaintenancePlanner) -> Int

    MaintenancePlanner::record_count

    fn MaintenancePlanner::record_count(self : MaintenancePlanner) -> Int

    MaintenancePlanner::summary

    fn MaintenancePlanner::summary(self : MaintenancePlanner, now : Int) -> Result[MaintenanceSummary, ModbusError]

    MaintenancePlanner::work_order

    fn MaintenancePlanner::work_order(self : MaintenancePlanner, id : String) -> MaintenanceWorkOrder?

    MaintenancePlanner::work_order_count

    fn MaintenancePlanner::work_order_count(self : MaintenancePlanner) -> Int

    MaintenancePriority

    pub(all) enum MaintenancePriority {
    Routine
    Important
    Urgent
    Critical
    } derive(Eq,
    Debug
    )

    Priority assigned by an operator or by an automated due-date rule.

    MaintenanceSummary

    pub(all) struct MaintenanceSummary {
    plans : Int
    due : Int
    overdue : Int
    completed : Int
    open : Int
    records : Int
    }

    Summary for maintenance dashboards and export jobs.

    MaintenanceSummary::completed

    fn MaintenanceSummary::completed(self : MaintenanceSummary) -> Int

    MaintenanceSummary::due

    fn MaintenanceSummary::due(self : MaintenanceSummary) -> Int

    MaintenanceSummary::open

    fn MaintenanceSummary::open(self : MaintenanceSummary) -> Int

    MaintenanceSummary::overdue

    fn MaintenanceSummary::overdue(self : MaintenanceSummary) -> Int

    MaintenanceSummary::plans

    fn MaintenanceSummary::plans(self : MaintenanceSummary) -> Int

    MaintenanceSummary::records

    fn MaintenanceSummary::records(self : MaintenanceSummary) -> Int

    MaintenanceSummary::summary

    fn MaintenanceSummary::summary(self : MaintenanceSummary) -> String

    MaintenanceWorkOrder

    pub(all) struct MaintenanceWorkOrder {
    id : String
    asset_id : String
    plan_id : String?
    title : String
    priority : MaintenancePriority
    state : WorkOrderState
    created_at : Int
    due_at : Int
    assigned_to : String?
    started_at : Int?
    finished_at : Int?
    note : String
    }

    An actionable unit of work generated from a service plan or alarm.

    MaintenanceWorkOrder::asset_id

    fn MaintenanceWorkOrder::asset_id(self : MaintenanceWorkOrder) -> String

    MaintenanceWorkOrder::assign

    fn MaintenanceWorkOrder::assign(self : MaintenanceWorkOrder, technician : String) -> Result[Unit, ModbusError]

    MaintenanceWorkOrder::assigned_to

    fn MaintenanceWorkOrder::assigned_to(self : MaintenanceWorkOrder) -> String?

    MaintenanceWorkOrder::block

    fn MaintenanceWorkOrder::block(self : MaintenanceWorkOrder, note : String) -> Result[Unit, ModbusError]

    MaintenanceWorkOrder::cancel

    fn MaintenanceWorkOrder::cancel(self : MaintenanceWorkOrder, reason : String) -> Result[Unit, ModbusError]

    MaintenanceWorkOrder::complete

    fn MaintenanceWorkOrder::complete(self : MaintenanceWorkOrder, timestamp : Int, note? : String) -> Result[Unit, ModbusError]

    MaintenanceWorkOrder::continue_work

    fn MaintenanceWorkOrder::continue_work(self : MaintenanceWorkOrder) -> Result[Unit, ModbusError]

    MaintenanceWorkOrder::created_at

    fn MaintenanceWorkOrder::created_at(self : MaintenanceWorkOrder) -> Int

    MaintenanceWorkOrder::due_at

    fn MaintenanceWorkOrder::due_at(self : MaintenanceWorkOrder) -> Int

    MaintenanceWorkOrder::duration

    fn MaintenanceWorkOrder::duration(self : MaintenanceWorkOrder) -> Int?

    MaintenanceWorkOrder::id

    MaintenanceWorkOrder::is_due

    fn MaintenanceWorkOrder::is_due(self : MaintenanceWorkOrder, now : Int) -> Bool

    MaintenanceWorkOrder::is_overdue

    fn MaintenanceWorkOrder::is_overdue(self : MaintenanceWorkOrder, now : Int) -> Bool

    MaintenanceWorkOrder::new

    fn MaintenanceWorkOrder::new(id : String, asset_id : String, title : String, priority : MaintenancePriority, created_at : Int, due_at : Int, plan_id? : String) -> Result[MaintenanceWorkOrder, ModbusError]

    MaintenanceWorkOrder::note

    fn MaintenanceWorkOrder::note(self : MaintenanceWorkOrder) -> String

    MaintenanceWorkOrder::plan_id

    fn MaintenanceWorkOrder::plan_id(self : MaintenanceWorkOrder) -> String?

    MaintenanceWorkOrder::priority

    MaintenanceWorkOrder::start