From 933b289f7ab5c965ad32207f2695e24651813d1d Mon Sep 17 00:00:00 2001 From: Benjamin Renard Date: Tue, 1 Oct 2019 15:30:59 +0200 Subject: [PATCH] Support for time in double format --- src/DDClientLibC/DD_client.c | 12 +++++++++++- src/DDClientLibC/INCLUDE/DD_comm.h | 9 +++++++++ src/DDClientLibCpp/DD_client.cc | 12 ++++++++++-- 3 files changed, 30 insertions(+), 3 deletions(-) diff --git a/src/DDClientLibC/DD_client.c b/src/DDClientLibC/DD_client.c index 2bdb51a..26b7ecb 100755 --- a/src/DDClientLibC/DD_client.c +++ b/src/DDClientLibC/DD_client.c @@ -536,10 +536,20 @@ int DD_SetTimeInfo(int VarID, char *Time, double *RealTime) if (err < 1) return err; err = DD_GetData(VarID, "Time", TimeInt, &data); + if (err < 0) return err; + if (data->VarNumber < 1) return OUTOFTIME; - *RealTime = DD_Time2Double((char *)data->Variables[0]); + if (data->type == DD_CHAR) { + *RealTime = DD_Time2Double((char *)data->Variables[0]); + } + else if (data->type == DD_DOUBLE) { + *RealTime = *((double*)data->Variables[0]); + } + else { + return DATAFILEERR; + } //BRE - When the corresponding time is the last one of a file, MOREDATA is returned by DDServer. // => force recall of DD_GetData to open the next file and finish correctly the request diff --git a/src/DDClientLibC/INCLUDE/DD_comm.h b/src/DDClientLibC/INCLUDE/DD_comm.h index d38494d..a2ff94b 100755 --- a/src/DDClientLibC/INCLUDE/DD_comm.h +++ b/src/DDClientLibC/INCLUDE/DD_comm.h @@ -302,6 +302,15 @@ extern int Cache_ReleaseDataFileAccess(DD_Var_t *D); extern int Cache_CloseFile(DD_Var_t *D); /* + * + */ +extern int Time_GetVarID(int ncID); + +extern int Time_IsDoubleVar(int ncID, int timeVarID); + +extern double Time_GetValueFromVar(int ncID, int timeVarID, int isDoubleTime, int recNum); + +/* * Open Virtual instrument by name and returns the ID * Returns negative value in case of error (see DD.h)or OK */ diff --git a/src/DDClientLibCpp/DD_client.cc b/src/DDClientLibCpp/DD_client.cc index e26f753..f7c1e5c 100644 --- a/src/DDClientLibCpp/DD_client.cc +++ b/src/DDClientLibCpp/DD_client.cc @@ -244,7 +244,7 @@ int DD_Client::GetSocket() #ifdef LOG4CXX LOG4CXX_ERROR(_logger, "DD_Client::GetSocket - Connection to server socket error - " << strerror (errnum)); #endif - perror("connect"); + perror(strerror (errnum)); return(-1); } @@ -672,7 +672,15 @@ int DD_Client:: DD_SetTimeInfo(int VarID, char *Time, double *RealTime) return OUTOFTIME; } - *RealTime = DD_Time2Double((char *)data->Variables[0]); + if (data->type == DD_CHAR) { + *RealTime = DD_Time2Double((char *)data->Variables[0]); + } + else if (data->type == DD_DOUBLE) { + *RealTime = *((double*)data->Variables[0]); + } + else { + return DATAFILEERR; + } //BRE - When the corresponding time is the last one of a file, MOREDATA is returned by DDServer. // => force recall of DD_GetData to open the next file and finish correctly the request -- libgit2 0.21.2