Academic Company Events NI Developer Zone Support Solutions Products & Services Contact NI MyNI

Document Type: Tutorial
NI Supported: Yes
Publish Date: Dec 7, 2006

Merging Two Databases in the LabVIEW DSC Module Using the Citadel Historical VIs

2 ratings | 5.00 out of 5
Print

Overview


Once data is logged using the LabVIEW DSC module, there are two methods for manipulating the database files. One option is using the Historical Data Viewer in Measurement and Automation Explorer (MAX). This is useful when the manipulation of the database does not need to be done programmatically. A programmatic option exists in the LabVIEW DSC module using the new Historical VIs. Using these VIs, data can be archived during logging to a new directory, merged with other databases, and collected from other computers.

These new Historical VIs are located in the Functions»Historical Data Palette. See the snapshot in Figure 1.1:


Figure 1.1: Historical Data Palette as seen in the LabVIEW DSC Module 6.1

Using the Archive Database VI, a database can be copied from one directory into a different directory. This VI does not require that the logging process be stopped. It can archive the database while the database is logging new data points. The wiring diagram of the Archive Database VI is shown below:




Figure 1.2: Wiring Diagram of the Archive Database VI.

Depending on the functionality of the data logging system, several archiving cases could apply. Two cases involving archiving historical databases are explored in the following sections.

Case 1: Merging Two Databases on the Same Computer:



The only VI that is necessary to merge two databases on the same computer is the Archive Database VI. Suppose there exists two databases, databaseA and databaseB. The contents of both databases can be seen using the Historical Trend Viewer in Figure 2.1 and Figure 2.2.



[+] Enlarge Image
Figure 2.1: Historical data in databaseA



[+] Enlarge Image
Figure 2.2: Historical data in databaseB

By selecting databaseA as the source Citadel path input and databaseB as the destination Citadel path, the Archive VI will combine the data in databaseA with the data in databaseB. Then, it will store the data in the same directory as databaseB. Figure 2.3 illustrates the wiring necessary to merge these two databases.




Figure 2.3: Merging one database into the directory of another.

Using the Archive Database VI as shown in Figure 2.3, all traces in both of the databases will be combined in the directory of databaseB. See Figure 2.4.


[+] Enlarge Image
Figure 2.4: Contents of databaseB after databaseA and databaseB have been merged.

Note: Select tags or Citadel traces can be archived by wiring the tags/traces input to the Archive Database VI.

To store the two databases into a new directory, two Archive Database VIs are needed. The first Archive Database VI will store the contents of databaseA into the new directory. Then, the second Archive Database VI will merge databaseB with databaseB in the new directory. See Figure 2.5




Figure 2.5: Merging two databases into a new directory

Case 2: Merging Two Databases Logged on Different Computers:



Suppose that there are two computers monitoring temperature data, TestCpu1 and TestCpu2. After the logging is complete, the databases on both computers need to be combined on one computer, TestCpu1.

Note: A typical use case is redundancy. Your primary machine is logging to its own database. The machine goes down and the secondary machine takes the controls over. It logs data to its own database. After the primary machine goes up again, you'll need to merge secondary database to the primary to fill in the gap.

This can also be done using the Archive Database VI. The database on TestCpu1 has the following data as viewed by the Measurement and Automation Explorer (MAX) Historical Data Viewer in Figure 3.1. The database on TestCpu2 can be seen in Figure 3.2.


[+] Enlarge Image
Figure 3.1: Data logged in databaseA on TestCpu1.



[+] Enlarge Image
Figure 3.2: Data logged in databaseB on TestCpu2.

The following steps are necessary to Merge databaseA and databaseB on TestCpu1:

1. Manually copy the database from the second computer to a new folder on the TestCpu1 machine.

IMPORTANT: If you want to make a manual copy, you have to stop the DSC engine and the Logos services. Refer to the document linked below to learn how to stop the services. If you create a copy while the service is running, you might get an inconsistent copy of the database. If you cannot stop the engine or the services, use the Archive Database.vi to make a copy dynamically (see above).

2. Rename the traces in the database to match the trace names used in TestCpu1 using the Rename Traces VI. See the Rename Traces VI Wiring Diagram in Figure 3.3. For example:

The traces logged in the process named LabVIEW (the default process name) on TestCpu2 have the prefix:
\\TestCpu2\LabVIEW\.....

The traces logged in the process named MyLabVIEWProcess (Selected in the Tag Configuration Editor) on TestCpu1 have the prefix:
\\TestCpu1\MyLabVIEWProcess\....
Note: These traces do not need to be named the same. However, if the data logged on both computers represent the same tags but logged from different computers, then it is desirable to keep the same name for the traces when merging the databases.

Figure 3.3: Wiring Diagram for the Rename Traces.vi

3. Merge the two databases into a new database folder using the Archive Database VI. See Figure 3.4 for an example front panel and Figure 3.5 for the example wire diagram.


[+] Enlarge Image
Figure 3.4: Front panel example of merging two databases logged on different computers.
Notice that the names of the traces are different and are renamed.



[+] Enlarge Image
Figure 3.5: Wiring diagram of the front panel in Figure 3.4

4. View the new database in the Historical Data Viewer to verify that the merge was successful. See the newly merged database in Figure 3.4.

Note: You have to use either the MAX based Historical Data Viewer or the HI HyperTrend control (Controls»Trends»HI HyperTrend) to view the data. The classic Hisrotical Trend Viewer (HTV) won't show the merged data.


[+] Enlarge Image
Figure 3.6: Merged database consisting of data logged from TestCpu1 and TestCpu2.

Related Links:
How Do I Stop Logos Services
Merging Two Databases Using the Historical Data Viewer in MAX
2 ratings | 5.00 out of 5
Print

Reader Comments | Submit a comment »

Merging from Different Computers without stopping Logos Services
Stopping the Logos Services never worked on my computers. I used the above 1st case to create a Backup database on the Remote computer, Detached the Backup using MAX, then manually copied it over to the Local computer, and reattached it using MAX. From there, the rest went just like it's outlined.
- bryan.gardner@ngc.com - Oct 21, 2005

 

Legal
This tutorial (this "tutorial") was developed by National Instruments ("NI"). Although technical support of this tutorial may be made available by National Instruments, the content in this tutorial may not be completely tested and verified, and NI does not guarantee its quality in any way or that NI will continue to support this content with each new revision of related products and drivers. THIS TUTORIAL IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND AND SUBJECT TO CERTAIN RESTRICTIONS AS MORE SPECIFICALLY SET FORTH IN NI.COM'S TERMS OF USE (http://ni.com/legal/termsofuse/unitedstates/us/).