I've seen people complaining a few times in the forums that LabVIEW's inbuilt XML functions aren't very user friendly etc. Well here is an example of what can be done with them.
The methods used in extracting data from an XML document are what new users may find educational.
A Vector CANdela Studio database file contains all the diagnostic information for a given Automotive Electronic Control Unit (ECU).
My main usage for this vi is to extract UDS (ISO 14229 / ISO 15765) diagnostic information for use in automated testing. It may need some tweaking for other protocols.
If you want to use that information in a test application it can be quite tricky to extract.
There can be some very complex structures defined for datatypes etc.
This example demonstrates how you can use inbuilt LabVIEW XML functions to read all sorts of information no matter how deeply it is buried in an XML document.
This VI (and subvis) read a complex (and potentially quite large) XML file and output it's useful contents in a format that can be used by your software.
The main vi is a state machine that traverses through the relevant xml nodes creating an array of relevant nodes which are then used by subvis to extract the desired data.
The most complex subvi is the one that extracts DIDs (Data by Identifier) and information on how to extract signals from the data they return.
DIDs (can) contain complex structures with 'c' type UNIONs and STRUCTs.
The vi grabs all the subsignals defined for a DID and builds an array of signal references.
When reading a DID an array of bytes is returned. Data is extracted from the byte array according to the DID structure definition. Each STRUCT can contain STRUCTs UNIONs DATAOBJects and something called a GAPDATAOBJect.
The signal references created by this vi treat the byte array as one continuous bitstream.
Therefore each DID contains an array of signals. Each signal has a name, a startbit and a length.
Steps to execute code:
Open the vi
On the front panel, Select the CAN ID type your device uses (Leave default for example file provided)
Input the names of the DID Classes you need extracted (Leave default for example file provided)
Input the names of the diagnostic Client and Server IDs or input 0x prefixed CAN IDs (Leave default for example file provided)
Select a CANdela .cdd database file (sample provided)
It will then extract the DIDs, Datatypes and Diagnostic Trouble codes from the .cdd database file.
The results displayed on the front panel may not look all that exciting unless you've tried to do automated diagnostics on CAN.
Main Block Diagram:
Any suggestions on improvement are welcome.
VI attached below (Updated July 19, 2011)
Troy - CLD "If a hammer is the only tool you have, everything starts to look like a nail." ~ Maslow/Kaplan - Law of the instrument