PLCnext API Documentation  20.3.1.28622
Public Types | Public Member Functions | Static Public Member Functions | List of all members
Arp::Plc::Gds::Services::ISubscriptionService Class Referenceabstract

Services for the subscription. More...

#include <ISubscriptionService.hpp>

Inheritance diagram for Arp::Plc::Gds::Services::ISubscriptionService:
Inheritance graph

Public Types

typedef std::shared_ptr< ISubscriptionServicePtr
 
typedef delegate< void(IRscWriteEnumerator< RscString< 512 >> &)> AddVariablesVariableNamesDelegate
 
typedef delegate< void(IRscReadEnumerator< DataAccessError > &)> AddVariablesResultDelegate
 
typedef delegate< void(IRscReadEnumerator< VariableInfo > &)> GetVariableInfosVariableInfoDelegate
 
typedef delegate< void(IRscReadEnumerator< VariableInfo > &)> GetTimeStampedVariableInfosVariableInfoDelegate
 
typedef delegate< void(IRscReadEnumerator< VariableInfo > &)> GetRecordInfosRecordInfosDelegate
 
typedef delegate< void(IRscReadEnumerator< RscVariant< 512 >> &)> ReadValuesValuesDelegate
 
typedef delegate< void(IRscReadEnumerator< RscVariant< 512 >> &)> ReadTimeStampedValuesValuesDelegate
 
typedef delegate< void(IRscReadEnumerator< RscVariant< 512 >> &)> ReadRecordsRecordsDelegate
 
- Public Types inherited from Arp::System::Rsc::Services::IRscService
typedef std::shared_ptr< IRscServicePtr
 

Public Member Functions

 ISubscriptionService (void)
 Constructs an ISubscriptionService instance. More...
 
virtual ~ISubscriptionService (void)
 Destructs this instance and frees all resouces. More...
 
virtual uint32 CreateSubscription (SubscriptionKind kind)=0
 Creates a subscription of the given Arp.Plc.Gds.Services.SubscriptionKind. More...
 
virtual uint32 CreateRecordingSubscription (uint16 recordCount)=0
 Creates a subscription of Arp.Plc.Gds.Services.SubscriptionKind.Recording. More...
 
virtual DataAccessError AddVariable (uint32 subscriptionId, const RscString< 512 > &variableName)=0
 Extends the subscription with the given id by inserting the given variable name More...
 
virtual void AddVariables (uint32 subscriptionId, AddVariablesVariableNamesDelegate variableNamesDelegate, AddVariablesResultDelegate resultDelegate)=0
 Extends the subscription with the given id by inserting a range of new variables. More...
 
virtual DataAccessError RemoveVariable (uint32 subscriptionId, const RscString< 512 > &variableName)=0
 Removes the variable with the specific variable name from the subscription. More...
 
virtual DataAccessError Subscribe (uint32 subscriptionId, uint64 sampleRate)=0
 Subscribes the subscription with the given id. More...
 
virtual DataAccessError Resubscribe (uint32 subscriptionId, uint64 sampleRate)=0
 Resubscribes the subscription with the given id. More...
 
virtual DataAccessError Unsubscribe (uint32 subscriptionId)=0
 Unsubscribes the subscription with the given id. More...
 
virtual DataAccessError DeleteSubscription (uint32 subscriptionId)=0
 Deletes the subscription. More...
 
virtual DataAccessError GetVariableInfos (uint32 subscriptionId, GetVariableInfosVariableInfoDelegate variableInfoDelegate)=0
 Get the subscribed variable information of the subscription. More...
 
virtual DataAccessError GetTimeStampedVariableInfos (uint32 subscriptionId, GetTimeStampedVariableInfosVariableInfoDelegate variableInfoDelegate)=0
 Get the subscribed variable information including information of timestamps of the subscription. More...
 
virtual DataAccessError GetRecordInfos (uint32 subscriptionId, GetRecordInfosRecordInfosDelegate recordInfosDelegate)=0
 Get the subscribed variable information as a record of the subscription. More...
 
virtual DataAccessError ReadValues (uint32 subscriptionId, ReadValuesValuesDelegate valuesDelegate)=0
 Read the data from the subscription with the given id. More...
 
virtual DataAccessError ReadTimeStampedValues (uint32 subscriptionId, ReadTimeStampedValuesValuesDelegate valuesDelegate)=0
 Read the data including timestamps from the subscription with the given id. More...
 
