DataModel

Inheritance diagram of DataModel
class DataModel(parent, dataUID, defaultData=None)[source]

An object containing one piece of data which is intended to be shared. The data will be identified by its UID (a unique identifier known to objects that intend to access the data)

In general, you are not supposed to instantiate objects of this class directly. Instead, you should interact via the SharedDataManager, which uses SharedDataManager.__getDataModel() to ensure that the DataModels are singletons.

Import from taurus.qt.qtcore.communication as:

from taurus.qt.qtcore.communication import DataModel
connectReader(slot, readOnConnect=True)[source]

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

Parameters
  • 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

connectWriter(writer, signalname)[source]

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

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

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

dataChanged
dataUID()[source]

returns the data unique identifier

Returns

Return type

str

disconnectReader(slot)[source]

unregister a reader

Parameters

slot (callable) – the slot to which this was connected

See also

SharedDataManager.disconnectReader(), .:meth:getData

disconnectWriter(writer, signalname)[source]

unregister a writer from this data model

Parameters
  • writer (QObject) – object to unregister

  • signalname (str) – the signal that was registered

getData()[source]

Returns the data object.

Returns

the data object

Return type

object

info()[source]
isDataSet()[source]

Whether the data has been set at least once or if it is uninitialized

Returns

True if the data has been set. False it is uninitialized

Return type

bool

readerCount()[source]

returns the number of currently registered readers of this model

Returns

Return type

int

setData(data)[source]

sets the data object and emits a “dataChanged” signal with the data as the parameter

Parameters

data (object) – the new value for the Model’s data

writerCount()[source]

returns the number of currently registered writers of this model

Returns

Return type

int