Example Code

Around the World in 80 Cases

Code and Documents

Attachment

Functional Description

Ever fancied taking an insightful and cultured excursion to Europe? A glamorous trek across North America? Perhaps an adventure to the tropical climes of the Far East? Well now you can! This application gives you an opportunity to all of these things... and learn a little about the LabVIEW State Machine Design Architecture in the process. This application is an example of the State Machine design architecture - each frame of the nested case-structure represents a different international city. Running the application allows you to embark on a Phileas Fogg style journey around the world.

(Disclaimer: I may have made the application sound a little more exciting than it really is.)

Front panel.JPG

Caveats and Additional Notes

  • The world tour begins and ends in Belfast, Northern Ireland.
  • The first few cities visited on the tour are European. But once we have arrived in Stockholm, we need to make a decision... do we fly East or West?
  • If you decide to fly West, you will visit North America - including the home town of National Instruments, Austin, Texas.
  • If you fly East you visit Oceania and Asia.
  • If you choose to visit North America you will invariably spend some time in Las Vegas. Note that the program forces you to stay in Vegas until you hit the relevant button on the front panel (presumably because you have either won a million dollars or bankrupt yourself.)
  • You can cut your tour short at any given time by hitting the "End Journey" Button on the user interface. This will return you safely to Belfast.

The ability to remain in certain locations and programmatically change the tour on the fly illustrates the flexibility of the State Machine design architecture. Standard sequential programming is far too rigid to implement an application as flexible as this one.

A FINAL NOTE: This application also illustrates a example of the use of a type definition. The code uses a enumerated control to decide which city (state) you will fly (transition) to next. Because the enumerated list of cities is a type definition, if you wanted to add a city to the world tour you could simply add a new item to the type definition (.ctl file). This modification will then propagate throughout your code. Without the use of the type def, you would have had to update every single use of the enumerated control on the block diagram. A monotonous and laborious task!!

Rich Roberts
Senior Marketing Engineer, National Instruments
Connect on LinkedIn: https://www.linkedin.com/in/richard-roberts-4176a27b/

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Contributors