Class 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
Inherited Members
Namespace: PlcDocu.TcoCore
Assembly: TcoCoreConnector.dll
Syntax
public abstract class TcoStateBase : TcoObject
Constructors
| Improve this Doc View SourceTcoStateBase()
Prevents creating instance of this class via public constructor
Declaration
public TcoStateBase()
Fields
| Improve this Doc View Source_State
Declaration
public object _State
Field Value
Type | Description |
---|---|
System.Object |
Properties
| Improve this Doc View SourceAutoRestorable
Returns if this instance is auto restorable. This is 'dependency property'. Value of this property is given by the parent of this object.
This value is assigned after download by calling the implicit method FB_init()
of the parent object and cannot be changed during runtime.
The AutoRestorable
property of this objects is retrieved from the EnableAutoRestore
property of the parent object.
This is done by calling the CheckIfAutoRestoreEnabledByParent()
method inside the implicit method FB_init()
after download.
If this instance is the auto restorable it will call the
1.) This instance has not been called for one or more cycles and starts to be called again. (By calling the instance means asking for its property
2.) Parent object of this instance changes its state.
See also
Declaration
[IgnoreReflection]
public dynamic AutoRestorable { get; }
Property Value
Type | Description |
---|---|
System.Object | Plc type BOOL; Twin type: Vortex.Connector.ValueTypes.OnlinerBool |
Context
Returns the context of the parent object, that this object is assigned to.
This context is given by declaration, its value is assigned after download by calling the implicit method FB_init()
and cannot be changed during runtime.
Declaration
[IgnoreReflection]
public dynamic Context { get; }
Property Value
Type | Description |
---|---|
System.Object | Plc type ITcoContext; Twin type: |
Identity
Returns the identity of the this object. This variable is used in the higher level packages.
Declaration
[IgnoreReflection]
public dynamic Identity { get; }
Property Value
Type | Description |
---|---|
System.Object | Plc type ULINT; Twin type: Vortex.Connector.ValueTypes.OnlinerULInt |
IsAutoRestoreEnabled
Returns if the auto restore mechanism is enabled for this instance. This property does not affect this instance, but it affects all members of this instance.
If the auto restore is enabled, the child member call its Restore()
method if:
1.) Its instance has not been called for one or more cycles.
2.) Its parent object (THIS^ instance) has changed its state.
This value is assigned after download by calling the implicit methodFB_init()
and cannot be changed during runtime.
See also AutoRestorable
Declaration
[IgnoreReflection]
public dynamic IsAutoRestoreEnabled { get; }
Property Value
Type | Description |
---|---|
System.Object | Plc type BOOL; Twin type: Vortex.Connector.ValueTypes.OnlinerBool |
LastStateChangeCycle
Returns number of the Plc cycle during which this instance changes its State
last time.
The child objects ask for this value to ensure auto restore mechanism working.
Declaration
[IgnoreReflection]
public dynamic LastStateChangeCycle { get; }
Property Value
Type | Description |
---|---|
System.Object | Plc type ULINT; Twin type: Vortex.Connector.ValueTypes.OnlinerULInt |
State
Return actual state of this instance. Needs to be asked for cyclically in case of this instance is auto restorable.
See also AutoRestorable
Declaration
[IgnoreReflection]
public dynamic State { get; }
Property Value
Type | Description |
---|---|
System.Object | Plc type INT; Twin type: Vortex.Connector.ValueTypes.OnlinerInt |
Methods
| Improve this Doc View SourceAutoRestore()
Private method called each time that State property is asked for. If this instance is auto restorable, this method ensures calling the
1.) Parent object of this instance changes its state in this Plc cycle.
2.) Parent object of this instance changes its state no mather when and this instance has not yet process this change.
3.) This instance has not been called for one or more cycles and starts to be called again. (By calling the instance means asking for its property
See also
See also
Declaration
[IgnoreReflection]
void AutoRestore()
ChangeStateProtected(Object)
Use to change the State property of this instance to the new value. This method is final, so it cannot be overloaded. However there is a OnStateChange(Object, Object)
method that is called on each change of the State
and could be overloaded.
Possibility to use the fluent syntax.
Example
ChangeState(newState).RestoreObject(myChildObject);
Declaration
[IgnoreReflection]
protected dynamic ChangeStateProtected(dynamic NewState)
Parameters
Type | Name | Description |
---|---|---|
System.Object | NewState | Plc type : INT [VAR_INPUT]; Twin type : Vortex.Connector.ValueTypes.OnlinerInt
|
Returns
Type | Description |
---|---|
System.Object | Plc type ITcoState; Twin type: |
CheckIfAutoRestoreEnabledByParent()
Declaration
[IgnoreReflection]
void CheckIfAutoRestoreEnabledByParent()
CheckIfCalledCyclically()
Private method called each time that the State property is asked for. If this instance is auto restorable, this method ensures calling the Restore() method if this instance has not been called for one or more cycles and starts to be called again. (By calling the instance means asking for its property State).
See also AutoRestorable
See also
Declaration
[IgnoreReflection]
void CheckIfCalledCyclically()
OnStateChange(Object, Object)
This method is called on each change of the State
. This method could be overloaded and custom code should be placed here.
Declaration
[IgnoreReflection]
protected void OnStateChange(dynamic PreviousState, dynamic NewState)
Parameters
Type | Name | Description |
---|---|---|
System.Object | PreviousState | Plc type : INT [VAR_INPUT]; Twin type : Vortex.Connector.ValueTypes.OnlinerInt
|
System.Object | NewState | Plc type : INT [VAR_INPUT]; Twin type : Vortex.Connector.ValueTypes.OnlinerInt
|
Restore()
Restores this instance to the state -1.
Possibility to use the fluent syntax.
Example
Restore().RestoreObject(myFirstChildObject).RestoreObject(mySecondChildObject);
See also
See also
Declaration
[IgnoreReflection]
public dynamic Restore()
Returns
Type | Description |
---|---|
System.Object | Plc type ITcoRestorable; Twin type: |
RestoreObject(Object)
Ensures the call of the Restore()
method in fluent-like fashion.
Possibility to use the fluent syntax.
Example
ChangeState(newState).RestoreObject(myFirstChildObject).RestoreObject(mySecondChildObject);
Declaration
[IgnoreReflection]
public dynamic RestoreObject(dynamic Obj)
Parameters
Type | Name | Description |
---|---|---|
System.Object | Obj | Plc type : ITcoRestorable [VAR_INPUT]; Twin type :
|
Returns
Type | Description |
---|---|
System.Object | Plc type ITcoObjectRestorer; Twin type: |