User Tools

Site Tools


kb:bestpractices:codingconventions:architecture

01 Architecture

General

  • When working with clusters and SubVIs, pass only the data the SubVI needs. Do not let the SubVIs consume the entire cluster.
  • Do NOT use variant attributes for data storage unless their high performance is definitely needed.
    • Attributes hide away any information about the datatypes at edit time
  • Wrap VIs in classes (.lvclass) or libraries (.lvlib) for name spacing and generally improved encapsulation / cohesion / coupling

Reentrancy

  • If a technology supports multiple threads (more than one instance in memory at the same time), all the VIs of the corresponding driver usually need to be set to reentrant execution.

Functions/Primitives

  • Do not use “First Call?”, use an FGV instead
  • Use Compound Arithmetic instead of boolean logic gates
  • Do NOT use invert options on boolean functions and operators
    • use a separate not operator instead

Constants

  • For constants that are reused throughout the project, create a subVI that only contains a single constant on the block diagram and one indicator returning the constant value

Structures

Unwired Terminals

  • Use “Use Default If Unwired” appropriately
  • If no default value should ever be used, enable “Linked Input Tunnel”

Conditional Disable Structures

  • When using CD Structures, put them into the project tree:
    • as far up as possible (ie. direct at the project root level, as opposed to the targets)
    • as far down as necessary (eg to distinguish different FPGA targets)
  • For each CD Symbol in the project, add a log entry or similar to your project so you can identify at runtime which values were defined for the symbols
    • Put these into a subVI directly after starting the application
    • When using HSE libs, put this subVI directly after initialising the HSE-Logger

Communication

  • Transferring data from one loop to another loop (VI-local)
    • Using VI server (reference or property node) to update the value of a control or indicator is the least efficient mechanism by far.
    • Local variables come with only a slight overhead to directly writing to the terminal.
    • Global variable would be the fastest with the additional caveats of race conditions and issues when global variables are not handled correctly.
    • RT FIFO or a User Event add context and encapsulation.

Database

  • Wrap each query in a separate SubVI
    • this allows for easy reuse
    • add documentation to describe the returned values
    • optional: convert the returned 2d-array of strings into a 1d-array of typedef'ed cluster

Type Conversions

Array to Cluster

  • The Array to Cluster node has the number of elements hard-coded
  • As an array is dynamic, we need to check the size during runtime
  • To convert the generic cluster to a typedef-ed one, use the Coerce To Type function

kb/bestpractices/codingconventions/architecture.txt · Last modified: 2024/08/09 07:46 by joerg.hampel