Producer/customer architecture sync

I built a producer/customer architecture type code and I ran into the problem that if the producer loops ends normally [because it produced the specified amount of data], it kills the queue as well so the consumer loop cannot output the data which is still in queue because the queue is destroyed - data is lost.
How is it possible to syncronise the two loops, how can I make the VI wait until the consumer empties the queue?
Thanks,
Krivan

Just out of curiosity:
as seen in the attached picture I moved the release queue VI from the producer loop to the consumer loop. This way I wanted to ensure that the queue is only released if the queue is empty. Now this implementation works according to the tests I have made so far and I don't use notifiers and the error handling is much easier.
Are there any drawbacks of my implementation? (Because in Felix's nugget various issues have been mentioned)
Attachments:
consumer.PNG ‏25 KB

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

  • 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

  • External reporting tool (Cognos) to produce customized reports from BPM 5.7

    Can I use external reporting tool (Cognos) to produce customized reports from BPM 5.7? Is it possible to query BPM DB for historical data (not BAM dashboard)?

    Hi Steve,
    From memory, I think you can just use ContactCallDetail and Resource. Just look for calls where originatorType = 1 (for agent) and originatorID = resourceID of the agent. So your where clause would look something like:
    WHERE
    originatorType = 1 AND
    originatorID = resourceID of the agent AND
    LEN(destinationDN) > 7
    Hope that helps.
    Cheers,
    Nathan

  • Functinal global variable for producer - consumer architecture

    Hi all,
    I am using a Producer - consumer architecture for my data acquistion as in the belwo diagram.. at some time i am stuck insde the while loop continously acquiring data .. is there any way i use one stop button as a functional gloabl variable and stop inside (consumer while loop) as well as producer architecture....
    Why i need this ?? so many design rules say that global variables are not a good idea...
    Thanks in advance...

    FGVs will work fine for your application.  You can also wire your error cluster to your stop button.  Your producer loop should throw an error 1 when the stop button is pressed, which will in turn stop your consumer loop.  But you would need a slightly different design for this.  Your consumer loop is designed to not advance until the stop button is pressed.  Instead of using and enum, you can use your producer loop to control the trigger to take a measurement.  No need for the while loop in the consumer loop this way.  You could set up your consumer loop to take a number of measurements, and then quit or take measurements for a certain amount of time.  Either way, you can stop your while loop when it times out.
    If you choose to stay with this design, a simple state machine archetecure might be better based on what I see.
    Reese, (former CLAD, future CLD)
    Some people call me the Space Cowboy!
    Some call me the gangster of love.
    Some people call me MoReese!
    ...I'm right here baby, right here, right here, right here at home

  • Custom ringtone sync error

    I have an window vista and i try to make an custom ringtone,and i got this message " Attempting to copy to the disk "<iPod name>" failed. An unknown error occurred (-54)."

    Thanks for the advice, carried out the instructions (twice to make sure I hadn't missed something) and sure enough, iTunes now actually shows the custom tones syncing on the 'action' bar at the top of the screen. However the tones still do not appear on my iPhone.
    Still, I am one step nearer thank you.

  • How do I set up a custom (local) Sync server for Firefox 4?

    I am having difficulty finding a clear set of instructions on how to set up a custom Sync server for Firefox 4. Most of the information that I can find seems outdated (only mentioning Weave and/or previous versions of Firefox).

    The URL you are looking for is https://wiki.mozilla.org/Labs/Weave/Sync/1.1/Setup

  • WHAT CANT MY CUSTOM RINGTONES SYNC WITH 2.0?

    I HAVE CUSTOM RINGTONES THAT I HAVE ON MY ITUNES... AND IT REFUSES TO SYNC WITH MY IPHONE AFTER I DID THE 2.0 UPGRADE...! ANYONE WITH THE SAME PROBLEM? THANKS

    yes i have over 100 ringtones on my itunes which i'd backed up from my iphone before the 2.0 upgrade.... and i can see it in itunes.... but when i sync it it doesnt transfer to my iphone...!
    2.0 *****... really

  • Problems with custom ringtone syncing after iOS update

    I recently updated the iOS to the latest version and it wiped out my custom ringtones.
    I resynced them but it only loaded three onto my phone.
    I then tried to delete them but when I synced again they were still there.
    I manually deleted the ringtones folder on the phone using ifunbox and they finally were deleted.
    Then when I tried to syc my ringtones back it only synced three (different three).
    Dragging and dropping isn't doing anything.

    Hello is anyone from Adobe out there? Is anyone from Adobe monitoring the forum? The 1.6 update has stopped the app from crashing when you were trying the sync function to the creative cloud.
    However, the sync function is not working as it did in the past. If you make a change in an already existing file in the Photoshop touch app and save it, the sync to the creative cloud results in an explanation point instead of a check to the left of the filename. Toggling the sync button on and off doesn't change the exclamation point to a check. The blue line goes across the file as it normally would when syncing but the explanation point remains. As a result, the changed file is not being synced with the creative cloud.
    I am not sure of the exact amount of time it takes, I am guessing about 24 hours. After about 24 hours when you do a sync, the file that had the explanation point to the left of it does change to a checkmark. However, you now have two files. One that reflects the change and has the word conflicted now added to the file name. As well as a file with the same name that doesn't reflect the change and no conflicted added to its file name.
    For me at least the sync function no longer causes the Photoshop touch app to crash. However, the 1.6 update also doesn't sync properly to the creative cloud.
    Making a change to a file in the Photoshop touch app and trying to sync it shouldn't result in the file not being synced or in a conflicted file. Could someone please help me in regard to this issue.

  • Producer/consumer architecture - timing

    Hello.
    I have some question about producer consumer pattern.
    People say that consumer shound NOT add elements into producer queue. Lets say that some states in in consumer need to stay active for eg 5 minutes. We also should be able to pause/resume state execution and exit program in any time. 
    I ve used functional global timer but consumer adds elements into queue and this should be avoided.
    How to solve timing problem? Some people have written about creating another thread - watchdog or asynchornous calls to vi...
    Could someone explain this to me?  :

    People have consumers add to their own queue all the time.  It is usually in a Queued State Machine though.  If you have a process that just needs to run for so long, then have the consumer run another while loop until the time is up.  It can then process the next item in the queue.
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines

  • Producer/consumer architecture over network variables with Real-Time target.

    Hi all,
    I am maintaining a producer/consumer data acquisition program to be deployed on a real-time target. The main code is deployed to and run on the real-time target during experiments, but was having trouble because the program was originally designed to write all experimental data to disk on the real time during acquisition, which puts the whole experiment at the mercy of the hard drive. I am now trying to rework the code so that the host takes care of logging, so that my time-critical loops don't have to wait.
    I am currently using LabVIEW 8.5
    I have two questions:
    First, how can I programmatically call the data-logging subvi on the host so that it runs in parallel with the main vi which runs the experiment and collects data on the real-time? I have attached the test code that I have been working with to figure this out, but it does not run the logging vi continuously in the background. I am aware that there is better functionality for this in newer versions of LabVIEW, but I would prefer not to upgrade unless there is no other option. I would like to be able to run my data-generating vi and have it start the data logging remotely.
    Second, is there a way in the host VI to read values off the network variable using an event structure rather than polling it for updates?
    Any help would be sincerely appreciated!
    Attachments:
    testRemoteLogging.zip ‏124 KB

    VI server
    Mark the target VI as served on the machine on which it will execute and use VI server Call by reference to invoke the served VI.
    This used to be taught as THE way to communicate syncronously with an RT app.
    Ben
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction

  • State machine VS producer consumer architecture - Time Analysis

    After learning various methods to program efficiently and learn how to use SM and Producer consumer. I built a program to control stepper motor in both these techniques.
    Here is the RESULT. As we can see a simple state machine without any complicated producer consumer technique performs faster than the second one.
    I am not sure which is still the best based on performance and optimization. Please advise which one should I keep and why.
    Abhilash S Nair
    Research Assistant @ Photonic Devices and Systems lab
    [ LabView professional Development System - Version 11.0 - 32-bit ]
    LabView Gear:
    1. NI PXI-7951R & NI 5761
    2. The Imaging Source USB 3.0 monochrome camera with trigger : DMK 23UM021
    OPERATING SYSTEM - [ MS windows 7 Home Premium 64-bit SP-1 ]
    CPU - [Intel Core i7-2600 CPU @ 3.40Ghz ]
    MEMORY - [ 16.0 GB RAM ]
    GPU - [ NVIDIA GeForce GT 530 ]

    This is with state machine alone
    Abhilash S Nair
    Research Assistant @ Photonic Devices and Systems lab
    [ LabView professional Development System - Version 11.0 - 32-bit ]
    LabView Gear:
    1. NI PXI-7951R & NI 5761
    2. The Imaging Source USB 3.0 monochrome camera with trigger : DMK 23UM021
    OPERATING SYSTEM - [ MS windows 7 Home Premium 64-bit SP-1 ]
    CPU - [Intel Core i7-2600 CPU @ 3.40Ghz ]
    MEMORY - [ 16.0 GB RAM ]
    GPU - [ NVIDIA GeForce GT 530 ]
    Attachments:
    Control 1.ctl ‏6 KB
    Control 2.ctl ‏6 KB
    Motor-UNI_Directiona Dev 3-TIME_ANALYSIS-2.vi ‏54 KB

  • Database producer consumer architecture

    Dear NI supporters,
    I am trying to devolope Producer/Consumer program to communicate with MS SQL database.
    The Producer loop select data from database1 and process them.The Consumer loop insert proccesed data to database2.
    The problem is, fast Producer loop must wait for slow Consumer loop and I have no idea why.
    I have attached really simplified VI. There are two parallel processes (while loops). First loop read large data and the execution time is high. The second loop read really small data, so execution time is low. So if I execute the VI, I would expect the fast while loop (FAST PROCESS) will get much more iterations then the slow one (SLOW PROCESS). But the reallity is, the FAST PROCESS will get the same number of iteration as SLOW PROCESS. It looks like the processes don´t run in parallel or did I just missed something?
    Could you explain me, why this occur, and how can I improve my code?
    Thanks in advance.

    vasicekv wrote:
    Thank you Jim, it really helps me!
    Do you also know any other library to communicate with database in labview which is reentrant?
    I mean I am focused on speed my labview-databse communcation up.
    Perhaps you should be considering why your consumer loop is so slow?  Is your database running on a dedicated server?  Is it getting bogged down?
    Please share a little of your real code so we can try to improve the performance of your consumer loop.

  • 2 producers/ 1 consumer for a Producer/Consumer Architecture

    I am trying to aquire two seperate tasks (one with analog and one with digital signals).  The digital signal needs to be aquired at a much higher rate (10 times higher).  The data from both of these aquisitions is required for writing to the same file and doing calculations.  I was wondering if it is possible to use 2 Producer loops and 1 Consumer loop?  I would need to use an enqueue in each producer loop and then dequeue them both in the consumer loop.  Will this work?
    Thanks.
    --Robert

    knapkerd wrote:
    I am trying to aquire two separate tasks (one with analog and one with digital signals).  The digital signal needs to be aquired at a much higher rate (10 times higher).  The data from both of these aquisitions is required for writing to the same file and doing calculations.  I was wondering if it is possible to use 2 Producer loops and 1 Consumer loop?  I would need to use an enqueue in each producer loop and then dequeue them both in the consumer loop.  Will this work?
    Thanks.
    --Robert
    Certainly.  You can  pass the reference wire for the queue you obtained into 2 different producer loops where you enqueue your data.  The same wire will pass into the consumer loop where you dequeue your data.  Of course with this method, you have no control over which loop puts its data into the queue first.
    It really comes down to what you are going to do with the data once you get it into the consumer loop.  Do you just want to write the data as you get it? What do you do with the calculations,  if you get 8 or 9 pieces of data from the one producer, then get a piece from the other producer, then get 11-12 pieces from the first producer, do you just hold on to the previous values from the older slower loop?
    Do you want to do this with 2 different queues?  If so, you may need to put some timeout functions on your dequeue functions in your consumer loop otherwise it will only run as fast as it gets the data from the slower queue.
    Message Edited by Ravens Fan on 05-07-2008 11:38 PM

  • Custom image from Address book not syncing to Exchange.

    I am running Mac OS X v 10.7.5. I have added custom images to contacts in address book. I have an Exchange account which will sync the data (ie name, address, email) but not the custom image. Is there away to have custom images sync to Exchange/Outlook?

    I'm Running Mac OS X Lion, and have seen that changes made in the mac address book do not sync to gmail contacts but changes to gmail contacts do sync to the mac address book.
    Making a change to a contact on my phone does sync to gmail contacts, and then to the mac address book.
    Another test I ran was to change the same contact in gmail and mac address book.  I made a change to a mobile number and notes in one contact on my mac address book, attempted to sync, and the change does not appear in my gmail contacts.  I tried multiple times, restarted my web browser, restarted mac address book, the sync would not work.  I changed the same contact mobile number in gmail with a slightly different change to the notes field so I could see when an update occurred, and when I told mac address book to sync it recognized a conflict. When I select the mac address book change to resolve the conflict, the gmail contact is not updated.  When I repeated the experiment and selected the gmail contact to resolve the conflict the change is made in the mac address book.

Maybe you are looking for

  • Error in posting gr

    hi i m doing gr in migo...while posting i get this error msg. how do i go ariund with this ...find the error below.. ''No authorization for posting period 010 2009 Message no. F5A094 Diagnosis Period 010 in fiscal year 2009 is open for posting for th

  • Mysterious lack of free disk space

    Recently im having a problem with my free disk space disappearing in osx.  running a du command shows a 90GB file usage in my /Library directory, but i cant seem to find or access it anywhere i enabled hidden files also ran sudo tmutil disablelocal m

  • How much to repair iphone4 screen?

    How much would it be to repair/replace a front screen on an iphone 4?

  • Problem in Decimal Rounding in FMS Query

    Dear All, When an FMS is executed and if the result is 8.6760 (Desired result) but the actual result shown in SAP is 8.6800. And please note that I have fixed the decimal places to 4. Y is my FMS not giving the correct output (without the rounding).

  • Allocation against outstanding PO

    Dear Experts, I want to know the way i will be able to find the Existance of allocation against Outstanding PO in SAP. Regards