PLCnext API Documentation 25.0.2.69
Public Types | Public Member Functions | List of all members
Arp::Io::Commons::DataManager Class Reference

This class is used to store and to manage fieldbus frame buffer objects. More...

#include <DataManager.hpp>

Public Types

using BufferInfo = Arp::Io::Commons::Data::BufferInfo
 
using DataType = Arp::Plc::Meta::Commons::DataType
 
using ArrayDimensions = Arp::Plc::Meta::Commons::Io::PortDefinition::ArrayDimensions
 

Public Member Functions

 DataManager (const DataManager &arg)=delete
 
 DataManager (DataManager &&arg) noexcept
 Default move constructor.
 
DataManageroperator= (const DataManager &arg)=delete
 
DataManageroperator= (DataManager &&arg) noexcept
 Default move-assignment operator.
 
 ~DataManager (void)
 Default destructor.
 
 DataManager (const String &componentName, Endianness defaultEndianness)
 Constructs an DataManager instance. More...
 
Endianness GetDefaultEndianness (void) const
 Gets the default endianness of the IoComponent. More...
 
bool IsPlcRunning (void) const
 Checks the current 'PlcState' is 'PlcState::Running'. The method returns at once to false after the real-time tasks are stopped, even before IoComponentBase::StopPlc. More...
 
IoBuffer::Ptr GetSystemIoBuffer (const String &bufferName)
 Returns a 'SystemIoBuffer' buffer object by given name. Throws exception, if buffer with 'bufferName' could not found. More...
 
bool TryGetSystemIoBuffer (const String &bufferName, IoBuffer::Ptr &result)
 Tries to return a 'SystemIoBuffer' buffer object by given name. More...
 
IoBuffer::Ptr GetPlcIoBuffer (const String &bufferName, bool isChanging=false)
 Returns a 'PlcIoBuffer' buffer object by given name. Throws exception, if buffer with 'bufferName' could not found. More...
 
bool TryGetPlcIoBuffer (const String &bufferName, IoBuffer::Ptr &result, bool isChanging=false)
 Tries to return a 'PlcIoBuffer' buffer object by given name. More...
 
IoBuffer::Ptr CreateSystemIoBuffer (const BufferInfo &bufferInfo)
 Creates a 'SystemIoBuffer' buffer object. Throws exception, if buffer with 'bufferName' is already added. More...
 
IoBuffer::Ptr CreatePlcIoBuffer (const BufferInfo &bufferInfo, bool isChanging=false)
 Creates a 'PlcIoBuffer' buffer object. Throws exception, if buffer with 'bufferName' is already added. More...
 
void RegisterStatusVariable (const String &name, DataType dataType)
 Registers a new status variable. More...
 
void RegisterStatusVariable (const String &name, DataType dataType, const ArrayDimensions &dimensions)
 Registers a new array status variable. More...
 
void RegisterBitStatusVariable (const String &name, uint32 bitOffset)
 Registers a new bit status variable. Bit variables always references a specific bit in the last registered (non-bit) status variable. More...
 
byte * GetStatusVariableAddress (const String &name) const
 Returns a pointer to a status variable. This is only possible after the status variable have been created in SetupConfig. Throws if the variable is unknown os is still not been created. More...
 
Impl & GetImpl (void)
 For internal use only.
 
const Impl & GetImpl (void) const
 

Detailed Description

This class is used to store and to manage fieldbus frame buffer objects.

The DataManager handles different kinds of data buffer objects:

type description
System buffer System Io buffers are created during the start up of the firmware. They are created in SetupConfig and are destroyed in ResetConfig. They should be used for all data elements, that are independent of the project.
Plc frame Plc Io buffers are created during the setup up of the project. They are created in SetupPlc and are destroyed in ResetPlc. They should be used for all data elements, that are part of the project.
Status variables Status variables are used to store global status values of the fieldbus. They are stored in an unsynced internal buffer. They can be accessed without real-time side effects but cannot guarantee data consistency. Status variables should be registered in IoComponentBase::InitializeInternal. They are created in SetupConfig.

The method IsPlcRunning provides information about the running state of the plc. This method should be polled in the update thread of the IO component. If the method returns false, the IO component should use substitute values and/or stop the communication. After this method returns false it's recommended to send the output data one time more marked as valid and after that mark the output data as invalid. This should ensure, that output data of a stop task / power down task is still sent.

Constructor & Destructor Documentation

◆ DataManager()

Arp::Io::Commons::DataManager::DataManager ( const String componentName,
Endianness  defaultEndianness 
)

Constructs an DataManager instance.

Parameters
componentNameName of the component providing the data manager
defaultEndiannessDefault data endianness of the IoComponent

