Main Page | Namespace List | Class Hierarchy | Class List | File List | Class Members | Examples

GetSync.cpp

This is an example of how to use the synchronous get call. The program reads and prints a value of the device property specified by the command line arguments (device name, property name, cycle selector).
See also:
Example.h
#include "Example.h"

int main(int argc, char** argv)
{
   //
   // Set device call parameters (deviceName, property, cycle) from
   // the command line arguments (see Example.h).
   //
   setParameters(argc, argv);
   
   try
   {
      //
      // Initialize RDA and obtain the device handle
      //
      rdaRDAService* rda = rdaRDAService::init();
      rdaDeviceHandle* device = rda->getDeviceHandle(deviceName);
      //
      // Read and print the property value
      //
      rdaData* result;
      if (cycle == 0) result = device->get(property);
      else result = device->get(property, cycle);
      cout << *result;
      //
      // The result Data was dynamically allocated by RDA and must be
      // released by the caller.
      //
      delete result;
   }
   catch(const rdaException& ex)
   {
      cout << ex << endl;
      return 1;
   }
   catch(const rdaInternalError& ex)
   {
      cout << ex << endl;
      return 1;
   }

   return 0;
}

RDA-2.3 documentation - 27 Jun 2007 - N.Trofimov