Class TcoDataExchange
Provides a mechanism to exchange data between PLC and an arbitrary data repository.
TcoDataExchange support Create, Read, Update, Delete (CRUD) operations and some additional
functions.
TcoDataExchange operates by convention on data member named
Inxton is required for this feature to work.
_data
declared in the function block.
The _data
member must be of type that extends TcoData.TcoEntity
.
TcoDataEchange must be then inizialized in the higher level application where the repository
and remote data exchange is configured.
information
Inherited Members
Namespace: PlcDocu.TcoData
Assembly: TcoDataConnector.dll
Syntax
public abstract class TcoDataExchange : TcoObject
Examples
// Function block for data maipulation must extend from TcoData.TcoDataExchange.
FUNCTION_BLOCK TcoDataManager EXTENDS TcoData.TcoDataExchange
VAR
// This is the structure that contains the actual data we will work with. The `STRUCT` must extend `TcoData.TcoEntity`
_data : SandboxData;
END_VAR
// IMPLEMENTATION BODY OF FUNCTION BLOCK
// IMPORTANT: SUPER CALL HERE IS REQUIRED TO CALL THE DATA MANAGER TASKS!!!
SUPER^();
// DATA STRUCTURE ELIGIBLE FOR USE WITH TcoDataExchange.
TYPE
SandboxData EXTENDS TcoData.TcoEntity :
STRUCT
sampleData : SampleDataStructure;
someInteger : INT;
someString : STRING;
END_STRUCT
END_TYPE
repository = new MongoDbRepository<PlainSandboxData>
(new MongoDbRepositorySettings<PlainSandboxData>("mongodb://localhost:27017", "MyExampleDatabase", "MyExampleCollection"));
Entry.TcoDataTests.MAIN.sandbox.DataManager.InitializeRepository(repository);
Entry.TcoDataTests.MAIN.sandbox.DataManager.InitializeRemoteDataExchange();
Constructors
| Improve this Doc View SourceTcoDataExchange()
Prevents creating instance of this class via public constructor
Declaration
public TcoDataExchange()
Fields
| Improve this Doc View Source_createOrUpdateTask
Instance of task that creates inexisting or updates existing
record in the repository.
Declaration
public TcoDataTask _createOrUpdateTask
Field Value
Type | Description |
---|---|
TcoDataTask |
_createTask
Instance of task that creates
the entry into repository.
Declaration
public TcoDataTask _createTask
Field Value
Type | Description |
---|---|
TcoDataTask |
_deleteTask
Instance of task that deletes
record from the repository.
Declaration
public TcoDataTask _deleteTask
Field Value
Type | Description |
---|---|
TcoDataTask |
_idExistsTask
Instance of task that check for existence
of a record with an id
in the repository.
Declaration
public TcoExistsTask _idExistsTask
Field Value
Type | Description |
---|---|
TcoExistsTask |
_readTask
Instance of task that reads
the entry from repository.
Declaration
public TcoDataTask _readTask
Field Value
Type | Description |
---|---|
TcoDataTask |
_updateTask
Instance of task that updates
record in the repository.
Declaration
public TcoDataTask _updateTask
Field Value
Type | Description |
---|---|
TcoDataTask |
Methods
| Improve this Doc View SourceCreate(Object)
Creates new entry in the Repository from
Inxton is required for this feature to work.
_data
member of this TcoDataExchange
.
information
Declaration
[IgnoreReflection]
public dynamic Create(dynamic Identifier)
Parameters
Type | Name | Description |
---|---|---|
System.Object | Identifier | Plc type : STRING [VAR_INPUT]; Twin type : Vortex.Connector.ValueTypes.OnlinerString
|
Returns
Type | Description |
---|---|
System.Object | Plc type ITcoTaskStatus; Twin type: |
Examples
// Will create new entry into repository with data contained in the `_data`
IF(DataManager.Create(recordId_1).Done) THEN
DataManager.Messenger.Build().Append('Record ').Append(recordId_1).Append(' created.').As().AsInfo();
END_IF;
|
Improve this Doc
View Source
CreateOrUpdate(Object)
Creates or updates new entry in the Repository from
Inxton is required for this feature to work.
_data
member of this TcoDataExchange
.
information
Declaration
[IgnoreReflection]
public dynamic CreateOrUpdate(dynamic Identifier)
Parameters
Type | Name | Description |
---|---|---|
System.Object | Identifier | Plc type : STRING [VAR_INPUT]; Twin type : Vortex.Connector.ValueTypes.OnlinerString
|
Returns
Type | Description |
---|---|
System.Object | Plc type ITcoTaskStatus; Twin type: |
Examples
|
Improve this Doc
View Source
Delete(Object)
Deletes an item from the repository.
Inxton is required for this feature to work.
information
Declaration
[IgnoreReflection]
public dynamic Delete(dynamic Identifier)
Parameters
Type | Name | Description |
---|---|---|
System.Object | Identifier | Plc type : STRING [VAR_INPUT]; Twin type : Vortex.Connector.ValueTypes.OnlinerString
|
Returns
Type | Description |
---|---|
System.Object | Plc type ITcoTaskStatus; Twin type: |
Examples
IF(DataManager.Delete(recordId_1).Done) THEN
DataManager.Messenger.Build().Append('Record ').Append(recordId_1).Append(' deleted.').As().AsInfo();
END_IF;
|
Improve this Doc
View Source
Exists(Object)
Determines if the entry with given
Inxton is required for this feature to work.
Identifier
exists in the repository.
information
Declaration
[IgnoreReflection]
public dynamic Exists(dynamic Identifier)
Parameters
Type | Name | Description |
---|---|---|
System.Object | Identifier | Plc type : STRING [VAR_INPUT]; Twin type : Vortex.Connector.ValueTypes.OnlinerString
|
Returns
Type | Description |
---|---|
System.Object | Plc type TcoExistsTask; Twin type: TcoExistsTask |
Examples
IF(DataManager.Exists(recordId_2).Done) THEN
DataManager.Messenger.Clear();
IF(DataManager.Exists(recordId_2).Exists) THEN
DataManager.Messenger.Build().Append('Record ').Append(recordId_2).Append(' exists.').As().AsInfo();
ELSE
DataManager.Messenger.Build().Append('Record ').Append(recordId_2).Append(' does not exists.').As().AsInfo();
END_IF
END_IF
|
Improve this Doc
View Source
Read(Object)
Reads data from the repository and stores it into
Inxton is required for this feature to work.
_data
member of this instance of TcoDataExchange
.
information
Declaration
[IgnoreReflection]
public dynamic Read(dynamic Identifier)
Parameters
Type | Name | Description |
---|---|---|
System.Object | Identifier | Plc type : STRING [VAR_INPUT]; Twin type : Vortex.Connector.ValueTypes.OnlinerString
|
Returns
Type | Description |
---|---|
System.Object | Plc type ITcoTaskStatus; Twin type: |
Examples
IF(DataManager.Read(recordId_1).Done) THEN
DataManager.Messenger.Build()
.Append('Record ')
.Append(recordId_1)
.Append(' read.')
.AppendAny(DataManager.Data.sampleData.SampleInt)
.Append(';')
.Append(DataManager.Data.sampleData.SampleString)
.Append(';')
.AppendAny(DataManager.Data.sampleData.SampleNestedStructure.SampleLREAL)
.As().AsInfo();
END_IF;
|
Improve this Doc
View Source
Update(Object)
Updates data in the repository from
Inxton is required for this feature to work.
_data
member of this instance of TcoDataExchange
.
information
Declaration
[IgnoreReflection]
public dynamic Update(dynamic Identifier)
Parameters
Type | Name | Description |
---|---|---|
System.Object | Identifier | Plc type : STRING [VAR_INPUT]; Twin type : Vortex.Connector.ValueTypes.OnlinerString
|
Returns
Type | Description |
---|---|
System.Object | Plc type ITcoTaskStatus; Twin type: |
Examples
DataManager.Data.sampleData.SampleInt := 33;
DataManager.Data.sampleData.SampleString := 'Max';
DataManager.Data.sampleData.SampleNestedStructure.SampleLREAL := 1;
IF(DataManager.Update(recordId_1).Done) THEN
DataManager.Messenger.Build().Append('Record ').Append(recordId_1).Append(' updated.').As().AsInfo();
END_IF;