07-30-2013 03:53 AM
Hello Everyone,
I am using a producer/consumer architecture, where cases in the consumer(s) are selected with enums sent through a queue.
The enums are enqueued in the producer, which is an Event Structure inside a While Loop. Then each of the events in the producer is associated to a case in the consumer(s) (to make it simpler).
Now I would like to execute programmatically several events in the producer, in a given sequence. The events involved in the sequence are basically all triggered by Value Change of a Boolean (button).
Please find attached a schematic of the sequence I would like to implement.
I have heard about 2 solutions:
- "Write to the Value(Sgnl) property node of the variable [I] want to change"
- Dynamic User Events
In any case, I don't know how to ensure this is done for several events in a specific sequence?
Thank you.
Florian
Solved! Go to Solution.
07-30-2013 04:05 AM
Hi,
I do this in my queue driven state machine. It may help you.
In the producer event state (example button value change event) I have a little vi that is a 'for loop' that enqueues a group of states in the order they are passed to the vi in an array.
You can do this straight on the block diagram, create an array of enums you want to call and then feed them in to an enqueue element vi sat inside a 'for loop'.
This solutions gets a lot more complicated if you want to send data in to each state. But it can be done, you just have to be careful about what data is sent to the states.
I would say that this is one of the main reasons for development of the Actor framework.
Neil.
07-30-2013 04:17 AM
Another option would be to use NI TestStand as prebuild sequencer.
My experience is that customizing a sequencer starts out small (one man, half day work for a limited time planned), but over the years grows to a fulltime job for several developer in order to maintain and add new features (e.g. parallel test) to the custom sequencer.....
QDMH is a good starting point for a sequencer as it could also be referred as a "self-feeding, externally controllable state machine".
Norbert
07-30-2013 04:30 AM
Hi Neil,
I am not sure if I understood correctly how to implement what you said.
Is the little VI inside the event structure, or just inside the while loop?
From what I understood, stacking the enums values in an array enforces cases in the consumer loop to execute in the order specified in the array.
What I would like to do though, is execute the code inside several events of the structure event, and specify this order of execution. Of course, the dataflow in the consumer loop will follow as one event enqueues one enum.
Did I get it right?
07-30-2013 04:55 AM
Hi Norbert,
Well, for the moment I only plan to implement a single test sequence.
That's true that it would be easier to customize test sequences later with NI Test Sand, but I surely have to do without it (unfortunately).
QDMH or Queue-Drive Message Handler refers to the same kind of architecture as mine, that is producer/consumer architecture with producer containing an event structure which events are passed to the consumer through a queue. Am I right?
Thank you.
Florian
07-30-2013 05:26 AM
@flongnos wrote:
Hello Everyone,
I am using a producer/consumer architecture, where cases in the consumer(s) are selected with enums sent through a queue.
The enums are enqueued in the producer, which is an Event Structure inside a While Loop. Then each of the events in the producer is associated to a case in the consumer(s) (to make it simpler).
Now I would like to execute programmatically several events in the producer, in a given sequence. The events involved in the sequence are basically all triggered by Value Change of a Boolean (button).
Please find attached a schematic of the sequence I would like to implement.
I have heard about 2 solutions:
- "Write to the Value(Sgnl) property node of the variable [I] want to change"
- Dynamic User Events
In any case, I don't know how to ensure this is done for several events in a specific sequence?
Usually event are performed in the order they are created, but there's no guarantee. I'd actually move it to the consumer, as a "create sequence/macro"-command, in which you enqueue an array of commands.
/Y
07-30-2013 05:31 AM
Sorry I think we got our wires crossed (LOL), maybe my suggestion wont help you in your case.
My understanding of best practice (for a QSM) is that no functional code should be placed in the event structure cases, so for me the event structure is litterally a UI monitor calling consumer states that perform my functional code, even if that is to just change the UI.
Someone else may be able to help you to change your code to work like you have clarified, I personally prefer the separation of events produced and consumer states called to action the event. Unless of course you have an event driven state machine.
Sorry I couldn't help more. Good luck.
Neil.
07-30-2013 06:33 AM
@flongnos wrote:
Hi Norbert,
[...]QDMH or Queue-Drive Message Handler refers to the same kind of architecture as mine, that is producer/consumer architecture with producer containing an event structure which events are passed to the consumer through a queue. Am I right?
Thank you.
Florian
Florian,
no, the QDMH is different to a producer/consumer (event based).
The QDMH includes both parts in a single loop. In order to stay responsive, the QDMH sacrifices the event based feature of being idle without CPU load (wait for event/queue element) and uses polling for both events and queue elements. If it would not, it would be stuck very fast....
As it is a single loop architecture, there is no difference anymore between "engine" and "peripheral update" (e.g. UI) which can increase usability.
Norbert
07-30-2013 08:44 AM
In my application, I would like the UI to remain responsive continuously, and not wait for parallel loops to end execution.
@ Neil: Beside looking out for user events, the producer also updates one pure GUI element (the wafer map) according to the event triggered. For that some code must be inside the event structure, and so far it works perfectly.
You have mentioned about Actor Framework. Do you think it's worth implementing in my situation?
@Norbert: The consumer enqueues one enum (usually IDLE) at the end of the CASE execution, so that the consumer loop remains in that state while no event is triggered in the producer.
From what I know is is Queued Message Handler.
I don't understand how you can have an event structure along with other processes, and that they all remain responsive, such as you describe for QDMH.
I find really little information concerning the QDMH you mentioned, on the Internet...
Thank you again.
Florian
07-30-2013 09:05 AM
Florian,
you are correct that the QDMH is obviously not very well documented outside NI class material. This architecture is one of the key architectures discussed in the LV Advanced Architectures class.
You can fin a similar architecture, the Queued Message Handler as template in the LV 2012 project assistant (New Project). It also provides a quite detailed documentation and shows in general the approach even if it still uses two loops.
The QDMH i refer to simply pulls both loops into a single one, so dequeue and event structure have both to use timeouts. Otherwise, you would block the loop.
hope this helps,
Norbert