-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathStripHistoryAR+ArR.c
152 lines (136 loc) · 3.91 KB
/
StripHistoryAR+ArR.c
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
/*************************************************************************\
* Copyright (c) 1994-2004 The University of Chicago, as Operator of Argonne
* National Laboratory.
* Copyright (c) 1997-2003 Southeastern Universities Research Association,
* as Operator of Thomas Jefferson National Accelerator Facility.
* Copyright (c) 1997-2002 Deutches Elektronen-Synchrotron in der Helmholtz-
* Gemelnschaft (DESY).
* This file is distributed subject to a Software License Agreement found
* in the file LICENSE that is included with this distribution.
\*************************************************************************/
#include "StripHistory.h"
#include "StripDataSource.h"
#include "getHistory.h"
#include <time.h>
#define DEBUG 0
/*#ifdef USE_AAPI TODO */
extern char **algorithmString;
extern int algorithmLength;
/* #endif */
/* StripHistory_init
*/
StripHistory StripHistory_init (Strip strip)
{
StripHistoryInfo *shi = 0;
if ((shi = (StripHistoryInfo *)malloc (sizeof(StripHistoryInfo))))
{
shi->strip = strip;
}
else
{
perror("StripHistory_init: can't allocate memory");
exit(1);
}
#ifdef USE_AAPI
if(AAPI_init() !=0 )
{
fprintf(stderr,"StripHistory_init: can't init AAPI\n");
exit(1);
}
if(extractAAPIfilterList(&algorithmString,&algorithmLength) != 0)
{
algorithmLength=0;
fprintf(stderr,"StripHistory_init: can't extractAAPIfilterList\n");
exit(1);
}
#endif
#ifdef USE_CAR
if(CAR_init(&(shi->archiverInfo)) !=0 )
{
fprintf(stderr,"StripHistory_init: can't init CAR\n");
exit(1);
}
#endif
return (StripHistory)shi;
}
/* StripHistory_delete
*/
void StripHistory_delete (StripHistory the_shi)
{
StripHistoryInfo *shi = (StripHistoryInfo *)the_shi;
#ifdef USE_AAPI
AAPI_free();
#endif
#ifdef USE_CAR
CAR_delete(shi);
#endif
free (shi);
}
/* StripHistory_fetch
*/
FetchStatus StripHistory_fetch (StripHistory the_shi,
char *name,
struct timeval *begin,
struct timeval *end,
StripHistoryResult *result,
StripHistoryCallback callback,
void *call_data)
{
unsigned long err;
struct timeval *times=NULL;
short *status=NULL;
double *data=NULL;
unsigned long count=0;
result->t0 = *begin;
result->t1 = *end;
result->n_points = 0;
result->fetch_stat=FETCH_NODATA;
if((err=getHistory(the_shi,name,begin,end,×,&status,&data,&count)) != 0)
{
fprintf(stderr,"err=%ld:bad getHistory; no goodData \n",err);
return (FETCH_NODATA);
}
if(count < 1)
{
if(DEBUG) fprintf(stderr,"getHistory; no goodData count=%lu\n",count);
return (FETCH_NODATA);
}
if ((compare_times (begin, ×[count-1]) <= 0) &&
(compare_times (end, ×[0]) >= 0) &&
(compare_times (begin, end) <= 0))
{
result->times = times;
result->data = data;
result->status = status;
result->n_points = count;
result->fetch_stat = FETCH_DONE;
}
else
{
if(DEBUG)
{
printf("StripHistory_fetch: Compare problem \n");
}
result->fetch_stat = FETCH_NODATA;
}
if(DEBUG) printf("%s: StripHistory_fetch: OK\n",name);
return result->fetch_stat;
}
/* StripHistory_cancel
*/
void StripHistory_cancel (StripHistory the_shi,
StripHistoryResult *result)
{
}
/* StripHistoryResult_release
*/
void StripHistoryResult_release (StripHistory BOGUS(the_shi),
StripHistoryResult *result)
{
#ifdef USE_AAPI
AAPI_Result_release(result);
#endif
#ifdef USE_CAR
CAR_Result_release(result);
#endif
}