<?xml version="1.0" encoding="utf-8" standalone="no"?>
<!DOCTYPE document PUBLIC "-//CNX//DTD CNXML 0.5//EN" "http://cnx.rice.edu/cnxml/0.5/DTD/cnxml_plain.dtd">
<document xmlns="http://cnx.rice.edu/cnxml" xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:bib="http://bibtexml.sf.net/" id="new1">
  <name>Creating LabVIEW demonstrations for Connexions</name>
  <metadata>
  <md:version>1.23</md:version>
  <md:created>2003/08/14 13:38:00 GMT-5</md:created>
  <md:revised>2004/02/12 14:11:04 US/Central</md:revised>
  <md:authorlist>
      <md:author id="prash">
      <md:firstname>Prashant</md:firstname>
      
      <md:surname>Singh</md:surname>
      <md:email>prash@ece.rice.edu</md:email>
    </md:author>
  </md:authorlist>

  <md:maintainerlist>
    <md:maintainer id="prash">
      <md:firstname>Prashant</md:firstname>
      
      <md:surname>Singh</md:surname>
      <md:email>prash@ece.rice.edu</md:email>
    </md:maintainer>
    <md:maintainer id="richb">
      <md:firstname>Richard</md:firstname>
      <md:othername>G.</md:othername>
      <md:surname>Baraniuk</md:surname>
      <md:email>richb@rice.edu</md:email>
    </md:maintainer>
  </md:maintainerlist>
  
  <md:keywordlist>
    <md:keyword>interactive</md:keyword>
    <md:keyword>LabVIEW</md:keyword>
    <md:keyword>VI</md:keyword>
  </md:keywordlist>

  <md:abstract>This document explains how authors can create LabVIEW demos and use them in Connexions documents.</md:abstract>
