Domain

class lsst.ts.salobj.Domain

Bases: object

dds domain participant and quality of service information.

Notes

Reads the following Environment Variables; follow the link for details:

  • OSPL_MASTER_PRIORITY, optional is used to set the Master Priority. If present, it must be a value between 0 and 255.

Cleanup

It is important to close a Domain when you are done with it, especially in unit tests, because otherwise unreleased resources may cause problems. To make this easier Domain is a context manager.

Domain contains a registry of SalInfo instances, so that it can close them when the domain is closed. The registry uses weak references to avoid circular dependencies (since SalInfo stores the domain). SalInfo instances automatically register themselves with the provided domain.

To conserve resources you should have only one Domain per process. Thus:

  • Controller creates its own Domain as attribute domain and closes it when the controller is closed. To create a Remote for a controller, use the domain from the controller, e.g.:

    controller = Controller(name="Test", index=47)
    try:
        remote = Remote(domain=controller.domain, name="Test", index=47)
        ...
    finally:
        await controller.close()
    
    # or if you only want the objects for the duration of a function,
    # e.g in a unit test:
    async with Controller(name="Test", index=47) as controller:
        remote = Remote(domain=controller.domain, name="Test", index=47)
        ...
    
  • If you are creating Remotes without a Controller then you must create the Domain yourself and close it when you are finished, e.g.:

    domain = salobj.Domain()
    try:
        remote = salobj.Remote(domain=domain, name="Test", index=47)
        ...
    finally:
        await domain.close()
    
    # or if you only want the objects for the duration of a function,
    # e.g in a unit test:
    async with salobj.Domain() as domain:
        test_remote = salobj.Remote(domain=domain, name="Test", index=5)
    
Attributes:
participantdds.DomainParticipant

DDS domain participant.

originint

Process ID. Used to set the private_origin field of output samples.

default_identitystr

Default value used for the identity field of SalInfo. Initalized to user_host but Controller‘s constructor sets it to SalInfo.user_index so that all Remotes constructed with the controller’s domain will have the controller’s identity. For testing purposes, it is allowed to change this field before constructing a Remote.

user_hoststr

username@host. This will match identity unless the latter is set to a CSC name.

idl_dirpathlib.Path

Root directory of the ts_idl package.

ackcmd_qos_setQosSet

QoS set for the ackcmd topic.

command_qos_setQosSet

QoS set for command topics.

event_qos_setQosSet

QoS set for event topics.

telemetry_qos_setQosSet

QoS set for telemetry topics.

Attributes Summary

salinfo_set

Methods Summary

add_salinfo(salinfo)

Add the specified salinfo to the internal registry.

basic_close()

A synchronous and less thorough version of close.

close()

Close all registered SalInfo and the dds domain participant.

make_publisher(partition_names)

Make a dds publisher.

make_subscriber(partition_names)

Make a dds subscriber.

remove_salinfo(salinfo)

Remove the specified salinfo from the internal registry.

Attributes Documentation

salinfo_set

Methods Documentation

add_salinfo(salinfo: SalInfo) None

Add the specified salinfo to the internal registry.

Parameters:
salinfoSalInfo

SAL component information

Raises:
RuntimeError

If the salinfo is already present

basic_close() None

A synchronous and less thorough version of close.

Intended for exit handlers and constructor error handlers.

async close() None

Close all registered SalInfo and the dds domain participant.

May be called multiple times. The first call closes the Domain; subsequent calls wait until the Domain is closed.

make_publisher(partition_names: Sequence[str]) Publisher

Make a dds publisher.

Parameters:
partition_nameslist [str]

List of DDS partition names.

make_subscriber(partition_names: Sequence[str]) Subscriber

Make a dds subscriber.

Parameters:
partition_nameslist [str]

List of DDS partition names.

remove_salinfo(salinfo: SalInfo) bool

Remove the specified salinfo from the internal registry.

Parameters:
salinfoSalInfo

SAL component information

Returns:
removedboolean

True if removed, False if not found