SharedDataManager

Inheritance diagram of SharedDataManager
class SharedDataManager(parent)[source]

A Factory of DataModel objects. The __getDataModel() method ensures that the created DataModels are singletons. DataModels are not kept alive unless there at least some Reader or Writer registered to it (or another object referencing them)

Import from taurus.qt.qtcore.communication as:

from taurus.qt.qtcore.communication import SharedDataManager
activeDataUIDs()[source]

Returns a list of currently shared data. Note that this list only reflects the situation at the moment of calling this method: a given DataModel may die at any moment if there are no references to it.

Returns:

UIDs of currently shared data.

Return type:

list<str>

connectReader(dataUID, slot, readOnConnect=True)[source]

Registers the given slot method to receive notifications whenever the data identified by dataUID is changed.

Note that it returns the DataModel.getData() method for the given data UID, which can be used for reading the data at any moment.

Parameters:
  • dataUID (str) – the unique identifier of the data

  • slot (callable) – a method that will be called when the data changes this slot will be the receiver of a signal which has the data as its first argument.

  • readOnConnect (bool) – if True (default) the slot will be called immediately with the current value of the data if the data has been already initialized

Returns:

a callable that can be used for reading the data

Return type:

callable

See also

connectWriter(), __getDataModel()

connectWriter(dataUID, writer, signalname)[source]

Registers the given writer object as a changer of the shared data identified by dataUID. The writer is then expected to emit a QtCore.SIGNAL(signalname) with the new data as the first parameter

Note that it returns the DataModel.setData() method for the given data UID, which can be used for changing the data at any moment.

Parameters:
  • dataUID (str) – the unique identifier of the data

  • writer (QObject) – object that will change the data

  • signalname (str) – the signal name that will notify changes of the data

Returns:

a callable that can be used for setting the data. When using it, one parameter has to be passed containing the new data

Return type:

callable

See also

connectWriter(), __getDataModel()

debugReader(data)[source]

A slot which you can connect as a reader for debugging. It will print info to the stdout

disconnectReader(dataUID, slot)[source]

Unregister the given method as data receiver

Parameters:
  • dataUID (str) – the unique identifier of the data

  • slot (str) – the slot that was registered

disconnectWriter(dataUID, writer, signalname)[source]

Unregister the given object as writer of the shared data

Parameters:
  • dataUID (str) – the unique identifier of the data

  • writer (QObject) – object to unregister

  • signalname (str) – the signal that was registered

getDataModelProxy(dataUID, callback=None)[source]

Returns a weakref.proxy to a DataModel object for the given data UID or None if the UID is not registered.

Note

The underlying DataModel object may cease to exist if all its readers and writers are unregistered.

Parameters:
  • dataUID (str) – the unique identifier of the data

  • callback (callable) – same as in weakref.ref callback parameter

Returns:

Return type:

weakref.proxy or None

info()[source]