The DataManager is provided by IoComponentBase and should not be created directly by the IO component

Member Function Documentation

◆ CreatePlcIoBuffer()

IoBuffer::Ptr Arp::Io::Commons::DataManager::CreatePlcIoBuffer ( const BufferInfo bufferInfo,
bool  isChanging = false 
)

Creates a 'PlcIoBuffer' buffer object. Throws exception, if buffer with 'bufferName' is already added.

Parameters
bufferInfoBuffer parameter values.
isChangingtrue if the buffer should added in the backgroundDomain, otherwise false.
Returns
IoBuffer::Ptr

◆ CreateSystemIoBuffer()

IoBuffer::Ptr Arp::Io::Commons::DataManager::CreateSystemIoBuffer ( const BufferInfo bufferInfo)

Creates a 'SystemIoBuffer' buffer object. Throws exception, if buffer with 'bufferName' is already added.

Parameters
bufferInfoBuffer parameter values.
Returns
IoBuffer::Ptr

◆ GetDefaultEndianness()

Endianness Arp::Io::Commons::DataManager::GetDefaultEndianness ( void  ) const

Gets the default endianness of the IoComponent.

Returns
Endianness

◆ GetPlcIoBuffer()

IoBuffer::Ptr Arp::Io::Commons::DataManager::GetPlcIoBuffer ( const String bufferName,
bool  isChanging = false 
)

Returns a 'PlcIoBuffer' buffer object by given name. Throws exception, if buffer with 'bufferName' could not found.

Parameters
bufferNameName of the buffer object.
isChangingtrue if the buffer of the background domain should be returned, otherwise false.
Returns
IoBuffer::Ptr

◆ GetStatusVariableAddress()

byte * Arp::Io::Commons::DataManager::GetStatusVariableAddress ( const String name) const

Returns a pointer to a status variable. This is only possible after the status variable have been created in SetupConfig. Throws if the variable is unknown os is still not been created.

Parameters
nameName of the status variable
Returns
Pointer to the status variable.

◆ GetSystemIoBuffer()

IoBuffer::Ptr Arp::Io::Commons::DataManager::GetSystemIoBuffer ( const String bufferName)

Returns a 'SystemIoBuffer' buffer object by given name. Throws exception, if buffer with 'bufferName' could not found.

Parameters
bufferNameName of the buffer object.
Returns
IoBuffer::Ptr

◆ IsPlcRunning()

bool Arp::Io::Commons::DataManager::IsPlcRunning ( void  ) const

Checks the current 'PlcState' is 'PlcState::Running'. The method returns at once to false after the real-time tasks are stopped, even before IoComponentBase::StopPlc.

Returns
true if the PLC is in 'PlcState::Running', otherwise false.

◆ RegisterBitStatusVariable()

void Arp::Io::Commons::DataManager::RegisterBitStatusVariable ( const String name,
uint32  bitOffset 
)

Registers a new bit status variable. Bit variables always references a specific bit in the last registered (non-bit) status variable.

Parameters
nameName of the status variable
bitOffsetRelative bit offset to the last full status variable.

◆ RegisterStatusVariable() [1/2]

void Arp::Io::Commons::DataManager::RegisterStatusVariable ( const String name,
DataType  dataType 
)

Registers a new status variable.

Parameters
nameName of the status variable
dataTypeInfoDescription of the status variable.

◆ RegisterStatusVariable() [2/2]

void Arp::Io::Commons::DataManager::RegisterStatusVariable ( const String name,
DataType  dataType,
const ArrayDimensions &  dimensions 
)

Registers a new array status variable.

Parameters
nameName of the status variable
dataTypeInfoDescription of the status variable base type.
dimensionsArray dimensions

◆ TryGetPlcIoBuffer()

bool Arp::Io::Commons::DataManager::TryGetPlcIoBuffer ( const String bufferName,
IoBuffer::Ptr &  result,
bool  isChanging = false 
)

Tries to return a 'PlcIoBuffer' buffer object by given name.

Parameters
bufferNameName of the buffer object.
resultReturns initialized IoBuffer::Ptr.
isChangingtrue if the buffer of the background domain should be returned, otherwise false.
Returns
true if buffer was found, otherwise false.

◆ TryGetSystemIoBuffer()

bool Arp::Io::Commons::DataManager::TryGetSystemIoBuffer ( const String bufferName,
IoBuffer::Ptr &  result 
)

Tries to return a 'SystemIoBuffer' buffer object by given name.

Parameters
bufferNameName of the buffer object.
resultReturns initialized IoBuffer::Ptr.
Returns
true if buffer was found, otherwise false.

The documentation for this class was generated from the following files: