<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: LabVIEW Queued State Machine Architecture</title>
	<atom:link href="http://expressionflow.com/2007/10/01/labview-queued-state-machine-architecture/feed/" rel="self" type="application/rss+xml" />
	<link>http://expressionflow.com/2007/10/01/labview-queued-state-machine-architecture/</link>
	<description>LabVIEW and visual programming blog</description>
	<lastBuildDate>Sun, 07 Mar 2010 19:26:05 -0600</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: LabBEAN</title>
		<link>http://expressionflow.com/2007/10/01/labview-queued-state-machine-architecture/comment-page-1/#comment-6992</link>
		<dc:creator>LabBEAN</dc:creator>
		<pubDate>Tue, 12 Jan 2010 23:20:39 +0000</pubDate>
		<guid isPermaLink="false">http://expressionflow.com/2007/10/01/labview-queued-state-machine-architecture/#comment-6992</guid>
		<description>Hi Anthony,

Let&#039;s say one of the producers (see the red &quot;4.1&quot; in Figure 2 above) enqueues states on the opposite end to the consumer (see the red &quot;3&quot; in Figure 2 above).  When the first state is enqueued, then the consumer will immediately dequeue it because the consumer is waiting to dequeue an element.  If you enqueue the elements in reverse order (which I agree *of course* that reversing the order first is necessary since they are each being enqueued on opposite end), then the elements will run in the order &quot;last&quot;, &quot;first&quot;, &quot;second&quot;, &quot;third&quot;, &quot;...&quot;, &quot;next to last&quot;.  You need to enqueue a dummy element on opposite end first.

Note:  This is not the case when enqueueing within the same consumer (because of data flow) or for any future elements after the first element enqueued on opposite end when enqueueing from producer to consumer (as long as the Q MGR [see red &quot;1.5&quot; in Figure 2] is non-reentrant).

Please reread my previous post.

