DD.hh
7.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
/*=================================================================================================
* 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 <log4cxx/logger.h>
#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 <netinet/in.h>
// 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 <project>:<instrument>:<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_ */