@flux-control/effect-modbus-rs
    Preparing search index...

    Interface CoilCache

    A belief about the coil states on a bus.

    This is the coil form of RegisterCache. It stores one boolean for each unit and coil address. Coils and holding registers are separate address spaces, so they use separate caches.

    The cache records only what this process wrote. It does not read the device.

    interface CoilCache {
        size: number;
        filter(unitId: number, writes: readonly CoilWrite[]): CoilCacheFilter;
        generationOf(unitId: number): number;
        invalidate(unitId?: number): void;
        observe(
            unitId: number,
            address: number,
            value: boolean,
            generation?: number,
        ): void;
        valueOf(unitId: number, address: number): boolean | undefined;
    }
    Index
    size: number

    Coils the cache currently holds a state for. Intended for tests.

    • Splits proposed writes into the ones that change a coil and the ones that do not. When an address appears more than once, the last write wins.

      Parameters

      Returns CoilCacheFilter

      RangeError - An address is out of range, or a value is not a boolean.

    • How many times what this cache believes about a unit has been discarded. Read it before a write, and give it to observe.

      Parameters

      • unitId: number

      Returns number

    • Forgets what a unit holds, or what every unit holds when unitId is omitted.

      Parameters

      • OptionalunitId: number

      Returns void

    • Records that a coil now holds a state.

      Call this only after the device acknowledged the write. When generation is given and the unit was invalidated after it, the call records nothing.

      Parameters

      • unitId: number
      • address: number
      • value: boolean
      • Optionalgeneration: number

      Returns void

    • The state this process last wrote to a coil, or undefined when unknown.

      A batching client uses this to fill the gaps of an FC15 span without a read.

      Parameters

      • unitId: number
      • address: number

      Returns boolean | undefined