Maximum Number of Opcodes Executed
The ClearSCADA logic engine has a default limit built in, that indicates when a logic program is taking too long to execute. It is a simple protection mechanism, if the number of operations exceed the default value the logic is terminated and the "Maximum Number of Opcodes Executed" error is generated.
This is primarily an issue for structured text programs however, all logic programs have this setting and could possibly hit this limit and generate this error.
The default limit is large enough so that a normal logic program should not reach it, however the introduction of loops (FOR and WHILE and the usage of %S) means that this limit can be easily reached.
The following program will always generate this error...
PROGRAM CountTest
WHILE (1) DO
;
END_WHILE;
END_PROGRAM
...because the program will never end. It will reach the maximum number of operations and terminate.
Possible causes of this error
- Large FOR loops within large FOR loops (such as AGA8 calculations performed in logic).
- WHILE loops, where it is possible to not reach the loop's false condition.
- Looping through an SQL resultset and forgetting to use .Next() (or any of the other navigation methods) for all possible paths.
- Dynamic programs, for example, a program where the inputs are variable and potentially all get handled, such as rows of a datagrid that grows over time.