testGetData.c 1.59 KB
/*=============================================================
 * testGetData.c
 * Test data collection for a a given parameter (hard coded)
 *  Oct 2019, V.1.0, Renard
 *=============================================================*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <DD.h>
#include <time.h>
#include <string.h>
#include <sys/time.h>

#define DATA_VI        "mes:mag:orb\0"
#define DATA_STARTTIME "2012000000000000\0"
#define DATA_TIMEINT   "0000010000000000\0"
#define DATA_TIMENAME  "Time\0"
#define DATA_PARAMNAME "B_MSO\0"


/*
 * Main
 */
int main()
{
   char ViName[100];
   char StartTime[17];
   char TimeInt[17];
   char ParamName[100];
   char TimeName[100];

   strcpy(ViName,DATA_VI);
   strcpy(StartTime, DATA_STARTTIME);
   strcpy(TimeInt, DATA_TIMEINT);
   strcpy(ParamName, DATA_PARAMNAME);
   strcpy(TimeName, DATA_TIMENAME);

   char* ParNames[2] = {TimeName, ParamName};

   int ID, error;

   double RealTime;
   DD_data_t *data;

   ID = DD_SetVariable(ViName);
   if(ID < 0)
   {
     error = DD_Close(99);
     printf("[ERROR]\n");
     return 0;
   }

   error = DD_SetTimeInfo(ID, StartTime, &RealTime);
   if(error < 0)
   {
     error = DD_Close(ID);
     printf("[ERROR]\n");
     return 0;
   }

   do
   {
      error = DD_GetMultiData(ID, 2, ParNames, TimeInt, &data, 1);
      if(error < 0)
      {
         error = DD_Close(ID);
         printf("[ERROR]\n");
         return 0;
      }
      if(error == MOREDELAY)
      {
         error = MOREDATA;
      }
   }
   while(error == MOREDATA);

   error = DD_Close(ID);

   printf("[SUCESS]\n");

   return 1;
}