Hi All,
In this simple program I am trying to pull a value from a method by calling the operator in the main(I apologize if my verbatum is incorrect, I am new to programming).
Essentially I want the instrument to read the frequency and then output next to the corresponding variable.
For instance if the Analyzer read 1400 MHz, in the console I would like to see:
"Frequency: 1400 MHz"
I am attempting to do this with multiple variables so any help would be appreciated!
Thanks!
Here is my code:
#include "stdafx.h"
#include "visa.h"
#include <iostream>
#include <fstream>
using namespace std;
int print_Freq()
{
char FreQ[2048];
int FreQSize = 2048;
ViSession rm;
viOpenDefaultRM(&rm);
ViSession v5182_signal_generator;
viOpen(rm, "TCPIP0::10.208.211.33::5025::SOCKET", VI_NULL, VI_NULL, &v5182_signal_generator);
viQueryf(v5182_signal_generator, "STAT:QUES:FREQ?\n", "%#T", FreQSize, FreQ);
char z;
z =printf(" %s\n",FreQ);
return z;
}
int print_Amp()
{
ViSession rm;
viOpenDefaultRM(&rm);
ViSession v5182_signal_generator;
viOpen(rm, "TCPIP0::10.208.211.33::5025::SOCKET", VI_NULL, VI_NULL, &v5182_signal_generator);
int z;
z = viPrintf(v5182_signal_generator, ":POW 0dBm\n");
return z;
}
int Save_Image()
{
ViSession rm;
viOpenDefaultRM(&rm);
ViSession n9010a_exa_signal_analyzer;
viOpen(rm, "TCPIP0::10.208.211.153::5025::SOCKET", VI_NULL, VI_NULL, &n9010a_exa_signal_analyzer);
viPrintf(n9010a_exa_signal_analyzer, "n9010a_exa_signal_analyzer\n");
return 0;
}
int _tmain(int argc, _TCHAR* argv[])
{
ViSession rm;
viOpenDefaultRM(&rm);
ViSession n9010a_exa_signal_analyzer;
ViSession v5182_signal_generator;
viOpen(rm, "TCPIP0::10.208.211.153::5025::SOCKET", VI_NULL, VI_NULL, &n9010a_exa_signal_analyzer);
viOpen(rm, "TCPIP0::10.208.211.33::5025::SOCKET", VI_NULL, VI_NULL, &v5182_signal_generator);
viPrintf(v5182_signal_generator, "*RCL 1\n");
viPrintf(n9010a_exa_signal_analyzer, "*RCL 1\n");
printf("You are currently viewing State 01 via v5182 Signal Generator\n");
printf(" \n");
printf("Generator Frequency: \n", print_Freq);
printf(" \n");
printf("Generator Power: \n", print_Amp);
printf(" \n");
printf("Screenshot Saved in 'My Data Directory' \n", Save_Image);
printf(" \n");
printf("Press any key to continue:\n");
getchar();
return 0;
viClose(n9010a_exa_signal_analyzer);
viClose(v5182_signal_generator);
return 0;
}