Using LabVIEW Scripting to Enforce Good Programming Practices

  Print Print

"LabVIEW VI Scripting is a real step forward in providing customizable software development tools that improve code and make the life of a LabVIEW architect easier."

- Steve Watts, SSDC

The Challenge:
Developing a well-structured LabVIEW design methodology that results in many similarly structured VIs, easy generation of repeated work, and a painless way to enforce design rules and documentation.

The Solution:
Automatically generating LabVIEW block diagrams from dialog-style data input using the LabVIEW VI Scripting API.

Author(s):
Steve Watts - SSDC

Our company methodology is described in our book A Software Engineering Approach to LabVIEW. In our terminology, a LabVIEW “component” is a VI with an enumerated type command wired to a fully populated Case structure and some form of local memory to enable it to handle its own state data.

The LabVIEW VI Scripting API allowed us to write a small wizard that automatically generates LabVIEW block diagram code. The wizard applies the following design rules to ensure each component is built to the same criteria.

Design Rules

  • The command enumerated type should be type-defined.
  • The connector pane pattern is 4 in, 4 out, and 2 up the middle.
  • All icons are uniform.
  • The command enumerated type is wired to one of the middle connections, and the connection is set to Required.
  • Error clusters are wired to the bottom input and output.
  • 3 inputs and 3 outputs are allowed.
  • Local memory is wired through each Case using feedback nodes.
  • Date, description, version, and author need to be completed to move to the next step.

Component Builder

The first page in the wizard is used to set the VI's path, description, author, and date. The next step is not allowed until some data is entered in each. This ensures adherence to documentation standards.

The second page deals with icon design. Most icons are simple text, so the icon page allows text entry with a standard title box at the top.

The third page is setting the command enumerated type control. This can be entered manually or loaded from a comma separated text file. Duplicate checking is undertaken, and the descriptions of the commands are included automatically in the VI documentation.

The next three pages deal with inputs, outputs, and local memory. The local memory is automatically wired through each Case statement.

The final page allows the component to be built, saved, and printed.

Our Component Builder tool is the first in a complete project template generator suite. It's beneficial because it forces LabVIEW architects to think about their designs, follow the template, and document from the beginning, but it also saves time. Applying these rules whilst saving time is a bonus, and this type of gain can be achieved in many areas.

LabVIEW VI Scripting is a real step forward in providing customizable software development tools that improve code and make the life of a LabVIEW architect easier. We believe it is going to increase productivity and allow LabVIEW architects to improve their G software procedures. This is one small part of a planned project-creation wizard that will enable us to tie in project documentation and standardise project structure and architecture. This part of our system will allow us to add more tools to automate repeated tasks on our own projects.

Author Information:
Steve Watts
SSDC
Winchester
United Kingdom
swatts@ssdc.co.uk

Bookmark and Share


Explore the NI Developer Community

Discover and collaborate on the latest example code and tutorials with a worldwide community of engineers and scientists.

‌Check‌ out‌ the‌ NI‌ Community


Who is National Instruments?

National Instruments provides a graphical system design platform for test, control, and embedded design applications that is transforming the way engineers and scientists design, prototype, and deploy systems.

‌Learn‌ more‌ about‌ NI