00001 #ident "$Header: /home/cvsuser/cvsroot/JSOC/proj/lev0/apps/decode_dayfile.c,v 1.25 2014/08/21 23:43:39 arta Exp $"
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00150
00151
00152 #define HKDDF_CNTRL_L ""
00153 #define HKDDF_MAXLINE_IN_FILE 200
00154 #define HKDDF_MAXNUM_PJNAMES 3
00155 #define HKDDF_MAX_APID_STR 5
00156 #define HKDDF_MAX_DSNAME_STR 100
00157 #define HKDDF_MAX_FILE_NAME 100
00158 #define HKDDF_MAX_JSVN_STR 5
00159 #define HKDDF_MAX_LONG_KW_NAME 50
00160 #define HKDDF_MAX_PKT_SIZE 1000
00161 #define HKDDF_MAX_PJNAME 50
00162 #define HKDDF_MAX_PVN_SIZE 50
00163 #define HKDDF_MAX_PVN_STR 10
00164 #define HKDDF_MAX_HK_SRC_KW 100
00165 #define HKDDF_MAX_VERSION_LINES 1000
00166 #define HKDDF_START_MERGED_PVNW (1)
00167 #define HKDDF_START_MERGED_PVND (194)
00168 #define HKDDF_MAX_PACKET_NAME 50
00169 #define HKDDF_MAX_LOOKUP_NAME 100
00170 #define HKDDF_MAX_SRC_ARG 10
00171 #define HKDDF_MAX_IN_OUT_ARG 200
00172 #define HKDDF_ENVIRONMENT_VARS_NOT_SET (-1)
00173
00174
00175 #define ENVFILE "/home/production/cvs/JSOC/proj/lev0/apps/SOURCE_ENV_FOR_HK_DAYFILE_DECODE"
00176 #define HKDDF_READ_ARRAY_SIZE (25000001)
00177
00178
00179 #include <stdio.h>
00180 #include <stdlib.h>
00181 #include <string.h>
00182 #include <time.h>
00183 #include <sys/stat.h>
00184 #include <unistd.h>
00185 #include <stdarg.h>
00186 #include "drms.h"
00187 #include "drms_names.h"
00188 #include "jsoc_main.h"
00189 #include "load_hk_config_files.h"
00190 #include "write_hk_to_drms.h"
00191 #include "packets.h"
00192 #include "decode_hk.h"
00193 #include "printk.h"
00194
00195
00196
00197 ModuleArgs_t module_args[] =
00198 {
00199 {ARG_STRING, "src", "Not Specified", "day file source"},
00200 {ARG_STRING, "in", "Not Specified", "full path to day file"},
00201 {ARG_STRING, "out", "Not Specified", "Series name"},
00202 {ARG_FLAG, "p", "0", "print values of keywords to standard out"},
00203 {ARG_END}
00204 };
00205 ModuleArgs_t *ggModArgs=module_args;
00206 char* module_name = "decode_dayfile";
00207
00208
00209 static char* get_ds_pjname(int apid, char pjn[HKDDF_MAXNUM_PJNAMES][HKDDF_MAX_PJNAME]);
00210 static int get_packet_time_for_df(HK_Keyword_t *hk, TIME *ptime);
00211 static int load_ds_names(char *pn, char* didn, int apid, char *pvn);
00212 static char* lookup_dsn( int apid, char *pvn,char *fvn, int count);
00213 static void print_packet_time(HK_Keyword_t *kwh);
00214 static void save_packet_values1(unsigned char *read_in_buffer, char *out, char *in, char *src);
00215 static void save_packet_values2(unsigned char *read_in_buffer, char projname[HKDDF_MAXNUM_PJNAMES][HKDDF_MAX_PJNAME],char *didn, char *in, char *src);
00216 static void saveprint_packet_values1(unsigned char *read_in_buffer, char *in, char *out, char *src);
00217 static void saveprint_packet_values2(unsigned char *read_in_buffer, char *in, char projname[HKDDF_MAXNUM_PJNAMES][HKDDF_MAX_PJNAME],char *didn, char *src);
00218 static void set_env_variables();
00219 static void write_to_drms( int apid, char packet_version_number[MAX_CHAR_VERSION_NUMBER], char file_version_number[MAX_CHAR_VERSION_NUMBER],char *data_series, HK_Keyword_t *kw_head, char *in, char *src);
00220 static TIME SDO_to_DRMS_time(int sdo_s, int sdo_ss);
00221 static char *get_hk_src_keyword(int apid, char *in_file, char *src);
00222 static int get_date_in_filename(char *inf, char *src, int *year, int *month, int *day);
00223 static void print_hk_src_keyword(char *ifn, int apid, char *src);
00224 static int check_df_env_variable(void);
00225 static void get_month_day(int year, int yearday, int *pmonth, int *pday);
00226
00227
00228 extern SHCIDS_Version_Number *global_shcids_vn;
00229 extern char * find_file_version_number(GTCIDS_Version_Number *top,char f_version_number[MAX_CHAR_VERSION_NUMBER], int apid);
00230 extern char * find_fvn_from_shcids(SHCIDS_Version_Number *top,char pkt_date[MAX_SIZE_PKT_DATE],int apid);
00231 extern double get_packet_time(unsigned short *word_ptr);
00232 extern int DoIt(void);
00233 extern int nice_intro (void);
00234 extern int check_for_sdo_apid(int apid);
00235 extern void sprint_time (char *at, TIME t, char *zone, int precision);
00236 extern char *get_data_packet_name(int apid ) ;
00237 extern char *get_lookup_filename(int apid);
00238 extern int check_hk_record_exists(char* ds_name, HK_Keyword_t *kw, int apid);
00239 extern int check_hk_record_within_time_range( HK_Keyword_t *kw);
00240
00241
00242 extern GTCIDS_Version_Number *global_gtcids_vn;
00243 extern GTCIDS_Version_Number *global_gtcids_vn;
00244 int INVALtime;
00245
00246
00247
00248 struct jsvn_map_data
00249 {
00250 char apid[HKDDF_MAX_APID_STR];
00251 char jvn[HKDDF_MAX_VERSION_LINES][HKDDF_MAX_JSVN_STR];
00252 char pvn[HKDDF_MAX_VERSION_LINES][HKDDF_MAX_PVN_STR];
00253 char fvn[HKDDF_MAX_VERSION_LINES][HKDDF_MAX_PVN_STR];
00254 char dsn[HKDDF_MAX_VERSION_LINES][HKDDF_MAX_DSNAME_STR];
00255 } jsvn_list[1], *jmap=jsvn_list;
00256
00257
00258
00259 enum project{pjnHMI,pjnAIA,pjnSDO};
00260
00261
00262
00263 static char datestr[32];
00264
00265 char *do_datestr() {
00266 time_t tval;
00267 struct tm *t_ptr;
00268
00269 tval = time(NULL);
00270 t_ptr = localtime(&tval);
00271 sprintf(datestr, "%d.%02d.%02d_%02d:%02d:%02d",
00272 (t_ptr->tm_year+1900), (t_ptr->tm_mon+1),
00273 t_ptr->tm_mday, t_ptr->tm_hour, t_ptr->tm_min, t_ptr->tm_sec);
00274 return(datestr);
00275 }
00276
00277
00278
00279
00280
00281
00282 int nice_intro (void)
00283 {
00284 int usage = cmdparams_get_int (&cmdparams, "h", NULL);
00285 if (usage == 1)
00286 {
00287 printf ("Usage:\ndecode_dayfile [-p | -h] "
00288 "src=<day filename source> "
00289 "in=<day filename> "
00290 "[ out=<data series name> ] \n"
00291 " details are:\n"
00292 " -h: help - show this message then exit(optional field)\n"
00293 " -p: print all keyword names and values to standard out(optional field)\n"
00294 " src=<moc|hsb|rtmon|egsefm> -use to determine input filename source (required field).\n"
00295 " user needs to set src value to correspond to file format of the -in- dayfile name.\n"
00296 " in=<day file name> -use full path to day file(required field)\n"
00297 " out=<data series name> -data series to write keyword values to in DRMS(optional field)\n"
00298 " if don't enter out value, data series name will be created automatically using the apid and\n"
00299 " packet version number in packets in day file. Also required to set environment variables\n"
00300 " for project names and data identifer name: HK_DDF_HKBYAPID_PROJECT_NAME_xx,\n"
00301 " HK_DDF_HKBYAPID__DATA_ID_NAME, HK_DDF_DF_PROJECT_NAME_xxx, and HK_DDF_DF__DATA_ID_NAME,\n"
00302 " Also need data series already created for this to program to load keywords in data series.\n"
00303 " Example of running using automatic lookup of data series name and without print on:\n"
00304 " decode_dayfile src=moc in=/tmp20/production/hmi_hk/20070707.0x0029\n" );
00305 return(1);
00306 }
00307 return (0);
00308 }
00309
00310
00311
00312
00313
00314
00315
00316
00317 int DoIt(void)
00318 {
00319
00320 FILE *file_ptr;
00321 char *hk_df_fn;
00322 char hk_directory_filename[HKDDF_MAX_FILE_NAME];
00323 char *pn1,*pn2,*pn3;
00324 char projname[HKDDF_MAXNUM_PJNAMES][HKDDF_MAX_PJNAME];
00325 char *didn;
00326 int out_flag;
00327 unsigned char *ptr_read_in_buffer;
00328 unsigned long int i;
00329 int print_flag;
00330 char src[HKDDF_MAX_SRC_ARG];
00331 char in[HKDDF_MAX_IN_OUT_ARG];
00332 char out[HKDDF_MAX_IN_OUT_ARG];
00333
00334
00335 set_env_variables();
00336
00337
00338 if(!check_df_env_variable())
00339 {
00340 exit(1);
00341 }
00342
00343
00344 hk_df_fn= hk_directory_filename;
00345 out_flag=0;
00346
00347
00348 const int c_print_flag =cmdparams_get_int (&cmdparams, "p", NULL) != 0;
00349 const char *c_src = cmdparams_get_str (&cmdparams, "src", NULL);
00350 const char *c_in = cmdparams_get_str (&cmdparams, "in", NULL);
00351 const char *c_out = cmdparams_get_str (&cmdparams, "out", NULL);
00352 print_flag = c_print_flag;
00353 strcpy(src ,c_src);
00354 strcpy(in,c_in);
00355 strcpy(out,c_out);
00356
00357
00358 if (nice_intro ()) return (0);
00359
00360
00361 if (in == NULL)
00362 {
00363 printkerr("ERROR at %s, line %d: Need to enter day file name.",
00364 "Exiting program.\nExample format for out file: "
00365 "$HOME/EGSE/tables/hk_sim_file/20060719.0x000f\n",
00366 __FILE__,__LINE__);
00367 return (0);
00368 }
00369
00370 if (!strcmp(out, "Not Specified"))
00371 {
00372
00373 out_flag=0;
00374
00375
00376 pn1 = getenv("HK_DDF_HKBYAPID_PROJECT_NAME_HMI");
00377 pn2 = getenv("HK_DDF_HKBYAPID_PROJECT_NAME_AIA");
00378 pn3 = getenv("HK_DDF_HKBYAPID_PROJECT_NAME_SDO");
00379 didn =getenv("HK_DDF_HKBYAPID_DATA_ID_NAME");
00380
00381
00382 strcpy(projname[pjnHMI],pn1);
00383 strcpy(projname[pjnAIA],pn2);
00384 strcpy(projname[pjnSDO],pn3);
00385 }
00386 else
00387 {
00388
00389 out_flag=1;
00390 }
00391
00392
00393
00394 strcpy(hk_df_fn, in);
00395 strcat(hk_df_fn, "\0");
00396 file_ptr=fopen(hk_df_fn,"r");
00397 if (!file_ptr)
00398 {
00399 printkerr("ERROR at %s, line %d: Please check filename and directory is correct. "
00400 " Could not get -in- directory and filename: "
00401 "<%s>. Exiting execution.\n", __FILE__,__LINE__, hk_df_fn);
00402 return(0);
00403 }
00404
00405 ptr_read_in_buffer = (unsigned char *) malloc(sizeof(unsigned char) * HKDDF_READ_ARRAY_SIZE);
00406
00407 for(i=0; i < HKDDF_READ_ARRAY_SIZE;i++) ptr_read_in_buffer[i]= '\0'; ;
00408 for(i = 0 ; fread(ptr_read_in_buffer + i,1,1,file_ptr) ; i++)
00409 {
00410 ;
00411 if( i == HKDDF_READ_ARRAY_SIZE - 1)
00412 {
00413 printkerr("ERROR at %s, line %d: Array for reading dayfile is too small. :"
00414 "<%lu>\n", __FILE__,__LINE__, i + 1);
00415 printkerr("Break up large dayfile using dd command. : dd if<large-file> "
00416 " of=<small-file-1> bs=<packet_size + 7> count=<i.e., 1000> skip=<0,1,etc>\n");
00417 return (0);
00418 }
00419 }
00420 *(ptr_read_in_buffer + i)= '\0';
00421 fclose(file_ptr);
00422 if(print_flag && out_flag)
00423 {
00424
00425
00426 saveprint_packet_values1(ptr_read_in_buffer, in, out, src);
00427 return 0;
00428 }
00429 else if(print_flag && !out_flag)
00430 {
00431
00432
00433 saveprint_packet_values2(ptr_read_in_buffer, in, projname, didn, src );
00434 return 0;
00435 }
00436 else if (!print_flag && out_flag)
00437 {
00438
00439
00440
00441 save_packet_values1(ptr_read_in_buffer, out, in, src);
00442 return 0;
00443 }
00444 else if (!print_flag && !out_flag)
00445 {
00446
00447
00448
00449
00450 save_packet_values2(ptr_read_in_buffer, projname, didn, in, src);
00451 return 0;
00452 }
00453 else
00454 {
00455 printkerr("ERROR at %s, line %d: Save and Print Flags are not set correctly."
00456 "This case should not occur. Check logic. Exiting Program.\n" ,
00457 __FILE__,__LINE__ );
00458 return 1;
00459 }
00460 }
00461
00462
00463
00464
00465
00466
00467
00468
00469
00470 void write_to_drms(int apid, char pkt_ver_num[MAX_CHAR_VERSION_NUMBER], char file_ver_num[MAX_CHAR_VERSION_NUMBER], char *ds_name, HK_Keyword_t *kw_head, char *in, char *src)
00471 {
00472
00473 char at[200];
00474 char query[HKDDF_MAX_DSNAME_STR];
00475 int status;
00476 int ck_status;
00477 int ck_rwtr_status;
00478
00479 HK_Keyword_t *kw;
00480 TIME pkt_time;
00481 TIME pkt_timestamp;
00482 kw= kw_head;
00483
00484
00485 DRMS_Type_t keytype;
00486 DRMS_Type_Value_t key_anyval;
00487 char keyname[HKDDF_MAX_LONG_KW_NAME];
00488
00489 DRMS_RecordSet_t *rs;
00490 DRMS_Record_t *rec;
00491
00492
00493 if(ds_name)
00494 {
00495 strcpy(query, ds_name) ;
00496 }
00497 else
00498 {
00499 printkerr("ERROR at %s, line %d: Bad value for data series name:"
00500 "<%s>. Exiting program.\n", __FILE__,__LINE__, ds_name);
00501 return;
00502 }
00503
00504
00505 kw=kw_head;
00506
00507
00508 ck_rwtr_status = check_hk_record_within_time_range(kw);
00509 if (ck_rwtr_status == 1)
00510 {
00511
00512 kw=kw_head;
00513 ck_status = check_hk_record_exists(ds_name, kw, apid);
00514 }
00515 else
00516 {
00517 (void)get_packet_time_for_df(kw, &pkt_timestamp);
00518 (void)sprint_time (at, pkt_timestamp, "UTC", 0);
00519 strcat(at,"\0");
00520 printkerr("WARNING:decode_dayfile: Skipping write of record to <%s> data series. Packet time:<%s> Record not within time range.\n", ds_name, at);
00521 return;
00522 }
00523
00524
00525 if (ck_status == 1)
00526 {
00527 ;
00528 #ifdef DEBUG_DECODE_DAYFILE
00529 printf("DEBUG:Message:decode_dayfile: Skipping write of record to <%s> data series - record already exits\n", ds_name);
00530 #endif
00531 }
00532 else
00533 {
00534 #ifdef DEBUG_DECODE_DAYFILE
00535 printkerr("DEBUG:Message at %s, line %d: Prepare write of record to <%s> data series.\n" ,
00536 __FILE__, __LINE__, ds_name);
00537 #endif
00538
00539
00540 rs = drms_create_records( drms_env, 1, query, DRMS_PERMANENT, &status);
00541 if (status)
00542 {
00543 printkerr("ERROR at %s, line %d: Cannot create record using this data"
00544 " series name:<%s>.Exiting write to drms.\n",__FILE__,__LINE__, query);
00545 return;
00546 }
00547 else
00548 {
00549 ;
00550 }
00551 rec = rs->records[0];
00552
00553
00554 if (!get_packet_time_for_df(kw, &pkt_time))
00555 {
00556
00557 printkerr("ERROR at %s, line %d: Could not set PACKET_TIME keyword.",
00558 "Exiting program.\n", __FILE__,__LINE__);
00559 return;
00560 }
00561 else
00562 {
00563
00564
00565 keytype= DRMS_TYPE_TIME;
00566 strcpy(keyname, "PACKET_TIME");
00567
00568 key_anyval.time_val= pkt_time;
00569
00570 status = drms_setkey(rec, keyname, keytype, &key_anyval);
00571 }
00572
00573
00574 if(check_for_sdo_apid(apid))
00575 {
00576
00577
00578
00579 keytype= DRMS_TYPE_STRING;
00580 strcpy(keyname, "FILE_VERSION_NUMBER");
00581
00582 key_anyval.string_val = (char *)malloc(sizeof(char) * 100);
00583
00584 strcpy(key_anyval.string_val, file_ver_num);
00585 }
00586 else
00587 {
00588
00589
00590 keytype= DRMS_TYPE_STRING;
00591 strcpy(keyname, "PACKET_VERSION_NUMBER");
00592
00593 key_anyval.string_val = (char *)malloc(sizeof(char) * 100);
00594
00595 strcpy(key_anyval.string_val, pkt_ver_num);
00596 }
00597
00598 status = drms_setkey(rec, keyname, keytype, &key_anyval);
00599
00600 free (key_anyval.string_val);
00601
00602
00603
00604 keytype= DRMS_TYPE_STRING;
00605
00606 strcpy(keyname, "HK_SOURCE");
00607
00608 key_anyval.string_val = (char *)malloc(sizeof(char) * 100);
00609
00610 strcpy(key_anyval.string_val, get_hk_src_keyword(apid, in, src));
00611 status = drms_setkey(rec, keyname, keytype, &key_anyval);
00612
00613 free (key_anyval.string_val);
00614
00615
00616 kw= kw_head;
00617 while (kw)
00618 {
00619 if(kw->eng_type == KW_TYPE_UINT8)
00620 {
00621
00622 keytype= DRMS_TYPE_SHORT;
00623 strcpy(keyname, kw->name);
00624
00625 key_anyval.short_val = (int16_t)kw->eng_value.uint8_val;
00626 status = drms_setkey(rec, keyname, keytype, &key_anyval);
00627 }
00628 else if(kw->eng_type == KW_TYPE_UINT16)
00629 {
00630
00631 keytype= DRMS_TYPE_INT;
00632 strcpy(keyname, kw->name);
00633
00634 key_anyval.int_val = (int32_t)kw->eng_value.uint16_val;
00635 status = drms_setkey(rec, keyname, keytype, &key_anyval);
00636 }
00637 else if(kw->eng_type == KW_TYPE_UINT32)
00638 {
00639
00640 keytype= DRMS_TYPE_LONGLONG;
00641 strcpy(keyname, kw->name);
00642
00643 key_anyval.longlong_val = (int64_t)kw->eng_value.uint32_val;
00644 status = drms_setkey(rec, keyname, keytype, &key_anyval);
00645 }
00646 else if(kw->eng_type == KW_TYPE_INT8)
00647 {
00648
00649 keytype= DRMS_TYPE_SHORT;
00650 strcpy(keyname, kw->name);
00651 key_anyval.short_val = (int16_t)kw->eng_value.int8_val;
00652 status = drms_setkey(rec, keyname, keytype, &key_anyval);
00653 }
00654 else if(kw->eng_type == KW_TYPE_DOUBLE)
00655 {
00656
00657 keytype= DRMS_TYPE_DOUBLE;
00658 strcpy(keyname, kw->name);
00659 key_anyval.double_val = kw->eng_value.double_val;
00660 status = drms_setkey(rec, keyname, keytype, &key_anyval);
00661 }
00662 else if(kw->eng_type == KW_TYPE_FLOAT)
00663 {
00664
00665 keytype= DRMS_TYPE_FLOAT;
00666 strcpy(keyname, kw->name);
00667 key_anyval.float_val = kw->eng_value.float_val;
00668 status = drms_setkey(rec, keyname, keytype, &key_anyval);
00669 }
00670 else if(kw->eng_type == KW_TYPE_INT16)
00671 {
00672
00673 keytype= DRMS_TYPE_SHORT;
00674 strcpy(keyname, kw->name);
00675 key_anyval.short_val = kw->eng_value.int16_val;
00676 status = drms_setkey(rec, keyname, keytype, &key_anyval);
00677 }
00678 else if(kw->eng_type == KW_TYPE_INT32)
00679 {
00680
00681 keytype= DRMS_TYPE_INT;
00682 strcpy(keyname, kw->name);
00683 key_anyval.int_val= kw->eng_value.int32_val;
00684 status = drms_setkey(rec, keyname, keytype, &key_anyval);
00685 }
00686 else if(kw->eng_type == KW_TYPE_STRING)
00687 {
00688
00689 keytype= DRMS_TYPE_STRING;
00690 strcpy(keyname, kw->name);
00691
00692 key_anyval.string_val = (char *)malloc(sizeof(char) * 100);
00693 strcpy(key_anyval.string_val, kw->eng_value.string_val);
00694 status = drms_setkey(rec, keyname, keytype, &key_anyval);
00695 free(key_anyval.string_val);
00696 }
00697 else
00698 {
00699 printkerr("Warning at %s, line %d: Found Unknown KW_TYPE for this keyword:"
00700 "<%d>. Check if new KW_TYPE has been created in HKPDF files"
00701 "Skipping recording keyword in structure. Keyword is <%s>.",
00702 __FILE__,__LINE__, (int)kw->eng_type, kw->name);
00704 }
00705
00706 kw=kw->next;
00707 }
00708
00709 status = drms_close_records(rs, DRMS_INSERT_RECORD);
00710 if (status)
00711 {
00712 printkerr("ERROR at %s, line %d: Cannot close drms record.\n",
00713 __FILE__,__LINE__);
00714 return;
00715 }
00716 else
00717 {
00718 ;
00719 #ifdef DEBUG_DECODE_DAYFILE
00720 printkerr("DEBUG:Message at %s, line %d: Completed close of write of record to <%s> data series.\n" ,
00721 __FILE__, __LINE__, ds_name);
00722 #endif
00723 }
00724 }
00725 return;
00726 }
00727
00728
00729
00730
00731
00732
00733 static TIME SDO_to_DRMS_time(int sdo_s, int sdo_ss)
00734 {
00735 static int firstcall = 1;
00736 static TIME sdo_epoch;
00737 if (firstcall)
00738 {
00739 firstcall = 0;
00740 sdo_epoch = sscan_time("1958.01.01_00:00:00_TAI");
00741 }
00742 return(sdo_epoch + (TIME)sdo_s + (TIME)(sdo_ss)/65536.0);
00743 }
00744
00745
00746
00747
00748
00749
00750
00751
00752 int get_packet_time_for_df(HK_Keyword_t *hk, TIME *ptime)
00753 {
00754
00755 int sec;
00756 int subsec;
00757 HK_Keyword_t *t_hk;
00758 int SEC_FOUND_FLAG=0;
00759 int SUBSEC_FOUND_FLAG=0;
00760 t_hk= hk;
00761
00762
00763 while (t_hk && ( !SEC_FOUND_FLAG || !SUBSEC_FOUND_FLAG ))
00764 {
00765 if(strstr(t_hk->name,"TIMECODE_SECONDS"))
00766 {
00767
00768 SEC_FOUND_FLAG=1;
00769
00770 sec = t_hk->eng_value.uint32_val;
00771 }
00772 if(strstr(t_hk->name,"TIMECODE_SUBSECS"))
00773 {
00774
00775 SUBSEC_FOUND_FLAG=1;
00776
00777 subsec = t_hk->eng_value.uint32_val;
00778 }
00779 t_hk= t_hk->next;
00780 }
00781
00782 if (!SEC_FOUND_FLAG)
00783 {
00784 printkerr("ERROR at %s, line %d: Did not find TIMECODE_SECONDS value for"
00785 "calculating the PACKET_TIME keyword and index. Returning error"
00786 "status.\n",__FILE__,__LINE__);
00787 return 0;
00788 }
00789 else
00790 {
00791 if (!SUBSEC_FOUND_FLAG)
00792 {
00793 printkerr("ERROR at %s, line %d: Did not find TIMECODE_SUBSECS value for"
00794 "calculating the PACKET_TIME keyword and index. Returning error"
00795 "status, but setting time using seconds only.\n",__FILE__,__LINE__);
00796 *ptime =SDO_to_DRMS_time(sec, 0);
00797 return 0;
00798 }
00799 else
00800 {
00801 int shifted_ss=(subsec >> 16) & 0xFFFF;
00802 *ptime =SDO_to_DRMS_time(sec, shifted_ss);
00803 return 1;
00804 }
00805 }
00806 }
00807
00808
00809
00810
00811
00812
00813
00814
00815 char* lookup_dsn( int apid, char *pvn, char *fvn, int cnt)
00816 {
00817
00818 int i;
00819 int found_jvn=0;
00820
00821
00822 for(i=0; i < cnt ;i++)
00823 {
00824
00825 if(check_for_sdo_apid(apid))
00826 {
00827
00828
00829 if (!strcmp (jmap->fvn[i], fvn ))
00830 {
00831 found_jvn = 1;
00832 break;
00833 }
00834 }
00835 else
00836 {
00837
00838 if (!strcmp (jmap->pvn[i], pvn ))
00839 {
00840 found_jvn = 1;
00841 break;
00842 }
00843 }
00844 }
00845 if ( found_jvn != 1)
00846 {
00847 if(check_for_sdo_apid(apid))
00848 {
00849 printkerr("ERROR at %s, line %d: Did not find the data series name "
00850 "for this file version number. Maybe this is new configuration "
00851 "and a new JVN-TO-PVN map files need to updated using script.\n",
00852 __FILE__,__LINE__);
00853 return ((char *)"");
00854 }
00855 else
00856 {
00857 printkerr("ERROR at %s, line %d: Did not find the data series name "
00858 "for this packet version number. Maybe this is new configuration "
00859 "and a new JVN-TO-PVN map files need to updated using script.\n",
00860 __FILE__,__LINE__);
00861 return ((char *)"");
00862 }
00863 }
00864 return ((char *)jmap->dsn[i]);
00865 }
00866
00867
00868
00869
00870
00871
00872
00873
00874
00875 void saveprint_packet_values1(unsigned char *read_in_buffer, char *in, char *out, char *src)
00876 {
00877
00878 CCSDS_Packet_t ccsds;
00879 HK_Keyword_t *kw_head;
00880 char packet_version_number[HKDDF_MAX_PVN_SIZE];
00881 char file_version_number[HKDDF_MAX_PVN_SIZE];
00882 char data_seriesname[HKDDF_MAX_DSNAME_STR];
00883 char *ptr_fvn;
00884 int i,j,k,y,x,s;
00885 int apid;
00886 int factor;
00887 int packet_length;
00888 int pvnw,pvnd;
00889 unsigned char hk_pkt_buffer[HKDDF_MAX_PKT_SIZE];
00890 unsigned short s_hk_pkt_buffer[HKDDF_MAX_PKT_SIZE];
00891 unsigned short *word_ptr;
00892 char pkt_date[MAX_SIZE_PKT_DATE];
00893
00894
00895 for(k=0,factor=0,packet_length=0; ; k++)
00896 {
00897
00898
00899 for(x=0; x < HKDDF_MAX_DSNAME_STR; data_seriesname[x]='\0', x++);
00900
00901
00902 factor = k * (packet_length + 6 + 1 ) ;
00903
00904
00905 if (*(read_in_buffer+5+factor) == '\0')
00906 {
00907
00908 printf("\n\n*****At end of file. Found %d packets in file.\n", k);
00909 break;
00910 }
00911
00912
00913 packet_length= *(read_in_buffer+5+factor);
00914
00915
00916
00917 apid = (unsigned short int)( (*(read_in_buffer+1+factor)) & 0x00FF );
00918
00919 apid |= (unsigned short int)( (*(read_in_buffer+0+factor) << 8) & 0xFF00 );
00920 apid &= 0x07FF;
00921
00922
00923
00924 if(check_for_sdo_apid(apid))
00925 {
00926 sprintf(packet_version_number,"%s","not applicable");
00927 }
00928 else
00929 {
00930
00931 if (( *(read_in_buffer+14+factor) == 0) && (*(read_in_buffer+15+factor) == 0))
00932 {
00933 printkerr("Warning at %s, line %d: Getting 0.0 for packet version number "
00934 "in packet data. Skip processing this packet, don't load to "
00935 "DRMS and get next packet", __FILE__,__LINE__);
00936 continue;
00937 }
00938
00939 if ( *(read_in_buffer+14+factor) == 0 && *(read_in_buffer+15+factor))
00940 {
00941 printkerr("Warning at %s, line %d: Getting 0 for whole number(i.e.,0.1) for "
00942 "packet version number in packet data. Skip processing this packet,"
00943 "don't load to DRMS and get next packet", __FILE__,__LINE__);
00944 continue;
00945 }
00946
00947 sprintf(packet_version_number,"%03d.%03d",*(read_in_buffer+14+factor), *(read_in_buffer+15+factor));
00948 strcat(packet_version_number,"\0");
00949 }
00950
00951
00952 for(i=0; i < HKDDF_MAX_PKT_SIZE;i++) hk_pkt_buffer[i]=0x00;
00953
00954
00955 for (i =0 + factor, j=0 ; i < packet_length + 6 + 1 + factor; i++)
00956 {
00957
00958 hk_pkt_buffer[j++]= *(read_in_buffer+i);
00959 }
00960
00961
00962
00963 for (i=0, y=0 ; i < packet_length + 6 + 1 ; i += 2, y++)
00964 {
00965 s_hk_pkt_buffer[y] = (unsigned short)(hk_pkt_buffer[i + 1] << 8 & 0xFF00 );
00966 s_hk_pkt_buffer[y] = (unsigned short)((hk_pkt_buffer[i] & 0x00FF) + s_hk_pkt_buffer[y]) ;
00967 }
00968
00969
00970 word_ptr = s_hk_pkt_buffer;
00971 s = decode_hk_keywords(word_ptr, apid, &ccsds.keywords);
00972 if (s)
00973 {
00974 printkerr("ERROR at %s, line %d: decode_hk_keyword function returned"
00975 " error status number <%d>\n\n", __FILE__,__LINE__, s);
00976 continue;
00977
00978 }
00979 kw_head= ccsds.keywords;
00980
00981
00982 if(check_for_sdo_apid(apid))
00983 {
00984
00985
00986 (void)sprint_time (pkt_date, get_packet_time(word_ptr), "TAI", 0);
00987
00988 ptr_fvn=find_fvn_from_shcids(global_shcids_vn, pkt_date, apid);
00989 }
00990 else
00991 {
00992
00993 ptr_fvn=find_file_version_number(global_gtcids_vn, packet_version_number,apid);
00994 }
00995
00996
00997
00998 strcpy(file_version_number,ptr_fvn);
00999 strcpy(data_seriesname, out);
01000
01001
01002
01003 printf ( "------------------------------------------------------------------------------\n");
01004 printf("Packet Number in day file = %-3d Packet Lenght = %d \n", k, packet_length);
01005 if(check_for_sdo_apid(apid))
01006 {
01007 printf("Apid = %-3.3x File Version Number = %s\n", apid,file_version_number);
01008 }
01009 else
01010 {
01011 printf("Apid = %-3.3x Packet Version Number = %s\n", apid,packet_version_number);
01012 }
01013 printf("In Day File = %s\n", in);
01014 printf("Out Series Name = %s\n", out);
01015 printf ( "------------------------------------------------------------------------------\n");
01016 printf("Packet Values in unsigned shorts: \n" );
01017 for (i=0, y=0 ; i < packet_length + 6 + 1 ; i += 2, y++)
01018 {
01019
01020 printf("%2.2x", s_hk_pkt_buffer[y] & 0x00FF);
01021 printf("%2.2x ", s_hk_pkt_buffer[y] >> 8 & 0x00FF);
01022 if ( i == 14 || i == 30 || i == 46 ||
01023 i == 62 || i == 78 || i == 94 ||
01024 i == 110 || i == 126 || i == 142 ||
01025 i == 158 || i == 174 || i == 190 ||
01026 i == 206 || i == 222 || i == 238 ||
01027 i == 254 || i == 270 || i == 286 )
01028 printf("\n");
01029 }
01030 printf("\n");
01031
01032
01033 printf ( "-----------------------------------------------------------------------------\n");
01034 printf ("LONG TELEM MNEMONIC NAME SHORT RAW VALUE ENGR VALUE ENGR VALUE\n");
01035 printf (" KEYWORD (HEX) (DECIMAL) (HEX) \n");
01036
01037
01038 for ( i=0; ccsds.keywords ; i++)
01039 {
01040 printf ( "------------------------------------------------------------------------------\n");
01041 printf ( "%-35.35s", ccsds.keywords->name);
01042 printf ( "%-9.8s", ccsds.keywords->fitsname);
01043 printf ( "%-8.8lx", (long int )ccsds.keywords->raw_value);
01044
01045
01046 if( ccsds.keywords->eng_type == KW_TYPE_UINT8)
01047 {
01048 printf(" %-12d %-10.2x\n",
01049 ccsds.keywords->eng_value.uint8_val, ccsds.keywords->eng_value.uint8_val);
01050 }
01051 else if(ccsds.keywords->eng_type == KW_TYPE_UINT16)
01052 {
01053 printf(" %-12hu %-10.4x\n",
01054 ccsds.keywords->eng_value.uint16_val, ccsds.keywords->eng_value.uint16_val);
01055 }
01056 else if(ccsds.keywords->eng_type == KW_TYPE_UINT32)
01057 {
01058 printf(" %-12u %-10.8x\n",
01059 ccsds.keywords->eng_value.uint32_val, ccsds.keywords->eng_value.uint32_val);
01060 }
01061 else if(ccsds.keywords->eng_type == KW_TYPE_STRING)
01062 {
01063 printf(" %-12s %-10s\n", ccsds.keywords->eng_value.string_val, ccsds.keywords->eng_value.string_val);
01064 }
01065 else if(ccsds.keywords->eng_type == KW_TYPE_DOUBLE)
01066 {
01067 printf(" %-12lf \n", ccsds.keywords->eng_value.double_val );
01068 }
01069 else if(ccsds.keywords->eng_type == KW_TYPE_INT8)
01070 {
01071 printf(" %-12hhd %-.2x\n", ccsds.keywords->eng_value.int8_val, ccsds.keywords->eng_value.int8_val);
01072 }
01073 else if(ccsds.keywords->eng_type == KW_TYPE_INT16)
01074 {
01075 printf(" %-12d %-10.4x\n", ccsds.keywords->eng_value.int16_val, ccsds.keywords->eng_value.int16_val);
01076 }
01077 else if(ccsds.keywords->eng_type == KW_TYPE_INT32)
01078 {
01079 printf(" %-12d %-10.8x\n", ccsds.keywords->eng_value.int32_val, ccsds.keywords->eng_value.int32_val);
01080 }
01081 else if(ccsds.keywords->eng_type == KW_TYPE_FLOAT)
01082 {
01083 printf(" %-20.20f \n", ccsds.keywords->eng_value.float_val );
01084 }
01085 else
01086 {
01087 printkerr("Warning at %s, line %d: Found Unknown KW_TYPE for this keyword:"
01088 "<%d>. Check if new or not valid KW_TYPE has been created in HKPDF files"
01089 "Skipping printing keyword. Keyword is <%s>.",
01090 __FILE__,__LINE__, (int)ccsds.keywords->eng_type, ccsds.keywords->name);
01091 }
01092
01093
01094 ccsds.keywords= ccsds.keywords->next;
01095
01096 }
01097
01098
01099 write_to_drms( apid, packet_version_number, file_version_number, out, kw_head, in, src );
01100
01101 print_packet_time(kw_head);
01102
01103
01104 sscanf(packet_version_number,"%3d.%3d",&pvnw, &pvnd);
01105 if(check_for_sdo_apid(apid))
01106 {
01107 print_hk_src_keyword(in,apid,src);
01108 }
01109 else if(pvnw == HKDDF_START_MERGED_PVNW && pvnd >= HKDDF_START_MERGED_PVND)
01110 {
01111 print_hk_src_keyword(in,apid,src);
01112 }
01113
01114
01115 }
01116 }
01117
01118
01119
01120
01121
01122
01123
01124
01125 char* get_ds_pjname(int apid, char pjn[HKDDF_MAXNUM_PJNAMES][HKDDF_MAX_PJNAME])
01126 {
01127 char *pn;
01128
01129
01130 if(apid <= HK_HSB_HIGHEST_HMI_APID && apid >= HK_HSB_LOWEST_HMI_APID || (apid <= HK_LR_HIGHEST_HMI_APID && apid >= HK_LR_LOWEST_HMI_APID))
01131 {
01132 pn = pjn[pjnHMI];
01133 }
01134 else if((apid <= HK_HSB_HIGHEST_AIA_APID && apid >= HK_HSB_LOWEST_AIA_APID) || (apid <= HK_LR_HIGHEST_AIA_APID && apid >= HK_LR_LOWEST_AIA_APID))
01135 {
01136 pn = pjn[pjnAIA];
01137 }
01138 else if((apid <= HK_LR_HIGHEST_SDO_APID) && (apid >= HK_LR_LOWEST_SDO_APID))
01139 {
01140 pn = pjn[pjnSDO];
01141 }
01142 else
01143 {
01144 printkerr("Warning at %s, line %d: APID is not in range of ",
01145 "HMI, AIA, or SDO. APID: <%d>\n",
01146 __FILE__, __LINE__, apid);
01147 pn="\0";
01148 }
01149 return((char*)pn);
01150 }
01151
01152
01153
01154
01155
01156
01157
01158
01159 int load_ds_names(char* pn, char* didn, int apid, char *pvn)
01160 {
01161
01162 FILE *file_ptr;
01163 char *directory ;
01164 char directory_filename[HKDDF_MAX_FILE_NAME];
01165 char fn[HKDDF_MAX_FILE_NAME];
01166 char lookup_name[HKDDF_MAX_LOOKUP_NAME];
01167 char sn[HKDDF_MAX_FILE_NAME];
01168 char line[HKDDF_MAXLINE_IN_FILE];
01169 int count;
01170 int fwn,fdn, pwn, pdn;
01171 int pvnw,pvnd;
01172
01173
01174 char *filename=fn;
01175 char *suffix_filename=sn;
01176 int k=0;
01177
01178
01179 directory = (char *)getenv("HK_JSVNMAP_DIRECTORY");
01180 suffix_filename= (char *)getenv("HK_SUFFIX_JSVNMAP_FILENAME");
01181 if(suffix_filename == NULL)
01182 {
01183 printkerr("ERROR at %s, line %d: Set environment variable <HK_SUFFIX_JSVNMAP_FILENAME>\n",
01184 __FILE__,__LINE__);
01185 }
01186 if(directory == NULL)
01187 {
01188 printkerr("ERROR at %s, line %d: Set environment variable <HK_JSVNMAP_DIRECTORY>\n",
01189 __FILE__,__LINE__);
01190 }
01191
01192
01193
01194 if(check_for_sdo_apid(apid))
01195 {
01196
01197 strcpy(lookup_name, get_lookup_filename(apid));
01198 sprintf(filename,"%s%s",lookup_name,suffix_filename);
01199 }
01200 else
01201 {
01202
01203 sscanf(pvn,"%3d.%3d",&pvnw, &pvnd);
01204 if(pvnw <= HKDDF_START_MERGED_PVNW && pvnd < HKDDF_START_MERGED_PVND)
01205 {
01206 sprintf(filename,"%4.4d%s",apid,suffix_filename);
01207 }
01208 else
01209 {
01210
01211 strcpy(lookup_name, get_lookup_filename(apid));
01212 sprintf(filename,"%s%s",lookup_name,suffix_filename);
01213 }
01214 }
01215
01216
01217 sprintf(directory_filename, "%s/%s", directory, filename);
01218
01219
01220 sprintf(jmap->apid,"%d",apid);
01221
01222
01223 file_ptr=fopen(directory_filename,"r");
01224 if (!file_ptr)
01225 {
01226 printkerr("ERROR at %s, line %d: Check if directory and filename are",
01227 "correct. Could not open filename: <%s>\n",
01228 __FILE__, __LINE__, directory_filename);
01229 return(0);
01230 }
01231
01232 k=0;
01233 while( fgets(line, HKDDF_MAXLINE_IN_FILE, file_ptr) != NULL )
01234 {
01235 if(line[0] == '#')
01236 {
01237 continue;
01238 }
01239 else
01240 {
01241 sscanf( line,
01242 "%s | %d.%d | %d.%d | %*s", jmap->jvn[k], &pwn,&pdn,&fwn,&fdn);
01243 sprintf(jmap->pvn[k],"%03d.%03d", pwn,pdn);
01244
01245
01246 sprintf(jmap->fvn[k],"%d.%d", fwn,fdn);
01247
01248
01249 if (!strcmp("0000", jmap->jvn[k]))
01250 {
01251 strcpy(jmap->dsn[k], "\0");
01252 }
01253 else
01254 {
01255
01256 if(check_for_sdo_apid(apid))
01257 {
01258 sprintf(jmap->dsn[k], "%s.%s_%s_%s", pn, didn, get_data_packet_name(apid), jmap->jvn[k]);
01259 }
01260 else
01261 {
01262
01263 if(pwn <= HKDDF_START_MERGED_PVNW && pdn < HKDDF_START_MERGED_PVND)
01264 {
01265 sprintf(jmap->dsn[k], "%s.%s_%04d_%s", pn, didn, apid, jmap->jvn[k]);
01266 }
01267 else
01268 {
01269 sprintf(jmap->dsn[k], "%s.%s_%s_%s", pn, didn, get_data_packet_name(apid), jmap->jvn[k]);
01270 }
01271 }
01272 }
01273 }
01274 k++;
01275 }
01276 fclose( file_ptr);
01277 count=k;
01278 return (count);
01279 }
01280
01281
01282
01283
01284
01285
01286
01287
01288
01289
01290
01291 void save_packet_values2(unsigned char *read_in_buffer, char projname[HKDDF_MAXNUM_PJNAMES][HKDDF_MAX_PJNAME],char *didn, char *in, char *src)
01292 {
01293
01294 CCSDS_Packet_t ccsds;
01295 HK_Keyword_t *kw_head;
01296 char packet_version_number[HKDDF_MAX_PVN_SIZE];
01297 char file_version_number[HKDDF_MAX_PVN_SIZE];
01298 char data_seriesname[HKDDF_MAX_DSNAME_STR];
01299 char *dname;
01300 char *ptr_fvn;
01301 int i,j,k,y,x,s;
01302 int apid;
01303 int count;
01304 int factor;
01305 int packet_length;
01306 unsigned char hk_pkt_buffer[HKDDF_MAX_PKT_SIZE];
01307 unsigned short s_hk_pkt_buffer[HKDDF_MAX_PKT_SIZE];
01308 unsigned short *word_ptr;
01309 char pkt_date[MAX_SIZE_PKT_DATE];
01310
01311
01312 for(k=0,factor=0, packet_length=0; ; k++)
01313 {
01314
01315 for(x=0; x < HKDDF_MAX_DSNAME_STR; data_seriesname[x]='\0', x++);
01316
01317
01318 factor = k * (packet_length + 6 + 1 ) ;
01319
01320
01321 if (*(read_in_buffer+5+factor) == '\0')
01322 {
01323 break;
01324 }
01325
01326
01327 packet_length= *(read_in_buffer+5+factor);
01328
01329
01330
01331 apid = (unsigned short int)( (*(read_in_buffer+1+factor)) & 0x00FF );
01332
01333 apid |= (unsigned short int)( (*(read_in_buffer+0+factor) << 8) & 0xFF00 );
01334 apid &= 0x07FF;
01335
01336
01337
01338 if(check_for_sdo_apid(apid))
01339 {
01340 sprintf(packet_version_number,"%s","not applicable");
01341 }
01342 else
01343 {
01344
01345 if (( *(read_in_buffer+14+factor) == 0) && (*(read_in_buffer+15+factor) == 0))
01346 {
01347 printkerr("Warning at %s, line %d: Getting 0.0 for packet version number."
01348 "in packet data. Skip processing this packet, don't load to "
01349 "DRMS and get next packet", __FILE__,__LINE__);
01350 continue;
01351 }
01352
01353 if ( *(read_in_buffer+14+factor) == 0 && *(read_in_buffer+15+factor))
01354 {
01355 printkerr("Warning at %s, line %d: Getting 0 for whole number(i.e.,0.1) for "
01356 "packet version number in packet data. Skip processing this packet,"
01357 "don't load to DRMS and get next packet", __FILE__,__LINE__);
01358 continue;
01359 }
01360
01361 sprintf(packet_version_number,"%03d.%03d",*(read_in_buffer+14+factor), *(read_in_buffer+15+factor));
01362 strcat(packet_version_number,"\0");
01363
01364 }
01365
01366
01367 for(i=0; i < HKDDF_MAX_PKT_SIZE;i++) hk_pkt_buffer[i]=0x00;
01368
01369
01370 for (i =0 + factor, j=0 ; i < packet_length + 6 + 1 + factor; i++)
01371 {
01372
01373 hk_pkt_buffer[j++]= *(read_in_buffer+i);
01374 }
01375
01376
01377
01378 for (i=0, y=0 ; i < packet_length + 6 + 1 ; i += 2, y++)
01379 {
01380 s_hk_pkt_buffer[y] = (unsigned short)(hk_pkt_buffer[i + 1] << 8 & 0xFF00 );
01381 s_hk_pkt_buffer[y] = (unsigned short)((hk_pkt_buffer[i] & 0x00FF) + s_hk_pkt_buffer[y]) ;
01382 }
01383
01384
01385 word_ptr = s_hk_pkt_buffer;
01386 s = decode_hk_keywords(word_ptr, apid, &ccsds.keywords);
01387 if (s)
01388 {
01389
01390
01391 printkerr("ERROR at %s, line %d: decode_hk_keyword function returned"
01392 " error status number <%d>\n\n", __FILE__,__LINE__, s);
01393 continue;
01394 }
01395 kw_head= ccsds.keywords;
01396
01397
01398 if(check_for_sdo_apid(apid))
01399 {
01400
01401
01402 (void)sprint_time (pkt_date, get_packet_time(word_ptr), "TAI", 0);
01403
01404 ptr_fvn=find_fvn_from_shcids(global_shcids_vn, pkt_date, apid);
01405 }
01406 else
01407 {
01408
01409 ptr_fvn=find_file_version_number(global_gtcids_vn, packet_version_number,apid);
01410 }
01411 strcpy(file_version_number,ptr_fvn);
01412
01413
01414
01415 count = load_ds_names(get_ds_pjname(apid,projname), didn, apid, packet_version_number);
01416 dname = lookup_dsn( apid, packet_version_number, file_version_number, count);
01417 strcpy(data_seriesname, dname);
01418
01419
01420 write_to_drms( apid, packet_version_number, file_version_number, data_seriesname, kw_head, in,src );
01421
01422 }
01423 }
01424
01425
01426
01427
01428
01429
01430
01431
01432
01433 void saveprint_packet_values2(unsigned char *read_in_buffer, char *in,
01434 char projname[HKDDF_MAXNUM_PJNAMES][HKDDF_MAX_PJNAME],
01435 char *didn, char *src)
01436 {
01437
01438 CCSDS_Packet_t ccsds;
01439 HK_Keyword_t *kw_head;
01440 char packet_version_number[HKDDF_MAX_PVN_SIZE];
01441 char file_version_number[HKDDF_MAX_PVN_SIZE];
01442 char data_seriesname[HKDDF_MAX_DSNAME_STR];
01443 char *dname;
01444 char *ptr_fvn;
01445 int i,j,k,y,x,s;
01446 int apid;
01447 int count;
01448 int factor;
01449 int packet_length;
01450 int pvnw,pvnd;
01451 unsigned char hk_pkt_buffer[HKDDF_MAX_PKT_SIZE];
01452 unsigned short s_hk_pkt_buffer[HKDDF_MAX_PKT_SIZE];
01453 unsigned short *word_ptr;
01454 char pkt_date[MAX_SIZE_PKT_DATE];
01455
01456
01457 for(k=0,factor=0, packet_length=0; ; k++)
01458 {
01459
01460 for(x=0; x < HKDDF_MAX_DSNAME_STR; data_seriesname[x]='\0', x++);
01461
01462
01463 factor = k * (packet_length + 6 + 1 ) ;
01464
01465
01466 if (*(read_in_buffer+5+factor) == '\0')
01467 {
01468 printf("\n\n*****At end of file. Found %d packets in file.\n", k);
01469 break;
01470 }
01471
01472
01473 packet_length= *(read_in_buffer+5+factor);
01474
01475
01476
01477 apid = (unsigned short int)( (*(read_in_buffer+1+factor)) & 0x00FF );
01478
01479 apid |= (unsigned short int)( (*(read_in_buffer+0+factor) << 8) & 0xFF00 );
01480 apid &= 0x07FF;
01481
01482
01483
01484 if(check_for_sdo_apid(apid))
01485 {
01486 sprintf(packet_version_number,"%s","not applicable");
01487 }
01488 else
01489 {
01490
01491 if (( *(read_in_buffer+14+factor) == 0) && (*(read_in_buffer+15+factor) == 0))
01492 {
01493 printkerr("Warning at %s, line %d: Getting 0.0 for packet version number."
01494 "in packet data. Skip processing this packet, don't load to "
01495 "DRMS and get next packet\n", __FILE__,__LINE__);
01496 continue;
01497 }
01498
01499 if ( *(read_in_buffer+14+factor) == 0 && *(read_in_buffer+15+factor))
01500 {
01501 printkerr("Warning at %s, line %d: Getting 0 for whole number(i.e.,0.1) for "
01502 "packet version number in packet data. Skip processing this packet,"
01503 "don't load to DRMS and get next packet\n", __FILE__,__LINE__);
01504 continue;
01505 }
01506
01507 sprintf(packet_version_number,"%03d.%03d",*(read_in_buffer+14+factor), *(read_in_buffer+15+factor));
01508 strcat(packet_version_number,"\0");
01509 }
01510
01511
01512 for(i=0; i < HKDDF_MAX_PKT_SIZE;i++) hk_pkt_buffer[i]=0x00;
01513
01514
01515 for (i =0 + factor, j=0 ; i < packet_length + 6 + 1 + factor; i++)
01516 {
01517
01518 hk_pkt_buffer[j++]= *(read_in_buffer+i);
01519 }
01520
01521
01522
01523 for (i=0, y=0 ; i < packet_length + 6 + 1 ; i += 2, y++)
01524 {
01525 s_hk_pkt_buffer[y] = (unsigned short)(hk_pkt_buffer[i + 1] << 8 & 0xFF00 );
01526 s_hk_pkt_buffer[y] = (unsigned short)((hk_pkt_buffer[i] & 0x00FF) + s_hk_pkt_buffer[y]) ;
01527 }
01528
01529
01530 word_ptr = s_hk_pkt_buffer;
01531 s = decode_hk_keywords(word_ptr, apid, &ccsds.keywords);
01532 if (s)
01533 {
01534 printkerr("ERROR at %s, line %d: decode_hk_keyword function returned"
01535 " error status number <%d>\n\n", __FILE__,__LINE__, s);
01536 continue;
01537 }
01538 kw_head= ccsds.keywords;
01539
01540
01541 if(check_for_sdo_apid(apid))
01542 {
01543
01544
01545 (void)sprint_time (pkt_date, get_packet_time(word_ptr), "TAI", 0);
01546
01547 ptr_fvn=find_fvn_from_shcids(global_shcids_vn, pkt_date,apid);
01548 }
01549 else
01550 {
01551
01552 ptr_fvn=find_file_version_number(global_gtcids_vn, packet_version_number,apid);
01553 }
01554 strcpy(file_version_number,ptr_fvn);
01555
01556
01557
01558 count = load_ds_names(get_ds_pjname(apid,projname), didn, apid, packet_version_number);
01559 dname = lookup_dsn( apid, packet_version_number, file_version_number, count);
01560 strcpy(data_seriesname, dname);
01561
01562
01563
01564 printf ( "------------------------------------------------------------------------------\n");
01565 printf("Packet Number in day file = %-3d Packet Lenght = %d \n", k, packet_length);
01566 if(check_for_sdo_apid(apid))
01567 {
01568 printf("Apid = %-3.3x File Version Number = %s\n", apid,file_version_number);
01569 }
01570 else
01571 {
01572 printf("Apid = %-3.3x Packet Version Number = %s\n", apid,packet_version_number);
01573 }
01574 printf("In Day File = %s\n", in);
01575 printf("Out Series Name = %s\n", data_seriesname);
01576 printf ( "------------------------------------------------------------------------------\n");
01577 printf("Packet Values in unsigned shorts: \n" );
01578 for (i=0, y=0 ; i < packet_length + 6 + 1 ; i += 2, y++)
01579 {
01580
01581 printf("%2.2x", s_hk_pkt_buffer[y] & 0x00FF);
01582 printf("%2.2x ", s_hk_pkt_buffer[y] >> 8 & 0x00FF);
01583 if ( i == 14 || i == 30 || i == 46 ||
01584 i == 62 || i == 78 || i == 94 ||
01585 i == 110 || i == 126 || i == 142 ||
01586 i == 158 || i == 174 || i == 190 ||
01587 i == 206 || i == 222 || i == 238 ||
01588 i == 254 || i == 270 || i == 286 )
01589 printf("\n");
01590 }
01591 printf("\n");
01592
01593
01594 printf ( "-----------------------------------------------------------------------------\n");
01595 printf ("LONG TELEM MNEMONIC NAME SHORT RAW VALUE ENGR VALUE ENGR VALUE\n");
01596 printf (" KEYWORD (HEX) (DECIMAL) (HEX) \n");
01597
01598
01599 for ( i=0; ccsds.keywords ; i++)
01600 {
01601 printf ( "------------------------------------------------------------------------------\n");
01602 printf ( "%-35.35s", ccsds.keywords->name);
01603 printf ( "%-9.8s", ccsds.keywords->fitsname);
01604 printf ( "%-8.8lx", (long int) ccsds.keywords->raw_value);
01605
01606 if( ccsds.keywords->eng_type == KW_TYPE_UINT8)
01607 {
01608 printf(" %-12d %-10.2x\n",
01609 ccsds.keywords->eng_value.uint8_val, ccsds.keywords->eng_value.uint8_val);
01610 }
01611 else if(ccsds.keywords->eng_type == KW_TYPE_UINT16)
01612 {
01613 printf(" %-12hu %-10.4x\n",
01614 ccsds.keywords->eng_value.uint16_val, ccsds.keywords->eng_value.uint16_val);
01615 }
01616 else if(ccsds.keywords->eng_type == KW_TYPE_UINT32)
01617 {
01618 printf(" %-12u %-10.8x\n",
01619 ccsds.keywords->eng_value.uint32_val, ccsds.keywords->eng_value.uint32_val);
01620 }
01621 else if(ccsds.keywords->eng_type == KW_TYPE_STRING)
01622 {
01623 printf(" %-12s %-10s\n", ccsds.keywords->eng_value.string_val, ccsds.keywords->eng_value.string_val);
01624 }
01625 else if(ccsds.keywords->eng_type == KW_TYPE_DOUBLE)
01626 {
01627 printf(" %-12lf \n", ccsds.keywords->eng_value.double_val );
01628 }
01629 else if(ccsds.keywords->eng_type == KW_TYPE_INT8)
01630 {
01631 printf(" %-12hhd %-.2x\n", ccsds.keywords->eng_value.int8_val, ccsds.keywords->eng_value.int8_val);
01632
01633 }
01634 else if(ccsds.keywords->eng_type == KW_TYPE_INT16)
01635 {
01636 printf(" %-12d %-10.4x\n", ccsds.keywords->eng_value.int16_val, ccsds.keywords->eng_value.int16_val);
01637 }
01638 else if(ccsds.keywords->eng_type == KW_TYPE_INT32)
01639 {
01640 printf(" %-12d %-10.8x\n", ccsds.keywords->eng_value.int32_val, ccsds.keywords->eng_value.int32_val);
01641 }
01642 else if(ccsds.keywords->eng_type == KW_TYPE_FLOAT)
01643 {
01644 printf(" %-20.20f \n", ccsds.keywords->eng_value.float_val);
01645 }
01646 else
01647 {
01648 printf("WARNING(decode_dayfile):****Found*** NO KW_TYPE\n");
01649 printf("Eng type is %d\n", (int)ccsds.keywords->eng_type);
01650 }
01651
01652
01653 ccsds.keywords= ccsds.keywords->next;
01654
01655 }
01656
01657
01658
01659 write_to_drms( apid, packet_version_number, file_version_number, data_seriesname, kw_head, in, src );
01660
01661 print_packet_time(kw_head);
01662
01663
01664 sscanf(packet_version_number,"%3d.%3d",&pvnw, &pvnd);
01665 if(check_for_sdo_apid(apid))
01666 {
01667 print_hk_src_keyword(in,apid,src);
01668 }
01669 else if(pvnw == HKDDF_START_MERGED_PVNW && pvnd >= HKDDF_START_MERGED_PVND)
01670 {
01671 print_hk_src_keyword(in,apid,src);
01672 }
01673
01674
01675 }
01676 }
01677
01678
01679
01680
01681
01682
01683
01684
01685 void print_packet_time(HK_Keyword_t *kwh)
01686 {
01687 HK_Keyword_t *kw;
01688 TIME pkt_time;
01689 kw= kwh;
01690 pkt_time=(TIME)0.0;
01691
01692 if (!get_packet_time_for_df(kw, &pkt_time))
01693 {
01694
01695 printf ( "------------------------------------------------------------------------------\n");
01696 printf("ERROR: COULD NOT SET PACKET_TIME KEYWORD\n");
01697 return;
01698 }
01699 else
01700 {
01701 printf ( "------------------------------------------------------------------------------\n");
01702 printf("PACKET_TIME %15.5lf\n", pkt_time);
01703 }
01704 return;
01705 }
01706
01707
01708
01709
01710
01711
01712
01713
01714
01715
01716 void save_packet_values1(unsigned char *read_in_buffer, char *out, char *in, char *src)
01717 {
01718
01719 CCSDS_Packet_t ccsds;
01720 HK_Keyword_t *kw_head;
01721 char packet_version_number[HKDDF_MAX_PVN_SIZE];
01722 char file_version_number[HKDDF_MAX_PVN_SIZE];
01723 int i,j,k,y,s;
01724 int apid;
01725 int factor;
01726 int packet_length;
01727 unsigned char hk_pkt_buffer[HKDDF_MAX_PKT_SIZE];
01728 unsigned short s_hk_pkt_buffer[HKDDF_MAX_PKT_SIZE];
01729 unsigned short *word_ptr;
01730 char pkt_date[MAX_SIZE_PKT_DATE];
01731 char *ptr_fvn;
01732
01733
01734 for(k=0,factor=0,packet_length=0; ; k++)
01735 {
01736
01737
01738 factor = k * (packet_length + 6 + 1 ) ;
01739
01740
01741 if (*(read_in_buffer+5+factor) == '\0')
01742 {
01743 break;
01744 }
01745
01746
01747 packet_length= *(read_in_buffer+5+factor);
01748
01749
01750
01751 apid = (unsigned short int)( (*(read_in_buffer+1+factor)) & 0x00FF );
01752
01753 apid |= (unsigned short int)( (*(read_in_buffer+0+factor) << 8) & 0xFF00 );
01754 apid &= 0x07FF;
01755
01756
01757
01758 if(check_for_sdo_apid(apid))
01759 {
01760 sprintf(packet_version_number,"%s","not applicable");
01761 }
01762 else
01763 {
01764
01765 if (( *(read_in_buffer+14+factor) == 0) && (*(read_in_buffer+15+factor) == 0))
01766 {
01767 printkerr("Warning at %s, line %d: Getting 0.0 for packet version number."
01768 "in packet data. Skip processing this packet, don't load to "
01769 "DRMS and get next packet", __FILE__,__LINE__);
01770 continue;
01771 }
01772
01773 if ( *(read_in_buffer+14+factor) == 0 && *(read_in_buffer+15+factor))
01774 {
01775 printkerr("Warning at %s, line %d: Getting 0 for whole number(i.e.,0.1) for "
01776 "packet version number in packet data. Skip processing this packet,"
01777 "don't load to DRMS and get next packet", __FILE__,__LINE__);
01778 continue;
01779 }
01780
01781 sprintf(packet_version_number,"%03d.%03d",*(read_in_buffer+14+factor), *(read_in_buffer+15+factor));
01782 strcat(packet_version_number,"\0");
01783 }
01784
01785
01786 for(i=0; i < HKDDF_MAX_PKT_SIZE;i++) hk_pkt_buffer[i]=0x00;
01787
01788
01789 for (i =0 + factor, j=0 ; i < packet_length + 6 + 1 + factor; i++)
01790 {
01791
01792 hk_pkt_buffer[j++]= *(read_in_buffer+i);
01793 }
01794
01795
01796
01797
01798 for (i=0, y=0 ; i < packet_length + 6 + 1 ; i += 2, y++)
01799 {
01800 s_hk_pkt_buffer[y] = (unsigned short)(hk_pkt_buffer[i + 1] << 8 & 0xFF00 );
01801 s_hk_pkt_buffer[y] = (unsigned short)((hk_pkt_buffer[i] & 0x00FF) + s_hk_pkt_buffer[y]) ;
01802 }
01803
01804 word_ptr = s_hk_pkt_buffer;
01805 s = decode_hk_keywords(word_ptr, apid, &ccsds.keywords);
01806 if (s)
01807 {
01808 printkerr("ERROR at %s, line %d: decode_hk_keyword function returned"
01809 " error status number <%d>\n\n", __FILE__,__LINE__, s);
01810 continue;
01811 }
01812 kw_head= ccsds.keywords;
01813
01814
01815 if(check_for_sdo_apid(apid))
01816 {
01817
01818
01819 (void)sprint_time (pkt_date, get_packet_time(word_ptr), "TAI", 0);
01820
01821 ptr_fvn=find_fvn_from_shcids(global_shcids_vn, pkt_date, apid);
01822 }
01823 else
01824 {
01825
01826 ptr_fvn=find_file_version_number(global_gtcids_vn, packet_version_number,apid);
01827 }
01828
01829 strcpy(file_version_number,ptr_fvn);
01830
01831
01832 write_to_drms( apid, packet_version_number, file_version_number, out, kw_head, in,src );
01833
01834 }
01835 }
01836
01837
01838
01839
01840
01841
01842
01843
01844
01845 void set_env_variables()
01846 {
01847 FILE * fp;
01848 char envfile[500], s1[256],s2[256],s3[256], line[256];
01849
01850
01851 strcpy(envfile, ENVFILE );
01852
01853 if(!(fp=fopen(envfile, "r")))
01854 {
01855 printf("ERROR:Can't open environment variable file <%s>. Check setting is correct\n", envfile);
01856 exit(0);
01857 }
01858
01859 while( fgets(line, MAXLINE_IN_FILE, fp) != NULL )
01860 {
01861 if (!strncmp(line, "#", 1))
01862 {
01863 continue;
01864 }
01865 else
01866 {
01867 sscanf(line, "%s %s %s ", s1,s2,s3);
01868
01869 setenv(s2, s3, 1);
01870 }
01871 }
01872
01873 fclose(fp);
01874 }
01875
01876
01877
01878
01879
01880
01881
01882
01883
01884
01885
01886
01887
01888
01889 char *get_hk_src_keyword(int apid, char *in_file, char *src)
01890 {
01891
01892 char date[HK_LEV0_MAX_HKS_DATE];
01893 char df_datatype_name[HK_LEV0_MAX_DATATYPE_NAME];
01894 char df_project_name[HK_LEV0_MAX_PROJECT_NAME];
01895 char *df_dtname, *df_pjname;
01896 char hk_source[HK_LEV0_MAX_HKS];
01897 char *hks;
01898 int len_hk_source;
01899 int pkt_yr, pkt_month, pkt_day;
01900 int status;
01901
01902
01903 df_dtname=df_datatype_name;
01904 df_pjname=df_project_name;
01905 hks = hk_source;
01906
01907
01908 if(apid <= HK_HSB_HIGHEST_HMI_APID && apid >= HK_HSB_LOWEST_HMI_APID || (apid <= HK_LR_HIGHEST_HMI_APID && apid >= HK_LR_LOWEST_HMI_APID))
01909 {
01910 df_pjname = getenv("HK_DDF_DF_PROJECT_NAME_HMI");
01911 }
01912 else if((apid <= HK_HSB_HIGHEST_AIA_APID && apid >= HK_HSB_LOWEST_AIA_APID) || (apid <= HK_LR_HIGHEST_AIA_APID && apid >= HK_LR_LOWEST_AIA_APID))
01913 {
01914 df_pjname = getenv("HK_DDF_DF_PROJECT_NAME_AIA");
01915 }
01916 else if((apid <= HK_LR_HIGHEST_SDO_APID) && (apid >= HK_LR_LOWEST_SDO_APID))
01917 {
01918 df_pjname = getenv("HK_DDF_DF_PROJECT_NAME_SDO");
01919 }
01920 else
01921 {
01922 printkerr("Warning at %s, line %d: APID is not in range of ",
01923 "HMI, AIA, or SDO. APID: <%d>\n",
01924 __FILE__, __LINE__, apid);
01925 }
01926
01927
01928 df_dtname = getenv("HK_DDF_DF_DATA_ID_NAME");
01929
01930
01931
01932 status=get_date_in_filename(in_file, src, &pkt_yr, &pkt_month, &pkt_day);
01933 if(!status)
01934 {
01935 printkerr("ERROR at %s, line %d: HK_SOURCE keyword value could not be set. "
01936 "Setting hk source keyword value to null for input filename <%s> "
01937 "with source value <%s>. \n", __FILE__, __LINE__, in_file, src);
01938 }
01939
01940
01941 sprintf(date,"%d.%-02.2d.%-02.2d_00:00:00.00_TAI",pkt_yr, pkt_month, pkt_day);
01942
01943
01944 len_hk_source=strlen(df_pjname) + strlen(df_dtname) + strlen(date) + strlen("hsb") + strlen("475");
01945 if(len_hk_source >= HK_LEV0_MAX_HKS - 1)
01946 {
01947 printkerr("ERROR at %s, line %d: HK_SOURCE keyword value exceeds maximum size of array. "
01948 "Length is %d. Setting source value to null so that we do not exceed hks array.\n",
01949 __FILE__, __LINE__, len_hk_source);
01950 strcpy(hks,"" );
01951 }
01952 else
01953 {
01954
01955 sprintf(hks,"%s.%s[%s][%d][%s]\0", df_pjname, df_dtname, date, apid, src);
01956 }
01957 return(hks);
01958 }
01959
01960
01961
01962
01963
01964
01965
01966
01967
01968
01969 int get_date_in_filename(char *inf,char *src, int *yr,int *mo, int *day)
01970 {
01971
01972 char fn_str[HKDDF_MAX_FILE_NAME];
01973 char final_fn_str[HKDDF_MAX_FILE_NAME];
01974 char *fn,*final_fn;
01975 int ret_status, year_day;
01976
01977
01978 fn=fn_str;
01979 final_fn=final_fn_str;
01980 ret_status=1;
01981
01982
01983 fn= strrchr(inf, '/');
01984
01985
01986 final_fn=strtok(fn,"/");
01987 final_fn=strtok(fn,"/");
01988
01989 if(!strcmp(src,"moc"))
01990 {
01991
01992
01993 sscanf(final_fn,"%*4s_%4d_%3d_%*2d.%*3s",yr,&year_day);
01994
01995
01996 (void)get_month_day(*yr, year_day, mo, day);
01997
01998 }
01999 else if(!strcmp(src,"rtmon"))
02000 {
02001
02002 sscanf(final_fn,"%4d%2d%2d",yr,mo,day);
02003 }
02004 else if(!strcmp(src,"hsb"))
02005 {
02006
02007 sscanf(final_fn,"%*3s_%*4s_%4d_%2d_%2d_%*8s.%*3s",yr,mo,day);
02008
02009 }
02010 else if(!strcmp(src,"egsefm"))
02011 {
02012
02013 sscanf(final_fn,"%4d%2d%2d",yr,mo,day);
02014 }
02015 else
02016 {
02017 printkerr("ERROR at %s, line %d: Unknown source value. Unexpected value:<%s>\n",
02018 __FILE__, __LINE__, src);
02019 ret_status=0;
02020 }
02021 return(ret_status);
02022 }
02023
02024
02025
02026
02027
02028
02029 void print_hk_src_keyword(char *ifn, int apid, char *src)
02030 {
02031 char hk_source[HKDDF_MAX_HK_SRC_KW];
02032
02033
02034 strcpy(hk_source, get_hk_src_keyword(apid, ifn, src));
02035 if (!hk_source)
02036 {
02037
02038 printf ( "------------------------------------------------------------------------------\n");
02039 printf("ERROR: COULD NOT SET PACKET_TIME KEYWORD\n");
02040 printf ( "------------------------------------------------------------------------------\n");
02041 printf ("%s\n",HKDDF_CNTRL_L);
02042 return;
02043 }
02044 else
02045 {
02046 printf ( "------------------------------------------------------------------------------\n");
02047 printf("HK_SOURCE %-100s\n", hk_source);
02048 printf ( "------------------------------------------------------------------------------\n");
02049 printf ("%s\n",HKDDF_CNTRL_L);
02050 }
02051 return;
02052 }
02053
02054
02055
02056
02057
02058
02059 void get_month_day(int year, int yearday, int *pmonth, int *pday)
02060 {
02061 static char daytab[2][13] =
02062 {
02063 {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31},
02064 {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31},
02065 };
02066 int i, leap ;
02067 leap = ((year%4 == 0) && year%100 != 0) || year%400 == 0;
02068 for(i = 1; yearday > daytab[leap][i]; i++)
02069 {
02070 yearday -= daytab[leap][i];
02071 }
02072 *pmonth = i;
02073 *pday = yearday;
02074 }
02075
02076
02077
02078
02079
02080
02081 int check_df_env_variable()
02082 {
02083
02084 char hkbyapid_project_name[HK_LEV0_MAX_PROJECT_NAME];
02085 char hkbyapid_datatype_name[HK_LEV0_MAX_DATATYPE_NAME];
02086 char df_project_name[HK_LEV0_MAX_PROJECT_NAME];
02087 char df_datatype_name[HK_LEV0_MAX_DATATYPE_NAME];
02088 char *hk_dtname, *hk_pjname, *df_dtname, *df_pjname;
02089
02090
02091 hk_pjname=hkbyapid_project_name;
02092 df_dtname=df_datatype_name;
02093 df_pjname=df_project_name;
02094 hk_dtname=hkbyapid_datatype_name;
02095
02096
02097
02098
02099 df_pjname = getenv("HK_DDF_DF_PROJECT_NAME_HMI");
02100 if(df_pjname == NULL)
02101 {
02102 printkerr("ERROR at %s, line %d: Could not get project name environment "
02103 "variable:<HK_DDF_DF_PROJECT_NAME_HMI>. Set the env variable "
02104 "HK_DDF_DF_PROJECT_NAME_HMI to dayfile data series project name"
02105 "(hmi, hmi_ground, su_carl,etc.) for a existing dayfile data series name.\n",
02106 __FILE__,__LINE__);
02107 return HKDDF_ENVIRONMENT_VARS_NOT_SET ;
02108 }
02109 df_pjname = getenv("HK_DDF_DF_PROJECT_NAME_AIA");
02110 if(df_pjname == NULL)
02111 {
02112 printkerr("ERROR at %s, line %d: Could not get project name environment "
02113 "variable:<HK_DDF_DF_PROJECT_NAME_AIA>. Set the env variable "
02114 "HK_DDF_DF_PROJECT_NAME_AIA to dayfile data series project name"
02115 "(aia, aia_ground, su_carl,etc.) for a existing data series name.\n",
02116 __FILE__,__LINE__);
02117 return HKDDF_ENVIRONMENT_VARS_NOT_SET ;
02118 }
02119 df_pjname = getenv("HK_DDF_DF_PROJECT_NAME_SDO");
02120 if(df_pjname == NULL)
02121 {
02122 printkerr("ERROR at %s, line %d: Could not get project name environment "
02123 "variable:<HK_DDF_DF_PROJECT_NAME_SDO>. Set the env variable "
02124 "HK_DDF_DF_PROJECT_NAME_SDO to dayfile data series project name"
02125 "(sdo, sdo_ground, su_carl,etc.) for a existing data series name.\n",
02126 __FILE__,__LINE__);
02127 return HKDDF_ENVIRONMENT_VARS_NOT_SET ;
02128 }
02129
02130
02131 df_dtname = getenv("HK_DDF_DF_DATA_ID_NAME");
02132 if(df_dtname == NULL)
02133 {
02134 printkerr("ERROR at %s, line %d: Could not get data type name environment "
02135 "variable:<HK_DDF_DF_DATA_ID_NAME>. Set the env variable "
02136 "HK_DDF_DF_DATA_ID_NAME to dayfile data series data type name"
02137 "(hk_dayfile, etc.) for a existing dayfile data series name\n",
02138 __FILE__ , __LINE__ );
02139 return (HKDDF_ENVIRONMENT_VARS_NOT_SET) ;
02140 }
02141
02142
02143
02144
02145 hk_pjname = getenv("HK_DDF_HKBYAPID_PROJECT_NAME_HMI");
02146 if(hk_pjname == NULL)
02147 {
02148 printkerr("ERROR at %s, line %d: Could not get project name environment "
02149 "variable:<HK_DDF_HKBYAPID_PROJECT_NAME_HMI>. Set the env variable "
02150 "HK_DDF_HKBYAPID_PROJECT_NAME_HMI to series project name"
02151 "(hmi, hmi_ground, su_carl,etc.) for a existing HK by APID series name.\n",
02152 __FILE__,__LINE__);
02153 return HKDDF_ENVIRONMENT_VARS_NOT_SET ;
02154 }
02155 hk_pjname = getenv("HK_DDF_HKBYAPID_PROJECT_NAME_AIA");
02156 if(hk_pjname == NULL)
02157 {
02158 printkerr("ERROR at %s, line %d: Could not get project name environment "
02159 "variable:<HK_DDF_HKBYAPID_PROJECT_NAME_AIA>. Set the env variable "
02160 "HK_DDF_HKBYAPID_PROJECT_NAME_AIA to series project name"
02161 "(hmi, hmi_ground, su_carl,etc.) for a existing HK by APID series name.\n",
02162 __FILE__,__LINE__);
02163 return HKDDF_ENVIRONMENT_VARS_NOT_SET ;
02164 }
02165 hk_pjname = getenv("HK_DDF_HKBYAPID_PROJECT_NAME_SDO");
02166 if(hk_pjname == NULL)
02167 {
02168 printkerr("ERROR at %s, line %d: Could not get project name environment "
02169 "variable:<HK_DDF_HKBYAPID_PROJECT_NAME_SDO>. Set the env variable "
02170 "HK_DDF_HKBYAPID_PROJECT_NAME_SDO to series project name"
02171 "(hmi, hmi_ground, su_carl,etc.) for a existing HK By APID series name.\n",
02172 __FILE__,__LINE__);
02173 return HKDDF_ENVIRONMENT_VARS_NOT_SET ;
02174 }
02175
02176
02177 hk_dtname = getenv("HK_DDF_HKBYAPID_DATA_ID_NAME");
02178 if(hk_dtname == NULL)
02179 {
02180 printkerr("ERROR at %s, line %d: Could not get data type name environment "
02181 "variable:<HK_DDF_HKBYAPID_DATA_ID_NAME>. Set the env variable "
02182 "HK_DDF_HKBYAPID_DATA_ID_NAME to data series data type name"
02183 "(lev0,lev0test, etc.) for a existing HK By APID data series name\n",
02184 __FILE__ , __LINE__ );
02185 return (HKDDF_ENVIRONMENT_VARS_NOT_SET) ;
02186 }
02187
02188 return (1);
02189 }
02190