virtual DataAccessError ReadRecords (uint32 subscriptionId, uint16 count, ReadRecordsRecordsDelegate recordsDelegate)=0
 Read the data including timestamps from the subscription with the given id separated in task records. More...
 
- Public Member Functions inherited from Arp::System::Rsc::Services::IRscService
 IRscService (void)=default
 Constructs an IRscService instance. More...
 
virtual ~IRscService (void)=default
 Destructs this instance and frees all resouces. More...
 

Static Public Member Functions

static IRscServiceProxyFactory & GetProxyFactory (void)
 
- Static Public Member Functions inherited from Arp::System::Rsc::Services::IRscService
static IRscServiceProxyFactory & GetProxyFactory (void)
 Returns a reference to service proxy factory to create a proxy instance of the service More...
 

Detailed Description

Services for the subscription.

The subscription functionality is a more elegant way reading values from variables, in contrast to permanently reading (polling). A client can subscribe a selection of variables of interest and the subscription will copy the data values to a internal buffer. This is the recommended mechanism to “read” variable values from th PLC system. All read data are always task consistent, because the data is written by the task itself.

The data updating rate depends of the task to which the variable belongs. Because global variables haven't a task affiliation, each global variable will be updated by default from the task 'Globals'. This task has a default cycling time of 50ms which is configurable via the ESM configuration. For more information to the update rate see Arp.Plc.Gds.Services.ISubscriptionService.Subscribe.

Initially, the internal buffers are initialized with null values (Arp.Plc.DataType.Void). This is important to know, especially if values are read immediately after the subscription is created. More precisely if the data are read before the tasks have written the data.

Additionally a subscription is able to generate timestamps which will be generated at the end of the variable source task. Arp.Plc.Gds.Services.ISubscriptionService.ReadTimeStampedValues

A client can subscribe to different types of variables provided in Arp.Plc.DataType. Currently supported variable types are listed below:

TypeSupported variablesDescription
Arp.Plc.DataType.PrimitiveYES
Arp.Plc.DataType.DateTimeYes
Arp.Plc.DataType.String(YES)Please use Arp.Plc.DataType.StaticString or Arp.Plc.DataType.IecString.
Arp.Plc.DataType.EnumYES
Arp.Plc.DataType.StructYES
Arp.Plc.DataType.FunctionBlockYES
Arp.Plc.DataType.PointerYES
Arp.Plc.DataType.ArrayYES

To address a variable, the full variable name (uri) is necessary. Some valid examples are given below:

ComponentName-1/ProgramName-1.Variable_Name
ComponentName-1/Global_Variable_Name
ComponentName-1/ProgramName-1.Array_Variable_Name[index]
ComponentName-1/ProgramName-1.Array_Variable_Name[startIndex:endIndex]
ComponentName-1/ProgramName-1.Struct_Variable_Name.Element1.Leaf
ComponentName-1/ProgramName-1.Struct_Variable_Name.Element1.LeafArray[index]
ComponentName-1/ProgramName-1.Struct_Variable_Name.Element1.LeafArrayOfArray[indexX][indexY]

A Subscription can created in the PLC process, in other processes and also on remote targets.

All subscriptions will be removed after a Arp.Plc.Domain.Services.PlcStartKind.Cold and Arp.Plc.Domain.Services.PlcStartKind.Warm start and after a download change. While a download change is in process the subscription service will be disabled and each function will be return the error code Arp.Plc.Gds.Services.DataAccessError.CurrentlyUnavailable.

Procedure of usage: tdb

Constructor & Destructor Documentation

◆ ISubscriptionService()

ISubscriptionService::ISubscriptionService ( void  )
inline

Constructs an ISubscriptionService instance.

◆ ~ISubscriptionService()

ISubscriptionService::~ISubscriptionService ( void  )
inlinevirtual

Destructs this instance and frees all resouces.

Member Function Documentation

◆ AddVariable()

virtual DataAccessError Arp::Plc::Gds::Services::ISubscriptionService::AddVariable ( uint32  subscriptionId,
const RscString< 512 > &  variableName 
)
pure virtual

Extends the subscription with the given id by inserting the given variable name

