00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #include <string.h>
00024 #include <sys/varargs.h>
00025
00026 #include "ingest_lib/generic_ingest_api.h"
00027 #include "ingest_lib/sds_log.h"
00028 #include "ingest_lib/sds_status.h"
00029
00030 IngestAtt *ingest_create_attribute(
00031 char *name,
00032 char *format, ...)
00033 {
00034 IngestAtt *attribute;
00035 va_list args;
00036 char value[4096];
00037
00038 va_start(args, format);
00039 vsprintf(value, format, args);
00040 va_end(args);
00041
00042
00043
00044
00045 attribute = (IngestAtt *)calloc(1, sizeof(IngestAtt));
00046
00047 if (!attribute) {
00048 append_log_msg(__FILE__, __LINE__,
00049 "Can Not Allocate Memory For New Ingest Attribute!\n");
00050 current_status(STATUS_NOMEM);
00051 return((IngestAtt *)NULL);
00052 }
00053
00054 attribute->name = (char *)calloc((strlen(name)+1), sizeof(char));
00055
00056 if (!attribute->name) {
00057 append_log_msg(__FILE__, __LINE__,
00058 "Can Not Allocate Memory For Ingest Attribute Name!\n");
00059 current_status(STATUS_NOMEM);
00060 return((IngestAtt *)NULL);
00061 }
00062
00063 attribute->value = (char *)calloc((strlen(value)+1), sizeof(char));
00064
00065 if (!attribute->value) {
00066 append_log_msg(__FILE__, __LINE__,
00067 "Can Not Allocate Memory For Ingest Attribute Value!\n");
00068 current_status(STATUS_NOMEM);
00069 return((IngestAtt *)NULL);
00070 }
00071
00072 strcpy(attribute->name, name);
00073 strcpy(attribute->value, value);
00074
00075 return(attribute);
00076 }
00077
00078
00079 IngestAtt *ingest_free_attribute(IngestAtt *att)
00080 {
00081 if (att) {
00082 if (att->name) {
00083 free(att->name);
00084 }
00085 if (att->value) {
00086 free(att->value);
00087 }
00088 free(att);
00089 }
00090 }
00091
00092
00093 IngestRecord *ingest_create_record(
00094 IngestPlat *plat,
00095 IngestRecDef *recdef,
00096 ZebTime time,
00097 double *array)
00098 {
00099 IngestRecord *record;
00100
00101
00102
00103
00104 record = (IngestRecord *)calloc(1, sizeof(IngestRecord));
00105
00106 if (!record) {
00107 append_log_msg(__FILE__, __LINE__,
00108 "Can Not Allocate Memory For New Ingest Record!\n");
00109 current_status(STATUS_NOMEM);
00110 return((IngestRecord *)NULL);
00111 }
00112
00113 record->plat = plat;
00114 record->recdef = recdef;
00115 record->time = time;
00116 record->array = array;
00117
00118 return(record);
00119 }
00120
00121
00122 IngestRecord *ingest_free_record(IngestRecord *record)
00123 {
00124 if (record) {
00125 if (record->array) {
00126 free(record->array);
00127 }
00128 free(record);
00129 }
00130
00131 return((IngestRecord *)NULL);
00132 }
00133
00134
00135 int ingest_cleanup_record_data(IngestPlat *plat)
00136 {
00137 IngestData *data = (IngestData *)plat->data;
00138 int i;
00139
00140 print_debug(__FILE__, __LINE__,
00141 "Cleaning Up Raw Data For: %s\n", plat->platbase);
00142
00143 if (data) {
00144 if (data->record) {
00145 for (i = 0; i < data->nrecs; i++) {
00146 ingest_free_record(data->record[i]);
00147 }
00148 free(data->record);
00149 }
00150
00151 data->nrecs = 0;
00152 data->record = NULL;
00153 }
00154
00155 return(SUCCESS);
00156 }
00157
00158
00159 int ingest_free_record_data(IngestPlat *plat)
00160 {
00161 int status;
00162 int i;
00163
00164 print_debug(__FILE__, __LINE__,
00165 "Freeing Up Raw Data For: %s\n", plat->platbase);
00166
00167 if (plat->data) {
00168 status = ingest_cleanup_record_data(plat);
00169 if (status != SUCCESS) {
00170 return(status);
00171 }
00172
00173 if (plat->data->recdef) {
00174 for (i = 0; i < plat->data->ndefs; i++) {
00175 if (plat->data->recdef[i]) {
00176 free(plat->data->recdef[i]->data_index);
00177 free(plat->data->recdef[i]);
00178 }
00179 }
00180 free(plat->data->recdef);
00181 }
00182
00183 if (plat->data->att) {
00184 for (i = 0; i < plat->data->natts; i++) {
00185 ingest_free_attribute(plat->data->att[i]);
00186 }
00187 free(plat->data->att);
00188 }
00189
00190 if (plat->data->static_record) {
00191 free(plat->data->static_record);
00192 }
00193
00194 free(plat->data);
00195 }
00196
00197 plat->data = NULL;
00198
00199 return(SUCCESS);
00200 }
00201
00202
00203 int *ingest_generate_data_index(int nfields)
00204 {
00205 int *intp = (int *)NULL;
00206 int i;
00207
00208 if (nfields > 0) {
00209 intp = (int *)malloc(nfields * sizeof(int));
00210 if (intp) {
00211 for(i = 0; i < nfields; i++) {
00212 intp[i] = i;
00213 }
00214 }
00215 }
00216
00217 return(intp);
00218 }
00219
00220
00221 int ingest_get_sample_size(
00222 DataChunk *dc,
00223 FieldId field_id,
00224 int *is_static,
00225 int *sample_size)
00226 {
00227 int status;
00228 int dim;
00229 int num_dims;
00230 unsigned long dim_sizes[DC_MaxDimension];
00231
00232 status = dc_NSGetField(dc,
00233 field_id,
00234 &num_dims,
00235 (char **)NULL,
00236 dim_sizes,
00237 is_static);
00238
00239 if (!status) {
00240 append_log_msg(__FILE__, __LINE__,
00241 "Could not get field properties for dc field id: %i\n", field_id);
00242 return(FAILURE);
00243 }
00244
00245
00246
00247
00248 *sample_size = 1;
00249
00250 for (dim = 0; dim < num_dims; dim++) {
00251 *sample_size *= dim_sizes[dim];
00252 }
00253
00254 return(SUCCESS);
00255 }
00256
00257
00258 int ingest_store_data_in_dc(IngestPlat *plat)
00259 {
00260 char *filename = plat->ingest->filename;
00261 IngestData *data = plat->data;
00262 DataChunk *dc = plat->dc;
00263 int *field_ids = plat->field_ids;
00264 int num_fields = plat->num_fields;
00265 int num_dims = plat->num_dims;
00266 char *platform_name = ds_PlatformName(dc->dc_Platform);
00267
00268 int field;
00269 DC_ElemType field_type;
00270 char *field_name;
00271 DC_ElemType att_type;
00272 int nvals;
00273
00274 int rec_num;
00275 int *data_index;
00276 int sample_size;
00277 int is_static;
00278 double *datap;
00279
00280 int status;
00281 int i, j;
00282
00283 union {
00284 void *vval;
00285 char *cval;
00286 short *sval;
00287 int *ival;
00288 long *lval;
00289 float *fval;
00290 double *dval;
00291 long double *ldval;
00292 } array, missing_value;
00293
00294 print_debug(__FILE__, __LINE__,
00295 "Storing %i Data Records In DataChunk: %s\n",
00296 data->nrecs, platform_name);
00297
00298 if (!data->nrecs) {
00299
00300
00301
00302
00303 return(SUCCESS);
00304 }
00305
00306 if (plat->make_dims_fields) {
00307 num_fields += num_dims;
00308 }
00309
00310 for (field = 0; field < num_fields; field++) {
00311
00312
00313
00314
00315 status = ingest_get_sample_size(dc, field_ids[field],
00316 &is_static, &sample_size);
00317 if (status == FAILURE) {
00318 return(FAILURE);
00319 }
00320
00321
00322
00323
00324 array.vval = (long double *)malloc(sample_size * sizeof(long double));
00325 if (!array.vval) {
00326 append_log_msg(__FILE__, __LINE__,
00327 "Can Not Allocate Memory For Data Array!\n");
00328 current_status(STATUS_NOMEM);
00329 return(FAILURE);
00330 }
00331
00332
00333
00334
00335 field_type = dc_Type(dc, field_ids[field]);
00336 field_name = F_GetName(field_ids[field]);
00337
00338
00339
00340
00341 missing_value.vval = dc_GetFieldAttrArray(dc, field_ids[field],
00342 "missing_value",
00343 &att_type, &nvals);
00344
00345 for (i = 0; i < data->ndefs; i++) {
00346
00347 if (data->recdef[i]->num_dc_fields <= 0) {
00348 continue;
00349 }
00350
00351 data_index = data->recdef[i]->data_index;
00352
00353 if (data_index[field] < 0) {
00354 if (!missing_value.vval) {
00355 append_log_msg(__FILE__, __LINE__,
00356 "Could not find 'missing_value' for '%s' in platform %s\n",
00357 field_name, platform_name);
00358 current_status(STATUS_BADMISSING);
00359 return(FAILURE);
00360 }
00361
00362 if (att_type != field_type) {
00363 append_log_msg(__FILE__, __LINE__,
00364 "'%s' type does not match 'missing_value' type in platform %s\n",
00365 field_name, platform_name);
00366 current_status(STATUS_BADMISSING);
00367 return(FAILURE);
00368 }
00369 }
00370 }
00371
00372
00373
00374
00375 rec_num = 0;
00376 for (i = 0; i < data->nrecs; i++) {
00377
00378 if (data->record[i]->recdef->num_dc_fields <= 0) {
00379 continue;
00380 }
00381
00382 data_index = data->record[i]->recdef->data_index;
00383
00384 if (is_static) {
00385 datap = data->static_record;
00386 }
00387 else {
00388 datap = data->record[i]->array;
00389 }
00390
00391 if (!datap) {
00392 continue;
00393 }
00394
00395 switch (field_type) {
00396 case DCT_Float:
00397 if (data_index[field] < 0) {
00398 for (j = 0; j < sample_size; j++) {
00399 array.fval[j] = *missing_value.fval;
00400 }
00401 }
00402 else {
00403 for (j = 0; j < sample_size; j++) {
00404 array.fval[j] = (float)datap[data_index[field] + j];
00405 }
00406 }
00407 break;
00408 case DCT_Double:
00409 if (data_index[field] < 0) {
00410 for (j = 0; j < sample_size; j++) {
00411 array.dval[j] = *missing_value.dval;
00412 }
00413 }
00414 else {
00415 for (j = 0; j < sample_size; j++) {
00416 array.dval[j] = (double)datap[data_index[field] + j];
00417 }
00418 }
00419 break;
00420 case DCT_LongDouble:
00421 if (data_index[field] < 0) {
00422 for (j = 0; j < sample_size; j++) {
00423 array.ldval[j] = *missing_value.ldval;
00424 }
00425 }
00426 else {
00427 for (j = 0; j < sample_size; j++) {
00428 array.ldval[j] = (long double)datap[data_index[field] + j];
00429 }
00430 }
00431 break;
00432 case DCT_Char:
00433 case DCT_UnsignedChar:
00434 if (data_index[field] < 0) {
00435 for (j = 0; j < sample_size; j++) {
00436 array.cval[j] = *missing_value.cval;
00437 }
00438 }
00439 else {
00440 for (j = 0; j < sample_size; j++) {
00441 array.cval[j] = (char)datap[data_index[field] + j];
00442 }
00443 }
00444 break;
00445 case DCT_ShortInt:
00446 case DCT_UnsignedShort:
00447 if (data_index[field] < 0) {
00448 for (j = 0; j < sample_size; j++) {
00449 array.sval[j] = *missing_value.sval;
00450 }
00451 }
00452 else {
00453 for (j = 0; j < sample_size; j++) {
00454 array.sval[j] = (short)datap[data_index[field] + j];
00455 }
00456 }
00457 break;
00458 case DCT_Integer:
00459 case DCT_UnsignedInt:
00460 if (data_index[field] < 0) {
00461 for (j = 0; j < sample_size; j++) {
00462 array.ival[j] = *missing_value.ival;
00463 }
00464 }
00465 else {
00466 for (j = 0; j < sample_size; j++) {
00467 array.ival[j] = (int)datap[data_index[field] + j];
00468 }
00469 }
00470 break;
00471 case DCT_LongInt:
00472 case DCT_UnsignedLong:
00473 if (data_index[field] < 0) {
00474 for (j = 0; j < sample_size; j++) {
00475 array.lval[j] = *missing_value.lval;
00476 }
00477 }
00478 else {
00479 for (j = 0; j < sample_size; j++) {
00480 array.lval[j] = (long)datap[data_index[field] + j];
00481 }
00482 }
00483 break;
00484 default:
00485 append_log_msg(__FILE__, __LINE__,
00486 "Unknown Data Type %i Found In Platform: %s\n",
00487 field_type, platform_name);
00488 current_status(STATUS_BADTYPE);
00489 return(FAILURE);
00490 }
00491
00492 if (is_static) {
00493 dc_NSAddStatic(dc, field_ids[field], array.vval);
00494 break;
00495 }
00496 else {
00497 dc_NSAddSample(dc,
00498 &data->record[i]->time,
00499 rec_num,
00500 field_ids[field],
00501 array.vval);
00502 }
00503
00504 rec_num++;
00505 }
00506
00507 free(array.vval);
00508 }
00509
00510
00511
00512
00513 for (i = 0; i < data->natts; i++) {
00514 print_debug(__FILE__, __LINE__,
00515 "Storing Attribute: '%s' = '%s'\n",
00516 data->att[i]->name, data->att[i]->value);
00517 plat->newfile += change_global(
00518 dc, data->att[i]->name, data->att[i]->value);
00519 }
00520 print_debug(__FILE__, __LINE__, "%i Attributes Changed\n", plat->newfile);
00521
00522 return(SUCCESS);
00523 }
00524
00525
00526 int ingest_store_data_in_dc_multisample(IngestPlat *plat)
00527 {
00528 char *filename = plat->ingest->filename;
00529 IngestData *data = plat->data;
00530 DataChunk *dc = plat->dc;
00531 int *field_ids = plat->field_ids;
00532 int num_fields = plat->num_fields;
00533 int num_dims = plat->num_dims;
00534 char *platform_name = ds_PlatformName(dc->dc_Platform);
00535
00536 int field;
00537 DC_ElemType field_type;
00538 char *field_name;
00539 DC_ElemType att_type;
00540 int nvals;
00541
00542 int *data_index;
00543 int sample_size;
00544 int is_static;
00545 ZebTime *data_times;
00546 int rec_num;
00547 int num_dc_recs;
00548 int static_recdef;
00549
00550 int status;
00551 int i, j;
00552
00553 union {
00554 void *vval;
00555 char *cval;
00556 short *sval;
00557 int *ival;
00558 long *lval;
00559 float *fval;
00560 double *dval;
00561 long double *ldval;
00562 } array, missing_value;
00563
00564 print_debug(__FILE__, __LINE__,
00565 "Storing %i Data Records In DataChunk: %s\n",
00566 data->nrecs, platform_name);
00567
00568 if (!data->nrecs) {
00569
00570
00571
00572
00573 return(SUCCESS);
00574 }
00575
00576
00577
00578
00579 data_times = (ZebTime *)malloc(data->nrecs * sizeof(ZebTime));
00580 if (!data_times) {
00581 append_log_msg(__FILE__, __LINE__,
00582 "Can Not Allocate Memory For Data Times Array!\n");
00583 current_status(STATUS_NOMEM);
00584 return(FAILURE);
00585 }
00586
00587
00588
00589
00590 rec_num = 0;
00591 for (i = 0; i < data->nrecs; i++) {
00592
00593 if (data->record[i]->recdef->num_dc_fields <= 0) {
00594 continue;
00595 }
00596
00597 data_times[rec_num] = data->record[i]->time;
00598 rec_num++;
00599 }
00600 num_dc_recs = rec_num;
00601
00602 if (!num_dc_recs) {
00603
00604
00605
00606
00607 return(SUCCESS);
00608 }
00609
00610 if (plat->make_dims_fields) {
00611 num_fields += num_dims;
00612 }
00613
00614 for (field = 0; field < num_fields; field++) {
00615
00616
00617
00618
00619 status = ingest_get_sample_size(dc, field_ids[field],
00620 &is_static, &sample_size);
00621
00622 if (status == FAILURE) {
00623 return(FAILURE);
00624 }
00625
00626
00627
00628
00629 array.vval = (long double *)malloc(data->nrecs * sample_size * sizeof(long double));
00630 if (!array.vval) {
00631 append_log_msg(__FILE__, __LINE__,
00632 "Can Not Allocate Memory For Data Array!\n");
00633 current_status(STATUS_NOMEM);
00634 return(FAILURE);
00635 }
00636
00637
00638
00639
00640 field_type = dc_Type(dc, field_ids[field]);
00641 field_name = F_GetName(field_ids[field]);
00642
00643
00644
00645
00646 missing_value.vval = dc_GetFieldAttrArray(dc, field_ids[field],
00647 "missing_value",
00648 &att_type, &nvals);
00649
00650 static_recdef = -1;
00651 for (i = 0; i < data->ndefs; i++) {
00652
00653 if (data->recdef[i]->num_dc_fields <= 0) {
00654 continue;
00655 }
00656
00657 if (static_recdef < 0) {
00658 static_recdef = i;
00659 }
00660
00661 data_index = data->recdef[i]->data_index;
00662
00663 if (data_index[field] < 0) {
00664 if (!missing_value.vval) {
00665 append_log_msg(__FILE__, __LINE__,
00666 "Could not find 'missing_value' for '%s' in platform %s\n",
00667 field_name, platform_name);
00668 current_status(STATUS_BADMISSING);
00669 return(FAILURE);
00670 }
00671
00672 if (att_type != field_type) {
00673 append_log_msg(__FILE__, __LINE__,
00674 "'%s' type does not match 'missing_value' type in platform %s\n",
00675 field_name, platform_name);
00676 current_status(STATUS_BADMISSING);
00677 return(FAILURE);
00678 }
00679 }
00680 }
00681
00682
00683
00684
00685 switch (field_type) {
00686
00687 case DCT_Float:
00688 if (is_static) {
00689 data_index = data->recdef[static_recdef]->data_index;
00690
00691 if (data_index[field] < 0) {
00692 for (j = 0; j < sample_size; j++) {
00693 array.fval[j] = *missing_value.fval;
00694 }
00695 }
00696 else {
00697 for (j = 0; j < sample_size; j++) {
00698 array.fval[j] = (float)
00699 data->static_record[data_index[field] + j];
00700 }
00701 }
00702 }
00703 else {
00704 rec_num = 0;
00705 for (i = 0; i < data->nrecs; i++) {
00706 if (data->record[i]->recdef->num_dc_fields <= 0) {
00707 continue;
00708 }
00709 data_index = data->record[i]->recdef->data_index;
00710
00711 if (data_index[field] < 0) {
00712 for (j = 0; j < sample_size; j++) {
00713 array.fval[(rec_num*sample_size)+j] = *missing_value.fval;
00714 }
00715 }
00716 else {
00717 for (j = 0; j < sample_size; j++) {
00718 array.fval[(rec_num*sample_size)+j] = (float)
00719 data->record[i]->array[data_index[field] + j];
00720 }
00721 }
00722 rec_num++;
00723 }
00724 }
00725 break;
00726 case DCT_Double:
00727 if (is_static) {
00728 data_index = data->recdef[static_recdef]->data_index;
00729
00730 if (data_index[field] < 0) {
00731 for (j = 0; j < sample_size; j++) {
00732 array.dval[j] = *missing_value.dval;
00733 }
00734 }
00735 else {
00736 for (j = 0; j < sample_size; j++) {
00737 array.dval[j] = (double)
00738 data->static_record[data_index[field] + j];
00739 }
00740 }
00741 }
00742 else {
00743 rec_num = 0;
00744 for (i = 0; i < data->nrecs; i++) {
00745 if (data->record[i]->recdef->num_dc_fields <= 0) {
00746 continue;
00747 }
00748 data_index = data->record[i]->recdef->data_index;
00749
00750 if (data_index[field] < 0) {
00751 for (j = 0; j < sample_size; j++) {
00752 array.dval[(rec_num*sample_size)+j] = *missing_value.dval;
00753 }
00754 }
00755 else {
00756 for (j = 0; j < sample_size; j++) {
00757 array.dval[(rec_num*sample_size)+j] = (double)
00758 data->record[i]->array[data_index[field] + j];
00759 }
00760 }
00761 rec_num++;
00762 }
00763 }
00764 break;
00765 case DCT_LongDouble:
00766 if (is_static) {
00767 data_index = data->recdef[static_recdef]->data_index;
00768
00769 if (data_index[field] < 0) {
00770 for (j = 0; j < sample_size; j++) {
00771 array.ldval[j] = *missing_value.ldval;
00772 }
00773 }
00774 else {
00775 for (j = 0; j < sample_size; j++) {
00776 array.ldval[j] = (long double)
00777 data->static_record[data_index[field] + j];
00778 }
00779 }
00780 }
00781 else {
00782 rec_num = 0;
00783 for (i = 0; i < data->nrecs; i++) {
00784 if (data->record[i]->recdef->num_dc_fields <= 0) {
00785 continue;
00786 }
00787 data_index = data->record[i]->recdef->data_index;
00788
00789 if (data_index[field] < 0) {
00790 for (j = 0; j < sample_size; j++) {
00791 array.ldval[(rec_num*sample_size)+j] = *missing_value.ldval;
00792 }
00793 }
00794 else {
00795 for (j = 0; j < sample_size; j++) {
00796 array.ldval[(rec_num*sample_size)+j] = (long double)
00797 data->record[i]->array[data_index[field] + j];
00798 }
00799 }
00800 rec_num++;
00801 }
00802 }
00803 break;
00804 case DCT_Char:
00805 case DCT_UnsignedChar:
00806 if (is_static) {
00807 data_index = data->recdef[static_recdef]->data_index;
00808
00809 if (data_index[field] < 0) {
00810 for (j = 0; j < sample_size; j++) {
00811 array.cval[j] = *missing_value.cval;
00812 }
00813 }
00814 else {
00815 for (j = 0; j < sample_size; j++) {
00816 array.cval[j] = (char)
00817 data->static_record[data_index[field] + j];
00818 }
00819 }
00820 }
00821 else {
00822 rec_num = 0;
00823 for (i = 0; i < data->nrecs; i++) {
00824 if (data->record[i]->recdef->num_dc_fields <= 0) {
00825 continue;
00826 }
00827 data_index = data->record[i]->recdef->data_index;
00828
00829 if (data_index[field] < 0) {
00830 for (j = 0; j < sample_size; j++) {
00831 array.cval[(rec_num*sample_size)+j] = *missing_value.cval;
00832 }
00833 }
00834 else {
00835 for (j = 0; j < sample_size; j++) {
00836 array.cval[(rec_num*sample_size)+j] = (char)
00837 data->record[i]->array[data_index[field] + j];
00838 }
00839 }
00840 rec_num++;
00841 }
00842 }
00843 break;
00844 case DCT_ShortInt:
00845 case DCT_UnsignedShort:
00846 if (is_static) {
00847 data_index = data->recdef[static_recdef]->data_index;
00848
00849 if (data_index[field] < 0) {
00850 for (j = 0; j < sample_size; j++) {
00851 array.sval[j] = *missing_value.sval;
00852 }
00853 }
00854 else {
00855 for (j = 0; j < sample_size; j++) {
00856 array.sval[j] = (short)
00857 data->static_record[data_index[field] + j];
00858 }
00859 }
00860 }
00861 else {
00862 rec_num = 0;
00863 for (i = 0; i < data->nrecs; i++) {
00864 if (data->record[i]->recdef->num_dc_fields <= 0) {
00865 continue;
00866 }
00867 data_index = data->record[i]->recdef->data_index;
00868
00869 if (data_index[field] < 0) {
00870 for (j = 0; j < sample_size; j++) {
00871 array.sval[(rec_num*sample_size)+j] = *missing_value.sval;
00872 }
00873 }
00874 else {
00875 for (j = 0; j < sample_size; j++) {
00876 array.sval[(rec_num*sample_size)+j] = (short)
00877 data->record[i]->array[data_index[field] + j];
00878 }
00879 }
00880 rec_num++;
00881 }
00882 }
00883 break;
00884 case DCT_Integer:
00885 case DCT_UnsignedInt:
00886 if (is_static) {
00887 data_index = data->recdef[static_recdef]->data_index;
00888
00889 if (data_index[field] < 0) {
00890 for (j = 0; j < sample_size; j++) {
00891 array.ival[j] = *missing_value.ival;
00892 }
00893 }
00894 else {
00895 for (j = 0; j < sample_size; j++) {
00896 array.ival[j] = (int)
00897 data->static_record[data_index[field] + j];
00898 }
00899 }
00900 }
00901 else {
00902 rec_num = 0;
00903 for (i = 0; i < data->nrecs; i++) {
00904 if (data->record[i]->recdef->num_dc_fields <= 0) {
00905 continue;
00906 }
00907 data_index = data->record[i]->recdef->data_index;
00908
00909 if (data_index[field] < 0) {
00910 for (j = 0; j < sample_size; j++) {
00911 array.ival[(rec_num*sample_size)+j] = *missing_value.ival;
00912 }
00913 }
00914 else {
00915 for (j = 0; j < sample_size; j++) {
00916 array.ival[(rec_num*sample_size)+j] = (int)
00917 data->record[i]->array[data_index[field] + j];
00918 }
00919 }
00920 rec_num++;
00921 }
00922 }
00923 break;
00924 case DCT_LongInt:
00925 case DCT_UnsignedLong:
00926 if (is_static) {
00927 data_index = data->recdef[static_recdef]->data_index;
00928
00929 if (data_index[field] < 0) {
00930 for (j = 0; j < sample_size; j++) {
00931 array.lval[j] = *missing_value.lval;
00932 }
00933 }
00934 else {
00935 for (j = 0; j < sample_size; j++) {
00936 array.lval[j] = (long)
00937 data->static_record[data_index[field] + j];
00938 }
00939 }
00940 }
00941 else {
00942 rec_num = 0;
00943 for (i = 0; i < data->nrecs; i++) {
00944 if (data->record[i]->recdef->num_dc_fields <= 0) {
00945 continue;
00946 }
00947 data_index = data->record[i]->recdef->data_index;
00948
00949 if (data_index[field] < 0) {
00950 for (j = 0; j < sample_size; j++) {
00951 array.lval[(rec_num*sample_size)+j] = *missing_value.lval;
00952 }
00953 }
00954 else {
00955 for (j = 0; j < sample_size; j++) {
00956 array.lval[(rec_num*sample_size)+j] = (long)
00957 data->record[i]->array[data_index[field] + j];
00958 }
00959 }
00960 rec_num++;
00961 }
00962 }
00963 break;
00964 default:
00965 append_log_msg(__FILE__, __LINE__,
00966 "Unknown Data Type %i Found In Platform: %s\n",
00967 field_type, platform_name);
00968 current_status(STATUS_BADTYPE);
00969 return(FAILURE);
00970 }
00971
00972 print_debug(__FILE__, __LINE__,
00973 "Storing Data For Field: %s\n", field_name);
00974
00975 if (is_static) {
00976 dc_NSAddStatic(dc, field_ids[field], array.vval);
00977 }
00978 else {
00979 dc_NSAddMultSamples(dc,
00980 data_times,
00981 0,
00982 num_dc_recs,
00983 field_ids[field],
00984 array.vval);
00985 }
00986
00987 free(array.vval);
00988 }
00989
00990 free(data_times);
00991
00992
00993
00994
00995 for (i = 0; i < data->natts; i++) {
00996 print_debug(__FILE__, __LINE__,
00997 "Storing Attribute: '%s' = '%s'\n",
00998 data->att[i]->name, data->att[i]->value);
00999 plat->newfile += change_global(
01000 dc, data->att[i]->name, data->att[i]->value);
01001 }
01002 print_debug(__FILE__, __LINE__, "%i Attributes Changed\n", plat->newfile);
01003
01004 return(SUCCESS);
01005 }