AxisListenerSequence
- Namespace
- ZEquipment
- Extends
- Inherited Properties
- Inherited Methods
- Implements
FUNCTION_BLOCK ABSTRACT AxisListenerSequence EXTENDS ZAux.Sequence IMPLEMENTS ZCore.ISequence, ZCore.IHaltable, ZCore.ICancellationToken, ZCore.IHaltToken, ZCore.IStartToken, ZCore.IError, ZCore.IObject, ZCore.IRecoverable (
[input] Axis : IAxisBase,
[input] ListenerState : ZAux.StateMachineListenerState,
[input] ListenerType : AxisListenerType,
[output] State : ObjectState,
[output] Diagnostics : DiagnosticMessage)
This function block is the base class for any listener for axis actions.
The function block is linked to an axis via an interface, which is passed during construction of the listener.
The axis calls all listeners, linked to it, before and after any action and also in case of error.
The ListenerState variable give the context to when (before, after, during, ...) the sequence is called, ListenerType variables gives the context why
(for which action) the sequence is being called. The Axis
variable points to the axis, which invoked the listener.
- A listener sequence can be used to perform an arbitrary action and/or abort the movement of the actuator. To implement an action you can use
Steps or any other objects to control the sequential flow. After the action is performed
SetBusy(FALSE)has to be called such that the axis can proceed with its sequence. The only exception here is the the action statePreError. If an axis has an error the listener sequences are only called once and then stopped immediatelly to continue with the actual fault reaction of the axis. - Sometime it is necessary to prevent an axis from a movement due to various cirumstances (e.g. it would collide with something). For this use case simply call the Abort method (or any of its derivatives), of the sequence to prevent the movement.
To implement a listener, simply extend from this object and implement the body of your function block, as the following example shows.
FUNCTION_BLOCK DummyAxisListenerSequence EXTENDS ZEquipment.AxisListenerSequence
VAR
_timer : ZAux.Timer;
END_VAR
IF OnStart(0)
THEN
_logger.AtInfo().Append('Enter AxisListener (')
.AppendParamString('ListenerType:', ListenerTypeDecoded(THIS^.ListenerType))
.Append('; ')
.AppendParamString('ListenerState:', ListenerStateDecoded(THIS^.ListenerState))
.LogMessage(')');
_timer.WaitAsync(5);
END_IF
CASE THIS^.ListenerType
OF
ZEquipment.AxisListenerType.Enable:
CASE THIS^.ListenerState
OF
ZAux.StateMachineListenerState.PreActive:
IF _timer.Done
THEN
_logger.Info('Waited 5s');
SetBusy(FALSE);
END_IF
ZAux.StateMachineListenerState.PostActive:
IF _timer.Done
THEN
_logger.Info('Waited 5s');
SetBusy(FALSE);
END_IF
ELSE
SetBusy(FALSE);
END_CASE
ELSE
SetBusy(FALSE);
END_CASE
IF NOT Busy
THEN
_logger.AtInfo().Append('Exit AxisListener (')
.AppendParamString('ListenerType:', ListenerTypeDecoded(THIS^.ListenerType))
.Append('; ')
.AppendParamString('ListenerState:', ListenerStateDecoded(THIS^.ListenerState))
.LogMessage(')');
END_IF
Warning
Make sure the listener sequences eventually calls SetBusy(FALSE), otherwise axis actions may be blocked forever. The only
exception here is for ListenerState=PreError, because the statemachine will only call the listener sequence once (for safety)
The minimum implementation of the sequences's body therefore is SetBusy(FALSE);!
Inputs
AxisIAxisBaseAxis calling the sequence
ListenerStateStateMachineListenerStateReason when the axis is calling the sequence
ListenerTypeAxisListenerTypeReason why the axis is calling the sequence
Constructor
FB_init
METHOD FB_init (
[input] bInitRetains : BOOL,
[input] bInCopyCode : BOOL,
[input] axis : REFERENCE TO Axis) : BOOL
Inputs
bInitRetainsBOOLif TRUE, the retain variables are initialized (warm start / cold start)
bInCopyCodeBOOLif TRUE, the instance afterwards gets moved into the copy code (online change)
axisREFERENCE TO Axis
Returns
- BOOL
Methods
ListenerStateDecoded
METHOD ListenerStateDecoded (
[input] listenerState : ZAux.StateMachineListenerState) : STRING
Inputs
listenerStateStateMachineListenerState
Returns
- STRING
ListenerTypeDecoded
METHOD ListenerTypeDecoded (
[input] listenerType : AxisListenerType) : STRING
Inputs
listenerTypeAxisListenerType
Returns
- STRING