The added variable is stored in a internal container and will be subscribed after calling Arp.Plc.Gds.Services.ISubscriptionService.Subscribe. If the subscription has already been subscribed, it is necessary to call Arp.Plc.Gds.Services.ISubscriptionService.Resubscribe to subscribe the new added variable finally.

If the same full variable name is added multiple times, the old variable will be overridden. In case, a variable name is invalid or doesn't exists a specific error code will be returned Arp.Plc.Gds.Services.DataAccessError, on success the code Arp.Plc.Gds.Services.DataAccessError.None of the added variable will be returned. A variable which doesn't returned with Arp.Plc.Gds.Services.DataAccessError.None won't be added to the subscription and won't be subscribed.

A single array element can added with its index in brackets e.g.:

ComponentName-1/ProgramName-1.Array_Name[index]

Or a rage of an array can added with tow indexes separated with a colon in brackets e.g.:

ComponentName-1/ProgramName-1.Array_Name[StartIndex:EndIndex]

If an array variable is added without a variable specification, the entire array will be added to the subscription.

An alternative way to insert variables to the subscription is by using the function Arp.Plc.Gds.Services.ISubscriptionService.AddVariables.

Parameters
subscriptionIdThe id of the subscription where the variable is add to.
variableNameThe full name of the variable.
Returns
Returns Arp.Plc.Gds.Services.DataAccessError.None on success.
See also
Arp.Plc.Gds.Services.ISubscriptionService.AddVariables

◆ AddVariables()

virtual void Arp::Plc::Gds::Services::ISubscriptionService::AddVariables ( uint32  subscriptionId,
AddVariablesVariableNamesDelegate  variableNamesDelegate,
AddVariablesResultDelegate  resultDelegate 
)
pure virtual

Extends the subscription with the given id by inserting a range of new variables.

Allows to add a range of variables to the subscription. The returned array of type Arp.Plc.Gds.Services.DataAccessError, is in the same order as the given array of variable names and indicates if the given variables are valid and exist. For further information see Arp.Plc.Gds.Services.ISubscriptionService.AddVariable.

Parameters
subscriptionIdThe id of the subscription where the variables are added to.
variableNamesAn array of full variable names.
Returns
Returns a vector of Arp.Plc.Gds.Services.DataAccessError, Arp.Plc.Gds.Services.DataAccessError.None on success, in the same order as the variables were added.
See also
Arp.Plc.Gds.Services.ISubscriptionService.AddVariable

◆ CreateRecordingSubscription()

virtual uint32 Arp::Plc::Gds::Services::ISubscriptionService::CreateRecordingSubscription ( uint16  recordCount)
pure virtual

Creates a subscription of Arp.Plc.Gds.Services.SubscriptionKind.Recording.

This method creates a subscription of the kind Arp.Plc.Gds.Services.SubscriptionKind.Recording. Compared to the method Arp.Plc.Gds.Services.ISubscriptionService.CreateSubscription, it allows to configure the capacity of the internal used ring buffer. For further information see Arp.Plc.Gds.Services.ISubscriptionService.CreateSubscription.

Parameters
recordCountThe maximum number of storable records.
Returns
The unique subscription id on success, otherwise 0.
See also
Arp.Plc.Gds.Services.ISubscriptionService.CreateSubscription

◆ CreateSubscription()

virtual uint32 Arp::Plc::Gds::Services::ISubscriptionService::CreateSubscription ( SubscriptionKind  kind)
pure virtual

Creates a subscription of the given Arp.Plc.Gds.Services.SubscriptionKind.

This method allows other components, also from remote targets, to create a subscription which is able to subscribe each PLC variable. On success it returns a unique SubscriptionId which is created internally. The SubscriptionId has to be exposed to the SDK user, due to the usage on remote targets. The SubscriptionId is the reference to a created subscription at the PLC target and is needed in each subscription method exclude this and Arp.Plc.Gds.Services.ISubscriptionService.CreateRecordingSubscription.

Each subscription contains at least one buffer which kind depends on the Arp.Plc.Gds.Services.SubscriptionKind. The number of buffer depends on the different tasks which contains the added variables. The buffer are initialized with a Arp.Plc.DataType specific initial value e.g.: int8 = 0 or boolean = false. Apart from Arp.Plc.Gds.Services.SubscriptionKind.DirectRead, the buffer will filled by the task. How often the task stores the data to the buffer depends on the task cycle time and the configured subscription sample interval.

