06-22-2015 09:42 AM - last edited on 10-26-2015 04:52 PM by LiliMcDonald
Hello,
i am working on this software and doing it via queues even driven state machine but Im having problem with. I understand how queues and event structure work but here's my problem. when I pass a massage to my state machine from the event structure via Queues. It works fine then stop. My goal is for the second loop where the state machine is to continue working but not wait on the next message. I tried ot use a time out on the queue but that didnt work. Is there anyway i can do that. I attached the VI. it's not finished yet but you will see what Im doing with it
Admin Note - Attachments removed per user's request
06-22-2015 09:58 AM
Instead of having Stop send a Notification, simply have Stop send the message "Stop". Get rid of the Notifier (I have nothing against them, but you already have a Queue for Messages, and Stop is just another Message). The Stop Button can stop the Producer loop (the Event loop), while the Stop Message can generate the True that you wire into the Stop Indicator of the Consumer (lower) Loop. Simpler is sometimes Better.
Bob Schor
06-22-2015 10:09 AM
Thanks for your input. I did that because at the end I have 4 different parallel while loops and to avoid race condition issues. I send the message thru notifiers and populate it to the other loops. As far as having my consumer loop running continuously by feeding the latest message from the queue to the case structure, is there any way I should go about this. because Im trying to plot data, so when the second loop stop my third loop (data display) have nothing to display so I have no data on my graph. Not sure if im being clear.
06-22-2015 10:48 AM
This is a case where the principle Write the Documentation First (or, for the purpose of this Forum, Describe Carefully What You Want to Do) applies. I confess I didn't take a careful look at your entire program and attempt Reverse Engineering to guess what you were trying to accomplish.
Would it be correct to say that the Event Loop is designed to choose a "signal source" that will be used to specify/change an on-going signal being generated in a separate loop? I don't see the signal generator anywhere ...
If this is the case, then your Random message wants to "set a switch" so that the Signal Generator generates a random signal (this could be an Enum, I suppose). Similarly, Sine Wave would set the "switch" (a Shift Register) to Sine Wave. You could have another message, "Get Waveform", that generates N points based on the current Switch setting -- to make it generate continuously, simply have Get Waveform put "Get Waveform" on the Queue. Because it is a Queue, you can interleave Event and Get Waveform Messages without worry.
Without knowing the rest of your Project, I can't make recommendations for stopping the other (unknown) loops. Perhaps the Notifier is the most efficient ...
Bob Schor
06-23-2015 07:58 AM - last edited on 10-26-2015 04:53 PM by LiliMcDonald
Bob, thanks for your input. I attached the full vi for you to have a better understanding of what Im talking about. Keep in mind though it works it isnt closed to finished.
My goal is to toggle different boolean that will generating different data. Each Boolean will generate a messgae via event structure to my message handling loop. once the message is passed, that loop will queue in the state of the data to generate. Once dequeued my plotting loop will generate the data then queue it in for display. It seems like there are too many queues being used but that is how I plan to write the VI. I want my 3rd loop to always generate the data so that my fourth one can display but that isnt working for me since the 3rd loop is always waiting on a message from teh 2nd loop ( messge handler). If you foolow the data flow you'll see what I am referring to
Admin Note - Attachments removed per user's request
06-23-2015 08:29 AM
Personally, I don't see a need here for all of the loops. All of that code can be done inside of the event structure. There isn't anything in there that will take a "long" time. So I would avoid all of this complication.
06-23-2015 08:33 AM
I do it this way to follow the Queue event driven state machine (QEDSM ) format. And I separate the data plot from display to avoid complications later.
06-23-2015 09:14 AM
@ritch_by_nature wrote:
I do it this way to follow the Queue event driven state machine (QEDSM ) format. And I separate the data plot from display to avoid complications later.
For what reason are you following that pattern? And what complications are you referring to?
06-23-2015 09:41 AM
Plotting complications and I am following that pattern becuase it is better way to develop and design a software according to Labview
06-23-2015 09:48 AM
@ritch_by_nature wrote:
Plotting complications and I am following that pattern becuase it is better way to develop and design a software according to Labview
What kinds of plotting complications? You show a waveform on a plot.
Is it really better? Are you doing anything that actually needs parallel operations? No, you are not. So I would not just blindly follow that pattern just because somebody said it was better. You need to apply the right architecture to the right problem. You are just making a simple task difficult by making all of these serial operations parallel. They are acting in parallel at a slow rate, basically making it a serial operation. So you might as well just make it simple and put everything into a single loop.