Take care,
Jason</description>
		<content:encoded><![CDATA[<p>Hi Anthony,</p>
<p>Let&#8217;s say one of the producers (see the red &#8220;4.1&#8243; in Figure 2 above) enqueues states on the opposite end to the consumer (see the red &#8220;3&#8243; in Figure 2 above).  When the first state is enqueued, then the consumer will immediately dequeue it because the consumer is waiting to dequeue an element.  If you enqueue the elements in reverse order (which I agree *of course* that reversing the order first is necessary since they are each being enqueued on opposite end), then the elements will run in the order &#8220;last&#8221;, &#8220;first&#8221;, &#8220;second&#8221;, &#8220;third&#8221;, &#8220;&#8230;&#8221;, &#8220;next to last&#8221;.  You need to enqueue a dummy element on opposite end first.</p>
<p>Note:  This is not the case when enqueueing within the same consumer (because of data flow) or for any future elements after the first element enqueued on opposite end when enqueueing from producer to consumer (as long as the Q MGR [see red "1.5" in Figure 2] is non-reentrant).</p>
<p>Please reread my previous post.</p>
<p>Take care,<br />
Jason</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Anthony Lukindo</title>
		<link>http://expressionflow.com/2007/10/01/labview-queued-state-machine-architecture/comment-page-1/#comment-6991</link>
		<dc:creator>Anthony Lukindo</dc:creator>
		<pubDate>Mon, 11 Jan 2010 05:26:23 +0000</pubDate>
		<guid isPermaLink="false">http://expressionflow.com/2007/10/01/labview-queued-state-machine-architecture/#comment-6991</guid>
		<description>Hi LabBEAN:

The need to reverse the order of multiple events added to the front of the queue is correct. This is implemented in Figure 9 of the article. Notice the &#039;Reverse 1D array node.&#039; Thus events are always reversed by the queue manager subVI when added to the front of the queue.</description>
		<content:encoded><![CDATA[<p>Hi LabBEAN:</p>
<p>The need to reverse the order of multiple events added to the front of the queue is correct. This is implemented in Figure 9 of the article. Notice the &#8216;Reverse 1D array node.&#8217; Thus events are always reversed by the queue manager subVI when added to the front of the queue.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: LabBEAN</title>
		<link>http://expressionflow.com/2007/10/01/labview-queued-state-machine-architecture/comment-page-1/#comment-6989</link>
		<dc:creator>LabBEAN</dc:creator>
		<pubDate>Wed, 06 Jan 2010 20:42:49 +0000</pubDate>
		<guid isPermaLink="false">http://expressionflow.com/2007/10/01/labview-queued-state-machine-architecture/#comment-6989</guid>
		<description>As I mentioned here:
http://decibel.ni.com/content/message/11700#11700

Regarding the implementation of enqueueing on opposite end (front of the queue):  When you enqueue multiple items on the opposite end to another loop which is waiting to dequeue elements [where execution order is critical (e.g. State 1, State 2, State 3, State 4)], the waiting loop will dequeue and run State 4 first.  Here&#039;s why:  Before enqueueing the 4 states on the opposite end, you must first reverse their order.  When another loop is waiting to dequeue, it grabs the first item you enqueue (e.g. State 4).  It&#039;s not a concern that it grab subsequent items, regardless of execution speed, since all loops share the same non-reentrant Queue Manager, and the only instance of the Queue Manager is busy enqueueing the next three states (in this example).  Therefore, you could end up with an execution order of State 4, State 1, State 2, State 3.  So, I would suggest enqueueing a dummy state before enqueueing on opposite end your states in reverse order.

Else, odd behaviour can occur (e.g. Stop state occurs before Power Supply Off state *ouch*).</description>
		<content:encoded><![CDATA[<p>As I mentioned here:<br />
<a href="http://decibel.ni.com/content/message/11700#11700" rel="nofollow">http://decibel.ni.com/content/message/11700#11700</a></p>
<p>Regarding the implementation of enqueueing on opposite end (front of the queue):  When you enqueue multiple items on the opposite end to another loop which is waiting to dequeue elements [where execution order is critical (e.g. State 1, State 2, State 3, State 4)], the waiting loop will dequeue and run State 4 first.  Here&#8217;s why:  Before enqueueing the 4 states on the opposite end, you must first reverse their order.  When another loop is waiting to dequeue, it grabs the first item you enqueue (e.g. State 4).  It&#8217;s not a concern that it grab subsequent items, regardless of execution speed, since all loops share the same non-reentrant Queue Manager, and the only instance of the Queue Manager is busy enqueueing the next three states (in this example).  Therefore, you could end up with an execution order of State 4, State 1, State 2, State 3.  So, I would suggest enqueueing a dummy state before enqueueing on opposite end your states in reverse order.</p>
<p>Else, odd behaviour can occur (e.g. Stop state occurs before Power Supply Off state *ouch*).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: harbenger</title>
		<link>http://expressionflow.com/2007/10/01/labview-queued-state-machine-architecture/comment-page-1/#comment-6988</link>
		<dc:creator>harbenger</dc:creator>
		<pubDate>Sun, 27 Dec 2009 04:59:41 +0000</pubDate>
		<guid isPermaLink="false">http://expressionflow.com/2007/10/01/labview-queued-state-machine-architecture/#comment-6988</guid>
		<description>I agree with everything you say. However, my concern was centered around the management of the queue. In order to completely flush the queue, you either need to have states with no next-state enqueues (which will have a net loss in the queue size) or manually flush the queue. The idle state has a zero net loss of the queue size.

Consider my example again. You have two idle-like loops which place default next-state commands into the queue. Likewise, you have two events which allow you to switch between loops. Each state by itself will not change the size of your queue. However, your queue will continue to fill up with unserviced next-state requests as you switch between states. This is true because the event loop is the primary producer of queue elements and the consumer loop has a net zero loss.

You can confirm this by adding queue status VI&#039;s either in-loop or as a separate loop.

I was able to fix this by adding more functionality to your Q Manager.vi. I&#039;m not completely sold on it being complete, but the idea is as follows: Define a &#039;default&#039; next state transition as a boolean input. Only add the default next-state element to the queue if your queue is empty. Otherwise, don&#039;t add it. This will fix the always increasing queue size problem.</description>
		<content:encoded><![CDATA[<p>I agree with everything you say. However, my concern was centered around the management of the queue. In order to completely flush the queue, you either need to have states with no next-state enqueues (which will have a net loss in the queue size) or manually flush the queue. The idle state has a zero net loss of the queue size.</p>
<p>Consider my example again. You have two idle-like loops which place default next-state commands into the queue. Likewise, you have two events which allow you to switch between loops. Each state by itself will not change the size of your queue. However, your queue will continue to fill up with unserviced next-state requests as you switch between states. This is true because the event loop is the primary producer of queue elements and the consumer loop has a net zero loss.</p>
<p>You can confirm this by adding queue status VI&#8217;s either in-loop or as a separate loop.</p>
<p>I was able to fix this by adding more functionality to your Q Manager.vi. I&#8217;m not completely sold on it being complete, but the idea is as follows: Define a &#8216;default&#8217; next state transition as a boolean input. Only add the default next-state element to the queue if your queue is empty. Otherwise, don&#8217;t add it. This will fix the always increasing queue size problem.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Anthony Lukindo</title>
		<link>http://expressionflow.com/2007/10/01/labview-queued-state-machine-architecture/comment-page-1/#comment-6987</link>
		<dc:creator>Anthony Lukindo</dc:creator>
		<pubDate>Thu, 24 Dec 2009 04:16:14 +0000</pubDate>
		<guid isPermaLink="false">http://expressionflow.com/2007/10/01/labview-queued-state-machine-architecture/#comment-6987</guid>
		<description>Harbenger:

Just wanted to comment on the idle state case. Note that the idle event is added at the end of the array build node. This means that any events added to the array build node, prior to the idle event, will run first. 

Also, the idle event should only be added in the idle case to indicate an eventual return to that case for polling or looping purposes. Alternatively you can omit adding the idle event to keep the program &#039;silent&#039; so that it only wakes-up and acts when some new event is added to queue.

Finally, take note that as you add events to the queue in other cases you have the option of adding them to the &#039;front of the queue&#039; so that they get executed immediately. This means that the event will be jumping the queue and will be immediately de-queued for execution.


I hope this further clarifies things</description>
		<content:encoded><![CDATA[<p>Harbenger:</p>
<p>Just wanted to comment on the idle state case. Note that the idle event is added at the end of the array build node. This means that any events added to the array build node, prior to the idle event, will run first. </p>
<p>Also, the idle event should only be added in the idle case to indicate an eventual return to that case for polling or looping purposes. Alternatively you can omit adding the idle event to keep the program &#8217;silent&#8217; so that it only wakes-up and acts when some new event is added to queue.</p>
<p>Finally, take note that as you add events to the queue in other cases you have the option of adding them to the &#8216;front of the queue&#8217; so that they get executed immediately. This means that the event will be jumping the queue and will be immediately de-queued for execution.</p>
<p>I hope this further clarifies things</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: harbenger</title>
		<link>http://expressionflow.com/2007/10/01/labview-queued-state-machine-architecture/comment-page-1/#comment-6985</link>
		<dc:creator>harbenger</dc:creator>
		<pubDate>Wed, 23 Dec 2009 04:07:39 +0000</pubDate>
		<guid isPermaLink="false">http://expressionflow.com/2007/10/01/labview-queued-state-machine-architecture/#comment-6985</guid>
		<description>This is a very interesting concept, and I&#039;m definitely new to the game. My question is in regards to managing the state queue. Take, for example, figure 13. An &quot;idle&quot; event was dequeued in order to get to the &quot;idle&quot; state. In the idle state, another &quot;idle&quot; queue is added. If another state transition is added to the queue by the producer loop, we now have two entries in the queue. If, in the new state, we enqueue another idle command, the queue will have two &quot;idle&quot; states. The current design doesn&#039;t account for two simultaneous idle entries.

All I&#039;m trying to say is that I am concerned about poor queue management when the consumer loop creates next state logic. It is very possible to create queue entries which will never be serviced. 

Any thoughts?</description>
		<content:encoded><![CDATA[<p>This is a very interesting concept, and I&#8217;m definitely new to the game. My question is in regards to managing the state queue. Take, for example, figure 13. An &#8220;idle&#8221; event was dequeued in order to get to the &#8220;idle&#8221; state. In the idle state, another &#8220;idle&#8221; queue is added. If another state transition is added to the queue by the producer loop, we now have two entries in the queue. If, in the new state, we enqueue another idle command, the queue will have two &#8220;idle&#8221; states. The current design doesn&#8217;t account for two simultaneous idle entries.</p>
<p>All I&#8217;m trying to say is that I am concerned about poor queue management when the consumer loop creates next state logic. It is very possible to create queue entries which will never be serviced. </p>
<p>Any thoughts?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Peter</title>
		<link>http://expressionflow.com/2007/10/01/labview-queued-state-machine-architecture/comment-page-1/#comment-6960</link>
		<dc:creator>Peter</dc:creator>
		<pubDate>Tue, 27 Oct 2009 01:32:56 +0000</pubDate>
		<guid isPermaLink="false">http://expressionflow.com/2007/10/01/labview-queued-state-machine-architecture/#comment-6960</guid>
		<description>Hi folks,

I have successfully used this specific QSM architecture for a relatively large application and was mostly happy with how things turned out.

Today I read the following comment from an NI employee about using User Events instead of QSMs.  What do others think ? Does the proposed alternative below have any downsides compared with QSMs ?

http://pasquarette.wordpress.com/2009/09/

&quot;The powerful thing about User-Defined events is that a developer gets to dictate what information gets sent to that event via the event’s internal terminals. A very simple example of this is: you can create an event called “save”, which has a path attribute. When the event gets called, the path attribute can be accessed using that events terminals, and the application can save its state at the path given. It is the caller of the event who would have gotten to specify what path to provide. Old and alternative ways of doing this was to use a LabVIEW Queue, who’s elements would either be a cluster of the data you wanted to pass around, or a variant so that anything could be passed. Both of these techniques have issues. One places a burden on the type of data that can be passed in the cluster, the other places the burden on the receiver of the data to extract it from the variant. The event structure removes both of these burdens by allowing each event type to have different data passed to them, and by giving direct access to that data within the event case via the internal terminals.&quot;


regards

Peter Badcock
Product Development
ResMed Ltd</description>
		<content:encoded><![CDATA[<p>Hi folks,</p>
<p>I have successfully used this specific QSM architecture for a relatively large application and was mostly happy with how things turned out.</p>
<p>Today I read the following comment from an NI employee about using User Events instead of QSMs.  What do others think ? Does the proposed alternative below have any downsides compared with QSMs ?</p>
<p><a href="http://pasquarette.wordpress.com/2009/09/" rel="nofollow">http://pasquarette.wordpress.com/2009/09/</a></p>
<p>&#8220;The powerful thing about User-Defined events is that a developer gets to dictate what information gets sent to that event via the event’s internal terminals. A very simple example of this is: you can create an event called “save”, which has a path attribute. When the event gets called, the path attribute can be accessed using that events terminals, and the application can save its state at the path given. It is the caller of the event who would have gotten to specify what path to provide. Old and alternative ways of doing this was to use a LabVIEW Queue, who’s elements would either be a cluster of the data you wanted to pass around, or a variant so that anything could be passed. Both of these techniques have issues. One places a burden on the type of data that can be passed in the cluster, the other places the burden on the receiver of the data to extract it from the variant. The event structure removes both of these burdens by allowing each event type to have different data passed to them, and by giving direct access to that data within the event case via the internal terminals.&#8221;</p>
<p>regards</p>
<p>Peter Badcock<br />
Product Development<br />
ResMed Ltd</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Architecting an Application to Avoid Spaghetti &#171; Software Engineering for LabVIEW</title>
		<link>http://expressionflow.com/2007/10/01/labview-queued-state-machine-architecture/comment-page-1/#comment-6900</link>
		<dc:creator>Architecting an Application to Avoid Spaghetti &#171; Software Engineering for LabVIEW</dc:creator>
		<pubDate>Fri, 03 Apr 2009 16:11:48 +0000</pubDate>
		<guid isPermaLink="false">http://expressionflow.com/2007/10/01/labview-queued-state-machine-architecture/#comment-6900</guid>
		<description>[...] also recommend visiting expressionflow.com. Anthony Lukindo wrote an excellent, indepth article on the QSM-PC (Queued State Machine - Producer / Consumer) design pattern, which is a fairly common and very [...]</description>
		<content:encoded><![CDATA[<p>[...] also recommend visiting expressionflow.com. Anthony Lukindo wrote an excellent, indepth article on the QSM-PC (Queued State Machine &#8211; Producer / Consumer) design pattern, which is a fairly common and very [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Great Resource for Learning a Common Architecture for LabVIEW Applications &#171; Software Engineering for LabVIEW</title>
		<link>http://expressionflow.com/2007/10/01/labview-queued-state-machine-architecture/comment-page-1/#comment-6899</link>
		<dc:creator>Great Resource for Learning a Common Architecture for LabVIEW Applications &#171; Software Engineering for LabVIEW</dc:creator>
		<pubDate>Wed, 18 Mar 2009 19:33:25 +0000</pubDate>
		<guid isPermaLink="false">http://expressionflow.com/2007/10/01/labview-queued-state-machine-architecture/#comment-6899</guid>
		<description>[...] Lukindo wrote an excellent article on expressionflow.com that explains how to utilize a queued state machine architecture with [...]</description>
		<content:encoded><![CDATA[<p>[...] Lukindo wrote an excellent article on expressionflow.com that explains how to utilize a queued state machine architecture with [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Anthony L.</title>
		<link>http://expressionflow.com/2007/10/01/labview-queued-state-machine-architecture/comment-page-1/#comment-2415</link>
		<dc:creator>Anthony L.</dc:creator>
		<pubDate>Thu, 24 Apr 2008 07:05:51 +0000</pubDate>
		<guid isPermaLink="false">http://expressionflow.com/2007/10/01/labview-queued-state-machine-architecture/#comment-2415</guid>
		<description>Will upload LV 7.1 version to FTP server and will point you to address for downloading. Will write back soon.

Anthony</description>
		<content:encoded><![CDATA[<p>Will upload LV 7.1 version to FTP server and will point you to address for downloading. Will write back soon.</p>
<p>Anthony</p>
]]></content:encoded>
	</item>
</channel>
</rss>