The Arp.Plc.Gds.Services.SubscriptionKind decides which kind of a subscription will be created. Each kind has its own benefits and differs in consistence, performance and memory usage. The available kinds are listed below:

kind description
Arp.Plc.Gds.Services.SubscriptionKind.DirectRead

The subscription itself triggers the copy process and will read the data directly from the source. This could be the fastest way and with no influence to the real time, to get the current data, but the task consistency is not guaranteed.

Usage example: Asynchronous data collection for non critical data.

Arp.Plc.Gds.Services.SubscriptionKind.HighPerformance This subscription uses a DoubleBuffer which contains the last written data from the added variables. This kind is task consistent, has low influence to the real time and is low in memory usage.

Usage example: Standard way to collect the variable data.

Arp.Plc.Gds.Services.SubscriptionKind.RealTime This subscription uses a QuadBuffer which contains the last written data from the added variables. This kind is task consistent, has the fastest access to the current written data, but uses the fourfold memory.

Usage example: For variables which are running in high speed tasks and for which it is necessary to guarantee the fastest access to the current written data. Note that in most cases the Arp.Plc.Gds.Services.SubscriptionKind.HighPerformance is sufficient.

Arp.Plc.Gds.Services.SubscriptionKind.Recording This subscription uses a RingBuffer which is able to store more than one record of data. This kind is task consistent, has low influence to the real time, but needs, dependent to the ring capacity, a lot of memory. By default the ring capacity is 10, use Arp.Plc.Gds.Services.ISubscriptionService.CreateRecordingSubscription to create a subscription witch a self defined size.

Usage example: For variables which are running in faster tasks than the consumer does and for which it is necessary to guarantee that every data record will be stored, without a single gap. Note that this kind uses a lot of memory!

After the subscription is created successfully, variables could be added with Arp.Plc.Gds.Services.ISubscriptionService.AddVariable or Arp.Plc.Gds.Services.ISubscriptionService.AddVariables with the SubscriptionId just returned in this method.

Parameters
kindThe kind of the subscription.
Returns

The unique subscription id on success, otherwise 0.

◆ DeleteSubscription()

virtual DataAccessError Arp::Plc::Gds::Services::ISubscriptionService::DeleteSubscription ( uint32  subscriptionId)
pure virtual

Deletes the subscription.

Deletes the subscription with the given id. After that the id is no longer valid and all data, containing in the subscription will be removed.

Parameters
subscriptionIdThe id of the subscription.
Returns
Returns Arp.Plc.Gds.Services.DataAccessError.None on success.

◆ GetRecordInfos()

virtual DataAccessError Arp::Plc::Gds::Services::ISubscriptionService::GetRecordInfos ( uint32  subscriptionId,
GetRecordInfosRecordInfosDelegate  recordInfosDelegate 
)
pure virtual

Get the subscribed variable information as a record of the subscription.

This service function relates to the read function Arp.Plc.Gds.Services.ISubscriptionService.ReadRecords. The provided information contains information of the added and currently subscribed variables, its task relation and additionally information about the task related timestamp.

The information are provided in an array of array of Arp.Plc.Gds.Services.VariableInfo. The first array correspond to the number of different tasks and the second contains the related variable information which are related to the variables of this task and additionally information about the task related timestamp.

Each containing timestamp has the variable name timestamp and the data type Arp.Plc.DataType.Int64 which is provided in Arp.Plc.Gds.Services.VariableInfo like each other variable information.

Example:

Added Variable from task A: a1, a2
Added Variable from task B: b1
Results in:
VariableInfo[][]
VariableInfo[]
timestamp
a1
a2
VariableInfo[]
timestamp
b1

For further information see Arp.Plc.Gds.Services.ISubscriptionService.GetVariableInfos.

Note: This function is currently not supported in C#!.

Parameters
subscriptionIdThe id of the subscription.
recordInfosAn array of Arp.Plc.Gds.Services.VariableInfo.
Returns
Returns Arp.Plc.Gds.Services.DataAccessError.None on success.

◆ GetTimeStampedVariableInfos()

virtual DataAccessError Arp::Plc::Gds::Services::ISubscriptionService::GetTimeStampedVariableInfos ( uint32  subscriptionId,
GetTimeStampedVariableInfosVariableInfoDelegate  variableInfoDelegate 
)
pure virtual

