To merge two databases on the same computer, you can use the Archive Traces VI. Suppose you have two databases, databaseA and databaseB. Use the Historical Trend Express VI to display the data of both databases, as shown in the following figures.Figure 1. Historical data in databaseAFigure 2. Historical data in databaseBThe following figure illustrates the front panel and block diagram of a VI that merges databaseA and databaseB. You specify the location of databaseA and the location of the databaseB in the First Database control and Second Database control, respectively. The Archive Traces VI combines the data in databaseA with the data in databaseB and stores the data in the same directory as databaseB. Refer to the following figure for the front panel and block diagram to merge these two databases.Figure 3. Front panel of merging one database into the directory of anotherFigure 4. Block diagram of merging one database into the directory of anotherThe block diagram in the previous figure shows an example of using the Archive Traces VI to combine all the data in both databases. The following figure displays the data of databaseB after combining all the data.Figure 5. Data of databaseB after the mergingNote: You can archive selected data by wiring the Trace Names input to the Archive Traces VI. You can also use the Archive Traces VI to merge the data of two databases together and store the data into a new directory. In this case, you need to use the Archive Traces VI twice. The first Archive Traces VI stores the data of databaseA into the new directory. The second Archive Traces VI merges databaseB with databaseA in the new directory. The following figure illustrates the front panel and block diagram of a VI that merges the two databases into a new directory.Figure 6. Front panel of merging two databases into a new directoryFigure 7. Block diagram of merging two databases into a new directoryAccording to the previous figure, the Archive Traces VI merges databaseA and databaseB into a new database and stores the data in the newdatabase directory.
A use case where you want to merge two databases logged on different computers is redundancy. In a redundancy system, the primary computer logs to its own database. When the primary computer logs off, the secondary computer takes control and logs data to its own database. After the primary computer logs on again, you need to merge the database on the secondary computer to the database on the primary computer to fill in the data gap.You can use the Archive Traces VI to merge two databases logged on different computers. Suppose that you have two computers monitoring temperature data, TestPC1 and TestPC2. After both computers finish logging data, you want to merge the databases on both computers into one computer, TestPC1. Use the Historical Data to view the database on each computer, as shown in the following figures.Figure 8. Database on TestPC1Figure 9. Database on TestPC2You must complete the following tasks to merge the databases on both computers into TestPC1.1. Manually copy the database from TestPC2 to a new folder on TestPC1.
Note: To manually copy the database, you must stop the Shared Variable Engine (SVE) and the Logos services. Refer to the LabVIEW Help to learn how to stop the SVE. If you cannot stop the Logos services, use the Detach Database VI in the DSC Module to detach the database before copying the database. Refer to the LabVIEW Help for more information about the Detach Database VI. If you create a copy of the database while the SVE or the Logos services are running, you might get an inconsistent copy of the database. If you cannot stop the engine or the services, use the Archive Traces VI to make a copy programmatically.
2. Rename the data in the database on TestPC2 to match the trace names in TestPC1 using the Rename Historical Data VI.
For example, the data logged in the process named LabVIEW (the default process name) on TestCpu2 has the following prefix:\\TestCpu2\LabVIEW\...
The data logged in the process named MyLabVIEWProcess (the edited process name) on TestCpu1 has the following prefix:\\TestCpu1\MyLabVIEWProcess\...
Note: You do not need to name these data with the same name. However, if the data on both computers represent the same traces but are logged from different computers, you can keep the same name for the traces when merging the databases.
3. Merge the two databases into a new database directory using the Archive Traces VI. The following figure is an example of the front panel and block diagram of a VI that merges two databases logged on different computers. Notice that the names of the traces are different and are renamed.Figure 10. Front panel of merging two databases logged on different computersFigure 11. Block diagram of merging two databases logged on different computers4. View the new database in the Historical Data Viewer to verify that the merging is complete. You can also use the NI HyperTrend control in LabVIEW to view the data.The following figure displays the database after merging two databases logged on different computers.Figure 12. Merged database consisting of data logged from TestCpu1 and TestCpu2
In applications that require merging two databases, you can use either the Historical Data Viewer in MAX or the Historical VIs in the DSC Module. Using the Archive Traces VI, you can copy a database from one directory into a different directory on the same computer without stopping the logging process. You also can use the Historical VIs to merge the databases logged on different computers.
Collaborate with other users in our discussion forums
A valid service agreement may be required, and support options vary by country.