ACDPBaseChannel Class
(ServerIO::ACDPBaseChannel)ACDPBaseChannel is a template base class, exposing channel-methods for converting values from to CDP data source. More...
Header: | #include <IO/ServerIO/ACDPBaseChannel.h> |
Inherits: | ICDPChannel |
Inherited By: | ServerIO::CDPPropertyChannel, ServerIO::CDPSignalChannel, and ServerIO::ComponentStateChannel |
Public Functions
ACDPBaseChannel() | |
~ACDPBaseChannel() override |
Reimplemented Public Functions
virtual bool | GetData(void *data, unsigned int size = 0, double *timestamp = nullptr) override |
virtual unsigned int | GetDataSize() const override |
virtual bool | PutData(const void *data, unsigned int size = 0, double timestamp = 0.0) override |
virtual void | RegisterValidator(IChangeValidator *validator) override |
virtual void | SetChannelMask(unsigned char mask) override |
virtual void | SetDataPointer(void *data, double *timestamp = nullptr, std::optional<unsigned int> size = {}) override |
virtual void | SetDataResizeHandler(const std::function<void( unsigned int ) > &resizeHandler = {}) override |
virtual void | SetDataSize(unsigned int size) override |
virtual void | SetNetworkConvert(bool networkConvert) override |
virtual void | UnregisterValidator(IChangeValidator *validator) override |
- 12 public functions inherited from ServerIO::ICDPChannel
- 8 public functions inherited from ServerIO::IChannel
- 26 public functions inherited from CDP::StudioAPI::CDPNode
- 22 public functions inherited from CDP::StudioAPI::ICDPNode
Protected Functions
virtual T | GetExternal() const = 0 |
virtual T | GetInternal(double &timeStamp) const = 0 |
virtual void | IssueBadDataSizeError(const char *methodName, unsigned int size) = 0 |
virtual void | NotifyExternalValueChange(CDPPropertyBase *base) |
void | ProcessChangeValidators(T &newValue, const T &oldValue) |
void | ResizeInternalStorage(unsigned int size) |
virtual void | SetExternal(T newValue) = 0 |
virtual void | SetInternal(T newValue, double timeStamp) = 0 |
Reimplemented Protected Functions
virtual const std::string | GetNodeName() const override |
virtual CDP::StudioAPI::CDPNodeType | GetNodeType() const override |
virtual std::string | GetNodeTypeName() const override |
virtual CDP::StudioAPI::CDPValueType | GetNodeValueType() const override |
virtual CDP::StudioAPI::CDPVariantValue | GetVariantValue() const override |
virtual void | SetVariantValue(const CDP::StudioAPI::CDPVariantValue &value) override |
virtual void | SyncIn() override |
virtual void | SyncOut() override |
- 2 protected functions inherited from ServerIO::IChannel
- 1 protected function inherited from CDP::StudioAPI::CDPNode
Protected Variables
std::unique_ptr<std::string> | m_internalStorage |
CDPProperty<bool> | m_networkConvert |
ChangeValidatorSupport<T> | m_validators |
Detailed Description
ACDPBaseChannel is a template base class, exposing channel-methods for converting values from to CDP data source.
ACDPBaseChannel is intended as a base class for all IOServer channel implementations, implementing the common code of channel handling in IOServer. All ACDPBaseChannel based classes in a same worker thread are usually contained in ChannelManager instance.
See also IOServer, ServerIO, ServerIO::ICDPChannel, ServerIO::IChannel, and ServerIO::ChannelManager.
Member Function Documentation
ACDPBaseChannel::ACDPBaseChannel()
Default constructor. Allocates channel internal value storage and resets all member variables to safe initial values. String channels default to dynamically re-sizable internal value storage.
ACDPBaseChannel::~ACDPBaseChannel()
[override virtual]
bool ACDPBaseChannel::GetData(void *data, unsigned int size = 0, double *timestamp = nullptr)
Reimplemented from IChannel::GetData().
Copies channel internal value storage to the memory buffer pointed by data. If timestamp is not a nullptr, timestamp will be updated with value from either *m_timestampPointer or m_timestamp.
data and timestamp are only updated if size is 0 or matches sizeof T. When size is 0, then the whole available internal value storage is copied (i.e. the amount of bytes that is returned by GetDataSize())
Returns true
if data is updated, false otherwise.
[override virtual]
unsigned int ACDPBaseChannel::GetDataSize() const
Reimplemented from IChannel::GetDataSize().
Returns the channel size in bytes. For dynamically re-sizable string channels returns the current channel size.
[pure virtual protected]
T ACDPBaseChannel::GetExternal() const
[pure virtual protected]
T ACDPBaseChannel::GetInternal(double &timeStamp) const
[override virtual protected]
const std::string ACDPBaseChannel::GetNodeName() const
Reimplemented from ICDPNode::GetNodeName().
Returns short name of channel.
[override virtual protected]
CDP::StudioAPI::CDPNodeType ACDPBaseChannel::GetNodeType() const
Reimplemented from ICDPNode::GetNodeType().
Returns eCDP_NODE, see CDP::StudioAPI::CDPNodeType.
[override virtual protected]
std::string ACDPBaseChannel::GetNodeTypeName() const
Reimplemented from ICDPNode::GetNodeTypeName().
Returns "CDPBaseChannel".
[override virtual protected]
CDP::StudioAPI::CDPValueType ACDPBaseChannel::GetNodeValueType() const
Reimplemented from ICDPNode::GetNodeValueType().
Returns the CDP::StudioAPI::CDPValueType
[override virtual protected]
CDP::StudioAPI::CDPVariantValue ACDPBaseChannel::GetVariantValue() const
Reimplemented from ICDPNode::GetVariantValue().
Returns the value of this channel as a CDPVariantValue.
[pure virtual protected]
void ACDPBaseChannel::IssueBadDataSizeError(const char *methodName, unsigned int size)
[virtual protected]
void ACDPBaseChannel::NotifyExternalValueChange(CDPPropertyBase *base)
Calls CDPNode::NotifyValueChange() with old/previous value and new value, before m_externalValue is updated with new value.
If this function is set up as a Property Change Handler function via SetPropertyChangeHandler(), it will be called when value is changing.
Examples:
From CDPPropertyChannel<T>::Configure():
m_property.SetPropertyChangeHandler([this](CDPPropertyBase* base){ this->NotifyExternalValueChange(base); });
and from CDPSignalChannel<T>::Configure():
m_signal.GetPropertyObject("Value")->SetPropertyChangeHandler([this](CDPPropertyBase* base){ this->NotifyExternalValueChange(base); });
[protected]
void ACDPBaseChannel::ProcessChangeValidators(T &newValue, const T &oldValue)
Calls m_validators's ProcessChangeValidators() to find out if new value is accepted or not.
Is called during SyncOut()/SyncIn() when channel has registered validators.
See also ICDPChannel::RegisterValidator() and ICDPChannel::UnregisterValidator().
[override virtual]
bool ACDPBaseChannel::PutData(const void *data, unsigned int size = 0, double timestamp = 0.0)
Reimplemented from IChannel::PutData().
Copies memory pointed by data into the channel internal value storage. timestamp value will be written into either *m_timestampPointer or m_timestamp.
data and timestamp are only written if size is 0 or matches sizeof T. When the channel internal value storage was set to dynamically re-sizable (i.e. SetDataPointer() was called with size==0), then it will also resize the internal value storage to the size.
Returns true
if data is written, false otherwise.
[override virtual]
void ACDPBaseChannel::RegisterValidator(IChangeValidator *validator)
[protected]
void ACDPBaseChannel::ResizeInternalStorage(unsigned int size)
[override virtual]
void ACDPBaseChannel::SetChannelMask(unsigned char mask)
Reimplemented from ICDPChannel::SetChannelMask().
Sets mask for channel. Only valid for type bool
.
Mask
is updated with value from mask, and MaskInverted
gets inverted value.
[override virtual]
void ACDPBaseChannel::SetDataPointer(void *data, double *timestamp = nullptr, std::optional<unsigned int> size = {})
[override virtual]
void ACDPBaseChannel::SetDataResizeHandler(const std::function<void( unsigned int ) > &resizeHandler = {})
[override virtual]
void ACDPBaseChannel::SetDataSize(unsigned int size)
[pure virtual protected]
void ACDPBaseChannel::SetExternal(T newValue)
[pure virtual protected]
void ACDPBaseChannel::SetInternal(T newValue, double timeStamp)
[override virtual]
void ACDPBaseChannel::SetNetworkConvert(bool networkConvert)
Reimplemented from ICDPChannel::SetNetworkConvert().
Specifies if networkconvert will be done or not in SyncOut()/SyncIn()
If networkConvert is true
, FromBigendian()/ToBigendian() will be called on data in SyncOut()/SyncIn(), otherwise just memcpy
will be performed.
[override virtual protected]
void ACDPBaseChannel::SetVariantValue(const CDP::StudioAPI::CDPVariantValue &value)
[override virtual protected]
void ACDPBaseChannel::SyncIn()
Reimplemented from IChannel::SyncIn().
Reads in value in using GetInternal(), does optional network convert and writes the data to the channel internal value storage.
Calls also ProcessChangeValidators().
When the channel internal value storage was set to dynamically re-sizable (i.e. SetDataPointer() was called with size==0), then will also resize the internal value storage to the size the new value has.
[override virtual protected]
void ACDPBaseChannel::SyncOut()
Reimplemented from IChannel::SyncOut().
Gets channel value from internal value storage, does optional network convert and writes the value out using SetInternal().
Calls also ProcessChangeValidators()
[override virtual]
void ACDPBaseChannel::UnregisterValidator(IChangeValidator *validator)
Member Variable Documentation
std::unique_ptr<std::string> ACDPBaseChannel::m_internalStorage
This variable holds string for the internal value storage to store values in transit (for cases where no user defined storage is set).
CDPProperty<bool> ACDPBaseChannel::m_networkConvert
This variable specifies if networkconvert will be done or not in SyncOut()/SyncIn(), see SetNetworkConvert().
ChangeValidatorSupport<T> ACDPBaseChannel::m_validators
This variable holds a validator-container to register/unregister validators and do ProcessChangeValidators (accept or not a value change).
Get started with CDP Studio today
Let us help you take your great ideas and turn them into the products your customer will love.