Get the subscribed variable information including information of timestamps of the subscription.

This service function relates to the read function Arp.Plc.Gds.Services.ISubscriptionService.ReadTimeStampedValues. The provided information contains information of the added and currently subscribed variables and additionally information about the timestamps. Note that a subscription could contain multiple timestamps, related on the number of used tasks from which the added variables are from. The timestamp is always the first value followed by all to the task related variable information.

Example:

Added Variable from task A: a1, a2
Added Variable from task B: b1
Results in:
VariableInfo[]
timestamp
a1
a2
timestamp
b1

Each containing timestamp has the variable name timestamp and the data type Arp.Plc.DataType.Int64 which is provided in Arp.Plc.Gds.Services.VariableInfo like each other variable information.

For further information see Arp.Plc.Gds.Services.ISubscriptionService.GetVariableInfos.

Parameters
subscriptionIdThe id of the subscription.
variableInfoAn array of Arp.Plc.Gds.Services.VariableInfo.
Returns
Returns Arp.Plc.Gds.Services.DataAccessError.None on success.

◆ GetVariableInfos()

virtual DataAccessError Arp::Plc::Gds::Services::ISubscriptionService::GetVariableInfos ( uint32  subscriptionId,
GetVariableInfosVariableInfoDelegate  variableInfoDelegate 
)
pure virtual

Get the subscribed variable information of the subscription.

The subscription service provides several read functions (Arp.Plc.Gds.Services.ISubscriptionService.ReadValues, Arp.Plc.Gds.Services.ISubscriptionService.ReadTimeStampedValues and Arp.Plc.Gds.Services.ISubscriptionService.ReadRecords) which will return the plain values without any information of type and order. To assign this plain values to the added variables, this function returns the currently subscribed variable information in a array of Arp.Plc.Gds.Services.VariableInfo in the same order as the read functions will do. This order and type information wont change, till Arp.Plc.Gds.Services.ISubscriptionService.Resubscribe was called. Note that this order does not have to be the same order like the variables has been added to the subscription.

This service function relates to the read function Arp.Plc.Gds.Services.ISubscriptionService.ReadValues. The provided information contains only information of the added and currently subscribed variables. It doesn't contain information of timestamps. Timestamps could be read by the function Arp.Plc.Gds.Services.ISubscriptionService.ReadTimeStampedValues and its related information with Arp.Plc.Gds.Services.ISubscriptionService.GetTimeStampedVariableInfos.

Example:

Added Variable from task A: a1, a2
Added Variable from task B: b1
Results in:
VariableInfo[]
a1
a2
b1
Parameters
subscriptionIdThe id of the subscription.
variableInfoAn array of Arp.Plc.Gds.Services.VariableInfo in a static order without timestamp information.
Returns
Returns Arp.Plc.Gds.Services.DataAccessError.None on success.

◆ ReadRecords()

virtual DataAccessError Arp::Plc::Gds::Services::ISubscriptionService::ReadRecords ( uint32  subscriptionId,
uint16  count,
ReadRecordsRecordsDelegate  recordsDelegate 
)
pure virtual

Read the data including timestamps from the subscription with the given id separated in task records.

This service function returns the plain data values from the added and subscribed variables including timestamps separated in task records. The data values are returned in a static order and doesn't contain any type information. To figure out which value belongs to the added variable, it is necessary to call the related information function Arp.Plc.Gds.Services.ISubscriptionService.GetRecordInfos. As long as the subscription doesn't resubscribed with Arp.Plc.Gds.Services.ISubscriptionService.Resubscribe, all the information are valid and both, the read value data and information data, are in a static order.

The number of returned value records depends on the count of tasks, the number of sampled data and the number of the given count parameter.

The structure how the values are returned is strictly defined: The first array (records) contains n arrays (task records) and where n depends on the number of tasks. The array from the second dimension (task records) contains n arrays (record), where n depends on the number of collected data, one data record per task cycle. The array from the third dimension (record) contains the plain values, starting with the timestamp.

The read data may contain null values (Arp.Plc.DataType.Void) if the read call was executed before the tasks initially have written the data.

Example:

