Execute an event a set number of times

<< Click to Display Table of Contents >>

Manual > Server Creation Guide > Events > Application of Events >

Execute an event a set number of times

overview

This section explains how to set up an event to occur a certain number of times.

 

For example, disable an event after it has occurred 10 times.

 

When "U01.F01.T01" turns ON, "E02" is enabled and "E02" is disabled after the "A02" action is executed 10 times.

 

c_event_0069

 

 

Download the sample

The creation examples shown on this page are provided with samples.

 

The sample can be downloaded from below.

 

Configuration file: event_sample04.txt

 

 

Setting contents

 

Tag configuration

 

Set the bit tag "U01.F01.T01" that will be the trigger to enable the event.

Also, set a numeric tag for the counter: "U01.F01.T02".

 

c_event_0070

 

 


 

Action Settings

 

Add a script action "A01" and set the script as follows:
c_event_0071

 

U01.F01.T02 = 10

//Event/E02!Enable = 1

 

The value set in U01.F01.T02 here will be the number of times it will be executed.
 

 

 


 

Event Settings

 

Add Tag event "E01" and Periodic event "E02".

c_event_0072
 

E01:

Tag "U01.F01.T01"

Comparison condition "Tag value = Comparison value"

Comparison value "TRUE"

Execution action "A01"

 

E02:

Set the period to 1 second

Check "Disable" to disable the initial state.

 

 

Commentary

 

c_event_0073

 

When you run this sample, the following will happen:

 

When bit is ON

1.When U01.F01.T01 becomes TRUE, Tag event "E01" occurs and script Ver1 action "A01" is executed.

2.In "A01", the formula "U01.F01.T02 = 10" is executed and 10 is set.

3.At the same time, the formula "//Event/E02!Enable = 1" is executed, enabling the event "E02."

 

Periodic event "E02" is active

1."E02" executes target action "A02" every second

2.After the process is complete, the formula "U01.F01.T02 = U01.F01.T02 – 1" is executed, and the tag value is decremented by 1 each time.

3.At the same time, the formula "//Event/E02!Enable = U01.F01.T02 > 0" is executed. When "U01.F01.T02" is greater than 0, there is no particular change. When "U01.F01.T02" is 0, "E02" is disabled.