...
Here, the current value of the input is stored in the variable "last input" which is used in the next command execution to perform the edge detection. The implementation is shown in the following figure.
"Is edge detected?"
This condition verifies whether an edge has been detected in the previous "CMD BLOCK". Using an "EQUAL" block, the current value of the variable "edge" (retrieved by the "VARIABLE VALUE" block in combination with a "VARIABLE NAME" block) is compared to the constant "TRUE" (provided by a "BOOL" block). The implementation of the "Is edge detected" condition is shown in the following figure.
"Set counter"
This block resets the counter to the value that is specified by the "Delay" parameter. The implementation of the "Set counter" block is shown in the following figure.
"Is output false?"
After having reset the counter, the output shall be set to true if it is not already true. To achieve this, the output has to verified. Figure \ref{fig:delayed_off_is_output_false} shows the implementation of the required condition.
"Write true to output"
The following figure shows how the output is set to true. Note that a "WRITE OUTPUT ITEM" block also forwards the value to the bus if a physical data point is behind the server item.
...
If the current counter value is zero, the delay interval is elapsed and the output shall be reset to false again. However, to avoid that multiple "false" telegrams are sent to the bus, the output shall only be set to false if the output is currently true. The implementation of the required test is shown in the following figure.
"Write false to output'
The following figure shows how the output is set to false. To forward the value also to the bus if the output is a physical data point, a "WRITE OUTPUT ITEM" is used. If the value shall only be set internally and not forwarded to the bus, a "SET OUTPUT VALUE" block has to be used instead.
\subsubsection{
"Decrement counter'
...
\nxatext
...
If the current counter value is not zero, the delay interval has not been elapsed and thus the counter value has to be decremented by one. Figure \ref{fig:delayed_off_decrement_counter} The following figure shows the implementation of this functionality. Decrementing the value is done using a "SUB" block. The incoming "Input 1" connector is connected to outgoing "VALUE" connector of the "VARIABLE VALUE" block that provides the current counter value. The "Input 2" connector is connected to the "NUMBER" block that provides the constant value 1. The result of the subtraction is stored in the "counter" variable again using a "SET VARIABLE" block.
}
{
Wenn der momentane Zählerwert nicht 0 ist, ist die Verzögerungszeit noch nicht abgelaufen und der Zählerwert muss um 1 dekrementiert werden. Abbildung \ref{fig:delayed_off_decrement_counter} stellt die Implementierung dieser Funktionalität dar. Das Dekrementieren des Wertes wird mithilfe eines "SUB" Blocks bewerkstelligt. Der eingehende Konnektor "Input 1" wird dabei mit dem ausgehenden Konnektor "VALUE" des "VARIABLE VALUE" Blocks, der den momentanen Zählerwert liefert verbunden. Der eingehende Konnektor "Input2" wird mit dem "NUMBER" Block, der den konstanten Wert 1 liefert, verknüpft. Das Resultat der Subtraktion wird schließlich mittels "SET VARIABLE" Block in der Variable "counter" gespeichert.
}
\nxagraphic
{examples/fig/delayed_off_decrement_counter.png}
{examples/fig/delayed_off_decrement_counter.png}
{"Decrement counter"}
{"Decrement counter"}
{delayed_off_decrement_counter}
{250pt}
{0.5pt}
Saving the command and using the command within the NETx BMS Server
To provide the command to the NETx BMS Server, it has to be compiled. This can be done by clicking the "Save" icon within the toolbar which saves and compiles the current command. In addition, it is possible to change several options of a command. To open the "Options" dialog, the entry "Options ..." within the menu "File" has to be selected (cf. figure \ref{fig:delayed_off_compile}). Within this dialog, basic information about the command can be specified. The flag "Add to Catalog" defines whether the command shall be visible within the catalog of the XLogic Editor. If activated, the command can be reused in other commands. If the option "Auto-Compile" is set, the command is automatically compiled whenever the project is saved.
\nxagraphic
{examples/fig/delayed_off_compile.png}
{examples/fig/delayed_off_compile.png}
{Compiling the command}
{Kompilieren des Kommandos}
{delayed_off_compile}
{150pt}
{0.5pt}
After having compiled the command successfully, close the \productname\ XLogic editor and go back to the \productbmsstudioNETx BMS Studio. Afterwards, the new command has to be loaded before it can be used. This can be done by restarting the \productbmsserver\ NETx BMS Server or by loading the command manually by selecting the entry "Load logic module" within the "Tools" menu of the \productbmsstudio (cf. section \ref{sec:execute_command})NETx BMS Studio. Then, open the "XCommand event definitions" via the menu "Extensions". Add a new definition and enter a name for the command within the first column. The next column can be left empty since all variables shall only be used locally. Within the third column, select "ON\_TIMER\_AND\_INPUT". This indicates that the command shall be invoked whenever one of the inputs changes and/or after a predefined timer interval has elapsed. To specify the timer interval, enter "1" in the "Options" column. This indicated that the command shall be executed every second in addition to a change of value of an input. Then, press the "..." button within the "XCommand" column. A dialog appears where the command can be selected and configured. Select the "Delayed Off" command from the drop down list. Afterwards, specify the different inputs, outputs, and parameters. A possible configuration is shown in figure \ref{fig:delayed_off_bms}.
\nxagraphic
{examples/fig/lock_bms.png}
{examples/fig/lock_bms.png}
{Defining the command within the \productbmsstudio}
{Definieren des Kommandos im \productbmsstudio}
{delayed_off_bms}
{200pt}
{0.5pt}
the following figure.
After having saved the "XCommand event definition", restart the NETx BMS Server and test the command.
...