Hello,
I am currently assigned a fairly big task and need some help with the structural design.
We want to run control loops on several different instrument configurations (we us LabJack as an I/O interface). Now I want to create a framework that can be reused for every test stand.
I identified the need to log data, have an email report, and to run different control procedures on each test stands. So far I have figured out how to solve every individual problem, logging is carried out via file-I/O operations , email via the smtp VI and for different control procedures I will use a simple state machine.
Since the control loop is more time critical than the logging or reporting I want to use a producer-consumer design pattern. The control loop will be placed in a state of the state machine and will generate request by adding messages to a message queue. A consumer loop that is placed outside the statemachine (it should handle messages from every state of the machine) will write the messages that come through the queue into a file.
Idea behind this: The consumer loop will be running at a slower rate than the control loop to give it a lower priority. When the statemachine has carried out its last state and stops the consumer loop can still run until no messages are left in the queue. Then it will also stop.
So far my plan. Now my first question is:
What is your opinion on such a structure? Maybe there is a simpler way to do this. I noticed that state machines can become a hussle when one has to deal with shift registers for every value passed from one state to the next state. Is it wise to bundle the data and have only one bundle shift register? Or would it be better to use a cluster instead?
My second question is; I would like to monitor the number of messages within the queue and have them displayed on a chart. The reason for this is, that I got the impression, that the consumer loop does not execute until a messages generating while loop within the statemachine has finished. But I would like the consumer loop to start right away when the first message enters the queue. Do you know a way to update the chart every time the number of messages within the queue has changed?
I know this description is fairly imprecise, please let me know if I should be more detailed at some point.
Currently I am using LV 7.1 but I could use 8.1 or 8.2 (?, I don't know) if that would help it any.
Thank you, I really appreciate your support.
Best regards,
Message Edited by richmart on 09-20-2007 01:27 PM
Message Edited by richmart on 09-20-2007 01:30 PM