00001 #include <SUM.h>
00002 #include <soi_key.h>
00003 #include <sys/time.h>
00004 #include <sys/errno.h>
00005 #include <rpc/rpc.h>
00006 #include <sum_rpc.h>
00007 #include <soi_error.h>
00008 #include <printk.h>
00009
00010 extern int errno;
00011 #define NUMTIMERS 10
00012
00013 KEY *rlist;
00014 FILE *logfp;
00015 SUM_t *sum;
00016 SUM_t *sum1, *sum2, *sum3;
00017 SUMID_t uid;
00018 int soi_errno = NO_ERROR;
00019 int waitcnt = 0;
00020 int bytes, msgtag, petid, req_num, status, cnt, i, j;
00021 char **cptr;
00022 uint64_t *dsixpt;
00023 uint64_t alloc_index;
00024 char alloc_wd[64];
00025 char cmd[128];
00026 char datestr[32];
00027 char timetag[32];
00028 char mod_name[] = "sum_rpc";
00029 char dbname[] = "jsoc";
00030 char dsname[] = "hmi_lev1_fd_V";
00031 char hcomment[] = "this is a dummy history comment that is greater than 80 chars long to check out the code";
00032 static struct timeval first[NUMTIMERS], second[NUMTIMERS];
00033
00034 void StartTimer(int n)
00035 {
00036 gettimeofday (&first[n], NULL);
00037 }
00038
00039 float StopTimer(int n)
00040 {
00041 gettimeofday (&second[n], NULL);
00042 if (first[n].tv_usec > second[n].tv_usec) {
00043 second[n].tv_usec += 1000000;
00044 second[n].tv_sec--;
00045 }
00046 return (float) (second[n].tv_sec-first[n].tv_sec) +
00047 (float) (second[n].tv_usec-first[n].tv_usec)/1000000.0;
00048 }
00049
00050 int SUM_delete_series_test(SUMID_t *ids)
00051 {
00052 SUMID_t sunum;
00053 int i;
00054
00055 for(i=0; ; i++) {
00056 if((sunum = ids[i]) == 0) {
00057 break;
00058 }
00059 }
00060 return(i);
00061 }
00062
00063
00064 void timestring()
00065 {
00066 struct timeval tvalr;
00067 struct tm *t_ptr;
00068
00069 gettimeofday(&tvalr, NULL);
00070 t_ptr = localtime((const time_t *)&tvalr);
00071 sprintf(timetag, "%04d%02d%02d%02d%02d.%02d", (t_ptr->tm_year+1900), (t_ptr->tm_mon+1), t_ptr->tm_mday, t_ptr->tm_hour, t_ptr->tm_min, t_ptr->tm_sec);
00072 }
00073
00074
00075
00076
00077
00078 int main(int argc, char *argv[])
00079 {
00080 double bytesdel;
00081 float ftmp;
00082
00083
00084
00085
00086
00087
00088
00089 printk_set(printf, printf);
00090
00091
00092
00093
00094
00095
00096
00097
00098 StartTimer(0);
00099 if((sum1 = SUM_open("xim", NULL, printf)) == 0) {
00100 printf("Failed on SUM_open() for sum1\n");
00101 exit(1);
00102 }
00103 ftmp = StopTimer(0);
00104 printf("Time sec for SUM_open() = %f\n", ftmp);
00105 uid = sum1->uid;
00106 printf("Opened sum1 with sumid = %d\n", uid);
00107
00108
00109 sum1->mode = RETRIEVE;
00110 sum1->tdays = 10;
00111 sum1->reqcnt = 6;
00112 sum1->status = -1;
00113 dsixpt = sum1->dsix_ptr;
00114 *dsixpt++ = 30506811;
00115
00116 *dsixpt++ = 30546025;
00117 *dsixpt++ = 30545583;
00118 *dsixpt++ = 30526881;
00119 *dsixpt++ = 30526986;
00120 *dsixpt++ = 18896721;
00121
00122
00123 StartTimer(1);
00124 status = SUM_get(sum1, printf);
00125 ftmp = StopTimer(1);
00126 printf("Time sec for SUM_get() w/o TOUCH = %f\n", ftmp);
00127
00128 switch(status) {
00129 case 0:
00130 break;
00131 case 1:
00132 printf("Failed on SUM_get() for sum1\n");
00133 break;
00134 case RESULT_PEND:
00135 printf("SUM_get() sum1 call RESULT_PEND...\n");
00136 waitcnt++;
00137 break;
00138 default:
00139 printf("Error: unknown status from SUM_get()\n");
00140 break;
00141 }
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211 if(waitcnt) printf("Will now poll for completion msgs...\n");
00212 while(waitcnt) {
00213 if(!SUM_poll(sum1)) {
00214 if(sum1->status != -1) {
00215 printf("sum1 complete w/status=%d\n", sum1->status);
00216 }
00217
00218
00219
00220
00221
00222
00223 waitcnt--;
00224 }
00225 }
00226
00227 cnt = sum1->reqcnt;
00228 cptr = sum1->wd;
00229 printf("The wd's found from the sum1 SUM_get() call are:\n");
00230 for(i = 0; i < cnt; i++) {
00231 printf("wd = %s\n", *cptr++);
00232 }
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243
00244
00245
00246
00247
00248
00249
00250
00251
00252
00253
00254 sum1->mode = RETRIEVE;
00255 sum1->tdays = 10;
00256 sum1->reqcnt = 6;
00257 sum1->status = -1;
00258 dsixpt = sum1->dsix_ptr;
00259 *dsixpt++ = 138640258;
00260 *dsixpt++ = 141658701;
00261 *dsixpt++ = 134379952;
00262 *dsixpt++ = 136466975;
00263 *dsixpt++ = 141663394;
00264 *dsixpt++ = 122525405;
00265 StartTimer(1);
00266 status = SUM_get(sum1, printf);
00267 ftmp = StopTimer(1);
00268 printf("Time sec for SUM_get() w/o TOUCH = %f\n", ftmp);
00269
00270 switch(status) {
00271 case 0:
00272 cnt = sum1->reqcnt;
00273 cptr = sum1->wd;
00274
00275 for(i = 0; i < cnt; i++) {
00276 printf("wd = %s\n", *cptr++);
00277 }
00278 break;
00279 case 1:
00280 printf("Failed on SUM_get() for sum1\n");
00281 break;
00282 case RESULT_PEND:
00283 printf("SUM_get() sum1 call RESULT_PEND...\n");
00284 SUM_wait(sum1);
00285 if(sum1->status) {
00286 printf("***ERROR on SUM_get() call\n");
00287 break;
00288 }
00289 cnt = sum1->reqcnt;
00290 cptr = sum1->wd;
00291
00292 for(i = 0; i < cnt; i++) {
00293 printf("wd = %s\n", *cptr++);
00294 }
00295 break;
00296 default:
00297 printf("Error: unknown status from SUM_get()\n");
00298 break;
00299 }
00300
00301 SUM_close(sum1, printf);
00302
00303
00304 SUMID_t ids[10];
00305
00306 ids[0] = 100;
00307 ids[1] = 101;
00308 ids[2] = 102;
00309 ids[3] = 103;
00310 ids[4] = 0;
00311
00312
00313
00314
00315 }
00316