</metadata>

  <content>
    <para id="intro">
      One can use LabVIEW 7 to create interactive or animated
      demonstrations for use in a Connexions document. These
      demonstrations are known as LabVIEW Virtual Instruments or
      VIs. These demonstrations currently run outside of the browser
      and require the user to have two extra tools: the LabVIEW 7
      Run-Time Engine and the Connexions virunner helper
      application. <cnxn document="m11550">Another document</cnxn>
      instructs users on how to obtain these tools for their platform.
    </para>
    <example id="vi1">
      <para id="vi1_para1">
	Here is one such LabVIEW demonstration. It lets the user see
	the effects of the amplitude, complex frequency, and phase on
	the complex exponential.
      </para>
      <media type="application/x-labview-llb" src="Complex_Exponential.vi">
	<param name="viinfo" value="ct_complex_exponential.viinfo"/>
      </media>
    </example>
    <section id="creating_vis">
      <name>Creating VIs</name>
      <para id="creating_1">
	Create a VI using LabVIEW 7 on your favorite platform. If you
	create and use sub VIs in your demonstration, then package
	these dynamic VIs with the top-level VI into an LLB file. A
	convenient way of doing this is by choosing Save with Options
	from the File menu. You can then choose Development
	Distribution, and when prompted, enter a name for an LLB file
	in which to save the VIs.
      </para>
      <para id="creating_2">
	When the VI has the desired functionality, you will want to
	ensure that it behaves the way a user will expect. There
	should be a convenient way of choosing to close the front
	panel when the VI has served its purpose. The appearance of
	the window should also be that of a demonstration applet. You
	can set the window appearance by choosing VI Properties from
	the File menu and selecting the Window Appearance
	category. Choose to customize the appearance, and deselect the
	following items:
	<list id="settings_list">
	  <item>Show menu bar</item>
	  <item>Show scroll bars</item>
	  <item>Show toolbar when running</item>
	  <item>Allow user to resize window</item>
	  <item>Allow run-time shortcut menus</item>
	</list>
	If you require scroll bar functionality, or if the VI resizes
	well, then you can select the relevant options.
      </para>
    </section>
    <section id="building">
      <name>Building Executables</name>
      <para id="building_1">
	Once you have put the finishing touches on the VI, you will
	need to build executables for each supported
	targets. Connexions currently supports Windows, Linux (x86),
	and Solaris (Sparc) platforms. If you do not have the LabVIEW
	7 Professional, then you may need an add-on that provides the
	application-building functionality. You will need access to
	LabVIEW on each of the supported platforms because we do not
	currently have an automated build process.
      </para>
      <para id="building_2">
	On each platform, choose Build Application or Shared Library
	from the Tools menu. The VIs must not be in memory when you
	build them. LabVIEW will warn you if they are. Specify a
	target file name for the compiled VI. On Windows, this should
	end in <code>.exe</code>. Linux and Solaris do not require
	specific extensions for executables, so you may want to append
	<code>_linux</code> or <code>_solaris</code> as appropriate to
	avoid file name conflicts. Choose a destination directory and
	specify the same directory as the support file
	directory. Choose the Source Files tab and add the top-level
	VI and any dynamic VIs to the list. If you are using dynamic
	VIs, then all of your VIs are likely located in an LLB file.
      </para>
      <para id="building_3">
	Click the Build button to build the executable. LabVIEW will
	place the executable and any shared libraries it calls in the
	destination directory. You may save the build options in a
	build script so that the process will be easier next time you
	create an executable from this VI. To load a saved build
	script, click the Load button.
      </para>
    </section>
    <section id="cnx">
      <name>Adding the demonstration to Connexions</name>
      <para id="cnx_1">
	Once you have created the executables, anyone with LabVIEW or
	the Run-Time Engine on those platforms can run them. But
	making the VI Connexions-friendly requires a couple of other
	small steps.
      </para>
      <para id="cnx_2">
	You must take all of the files created when you built the
	executables, as well as the source VI or LLB file, and add
	them to this document. The ID of this document is m11601. To
	improve the user's experience, we provide only one link for
	running the VI. The virunner helper app then reads the file
	pointed to by this link, downloads the platform-specific
	files, and runs the VI. The file read by virunner is known as
	a VI Information File (viinfo file) and is a simple XML file,
	which indicates the locations of the necessary files for each
	platform. For the Connexions project we prefer that these
	files reside in this document you are currently viewing. The
	viinfo file should then point to files inside of this
	document.
      </para>
      <para id="cnx_3">
	Once the files are all in document m11601, you must create the
	viinfo file. The FORMAT file included with the virunner source
	describes the format of the viinfo file. You can access the
	virunner source via the CVS web interface at <link src="http://mountainbunker.org/cgi-bin/viewcvs.cgi/software/virunner/">http://mountainbunker.org/cgi-bin/viewcvs.cgi/software/virunner/</link>. Here
	is a sample viinfo file: <code type="block">
	<![CDATA[
<viinfo>
  <binary>
    <platform>windows</platform>
    <main>
      http://cnx.rice.edu/content/m11601/latest/common_distributions.exe
    </main>
    <subordinate>
      http://cnx.rice.edu/content/m11601/latest/lvanlys.dll
    </subordinate>
  </binary>
  <binary>
    <platform>linux</platform>
    <main>
      http://cnx.rice.edu/content/m11601/latest/common_distributions_linux
    </main>
    <subordinate>
      http://cnx.rice.edu/content/m11601/latest/lvanlys.so
    </subordinate>
  </binary>
  <binary>
    <platform>solaris</platform>
    <main>
      http://cnx.rice.edu/content/m11601/latest/common_distributions_solaris
    </main>
    <subordinate>
      http://cnx.rice.edu/content/m11601/latest/lvanlys.so
    </subordinate>
  </binary>
  <source>
    <main>
      http://cnx.rice.edu/content/m11601/latest/Common_Distributions.vi
    </main>
  </source>
</viinfo>
	  ]]>
	</code> You
	should also add the viinfo file to this document so that
	others can easily use your LabVIEW demonstration in their
	documents.
      </para>
    </section>
    <section id="using">
      <name>Using a demonstration in a document</name>
      <para id="using_1">
	After adding a demonstration to Connexions, you can use it in
	a Connexions document. You will need to add the source VI or
	LLB file as well as the viinfo file to the document. You can
	then then use an example and media tag to present a LabVIEW
	demonstration example element.
      </para>
      <example id="using_2">
	<para id="using_3">
	  To produce the following example,
	</para>
	<example id="example_id">
	  <para id="para_id">
	    Here is one such LabVIEW demonstration. It lets the user
	    see the effects of the amplitude, complex frequency, and
	    phase on the complex exponential.
	  </para>
	  <media type="application/x-labview-vi" src="Common_Distributions.vi">
	    <param name="viinfo" value="common_distributions.viinfo"/>
	  </media>
	</example>
	<para id="using_4">
	  use this CNXML code:
	  <code type="block">
	    <![CDATA[
	  <example id="example_id">
	    <para id="para_id">
	      Here is a sample LabVIEW demonstration. It lets the user
	      look at various probability distributions and see the
	      effects of the parameters.
	    </para>
	    <media type="application/x-labview-vi" src="Common_Distributions.vi">
	      <param name="viinfo" value="common_distributions.viinfo"/>
	    </media>
	  </example>
	    ]]>
          </code>
        </para>
      </example>
    </section>
  </content>
  
</document>
