/*================================================================================================= * DD SYSTEM * DD.h * Version: 5.2 * Description: The public header to use DD library libDD.a * List of changes: * Apr. 17, 2002 Fedorov, - New error constant to interrupt the * transmission if data dimensions are changed from file * to file * Nov 18, 2004 - V.4.2 - Fedorov, New errors for CACH manipulating * Jun 17, 2007 - V.4.6 Fedorov New requestes and external executables * Aug 02, 2007 - V.4.7 Fedorov Modification of call external executables * Sep 24, 2007 - V.5.0 Fedorov New status of Get Data: MOREDELAY * May 21, 2008 - V.5.1 Fedorov New Status of SetTime: CTIMEISSHIFTED * Oct 18, 2012 - V.5.2 Knizhnikova New DD_SetTimeInfo() function * Dec 15, 2012 - Fedorov, V.6.0. DD_GetMultiData(). Request structure is very changed, CurrentData is not a global structure *=================================================================================================*/ #ifndef DD_H_ #define DD_H_ // #define LOG4CXX #include "DD_comm.hh" #include "DD_Access.hh" #include "DD_time.hh" #ifdef LOG4CXX #include #endif #define VERSION "V.6.0" class DD_Client { private: /* variable for DD_GetInform */ DD_data_t idd; public: DD_data_t *CurrentData; /* Data block received recently */ int _varNumber; int SocketID; /* Global socket id for this communication session */ char UserName[USRLENGTH]; /* string for user name */ char UserHost[MAXHOSTLENGTH]; /* IP of user's host in a string form */ int UserID; /* ID of user at the user's host */ /* User's ID at a local client host */ unsigned int m1 ; unsigned int m2 ; unsigned int m3 ; unsigned int m4 ; //struct hostent *Host; /* name & internet (32b) address for // remout hosts (see netdb.h) */ char RemSerName[PATHLENGTH]; /* name of remote server */ //struct sockaddr_in IntAFAddr; /* structure of internet address of type AF_INET // see // to get name of socket we should // to convert pointer to this structure // to pointer to "srtruct sockaddr" where // all fields are "char array". */ caddr_t buffSetVarialbe; XDR xdrs; /* variable for DD_SetTime */ caddr_t bufDD_SetTime; XDR xdrsDD_SetTime; int op; char TimeInt[17]; /* variable for DD_GetData */ caddr_t bufDD_GetData ; XDR xdrsDD_GetData; int LastPacketFlag; /* variable for DD_Close*/ caddr_t bufDD_Close; XDR xdrsDD_Close; int opDD_Close; /* variable for DD_AddDataSet */ caddr_t bufDD_AddDataSet; XDR xdrsDD_AddDataSet; int opDD_AddDataSet; /* variable for DD_GetVersion */ const char *Version; DD_Client(); ~DD_Client(); /*------------------- FUNCTIONS ---------------------------*/ int ReceiveFromNet(char *buf, int PacketSize); int GetUserHost(); void setUserHost(const char* host); void setUserName(const char* name); int getInfoFromHostName(const char *hostName, struct sockaddr_in &addr); int GetSocket(); int DD_SetVariable(char *VarName); /* * VarName - full name of variable :: * Returns VarID or negative in case of error (see bellow) */ int DD_GetInform(int VarID,char *AttrName, DD_data_t **data); /* * VarID - Variable ID from DD_SetVariable * AttrName - name of attribute ( defined by konvention ) * data - address of data structure * Returns 1 if OK and negative value in case of error (see bellow) */ int DD_SetTime(int VarID, char *Time); /* * VarID - Variable ID from DD_SetVariable * Time - string defined in DD_time.h * Returns 1 if OK and negative value in case of error (see bellow) */ int DD_SetTimeInfo(int VarID, char *Time, double *RealTime); /* * VarID - Variable ID from DD_SetVariable * Time - string defined in DD_time.h * RealTime - time pointer was set to * Returns 1 if OK and negative value in case of error (see bellow) */ int DD_GetData(int VarID, char *VarName, char *TimeInt, DD_data_t **data); /* * VarID - Variable ID from DD_SetVariable * VarName - Name of requested Variable * TimeInt - String of Time interval in DD_time style * data - address of data structure * Returns 1 if OK and negative value in case of error (see bellow) */ int DD_GetMultiData(int VarID,size_t VarSize, char **VarNames,char *TimeInt,DD_data_t **data, int BackFlag); /* * VarID - Variable ID from DD_SetVariable * VarSize - number of variables to return * VarNames - the array of Names of the requested Variable * TimeInt - String of Time interval in DD_time style * data - Data structures array * BackFlag - 0 - pointer is at the lasy position, 1 - pointer returns to the start point * Returns 1 if OK and negative value in case of error (see bellow) */ int DD_MovePoint(int VarID, int RecordNumber); /* * VarID - Open virtual instrument ID * int RecordNumber - +/- records to move * Move pointer in the open instrument and return 1 or negative if error */ int DD_Close(int VarID); /* * VarID - Variable ID from DD_SetVariable * Returns 1 if OK and negative value in case of error (see bellow) */ const char *DD_GetVersion(); /* * return static pointer to internal string with the DDLIB-SERVER package version */ /*----------- Data Update functions -----------------------------------*/ int DD_AddDataSet(char *DataSetName, char *RemSetID, char *BaseName); /* * Request for new VI. See ../DOC/TECHDOC/DDServFunct.html */ private: #ifdef LOG4CXX static log4cxx::LoggerPtr _logger; #endif }; /*--------------------- CONSTANTS -----------------------------------------*/ #define MOREDATA 1 /* There is data, but we have to call GetData again right now*/ #define MOREDELAY 2 /* There is data, but we have to call GetData again after delay */ #define OK 0 /* It is last data packet */ #define NOCONNECTION -1 #define TOOMANYREQ -2 #define REQSENDERR -3 #define REPLYRECERR -4 #define NOID -5 #define NOREFFILE -6 #define NOTIMESFILE -7 #define NOINFOFILE -8 #define NOVAR -9 #define OUTOFTIME -10 #define CACHERR -11 /* The error occured when program manipulated the cach */ #define CACHTOOREC -33 /* Off files in the CASH are created less then 5 sec ago */ #define WAITEXTCALL -34 /* Server Waits external call finish */ #define TRYAGAIN -35 /* Times file is locked. This request should be repeated again */ #define NODATAATTIME -36 /* Requested time is inside NODATA time interval */ #define GAPISSMALL -37 /* Gap is too small to call external archive */ #define CTIMEISSHIFTED -38 /* The request was in NoData interval, try again with time at the end */ #define DATAFILEERR -12 /* The error while manipulate with data file */ #define ENVIRERROR -13 /* Error in Environments */ #define NOPOINTER -14 /* The pointer points nowhere, SetTime were failed */ #define INTSERERR -15 /* Server internal error */ #define TIMEINEMPTY -16 /* No data for specified time interval */ #define NOEXEC -17 /* No executable */ #define DD_SHORT 4 #define DD_INT 1 #define DD_FLOAT 2 #define DD_DOUBLE 3 #define DD_CHAR 0 #endif /* DD_H_ */