Class TcoObject
Basic construction block from which all blocks of a TcOpen application should derive in order to take advantage of the framework.
This function block is abstract and must be implemented in a derived block.
TcoObject
, must be constructed via FB_init(ITcoObject)
method at instantiation.
TcoObjects
that belong to same TcoContext
share the same context.
This is typically achieved by constructing the object with FB_init(THIS^)
, where THIS^
is of ITcoObject
(note that ITcoContext also implements ITcoObject).
warning
Whenever it is required to pass function block parameters of a block type that derives from `TcoObject` it should be passed as **reference**. This means either via appropriate interface or as `REFERENCE TO` in VAR_INPUT and VAR_OUTPUT sections or as VAR_IN_OUT. Be aware the VAR_INPUT and VAR_OUTPUT create a copy of the variable.
All the variables _myContext, _ContextTcoObjectA, _ContextTcoObjectB, _ContextChildTcoObject should have all the same value.
All the variables _myIdentity, _TcoObjectAidentity, _TcoObjectBidentity, _ChildTcoObjectidentity should have uniques values.
The context of the myTcoContext instance is assigned to itself. As the _myTcoObjectA context is assigned to this instance of the myTcoContext, it is assigned to the same context,
and the value of the _ContextTcoObjectA will be the same as the value of the _myContext.
The context of the _myTcoObjectB instance is assigned to the _myTcoObjectA, that has already assigned context to this instance of the myTcoContext.
So the value of the _ContextTcoObjectB will be the same as the values of the _ContextTcoObjectA and _myContext.
The context of the _myTcoObjectB._myChildTcoObject instance is assigned to the _myTcoObjectB, that has already assigned context to _myTcoObjectA,
that has already assigned its context to this instance of the myTcoContext.
So the value of the _ContextChildTcoObject wile be the same as the values _ContextTcoObjectB,_ContextTcoObjectA and _myContext.
As the Identities of all objects points to the themselves, all identities will have different values, as all objects are unique.
Example
//Definition of the myTcoObject
FUNCTION_BLOCK myTcoObject EXTENDS TcoObject
VAR
_myChildTcoObject : myChildTcoObject(THIS^);
END_VAR
//Definition of the myTcoContext
FUNCTION_BLOCK myTcoContext EXTENDS TcoContext
VAR
_myTcoObjectA : myTcoObject(THIS^);
_myTcoObjectB : myTcoObject(_myTcoObjectA.Context);
_myContext : ITcoContext;
_ContextTcoObjectA : ITcoContext;
_ContextTcoObjectB : ITcoContext;
_ContextChildTcoObject : ITcoContext;
_myIdentity : ULINT;
_TcoObjectAidentity : ULINT;
_TcoObjectBidentity : ULINT;
_ChildTcoObjectidentity : ULINT;
END_VAR
//Plc code of the myTcoContext
_myContext := THIS^.Context;
_ContextTcoObjectA := _myTcoObjectA.Context;
_ContextTcoObjectB := _myTcoObjectB.Context;
_ContextChildTcoObject := _myTcoObjectB._myChildTcoObject.Context;
_myIdentity := THIS^.Identity;
_TcoObjectAidentity := _myTcoObjectA.Identity;
_TcoObjectBidentity := _myTcoObjectB.Identity;
_ChildTcoObjectidentity := _myTcoObjectB._myChildTcoObject.Identity;
Explanation
Inheritance
Inherited Members
Namespace: PlcDocu.TcoCore
Assembly: TcoCoreConnector.dll
Syntax
public abstract class TcoObject
Constructors
| Improve this Doc View SourceTcoObject()
Prevents creating instance of this class via public constructor
Declaration
public TcoObject()
Fields
| Improve this Doc View Source_Identity
Declaration
public object _Identity
Field Value
Type | Description |
---|---|
System.Object |
_messenger
Declaration
public TcoMessenger _messenger
Field Value
Type | Description |
---|---|
TcoMessenger |
Properties
| Improve this Doc View SourceContext
Gets the context of the this object. The context is provided by parent object(s).
Declaration
[IgnoreReflection]
public dynamic Context { get; }
Property Value
Type | Description |
---|---|
System.Object | Plc type ITcoContext; Twin type: |
Identity
Gets the identity of this TcoObject().
This value is assigned after download by calling the implicit method FB_init()
and cannot be changed during runtime.
This variable is used in the higher level applications.
Declaration
[IgnoreReflection]
public dynamic Identity { get; }
Property Value
Type | Description |
---|---|
System.Object | Plc type ULINT; Twin type: Vortex.Connector.ValueTypes.OnlinerULInt |
Messenger
Gets messenger of this object. See TcoMessenger() for more details.
Declaration
[IgnoreReflection]
public dynamic Messenger { get; }
Property Value
Type | Description |
---|---|
System.Object | Plc type ITcoMessenger; Twin type: |
Methods
| Improve this Doc View SourceEqualsTo(Object)
Compares this object to another object and returns true
when the reference equals.
When overriden in derived class custom comparison of two objects of the same type can be evaluated.
Declaration
[IgnoreReflection]
public dynamic EqualsTo(dynamic Object)
Parameters
Type | Name | Description |
---|---|---|
System.Object | Object | Plc type : ITcoObject [VAR_INPUT]; Twin type :
|
Returns
Type | Description |
---|---|
System.Object | Plc type BOOL; Twin type: Vortex.Connector.ValueTypes.OnlinerBool |
Examples
// EqualsTo method override example of type MyObject
METHOD PUBLIC EqualsTo : BOOL
VAR_INPUT
Object : ITcoObject;
END_VAR
VAR
_object : POINTER TO MyObject;
END_VAR
//--------------------------------------------
IF(__QUERYPOINTER(Object, _object)) THEN
EqualsTo := _object^._SomeNumber = THIS^._SomeNumber AND _object^._SomeString = THIS^._SomeString;
END_IF;