Class 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.
Inheritance
System.Object
TcoTask
Implements
Vortex.Connector.Identity.IVortexIdentity
System.Windows.Input.ICommand
Vortex.Connector.IVortexObject
Vortex.Connector.ITwinObject
Vortex.Connector.IVortexElement
Vortex.Connector.IVortexOnlineObject
Vortex.Connector.IVortexShadowObject
Inherited Members
System.Object.ToString()
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
Assembly: TcoCoreConnector.dll
Syntax
[TypeMetaDescriptor("{attribute addProperty Name \"\" }", "TcoTask", "TcoCore", TypeComplexityEnum.Complex)]
public class TcoTask : TcoObject, IVortexIdentity, IsTcoObject, ICommand, IDecorateLog, IsTask, IVortexObject, ITwinObject, IVortexElement, ITcoTask, ITcoObject, IShadowTcoTask, IShadowTcoObject, IVortexOnlineObject, IVortexShadowObject
Examples
Declaration part of the 'TcoTask' example.
(*
This example shows using the 'Tcotask' application. 'TcoTask' is the simplest
'TcoOpen' coordination primitive.
In general the body of the task could be devided into the three section:
1.) Action
2.) Termination condition for the expected behavior.
3.) Termination condition for the non-expected behavior.
The body of the 'Tcotask' needs to be called cyclically. The 'Tcotask' could be then
invoked from 'outside'. The task of this 'Tcotask' is to ask for the favor
(in the name of the 'TcoContext' in this example Don Corleone) and offer the return favor.
Task could end up the expected way in the 'DONE' state if the requested person grant
the favor or it could end up in the 'ERROR' state if the requested person refuses to grant
the favor. Each task could be invoked only from the 'READY' state. So if the task enters
the 'ERROR' state, it cannot be invoked again and has to be restored before. Anyway in this
example this task is never restored and invoked again as Don Corleone never asks for the
next favor if the first one was refused.
*)
FUNCTION_BLOCK AskForTheFavor_Task EXTENDS TcoCore.TcoTask
VAR_INPUT
(*
'Parameters' of this task are assigned in this example from 'outside' from the
'upper level' of the hierarchy, where Invoke() method is triggered.
*)
_Person_Requested : REFERENCE TO Person_Object;
_RequestedFavor : STRING;
_ReturnFavor : STRING;
END_VAR
Implementation part of the 'TcoTask' example.
// THIS part needs to be called cyclically.
IF Execute() THEN
// First section: Action.
// Meet the right person and interpret the requirements so as a possible return favor.
_Person_Requested.RequestForTheFavor(_RequestedFavor,_ReturnFavor);
// Let the person requested to think carefully about the proposition.
_Person_Requested.ThinkCarefully();
// Second section: Termination condition for the expected behavior.
// In the case that the requested person is "smart" and "show the respect" to the
// 'TcoContext', task finishes in the 'DONE' state and process of the granted the
// return favor should be started.
DoneWhen(_Person_Requested.FavorIsGranted());
// Third section: Termination condition for the non-expected behavior.
// In the case that the requested person is so self-confident and refuse to grant
// the favor, task finishes in the 'ERROR' state and automatically the OnTaskError()
// method is triggered. In this method normally the value of the ReturnFavor is
// drammatically decreased OR changed to 'Nothing'. Anyway the requested person still
// have the possibility to grant the favor but under different condition, as he
// "had to do it the hard way".
ThrowWhen(_Person_Requested.FavorIsRefused());
END_IF
Example of the invoking this example 'TcoTask' instance 'outside' of the instance and wait if it ends-up in 'DONE' state or in 'ERROR' state.
//Starting the execution of the 'TcoTask' instance extended by input parameters from 'outside' of the instance.
Thomas.AskForTheFavor(Jack_Woltz,'Grant movie role to Johny Fontane.','No future problems with unions.').Invoke();
// Checking from the 'outside' of the instance, if the task has already finished in expected way.
_FirstOfferAccepted := Thomas._AskForTheFavor.Done;
// Checking from the 'outside' of the instance, if the task has finished in non-expected way.
_FirstOfferRefused := Thomas._AskForTheFavor.Error;
Constructors
|
Improve this Doc
View Source
TcoTask()
Declaration
|
Improve this Doc
View Source
TcoTask(IVortexObject, String, String)
Declaration
public TcoTask(IVortexObject parent, string readableTail, string symbolTail)
Parameters
Type |
Name |
Description |
Vortex.Connector.IVortexObject |
parent |
|
System.String |
readableTail |
|
System.String |
symbolTail |
|
Fields
|
Improve this Doc
View Source
__abortRequest
Declaration
OnlinerBool __abortRequest
Field Value
Type |
Description |
Vortex.Connector.ValueTypes.OnlinerBool |
|
|
Improve this Doc
View Source
__elapsedTime
Declaration
OnlinerTime __elapsedTime
Field Value
Type |
Description |
Vortex.Connector.ValueTypes.OnlinerTime |
|
|
Improve this Doc
View Source
__enabled
Declaration
Field Value
Type |
Description |
Vortex.Connector.ValueTypes.OnlinerBool |
|
|
Improve this Doc
View Source
__invokeRequest
Declaration
OnlinerBool __invokeRequest
Field Value
Type |
Description |
Vortex.Connector.ValueTypes.OnlinerBool |
|
|
Improve this Doc
View Source
__isServiceable
Declaration
OnlinerBool __isServiceable
Field Value
Type |
Description |
Vortex.Connector.ValueTypes.OnlinerBool |
|
|
Improve this Doc
View Source
__restoreRequest
Declaration
OnlinerBool __restoreRequest
Field Value
Type |
Description |
Vortex.Connector.ValueTypes.OnlinerBool |
|
|
Improve this Doc
View Source
__taskState
Declaration
Field Value
Type |
Description |
Vortex.Connector.ValueTypes.OnlinerInt |
|
|
Improve this Doc
View Source
_logPayloadDecoration
Declaration
Func<object> _logPayloadDecoration
Field Value
Type |
Description |
System.Func<System.Object> |
|
|
Improve this Doc
View Source
codeProvider
Declaration
ICodeProvider codeProvider
Field Value
|
Improve this Doc
View Source
ExecuteDialog
Declaration
public TcoTask.ExecuteDialogDelegate ExecuteDialog
Field Value
Properties
|
Improve this Doc
View Source
_abortRequest
Use to abort the executing task and set this instance back to the Ready state.
The value is than set to FALSE.
Declaration
public OnlinerBool _abortRequest { get; }
Property Value
Type |
Description |
Vortex.Connector.ValueTypes.OnlinerBool |
|
|
Improve this Doc
View Source
_elapsedTime
Declaration
[ReadOnly]
public OnlinerTime _elapsedTime { get; }
Property Value
Type |
Description |
Vortex.Connector.ValueTypes.OnlinerTime |
|
|
Improve this Doc
View Source
_enabled
Use to determine if the task execution is enabled for example from the HMI application.
This value is read only, to modify it use the property Enabled
Declaration
[ReadOnly]
public OnlinerBool _enabled { get; }
Property Value
Type |
Description |
Vortex.Connector.ValueTypes.OnlinerBool |
|
|
Improve this Doc
View Source
_invokeRequest
Use to start the execution of the task from Ready state or from Done state by performing the rising edge.
Analogously to the xExecute signal of the PLCopen motion function blocks.
Declaration
public OnlinerBool _invokeRequest { get; }
Property Value
Type |
Description |
Vortex.Connector.ValueTypes.OnlinerBool |
|
|
Improve this Doc
View Source
_isServiceable
Indicates whether the task is in serviceable state. The default state 'serviceable' that means that the task
can be invoked from the higher-level application. The serviceable state is cancelled when the immediate parent is ITcoServiceable
and at the same time the parent is not in servicebable state. TcoComponent
is serviceable, in order for the component's task to be
invokable from higher-level application component must call Service
method to induce the component into serviceable state.
Declaration
[ReadOnly]
[RenderIgnore]
public OnlinerBool _isServiceable { get; }
Property Value
Type |
Description |
Vortex.Connector.ValueTypes.OnlinerBool |
|
|
Improve this Doc
View Source
_restoreRequest
Use to restore this instance to the Ready state. The value is than set to FALSE.
Declaration
public OnlinerBool _restoreRequest { get; }
Property Value
Type |
Description |
Vortex.Connector.ValueTypes.OnlinerBool |
|
|
Improve this Doc
View Source
_taskState
Declaration
[ReadOnly]
[EnumeratorDiscriminator(typeof(eTaskState))]
public OnlinerInt _taskState { get; }
Property Value
Type |
Description |
Vortex.Connector.ValueTypes.OnlinerInt |
|
|
Improve this Doc
View Source
Abort
Gets command that aborts the execution of this task.
Declaration
public RelayCommand Abort { get; }
Property Value
|
Improve this Doc
View Source
CodeProvider
Gets swift code provider for this task.
Declaration
public virtual ICodeProvider CodeProvider { get; set; }
Property Value
|
Improve this Doc
View Source
LogPayloadDecoration
Declaration
public Func<object> LogPayloadDecoration { get; set; }
Property Value
Type |
Description |
System.Func<System.Object> |
|
|
Improve this Doc
View Source
RecordTaskAction
Gets or set action recording delegate for this task.
Declaration
public RecordTaskActionDelegate RecordTaskAction { get; set; }
Property Value
|
Improve this Doc
View Source
Restore
Gets command that restores this task.
Declaration
public RelayCommand Restore { get; }
Property Value
|
Improve this Doc
View Source
Roles
Declaration
public string Roles { get; set; }
Property Value
Type |
Description |
System.String |
|
Methods
|
Improve this Doc
View Source
AbortTask(Object)
Declaration
void AbortTask(object obj)
Parameters
Type |
Name |
Description |
System.Object |
obj |
|
|
Improve this Doc
View Source
CanAbortTask()
Declaration
Returns
Type |
Description |
System.Boolean |
|
|
Improve this Doc
View Source
CanExecute(Object)
Queries whether the command can be executed.
Declaration
public bool CanExecute(object parameter)
Parameters
Type |
Name |
Description |
System.Object |
parameter |
|
Returns
Type |
Description |
System.Boolean |
Boolean result of the query.
|
|
Improve this Doc
View Source
CanRestoreTask()
Declaration
Returns
Type |
Description |
System.Boolean |
|
|
Improve this Doc
View Source
CopyPlainToShadow(PlainTcoTask)
Declaration
public void CopyPlainToShadow(PlainTcoTask source)
Parameters
|
Improve this Doc
View Source
CreatePlainerType()
Declaration
public PlainTcoTask CreatePlainerType()
Returns
|
Improve this Doc
View Source
CreatePlainerType(PlainTcoTask)
Declaration
protected PlainTcoTask CreatePlainerType(PlainTcoTask cloned)
Parameters
Returns
|
Improve this Doc
View Source
Execute(Object)
Declaration
public void Execute(object parameter = null)
Parameters
Type |
Name |
Description |
System.Object |
parameter |
|
|
Improve this Doc
View Source
FlushOnlineToPlain(PlainTcoTask)
Declaration
public void FlushOnlineToPlain(PlainTcoTask source)
Parameters
|
Improve this Doc
View Source
FlushOnlineToShadow()
Declaration
public void FlushOnlineToShadow()
|
Improve this Doc
View Source
FlushPlainToOnline(PlainTcoTask)
Declaration
public void FlushPlainToOnline(PlainTcoTask source)
Parameters
|
Improve this Doc
View Source
FlushShadowToOnline()
Declaration
public void FlushShadowToOnline()
|
Improve this Doc
View Source
InitCommands()
Declaration
|
Improve this Doc
View Source
LazyOnlineToShadow()
Declaration
public void LazyOnlineToShadow()
|
Improve this Doc
View Source
LazyShadowToOnline()
Declaration
public void LazyShadowToOnline()
|
Improve this Doc
View Source
PexConstructor(IVortexObject, String, String)
Declaration
void PexConstructor(IVortexObject parent, string readableTail, string symbolTail)
Parameters
Type |
Name |
Description |
Vortex.Connector.IVortexObject |
parent |
|
System.String |
readableTail |
|
System.String |
symbolTail |
|
|
Improve this Doc
View Source
PexConstructorParameterless()
Declaration
void PexConstructorParameterless()
|
Improve this Doc
View Source
PexPreConstructor(IVortexObject, String, String)
Declaration
void PexPreConstructor(IVortexObject parent, string readableTail, string symbolTail)
Parameters
Type |
Name |
Description |
Vortex.Connector.IVortexObject |
parent |
|
System.String |
readableTail |
|
System.String |
symbolTail |
|
|
Improve this Doc
View Source
PexPreConstructorParameterless()
Declaration
void PexPreConstructorParameterless()
|
Improve this Doc
View Source
RestoreTask(Object)
Declaration
void RestoreTask(object obj)
Parameters
Type |
Name |
Description |
System.Object |
obj |
|
|
Improve this Doc
View Source
TcoTask_CanExecuteChanged(Object, EventArgs)
Declaration
void TcoTask_CanExecuteChanged(object sender, EventArgs e)
Parameters
Type |
Name |
Description |
System.Object |
sender |
|
System.EventArgs |
e |
|
|
Improve this Doc
View Source
ValidateCanExecute(IValueTag, ValueChangedEventArgs)
Declaration
void ValidateCanExecute(IValueTag sender, ValueChangedEventArgs args)
Parameters
Type |
Name |
Description |
Vortex.Connector.IValueTag |
sender |
|
Vortex.Connector.ValueTypes.ValueChangedEventArgs |
args |
|
|
Improve this Doc
View Source
ValidateCanExecuteAbortRestore(IValueTag, ValueChangedEventArgs)
Declaration
public void ValidateCanExecuteAbortRestore(IValueTag sender, ValueChangedEventArgs args)
Parameters
Type |
Name |
Description |
Vortex.Connector.IValueTag |
sender |
|
Vortex.Connector.ValueTypes.ValueChangedEventArgs |
args |
|
Events
|
Improve this Doc
View Source
CanExecuteChanged
Declaration
public event EventHandler CanExecuteChanged
Event Type
Type |
Description |
System.EventHandler |
|
Explicit Interface Implementations
|
Improve this Doc
View Source
IShadowTcoTask._abortRequest
Declaration
IShadowBool IShadowTcoTask._abortRequest { get; }
Returns
Type |
Description |
Vortex.Connector.ValueTypes.Shadows.IShadowBool |
|
|
Improve this Doc
View Source
IShadowTcoTask._elapsedTime
Declaration
[ReadOnly]
IShadowTime IShadowTcoTask._elapsedTime { get; }
Returns
Type |
Description |
Vortex.Connector.ValueTypes.Shadows.IShadowTime |
|
|
Improve this Doc
View Source
IShadowTcoTask._enabled
Declaration
[ReadOnly]
IShadowBool IShadowTcoTask._enabled { get; }
Returns
Type |
Description |
Vortex.Connector.ValueTypes.Shadows.IShadowBool |
|
|
Improve this Doc
View Source
IShadowTcoTask._invokeRequest
Declaration
IShadowBool IShadowTcoTask._invokeRequest { get; }
Returns
Type |
Description |
Vortex.Connector.ValueTypes.Shadows.IShadowBool |
|
|
Improve this Doc
View Source
IShadowTcoTask._isServiceable
Declaration
[ReadOnly]
[RenderIgnore]
IShadowBool IShadowTcoTask._isServiceable { get; }
Returns
Type |
Description |
Vortex.Connector.ValueTypes.Shadows.IShadowBool |
|
|
Improve this Doc
View Source
IShadowTcoTask._restoreRequest
Declaration
IShadowBool IShadowTcoTask._restoreRequest { get; }
Returns
Type |
Description |
Vortex.Connector.ValueTypes.Shadows.IShadowBool |
|
|
Improve this Doc
View Source
IShadowTcoTask._taskState
Declaration
[ReadOnly]
[EnumeratorDiscriminator(typeof(eTaskState))]
IShadowInt IShadowTcoTask._taskState { get; }
Returns
Type |
Description |
Vortex.Connector.ValueTypes.Shadows.IShadowInt |
|
|
Improve this Doc
View Source
ITcoTask._abortRequest
Declaration
IOnlineBool ITcoTask._abortRequest { get; }
Returns
Type |
Description |
Vortex.Connector.ValueTypes.Online.IOnlineBool |
|
|
Improve this Doc
View Source
ITcoTask._elapsedTime
Declaration
[ReadOnly]
IOnlineTime ITcoTask._elapsedTime { get; }
Returns
Type |
Description |
Vortex.Connector.ValueTypes.Online.IOnlineTime |
|
|
Improve this Doc
View Source
ITcoTask._enabled
Declaration
[ReadOnly]
IOnlineBool ITcoTask._enabled { get; }
Returns
Type |
Description |
Vortex.Connector.ValueTypes.Online.IOnlineBool |
|
|
Improve this Doc
View Source
ITcoTask._invokeRequest
Declaration
IOnlineBool ITcoTask._invokeRequest { get; }
Returns
Type |
Description |
Vortex.Connector.ValueTypes.Online.IOnlineBool |
|
|
Improve this Doc
View Source
ITcoTask._isServiceable
Declaration
[ReadOnly]
[RenderIgnore]
IOnlineBool ITcoTask._isServiceable { get; }
Returns
Type |
Description |
Vortex.Connector.ValueTypes.Online.IOnlineBool |
|
|
Improve this Doc
View Source
ITcoTask._restoreRequest
Declaration
IOnlineBool ITcoTask._restoreRequest { get; }
Returns
Type |
Description |
Vortex.Connector.ValueTypes.Online.IOnlineBool |
|
|
Improve this Doc
View Source
ITcoTask._taskState
Declaration
[ReadOnly]
[EnumeratorDiscriminator(typeof(eTaskState))]
IOnlineInt ITcoTask._taskState { get; }
Returns
Type |
Description |
Vortex.Connector.ValueTypes.Online.IOnlineInt |
|
Implements
Vortex.Connector.Identity.IVortexIdentity
System.Windows.Input.ICommand
Vortex.Connector.IVortexObject
Vortex.Connector.ITwinObject
Vortex.Connector.IVortexElement
Vortex.Connector.IVortexOnlineObject
Vortex.Connector.IVortexShadowObject
See Also