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

Example.h

Included in all device call examples. Provides a function that sets the call parameters from the command line arguments.
See also:
GetSync.cpp

GetAsync.cpp

Monitor.cpp

Subscription.cpp

#include <iostream>

#ifdef CMW_WIN        // Windows
#include <windows.h>
#else                 // Unix
#include <unistd.h>
#endif

#include <rda/RDAService.h>

using namespace std;

//
// Device call parameters
//
static const char* deviceName = 0; // device name
static const char* property   = 0; // property name
static const char* cycle      = 0; // cycle selector

//
// Set device call parameters from the command line arguments
//
static void setParameters(int argc, char** argv)
{
   if (argc > 2)
   {
      deviceName = argv[1];
      property = argv[2];
      if (argc > 3) cycle = argv[3];
   }
   else
   {
      cout << "Missing command line arguments\n";
      cout << "Expected: <device name> <property name>";
      cout << " <cycle selector (optional)>\n";
      exit(1);
   }
}
//
// Sleep forever
//
static void sleepForever()
{
   while (true)
   {
      #ifdef CMW_WIN
      Sleep(1000);
      #else
      sleep(1);
      #endif
   }
}

class Example
{
   static bool flag;
   
   public:

      static void wait()
      {
         while (flag == false)
         {
            #ifdef CMW_WIN
            Sleep(1000);
            #else
            sleep(1);
            #endif
         }
      }

      static void terminate()
      {
         flag = true;
      }
};

bool Example::flag = false;

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