Quantum Data 881 User Manual page 562

Hide thumbs Also See for 881:
Table of Contents

Advertisement

testapi.cpp
184
Chapter 15 Script SDK
This example demonstrates the following functions of the API:
Sending commands and getting responses back
Pause()
Multi-line response
Operators "=" and "+="
QDLcd associated API commands: InputInteger(), InputFloat(), and
WaitForButtonPress()
GetUIntResponse()
GetIntResponse()
GetDoubleResponse()
GetBoolResponse()
Detecting an invalid command
#include <QDScriptContext.h>
#include <stdio.h>
bool Script_testapi( QDScriptContext& sc )
{
// =========================================================
// Demonstration of sending command and getting response back
// =========================================================
// one way to execute a command/query
sc.Exec("CIOY");
// another way to execute a command/query
sc.SetCmdName("VERF?"); // query generator firmware version
sc.Exec();
printf("The return value of command \"%s\" is %s\n", sc.GetCmdName(),
sc.GetResponse());
// =========================================================
// Demonstration of Pause()
// =========================================================
printf("Pause for 5 seconds\n");
sc.Pause( 5000 );
if (sc.Canceled()) {
return true;
}
printf("\nWake up from Pause(5000)\n");
sc.SetCmdName("VERG?"); // query generator gateware versions
sc.Exec();
if (sc.Succeed()) {
printf("\nThe return value of command \"%s\" is %s\n",
sc.GetCmdName(), sc.GetResponse());
}
// enable printf to serial terminal
// execute the command
// execute the command
// was previous command successful?

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

882

Table of Contents