<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Seneca5 Software Blog &#187; Examples</title>
	<atom:link href="http://www.seneca5.com/blog/category/examples/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.seneca5.com/blog</link>
	<description>Expert LabVIEW™ Development</description>
	<lastBuildDate>Mon, 06 Sep 2010 15:09:08 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>July User Group &#8211; Circular Buffer in LabVIEW</title>
		<link>http://www.seneca5.com/blog/2010/07/july-user-group-circular-buffer-in-labview/</link>
		<comments>http://www.seneca5.com/blog/2010/07/july-user-group-circular-buffer-in-labview/#comments</comments>
		<pubDate>Wed, 07 Jul 2010 15:35:57 +0000</pubDate>
		<dc:creator>Craig Bedward</dc:creator>
				<category><![CDATA[Examples]]></category>
		<category><![CDATA[LabVIEW]]></category>
		<category><![CDATA[User Group]]></category>
		<category><![CDATA[example]]></category>

		<guid isPermaLink="false">http://www.seneca5.com/blog/?p=562</guid>
		<description><![CDATA[Ludwik Kordas presented the concept of a Circular Buffer (CB) and various ways to implement it in LabVIEW. His presentation and example VI&#8217;s are included in this post. Definition An area of memory  used to store a continuous stream of data by starting again at the beginning of the buffer after reaching the end. A [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.seneca5.com/blog/wp-content/uploads/2010/07/CircularBuffer_Ring1.png"></a><a href="http://www.seneca5.com/blog/wp-content/uploads/2010/07/CircularBuffer_Ring1.png"><img class="alignright size-full wp-image-564" title="CircularBuffer_Ring1" src="http://www.seneca5.com/blog/wp-content/uploads/2010/07/CircularBuffer_Ring1.png" alt="" width="132" height="151" /></a>Ludwik Kordas presented the concept of a Circular Buffer (CB) and various ways to implement it in LabVIEW.</p>
<p>His presentation and example VI&#8217;s are included in this post.</p>
<p><span id="more-562"></span></p>
<h3>Definition</h3>
<p>An area of memory  used to store a continuous stream of data by starting again at the beginning of the buffer after reaching the end. A circular buffer is usually written by one process and read by another. Separate read and write pointers are maintained. These are not allowed to pass each other otherwise either unread data would be overwritten or invalid data would be read.<br />
<a href="http://www.seneca5.com/blog/wp-content/uploads/2010/07/CircularBuffer_Ring1.png"><img class="alignright size-full wp-image-564" title="CircularBuffer_Ring1" src="http://www.seneca5.com/blog/wp-content/uploads/2010/07/CircularBuffer_Ring1.png" alt="" width="188" height="215" /></a></p>
<h3>Simple CB Models</h3>
<ul>
<li style="text-align: left;">FIFO: first IN first OUT</li>
<li style="text-align: left;">(first WRITTEN first READ)</li>
<li style="text-align: left;">Number of elements: n+1</li>
<li style="text-align: left;">Predefined # of elements: n</li>
<li style="text-align: left;">“n+1” element is forbidden for write/read pointers</li>
<li style="text-align: left;">Elements could be of any data type including arrays, clusters or even clusters of arrays of clusters</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.seneca5.com/blog/2010/07/july-user-group-circular-buffer-in-labview/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>VIG Example &#8211; Stopwatch</title>
		<link>http://www.seneca5.com/blog/2010/07/vig-example-stopwatch/</link>
		<comments>http://www.seneca5.com/blog/2010/07/vig-example-stopwatch/#comments</comments>
		<pubDate>Sun, 04 Jul 2010 19:35:06 +0000</pubDate>
		<dc:creator>Craig Bedward</dc:creator>
				<category><![CDATA[Examples]]></category>
		<category><![CDATA[LabVIEW]]></category>
		<category><![CDATA[example]]></category>
		<category><![CDATA[Functional Global]]></category>
		<category><![CDATA[VIG]]></category>

		<guid isPermaLink="false">http://www.seneca5.com/blog/?p=535</guid>
		<description><![CDATA[A VIG or &#8220;functional global&#8221; is a LabVIEW VI that provides the features of a global variable while overcoming some of the down sides of an actual global variable. A function global uses uninitialized shift registers to maintain state information and a typedef function to select the mode of operation. This example implements a stopwatch [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.seneca5.com/blog/wp-content/uploads/2010/07/StopWatchScreen1.png"><img class="alignright size-medium wp-image-536" title="StopWatchScreen1" src="http://www.seneca5.com/blog/wp-content/uploads/2010/07/StopWatchScreen1-300x255.png" alt="" width="300" height="255" /></a>A VIG or &#8220;functional global&#8221; is a LabVIEW VI that provides the features of a global variable while overcoming some of the down sides of an actual global variable.</p>
<p>A function global uses uninitialized shift registers to maintain state information and a typedef function to select the mode of operation.</p>
<p>This example implements a stopwatch timer. You can use it to time up to 16 independent events in your application.</p>
<p>For more information on functional globals, check out these links:</p>
<p><a href="http://decibel.ni.com/content/docs/DOC-2143" target="_blank">Basic Functional Global Example</a></p>
<p><a href="http://decibel.ni.com/content/docs/DOC-12054" target="_blank">Functional Global Flags to Protect a Shared Resource</a></p>
<p><a href="http://search.ni.com/nisearch/app/main/p/bot/no/ap/tech/lang/en/pg/1/ps/10/sn/ssnav:dzn/q/%22functional%20global%22/ses/false/" target="_blank">Other &#8220;functional global&#8221; examples in NI Developer Zone</a></p>
<h4>Download the Code here:</h4>
<ul>
<li><a href="http://www.seneca5.com/blog/wp-content/uploads/2010/07/StopwatchLV2009.zip">Stopwatch LV2009</a></li>
<li><a href="http://www.seneca5.com/blog/wp-content/uploads/2010/07/StopwatchLV61.zip">Stopwatch LV61</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.seneca5.com/blog/2010/07/vig-example-stopwatch/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Certified LabVIEW Associate Developer (CLAD) Example Tests</title>
		<link>http://www.seneca5.com/blog/2010/06/clad-example-tests/</link>
		<comments>http://www.seneca5.com/blog/2010/06/clad-example-tests/#comments</comments>
		<pubDate>Thu, 10 Jun 2010 21:14:21 +0000</pubDate>
		<dc:creator>Craig Bedward</dc:creator>
				<category><![CDATA[Examples]]></category>
		<category><![CDATA[LabVIEW]]></category>
		<category><![CDATA[User Group]]></category>
		<category><![CDATA[Certification]]></category>

		<guid isPermaLink="false">http://www.seneca5.com/blog/?p=515</guid>
		<description><![CDATA[There was a lot of interest at our last group meeting about NI certification tests. The Certified LabVIEW Associate Developer (CLAD) is the first step in getting certified. The test shows knowledge of LabVIEW basics. If you have had the LabVIEW Basics class (now called Core 1) or if you have some real-life experience with [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.seneca5.com/blog/wp-content/uploads/2010/06/testform.jpg"><img class="alignright size-thumbnail wp-image-516" title="testform" src="http://www.seneca5.com/blog/wp-content/uploads/2010/06/testform-150x150.jpg" alt="" width="150" height="150" /></a>There was a lot of interest at our last group meeting about NI certification tests.</p>
<p>The Certified LabVIEW Associate Developer (CLAD) is the first step in getting certified. The test shows knowledge of LabVIEW basics. If you have had the LabVIEW Basics class (now called Core 1) or if you have some real-life experience with LabVIEW, you might be ready. If you want to find out, there are some sample tests you can download from NI&#8217;s web site:</p>
<p><a href="http://www.seneca5.com/blog/wp-content/uploads/2010/06/clad_sample_exam1.pdf">clad_sample_exam1.pdf</a></p>
<p><a href="http://www.seneca5.com/blog/wp-content/uploads/2010/06/clad_sample_exam2.pdf">clad_sample_exam2.pdf</a></p>
<p><a href="http://zone.ni.com/devzone/cda/epd/p/id/5225" target="_blank">Certified LabVIEW Associate Developer (CLAD) Sample Exams</a></p>
<p><a href="http://zone.ni.com/devzone/cda/tut/p/id/4261" target="_blank">How Can I Prepare for the Certified LabVIEW Associate Developer (CLAD) Exam?</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.seneca5.com/blog/2010/06/clad-example-tests/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Vision Solution</title>
		<link>http://www.seneca5.com/blog/2010/01/vision-solution/</link>
		<comments>http://www.seneca5.com/blog/2010/01/vision-solution/#comments</comments>
		<pubDate>Thu, 28 Jan 2010 04:16:28 +0000</pubDate>
		<dc:creator>Michael Jones</dc:creator>
				<category><![CDATA[Examples]]></category>
		<category><![CDATA[LabVIEW]]></category>
		<category><![CDATA[LabVIEW Vision USB Camera]]></category>

		<guid isPermaLink="false">http://www.seneca5.com/blog/?p=253</guid>
		<description><![CDATA[Good vision systems are difficult to engineer. Our brain, as far as computations are concerned, is a very parallel system. It can account for contrast and brightness, recognize and categorize a seemingly endless number of shapes, and set our eyes to focus faster than any commercial camera, all simultaneously. It can also, through the depth [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignright size-full wp-image-278" title="11-air-pressure-gauge" src="http://www.seneca5.com/blog/wp-content/uploads/2010/01/11-air-pressure-gauge1.jpg" alt="11-air-pressure-gauge" width="218" height="261" />Good vision systems are difficult to engineer. Our brain, as far as computations are concerned, is a very parallel system. It can account for contrast and brightness, recognize and categorize a seemingly endless number of shapes, and set our eyes to focus faster than any commercial camera, all simultaneously. It can also, through the depth perception of having two eyes or through the patterns of experience, give volume to the two dimensional image your eyes obtain.</p>
<p>Replicating these tasks on a computer is nothing short of impossible with today&#8217;s level of research and design.</p>
<p>What the computer does well though is sequential logic very quickly. Vision systems use this to their advantage by constraining the vision problem to one task at the time. In the end the computer can attack and solve particular vision problems better than our own vision systems can.</p>
<p>Today we will be detecting the value of an off-the-shelf PSI gauge using <a href="http://zone.ni.com/devzone/cda/tut/p/id/10430" target="_blank">NI Vision Builder</a>. Hopefully our solution gives some insight into the current level of vision systems.</p>
<p><span id="more-253"></span><strong>Acquire</strong></p>
<p>The first step in any vision application is to acquire the image.  Vision Builder makes this particularly easy for USB, Firewire, or Ethernet cameras.</p>
<p><a style="text-decoration: none;" href="http://www.seneca5.com/blog/wp-content/uploads/2010/01/1.JPG"><img class="aligncenter size-full wp-image-234" title="1" src="http://www.seneca5.com/blog/wp-content/uploads/2010/01/1.JPG" alt="1" width="576" height="433" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.seneca5.com/blog/2010/01/vision-solution/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Nice Threads</title>
		<link>http://www.seneca5.com/blog/2009/11/nice-threads/</link>
		<comments>http://www.seneca5.com/blog/2009/11/nice-threads/#comments</comments>
		<pubDate>Tue, 03 Nov 2009 07:33:57 +0000</pubDate>
		<dc:creator>Craig Bedward</dc:creator>
				<category><![CDATA[Examples]]></category>
		<category><![CDATA[LabVIEW]]></category>
		<category><![CDATA[Software Architecture]]></category>
		<category><![CDATA[threads]]></category>

		<guid isPermaLink="false">http://www.seneca5.com/blog/?p=202</guid>
		<description><![CDATA[Multithread programming in traditional languages can be a challenge. The programmer is responsible for managing many things, such as: Separating logical tasks Avoiding race conditions Avoiding thread starvation conditions Managing communication between the threads LabVIEW, on the other hand, lends itself easily to multithreaded programming. In fact, if you follow the dataflow rules, multithreading will [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.seneca5.com/blog/wp-content/uploads/2009/11/VI-Server-Functions1.PNG"></a><a href="http://www.seneca5.com/blog/wp-content/uploads/2009/11/Threads_RGB.png"><img class="alignright size-full wp-image-478" title="Threads" src="http://www.seneca5.com/blog/wp-content/uploads/2009/11/Threads_RGB.png" alt="" width="305" height="340" /></a>Multithread programming in traditional languages can be a challenge. The programmer is responsible for managing many things, such as:</p>
<ul>
<li>Separating logical tasks</li>
<li>Avoiding race conditions</li>
<li>Avoiding thread starvation conditions</li>
<li>Managing communication between the threads</li>
</ul>
<p>LabVIEW, on the other hand, lends itself easily to multithreaded programming. In fact, if you follow the dataflow rules, multithreading will happen <em>automatically</em> when LabVIEW finds the opportunity.</p>
<h3><span id="more-202"></span>Dataflow Programming</h3>
<p>LabVIEW follows a programming model called dataflow programming. Rather than writing a program in the form of Step 1, Step 2, Step 3, &#8230;, LabVIEW programs pass the data on wires. Any VI taking inputs must wait for all of its inputs to be ready before it can run. In the example below, Loop A must run before Loop B is able to run, because Loop A produces data that is used by Loop B. The data dependency controls the order of execution.</p>
<div id="attachment_216" class="wp-caption aligncenter" style="width: 466px"><a href="http://www.seneca5.com/blog/wp-content/uploads/2009/11/loops_dependent.PNG"><img class="size-full wp-image-216" title="loops_dependent" src="http://www.seneca5.com/blog/wp-content/uploads/2009/11/loops_dependent.PNG" alt="Loops with a data dependency" width="456" height="140" /></a><p class="wp-caption-text">Loops with a data dependency</p></div>
<p>However, if we remove the data dependency, we no longer force the order of execution. LabVIEW gets to decide which loop will run first. But is it Loop A or Loop B? Actually, it is both. This is where LabVIEW&#8217;s automatic multithreading kicks in. LabVIEW will create multiple threads and run each loop simultaneously, one in each thread.</p>
<div id="attachment_217" class="wp-caption aligncenter" style="width: 466px"><a href="http://www.seneca5.com/blog/wp-content/uploads/2009/11/loops_threaded.PNG"><img class="size-full wp-image-217" title="loops_threaded" src="http://www.seneca5.com/blog/wp-content/uploads/2009/11/loops_threaded.PNG" alt="Loops with no data dependency" width="456" height="140" /></a><p class="wp-caption-text">Loops with no data dependency</p></div>
<h3>Sharing Data</h3>
<p>Remember, LabVIEW can do automatic multithreading only because there is no wired data dependency between the two loops, so the next question is, how do we share data between the two loops?</p>
<h4>Local Variable</h4>
<p>The first way of sharing data between loops that probably comes to mind is a local variable. It provides a way for you to access the value of data without wiring, so it can indeed be used and still allow automatic multithreading. But there are some drawbacks to local variables: they can cause race conditions, they need to be initialized, they break the dataflow programming paradigm, so you should not get used to using them (if you are a LabVIEW purist, you would never use a local variable).</p>
<h4>Queues</h4>
<p>A better way to share data between loops is with a queue. One loop can send a message to the other with a queue without creating a data dependency. And the message is delivered in a more predictable manner than a local variable. A great example of this technique is the standard Producer/Consumer template.</p>
<div id="attachment_219" class="wp-caption aligncenter" style="width: 543px"><a href="http://www.seneca5.com/blog/wp-content/uploads/2009/11/producer-consumer.PNG"><img class="size-full wp-image-219" title="producer-consumer" src="http://www.seneca5.com/blog/wp-content/uploads/2009/11/producer-consumer.PNG" alt="Producer-Consumer Template" width="533" height="371" /></a><p class="wp-caption-text">Producer-Consumer Template</p></div>
<h3>Spinning Off Threads</h3>
<p>Multithreading with multiple parallel loops is fine, but it takes you only so far. Take for example a program that needs to capture data from a DAQ card as fast as possible, handle the user interface at a medium rate to keep up with the operator, and log the data to a file as a background function. Using parallel loops, you cannot control the priority of the various loops, which means the file loop runs as an equal to the DAQ task. That will likely slow down the DAQ and cause data to be lost.</p>
<p>One solution is to put each of the loops into a separate VI and &#8220;spin off&#8221; each of those VI&#8217;s to run independently. You can control the priority of a VI (under <em>VI Properties-&gt;Execution</em>), so you can set the DAQ VI to be time critical and the file I/O to be a background task.</p>
<h3>How to Spin Off a Thread</h3>
<p><img class="alignright size-full wp-image-220" style="margin-left: 10px; margin-right: 10px;" title="AppControlPalette" src="http://www.seneca5.com/blog/wp-content/uploads/2009/11/AppControlPalette.PNG" alt="AppControlPalette" width="174" height="225" /></p>
<p>To run a VI as a thread, you can&#8217;t just call it as you would a normal VI. Normally, when a VI calls another, that VI suspends its execution until the sub-VI completes. That&#8217;s the opposite of the multithreaded operation we are after. To spin off a VI, we can make use of some of the <em>VI Server </em>VI&#8217;s. These can be found in the <em>Application Control</em> palette.</p>
<p>The process is not difficult:</p>
<ol>
<li>Open VI Reference</li>
<li>Invoke Node &#8211; <em>Invoke Run VI</em>, specifying to not <em>Wait Until Done</em></li>
<li>(Optionally) Invoke Node &#8211; Invoke <em>FP.Open</em> to show the front panel of the VI you are spinning off</li>
<li>Use a named queue to communicate between the threads</li>
<li>When the thread is terminated, use Close Reference to dispose of the reference to the VI</li>
</ol>
<p><a href="http://www.seneca5.com/blog/wp-content/uploads/2009/11/VI-Server-Functions1.PNG"><img style="display: block; margin-left: auto; margin-right: auto; border: 0px initial initial;" title="VI Server Functions" src="http://www.seneca5.com/blog/wp-content/uploads/2009/11/VI-Server-Functions1.PNG" alt="VI Server Functions" width="536" height="144" /></a></p>
<h4>Priority</h4>
<p>When you spin off a thread, it will run with the priority specified in <em>VI Properties-&gt;Execution</em>. You can also set the <em>Preferred Execution System</em> to tweak performance.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.seneca5.com/blog/2009/11/nice-threads/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Easy Pop-Up Windows</title>
		<link>http://www.seneca5.com/blog/2009/09/easy-pop-up-windows/</link>
		<comments>http://www.seneca5.com/blog/2009/09/easy-pop-up-windows/#comments</comments>
		<pubDate>Wed, 02 Sep 2009 17:57:30 +0000</pubDate>
		<dc:creator>Craig Bedward</dc:creator>
				<category><![CDATA[Examples]]></category>
		<category><![CDATA[GUI]]></category>
		<category><![CDATA[LabVIEW]]></category>

		<guid isPermaLink="false">http://www.seneca5.com/blog/?p=196</guid>
		<description><![CDATA[You can make pop-up windows quickly and easily by using tab controls. By using tab controls, you can create the same visual effect and the same functionality as a pop-up window, but you don&#8217;t need to create a sub-VI. Since you never leave the VI, you don&#8217;t need to worry about passing information into and [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.seneca5.com/blog/wp-content/uploads/2009/09/FancyPopUp2.png"><img class="alignright size-medium wp-image-197" title="FancyPopUp2" src="http://www.seneca5.com/blog/wp-content/uploads/2009/09/FancyPopUp2-300x175.png" alt="FancyPopUp2" width="300" height="175" /></a>You can make pop-up windows quickly and easily by using tab controls.</p>
<p>By using tab controls, you can create the same visual effect and the same functionality as a pop-up window, but you don&#8217;t need to create a sub-VI. Since you never leave the VI, you don&#8217;t need to worry about passing information into and out of the dialog, simplifiying the code.</p>
<p>While this technique may not be appropriate for every situation, it is a nice trick to have when you need a quick pop-up window.</p>
<p>Give it a try. An example VI is attached.</p>
<p>Download VI: <a href="http://www.seneca5.com/blog/wp-content/uploads/2009/09/QuickPopUp.vi">QuickPopUp.vi</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.seneca5.com/blog/2009/09/easy-pop-up-windows/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Close with Class</title>
		<link>http://www.seneca5.com/blog/2009/08/close-with-class/</link>
		<comments>http://www.seneca5.com/blog/2009/08/close-with-class/#comments</comments>
		<pubDate>Tue, 04 Aug 2009 06:57:34 +0000</pubDate>
		<dc:creator>Craig Bedward</dc:creator>
				<category><![CDATA[Examples]]></category>
		<category><![CDATA[GUI]]></category>
		<category><![CDATA[LabVIEW]]></category>

		<guid isPermaLink="false">http://www.seneca5.com/blog/?p=161</guid>
		<description><![CDATA[One rule to remember when designing a user interface is to do things in standard ways. For example, if you want to close a program in Windows, you click the red X button in the upper right-hand corner of the window. Most LabVIEW™ have a tell-tale &#8220;Stop&#8221; or &#8220;Done&#8221; button. That always bugs me. Why [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.seneca5.com/blog/wp-content/uploads/2009/08/CloseButton_big.png"></a><a href="http://www.seneca5.com/blog/wp-content/uploads/2009/08/CloseButton_big2.png"><img class="size-full wp-image-180 alignright" title="CloseButton_big2" src="http://www.seneca5.com/blog/wp-content/uploads/2009/08/CloseButton_big2.png" alt="CloseButton_big2" width="174" height="180" /></a>One rule to remember when designing a user interface is to do things in standard ways.</p>
<p>For example, if you want to close a program in Windows, you click the red X button in the upper right-hand corner of the window. Most LabVIEW™ have a tell-tale &#8220;Stop&#8221; or &#8220;Done&#8221; button. That always bugs me. Why shouldn&#8217;t a LabVIEW program end the same way any other Windows program ends?</p>
<p><span id="more-161"></span></p>
<p>Why indeed. Here&#8217;s how to do it.</p>
<p><a href="http://www.seneca5.com/blog/wp-content/uploads/2009/08/UseCloseButtonToStopVI.png"><img class="alignnone size-full wp-image-162" title="UseCloseButtonToStopVI" src="http://www.seneca5.com/blog/wp-content/uploads/2009/08/UseCloseButtonToStopVI.png" alt="UseCloseButtonToStopVI" width="471" height="256" /></a></p>
<p>In order to catch the press of the Close button, you need to use an event structure. The event structure allows you to tie into the <em>Panel Close?</em> event to make it run your code.</p>
<p>You will find the event under &lt;This VI&gt;Event Source. Take note of the question mark in the event name. There is also an event called Panel Close. You need the one with the question mark. It is a filter event. Since it is a filter event, it is indicated with a red arrow.</p>
<p>Filter events get called before the event is processed. By wiring a TRUE to the discard, the event is killed, so the standard event handling is not processed. We have complete control over what we want to do in response to the event.</p>
<p>Now you have no excuse. So, please, no more &#8220;Stop&#8221; buttons.</p>
<p>Download Example: <a href="http://www.seneca5.com/blog/wp-content/uploads/2009/08/CloseButtonToStopVI.vi">CloseButtonToStopVI.vi</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.seneca5.com/blog/2009/08/close-with-class/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Errors, Errors, Everywhere</title>
		<link>http://www.seneca5.com/blog/2009/08/errors-errors-everywhere/</link>
		<comments>http://www.seneca5.com/blog/2009/08/errors-errors-everywhere/#comments</comments>
		<pubDate>Tue, 04 Aug 2009 06:28:26 +0000</pubDate>
		<dc:creator>Craig Bedward</dc:creator>
				<category><![CDATA[Examples]]></category>
		<category><![CDATA[LabVIEW]]></category>
		<category><![CDATA[Error Handling]]></category>

		<guid isPermaLink="false">http://blog.seneca5.com/?p=13</guid>
		<description><![CDATA[Error handling. You know you have to do&#8230;well, you should do it&#8230;well, maybe you will get the code working and then come back later and add proper error handling. Let&#8217;s be honest, you will never go back and do it. If you can&#8217;t take time to do it right the first time, how do you [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.seneca5.com/blog/wp-content/uploads/2009/08/ShinyYellow_error.png"><img class="alignright size-full wp-image-167" title="ShinyYellow_error" src="http://www.seneca5.com/blog/wp-content/uploads/2009/08/ShinyYellow_error.png" alt="ShinyYellow_error" width="128" height="128" /></a> Error handling. You know you have to do&#8230;well, you should do it&#8230;well, maybe you will get the code working and then come back later and add proper error handling.</p>
<p>Let&#8217;s be honest, you will never go back and do it. If you can&#8217;t take time to do it right the first time, how do you expect to find time to do it over again?</p>
<p>Error handling is not the most fun aspect of programming, but doing it right can separate a buggy program from good solid code.</p>
<p><span id="more-13"></span></p>
<h3>Seneca5 Error Logging Class</h3>
<p>We have created a simple class that helps handle errors. It takes care of the most common needs for dealing with errors: Reporting, Cleaning, Displaying, and Logging. This is not an error handler, in the sense that it takes no particular action based on an error; you can still do that with code specific to the event. The purpose is to provide a way to make sure all errors are caught and recorded.</p>
<h3>Features</h3>
<ul>
<li>Central collection of errors that occur throughout your program</li>
<li>Timestamps errors</li>
<li>Save errors to a file</li>
<li>Optionally supresses duplicate consecutive errors</li>
</ul>
<h3>Class Methods</h3>
<p><img class="alignnone size-full wp-image-140" title="ErrorLog_Create" src="http://www.seneca5.com/blog/wp-content/uploads/2009/08/ErrorLog_Create1.png" alt="ErrorLog_Create" width="364" height="172" /></p>
<p><img class="alignnone size-full wp-image-141" title="ErrorLog_Destroy" src="http://www.seneca5.com/blog/wp-content/uploads/2009/08/ErrorLog_Destroy.png" alt="ErrorLog_Destroy" width="266" height="149" /></p>
<p><img class="alignnone size-full wp-image-142" title="ErrorLog_LogError" src="http://www.seneca5.com/blog/wp-content/uploads/2009/08/ErrorLog_LogError.png" alt="ErrorLog_LogError" width="326" height="113" /></p>
<p><img class="alignnone size-full wp-image-143" title="ErrorLog_GetErrors" src="http://www.seneca5.com/blog/wp-content/uploads/2009/08/ErrorLog_GetErrors.png" alt="ErrorLog_GetErrors" width="333" height="157" /></p>
<p><img class="alignnone size-full wp-image-144" title="ErrorLog_ShowErrorDialog" src="http://www.seneca5.com/blog/wp-content/uploads/2009/08/ErrorLog_ShowErrorDialog.png" alt="ErrorLog_ShowErrorDialog" width="248" height="102" /></p>
<p><img class="alignnone size-full wp-image-145" title="ErrorLog_ClearErrors" src="http://www.seneca5.com/blog/wp-content/uploads/2009/08/ErrorLog_ClearErrors.png" alt="ErrorLog_ClearErrors" width="267" height="115" /></p>
<h3>Example Program</h3>
<p><a href="http://www.seneca5.com/blog/wp-content/uploads/2009/08/ErrorLog_ExampleFrontPanel.png"><img class="alignnone size-full wp-image-156" title="ErrorLog_ExampleFrontPanel" src="http://www.seneca5.com/blog/wp-content/uploads/2009/08/ErrorLog_ExampleFrontPanel.png" alt="ErrorLog_ExampleFrontPanel" width="572" height="368" /></a></p>
<p><a href="http://www.seneca5.com/blog/wp-content/uploads/2009/08/ErrorLog_ExampleDiagram.png"><img class="alignnone size-full wp-image-158" title="ErrorLog_ExampleDiagram" src="http://www.seneca5.com/blog/wp-content/uploads/2009/08/ErrorLog_ExampleDiagram.png" alt="ErrorLog_ExampleDiagram" width="591" height="185" /></a></p>
<p>This example shows the basic usage of the ErrorLog class. Once the object is constructed, you can use the same object from multiple loops in your program. You can also use the object reference to pass to sub-VI&#8217;s that you call. You can even pass a reference to a VI executing in parallel (although that is a little trickier).</p>
<p>Every place that can generate errors uses the Log Error VI to process the error. Each call to LogError includes a string to indicate the context of the code that generated the error. That ensures that all of the errors are collected, including a timestep and context, which can be very helpful later for finding the source of a problem.</p>
<p>You can use the Get Errors function in your main GUI loop to watch for errors to occur and light up an indicator. When the user sees that an error has occurred, he can hit the Show Errors button to bring up a dialog box that shows the history of errors.</p>
<h3>Download</h3>
<p>The example program is written in LabVIEW 8.5 with full access to the source. There is a simple example, as well as a more complex example that shows how to use multiple loops and customized a popup window.<br />
Download: <a href="http://www.seneca5.com/blog/wp-content/uploads/2009/08/Example-S5Tools-ErrorLog-Class.zip">[Example] S5Tools ErrorLog Class.zip</a></p>
<p>This class has been saved in LabVIEW 8.5. Although password protected, the diagrams are present, so upgrading should be no problem. Download ErrorLog.llb and install into &lt;LabVIEW&gt;\user.lib\S5Tools<br />
Download: <a style="text-decoration: none;" href="http://www.seneca5.com/blog/wp-content/uploads/2009/08/ErrorLog.llb">ErrorLog.llb</a></p>
<p>The class is built with the Endevo GOOP Toolkit, version 2. The GOOP2 run-time is required to use the class. Download _goop2.llb and install into &lt;LabVIEW&gt;\vi.lib\addons<br />
Download: <a href="http://www.seneca5.com/blog/wp-content/uploads/2009/08/goop2.llb">_goop2.llb</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.seneca5.com/blog/2009/08/errors-errors-everywhere/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
