C++ Example for Opt. 004 COM Command

#include "stdafx.h"

#include <atlstr.h>

#import "C:\\Program Files (x86)\\Keysight\\Materials Measurement Suite 2020\\MaterialsMeas.dll"

 

int _tmain(int argc, _TCHAR* argv[])

{

                CoInitialize(NULL);

                MaterialsMeasLib::ICoaxialProbePtr pp(__uuidof(MaterialsMeasLib::CoaxialProbe));

                HRESULT r = pp->Init();

                pp->Show();

                float f1, f2;

                pp->GetStartFrequency(&f1);

                pp->GetStopFrequency(&f2);

 

                //Calibrate before measurement, three steps calibration.

                pp->CalibrateProbeStd1();           //calibrate open

                pp->CalibrateProbeStd2();           //calibrate short

                pp->CalibrateProbeStd3();           //calibrate load and download calibration.

 

                HRESULT h3 = pp->TriggerProbe();           //h3=S_OK means it succeed, S_FALSE means it failed.   

                if(S_OK == h3)

                {

                                const long num = 101;

                                float f[num] = { 0.0, };

                                float s11_r[num] = { 0.0, };

                                float s11_i[num] = { 0.0, };

                                long n;

                                r = pp->GetNumberPoints(&n);

                                float temperature;

                                r = pp->GetTemperature(&temperature);

 

                                for (int i = 0; i < n; i++)

                                {

                                                pp->GetS11Data(i, &f[i], &s11_r[i], &s11_i[i]);     //Here it gets the results one point by one point.

                                }

                                CString str;

                                str.Format(_T("n=%d, f[0]=%f, s11_r[0]=%f, s11_i[0]=%f, f[1]=%f, s11_r[1]=%f, s11_i[1]=%f"), n, f[0], s11_r[0], s11_i[0], f[1], s11_r[1], s11_i[1]);

                }

 

                return 0;

}