Device
class Device : public karabo::xms::SignalSlotable
@brief all Karabo devices derive from this class
The Device class is the base class for all Karabo devices. It provides for a standardized set of basic properties that all devices share and provides interaction with its configuration and properties.
Devices are defined by their expected parameters; a list of properties and commands that are known to the distributed system at static time. These parameters describe a devices Schema, which in turn describes the possible configurations of the device.
Variables
| Name | Description |
|---|---|
| m_validatorIntern | Validators to validate... |
| m_validatorExtern | ...internal updates via 'Device::set' |
| m_deviceClient | ...external updates via 'Device::slotReconfigure' |
Functions
| Name | Description |
|---|---|
| expectedParameters | The expected parameter section of the Device class, known at static time. |
| Device | Construct a device with a given configuration. |
| ~Device | The destructor will reset the DeviceClient attached to this device. |
| registerInitialFunction | Register a function to be called after construction Can be called by each class of an inheritance chain. |
| finalizeInternalInitialization | This method is called to finalize initialization of a device. |
| remote | This function allows to communicate to other (remote) devices. |
| set | Updates the state/properties of the device. |
| setVectorUpdate | Concurrency safe update of vector property Does not work for Hash (i.e. table element) due to Hash equality just checking similarity. Removing might be unreliable for VECTOR_FLOAT or VECTOR_DOUBLE due to floating point equality issues. key : of the vector property to update updates: : items to remove from property vector (starting at the front) or to add (at the end) updateType: : indicates update type - applied individually to all items in 'updates' timestamp: : timestamp to assign to updated vector property (e.g. getTimestamp()) |
| set | Updates the state of the device. |
| writeChannel | Writes a hash to the specified channel. |
| writeChannel | Writes a hash to the specified channel. |
| signalEndOfStream | Signals an end-of-stream event (EOS) on the output channel identified by channelName channelName: : the name of the output channel. Thread safety: The 'writeChannel(..)' methods and 'signalEndOfStream(..)' must not be called concurrently for the same 'channelName'. |
| set | Updates the state/properties of the device with all key/value pairs given in the hash. |
| set | Updates the state of the device with all key/value pairs given in the hash Any updates are validated against the device schema and rejected if they are not appropriate for the current device state or are of wrong type. |
| setNoLock | Internal method for set(Hash, Timestamp), requiring m_objectStateChangeMutex to be locked |
| setNoValidate | Updates the state of the device with all key/value pairs given in the hash. |
| setNoValidate | Updates the state of the device with all key/value pairs given in the hash. |
| setNoValidate | Updates the state of the device with all key/value pairs given in the hash. |
| setNoValidate | Updates the state of the device with all key/value pairs given in the hash. |
| setNoValidateNoLock | Internal version of setNoValidate(hash, timestamp) that requires m_objectStateChangeMutex to be locked |
| get | Retrieves the current value of any device parameter (that was defined in the expectedParameters function) key : A valid parameter of the device (must be defined in the expectedParameters function) Return : value of the requested parameter |
| getAs | Retrieves the current value of any device parameter (that was defined in the expectedParameters function) The value is casted on the fly into the desired type. |
| getFullSchema | Retrieves all expected parameters of this device Return : Schema object containing all expected parameters |
| appendSchema | Append a schema to the existing device schema schema : to be appended - may also contain existing elements to overwrite their attributes like min/max values/sizes, alarm ranges, etc. If it contains Input-/OutputChannels, they are (re-)created. If previously an InputChannel existed under the same key, its data/input/endOfStream handlers are kept for the recreated InputChannel. unused : parameter, kept for backward compatibility. |
| updateSchema | Replace existing schema descriptions by static (hard coded in expectedParameters) part and add additional (dynamic) descriptions. |
| getAliasFromKey | Converts a device parameter key into its aliased key (must be defined in the expectedParameters function) key : A valid parameter of the device (must be defined in the expectedParameters function) Return : Aliased representation of the parameter |
| getKeyFromAlias | Converts a device parameter alias into the original key (must be defined in the expectedParameters function) key : A valid parameter-alias of the device (must be defined in the expectedParameters function) Return : The original name of the parameter |
| aliasHasKey | Checks if the argument is a valid alias of some key, i.e. defined in the expectedParameters function alias : Arbitrary argument of arbitrary type Return : true if it is an alias found in one of three containers of parameters: "reconfigurable", "initial" or "monitored", otherwise false |
| keyHasAlias | Checks if some alias is defined for the given key key : in expectedParameters mapping Return : true if the alias exists |
| getValueType | Checks the type of any device parameter (that was defined in the expectedParameters function) key : A valid parameter of the device (must be defined in the expectedParameters function) Return : The enumerated internal reference type of the value |
| getCurrentConfiguration | Retrieves the current configuration. |
| getCurrentConfigurationSlice | Retrieves a slice of the current configuration. |
| filterByTags | Return a tag filtered version of the input Hash. |
| getServerId | Return the serverId of the server this device is running on Return : |
| getState | Return a State object holding the current unified state of the device. |
| updateState | Update the state of the device, using "actual timestamp". |
| updateState | Update the state of the device, using "actual timestamp". |
| updateState | Update the state of the device, using given timestamp. |
| updateState | Update the state of the device, using given timestamp. |
| execute | Execute a command on this device command : |
| execute | Execute a command with one argument on this device command : a1 : |
| execute | Execute a command with two arguments on this device command : a1 : a2 : |
| execute | Execute a command with three arguments on this device command : a1 : a2 : a3 : |
| execute | Execute a command with four arguments on this device command : a1 : a2 : a3 : a4 : |
| getAlarmCondition | Get the current alarm condition the device is in Return : |
| setAlarmCondition | Set the global alarm condition condition : to set needsAcknowledging : if this condition will require acknowledgment on the alarm service description : an optional description of the condition. Consider including remarks on how to resolve |
| getAlarmCondition | Get the alarm condition for a specific property key : of the property to get the condition for sep : optional separator to use in the key path Return : the alarm condition of the property |
| slotTimeTick | A slot called by the device server if the external time ticks update to synchronize this device with the timing system. |
| onTimeTick | A hook which is called if the device receives external time-server update, i.e. if slotTimeTick on the device server is called. Can be overwritten by derived classes. id: : train id sec: : unix seconds frac: : fractional seconds (i.e. attoseconds) period: : interval between ids in microseconds |
| onTimeUpdate | If the device receives time-server updates via slotTimeTick, this hook will be called for every id in sequential order. |
| appendSchemaMaxSize | Append Schema to change/set maximum size information for path - if paths does not exist, throw exception This is similar to the more general appendSchema, but dedicated to a common use case. |
| getActualTimestamp | Returns the actual timestamp. |
| getTimestamp | Returns the Timestamp for given Epochstamp. |
| initChannels | Called to setup pipeline channels, will recursively go through the given schema, assuming it to be at least a part of the schema of the device. |
| prepareOutputChannel | Create OutputChannel for given path and take care to set handlers needed Needs to be called with m_objectStateChangeMutex being locked. |
| prepareInputChannel | Create InputChannel for given path and take care to set handlers needed Needs to be called with m_objectStateChangeMutex being locked. |
| slotCallGuard | This function is called by SignalSlotable to verify if a slot may be called from remote. |
| slotClearLock | Clear any lock on this device |
| getTimeInfo | Internal method to retrieve time information of this device. |
| slotGetTime | Returns the actual time information of this device. |
| slotGetSystemInfo | Returns the actual system information of this device. |
Variable Details
m_deviceClient
std::shared_ptr<DeviceClient> m_deviceClient
...external updates via 'Device::slotReconfigure'
m_validatorExtern
karabo::data::Validator m_validatorExtern
...internal updates via 'Device::set'
m_validatorIntern
karabo::data::Validator m_validatorIntern
Validators to validate...
Function Details
Device
Device(const karabo::data::Hash& configuration)
Construct a device with a given configuration. The configuration Hash may contain any of the following entries:
serverId: a string representing the server this device is running on. If not given the device assumes to run in stand-alone mode.
deviceId: a string representing this device's id, part of the unique identifier in the distributed system. If not given it defaults to none.
configuration
:
aliasHasKey
template <class T> const bool aliasHasKey(const T& alias) const
Checks if the argument is a valid alias of some key, i.e. defined in the expectedParameters function
alias
: Arbitrary argument of arbitrary type
Return : true if it is an alias found in one of three containers of parameters: "reconfigurable", "initial" or "monitored", otherwise false
appendSchema
void appendSchema(const karabo::data::Schema& schema, const bool /*unused*/ = false)
Append a schema to the existing device schema
schema
: to be appended - may also contain existing elements to overwrite their
attributes like min/max values/sizes, alarm ranges, etc.
If it contains Input-/OutputChannels, they are (re-)created.
If previously an InputChannel existed under the same key, its data/input/endOfStream
handlers are kept for the recreated InputChannel.
unused
: parameter, kept for backward compatibility.
appendSchemaMaxSize
void appendSchemaMaxSize(const std::string& path, unsigned int value, bool emitFlag = true)
Append Schema to change/set maximum size information for path - if paths does not exist, throw exception
This is similar to the more general appendSchema, but dedicated to a common use case.
Caveat: This does not recreate an output channel if its schema is changed
path
: indicates the parameter which should be a Vector- or TableElement
value
: is the new maximum size of the parameter
emitFlag
: indicates if others should be informed about this Schema update.
If this method is called for a bunch of paths, it is recommended to
set this to true only for the last call.
execute
void execute(const std::string& command) const
Execute a command on this device
command
:
template <class A1> void execute(const std::string& command, const A1& a1) const
Execute a command with one argument on this device
command
:
a1
:
template <class A1, class A2> void execute(const std::string& command, const A1& a1, const A2& a2) const
Execute a command with two arguments on this device
command
:
a1
:
a2
:
template <class A1, class A2, class A3> void execute(const std::string& command, const A1& a1, const A2& a2, const A3& a3) const
Execute a command with three arguments on this device
command
:
a1
:
a2
:
a3
:
template <class A1, class A2, class A3, class A4> void execute(const std::string& command, const A1& a1, const A2& a2, const A3& a3, const A4& a4) const
Execute a command with four arguments on this device
command
:
a1
:
a2
:
a3
:
a4
:
expectedParameters
static void expectedParameters(karabo::data::Schema& expected)
The expected parameter section of the Device class, known at static time. The basic parameters described here are available for all devices, many of them being expert or admin visible only.
expected:
: a Schema to which these parameters will be
appended.
filterByTags
karabo::data::Hash filterByTags(const karabo::data::Hash& hash, const std::string& tags) const
Return a tag filtered version of the input Hash. Tags are as defined in the device schema
hash
: to filter
tags
: to filter by
Return : a filtered version of the input Hash.
finalizeInternalInitialization
void finalizeInternalInitialization(const karabo::net::Broker::Pointer& connection, bool consumeBroadcasts, const std::string& timeServerId)
This method is called to finalize initialization of a device. It is needed to allow user code to hook in after the base device constructor, but before the device is fully initialized.
connection
: The broker connection for the device.
consumeBroadcasts
: If false, do not listen directly to broadcast messages (addressed to '*').
Whoever sets this to false has to ensure that broadcast messages reach the
Device in some other way, otherwise the device will not work correctly.
timeServerId
: The id of the time server to be used by the device - usually set by the DeviceServer.
get
template <class T> T get(const std::string& key) const
Retrieves the current value of any device parameter (that was defined in the expectedParameters function)
key
: A valid parameter of the device (must be defined in the expectedParameters function)
Return : value of the requested parameter
getActualTimestamp
inline karabo::data::Timestamp getActualTimestamp() const
Returns the actual timestamp. The Trainstamp part of Timestamp is extrapolated from the last values received via slotTimeTick (or zero if no time ticks received yet). To receive time ticks, the server of the device has to be connected to a time server.
Return : the actual timestamp
getAlarmCondition
karabo::data::AlarmCondition getAlarmCondition() const
Get the current alarm condition the device is in
Return :
const karabo::data::AlarmCondition& getAlarmCondition(const std::string& key, const std::string& sep = ".") const
Get the alarm condition for a specific property
key
: of the property to get the condition for
sep
: optional separator to use in the key path
Return : the alarm condition of the property
getAliasFromKey
template <class AliasType> AliasType getAliasFromKey(const std::string& key) const
Converts a device parameter key into its aliased key (must be defined in the expectedParameters function)
key
: A valid parameter of the device (must be defined in the expectedParameters function)
Return : Aliased representation of the parameter
getAs
template <class T> T getAs(const std::string& key) const
Retrieves the current value of any device parameter (that was defined in the expectedParameters function) The value is casted on the fly into the desired type. NOTE: This function is considerably slower than the simple get() functionality
key
: A valid parameter of the device (must be defined in the expectedParameters function)
Return : value of the requested parameter
getCurrentConfiguration
karabo::data::Hash getCurrentConfiguration(const std::string& tags = "") const
Retrieves the current configuration. If no argument is given, all parameters (those described in the expected parameters section) are returned. A subset of parameters can be retrieved by specifying one or more tags.
tags
: The tags (separated by comma) the parameter must carry to be retrieved
Return : A Hash containing the current value of the selected configuration
getCurrentConfigurationSlice
karabo::data::Hash getCurrentConfigurationSlice(const std::vector<std::string>& paths) const
Retrieves a slice of the current configuration.
paths
: of the configuration which should be returned (as declared in expectedParameters)
(method throws ParameterExcepton if a non-existing path is given)
Return : Hash with the current values and attributes (e.g. timestamp) of the selected configuration
getFullSchema
karabo::data::Schema getFullSchema() const
Retrieves all expected parameters of this device
Return : Schema object containing all expected parameters
getKeyFromAlias
template <class AliasType> std::string getKeyFromAlias(const AliasType& alias) const
Converts a device parameter alias into the original key (must be defined in the expectedParameters function)
key
: A valid parameter-alias of the device (must be defined in the expectedParameters function)
Return : The original name of the parameter
getServerId
const std::string& getServerId() const
Return the serverId of the server this device is running on
Return :
getState
const karabo::data::State getState()
Return a State object holding the current unified state of the device.
Return :
getTimeInfo
karabo::data::Hash getTimeInfo()
Internal method to retrieve time information of this device.
getTimestamp
karabo::data::Timestamp getTimestamp(const karabo::data::Epochstamp& epoch) const
Returns the Timestamp for given Epochstamp. The Trainstamp part of Timestamp is extrapolated forward or backward from the last values received via slotTimeTick (or zero if no time ticks received yet). To receive time ticks, the server of the device has to be connected to a time server.
epoch
: for that the time stamp is searched for
Return : the matching timestamp, consisting of epoch and the corresponding Trainstamp
getValueType
karabo::data::Types::ReferenceType getValueType(const std::string& key) const
Checks the type of any device parameter (that was defined in the expectedParameters function)
key
: A valid parameter of the device (must be defined in the expectedParameters function)
Return : The enumerated internal reference type of the value
initChannels
void initChannels(const karabo::data::Schema& schema, const std::string& topLevel = "")
Called to setup pipeline channels, will
recursively go through the given schema, assuming it to be at least
a part of the schema of the device.
Needs to be called with m_objectStateChangeMutex being locked.
*
*
schema:
: the schema to traverse
*
topLevel:
: std::string: empty or existing path of full
* schema of the device
keyHasAlias
bool keyHasAlias(const std::string& key) const
Checks if some alias is defined for the given key
key
: in expectedParameters mapping
Return : true if the alias exists
onTimeTick
virtual void onTimeTick(unsigned long long id, unsigned long long sec, unsigned long long frac, unsigned long long period)
A hook which is called if the device receives external time-server update, i.e. if slotTimeTick on the device server is called. Can be overwritten by derived classes.
id:
: train id
sec:
: unix seconds
frac:
: fractional seconds (i.e. attoseconds)
period:
: interval between ids in microseconds
onTimeUpdate
virtual void onTimeUpdate(unsigned long long id, unsigned long long sec, unsigned long long frac, unsigned long long period)
If the device receives time-server updates via slotTimeTick, this hook will be called for every id in sequential order. The time stamps (sec + frac) of subsequent ids might be identical - though they are usually spaced by period. Can be overwritten in derived classes.
id:
: train id
sec:
: unix seconds
frac:
: fractional seconds (i.e. attoseconds)
period:
: interval between ids in microseconds
prepareInputChannel
void prepareInputChannel(const std::string& path)
Create InputChannel for given path and take care to set handlers needed Needs to be called with m_objectStateChangeMutex being locked.
path
:
prepareOutputChannel
void prepareOutputChannel(const std::string& path)
Create OutputChannel for given path and take care to set handlers needed Needs to be called with m_objectStateChangeMutex being locked.
path
:
registerInitialFunction
void registerInitialFunction(const std::function<void()>& func)
Register a function to be called after construction
Can be called by each class of an inheritance chain. Functions will be called in order of registration.
remote
DeviceClient& remote()
This function allows to communicate to other (remote) devices. Any device contains also a controller for other devices (DeviceClient) which is returned by this function.
Return : DeviceClient instance
set
template <class ValueType> void set(const std::string& key, const ValueType& value)
Updates the state/properties of the device. This function automatically notifies any observers in the distributed system.
key
: A valid parameter of the device (must be defined in the expectedParameters function)
value
: The corresponding value (of corresponding data-type)
template <class ValueType> void set(const std::string& key, const ValueType& value, const karabo::data::Timestamp& timestamp)
Updates the state of the device. This function automatically notifies any observers in the distributed system.
Any updates are validated against the device schema and rejected if they are not appropriate for the current device state or are of wrong type. During validation alarm bounds are evaluated and alarms on properties will be raised if alarm conditions are met. Additionally, the distributed system is notified of these alarms.
key
: A valid parameter of the device (must be defined in the expectedParameters function)
value
: The corresponding value (of corresponding data-type)
timestamp
: The time of the value change
void set(const karabo::data::Hash& hash)
Updates the state/properties of the device with all key/value pairs given in the hash.
Any updates are validated against the device schema and rejected if they are not
appropriate for the current device state or are of wrong type. During validation
alarm bounds are evaluated and alarms on properties will be raised if alarm
conditions are met. Additionally, the distributed system is notified of these
alarms.
For those paths in 'hash' which do not already have time stamp attributes assigned as tested by
Timestamp::hashAttributesContainTimeInformation(hash.getAttributes(
NOTE: This function will automatically and efficiently (only one message) inform any observers.
hash
: Hash of updated internal parameters
(must be in current full schema, e.g. since declared in the expectedParameters function)
void set(const karabo::data::Hash& hash, const karabo::data::Timestamp& timestamp)
Updates the state of the device with all key/value pairs given in the hash
Any updates are validated against the device schema and rejected if they are not appropriate for the current device state or are of wrong type. During validation alarm bounds are evaluated and alarms on properties will be raised if alarm conditions are met. Additionally, the distributed system is notified of these alarms.
NOTE: This function will automatically and efficiently (only one message) inform any observers.
hash
: Hash of updated internal parameters
(must be in current full schema, e.g. since declared in the expectedParameters function)
timestamp
: to indicate when the set occurred - but is ignored for paths in 'hash'
that already have time stamp attributes as tested by
Timestamp::hashAttributesContainTimeInformation(hash.getAttributes(
setAlarmCondition
void setAlarmCondition(const karabo::data::AlarmCondition& condition, bool needsAcknowledging = false, const std::string& description = std::string())
Set the global alarm condition
condition
: to set
needsAcknowledging
: if this condition will require acknowledgment on the alarm service
description
: an optional description of the condition. Consider including remarks on how to resolve
setNoLock
void setNoLock(const karabo::data::Hash& hash, const karabo::data::Timestamp& timestamp)
Internal method for set(Hash, Timestamp), requiring m_objectStateChangeMutex to be locked
setNoValidate
template <class ValueType> void setNoValidate(const std::string& key, const ValueType& value)
Updates the state of the device with all key/value pairs given in the hash. In contrast to the set function, no validation is performed.
key
: identifying the property to update
value:
: updated value
template <class ValueType> void setNoValidate(const std::string& key, const ValueType& value, const karabo::data::Timestamp& timestamp)
Updates the state of the device with all key/value pairs given in the hash. In contrast to the set function, no validation is performed.
key
: identifying the property to update
value:
: updated value
timestamp
: optional timestamp to indicate when the set occurred.
void setNoValidate(const karabo::data::Hash& hash)
Updates the state of the device with all key/value pairs given in the hash. In contrast to the set function, no validation is performed.
NOTE: This function will automatically and efficiently (only one message) inform any observers.
config
: Hash of updated internal parameters (must be declared in the expectedParameters function)
void setNoValidate(const karabo::data::Hash& hash, const karabo::data::Timestamp& timestamp)
Updates the state of the device with all key/value pairs given in the hash. In contrast to the set function, no validation is performed.
NOTE: This function will automatically and efficiently (only one message) inform any observers.
config
: Hash of updated internal parameters (must be declared in the expectedParameters function)
timestamp
: optional timestamp to indicate when the set occurred.
setNoValidateNoLock
void setNoValidateNoLock(const karabo::data::Hash& hash, const karabo::data::Timestamp& timestamp)
Internal version of setNoValidate(hash, timestamp) that requires m_objectStateChangeMutex to be locked
setVectorUpdate
template <class ItemType> void setVectorUpdate(const std::string& key, const std::vector<ItemType>& updates, VectorUpdate updateType, const karabo::data::Timestamp& timestamp)
Concurrency safe update of vector property
Does not work for Hash (i.e. table element) due to Hash equality just checking similarity. Removing might be unreliable for VECTOR_FLOAT or VECTOR_DOUBLE due to floating point equality issues.
key
: of the vector property to update
updates:
: items to remove from property vector (starting at the front) or to add (at the end)
updateType:
: indicates update type - applied individually to all items in 'updates'
timestamp:
: timestamp to assign to updated vector property (e.g. getTimestamp())
signalEndOfStream
void signalEndOfStream(const std::string& channelName)
Signals an end-of-stream event (EOS) on the output channel identified by channelName
channelName:
: the name of the output channel.
Thread safety: The 'writeChannel(..)' methods and 'signalEndOfStream(..)' must not be called concurrently for the same 'channelName'.
slotCallGuard
void slotCallGuard(const std::string& slotName, const std::string& callee)
This function is called by SignalSlotable to verify if a slot may be called from remote. The function only checks slots that are mentioned in the expectedParameter section ("DeviceSlots")
slotName:
: name of the slot
callee:
: the calling remote, can be unknown
The following checks are performed:
1) Is this device locked by another device? If the lockedBy field is non-empty and does not match the callee's instance id, the call will be rejected
2) Is the slot callable from the current state, i.e. is the current state specified as an allowed state for the slot.
slotClearLock
void slotClearLock()
Clear any lock on this device
slotGetSystemInfo
void slotGetSystemInfo(const karabo::data::Hash& /* unused */)
Returns the actual system information of this device.
info
: an unused (at least for now) Hash parameter that
has been added to fit the generic slot call
(Hash in, Hash out) of the GUI server/client protocol.
This slot reply is a Hash with the following keys:
- user the actual user running this device
- broker the current connected broker node
and all keys provided by slotGetTime.
slotGetTime
void slotGetTime(const karabo::data::Hash& /* unused */)
Returns the actual time information of this device.
info
: an unused (at least for now) Hash parameter that
has been added to fit the generic slot call
(Hash in, Hash out) of the GUI server/client protocol.
This slot reply is a Hash with the following keys:
- time and its attributes provide an actual timestamp
with train Id information.
- timeServerId the id of the time server configured for
the DeviceServer of this device; "None" when there's no time
server configured.
- reference and its attributes provide the latest
timestamp information received from the timeserver.
slotTimeTick
void slotTimeTick(unsigned long long id, unsigned long long sec, unsigned long long frac, unsigned long long period)
A slot called by the device server if the external time ticks update to synchronize this device with the timing system.
id:
: current train id
sec:
: current system seconds
frac:
: current fractional seconds
period:
: interval between subsequent ids in microseconds
updateSchema
void updateSchema(const karabo::data::Schema& schema, const bool /*unused*/ = false)
Replace existing schema descriptions by static (hard coded in expectedParameters) part and add additional (dynamic) descriptions. Previous additions will be removed.
schema
: additional, dynamic schema - may also contain existing elements to overwrite their
attributes like min/max values/sizes, alarm ranges, etc.
If it contains Input-/OutputChannels, they are (re-)created (and previously added ones
removed). If previously an InputChannel existed under the same key, its data/input/endOfStream handlers
are kept for the recreated InputChannel.
unused
: parameter, kept for backward compatibility.
updateState
void updateState(const karabo::data::State& currentState)
Update the state of the device, using "actual timestamp".
Will also update the instanceInfo describing this device instance (if new or old State are ERROR).
currentState:
: the state to update to
void updateState(const karabo::data::State& currentState, const karabo::data::Hash& other)
Update the state of the device, using "actual timestamp".
Will also update the instanceInfo describing this device instance (if new or old State are ERROR).
currentState:
: the state to update to
other:
: a Hash to set other properties in the same state update message,
time stamp attributes to its paths have precedence over the actual timestamp
void updateState(const karabo::data::State& currentState, const karabo::data::Timestamp& timestamp)
Update the state of the device, using given timestamp.
Will also update the instanceInfo describing this device instance (if new or old State are ERROR).
currentState:
: the state to update to
timestamp:
: time stamp to assign to the state property and the properties in 'other'
(if the latter do not have specified timestamp attributes)
void updateState(const karabo::data::State& currentState, karabo::data::Hash other, const karabo::data::Timestamp& timestamp)
Update the state of the device, using given timestamp.
Will also update the instanceInfo describing this device instance (if new or old State are ERROR).
currentState:
: the state to update to
other:
: a Hash to set other properties in the same state update message,
time stamp attributes to its paths have precedence over the given 'timestamp'
timestamp:
: time stamp to assign to the state property and the properties in 'other'
(if the latter do not have specified timestamp attributes)
writeChannel
void writeChannel(const std::string& channelName, const karabo::data::Hash& data)
Writes a hash to the specified channel. The hash internally must follow exactly the data schema as defined in the expected parameters.
If 'data' contains an 'NDArray', consider to use the overload of this method that has the 'safeNDArray' flag. If that flag can be set to 'true', data copies can be avoided:
writeChannel(channelName, data, getActualTimestamp(), true);
channelName
: The output channel name
data
: Hash with the data
Thread safety: The 'writeChannel(..)' methods and 'signalEndOfStream(..)' must not be called concurrently for the same 'channelName'.
void writeChannel(const std::string& channelName, const karabo::data::Hash& data, const karabo::data::Timestamp& timestamp, bool safeNDArray = false)
Writes a hash to the specified channel. The hash internally must follow exactly the data schema as defined in the expected parameters.
channelName
: The output channel name
data
: Hash with the data
timestamp
: A user provided timestamp (if e.g. retrieved from h/w)
safeNDArray
: Boolean that should be set to 'true' if 'data' contains any 'NDArray' and their data
is not changed after this 'writeChannel'. Otherwise, data will be copied if needed,
i.e. when the output channel has to queue or serves inner-process receivers.
Thread safety: The 'writeChannel(..)' methods and 'signalEndOfStream(..)' must not be called concurrently for the same 'channelName'.
~Device
virtual ~Device()
The destructor will reset the DeviceClient attached to this device.