Producer/Consumer in Coherence?

I have an app which produces unprocessed orders and places them in the cache. I have multiple instances of an order processing app which listens for new orders going into the cache. Orders must be processed only once. What's the best way for my consumers to arbitrate processing of these orders? I can't have, say, 10 consumers and just do thisOrder.OrderId%10 because if one consumer dies I want the others to continue processing all orders.
Thanks,
Andrew

Hi Andrew,
there are several ways to do that, one or more may be suitable depending on what resource dependencies your operation has.
Within the storage node:
You can use entry-processors which guarantee that at most one operation is running on the same entry at the same time and should that node fail, it will be retried.
You can use the command pattern from the Incubator similarly as entry-processors but it provides even stronger failover guarantees.
You can use cache-stores to implement order processing, too, it also guarantees that there is at most one cache store attempting to persist the same entry and with write-behind you are even able to batch processing multiple orders together.
Outside of storage nodes you can use locking to implement mutual exclusion.
It all depends on your choice.
Best regards,
Robert

Similar Messages

  • Progmatically stop vi with producer/consumer architecture

    I can't seem to get my VI to fully stop, so that I can go on to do some more things in the program.  I am trying to progmatically stop the vi (pictured below), so that I can return to my main gui (not pictured).  The main gui just consists of a login, exit test system, and run test.  Once the user presses run test, the vi pictured below opens.
    I am using a producer/consumer architecture with a state machine.  The problem I run into is that when I press the "Main Menu" button, it should close the pictured vi and return to the main gui.  I tried using the vi server, and when the user presses the Main Menu button, it fires an event and then it goes to the Stop state in the consumer loop, which opens a reference to the vi's (one for the strip chart vi and another for the gage vi), closes the front panel using an invoke node and then closing the reference.  I also tried adding in the abort vi method after the close front panel and it still gave me the same result.
    Here is the catch, it does close the vi's, but it does not stop the while loops (producer and consumer), or it stops only one of the loops.  I thought of putting in a constant in the event structure for when the Main Menu event is fired, but that will stop the producer loop before the consumer loop reveices the info to go to the stop state, so the consumer loop does not end.
    I also tried a "dummy" control that was connected to the comsumer loop Stop terminal (for the while loop), and then progmatically changed the value in the stop case to true and then read that value in the producer loop to, hopefully, stop both loops, but it did not work either.
    I am sure that it is something so stuipidly simple that I cant see it right now
    Kenny
    Kenny
    Attachments:
    test system.gif ‏252 KB

    Hi Kenny,
    I think of two solutions to your problem. First, use the message queue to pass the message "stop" or something from producer to consumer or second (and I think, better), use occurrences. I made a little draft how it could work.
       You have to pass the occurence- Refnum to both VIs, the producer and the consumer, when the producer finishes execution, then use "Set Occurence".
       In the consumer blockdiagram you react on the generated occurrence.
    If you set in the VI- properties "Open Frontpanel when called" and "Close if originally..." the VI Frontpanel should disappear itself when execution is stopped.
    Hope this helps,
    Dave
    Message Edited by daveTW on 08-14-2006 04:53 PM
    Greets, Dave
    Attachments:
    occurrence 1.png ‏1 KB
    occurrence 2.png ‏5 KB

  • How to change the transmissi​on rate of data flow in producer/ consumer pattern

    Hi All
    I am new to labview and trying to design a application to transfer image data in different rates, that means I can change the transfer rate in the transmission process. In fact,I refer to the the Queue Basic.vi to achieve this function by Changing the delay value of dequeue and enqueue.The program is divided into three parts:
    The first part is the sender in vc used to split and send image data.Data size is 226kb and each time we send a 1kb packet;
    The second is labview rate-change part,use producer/ consumer pattern and queue to transfer data;
    The third one is the receiver in vc,receive data in sequence and synthetic images.
    The entire transfer process is: image data was sent from the sender to producer loop through DLL, then enqueue--dequeue in consumer loop--DLL--receiver.The sleep time in vc sender is equal to the delay value in producer loop and this makes it look like the data generated as in the loop.
    Now this is where my dilemma is:
    When transferring data, if the producer loop and consumer loop delay value are equal(both 20ms), I can see image synthesis at a constant speed and no data lose; if I change the consumer loop delay value and make it greater than the producer delay(one is still 20ms and another is 50ms),that means receive in a lower rate and store data in queue. I can see Elements in Queue
    increase but the image data randomly lost, and the image synthesis speed is not reduced.
    My question is why image data loss and I can't see the image synthesis speed reduced when change the delay value in consumer loop?
    Do anyone know how to solve the problem? Are there any examples I can refer to? Any suggestions are greatly appreciated!
    Attachments:
    image1.JPG ‏56 KB

    thisoldman,
    I don't have '/usr/lib/modules/3.17.3-1-ARCH/build/Documentation/VGA-softcursor.txt' on my file system. Does it contain the info about changing the blinking speed?
    P.S. The other two links I found yet before starting this thread. I only found in them the recommendations about changing "the color and shape of the cursor and turning blinking on/off" (as I mentioned in the original question). Did I miss the info about the blinking speed?
    PPS: I found the vga-softcursor.txt here: https://www.kernel.org/doc/Documentatio … cursor.txt
    But that file doesn't tell about changing the blink rate either.
    Last edited by nbd (2014-11-23 20:55:41)

  • Producer consumer timing

    Back again
    Thought I was getting somewhere now I am at another brick wall.
    Bit of background:
    I have a producer consumer set up. In the producer loop there are 2 DAQmx read VI's reading from a Pressure task and a Temperature task. These are multiple channels, 1 sample, outputtng a 1D wave form. This loop is set to run every 20ms. The two tasks were created using DAQmx Create Channel VI's and DAQmx Start Task VI's. The producer loop feeds a display on the front panel with the sensor values and this hopefully is refreshed at the 50Hz I have asked for. Secondly the loop bundles up the waveforms and puts them in a queue where they are picked up for logging by the consumer loop. In the consumer loop I have a wait 1000ms timer and a Write to Measurment File Express VI to do the logging. This is supposed to log at 1 per second.
    The queue is set to enqueue at opposite end, and the max queue length is set to 1. I.E. I only want to log the value at that specific second, but I want to show the data on the front panel at 50 times a second.
    Now heres my problems:
    1) I replaced the DAQmx Create channel's with a MAX project task wired into my DAQmx Start Task VI. As expected the thing picks up and displays the sensor values as it did before. However there is now a problem logging. Before when I had the DAQmx Create Channel, the logging recorded my values correctly at 1 second intervals. The time stamp in the X column went up by 1 second for each set of results. But now, with the MAX project task (needed because of custom scales and differing min/max values for different sensors), The logging still seems to happen at 1 per second, but the time stamp intervals are the same as the sampling rate set in the task!!! (ie at 50Hz the time stamp goes up 20ms for each result even though the results are being recorded at 1 per second)
    2) The timing just seems out of whack.
    I keep getting errors that the requested data no longer exists, that it was there but then was over written. Increasing the buffer size or sampling rate is supposed to remedy this... but what sampling rate? the rate set in the task? or the loop iteration speed? I dont understand.
    Secondly, despite telling my consumer loop to wait one second between picking up stuff out of the queue to log, it seems to be going round nearly the same pace as the producer loop. To top this off the producer isnt going round at the speed I asked it too either! I put indicators on the loop counters to see this. they are going round at maybe 2Hz.
    I have included my VI's
    What am I doing wrong, its really bugging the crap out of me!
    Attachments:
    EngineMon.zip ‏90 KB

    The reason you would use get time and date in seconds to to ensure that you log every second. If you use the 1 second wait then you do not take into account the exicution time of your loop. If you add more to the loop in the future than you will see that you do not log every second as you thought. If you loop took 500ms to exicute and you have the 1000ms wait then the actual excution time for recoding to file is 1.5 seconds not 1000ms as you desired. The way I did it will always give you one second unless you exicution time for your loop exceeds one second.''
    I did make one change to the vi. I shoulod have put the write in the true false case so that the write only happens when the 1 second has expired.
    Tim
    Johnson Controls
    Holland Michigan
    Attachments:
    VDU3.vi ‏59 KB

  • First attempt at Producer Consumer Architectu​re: continuous read and dynamicall​y update parameters​.

    Hello,
    I am currently working with two instruments; an Agilent E3646A and an NI 6212 BNC. My objective is to have the 6212 to be continuously taking measurements according to predefined parameters while the E3646A's parameters can be continuously updated. This simple instrument combination is intended to help me learn the necessarry achitecture; continuous measurement, dynamic output control, and more instruments will be added in the future.
    I've previously posted on a similar, but more complicated, setup (http://forums.ni.com/t5/Instrument-Control-GPIB-Se​rial/Split-second-lag-when-controlling-two-instrum​... and was advised to try the Producer Consumer Architecture. I've found relevant literature on the site (http://www.ni.com/white-paper/3023/en/, https://decibel.ni.com/content/docs/DOC-2431), searched the forums and constructed my own VI. While my first attempt at a Producer Consumer Architecture has resolved some of the issues I was having when I first posted on the subject, however, new issues have arisen with regard to reading and stopping the VI.
    I am currently able to run the VI and update the device parameters. Previously, I would get a freeze while the instrument was being updated and could not toggle parameters until it was done. This has been resolved although the read only updates when a parameter has been updated although it is outside of the event structure. Furthermore the Stop button does not work in any context. I've also gotten occasional errors regarding the Deqeue Element but the bulk of the trouble is Error -200279 "Attempted to read samples that are no longer available" at DAQmx Read. I realize that there is a problem in my Producer Loop but haven't been able to figure out how to resolve it.
    This is my first attempt at a Producer Consumer Architecture and already I can see that it is a powerful tool. I read as much as I could and looked at the relevant examples but expected to have some issues in the beginning. Would really appreciate any advice so I can take full advantage of the architecture.
    Hope to hear from you,
    Yusif Nurizade
    Solved!
    Go to Solution.
    Attachments:
    DCe3646A_DAQ6212_Prod_Con_4_13a_2014.vi ‏89 KB

    Jon,
    Thank you for the response and the suggestions.
    I created the Local Variable for the Stop Button and moved the original into its own Event Case. It is now able to stop VI execution although I get Warning -1073676294 which I understand to be the buffer issue. The warning says that this was incurred on VISA Open for the E3646A's Initialize VI which is outside both loops, however, which I don't understand.
    I tried increasing buffer size by decreasing the Number of Samples as per suggestions I found on NI forum threads. I've brought it down as low as 1 but the graph still only updates when an Event occurs and I keep getting the same buffer error. You suggested that the problem could be that they are in the same loop; does this mean that the DAQmx read should be outside both Producer and Consumer Loops or moved into the Consumer Loop? I found a couple of links ( http://forums.ni.com/t5/LabVIEW/Producer-Consumer-​Design-Pattern-DAQmx-Event-Structure/td-p/2744450 ,  http://forums.ni.com/t5/LabVIEW/Producer-Consumer-​Architecture/td-p/494883 -first response) on dealing with an Event Structure that my own VI is based. Alternatively, I found another link ( http://forums.ni.com/t5/LabVIEW/Producer-Consumer-​Design-Pattern-DAQmx-Event-Structure/td-p/2744450 - first response) on a DAQmx Read with an Event Structure that places the graph in the Consumer Loop.
    The core of my purpose in setting up this Producer Consumer Architecture is so that I could read continuously while the instrument parameters are updated dynamically so it's very important that I understand how this works. I am particularly struggling with how the Event Structure is controlling the While Loop's Execution.
    Hope to hear form you,
    Yusif Nurizade
    Attachments:
    DCe3646A_DAQ6212_Prod_Con_4_14a_2014_Edit_I.vi ‏90 KB

  • Can anyone tell me what's wrong with my queue or producer consumer loop?

    A Labview engineer helped me with the overall structure of my program, necessitated by the fast data sample rate and post processing requirements. He recommended the producer/consumer loop and using one of the example files (Cont Acq graph voltage - int clk) to do the actual data acquistion. So I put together the loop and go my two channels of data acq going in the producer loop. However, nothing's getting picked up in the consumer loop and none of my data gets displayed over there.
    Anyone care to take a look at it and let me know what I'm doing wrong?
    Solved!
    Go to Solution.
    Attachments:
    P-C Yanmar Program.vi ‏296 KB

    Your Enque Element should be inside the while loop where you aquire the data.  As it is now, the data has to stop being aquired before you send the last set of aquired data.
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines

  • Time Stamps in Producer/Consumer Setup

    I am trying to acquire signal from a Gas Analyzer, Flow Meter, and 3 RTDs.  My hardware is a NI 9215 and NI 9217.  I need to write the data to a file with a time stamp at which the sample was read.  The program is written in a producer/consumer setup in which the data is being acquired in the prodcuer loop and sent to the consumer loop to be written.  I can get the samples written to the file okay. However, I have not figured out how to put the time stamp in the data file correctly. I thought the time stamp was created with the corressponding measurement at the Data Acquisition VI. However, whenever I open the data file, there are only 0s in the time column.  So, I've tried to use Format/Date String to add the time stamp. I can get it to work if I place it in the consumer loop. However, the time stamp is not accurate.  It puts the same time stamp up to six digits of precision for two consecutive samples. I've tried to figure out how to add it to the producer  loop, but I don't know how to add it and the measurements to the queue at the same time. Please tell me the best way to acquire signals with the exact time stamp and write them to a file using a producer/consumer design.
     Example:
    Date             Time               RTD1     RTD2      RTD3     CO2      Flow
    5/26/07      5:20:01.25       57         56         56.5      100       0.5
    5/26/07      5:20:01.30       57         56         56.5      100       0.5
    5/26/07      5:20:01.35       57         56         56.5      100       0.5
    Attachments:
    Producer-Consumer From Scratch2.vi ‏75 KB

    Okay, I've put it in a For Loop and it will connect now. However, whenever it runs the time stamp increments for a couple seconds and then it just repeats. How do I correct this?
    Attachments:
    Producer-Consumer From Scratch2.vi ‏88 KB
    pleasework.txt ‏20 KB

  • Input and output on same device, producer/consumer structure

    Hello interested people,
    I have a question about using the same device for both digital inputs
    and outputs.  I have written a simple program of one while loop
    that continuously polls the device, processes, and requests.  I
    have addressed the device using two DAQmx Asst. and I have attached
    them with their error in/out cluster terminals to provide data flow and
    eliminate the chance of addressing the devices at the same time (which
    produces an error).  Now I want to change this program structure
    to a producer/consumer loop foundation with state machine.  
    In this design, I will have the DI in the producer loop and the DO in
    the consumer loop, under one of the states.  I can't simply
    connect the error in/out ports in this configuration, so my question is
    how to avoid the error caused by addressing the same device
    simultaneously with two different tasks (input and output)?  I
    have attached two VI's, the "One Loop" vi is the original configuration
    (simplified), and the Producer-Consumer vi is a NONSENSICAL program
    that simply represents the desired configuration.  (I don't need
    any comments on the programming of this vi, it is only an example for
    illustration of the problem). 
    I am thinking about bundling the input data and the error cluster, both
    from the PXI 6528 DI, into one cluster, queueing that up, and
    unbundling the de-queued elements for some kind of data flow between
    the producer loop and the "Request" state of the consumer loop. 
    Is this the right approach, or am I barking up the wrong tree?
    Thanks
    Attachments:
    One Loop DO DI.vi ‏102 KB
    Producer-Consumer DI-DO.vi ‏106 KB

    Hello,
    It sounds to me like you really have two modes:
    1. user interface actions determine execution
    2. user interface is locked, and execution is automated.
    I think it would make sense to use the producer consumer for an architecture.  Basically you would do the following:
    1. program the producer to handle the user interface as you normally would.
    2. provide one additional event case in the producer which would be your "automated handling" case.  In that case, you could put a state machine which could run until whatever conditions were met to put your program back in "user interface mode".
    Keep in mind that you can use custom USER EVENTS to programmatically generate events ie. you can trigger the start of your "automated handling" form anywhere in your code at virtually any time.
    I think this would allow you to take advantage of the producer consumer architecture in its intended spirit, while integrating an automated routine.
    I hope this helps!
    Best Regards,
    JLS
    Best,
    JLS
    Sixclear

  • Running subVI in parallel with itself using producer-consumer pattern

    I'm using the procuder-consumer pattern to create what I call threads in response to various events much like in Producer Consumer with Event Structure and Queues
    I have several physical instruments, and would like to run the exact
    same test in parallel on each of the instruments.  I have a subVI
    that takes as inputs a VISA resource and a few control references among
    other things and then performs the desired experiment.  I have a
    separate consumer loop for each physical instrument, with this subVI
    inside each consumer loop.
    My test VI worked great; each consumer loop was a simple while loop
    incrementing a numeric indicator (not using my real subVI above). 
    However, my real program can only run one consumer loop at a time much
    to my dismay.  Reworking my simple test VI to use a subVI to
    increment the indicator rather than just explicitly coding everything
    resulted in the same problem: only a single consumer loop ran at a time
    (and as I stopped the running loop, another would get a chance to
    begin). The subVI in this case was extremely
    simple taking only a ref to the indicator and a ref to a boolean to
    stop, and incrementing the indicator in a while-loop.
    Is there a way around this?  Now that I've spent the time making a
    nice subVI to do the entire experiment on on the physical instrument, I
    thought it would be fairly trivial to extend this to control multiple
    instruments performing the same experiment in parallel.  It seems
    only one instance of a given subVI may run at one time.  Is this
    true?  If it is indeed true, what other options do I have?  I
    have little desire to recode my subVI to manually handle multiple
    physical instruments; this would also result in a loss of functionality
    as all parallel experiments would run more or less in lock step without
    much more complexity.
    Thank you.

    You need to make your subvi reentrant.  Then it can run several instances at any time with each instance occupying its own unique memory space.  Click on File - VI Properties - Execution, and check the reentry execution checkbox.  Then save the vi.
    - tbob
    Inventor of the WORM Global

  • Producer/Consumer Design Pattern with Classes

    I'm starting a new project which involves acquiring data from various pieces of equipment using a GPIB port.  I thought this would be a good time to start using Classes.  I created a GPIB class which contains member data of:  Address, Open State, Error; with member vis such as Set Address, Get Address, Open, Close...general actions that all GPIB devices need to do.  I then created a child class for a specific instrument (Agilent N1912 Power Meter for this example) which inherits from the GPIB class but also adds member data such as Channel A power and Channel B power and the associated Member Functions to obtain the data from the hardware.  This went fine and I created a Test vi for verfication utilizing a typical Event Structure architecture. 
    However, in other applications (without classes) I  typically use the Producer/Consumer Design Pattern with Event Structure so that the main loop is not delayed by any hardware interaction.  My queue data is a cluster of an "action" enum and a variant to pass data.  Is it OK to use this pattern with classes?  I created a vi and it works fine and attached is a png (of 1 case) of it.
    Are there any problems doing it this way?
    Jason

    JTerosky wrote:
    I'm starting a new project which involves acquiring data from various pieces of equipment using a GPIB port.  I thought this would be a good time to start using Classes.  I created a GPIB class which contains member data of:  Address, Open State, Error; with member vis such as Set Address, Get Address, Open, Close...general actions that all GPIB devices need to do.  I then created a child class for a specific instrument (Agilent N1912 Power Meter for this example) which inherits from the GPIB class but also adds member data such as Channel A power and Channel B power and the associated Member Functions to obtain the data from the hardware.  This went fine and I created a Test vi for verfication utilizing a typical Event Structure architecture. 
    However, in other applications (without classes) I  typically use the Producer/Consumer Design Pattern with Event Structure so that the main loop is not delayed by any hardware interaction.  My queue data is a cluster of an "action" enum and a variant to pass data.  Is it OK to use this pattern with classes?  I created a vi and it works fine and attached is a png (of 1 case) of it.
    Are there any problems doing it this way?
    Including the error cluster as part of the  private data is something I have never seen done and ... well I'll have to think about that one.
    Ben
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction

  • Producer/Consumer Architecture

    Hello All,
                    I am currently working on an application using State Machine Architecture where I have to monitor various parameters (7 temperature values & 3 pressure values), along with this I have to On/Off a Clutch using a digital Output for set time (e.g. On for "X" seconds OFF for "Y" seconds), but as soon as the pressure and temperature values go beyond upper or lower limits or whenever the user presses the Emergency Stop (that means I have to monitor Digital Input as well) so I am moving to different error cases depending on which values go beyond limits or emregency pressed etc..
                But this realisation is not working fine as I have to monitor and control several other things in addition to acquiring data....till now I just have used State Machine Architecture, I have seen Producer/Consumer Template but not quite sure how to realise such kind of application which involves data acquisition along with user interaction and monitoring.
    Could someone please put some light on giving similar kind of example or what else I can try with this problem.
    Regards
    James

    Hello James,
    A Producer/Consumer architecture will certainly do the trick for you. I am sending you an example that has the Data Acquisition section in the producer loop. However, you can also put your User Interface in the Producer loop and have the Data Acquisition in the Consumer loop. The Queues are used for sending data from the Producer to the Consumer(s) loop(s) (you can have multiple comsumer loops).
    You will just have to design specific cases to react to different user inputs.
    By the way, this example is from LabVIEW Basics II training course. If you have never taken LabVIEW Basics I and II, I highly recommend them. You can self-pace the class or take it with an instructor.
    LabVIEW Courses
    Hope this helps!
    Message Edited by Kalin T on 03-23-2007 09:57 AM
    Kalin T.
    National Instruments
    Attachments:
    ImplementedProducerConsumer.zip ‏250 KB

  • Producer Consumer Start Trigger

    Short Explanation: I'm using a 3rd party device to send a TTL signal to use as my start trigger in my VI. My cDAQ and modules appear to have the ability to send a start trigger independantly but I have been unable to hunt down how to do this in a producer/consumer system.  I do have an idea at the bottom of the long explanation.
    Long Explanation:
    I'm running a test system that monitors the pressure wave from a hydrogen/oxygen ignition. Components are a cDAQ-9188 with modules 9222 (x3 high speed AI), 9481 (x2 relay), 9402  (x1 I/O Module), 9221 ("Low" Speed AI). 
    Based upon recommendations in this forum I've placed my DAQ in a producer/consumer architecture. 
    At this point the system mostly works, I still have a few more things to add for all the information I want to collect. However, it records at high speed and the 9221 and the 9222 modules are synchronized. It has successfully collected good data as of this writing.
    When the system starts it will monitor, but not record. I need to fill the test structure with gas to a specific concentration before I ignite/record. When I press the record button I send a TTL signal from the 9402 to my high speed camera and I close a relay on a 9481 which engages a spark system. The spark system takes a variable amount of time to charge and fire so I have a timer that leaves the TTL and the relay active for a half second.
    My problem, and it's a small one, comes in with the monitoring system and the synchronization. In order to get the system to synchronize properly I had to generate an external pulse into PFI0 to use as a trigger. I attempted to assign the various clocks available as a start trigger but I ended up with unsynchronized data.  
    Is there a way to generate a pulse on my 9402 to use as a trigger? It feels silly to me to use an external device when I have something that can generate the signal I need.
    In thinking about this post I might have solved my problem, at least in my head. I'm thinking I can move the TTL output VI (which I will eventually change to DAQmx) into the producer loop and move my true/false statements to the consumer loop as a 1D array within my queue to start the record. Probably more to it than that but I can only learn by experimentation right?
    Thoughts? Recommendations?
    VI attached. 
    Solved!
    Go to Solution.
    Attachments:
    HUCTA Controls.vi ‏186 KB

    You can't generate a pulse with the 9402 itself. The pulse would actually be generated by the 9188. You should create a Counter Output task to generate a pulse train. Try the attached example as a start point to experiment with the counter.
    This Vi is for LabVIEW 2013, if you have an older version let me know and I will try to convert it.
    Camilo V.
    Applications Engineer
    National Instruments
    www.ni.com/support
    Attachments:
    Pulse Train Generator.vi ‏18 KB

  • Producer consumer vs state machine

    Hi there,
    I have been on and around for quite a while to understand how can I re-design an application, which was originally built using a mix of sequence structure, while loops and event structures. And now I am making a newer version of the same application, for research purposes, while learning the LabVIEW techniques. Earlier I used LabVIEW versions 5 and 6 to make simple programs for fuzzy logic and neural networks. And that's not a good reference.
    Ok, after learning that Producer Consumer (PC) and Standard State Machines (SSM or SM) are two new approaches for a better (scalable, flexible and efficient) coding as suggest by veterans, in one thread where I asked about another issue, I have started digging into this topic and now I am on a point where I have to implement it finally (spent pretty much time in the learning phase).
    I have several questions.
    To start the discussion, I would give a brief description of my application.
    It's a networked application, where the network communication happens using DataSocket (one reason to use LabVIEW as the environment).
    We are talking about the client application, which communicates with other applications on remote computer, via Internet.
    User interface involves a tab control, with several pages-
    On startup, the controls/indicators (now onwards referred as controls only), are initialized, datasocket connection is checked (rather internet is checked, and a connection established with the remote datasocket server) (page 1)
    If connected to the datasocket server, the user selects Login/Registration (page 2)
    Login and/or Registration happen on page 3/4
    Then the user sees a table of remote users to connect to (page 5)
    Upon selection of a remote user, and after clicking on "connect", the user will see a video indicator, with a lot of other controls. (page 6)
    On this page with video indicator and controls, the user has a lot of activities, in which many messages are sent and received to/from the remote machine.
    the user may disconnect and go back to page 5, and log out and go back to page 2 and so on.
    I hope this is clear.
    I have thought about two different ways to do this application. Using PS or by SSM.
    In the attachments, I have given a diagram (with errors, of course, because of unlinked controls), for each of the approach, plus the original application's diagram.
    I hope this is sufficient for anybody to understand my case and give suggestions.
    I am looking for suggestions about which is a better model for my type of case. I have been to discussions like this one and saw that there are many issues regarding dequeue in PC model. So I am curious to know if SSM is a better and latest model or it's more primitive? Which looks better for my application's performance?
    Thanks ahead!
    Vaibhav
    Attachments:
    OldDesign.vi ‏41 KB
    PCDesign.vi ‏42 KB
    SSMDesign.vi ‏46 KB

    Vaibhav wrote:
    @ Harold
    Thanks. Any suggestion how can I start and stop that loop in parallel with other loops? Like, if some event occurs, the loop should start execution, and keep on moving, while other events are being traced and executed.
    In those examples where you had a while loop inside a case structure, that bit of code will only execute one time.  It will immediately read the boolean at the start of the program, if the value was true before the porgram started, then the while loop will run.  Once that while loop stops, the case structure will end.  It will never execute again unless you completely stop and restart your program.  If the boolean is false before the program starts, the false case will execute immediately.  Nothing happens since it is empty and it is done, never to run again (unless you stop and restart your VI)  You should turn the structure around.  Put the case structure in the while loop.  Make sure you put a small wait statement in the loop so that it doesn't run full speed eating up CPU cycles just polling the status of the boolean.
    @ Ravens
    Thanks for the detailed comment.
    One thing I would clarify. The user will not be able to switch between the pages using the tab control. The program will direct appropriate page to the user. I kept the tabs visible just for your idea of the pages. Sorry, I didn't mention that.
    Do you think it's still a bad design?
    If the tabs will be hidden or disabled, you will probably be okay.  I wouldn't call it a bad design.  I wouldn't do it that way.  But as long as you understand the possibility of problems and prevent that.  Especially some time down the road when you modify the program in some other way that could lead to a problem because you forgot about the dependencies of the event structures on the state of the state machine. 
    Yes, I agree about only one event structure to handle all the events. But since the user will not be able to click somewhere else, other than those possible controls, I thought to keep it like this.
    I thought the events are captured only if we are in that case. I think I am wrong, right? Events are captured at any time, even if the case has never executed before, or will never execute.  Ok, The events will be captured, but will not be executed until in that case.
    And that's the reason why I have two separate event structures, in two separate phases of the program.
    Because, prior to page 6, the events will occur sequencially. The user will click somewhere, then some message will be transmitted over DataSocket, then some message may come , then again some user action and so on. But, when the user starts using page 6, there will be parallel process of user controls events and actions, and incoming messages and corresponding actions. For this, in the page 6, I need a different kind of execution. So I separated the two event structures.
    At first I thought to have SSM, and then I thought to PC, just because I can have two separate parallel processes - one for user events, and another for messages (because that way I can take maximum advantage of message tracking). But looking at other complexities, I find SSM more appropriate. Can you please tell me how can I have my message loop and events loop parallel to each other and just one event structure?
    You can have a dequeue function in your state machine loop and have it be a consumer loop.  Use a timeout on the Dequeue.  If there is a timeout, have the statemachine execute normally after that perhaps just passing the enum wire straight into the case structure of the state machine.  If it doesn't timeout meaning you got a message, then look at the message that is dequeued and act on it.  Perhaps it means ignoring the enum coming in from the shift register and changing the enum to something else to feed into the case structure of the state machine.  Attached is an example
    Attachments:
    PCDesign[1]_BD.png ‏6 KB

  • Producer Consumer simultaneous operations at different frequencies

    My goal is to do two operations simultaneously.
    The desired end result is:
    1)      Produce an output signal which oscillates at a specified frequency (1 to 10 hz)(using DIO NI-9403). This signal will cause a solenoid to vibrate at different frequencies.
    2)      Monitor voltage on 3 lines in real-time (using analog input NI-9201). This will monitor system response to vibration.
    3)      Produce an output signal which oscillates at a different frequency from (1) – producing 1-second HI values 5 seconds apart. This will cause the system to “pulse”; system response will be monitored.
    4)      Have a front-panel user interface where: the signals in (2) can be monitored; frequency of (1) can be monitored and changed; and the output on (3) can be monitored and changed.
    My efforts so far have been to build a producer-consumer structure. This is my first time using this structure so I may be completely misunderstanding its use. Feel free to correct me if I’m way off target.
    The issue I have is the solenoid in the consumer loop (which handles item (1)) is not operating at the desired frequency. It is too slow. I used a 10ms timer for this loop, but instead it is operating about 1 cycle per second.
    There may be a much better way to approach this, or maybe my program only needs some minor tweaks. Either way, thanks in advance for your help.
    Attachments:
    ProdComsLoop Pulser 2-27-14.vi ‏65 KB

    Hi BradleyDDC,
    It seems from your program that you don't need a producer consumer loop. The only thing you are feeding from one loop to another can be put in one loop, I mean the simulator on button.
    The timer does not determine how fast the loop runs in real time. To get more precise timings, we recommend hardware timed operations as opposed to the software timed ones.
    Instead of using a digital output signal, you can use a counter output task, here is a knowledgebase, which has an example of what you may want.
    Paolo F.
    National Instruments
    Applications Engineer

  • Producer consumer error 200279

    Hello,
    So I’m about to go crazy and hoping someone can help me here. I’m writing a program that controls a motor and using a producer/consumer method to write the data at 10,000 intervals a second. I’ve read through multiple examples and I don’t see what I’m missing. I’m trying to record 18 different readings from a DAQ 9178, 3 readings for voltage module NI 9205, 1 reading for current module Ni 9203, 2 readings for accelerometer module Ni 9234 and 12 readings for temperature module 9213. Every time I run the program I keep getting the error message 200279 and it states that it’s trying to read samples that no longer exist. It advised me to increase the buffer rate. So I did as it suggested in multiple ways and the error messages keeps showing up. I’ve also shut down the computer, exited and restarted Labview several times and none of this worked. I have included the a picture file below.  Where the problem is, is in the producer loop and the error is shown coming out of the DAQ error indicator. One idea I had but I’m unsure how to approach it is to somehow mean the data coming out of the DAQ to reduce what’s getting to the buffer. If anyone knows how to fix this problem please explain it in detail (I mean talk to me like I’m stupid) cause I’ve been stuck on this problem for almost two weeks now. Thank you in advance to anyone who can help.
    SteelTiki  
    Solved!
    Go to Solution.

    The DAQ error isn't related to your choice of architecture, although your implementation of it might be hurting you.  It's almost impossible to follow what's going on in your diagram because you have wires running in many directions (try to keep data flowing from left to right), there are local variables all over the place (almost definitely not needed), and there's a lot of code that's not in the image or is hidden in another frame of the sequence.  Normally one would not have the event structure as the consumer loop (as you've done), and it's generally not a good idea to have multiple event structure in the same VI (with rare exceptions usually involving user events).  It might not solve your problem but it would be worth taking the time to clean up your diagram.  Eliminate sequence structures and local variables as much as possible, move some code into subVIs, and straighten out your wires.
    As for the DAQ error: the DAQ board is reading data into a circular buffer, and you're not reading it fast enough, so samples are being overwritten.  The reason you're not reading it fast enough is because you only read a single sample at a time (the DAQmx Read is configured for 1 sample on multiple channels) but you say you're acquiring 10,000 samples/second.  Since your loop won't run 10,000 times per second, you're not reading all the data, which causes the error.  Try configuring the DAQmx Read for multiple samples.

Maybe you are looking for

  • Extension list not showing in 16.0.2

    After upgrading to v16.0.2 my list of installed extensions is empty even though most (probably all) are still working, so I cannot manage them.

  • How do i uninstall gfx card status fix?

    I had a problem with GoToMeeting and they told me to install the gfxcardstatus fix. In the end the problem was because of another issue since I did fix but I also do not have more than one grafix card and so when my macbook pro boots up it tells me t

  • I can't run LR5 and EOS utility at the same time

    I'm running Mac OS 10.9.5, LR5.7 & Eos Utility 3. I can't run LR and Eos3 at the same time. Eos just crashes and have to force quit Eos. Any tips anyone? Do I have to downgrade to Eos2. Not a problem really I suppose.

  • Adobe Lightroom 3.3 BSOD

    Hey guys, About two weeks ago I installed the trial version of Adobe Photoshop Lightroom 3.3. I am loving it to death and am considering purchasing the program, although there is a major issue that is standing in my way. Since I installed, I have pro

  • After rendering a movie, the DVD project screen doesn't display

    Q. After rendering a movie, my DVD project screen won't display?