DigitalArray
- Namespace
- ZEquipment
- Implements
FUNCTION_BLOCK DigitalArray IMPLEMENTS ZEquipment.IDigital, ZCore.ITrigger
This function blocks allows to group several IDigital into one single object. Use AddDigital to add 1 or up to MaxIoDigitalArrayIos inputs or outputs. If any method of the DigitalArray is called, internally all method of the I/Os added to this instance get called.
Constructor
FB_init
METHOD FB_init (
[input] bInitRetains : BOOL,
[input] bInCopyCode : BOOL) : 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)
Returns
- BOOL
Properties
Enabled
PROPERTY Enabled : BOOL
This property returns the current state of all digital interfaces which are added to this DigitalArray by AddDigital. It respects the logic configuration of each input/output and also the operation setting which can be parametrized by SetOperationType.
Note
The setter method of the property is not implemented.
Property Value
- BOOL
Logic
PROPERTY Logic : DigitalLogic
This property can be used to return the parametrized logic of the DigitalInput or Output and it can also be set directly
Property Value
OperationType
PROPERTY OperationType : DigitalOperationType
Returns the actual set boolean operation between all digital input or output function blocks which are added to this DigitalArray by AddDigital. Possible values are LogicalOr, LogicalAnd, LogicalXor and LogicalNot.
For more information on how these operation types work see the documentation at SetOperationType.
Property Value
Simulation
PROPERTY Simulation : BOOL
By default all digital interfaces that extend from this function block are simulated, to disable simulation mode this can be done by changing this property. Usually, the decision if simulation is used, takes places during initialization phase. However, some applications require to switch between these modes on-the-fly. In the latter case simply call this method at any time.
Property Value
- BOOL
Methods
AddDigital
METHOD AddDigital (
[input] io : IDigital)
This method adds an digital output to the input-output-Array. When using any method of the DigitalArray it internally calls this method for all IDigital that have been added to it by using AddDigital.
Note
Simulated inputs and outputs may still behave differently than physical ones. I.e. write access to an IO is blocked to DigitalInput if it is a phyical input or output.
Warning
The actual number that CAN BE added to a DigitalArray is set by MaxDigitalArrayIos. If this number is exceeded, DigitalArray will not throw an error, because it is not an Object
Inputs
ioIDigitalobject which implements the IDigital interface, usually a DigitalInput or DigitalOutput instance
Clear
METHOD Clear ()
removes all inputs and outputs from this DigitalArray that have been added to it previously by using AddDigital.
Enable
METHOD Enable (
[input] on : BOOL)
Enables all registered inputs and outputs as described in the documentation of the specialized function blocks For more details on this method please refer to Enable.
Inputs
FallingTrigger
METHOD FallingTrigger () : BOOL
Consecutive calls to this method returns TRUE once, whenever the state of the digital interface switched from IsEnabled to NOT IsEnabled.
It is the same as using a FallingTrigger instance or using an F_TRIG instance on Enabled.
IF digitalInput.FallingTrigger()
THEN
// ...
END_IF
<h4 class="section">Returns</h4>
<dl class="parameters">
<dt>BOOL</dt>
<dd></dd>
</dl>
<h3 id="ZEquipment_DigitalArray_HasTriggered" data-uid="ZEquipment.DigitalArray.HasTriggered">
HasTriggered
</h3><a name="HasTriggered"></a>
<div class="codewrapper">
<pre><code class="lang-st hljs">METHOD HasTriggered () : BOOL
</code></pre></div>
Depending on the logic set with [SetTriggerLogic](xref:ZEquipment.DigitalArray#SetTriggerLogic) this method
internally calls [RisingTrigger](xref:ZEquipment.DigitalArray#RisingTrigger) or [FallingTrigger](xref:ZEquipment.DigitalArray#FallingTrigger) and
returns its output.
By default this method is the same as calling [FallingTrigger](xref:ZEquipment.DigitalArray#FallingTrigger).
<h4 class="section">Returns</h4>
<dl class="parameters">
<dt>BOOL</dt>
<dd></dd>
</dl>
<h3 id="ZEquipment_DigitalArray_Invert" data-uid="ZEquipment.DigitalArray.Invert">
Invert
</h3><a name="Invert"></a>
<div class="codewrapper">
<pre><code class="lang-st hljs">METHOD Invert ()
</code></pre></div>
This method inverts the states of all registered inputs and outputs
For more details on this method please refer to [Invert](xref:ZEquipment.Digital#Invert).
<h3 id="ZEquipment_DigitalArray_Name" data-uid="ZEquipment.DigitalArray.Name">
Name
</h3><a name="Name"></a>
<div class="codewrapper">
<pre><code class="lang-st hljs">METHOD FINAL Name () : ZCore.ZString
</code></pre></div>
This method return the name that has been set with [SetName](xref:ZEquipment.DigitalArray#SetName)
<h4 class="section">Returns</h4>
<dl class="parameters">
<dt><a class="xref" href="../ZCore/ZString.md">ZString</a></dt>
<dd></dd>
</dl>
<h3 id="ZEquipment_DigitalArray_RisingTrigger" data-uid="ZEquipment.DigitalArray.RisingTrigger">
RisingTrigger
</h3><a name="RisingTrigger"></a>
<div class="codewrapper">
<pre><code class="lang-st hljs">METHOD RisingTrigger () : BOOL
</code></pre></div>
Consecutive calls to this method returns `TRUE` once, whenever the state of the digital interface switched from `IsEnabled` to `NOT IsEnabled`.
It is the same as using a [RisingTrigger](xref:ZCore.RisingTrigger) instance or using an `F_TRIG` instance on [Enabled](xref:ZEquipment.DigitalArray#Enabled).
``` st
IF digitalInput.RisingTrigger()
THEN
// ...
END_IF
Returns
- BOOL
SetLogger
METHOD SetLogger (
[input] logger : ZCore.ILogger)
Use this method together with SetName to enable logging for this digital interface. Various methods of this implementation write log messages into the passed logger interface.
Note
Sometimes it is beneficial to disable logging by passing 0 to this method (e.g. for inputs or outputs which are switch very often).
Inputs
loggerILoggerObject which implements the ILogger interface, usually one of the Zeugwerk Logger instances of ZAux library
SetLogic
METHOD SetLogic (
[input] logic : DigitalLogic)
According to the process or the used hardware some signals on the fieldbus are high or low active, but in the PLC it is benefical to have these states inverted. This method allows to switch the logic that this class is operating with. Note that almost all methods of the digital array function block make use of the logic that can be set here. (i.e. RisingTrigger, FallingTrigger, Enable, ...).
Inputs
logicDigitalLogic
SetName
METHOD SetName (
[input] name : ZCore.ZString)
Sets the name of this object as it will show up in any log messages that is created by this object. The name set with this method should be relatable to the name of the input in the electrical plan of your automation project to identify the corresponding input properly. However, please note that logging should not be used for inputs because some of them are switched very often, which leads to a high logging load.
Inputs
nameZString
SetOperationType
METHOD SetOperationType (
[input] operationType : DigitalOperationType)
This method sets the default boolean operation between all set digital inputs or outputs.
In case of inputs, as default the digital array returns Enabled=TRUE, if all inputs are Enabled. This is the LogicalAnd operation type.
This setting can be changed at every time in your application and is considered immediately after this method gets called.
| Operation | DigitalInput 1 | DigitalInput 2 | Enabled Property Return |
|---|---|---|---|
| LogicalOr | FALSE | FALSE | FALSE |
| LogicalOr | TRUE | FALSE | TRUE |
| LogicalOr | FALSE | TRUE | TRUE |
| LogicalOr | TRUE | TRUE | TRUE |
| LogicalAnd | FALSE | FALSE | FALSE |
| LogicalAnd | TRUE | FALSE | FALSE |
| LogicalAnd | FALSE | TRUE | FALSE |
| LogicalAnd | TRUE | TRUE | TRUE |
| LogicalXor | FALSE | FALSE | FALSE |
| LogicalXor | TRUE | FALSE | TRUE |
| LogicalXor | FALSE | TRUE | TRUE |
| LogicalXor | TRUE | TRUE | FALSE |
| LogicalNot | FALSE | FALSE | TRUE |
| LogicalNot | TRUE | FALSE | TRUE |
| LogicalNot | FALSE | TRUE | TRUE |
| LogicalNot | TRUE | TRUE | FALSE |
Inputs
operationTypeDigitalOperationTypeDigitalOperationType.LogicalAnd means all inputs are connected by boolean AND
SetSimulation
METHOD SetSimulation (
[input] on : BOOL)
By default all digital interfaces that extend from this function block are simulated, to disable simulation mode this can be done by this method. Usually, the decision if simulation is used, takes places during initialization phase. However, some applications require to switch between these modes on-the-fly. In the latter case simply call this method at any time.
Inputs
SetTriggerLogic
METHOD SetTriggerLogic (
[input] logic : DigitalLogic)
This method controls the logic of the HasTriggered method. By default, the trigger logic is set to Normal.
Inputs
logicDigitalLogiclogic of the input or output, available types are normal and inverted