Settings for a subscription

interface SubscriptionSettings<T> {
    callback: SubscriptionCallback<T>;
    cycleTime?: number;
    maxDelay?: number;
    sendOnChange?: boolean;
    target: string | AdsRawAddress;
}

Type Parameters

  • T = any

Properties

Callback function that is called when new value is received

cycleTime?: number

Cycle time for subscription (default: 200 ms)

If sendOnChange is true (default), PLC checks if value has changed with cycleTime interval. If the value has changed, a new value is sent.

If sendOnChange is false, PLC constantly sends the value with cycleTime interval.

maxDelay?: number

How long the PLC waits before sending the values at maximum? (default: 0 ms --> maximum delay is off)

If value is not changing, the first notification with active value after subscribing is sent after maxDelay.

If the value is changing, the PLC sends one or more notifications every maxDelay.

So if cycleTime is 100 ms, maxDelay is 1000 ms and value changes every 100 ms, the PLC sends 10 notifications every 1000 ms. This can be useful for throttling.

sendOnChange?: boolean

Should the notification be sent only when the value changes? (default: true)

If false, the value is sent with cycleTime interval (even if it doesn't change).

If true (default), the value is checked every cycleTime and sent only if it has changed.

NOTE: When subscribing, the value is always sent once.

target: string | AdsRawAddress

Subscription target (variable name as string or raw ADS address).

Such as such as GVL_Test.ExampleStruct or {indexGroup, indexOffset, size} object