ManagedObject
- Namespace
- ZCore
- Extends
- Inherited Properties
- Inherited Methods
- Implements
Its main purpose is the FB_init block that is used to notify a potential parent about a new child object. For identification purposes also a name may be provided to such an object.
This mechanism is used throughout the framework to simplify the generation of an object hierachie in order to automate calling the Cyclic method for objects in the framework. All 'bigger' objects should extend ManagedObject and may implement IManagedObject to make the name of an object available to users.
See Objects types for details
FUNCTION_BLOCK ABSTRACT ManagedObject EXTENDS ZCore.Object IMPLEMENTS ZCore.IManagedObject, ZCore.IObject, ZCore.IBootable, ZCore.IError
Constructor
FB_init
The constructor of ManagedObject takes a parent as parameter, which is then notified about the creation of this instance.
METHOD FB_init (
bInitRetains : BOOL,
bInCopyCode : BOOL,
parent : IManagedObject) : BOOL
Inputs
bInitRetains
BOOLif TRUE, the retain variables are initialized (warm start / cold start)
bInCopyCode
BOOLif TRUE, the instance afterwards gets moved into the copy code (online change)
parent
IManagedObjectObject that is informed about this object by calling its NotifyChild method
Returns
- BOOL
Properties
BootingHints
Suggests when the Cyclic method should be called during the booting phase of the application
The default booting hint is WhenNotBooted, which means the cyclic should only be called if the object is itself in the booting phase
PROPERTY BootingHints : ManagedObjectBootingHintFlags
Property Value
ExecutionHints
Suggests when the Cyclic method should be called after the booting phase of the application
The default execution hint is EveryCycle.
PROPERTY ExecutionHints : ManagedObjectExecutionHintFlags
Property Value
Methods
Cyclic
METHOD Cyclic ()
Name
Returns the name of the object as it has been set by calling the SetName. Usually this name is used for logging in particular extensions of ManagedObject.
METHOD Name () : ZString
Returns
NotifyChild
This method is internally used to inform an object of a new child. This method should only be called internally by the framework in the FB_init constructor. By default this object's method simply forwards the call to the parent (if it exists)
METHOD NotifyChild (
child : IManagedObject)
Inputs
child
IManagedObject
Reject
With this method, calls to an Async method can be rejected. This may be done for several reasons, including, but not limited to, invalid parameters or any other reason without aborting the object itself (maybe because its already running). The method should only be used internally in Async mehhods of an object.
The behavior of Reject is as follows.
- It always aborts startToken (if available)
- It aborts the object itself if
- no
startToken
was given by passing 0 as parameter - the object is
NOT Busy
when calling the method.
- no
Note that this implies that an active object is not aborted - even if a consecutive call to Async is invalid.
Example 1: An axis is already moving and another consecutive call to a different position has been made but a wrong speed has been given in that call
METHOD MoveAbsoluteAsync
VAR_INPUT
startToken : ZCore.IStartToken
position : LREAL;
speed : LREAL;
END_VAR
------------------------------------------
IF IsNullLreal(speed, 1E-5)
THEN
Reject(startToken, 'Action can not be started, invalid speed parameter given!');
RETURN;
END_IF
...
Example 2: An axis should be enabled but has no power
```st
METHOD EnableDriveAsync
VAR_INPUT
startToken : ZCore.IStartToken;
on : BOOL;
END_VAR
------------------------------------------
IF NOT Busy
THEN
SetBusy(TRUE);
IF NOT _drive.IsDrivePowered() AND_THEN on
THEN
Reject(startToken, 'Failed to start EnableDriveAsync command, no power available');
RETURN;
END_IF
...
METHOD PROTECTED Reject (
startToken : IStartToken,
reason : ZString)
Inputs
startToken
IStartTokenStarttoken which has to be aborted
reason
ZStringAbort message, simply the reason why a call to an Async method is rejected
SetName
Sets a human-readable name for this object. Usually this name is used for logging in particular extensions of ManagedObject.
METHOD SetName (
name : ZString)
Inputs
name
ZString
TraceErrorStack
This method is used internally when recording an error trace.
METHOD TraceErrorStack (
trace : IErrorTrace)
Inputs
trace
IErrorTrace