This is an example of STD0903 Converter usage for VMTI data traversing. This code snippet demonstrates how to go over the VMTI packet and print out the data.
- Add references to STD0903ConvLib.dll and lib files, include a header file.
#include "ISTD0903Conv.h"
- Decode the data buffer or fill it with the data.
- Traverse the data tree.
VARIANT vt;
TargetLocalDataIterator ld_it;
{
VariantInit(&vt);
VTargetLocalDataTag tag = (*ld_it).first;
PrintData(vt);
if (tag == VTargetLocalDataTag::UNIX_Time_Stamp)
cout << endl;
VariantClear(&vt);
}
TargetSeriesIterator ts_it;
{
TargetPackIterator tp_it;
cout <<
"\tTarget Id - " << pTargetPack->
TargetID << endl;
for (tp_it = pTargetPack->GetVTargetPackItems().begin(); tp_it != pTargetPack->GetVTargetPackItems().end(); tp_it++)
{
VariantInit(&vt);
VTargetPackTag tag = (*tp_it).first;
if (tag < Target_Location)
PrintData(vt);
else
{
PrintHierarchyData(pVmtiConv, tag, vt);
}
cout << endl;
VariantClear(&vt);
}
}
cout << endl;
Here is a code of the PrintData helper function used above:
{
switch (vt.vt)
{
case VT_BSTR:
cout << (char*)(_bstr_t)vt;
break;
case VT_UI1:
case VT_UI2:
case VT_UI4:
cout << vt.uintVal;
break;
case VT_UI8:
cout << vt.ullVal;
break;
case VT_R4:
cout << vt.fltVal;
break;
case VT_R8:
cout << vt.dblVal;
break;
}
}
For the complete sample source please see Sample Code - MISB 0903 Converter Demo Application (C++)