I wrote a Protocol that request every hour a server via API Calls to get data and display them in a Table. Meanwhile, I have a counter that counts till 60 min (1 hour). After getting the data, I set the param to 0
Protocol:
groups
200 execute session 200
320 execute Action 320
100 execute session 100
3 execute Action 3
Sessions:
200 Get / Create Token
100 Get data bank information from Server / requires token
triggers:
200 execute Action 200
201 execute Action 201
100 execute Action 100
Actions:
200 execute Group 200
201 clear token
320 execute Group 320
100 execute Group 100
3 timer increase
Qactions (only parsing the data):
100 response of the sessions 100, parsing data and display in a table
320 setting the param from the read write params for the session requests
206 use the token of the session response and save token as param
Timer:
slow timer, 3600000 execute group 320
fast timer, 60000 increment timer
Flowchart:
1. Qaction 320 Fetch the Login data from display input params check Trigger 200
2. Sessions 200 login with the data and get Token back
3. 206 serialize the JSON Response and set the token to the param. Checking trigger 100
4. Sessions 100 use the token and request the data
5. Qaction 100 parsing the response from session 100 and display on table, set the counter to 0
The problem is that every hour sometimes all triggers getting executed, sometimes trigger 100 don't be executed (see log).
Log:
Success:
2024/06/10 10:03:54.455|SLManagedScripting.exe|ManagedInterop|CRU|-1|480|The param are url ias/v3/token/actions/signOnByUserNamePassword token body is after trigger 200 checked
2024/06/10 10:03:54.857|SLManagedScripting.exe|ManagedInterop|CRU|-1|480|das ist der token der gecleart wird
2024/06/10 10:03:54.857|SLManagedScripting.exe|ManagedInterop|CRU|-1|480|tokenoperaotr 207
2024/06/10 10:03:54.858|SLManagedScripting.exe|ManagedInterop|CRU|-1|480|excuting triggers 201 clear token and trigger 100 get the layouts
2024/06/10 10:03:55.266|SLManagedScripting.exe|ManagedInterop|CRU|-1|518|check trigger 2 clear table and before iteration
2024/06/10 10:03:55.278|SLManagedScripting.exe|ManagedInterop|CRU|-1|518|only all Rail check loop
2024/06/10 10:03:55.278|SLManagedScripting.exe|ManagedInterop|CRU|-1|518|before setting the counter to 0 60
2024/06/10 10:03:55.278|SLManagedScripting.exe|ManagedInterop|CRU|-1|518|after setting the counter to 0 0
2024/06/10 10:03:55.286|SLElement.exe|15000|CParameter::SetElementState|DBG|0|** parameter alarmstate 1004/0 from 1 to 0
2024/06/10 10:03:55.287|SLElement.exe|15000|CParameter::SetElementState|DBG|0|** parameter alarmstate 1004/0 from 0 to 1
Fails:
2024/06/10 11:03:54.485|SLManagedScripting.exe|ManagedInterop|CRU|-1|458|The param are url ias/v3/token/actions/signOnByUserNamePassword token body is after trigger 200
2024/06/10 11:03:54.977|SLManagedScripting.exe|ManagedInterop|CRU|-1|447|das ist der token der gecleart wird
2024/06/10 11:03:54.977|SLManagedScripting.exe|ManagedInterop|CRU|-1|447|tokenoperaotr 207
2024/06/10 11:03:54.977|SLManagedScripting.exe|ManagedInterop|CRU|-1|447|excuting triggers 201 clear token and trigger 100 get the layouts
2024/06/10 11:04:26.851|SLElement.exe|15000|CParameter::SetElementState|DBG|0|** parameter alarmstate 3/ from 1 to 2
2024/06/10 11:04:26.851|SLElement.exe|15000|CElement::NotifyAlarmState|DBG|0|** Element Alarmstate changed to 2.
2024/06/10 11:08:26.908|SLElement.exe|15000|CParameter::SetElementState|DBG|0|** parameter alarmstate 3/ from 2 to 5
2024/06/10 11:08:26.908|SLElement.exe|15000|CElement::NotifyAlarmState|DBG|0|** Element Alarmstate changed to 5.
Success:
2024/06/10 12:03:54.548|SLManagedScripting.exe|ManagedInterop|CRU|-1|515|The param are url ias/v3/token/actions/signOnByUserNamePassword token body is after trigger 200 checked
2024/06/10 12:03:55.086|SLManagedScripting.exe|ManagedInterop|CRU|-1|322|das ist der token der gecleart wird
2024/06/10 12:03:55.086|SLManagedScripting.exe|ManagedInterop|CRU|-1|322|tokenoperaotr 207 :
2024/06/10 12:03:55.087|SLManagedScripting.exe|ManagedInterop|CRU|-1|322|excuting triggers 201 clear token and trigger 100 get the layouts
2024/06/10 12:03:55.326|SLManagedScripting.exe|ManagedInterop|CRU|-1|322|check trigger 2 clear table and before iteration
2024/06/10 12:03:55.340|SLManagedScripting.exe|ManagedInterop|CRU|-1|322|only all Rail check loop
2024/06/10 12:03:55.341|SLManagedScripting.exe|ManagedInterop|CRU|-1|322|before setting the counter to 0 120
2024/06/10 12:03:55.341|SLManagedScripting.exe|ManagedInterop|CRU|-1|322|after setting the counter to 0 0
2024/06/10 12:03:55.349|SLElement.exe|15000|CParameter::SetElementState|DBG|0|** parameter alarmstate 1004/0 from 1 to 0
2024/06/10 12:03:55.352|SLElement.exe|15000|CParameter::SetElementState|DBG|0|** parameter alarmstate 1004/0 from 0 to 1
2024/06/10 12:03:55.357|SLElement.exe|15000|CParameter::SetElementState|DBG|0|** parameter alarmstate 3/ from 5 to 1
2024/06/10 12:03:55.357|SLElement.exe|15000|CElement::NotifyAlarmState|DBG|0|** Element Alarmstate changed to 1.
Success:
2024/06/10 13:03:54.601|SLManagedScripting.exe|ManagedInterop|CRU|-1|428|The param are url ias/v3/token/actions/signOnByUserNamePassword token body is after trigger 200 checked
2024/06/10 13:03:55.011|SLManagedScripting.exe|ManagedInterop|CRU|-1|501|das ist der token der gecleart wird 2024/06/10 13:03:55.011|SLManagedScripting.exe|ManagedInterop|CRU|-1|501|tokenoperaotr 2024/06/10 13:03:55.012|SLManagedScripting.exe|ManagedInterop|CRU|-1|501|excuting triggers 201 clear token and trigger 100 get the layouts
2024/06/10 13:03:55.236|SLManagedScripting.exe|ManagedInterop|CRU|-1|501|check trigger 2 clear table and before iteration
2024/06/10 13:03:55.253|SLManagedScripting.exe|ManagedInterop|CRU|-1|501|only all Rail check loop
2024/06/10 13:03:55.253|SLManagedScripting.exe|ManagedInterop|CRU|-1|501|before setting the counter to 0 60
2024/06/10 13:03:55.253|SLManagedScripting.exe|ManagedInterop|CRU|-1|501|after setting the counter to 0 0
2024/06/10 13:03:55.264|SLElement.exe|15000|CParameter::SetElementState|DBG|0|** parameter alarmstate 1004/0 from 1 to 0
2024/06/10 13:03:55.267|SLElement.exe|15000|CParameter::SetElementState|DBG|0|** parameter alarmstate 1004/0 from 0 to 1
Fails (doesn't execute trigger 100):
2024/06/10 14:03:54.636|SLManagedScripting.exe|ManagedInterop|CRU|-1|470|The param are url ias/v3/token/actions/signOnByUserNamePassword token body is after trigger 200 checked
2024/06/10 14:03:55.079|SLManagedScripting.exe|ManagedInterop|CRU|-1|447|das ist der token der gecleart wird
2024/06/10 14:03:55.079|SLManagedScripting.exe|ManagedInterop|CRU|-1|447|tokenoperaotr 207 :
2024/06/10 14:03:55.079|SLManagedScripting.exe|ManagedInterop|CRU|-1|447|excuting triggers 201 clear token and trigger 100 get the layouts
2024/06/10 14:04:28.299|SLElement.exe|15000|CParameter::SetElementState|DBG|0|** parameter alarmstate 3/ from 1 to 2
2024/06/10 14:04:28.299|SLElement.exe|15000|CElement::NotifyAlarmState|DBG|0|** Element Alarmstate changed to 2.
2024/06/10 14:08:28.332|SLElement.exe|15000|CParameter::SetElementState|DBG|0|** parameter alarmstate 3/ from 2 to 5
2024/06/10 14:08:28.332|SLElement.exe|15000|CElement::NotifyAlarmState|DBG|0|** Element Alarmstate changed to 5.
Fails (doesn't execute trigger 100):
2024/06/10 15:03:54.688|SLManagedScripting.exe|ManagedInterop|CRU|-1|125|The param are url ias/v3/token/actions/signOnByUserNamePassword token body is after trigger 200 checked
2024/06/10 15:03:55.090|SLManagedScripting.exe|ManagedInterop|CRU|-1|476|das ist der token der gecleart wird
2024/06/10 15:03:55.090|SLManagedScripting.exe|ManagedInterop|CRU|-1|476|tokenoperaotr 207 :
2024/06/10 15:03:55.090|SLManagedScripting.exe|ManagedInterop|CRU|-1|476|excuting triggers 201 clear token and trigger 100 get the layouts
Fails (doesn't execute trigger 100):
2024/06/10 16:03:54.738|SLManagedScripting.exe|ManagedInterop|CRU|-1|458|The param are url ias/v3/token/actions/signOnByUserNamePassword token body is after trigger 200 checked
2024/06/10 16:03:55.164|SLManagedScripting.exe|ManagedInterop|CRU|-1|367|das ist der token der gecleart wird
2024/06/10 16:03:55.164|SLManagedScripting.exe|ManagedInterop|CRU|-1|367|tokenoperaotr 207 :
2024/06/10 16:03:55.165|SLManagedScripting.exe|ManagedInterop|CRU|-1|367|excuting triggers 201 clear token and trigger 100 get the layouts
Success:
2024/06/10 17:03:54.802|SLManagedScripting.exe|ManagedInterop|CRU|-1|495|The param are url ias/v3/token/actions/signOnByUserNamePassword token body is after trigger 200 checked
2024/06/10 17:03:55.191|SLManagedScripting.exe|ManagedInterop|CRU|-1|220|das ist der token der gecleart wird
2024/06/10 17:03:55.191|SLManagedScripting.exe|ManagedInterop|CRU|-1|220|tokenoperaotr 207
2024/06/10 17:03:55.191|SLManagedScripting.exe|ManagedInterop|CRU|-1|220|excuting triggers 201 clear token and trigger 100 get the layouts
2024/06/10 17:03:55.380|SLManagedScripting.exe|ManagedInterop|CRU|-1|516|check trigger 2 clear table and before iteration
2024/06/10 17:03:55.383|SLElement.exe|15000|CParameter::SetElementState|DBG|0|** parameter alarmstate 1004/0 from 1 to 0
2024/06/10 17:03:55.387|SLManagedScripting.exe|ManagedInterop|CRU|-1|516|only all Rail check loop
2024/06/10 17:03:55.387|SLManagedScripting.exe|ManagedInterop|CRU|-1|516|before setting the counter to 0 240
2024/06/10 17:03:55.387|SLManagedScripting.exe|ManagedInterop|CRU|-1|516|after setting the counter to 0 0
2024/06/10 17:03:55.398|SLElement.exe|15000|CParameter::SetElementState|DBG|0|** parameter alarmstate 1004/0 from 0 to 1
2024/06/10 17:03:55.399|SLElement.exe|15000|CParameter::SetElementState|DBG|0|** parameter alarmstate 3/ from 5 to 1
2024/06/10 17:03:55.399|SLElement.exe|15000|CElement::NotifyAlarmState|DBG|0|** Element Alarmstate changed to 1.
2024/06/10 17:12:00.176|SLProtocol - 5004 - Rail Monitor|20312|CProtocol::HandleAnotherTelnetClient|DBG|0|Telnet clients connected Primary = 1, Derived = 0
**********
Any ideas ?
Thanks you in advance
Hi Omer,
Could it be that the QAction is not being executed when the HTTP request fails? In that case the response parameter is not being set. To solve this, you could trigger 'after group' 100 and 200, instread of the response parameter. Such trigger is always executed, even when the HTTP request times out.
See the second diagram on this page: https://docs.dataminer.services/develop/devguide/Connector/LogicTriggers.html.
That trigger can then eventually execute a QAction that processes the response. It's important to check the received HTTP response code because the QAction will also be executed when no response was received.
Trigger (after group) > Group > Action "run actions" > Param > QAction
[Ping]
Hi I comment my answer
maybe u didn’t receive message
[ping]
How to make that the trigger always triggers like you said and not independent on the response ?
Like u suggested before
have u any example ?
So hopefully I can fix the problem
Hi,
Thanks for your help.
I clear the parameters every time after writing in the table, so my QAction executes every time.
You are right that the QAction doesn’t trigger if there are no changes. The API call response rarely changes, only in very rare moments. That’s why we have the logs, as explained.
I wrote a new answer cause in the comments I can’t put an image.
Thanks