Added Variable from task A: a1, a2
Added Variable from task B: b1
task A sampled 2 cycles
task B sampled 1 cycles
Results in:
object[] (records)
object[] (task A records)
object[] (record cycle 1)
timestamp
a1
a2
object[] (record cycle 2)
timestamp
a1
a2
object[] (task B records)
object[] (record cycle 1)
timestamp
a1
a2
Parameters
subscriptionIdThe id of the subscription.
countNumber of maximum records to be copied per task. If set to zero, all available records will be copied.
recordsArray for the subscribed data records including timestamps.
Returns
Returns Arp.Plc.Gds.Services.DataAccessError.None on success.

◆ ReadTimeStampedValues()

virtual DataAccessError Arp::Plc::Gds::Services::ISubscriptionService::ReadTimeStampedValues ( uint32  subscriptionId,
ReadTimeStampedValuesValuesDelegate  valuesDelegate 
)
pure virtual

Read the data including timestamps from the subscription with the given id.

This service function returns the plain data values from the added and subscribed variables including timestamps. The data values are returned in a static order and doesn't contain any type information. To figure out which value belongs to the added variable, it is necessary to call the related information function Arp.Plc.Gds.Services.ISubscriptionService.GetTimeStampedVariableInfos. As long as the subscription doesn't resubscribed with Arp.Plc.Gds.Services.ISubscriptionService.Resubscribe, all the information are valid and both, the read value data and information data, are in a static order.

The read data may contain null values (Arp.Plc.DataType.Void) if the read call was executed before the tasks initially have written the data.

Example:

Added Variable from task A: a1, a2
Added Variable from task B: b1
Results in:
object[]
timestamp task A
a1
a2
timestamp task B
b1
Parameters
subscriptionIdThe id of the subscription.
valuesContains the plain values including the timestamps of the given and subscribed variables.
Returns
Returns Arp.Plc.Gds.Services.DataAccessError.None on success.

◆ ReadValues()

virtual DataAccessError Arp::Plc::Gds::Services::ISubscriptionService::ReadValues ( uint32  subscriptionId,
ReadValuesValuesDelegate  valuesDelegate 
)
pure virtual

Read the data from the subscription with the given id.

This service function returns the plain data values from the added and subscribed variables. The data values are returned in a static order and doesn't contain any type information. To figure out which value belongs to the added variable, it is necessary to call the related information function Arp.Plc.Gds.Services.ISubscriptionService.GetVariableInfos. As long as the subscription doesn't resubscribed with Arp.Plc.Gds.Services.ISubscriptionService.Resubscribe, all the information are valid and both, the read value data and information data, are in a static order.

Note that this values doesn't contain timestamps! If the timestamp is needed use the function Arp.Plc.Gds.Services.ISubscriptionService.ReadTimeStampedValues instead.

The read data may contain null values (Arp.Plc.DataType.Void) if the read call was executed before the tasks initially have written the data.

Example:

Added Variable from task A: a1, a2
Added Variable from task B: b1
Results in:
object[]
a1
a2
b1
Parameters
subscriptionIdThe id of the subscription.
valuesContains the plain values of the given and subscribed variables.
Returns
Returns Arp.Plc.Gds.Services.DataAccessError.None on success.

◆ RemoveVariable()

virtual DataAccessError Arp::Plc::Gds::Services::ISubscriptionService::RemoveVariable ( uint32  subscriptionId,
const RscString< 512 > &  variableName 
)
pure virtual

Removes the variable with the specific variable name from the subscription.

Removes the variable that compare equal to the given variable name, from the internal variable list. If the subscription has already been subscribed, it is necessary to call Arp.Plc.Gds.Services.ISubscriptionService.Resubscribe to remove the given variable from the internal created buffer.

Parameters
subscriptionIdThe id of the subscription.
variableNameThe full name of the variable to be removed from the subscription.
Returns
Returns Arp.Plc.Gds.Services.DataAccessError.None on success.

◆ Resubscribe()

virtual DataAccessError Arp::Plc::Gds::Services::ISubscriptionService::Resubscribe ( uint32  subscriptionId,
uint64  sampleRate 
)
pure virtual

Resubscribes the subscription with the given id.

Resubscribes the subscription, which will trigger a completely rebuild process of the whole subscription, including previously done variable modification which have been done after the first call of Arp.Plc.Gds.Services.ISubscriptionService.Subscribe. It destroys the internal buffer and subscribes the subscription again (for further information see Arp.Plc.Gds.Services.ISubscriptionService.Subscribe). Note that the subscription is not able to collect data from the variables, while the resubscribe process is in progress.

