Namespace PlcDocu.TcoCore
Classes
_internals_TcoContext
_internals_TcoSequence
_internals_TcoSequencer
F_AnyToUnionValue
MAIN
NO
RtcPrg
RtcSynchParams
StepDetails
Describes the status of a step of the sequencer.
StringBuilder
Allows to concat strings using fluent interface. It's similar to C# StringBuilder class Usage as follows :
ErrorString := _stringBuilder
.Clear()
.Append('Error number: ')
.Append(INT_TO_STRING(ErrorNumber))
.Append('. Message: ')
.Append(ErrorMessage)
.Append('.')
.ToString();
Inspired by Gerhard Barteling blogpost at https://www.plccoder.com/fluent-code/
TcoComponent
Basic class for components.
TcoContext
Root construction container, provides context information for TcoObjects
declared within its scope.
This function block is abstract
and cannot be instantiated.
Use Run() to run this context, Run
method must be called only once per PLC Task cycle.
Several 'TcoContext' instances can be declared and called inside one TwinCAT PlcTask, but only once per PLC cycle.
The instance should not be accessed from several Twincat PlcTasks.
Default implemenation of the 'TcoContext' allows its child members access properties StartCycleCount
and EndCycleCount, messenger settings, rtc and other information related to the context of the running logic.
tip
A TcoContext
can contain objects, components and PLC logic of one independent station of the machine,
while the another one can cover the same for another station.
tip
TwinCAT PlcTask and TcoTask() refer to two different concepts.
TcoContextCompatibility
TcoContextEnvironment
TcoContextNfCompatibility
TcoDialog
Provides standard dialog to interact with the user.
TcoDialogBase
Base block for interactive dialogs.
TcoLogger
Default implementation of Logger.
tip
This type is partially extended by IVF to retrieve messages from the logger in IVF application.
TcoLogItem
Logger message object contains complete message details including time stamp, message text, message category, identity of the message provider, context cycle in which the message was posted.
TcoMessage
Complete message details including time stamp, message text, message category, identity of the message provider, context cycle in which the message was posted.
TcoMessageDigest
TcoMessenger
Provides mechanism for delivering static messages to the supervising applications (SCADA/HMI).
Each messenger has a single placeholder for the message; it stores the most important message from the last context cycle.
If there are more messages in a single cycle for the same messenger then less important messages are discarded and replaced by
the message with the category of higher severity.
Messenger can send the data to context logger. There is a maximum limit of 10 different messages per messenger in 2 consecutive context cycles.
The messages that exceed this limit won't be logged when `OnEventRisen` logging is set.
Take this behaviour into account when designing your system.
important
important
TcoMessengerEnv
TcoMomentaryTask
Provides basic momentary on function.
To get the actual state of the momentary task,
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
TcoParentedStructure
TcoRemoteTask
Remote tasks delegates its execution to C#. When this task is invoked a C# method will be called. To initiliaze
RemoteTask
with C# method use the Initiliaze
or InitializeExclusively
method.
partial void PexConstructor(IVortexObject parent, string readableTail, string symbolTail)
{
_remoteTaskInstance.InitializeExclusively(Create);
//_remoteTaskInstance.Initialize(Create);
}
private bool Create()
{
//your code.
return true;
}
TcoRtc
TcoSequence
TcoSequencer
TcoSequencerBase
Provides basic sequential control, including step mode, which allows to run the sequence step-by-step, steping forward and steping backward.
TcoSequencerModeController
Provides switching between sequencer modes so as handling stepping tasks in the step mode.
TcoSequencerObserver
TcoSignalInfo
Provides symbol information about a I/O signal.
important
`SymbolPath` can only contain string of 255 characters.
tip
This block is partially extended by IVF to provide more information about the symbol.
TcoState
TcoStateBase
Provides basic state controller. It could be implemented using IF
, IF
ELSIF
or CASE
statement. The transition to the different state needs to be perfromed by calling
OnStateChange()
could be overloaded and some custom code that needs to be executed on each change of the state could be placed here. The TcoState could be used like this:
Example 1
_myTask()
is not a member of this TcoState()
, it is restored manually to be able to trigger it in the next state.
IF State = 10 THEN
Main._myTask.Invoke();
Main._myTask.Execute();
IF Main._myTask.Done THEN
ChangeState(State + 10);
Main._myTask.Restore();
END_IF
END_IF
IF State = 20 THEN
Main._myTask.Invoke();
Main._myTask.Execute();
IF Main._myTask.Done THEN
ChangeState(State + 10);
Main._myTask.Restore();
END_IF
END_IF
Example 2
_myTask()
is a member of this TcoState()
, it is restored manually using the fluent syntax to be able to trigger it in the next state.
CASE State OF
10:
_myTask.Invoke();
_myTask.Execute();
IF _myTask.Done THEN
ChangeState(State + 10).RestoreObject(_myTask);
END_IF
20:
_myTask.Invoke();
_myTask.Execute();
IF _myTask.Done THEN
ChangeState(State + 10).RestoreObject(_myTask);
END_IF
END_CASE
See
TcoStateExtendible
TcoStruct
Basic structure block from which most of the structures in TcOpen derive. TcoStruct
provides construction mechanism to allow for access to the
parent function block and the context.
important
The derived structure must be initialized in the declaration of the function block `mystruct : MyCustomStructure := (Parent := THIS^)`, when nested in another structure `mystruct : MyCustomStructure := (Parent := THISSTRUCT)`. This will provide access to the `TcoContext` and parent `TcoObject`.
TcoTask
Provides basic task execution. Task is started by calling the Invoke() method.
The Execute() method returns true, until the task is Done
.
To get the actual state of the task, Ready, Busy, Error and Done properties are available.
TcoTaskResult
TcoTcoSequencerObserverDummy
TcoTier
TcoToggleTask
Provides basic toggling between two states. The states are triggered by calling the Toggle() method.
To get the actual state of the toggle task,