PdCom5 Subscription

Selectors

class pdcom5.Selector

Default Selector

class pdcom5.ScalarSelector

Select a Scalar from a multidimensional variable.

Parameters

indices – Vector of indices, row major

Subscriptions

class pdcom5.Subscription(subscriber: pdcom5.Subscription.SubscriberBase, variable: Union[str, pdcom5._PdComWrapper.Variable], fut: _asyncio.Future, selector: Optional[pdcom5._PdComWrapper.Selector])
class State

Members:

Pending

Active

Invalid

property name
cancel()

Cancel a subscription.

async poll()

Poll an existing subscription.

This can for example be used to refresh an event-based subscription.

async read()

Wait for an update and return the new value.

Returns

tuple of (value, timestamp)

property state

The current state of the subscription.

property value

The current value.

property variable

The corresponding variable.

class pdcom5.SubscriptionWithSubscriber(subscriber: pdcom5.Subscription.SubscriberBase, variable: Union[str, pdcom5._PdComWrapper.Variable], fut: _asyncio.Future, selector: Optional[pdcom5._PdComWrapper.Selector])
newValues() → AsyncGenerator[datetime.timedelta, Any]

Iterate over all incoming values.

This functions an asynchronous generator for the timestamp of incoming data. In the body of the loop, the value attribute belongs to the current timestamp.

import pdcom5
process = pdcom5.Process()
await process.connect("msr://localhost")
subscription = await process.subscribe(0.1, "/osc/cos")
async for timestamp in subscription.newValues():
    print(f"At {timestamp}, cos was {subscription.value}"

For more details, see SubscriberBase.newValues().