A trigger condition is necessary when values should only be shown if a certain condition is true. For the callpath this means that the call stack has to be equal to the passed in callpath.
This example uses the files in the folder 'callpathExample'.
'callpathExample.st' defines two programs: UpCounter which uses the global variable counterInt and SomeCounter which uses the global variable secondCounterInt. Both programs are running cyclically every 200 ms and are calling the UpCounter_Func. But each program calls the UpCounter_Func with its own values. For this example they can be destinguished by their values: counterInt default value is 10000, secondCounterInt default value is -10000.
The following line adds a logpoint at line 12 in the file 'upcounter.st':
watch add .src/callpathExample/upcounter.st:12 up_temp
Since this function is called from two different locations with different values it can not be foreseen which values will be shown. The output will look similar to this:
>Scope: .src/callpathExample/upcounter.st -> Line:1 -> UpCounter_Func - Installed successful
Callpath: Not set
Logpoints:
Line:12 Id:4 - Installed
Scope: .src/callpathExample/upcounter.st -> Line:1 -> UpCounter_Func
Logpoints:
Line:12 Id:4 Age:0
up_temp -> 10060
Scope: .src/callpathExample/upcounter.st -> Line:1 -> UpCounter_Func
Logpoints:
Line:12 Id:4 Age:0
up_temp -> -9940
As it can seen, the values are flickering and it is not really clear where these values are coming from.
The following line will add a trigger condition to the installed logpoint, so that value updates are only shown if the program SomeCounter calls the UpCounter_Func:
watch set --location src/callpathExample/upcounter.st:12 --callpath src/callpathExample/callpathExample.st:26
The result will look similar to this - just one up counting value:
Scope: .src/callpathExample/upcounter.st -> Line:1 -> UpCounter_Func - Installed successful
Callpath: src/callpathExample/callpathExample.st:26
Logpoints:
Line:12 Id:4 - Installed
Scope: .src/callpathExample/upcounter.st -> Line:1 -> UpCounter_Func
Logpoints:
Line:12 Id:4 Age:0
up_temp -> -9716
Scope: .src/callpathExample/upcounter.st -> Line:1 -> UpCounter_Func
Logpoints:
Line:12 Id:4 Age:0
up_temp -> -9715
The Callpath is connected to the scope and will effect all logpoints that are under this scope. If logpoints would be added to line 11 and 13, they would also just send updated values when the UpCounter_Func is called from the file src/callpathExample/callpathExample.st in line 26.
The scope is the equvilant to a program organization unit (Program, Method, Function, Function block) - in this case it is the function UpCounter_Func which starts in line 1 of the file .src/callpathExample/upcounter.st.
When the last logpoint in a scope is removed, it will also remove the associated callpath.
The following line removes the logpoint and the callpath trigger condition - since it is the only logpoint in this scope:
watch remove 4
The result of the remvoal look like this:
Scope: .src/callpathExample/upcounter.st -> Line:1 -> UpCounter_Func - Uninstalled successful
Callpath: src/callpathExample/callpathExample.st:26
Logpoints:
Line:12 Id:4 - Removed