This method has only an effect if the given subscription is currently subscribed, otherwise nothing will happen.

Parameters
subscriptionIdThe id of the subscription.
sampleRateThe desired sample rate in microseconds.
Returns
Returns Arp.Plc.Gds.Services.DataAccessError.None on success.
See also
Arp.Plc.Gds.Services.ISubscriptionService.Subscribe

◆ Subscribe()

virtual DataAccessError Arp::Plc::Gds::Services::ISubscriptionService::Subscribe ( uint32  subscriptionId,
uint64  sampleRate 
)
pure virtual

Subscribes the subscription with the given id.

All previously added variables including in the given subscription will be subscribed. Internally the variables are separated in the respective tasks, a buffer for each task will be created and connected to the task executed event. At this point the task will copy the selected variable data into the task buffer (excluded subscriptions from kind Arp.Plc.Gds.Services.SubscriptionKind.DirectRead). How often the task stores the data to the buffer depends on the task cycle time and the configured subscription sample rate.

Calling this method on a already subscribed subscription has no effect, even if new variables have been added or removed. To make variable modification effective, use Arp.Plc.Gds.Services.ISubscriptionService.Resubscribe. Calling this method while the subscription is in the state Unsubscribed, because Arp.Plc.Gds.Services.ISubscriptionService.Unsubscribe has been called, will only connect the already constructed buffer to the respective tasks and will set the given sampleRate. Compare to the first and initial call of this method, this call cost more less time because the buffer are already created. This also means that variable modification which have been done after the first call of Arp.Plc.Gds.Services.ISubscriptionService.Subscribe, have also no effect. At this point it is also necessary to call Arp.Plc.Gds.Services.ISubscriptionService.Resubscribe.

A subscribed subscription can operates in different sample rates (excluded subscriptions from kind Arp.Plc.Gds.Services.SubscriptionKind.DirectRead) which depends on several factors. First, each variable belongs to a program which runs in a task and this task has a cycle rate which determines the sample rate. This means that at the end of each task cycle, all variable data, subscribed and related to this task, will be written to the corresponding buffer. Note that all global variables are assigned to the task 'Globals'. Thats the case if the given sample rate is set to zero, which means the subscription operates in 'real-time', the same sample rate the task is operating in. This is also the fastest possible rate for a subscription. Note that it's possible that one subscription could contain variables from different tasks, which has the consequence that the subscription operates in different rates! If the given sample rate desire to a specific rate, the subscription tries to operate in this rate, for each variable, no matter from which task this variable comes. Potential self defined sample rates for a subscription are the task cycle rate or a multiple of them, otherwise the given rate will rounded down. E.g.:

Task A cycle rate = 10ms
Task B cycle rate = 8ms
Subscription given rate = 50ms
Subscription rate for task A = 50ms
Subscription rate for task B = 48ms

Special handling for global Varibales: If there isn't a given sample rate by the user (value is zero), the global variables will be recored by default from the 'Globals' task (50ms, configured in the ESM.config). But if there is a given sample rate (value is greater than zero) the global variables will be connected a task which fits the given sample rate. If no task exists with the given sample rate, the fastest available task will be picked and used for downsampling (see above). So it is possible to record data of global variables in the fastest availble interval or an multiple of them.

Parameters
subscriptionIdThe id of the subscription.
sampleRateThe desired sample rate in microseconds.
Returns
Returns Arp.Plc.Gds.Services.DataAccessError.None on success.
See also
Arp.Plc.Gds.Services.ISubscriptionService.Resubscribe

◆ Unsubscribe()

virtual DataAccessError Arp::Plc::Gds::Services::ISubscriptionService::Unsubscribe ( uint32  subscriptionId)
pure virtual

Unsubscribes the subscription with the given id.

Unsubscribes the subscription from all task executed events. The subscription data are still exist and could be get by the respective read-methods. To subscribe the subscription again, call Arp.Plc.Gds.Services.ISubscriptionService.Subscribe.

This method has only an effect if the given subscription is currently subscribed, otherwise nothing will happen.

Parameters
subscriptionIdThe id of the subscription.
Returns
Returns Arp.Plc.Gds.Services.DataAccessError.None on success.

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