[ANSWERED] Network Triggers and variables

Posted on
Fri Apr 18, 2014 9:49 am
autolog offline
Posts: 3991
Joined: Sep 10, 2013
Location: West Sussex, UK [GMT aka UTC]

[ANSWERED] Network Triggers and variables

When I send multiple TCP out messages to the same target system, I get a trigger fired on each receipt of a line from the target system. I am using Unrecognised and the line text is put into a variable.
The trouble I am having is that the subsequent line input appears to overwriting the variable before I can process it. If I put a sleep of 2 seconds between each TCP out call then the variables don't get overwritten by subsequent calls and I can process them in time.

So for example if I output 4 messages 'A', 'B', 'C', 'D' expecting replies '1', '2', '3', '4' - the replies I am actually getting might be '1', '3', '4', '4'. It looks like a trigger is firing as each response is received, it is just that the variable is replaced too quickly.

Am I missing something, or do I have to add in logic to wait for replies before sending further messages?

TIA :)
Last edited by autolog on Fri Apr 25, 2014 3:31 pm, edited 1 time in total.

Posted on
Fri Apr 25, 2014 1:41 pm
Perry The Cynic offline
Posts: 836
Joined: Apr 07, 2008

Re: Network Triggers and variables

autolog wrote:
When I send multiple TCP out messages to the same target system, I get a trigger fired on each receipt of a line from the target system. I am using Unrecognised and the line text is put into a variable.
The trouble I am having is that the subsequent line input appears to overwriting the variable before I can process it. If I put a sleep of 2 seconds between each TCP out call then the variables don't get overwritten by subsequent calls and I can process them in time.

So for example if I output 4 messages 'A', 'B', 'C', 'D' expecting replies '1', '2', '3', '4' - the replies I am actually getting might be '1', '3', '4', '4'. It looks like a trigger is firing as each response is received, it is just that the variable is replaced too quickly.

Am I missing something, or do I have to add in logic to wait for replies before sending further messages?
TIA :)

You may have to. Indigo does not promise sequencing between triggers firing and their attached actions firing, so you may indeed get this behavior when things get busy. Nor does Indigo have a way to "attach" dynamic data to trigger or action firings (we have to use variables or properties to keep data), and I don't know of a way to model queues of data in a way that's not seriously obtuse.

If the incoming messages are recognizably different, you may use separate Recognized Input events; each can have its own variable. But if you need to process a list of replies that all have the same pattern, adding delays may be your only choice for now.

Cheers
-- perry

Posted on
Fri Apr 25, 2014 3:30 pm
autolog offline
Posts: 3991
Joined: Sep 10, 2013
Location: West Sussex, UK [GMT aka UTC]

Re: Network Triggers and variables

Perry The Cynic wrote:
You may have to. Indigo does not promise sequencing between triggers firing and their attached actions firing, so you may indeed get this behavior when things get busy. Nor does Indigo have a way to "attach" dynamic data to trigger or action firings (we have to use variables or properties to keep data), and I don't know of a way to model queues of data in a way that's not seriously obtuse.

If the incoming messages are recognizably different, you may use separate Recognized Input events; each can have its own variable. But if you need to process a list of replies that all have the same pattern, adding delays may be your only choice for now.

Cheers
-- perry

Thanks for the reply. :)

I have implemented a queuing system which seems to be working quite well so far and works like this:
  • Push messages to send onto a queue for the particular Cynical Network connection
  • pop a message from queue and send via Cynical Network
  • On receipt of response (variable updated by Cynical Network and event fires)
    - process response
    - pop next message from queue and send via Cynical Network
This effectively serialises the messages which is what I want. The only risk I can see is that a queue of messages might build up because a response is not received, so I need to handle this.

Thanks again for the reply and also for a very useful Plugin :D

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 1 guest