DigitalArray
- Namespace
- ZEquipment
- Implements
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.
FUNCTION_BLOCK DigitalArray IMPLEMENTS ZEquipment.IDigital, ZCore.ITrigger
Constructor
FB_init
METHOD FB_init (
bInitRetains : BOOL,
bInCopyCode : BOOL) : 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)
Returns
- BOOL
Properties
Enabled
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 Enabled : BOOL
Property Value
- BOOL
OperationType
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 OperationType : DigitalOperationType
Property Value
Simulation
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 Simulation : BOOL
Property Value
- BOOL
Methods
AddDigital
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
METHOD AddDigital (
io : IDigital)
Inputs
io
IDigitalobject which implements the IDigital interface, usually a DigitalInput or DigitalOutput instance
Clear
removes all inputs and outputs from this DigitalArray that have been added to it previously by using AddDigital.
METHOD Clear ()
Enable
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.
METHOD Enable (
on : BOOL)
Inputs
FallingTrigger
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
<div class="codewrapper">
<pre><code class="lang-st hljs">METHOD FallingTrigger () : BOOL
</code></pre></div>
<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>
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).
<div class="codewrapper">
<pre><code class="lang-st hljs">METHOD HasTriggered () : BOOL
</code></pre></div>
<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>
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).
<div class="codewrapper">
<pre><code class="lang-st hljs">METHOD Invert ()
</code></pre></div>
<h3 id="ZEquipment.DigitalArray_Name" data-uid="ZEquipment.DigitalArray.Name">
Name
</h3><a name="Name"></a>
This method return the name that has been set with [SetName](xref:ZEquipment.DigitalArray#SetName)
<div class="codewrapper">
<pre><code class="lang-st hljs">METHOD FINAL Name () : ZCore.ZString
</code></pre></div>
<h4 class="section">Returns</h4>
<dl class="parameters">
<dt> <a class="xref" href="../../ZCore/BaseTypes/ZString.md">ZString</a></dt>
<dd></dd>
</dl>
<h3 id="ZEquipment.DigitalArray_RisingTrigger" data-uid="ZEquipment.DigitalArray.RisingTrigger">
RisingTrigger
</h3><a name="RisingTrigger"></a>
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
METHOD RisingTrigger () : BOOL
Returns
- BOOL
SetLogger
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).
METHOD SetLogger (
logger : ZCore.ILogger)
Inputs
logger
ILoggerObject which implements the ILogger interface, usually one of the Zeugwerk Logger instances of ZAux library
SetLogic
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, ...).
METHOD SetLogic (
logic : DigitalLogic)
Inputs
logic
DigitalLogic
SetName
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.
METHOD SetName (
name : ZCore.ZString)
Inputs
name
ZString
SetOperationType
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 |
METHOD SetOperationType (
operationType : DigitalOperationType)
Inputs
operationType
DigitalOperationTypeDigitalOperationType.LogicalAnd means all inputs are connected by boolean AND
SetSimulation
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.
METHOD SetSimulation (
on : BOOL)
Inputs
SetTriggerLogic
This method controls the logic of the HasTriggered method. By default, the trigger logic is set to Normal.
METHOD SetTriggerLogic (
logic : DigitalLogic)
Inputs
logic
DigitalLogiclogic of the input or output, available types are normal and inverted