<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to know how manv times the dequeue element function is called? in LabVIEW</title>
    <link>https://ni.lithium.com/t5/LabVIEW/How-to-know-how-manv-times-the-dequeue-element-function-is/m-p/4379722#M1288198</link>
    <description>&lt;P&gt;In a Producer/Consumer design, the Producer "produces", and is "responsible" for controlling (and&amp;nbsp;&lt;U&gt;counting&lt;/U&gt;, if that's important) the things being "produced".&amp;nbsp; The Producer is&amp;nbsp;&lt;U&gt;also&lt;/U&gt; responsible for knowing when Production is done (since the Producer "gets the data first").&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The Consumer has no idea when the data will be coming, but knows to process it&amp;nbsp;&lt;U&gt;as it comes&lt;/U&gt;, until it gets a sign from the Producer that "Production is done", in which case the Consumer can stop waiting for more data and close whatever it is doing with the data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So, the Producer simply counts 1, 2, 3, ... until it gets to 100 (or, if you are doing this in a For Loop, the Producer has 100 written to the "N" of the For loop).&amp;nbsp; When it is done, it sends a "signal" (called a "sentinel") to the Consumer saying "I'm Done".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Until 2016, LabVIEW handled Producer/Consumer Designs with Queues.&amp;nbsp; You enqueue 100 "elements" in the Producer and it goes to the Consumer.&amp;nbsp; How do you signal you are done?&amp;nbsp; NI seems to do this by having the Producer releasing the Queue, which causes the Consumer to throw an Error.&amp;nbsp; Bad!&amp;nbsp; Better is for the Producer to Enqueue One More Time and send a Sentinel.&amp;nbsp; Since a frequent quantity being passed in P/C designs are Arrays of Data, a great Sentinel is an Empty Array.&amp;nbsp; The Producer exits the For Loop (bring the Queue with it), and enqueues an Empty Array.&amp;nbsp; The Consumer is modified so when it Dequeues, it checks for the Sentinel (Empty Array? function) and uses a Case Statement to Process Data if False (meaning Not Empty Array) or Releasing the Queue (safely!) and stopping the Consumer Loop if True.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In 2016, LabVIEW got Asynchronous Channel Wires.&amp;nbsp; The Stream Channel is what you use for Producer/Consumer.&amp;nbsp; No more "data wire going backwards".&amp;nbsp; It also has "Element Valid?" and "Last Element?" inputs in the Channel Writer (Producer), ideal for signaling the same to the Channel Reader (Consumer).&amp;nbsp; Best of all, you only need Writer and Reader, as Writer also does "Obtain Stream" and Reader will do "Release Stream" when it gets "Last Element" is true.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Bob Schor&lt;/P&gt;</description>
    <pubDate>Wed, 19 Jun 2024 02:16:14 GMT</pubDate>
    <dc:creator>Bob_Schor</dc:creator>
    <dc:date>2024-06-19T02:16:14Z</dc:date>
    <item>
      <title>How to know how manv times the dequeue element function is called?</title>
      <link>https://ni.lithium.com/t5/LabVIEW/How-to-know-how-manv-times-the-dequeue-element-function-is/m-p/4379596#M1288140</link>
      <description>&lt;P&gt;Hey, I'm developing a producer-consumer VI and I want to stop both loops when I dequeue 100 elements. How can I count how many elements have been dequeued or how many times the dequeue element function was called?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Could you help me please? Thankss&lt;/P&gt;</description>
      <pubDate>Tue, 18 Jun 2024 13:04:37 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW/How-to-know-how-manv-times-the-dequeue-element-function-is/m-p/4379596#M1288140</guid>
      <dc:creator>euqinom2727</dc:creator>
      <dc:date>2024-06-18T13:04:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to know how manv times the dequeue element function is called?</title>
      <link>https://ni.lithium.com/t5/LabVIEW/How-to-know-how-manv-times-the-dequeue-element-function-is/m-p/4379599#M1288142</link>
      <description>&lt;P&gt;You can use the iteration counter to count to 99 (value of 99 since it is zero-based).&lt;/P&gt;</description>
      <pubDate>Tue, 18 Jun 2024 13:13:52 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW/How-to-know-how-manv-times-the-dequeue-element-function-is/m-p/4379599#M1288142</guid>
      <dc:creator>billko</dc:creator>
      <dc:date>2024-06-18T13:13:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to know how manv times the dequeue element function is called?</title>
      <link>https://ni.lithium.com/t5/LabVIEW/How-to-know-how-manv-times-the-dequeue-element-function-is/m-p/4379611#M1288147</link>
      <description>&lt;P&gt;Unless you're enqueuing from multiple producers, I think it'd be smarter to count on the producer side and stop enqueuing when you get to 100.&amp;nbsp; That's more in the spirit of the producer / consumer pattern where the producer's job is to *defer* the needed work and the consumer's job is to complete it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;-Kevin P&lt;/P&gt;</description>
      <pubDate>Tue, 18 Jun 2024 13:30:00 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW/How-to-know-how-manv-times-the-dequeue-element-function-is/m-p/4379611#M1288147</guid>
      <dc:creator>Kevin_Price</dc:creator>
      <dc:date>2024-06-18T13:30:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to know how manv times the dequeue element function is called?</title>
      <link>https://ni.lithium.com/t5/LabVIEW/How-to-know-how-manv-times-the-dequeue-element-function-is/m-p/4379614#M1288149</link>
      <description>&lt;P&gt;I did this actually, but when I see my tdms file I don't have 50 elements, I have 0. So I assumed that the consumer loop is called without any elements on the queue or something like that.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="euqinom2727_0-1718717988138.png" style="width: 400px;"&gt;&lt;img src="https://ip1.i.lithium.com/b647076a43ff2d4be2727ac429cb9110ed0b0136/68747470733a2f2f6e692e6c69746869756d2e636f6d2f74352f696d6167652f736572766572706167652f696d6167652d69642f33333435343769314130454533373635364130454331372f696d6167652d73697a652f6d656469756d3f763d76322670783d343030" role="button" title="euqinom2727_0-1718717988138.png" alt="euqinom2727_0-1718717988138.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 18 Jun 2024 13:39:56 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW/How-to-know-how-manv-times-the-dequeue-element-function-is/m-p/4379614#M1288149</guid>
      <dc:creator>euqinom2727</dc:creator>
      <dc:date>2024-06-18T13:39:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to know how manv times the dequeue element function is called?</title>
      <link>https://ni.lithium.com/t5/LabVIEW/How-to-know-how-manv-times-the-dequeue-element-function-is/m-p/4379625#M1288155</link>
      <description>&lt;P&gt;If the &lt;EM&gt;timed out?&lt;/EM&gt; output of the Dequeue Element function is true, you have no data, so there is nothing to save.&lt;/P&gt;
&lt;P&gt;Also, you should not use a null timeout, as the loop would spin too fast even if there are no data.&lt;/P&gt;</description>
      <pubDate>Tue, 18 Jun 2024 14:13:36 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW/How-to-know-how-manv-times-the-dequeue-element-function-is/m-p/4379625#M1288155</guid>
      <dc:creator>pincpanter</dc:creator>
      <dc:date>2024-06-18T14:13:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to know how manv times the dequeue element function is called?</title>
      <link>https://ni.lithium.com/t5/LabVIEW/How-to-know-how-manv-times-the-dequeue-element-function-is/m-p/4379633#M1288160</link>
      <description>&lt;P&gt;It seems that the timed out? it's never true, so I always have data, so my theory is not true. I could count how many times I write to the file, but I don't know how to do it either&lt;/P&gt;</description>
      <pubDate>Tue, 18 Jun 2024 14:55:14 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW/How-to-know-how-manv-times-the-dequeue-element-function-is/m-p/4379633#M1288160</guid>
      <dc:creator>euqinom2727</dc:creator>
      <dc:date>2024-06-18T14:55:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to know how manv times the dequeue element function is called?</title>
      <link>https://ni.lithium.com/t5/LabVIEW/How-to-know-how-manv-times-the-dequeue-element-function-is/m-p/4379722#M1288198</link>
      <description>&lt;P&gt;In a Producer/Consumer design, the Producer "produces", and is "responsible" for controlling (and&amp;nbsp;&lt;U&gt;counting&lt;/U&gt;, if that's important) the things being "produced".&amp;nbsp; The Producer is&amp;nbsp;&lt;U&gt;also&lt;/U&gt; responsible for knowing when Production is done (since the Producer "gets the data first").&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The Consumer has no idea when the data will be coming, but knows to process it&amp;nbsp;&lt;U&gt;as it comes&lt;/U&gt;, until it gets a sign from the Producer that "Production is done", in which case the Consumer can stop waiting for more data and close whatever it is doing with the data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So, the Producer simply counts 1, 2, 3, ... until it gets to 100 (or, if you are doing this in a For Loop, the Producer has 100 written to the "N" of the For loop).&amp;nbsp; When it is done, it sends a "signal" (called a "sentinel") to the Consumer saying "I'm Done".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Until 2016, LabVIEW handled Producer/Consumer Designs with Queues.&amp;nbsp; You enqueue 100 "elements" in the Producer and it goes to the Consumer.&amp;nbsp; How do you signal you are done?&amp;nbsp; NI seems to do this by having the Producer releasing the Queue, which causes the Consumer to throw an Error.&amp;nbsp; Bad!&amp;nbsp; Better is for the Producer to Enqueue One More Time and send a Sentinel.&amp;nbsp; Since a frequent quantity being passed in P/C designs are Arrays of Data, a great Sentinel is an Empty Array.&amp;nbsp; The Producer exits the For Loop (bring the Queue with it), and enqueues an Empty Array.&amp;nbsp; The Consumer is modified so when it Dequeues, it checks for the Sentinel (Empty Array? function) and uses a Case Statement to Process Data if False (meaning Not Empty Array) or Releasing the Queue (safely!) and stopping the Consumer Loop if True.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In 2016, LabVIEW got Asynchronous Channel Wires.&amp;nbsp; The Stream Channel is what you use for Producer/Consumer.&amp;nbsp; No more "data wire going backwards".&amp;nbsp; It also has "Element Valid?" and "Last Element?" inputs in the Channel Writer (Producer), ideal for signaling the same to the Channel Reader (Consumer).&amp;nbsp; Best of all, you only need Writer and Reader, as Writer also does "Obtain Stream" and Reader will do "Release Stream" when it gets "Last Element" is true.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Bob Schor&lt;/P&gt;</description>
      <pubDate>Wed, 19 Jun 2024 02:16:14 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW/How-to-know-how-manv-times-the-dequeue-element-function-is/m-p/4379722#M1288198</guid>
      <dc:creator>Bob_Schor</dc:creator>
      <dc:date>2024-06-19T02:16:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to know how manv times the dequeue element function is called?</title>
      <link>https://ni.lithium.com/t5/LabVIEW/How-to-know-how-manv-times-the-dequeue-element-function-is/m-p/4379989#M1288341</link>
      <description>&lt;P&gt;Nice, I used the stream channel and it worked, thank u&lt;/P&gt;</description>
      <pubDate>Thu, 20 Jun 2024 12:56:51 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW/How-to-know-how-manv-times-the-dequeue-element-function-is/m-p/4379989#M1288341</guid>
      <dc:creator>euqinom2727</dc:creator>
      <dc:date>2024-06-20T12:56:51Z</dc:date>
    </item>
  </channel>
</rss>

