Database Programming for LabVIEW API

The NI-XNET software provides various methods for creating your application database configuration. The following figure shows a process for deciding the database source. A description of each step in the process follows the flowchart.

Figure 3. Decision Process for Choosing a Database Source

1378

Already Have File?

If you are testing an ECU used within a vehicle, the vehicle maker (or the maker's supplier) already may have provided a database file. This file likely would be in CANdb, FIBEX, AUTOSAR, or LDF format. When you have this file, using NI-XNET is relatively straightforward.

Can I Use File As Is?

Is the file up to date with respect to your ECU(s)?

If you do not know the answer to this question, the best choice is to assume Yes and begin using NI-XNET with the file. If you encounter problems, you can use the techniques discussed in "Edit and Select" to update your application without significant redesign.

Select From File

There are three options for selecting the database objects to use for NI-XNET sessions:
  • A LabVIEW project
  • I/O Names
  • Property Nodes
  • Edit in Memory: First, you select the frames or signals for the NI-XNET session using one of the options described in Select From File, above.

    Next, you wire the selected objects to the corresponding property node and set properties to change the value. When you edit the object using its property node, this changes the representation in memory, but does not save the change to the file. When you pass the object into the XNET Create Session VI, the changes in memory (not the original file) are used.

  • Edit the File: The NI-XNET Database Editor is a tool for editing database files for use with NI-XNET. Using this tool, you open an existing file, edit the objects, and save those changes. You can save the changes to the existing file or a new file.

    When you have a file with the changes you need, you select objects in your application as described in "Select From File."

Edit and Select

There are two options for editing the database objects to use for NI-XNET sessions: edit in memory and edit the file.

Want to Use a File?

If you do not have a usable database file, you can choose to create a file or avoid files altogether for a self-contained application.

Create New File Using Editor

You can use the NI-XNET Database Editor to create a new database file. Once you have a file, you select objects in your application as described in "Select From File."

As a general rule, for FlexRay applications, using a FIBEX file is recommended. FlexRay communication configuration requires a large number of complex properties, and storage in a file makes this easier to manage. The NI-XNET Database Editor has features that facilitate this configuration.

Create in Memory

You can use the XNET Database Create Object VI to create new database objects in memory. Using this technique, you can avoid files entirely and make your application self contained.

You configure each object you create using the property node. Each class of database object contains required properties that you must set (refer to "Required Properties").

Because CAN is a more straightforward protocol, it is easier to create a self-contained application. For example, you can create a session to transmit a CAN frame with only two objects.

Figure 4. Create a Cluster and Frame for CAN

1378

The figure above shows a sample diagram that creates a cluster and frame in memory. The database name is :memory:. This special database name specifies a database that does not originate from a file. The cluster name is myCluster. For CAN, the only property required for the cluster is Baud Rate. The cluster is wired to create a frame object named myFrame. The frame has several required properties. The XNET Frame CAN:Timing Type property specifies how to transmit the frame, with Cyclic Data meaning to transmit every CAN:Transmit Time seconds (0.01, or 10 ms). The remaining properties configure the frame to use 8 bytes of payload data and CAN standard ID 5. If the subsequent diagram passed the frame to the XNET Create Session (Frame Output Queued) VI, this would create a session you can use to write data for transmit.

After you create and configure objects in memory, you can use >XNET Database Save VI to save the objects to a file. This enables you to implement a database editor within your application.

Multiple Databases Simultaneously

NI-XNET allows up to 63 database sessions to be open at the same time. You can open any database from a database file or in memory. To open multiple in-memory databases, use the name :memory[<digit>]:; for example, :memory:, :memory1:, :memory2:.