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() | |
virtual | ~ACDPBaseChannel() |
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, unsigned int size = 0) override |
virtual void | SetNetworkConvert(bool networkConvert) override |
virtual void | UnregisterValidator(IChangeValidator *validator) override |
- 12 public functions inherited from ServerIO::ICDPChannel
- 6 public functions inherited from ServerIO::IChannel
- 26 public functions inherited from CDP::StudioAPI::CDPNode
- 22 public functions inherited from CDP::StudioAPI::ICDPNode
Protected Functions
ACDPBaseChannel(unsigned char *syncPointer, double timestamp, double *pTimestamp) | |
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) |
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() |
virtual void | SyncOut() |
- 2 protected functions inherited from ServerIO::IChannel
- 1 protected function inherited from CDP::StudioAPI::CDPNode
Protected Variables
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 memory for m_internalStoragePointer and resets all member variables to safe initial values.
[protected]
ACDPBaseChannel::ACDPBaseChannel(unsigned char *syncPointer, double timestamp, double *pTimestamp)
Constructor with 3 arguments.
m_storagePointer is updated with syncPointer value if it is not a nullptr. m_timestamp is updated with timestamp value, and m_timestampPointer is updated with pTimestamp. Allocates memory for m_internalStoragePointer and resets all member variables to safe initial values.
[virtual]
ACDPBaseChannel::~ACDPBaseChannel()
Deletes memory for m_internalStoragePointer.
[override virtual]
bool ACDPBaseChannel::GetData(void *data, unsigned int size = 0, double *timestamp = nullptr)
Reimplemented from IChannel::GetData().
Reads data from either m_internalStoragePointer or from pointer set in SetDataPointer()/constructor. 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. Returns true
if data is updated, false otherwise.
[override virtual]
unsigned int ACDPBaseChannel::GetDataSize() const
Reimplemented from IChannel::GetDataSize().
Returns sizeof(T).
[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().
Writes data into either m_internalStoragePointer or pointer set in SetDataPointer()/constructor. 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. Returns true
if data is written, false otherwise.
[override virtual]
void ACDPBaseChannel::RegisterValidator(IChangeValidator *validator)
[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, unsigned int size = 0)
Reimplemented from IChannel::SetDataPointer().
Function to set external memory region to be used as channels internal value from/to where the data from/to CDP is stored.
m_storagePointer and m_timestampPointer will be updated with the pointers data and timestamp, if for numeric types the size is 0 or matches sizeof T. For string channels the size sets the max string length.
[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)
[virtual protected]
void ACDPBaseChannel::SyncIn()
Reimplemented from IChannel::SyncIn().
Reads in value and timestamp by GetInternal().
ProcessChangeValidators() is called and network convert may be done. m_storagePointer is updated with the value. m_input
must be true
, otherwise nothing is done.
[virtual protected]
void ACDPBaseChannel::SyncOut()
Reimplemented from IChannel::SyncOut().
Value is first read from m_storagePointer, and network convert may be done.
ProcessChangeValidators() is called, before value and timestamp is written by SetInternal(). m_input
must be false
, otherwise nothing is done.
[override virtual]
void ACDPBaseChannel::UnregisterValidator(IChangeValidator *validator)
Member Variable Documentation
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.