00001 #ident "$Header: /home/cvsuser/cvsroot/JSOC/proj/lev0/apps/load_hk_config_files_iris.c,v 1.3 2013/03/07 23:30:35 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
00043
00044
00045
00046
00047 #include <stdio.h>
00048 #include <stdlib.h>
00049 #include <string.h>
00050 #include <math.h>
00051 #include <time.h>
00052 #include <sys/types.h>
00053 #include <sys/stat.h>
00054 #include <sys/vfs.h>
00055 #include <fcntl.h>
00056 #include <unistd.h>
00057 #include <libgen.h>
00058 #include "drms_types.h"
00059 #include "egsehmicomp.h"
00060 #include "printk.h"
00061 #include "decode_hk.h"
00062 #include <dirent.h>
00063 #include "write_hk_to_drms.h"
00064
00065 #define LOAD_HK_C
00066 #include "load_hk_config_files.h"
00067 #undef LOAD_HK_C
00068
00069
00070 APID_HKPFD_Files * allocate_apid_hkpfd_files_nodes(int *ptrFirstTimeFlag);
00071 void load_gtcids_data( GTCIDS_Version_Number* top_ptr_gtcids_data,
00072 APID_Pointer_HK_Configs *top_apid_ptr_hk_configs);
00073 int check_for_sdo_apid(int apid);
00074
00075 #define LOAD_HK_C
00076 #include "load_hk_config_files.h"
00077 #undef LOAD_HK_C
00078
00079
00080 APID_HKPFD_Files * allocate_apid_hkpfd_files_nodes(int *ptrFirstTimeFlag);
00081 void load_gtcids_data( GTCIDS_Version_Number* top_ptr_gtcids_data,
00082 APID_Pointer_HK_Configs *top_apid_ptr_hk_configs);
00083 int check_for_sdo_apid(int apid);
00084 void deallocate_apid_hkpfd_files_nodes(APID_HKPFD_Files *top_ptr_apid_hkpfd_files_ptr) ;
00085 char * find_file_version_number(GTCIDS_Version_Number *top,char p_version_number[MAX_CHAR_VERSION_NUMBER], int apid);
00086 char * find_fvn_from_shcids(SHCIDS_Version_Number *top,char pkt_date[MAX_SIZE_PKT_DATE],int apid);
00087
00088 APID_Pointer_HK_Configs *global_apid_configs;
00089 GTCIDS_Version_Number *global_gtcids_vn;
00090 SHCIDS_Version_Number *global_shcids_vn;
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104 int load_all_apids_hk_configs(int apid, char version_number[MAX_CHAR_VERSION_NUMBER], char pkt_date[MAX_SIZE_PKT_DATE])
00105 {
00106
00107 APID_Pointer_HK_Configs *apid_ptr_hk_configs;
00108 APID_Pointer_HK_Configs *top_apid_ptr_hk_configs;
00109 APID_HKPFD_Files *top_apid_hkpfd_files;
00110 APID_HKPFD_Files *hkpfd_files;
00111 GTCIDS_Version_Number *top_ptr_gtcids_data;
00112 SHCIDS_Version_Number *top_ptr_shcids_data;
00113 int apid_array[MAX_APID_POINTERS];
00114 char apidstr_array[MAX_APID_POINTERS][10];
00115 int number_of_apids, i;
00116 char file_version_number[MAX_CHAR_VERSION_NUMBER];
00117 char *ptr_fvn;
00118
00119
00120
00121
00122
00123 ptr_fvn=version_number;
00124
00125
00126 top_ptr_gtcids_data = read_gtcids_hk_file();
00127
00128
00129
00130 top_ptr_shcids_data = read_shcids_hk_file();
00131
00132
00133 if(check_for_sdo_apid(apid))
00134 {
00135
00136 ptr_fvn=find_fvn_from_shcids(top_ptr_shcids_data, pkt_date, apid);
00137 }
00138 else
00139 {
00140
00141 ptr_fvn=find_file_version_number(top_ptr_gtcids_data, version_number, apid);
00142 }
00143
00144
00145 if ((top_apid_hkpfd_files = read_all_hk_config_files(apid, ptr_fvn, version_number)) == NULL)
00146 return ERROR_HK_NOSUCHDIR;
00147
00148
00149 number_of_apids = 0;
00150 memset(apid_array, 0, sizeof(apid_array));
00151 for(i=0; i < MAX_APID_POINTERS; i++)
00152 {
00153 memset(apidstr_array[i],'\0', 10);
00154 }
00155 for(hkpfd_files=top_apid_hkpfd_files; hkpfd_files;
00156 hkpfd_files=hkpfd_files->next)
00157 {
00158
00159 for (i=0; i<number_of_apids; i++)
00160 {
00161
00162 if (apid_array[i] == hkpfd_files->apid)
00163 {
00164
00165 break;
00166 }
00167 }
00168 if (i >= number_of_apids)
00169 {
00170
00171 apid_array[i]= hkpfd_files->apid;
00172
00173
00174 strcpy(apidstr_array[i], hkpfd_files->apid_name);
00175 number_of_apids++;
00176 }
00177 }
00178
00179 for ( i=0; i < number_of_apids; i++)
00180 {
00181 if ( i == 0)
00182 {
00183
00184 apid_ptr_hk_configs = (APID_Pointer_HK_Configs *)malloc(sizeof(APID_Pointer_HK_Configs));
00185 top_apid_ptr_hk_configs = apid_ptr_hk_configs;
00186 }
00187 else
00188 {
00189
00190 apid_ptr_hk_configs->next = (APID_Pointer_HK_Configs *)malloc(sizeof(APID_Pointer_HK_Configs));
00191 apid_ptr_hk_configs = apid_ptr_hk_configs->next;
00192 }
00193
00194
00195 apid_ptr_hk_configs->apid = apid_array[i];
00196 strcpy(apid_ptr_hk_configs->apid_name, apidstr_array[i]);
00197
00198
00199 apid_ptr_hk_configs->next= NULL;
00200 apid_ptr_hk_configs->ptr_hk_configs= (HK_Config_Files*)NULL;
00201 }
00202
00203
00204 apid_ptr_hk_configs = top_apid_ptr_hk_configs;
00205 for(i=0; i < number_of_apids; i++)
00206 {
00207 load_config_data( top_apid_hkpfd_files, apid_ptr_hk_configs);
00208 apid_ptr_hk_configs = apid_ptr_hk_configs->next;
00209 }
00210
00211
00212
00213 load_gtcids_data(top_ptr_gtcids_data, top_apid_ptr_hk_configs);
00214
00215
00216 global_apid_configs = top_apid_ptr_hk_configs;
00217
00218
00219 deallocate_apid_hkpfd_files_nodes(top_apid_hkpfd_files) ;
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243
00244
00245
00246
00247
00248
00249 return HK_SUCCESSFUL;
00250 }
00251
00252
00253
00254
00255
00256
00257
00258
00259
00260
00261 void load_config_data(APID_HKPFD_Files *hkpfd_files,
00262 APID_Pointer_HK_Configs *hk_configs)
00263 {
00264
00265 APID_HKPFD_Files* p;
00266 FILE* file_ptr;
00267 char filename[MAX_FILE_NAME];
00268 int apid;
00269
00270
00271 apid = hk_configs->apid;
00272 p = hkpfd_files;
00273 while(p)
00274 {
00275 if ( p->apid == apid )
00276 {
00277 sprintf(filename,"%s/%s",p->directory_name, p->filename);
00278 file_ptr = fopen( filename ,"r");
00279 (void)save_hdpf_new_formats(file_ptr, hk_configs);
00280 fclose(file_ptr);
00281 }
00282 p = p->next;
00283 }
00284 }
00285
00286
00287
00288
00289
00290
00291
00292
00293
00294 APID_HKPFD_Files* read_all_hk_config_files(int apid, char f_version_number[MAX_CHAR_VERSION_NUMBER],char p_version_number[MAX_CHAR_VERSION_NUMBER])
00295 {
00296
00297 APID_HKPFD_Files *top, *p;
00298 DIR *dir_p;
00299 char dirname[200];
00300 char *dn;
00301 int curr_pvn_wn,curr_pvn_dn;
00302 struct dirent *dir_entry_p;
00303
00304
00305 int file_loaded_flag=0;
00306 memset(dirname, 0x0, sizeof(dirname));
00307
00308
00309 if(check_for_sdo_apid(apid))
00310 {
00311 dn = getenv("HK_SHCIDS_DIRECTORY");
00312 if(dn == NULL)
00313 {
00314 printkerr("ERROR at %s, line %d: Could not get directory environment\n"
00315 "variable:<HK_SHCIDS_DIRECTORY>. Set the env variable "
00316 "HK_SHCIDS_DIRECTORY to point to the config file directory.\n",
00317 __FILE__,__LINE__,dn);
00318 return NULL;
00319 }
00320 }
00321 else
00322 {
00323 dn = getenv("HK_CONFIG_DIRECTORY");
00324 if(dn == NULL)
00325 {
00326 printkerr("ERROR at %s, line %d: Could not get directory environment\n"
00327 "variable:<HK_CONFIG_DIRECTORY>. Set the env variable "
00328 "HK_CONFIG_DIRECTORY to point to the config file directory.\n",
00329 __FILE__,__LINE__,dn);
00330 return NULL;
00331 }
00332 }
00333
00334
00335 strcpy( dirname, dn);
00336 strcat(dirname, f_version_number);
00337 strcat(dirname,"\0");
00338
00339
00340 if ((dir_p = opendir(dirname)) == NULL)
00341 {
00342 printkerr("ERROR at %s, line %d: Could not open directory <%s>. "
00343 "The directory with < %s > version number does not exist. "
00344 "Run make_hkpdf.pl script to create directory and config files.\n",
00345 __FILE__,__LINE__,dirname, f_version_number);
00346 return NULL;
00347 }
00348
00349
00350 top = NULL;
00351 while( (dir_entry_p = readdir(dir_p)) != NULL )
00352 {
00353
00354
00355
00356 if( !strncmp(dir_entry_p->d_name,"IRIS-",5))
00357 ;
00358 else
00359 continue;
00360
00361 if( top == NULL )
00362 top = p = malloc(sizeof(APID_HKPFD_Files));
00363 else
00364 {
00365 p->next = malloc(sizeof(APID_HKPFD_Files));
00366 p = p->next;
00367 }
00368 p->next = NULL;
00369
00370
00371 strcpy(p->filename, dir_entry_p->d_name);
00372 strcpy(p->directory_name, dirname);
00373
00374 if (check_for_sdo_apid(apid))
00375 {
00376
00377
00378 curr_pvn_wn= HK_LEV0_START_MERGED_PVNW;
00379 curr_pvn_dn= HK_LEV0_START_MERGED_PVND;
00380 }
00381 else
00382 {
00383
00384 sscanf(p_version_number,"%3d.%3d",&curr_pvn_wn, &curr_pvn_dn);
00385 }
00386
00387
00388
00389
00390
00391
00392 if( !strncmp(dir_entry_p->d_name,"IRIS-ISP",8) )
00393 {
00394
00395 sscanf(p->filename, "%*4s-%3s-%*7s-%s", p->apid_name, p->version_number);
00396 p->apid=56;
00397 }
00398 else if( !strncmp(dir_entry_p->d_name,"HMI-ISP",7) )
00399 {
00400
00401 sscanf(p->filename, "%*3s-%3s-%*7s-%s", p->apid_name, p->version_number);
00402 p->apid=445;
00403 }
00404 else if( !strncmp(dir_entry_p->d_name,"AIA-ISP",7) )
00405 {
00406
00407 sscanf(p->filename, "%*3s-%3s-%*7s-%s", p->apid_name, p->version_number);
00408 p->apid=529;
00409 }
00410 else if( !strncmp(dir_entry_p->d_name,"HMI-SEQ",7) )
00411 {
00412
00413 sscanf(p->filename, "%*3s-%3s-%*7s-%s", p->apid_name, p->version_number);
00414 p->apid=451;
00415 }
00416 else if( !strncmp(dir_entry_p->d_name,"AIA-SEQ",7) )
00417 {
00418
00419 sscanf(p->filename, "%*3s-%3s-%*7s-%s", p->apid_name, p->version_number);
00420 p->apid=536;
00421 }
00422 else if( !strncmp(dir_entry_p->d_name,"HMI-OBT",7) )
00423 {
00424
00425 sscanf(p->filename, "%*3s-%3s-%*7s-%s", p->apid_name, p->version_number);
00426 p->apid=448;
00427 }
00428 else if( !strncmp(dir_entry_p->d_name,"AIA-OBT",7) )
00429 {
00430
00431 sscanf(p->filename, "%*3s-%3s-%*7s-%s", p->apid_name, p->version_number);
00432 p->apid=540;
00433 }
00434 else if( !strncmp(dir_entry_p->d_name,"SDO-ASD",7) )
00435 {
00436
00437 sscanf(p->filename, "%*3s-%3s-%*7s-%s", p->apid_name, p->version_number);
00438 p->apid=129;
00439 }
00440 else if( !strncmp(dir_entry_p->d_name,"AIA-",4) )
00441 {
00442
00443 sscanf(p->filename, "%*3s-%x-%*7s-%s", &p->apid, p->version_number);
00444 sprintf(p->apid_name,"0x%03x", p->apid);
00445 }
00446 else if( !strncmp(dir_entry_p->d_name,"HMI-",4) )
00447 {
00448
00449 sscanf(p->filename, "%*3s-%x-%*7s-%s", &p->apid, p->version_number);
00450 sprintf(p->apid_name,"0x%03x", p->apid);
00451 }
00452 else
00453 {
00454
00455 sscanf(p->filename, "%*4s-%x-%*7s-%s", &p->apid, p->version_number);
00456 sprintf(p->apid_name,"0x%03x", p->apid);
00457 printkerr("WARNING at %s, line %d: This is not a valid config file "
00458 "name < %s > for merged apid case. Updates HKPDF files with correct "
00459 "format of files(<HMI|AIA|SDO>-<APID-NAME>-version-<file version number>. "
00460 "This occurred for apid < %d >.\n",
00461 __FILE__,__LINE__, dir_entry_p->d_name, p->apid );
00462 }
00463
00464
00465
00466
00467
00468
00469
00470 file_loaded_flag=1;
00471 }
00472
00473 closedir(dir_p);
00474
00475
00476 if ( !file_loaded_flag)
00477 {
00478
00479
00480
00481
00482
00483
00484
00485 }
00486 return top;
00487 }
00488
00489
00490
00491
00492
00493
00494
00495
00496
00497
00498
00499
00500
00501
00502
00503
00504 int save_hdpf_new_formats(FILE* file_ptr,APID_Pointer_HK_Configs *p_apid_ptr_hk_configs)
00505 {
00506
00507 int err_status[3];
00508 HK_Config_Files *ptr_config_node;
00509 HK_Config_Files *previous_ptr_config_node;
00510 int status;
00511 int i, j, k;
00512 char line[MAXLINE_IN_FILE];
00513 char keyword_lines[MAX_NUM_KW_LINES][MAXLINE_IN_FILE];
00514 char acon_lines[MAX_NUM_ACON_LINES][MAXLINE_ACON_IN_FILE];
00515 char dcon_lines[MAX_NUM_DCON_LINES][MAXLINE_DCON_IN_FILE];
00516
00517
00518
00519 if (p_apid_ptr_hk_configs->ptr_hk_configs == NULL)
00520 {
00521
00522 p_apid_ptr_hk_configs->ptr_hk_configs =malloc( sizeof(HK_Config_Files));
00523 ptr_config_node = p_apid_ptr_hk_configs->ptr_hk_configs;
00524 ptr_config_node->next = NULL;
00525 ptr_config_node->keywords = NULL;
00526 }
00527 else
00528 {
00529
00530 for(ptr_config_node = p_apid_ptr_hk_configs->ptr_hk_configs,
00531 previous_ptr_config_node = ptr_config_node;
00532 ptr_config_node;
00533 previous_ptr_config_node = ptr_config_node,
00534 ptr_config_node = ptr_config_node->next)
00535 {
00536 ;
00537 }
00538
00539 ptr_config_node = malloc( sizeof(HK_Config_Files));
00540 previous_ptr_config_node->next = ptr_config_node;
00541 ptr_config_node->next = NULL;
00542 ptr_config_node->keywords = NULL;
00543 }
00544
00545 for(i=0, j=0, k=0; fgets(line, MAXLINE_IN_FILE, file_ptr) != NULL; )
00546 {
00547 if (!strncmp(line, "#", 1))
00548 {
00549 continue;
00550 }
00551 else if (!strncmp(line, "KWD", 3))
00552 {
00553 strcpy( keyword_lines[i++], line);
00554 }
00555 else if (!strncmp(line, "DCON", 4))
00556 {
00557
00558 if(j >= MAX_NUM_DCON_LINES)
00559 {
00560 printkerr("WARNING: Maximum lines for array exceeded.\n"
00561 " Skipping saving DCON config data since array too small.\n"
00562 " Update define variable MAX_NUM_DCON_LINES. \n");
00563 }
00564 else
00565 {
00566 strncpy( dcon_lines[j++], line, MAXLINE_DCON_IN_FILE);
00567 }
00568 }
00569 else if (! strncmp(line, "ACON", 4))
00570 {
00571 if(k >= MAX_NUM_ACON_LINES)
00572 {
00573 printkerr("WARNING: Maximum lines for array exceeded.\n"
00574 " Skipping saving ACON config data since array too small.\n"
00575 " Update define variable MAX_NUM_ACON_LINES. \n");
00576 }
00577 else
00578 {
00579 strcpy( acon_lines[k++], line);
00580 }
00581 }
00582 else if (!strncmp(line, "FILE", 4))
00583 {
00584 sscanf(line," %*s %*s %s ", ptr_config_node->file_version_number);
00585 }
00586 else if (!strncmp(line, "APID", 4))
00587 {
00588
00589 if( strstr(line, "HMIKER") )
00590 {
00591
00592 sscanf( line,"%*s %s %d %s %s",
00593 ptr_config_node->apid_name,
00594 &(ptr_config_node->number_bytes_used),
00595 ptr_config_node->packet_id_type,
00596 ptr_config_node->date);
00597 }
00598 else if( strstr(line, "AIAKER") )
00599 {
00600
00601 sscanf( line,"%*s %s %d %s %s",
00602 ptr_config_node->apid_name,
00603 &(ptr_config_node->number_bytes_used),
00604 ptr_config_node->packet_id_type,
00605 ptr_config_node->date);
00606 }
00607 else if( strstr(line, "IRIS") )
00608 {
00609
00610 sscanf( line,"%*s %s %d %s %s",
00611 ptr_config_node->apid_name,
00612 &(ptr_config_node->number_bytes_used),
00613 ptr_config_node->packet_id_type,
00614 ptr_config_node->date);
00615 ptr_config_node->apid_number = 56;
00616 }
00617 else if( strstr(line, "HMI") )
00618 {
00619
00620 sscanf( line,"%*s %s %d %s %s",
00621 ptr_config_node->apid_name,
00622 &(ptr_config_node->number_bytes_used),
00623 ptr_config_node->packet_id_type,
00624 ptr_config_node->date);
00625 }
00626 else if( strstr(line, "AIA") )
00627 {
00628
00629 sscanf( line,"%*s %s %d %s %s",
00630 ptr_config_node->apid_name,
00631 &(ptr_config_node->number_bytes_used),
00632 ptr_config_node->packet_id_type,
00633 ptr_config_node->date);
00634 }
00635 else if( strstr(line, "SDO") )
00636 {
00637
00638 sscanf( line,"%*s %s %d %*s %s",
00639 ptr_config_node->apid_name,
00640 &(ptr_config_node->number_bytes_used),
00641 ptr_config_node->date);
00642
00643 strcpy(ptr_config_node->packet_id_type,"SDO");
00644 sscanf( line,"%*s %x", &(ptr_config_node->apid_number));
00645 }
00646 else if( strstr(line, "SSIM") )
00647 {
00648
00649 sscanf( line,"%*s %5s %d %*s %s",
00650 ptr_config_node->apid_name,
00651 &(ptr_config_node->number_bytes_used),
00652 ptr_config_node->date);
00653
00654 strcpy(ptr_config_node->packet_id_type,"HMI");
00655 }
00656 else
00657 {
00658
00659
00660 sscanf( line,"%*s %x %d %s",
00661 &(ptr_config_node->apid_number),
00662 &(ptr_config_node->number_bytes_used),
00663 ptr_config_node->date);
00664
00665
00666 strcpy(ptr_config_node->packet_id_type,"HMI");
00667 printkerr("WARNING: Could not find line valid value in APID line in apid-#-version-# file. "
00668 "Got line:<%s> so default setting to instrument flag to HMI. Probably need to "
00669 "update make_hkpdf.pl script or rerun to fix older HK files.\n", line);
00670 }
00671 }
00672 else
00673 {
00674 printkerr("WARNING: Could not find line with this keyword in apid-#-version-# file. Possible bad data in STANFORD file.\n");
00675 printkerr("WARNING: Line tried to parse is < %s >\n", line);
00676 }
00677 }
00678
00679 strcpy(keyword_lines[i],"");
00680 strcpy(dcon_lines[j],"");
00681 strcpy(acon_lines[k],"");
00682
00683 err_status[0] = load_hdpf_keyword_lines(keyword_lines,i,ptr_config_node);
00684 err_status[1] = load_hdpf_dsc_lines(dcon_lines,j,ptr_config_node);
00685 err_status[2] = load_hdpf_alg_lines(acon_lines,k,ptr_config_node);
00686
00687
00688
00689
00690 for ( i=0; i < sizeof(err_status); i++)
00691 {
00692 if ( err_status[i] != ERROR_LOADING_HK_DATA )
00693 continue;
00694 else
00695 status= err_status[i];
00696 }
00697 return status;
00698 }
00699
00700
00701
00702
00703
00704
00705
00706
00707
00708 int load_hdpf_keyword_lines(char keyword_lines[MAX_NUM_KW_LINES][MAXLINE_IN_FILE],int number_of_lines,HK_Config_Files *ptr_hk_config_node)
00709 {
00710
00711 Keyword_Parameter *keyword_node;
00712 int k=0;
00713
00714
00715 keyword_node= create_hdpf_keyword_nodes( ptr_hk_config_node, number_of_lines );
00716
00717 for(k=0; keyword_lines[k][0] != '\0';
00718 k++,keyword_node=keyword_node->next)
00719 {
00720 sscanf(keyword_lines[k]," %*s %s %s %d %d %d %s %c %*s",
00721 keyword_node->keyword_name,
00722 keyword_node->telemetry_mnemonic_name,
00723 &(keyword_node->start_byte),
00724 &(keyword_node->start_bit_number),
00725 &(keyword_node->bit_length),
00726 keyword_node->type,
00727 &keyword_node->conv_type);
00728 strcat(keyword_node->telemetry_mnemonic_name,"\0");
00729 strcat(keyword_node->keyword_name,"\0");
00730 keyword_node->dsc_ptr = (DSC_Conversion *)NULL;
00731 keyword_node->alg_ptr = (ALG_Conversion *)NULL;
00732 }
00733 return HK_SUCCESSFUL;
00734 }
00735
00736
00737
00738
00739
00740
00741
00742
00743
00744 int load_hdpf_dsc_lines(char dsc_lines[MAX_NUM_DCON_LINES][MAXLINE_DCON_IN_FILE ], int number_of_lines, HK_Config_Files *ptr_hk_config_node)
00745 {
00746
00747 DSC_Conversion *dsc_node;
00748 int i=0;
00749 char tlm_name[HK_MAX_TLM_NAME];
00750 Keyword_Parameter *kw;
00751
00752
00753
00754
00755
00756
00757 for ( kw= ptr_hk_config_node->keywords ; kw; kw=kw->next)
00758 {
00759
00760 if ( kw->conv_type == 'D')
00761 {
00762 kw->dsc_ptr=(DSC_Conversion*)NULL;
00763
00764 for (i=0; i < number_of_lines; i++)
00765 {
00766 sscanf ( dsc_lines[i], "%*s %s %*d %*d %*d %*d %*d %*d", tlm_name);
00767 strcat( tlm_name, "");
00768 strcat( tlm_name, "\0");
00769 if( !strcmp( kw->telemetry_mnemonic_name, tlm_name))
00770 {
00771
00772 dsc_node = create_hdpf_dsc_nodes( kw);
00773
00774 sscanf(dsc_lines[i]," %*s %*s %d %d %s %*s",
00775 &(dsc_node->low_range), &(dsc_node->high_range),
00776 dsc_node->dsc_value);
00777 dsc_node->next = NULL;
00778 }
00779 }
00780 }
00781 }
00782 return 0;
00783 }
00784
00785
00786
00787
00788
00789
00790
00791
00792
00793
00794
00795 int load_hdpf_alg_lines(char alg_lines[MAX_NUM_ACON_LINES][MAXLINE_ACON_IN_FILE],int number_of_lines,HK_Config_Files *ptr_hk_config_node)
00796 {
00797
00798 ALG_Conversion *alg_node;
00799 int i, k;
00800 char tlm_name[HK_MAX_TLM_NAME];
00801 Keyword_Parameter *kw;
00802
00803
00804
00805
00806
00807
00808 for ( kw= ptr_hk_config_node->keywords ; kw; kw=kw->next)
00809 {
00810
00811 if ( kw->conv_type == 'A')
00812 {
00813
00814 for (i=0; i < number_of_lines; i++)
00815 {
00816
00817 sscanf ( alg_lines[i], "%*s %s %*d %*d %*d %*d %*d %*d %*d", tlm_name);
00818 strcat( tlm_name, "");
00819 if( !strncmp( kw->telemetry_mnemonic_name, tlm_name, sizeof(tlm_name)))
00820 {
00821
00822 kw->alg_ptr = (ALG_Conversion*)malloc (sizeof (ALG_Conversion));
00823 alg_node= kw->alg_ptr;
00824
00825
00826 k=0;
00827 sscanf(alg_lines[i]," %*s %*s %d %lf %lf %lf %lf %lf %lf %*s",
00828 &(alg_node->number_of_coeffs), &(alg_node->coeff[k++]),
00829 &(alg_node->coeff[k++]), &(alg_node->coeff[k++]),
00830 &(alg_node->coeff[k++]), &(alg_node->coeff[k++]), &(alg_node->coeff[k]) );
00831 if(alg_node->number_of_coeffs != 6 && alg_node->number_of_coeffs != 5)
00832 {
00833 printkerr("WARNING: Receive data value for number of coefficients that were not expected values "
00834 "which are <5 or 6>. If value larger then 6 then will exceed array allowed size. "
00835 "Number of coefficients got was:<%d> \n",alg_node->number_of_coeffs);
00836 }
00837 break;
00838 }
00839 }
00840 }
00841 }
00842 return HK_SUCCESSFUL;
00843 }
00844
00845
00846
00847
00848
00849
00850
00851
00852
00853
00854 Keyword_Parameter* create_hdpf_keyword_nodes(HK_Config_Files *ptr_hk_config,
00855 int number_of_lines)
00856 {
00857
00858 Keyword_Parameter *p;
00859 int k;
00860
00861
00862 p = ptr_hk_config->keywords = NULL;
00863
00864 for( k=0; k<number_of_lines; k++)
00865 {
00866 if(ptr_hk_config->keywords == NULL)
00867 {
00868
00869 p = ptr_hk_config->keywords = malloc( sizeof(Keyword_Parameter) );
00870 }
00871 else
00872 {
00873
00874 p->next = malloc(sizeof(Keyword_Parameter ));
00875 p = p->next;
00876 }
00877 p->next = NULL;
00878 }
00879 return (ptr_hk_config->keywords);
00880 }
00881
00882
00883
00884
00885
00886
00887
00888
00889
00890 DSC_Conversion* create_hdpf_dsc_nodes(Keyword_Parameter *ptr_hk_keyword)
00891 {
00892
00893 DSC_Conversion *p;
00894
00895
00896 p = ptr_hk_keyword->dsc_ptr ;
00897
00898 if ( p == NULL)
00899 {
00900
00901 p = (DSC_Conversion *) malloc(sizeof(DSC_Conversion));
00902 ptr_hk_keyword->dsc_ptr= p;
00903 }
00904 else
00905 {
00906 while ( p->next != (DSC_Conversion *)(NULL))
00907 {
00908 p= p->next;
00909 }
00910
00911 p->next = (DSC_Conversion *) malloc (sizeof(DSC_Conversion));
00912 p=p->next;
00913 }
00914 p->next= NULL;
00915 return(p);
00916 }
00917
00918
00919
00920
00921
00922
00923
00924
00925
00926
00927 HK_Config_Files* check_packet_version_number( HK_Config_Files *ptr_to_configs,
00928 char *version_number )
00929 {
00930 while(ptr_to_configs != NULL )
00931 {
00932 #ifdef DEBUG_LOAD_HK_CONFIG_FILE
00933 printkerr("DEBUG:Message at %s, line %d: Packet Version Number looking for:<%s>\n", __FILE__, __LINE__,version_number);
00934 printkerr("DEBUG:Message at %s, line %d: Packet Version Number found in config structure:<%s>\n", __FILE__, __LINE__,ptr_to_configs->parameter_version_number);
00935 #endif
00936 if(!strcmp(ptr_to_configs->parameter_version_number, version_number))
00937 {
00938 break;
00939 }
00940 ptr_to_configs = ptr_to_configs->next;
00941 }
00942 return ptr_to_configs;
00943 }
00944
00945
00946
00947
00948
00949
00950
00951 HK_Config_Files* check_file_version_number( HK_Config_Files *ptr_to_configs,
00952 char *version_number )
00953 {
00954 while(ptr_to_configs != NULL )
00955 {
00956 if(!strcmp(ptr_to_configs->file_version_number, version_number))
00957 break;
00958 ptr_to_configs = ptr_to_configs->next;
00959 }
00960 return ptr_to_configs;
00961 }
00962
00963
00964
00965
00966
00967
00968
00969
00970
00971 int check_free_configs_flag(void)
00972 {
00973
00974 int status;
00975 FILE *file_ptr;
00976 char *directory ;
00977 char *filename;
00978 char directory_filename[MAX_FILE_NAME];
00979
00980
00981 directory = getenv("HK_CONFIG_DIRECTORY");
00982 filename= getenv("HK_FREE_FLAG_FILE");
00983 if(filename == NULL)
00984 filename = "HK_FREE_CONFIG_FLAG_FILE";
00985 if(directory == NULL)
00986 directory = "../../tables/hk_config_file";
00987 sprintf(directory_filename, "%s/%s", directory, filename);
00988
00989 file_ptr = fopen(directory_filename, "r");
00990 if (file_ptr == NULL)
00991 {
00992 status =0;
00993 }
00994 else
00995 {
00996 status = 1;
00997 fclose(file_ptr);
00998 }
00999 return status;
01000 }
01001
01002
01003
01004
01005
01006
01007
01008
01009
01010
01011
01012
01013
01014
01015 void deallocate_apid_ptr_hk_config_nodes(void)
01016 {
01017 extern APID_Pointer_HK_Configs *global_apid_configs;
01018 APID_Pointer_HK_Configs *tmp_apid_ptr_hk_configs;
01019 APID_Pointer_HK_Configs *prev_apid_ptr_hk_configs;
01020 HK_Config_Files *tmp_ptr_hk_configs;
01021 HK_Config_Files *prev_ptr_hk_configs;
01022 Keyword_Parameter *tmp_keyword_node;
01023 Keyword_Parameter *prev_keyword_node;
01024 DSC_Conversion *tmp_dsc_node;
01025 DSC_Conversion *prev_dsc_node;
01026 ALG_Conversion *tmp_alg_node;
01027
01028
01029 if (!( check_free_configs_flag()))
01030 {
01031
01032 return;
01033 }
01034
01035
01036 tmp_apid_ptr_hk_configs=global_apid_configs;
01037
01038
01039 for(prev_apid_ptr_hk_configs=tmp_apid_ptr_hk_configs;
01040 tmp_apid_ptr_hk_configs;
01041 prev_apid_ptr_hk_configs = tmp_apid_ptr_hk_configs )
01042 {
01043 for(prev_ptr_hk_configs=tmp_ptr_hk_configs=tmp_apid_ptr_hk_configs->ptr_hk_configs;
01044 tmp_ptr_hk_configs;
01045 prev_ptr_hk_configs =tmp_ptr_hk_configs)
01046 {
01047 for(prev_keyword_node=tmp_keyword_node=
01048 tmp_ptr_hk_configs->keywords;
01049 tmp_keyword_node;
01050 prev_keyword_node =tmp_keyword_node)
01051 {
01052
01053 for(prev_dsc_node=tmp_dsc_node=tmp_keyword_node->dsc_ptr;
01054 tmp_dsc_node; prev_dsc_node = tmp_dsc_node)
01055 {
01056 tmp_dsc_node= tmp_dsc_node->next;
01057 free( prev_dsc_node);
01058 }
01059
01060 tmp_alg_node=tmp_keyword_node->alg_ptr;
01061 if (tmp_keyword_node)
01062 {
01063 free( tmp_alg_node );
01064 }
01065 tmp_keyword_node=tmp_keyword_node->next;
01066 free(prev_keyword_node);
01067 }
01068 tmp_ptr_hk_configs =tmp_ptr_hk_configs->next;
01069 free(prev_ptr_hk_configs);
01070 }
01071 tmp_apid_ptr_hk_configs = tmp_apid_ptr_hk_configs->next ;
01072 free(prev_apid_ptr_hk_configs);
01073 }
01074
01075 global_apid_configs=NULL;
01076
01077 }
01078
01079
01080
01081
01082
01083
01084
01085
01086
01087 GTCIDS_Version_Number * read_gtcids_hk_file()
01088 {
01089
01090 char *hk_gtcids_directory ;
01091 char *hk_gtcids_filename;
01092 char hk_gtcids_directory_filename[MAX_FILE_NAME];
01093 FILE *file_ptr;
01094 char line[MAXLINE_IN_FILE];
01095 GTCIDS_Version_Number *top_ptr_gtcids_vn;
01096 GTCIDS_Version_Number *ptr_gtcids_vn;
01097
01098
01099 hk_gtcids_directory = getenv("HK_CONFIG_DIRECTORY");
01100 hk_gtcids_filename= getenv("HK_GTCIDS_FILE");
01101 if(hk_gtcids_filename == NULL)
01102 hk_gtcids_filename = "gtcids.txt";
01103 if(hk_gtcids_directory == NULL)
01104 hk_gtcids_directory = "../../tables/hk_config_file";
01105 sprintf(hk_gtcids_directory_filename, "%s/%s", hk_gtcids_directory,
01106 hk_gtcids_filename);
01107
01108 file_ptr = fopen(hk_gtcids_directory_filename, "r");
01109 if(!file_ptr)
01110 {
01111 printkerr("ERROR:Couldn't open Ground To Code IDS file %s.\n",hk_gtcids_directory_filename);
01112 printkerr("Set the enviroment variables HK_CONFIG_DIRECTORY"
01113 " to point to config directory and HK_GTCIDS_FILE"
01114 " environment variable to point to the correct file name\n");
01115 return NULL;
01116 }
01117 top_ptr_gtcids_vn = NULL;
01118 while( fgets(line, MAXLINE_IN_FILE, file_ptr) != NULL )
01119 {
01120 if((line[0] == '#') || (line[0] == '\n'))
01121 continue;
01122 else
01123 {
01124 if (top_ptr_gtcids_vn == NULL)
01125 {
01126 top_ptr_gtcids_vn = ptr_gtcids_vn = malloc(sizeof(GTCIDS_Version_Number));
01127 ptr_gtcids_vn->next = (GTCIDS_Version_Number*)NULL;
01128 }
01129 else
01130 {
01131 ptr_gtcids_vn->next = malloc(sizeof(GTCIDS_Version_Number));
01132 ptr_gtcids_vn = ptr_gtcids_vn->next;
01133 ptr_gtcids_vn->next = (GTCIDS_Version_Number*)NULL;
01134 }
01135 ptr_gtcids_vn->next= NULL;
01136
01137
01138
01139
01140
01141 sscanf( line,
01142 "%s %s |%*s | %s | %s | %s | %*s | %s | %*s",
01143 ptr_gtcids_vn->change_date,
01144 ptr_gtcids_vn->change_time,
01145 ptr_gtcids_vn->ker_id_version_number,
01146 ptr_gtcids_vn->hmi_id_version_number,
01147 ptr_gtcids_vn->aia_id_version_number,
01148 ptr_gtcids_vn->file_version_number);
01149 }
01150 }
01151 fclose(file_ptr);
01152
01153 global_gtcids_vn = top_ptr_gtcids_vn;
01154 return(top_ptr_gtcids_vn);
01155 }
01156
01157
01158
01159
01160
01161
01162
01163
01164
01165
01166
01167
01168 void load_gtcids_data( GTCIDS_Version_Number* top_ptr_gtcids_data,
01169 APID_Pointer_HK_Configs *top_apid_ptr_hk_configs)
01170 {
01171
01172 GTCIDS_Version_Number* tmp_ptr_gtcids_data;
01173 APID_Pointer_HK_Configs *tmp_apid_ptr_hk_configs;
01174 HK_Config_Files *tmp_ptr_hk_configs;
01175
01176
01177 tmp_ptr_gtcids_data= top_ptr_gtcids_data;
01178 tmp_apid_ptr_hk_configs= top_apid_ptr_hk_configs;
01179
01180
01181 for(tmp_apid_ptr_hk_configs = top_apid_ptr_hk_configs;
01182 tmp_apid_ptr_hk_configs ;
01183 tmp_apid_ptr_hk_configs= tmp_apid_ptr_hk_configs->next)
01184 {
01185 for( tmp_ptr_hk_configs = tmp_apid_ptr_hk_configs->ptr_hk_configs;
01186 tmp_ptr_hk_configs ;
01187 tmp_ptr_hk_configs= tmp_ptr_hk_configs->next)
01188 {
01189 for (tmp_ptr_gtcids_data=top_ptr_gtcids_data;tmp_ptr_gtcids_data ;
01190 tmp_ptr_gtcids_data=tmp_ptr_gtcids_data->next)
01191 {
01192 if( !strcmp(tmp_ptr_gtcids_data->file_version_number,
01193 tmp_ptr_hk_configs->file_version_number))
01194 {
01195 if(!strcmp(tmp_ptr_hk_configs->packet_id_type, HMI_ID_TYPE))
01196 {
01197 strcpy(tmp_ptr_hk_configs->parameter_version_number,
01198 tmp_ptr_gtcids_data->hmi_id_version_number);
01199 }
01200 else if(!strcmp(tmp_ptr_hk_configs->packet_id_type, AIA_ID_TYPE))
01201 {
01202 strcpy(tmp_ptr_hk_configs->parameter_version_number,
01203 tmp_ptr_gtcids_data->aia_id_version_number);
01204 }
01205 else if(!strcmp(tmp_ptr_hk_configs->packet_id_type, IRIS_ID_TYPE))
01206 {
01207 strcpy(tmp_ptr_hk_configs->parameter_version_number,
01208 tmp_ptr_gtcids_data->hmi_id_version_number);
01209 }
01210 else if(!strcmp(tmp_ptr_hk_configs->packet_id_type, AIAKER_ID_TYPE))
01211 {
01212 strcpy(tmp_ptr_hk_configs->parameter_version_number,
01213 tmp_ptr_gtcids_data->ker_id_version_number);
01214 }
01215 else if(!strcmp(tmp_ptr_hk_configs->packet_id_type, HMIKER_ID_TYPE))
01216 {
01217 strcpy(tmp_ptr_hk_configs->parameter_version_number,
01218 tmp_ptr_gtcids_data->ker_id_version_number);
01219 }
01220 else
01221 {
01222 strcpy(tmp_ptr_hk_configs->parameter_version_number,
01223 tmp_ptr_gtcids_data->hmi_id_version_number);
01224 }
01225 break;
01226 }
01227 }
01228 }
01229 }
01230 }
01231
01232
01233
01234
01235
01236
01237
01238
01239
01240 void deallocate_GTCIDS_Version_Number(void)
01241 {
01242
01243 GTCIDS_Version_Number *p,*tmp;
01244
01245
01246 p = global_gtcids_vn;
01247
01248 while(p)
01249 {
01250 tmp = p->next;
01251 free(p);
01252 p = tmp;
01253 }
01254 }
01255
01256
01257
01258
01259
01260
01261 void deallocate_SHCIDS_Version_Number(void)
01262 {
01263
01264 SHCIDS_Version_Number *p,*tmp;
01265
01266
01267 p = global_shcids_vn;
01268
01269 while(p)
01270 {
01271 tmp = p->next;
01272 free(p);
01273 p = tmp;
01274 }
01275 }
01276
01277
01278
01279
01280
01281
01282
01283
01284 void deallocate_apid_hkpfd_files_nodes(APID_HKPFD_Files *ptr)
01285 {
01286
01287 APID_HKPFD_Files *tmp;
01288
01289 while(ptr)
01290 {
01291 tmp = ptr->next;
01292 free(ptr);
01293 ptr = tmp;
01294 }
01295 return;
01296 }
01297
01298
01299
01300
01301
01302
01303
01304
01305
01306
01307 HK_Config_Files* reread_all_files(APID_Pointer_HK_Configs *apid_ptr_configs,
01308 char version_number[MAX_CHAR_VERSION_NUMBER], char pkt_date[MAX_SIZE_PKT_DATE])
01309 {
01310
01311 APID_HKPFD_Files *hkpfd_files;
01312 APID_HKPFD_Files *top_hkpfd_files;
01313 APID_Pointer_HK_Configs *p, *prev_p;
01314 GTCIDS_Version_Number *ptr_gtcids_data;
01315 SHCIDS_Version_Number *ptr_shcids_data;
01316 char file_version_number[50];
01317 char *ptr_fvn;
01318 int apid;
01319 int found_flag;
01320
01321
01322 ptr_fvn=file_version_number;
01323
01324
01325 apid= apid_ptr_configs->apid;
01326
01327
01328
01329 deallocate_GTCIDS_Version_Number();
01330 deallocate_SHCIDS_Version_Number();
01331 read_gtcids_hk_file();
01332 read_shcids_hk_file();
01333 ptr_gtcids_data = global_gtcids_vn;
01334 ptr_shcids_data = global_shcids_vn;
01335
01336 if(check_for_sdo_apid(apid))
01337 {
01338 ptr_fvn=find_fvn_from_shcids(ptr_shcids_data, pkt_date, apid);
01339 #ifdef DEBUG_LOAD_HK_CONFIG_FILE
01340 printkerr("DEBUG:Message at %s, line %d: Rereading config files and shcids file to find file version:<%s> apid:<%d>\n", __FILE__, __LINE__, ptr_fvn, apid);
01341 #endif
01342 }
01343 else
01344 {
01345
01346 ptr_fvn=find_file_version_number(ptr_gtcids_data, version_number, apid);
01347 #ifdef DEBUG_LOAD_HK_CONFIG_FILE
01348 printkerr("DEBUG:Message at %s, line %d: Rereading config files and gtcids file to find file version:<%s> apid:<%d>\n", __FILE__, __LINE__,ptr_fvn, apid);
01349 #endif
01350 }
01351
01352
01353 if ((top_hkpfd_files = read_all_hk_config_files(apid,ptr_fvn,version_number)) == NULL)
01354 return (HK_Config_Files*)NULL;
01355
01356 for(hkpfd_files=top_hkpfd_files; hkpfd_files;
01357 hkpfd_files=hkpfd_files->next)
01358 {
01359 found_flag=0;
01360 for(p=global_apid_configs; p ; p=p->next)
01361 {
01362
01363 if (!strcmp(p->apid_name, hkpfd_files->apid_name))
01364 {
01365 found_flag=1;
01366 break;
01367 }
01368 prev_p=p;
01369 }
01370 if (!found_flag)
01371 {
01372
01373 prev_p->next = (APID_Pointer_HK_Configs *) malloc (sizeof (APID_Pointer_HK_Configs));
01374 prev_p->next->next= NULL;
01375 prev_p->next->ptr_hk_configs= (HK_Config_Files*) NULL;
01376
01377 strcpy(prev_p->next->apid_name, hkpfd_files->apid_name);
01378 }
01379 }
01380
01381 for(p=global_apid_configs; p ; p=p->next)
01382 {
01383 load_config_data(top_hkpfd_files, p);
01384 }
01385
01386 if (!check_for_sdo_apid(apid))
01387 {
01388
01389 p=global_apid_configs;
01390 load_gtcids_data(ptr_gtcids_data, p);
01391 }
01392
01393
01394 hkpfd_files=top_hkpfd_files;
01395 deallocate_apid_hkpfd_files_nodes(hkpfd_files) ;
01396
01397
01398 p = global_apid_configs;
01399 while (p)
01400 {
01401 if( p->apid == apid )
01402 {
01403 return p->ptr_hk_configs;
01404 }
01405 p = p->next;
01406 }
01407
01408 return (HK_Config_Files*)NULL;
01409 }
01410
01411
01412
01413
01414
01415
01416
01417
01418
01419 char * find_file_version_number(GTCIDS_Version_Number *top, char p_version_number[MAX_CHAR_VERSION_NUMBER],int aid)
01420 {
01421
01422 GTCIDS_Version_Number *tmp_ptr;
01423
01424 for(tmp_ptr=top;tmp_ptr;tmp_ptr=tmp_ptr->next)
01425 {
01426
01427 if (aid == HK_HSB_HMI_OBT_1 || aid == HK_HSB_HMI_OBT_2 || aid == HK_HSB_AIA_OBT_1 || aid == HK_HSB_AIA_OBT_2 || aid == HK_LR_AIA_OBT || aid == HK_LR_HMI_OBT || aid == HK_LR_HMI_KER_TELEM || aid == HK_LR_AIA_KER_TELEM)
01428 {
01429 if( !strcmp(tmp_ptr->ker_id_version_number, p_version_number))
01430 {
01431 return tmp_ptr->file_version_number;
01432 }
01433 }
01434 else if ((aid >= HK_HSB_HMI_LRANGE && aid <= HK_HSB_HMI_HRANGE ) || (aid >= HK_LR_HMI_LRANGE && aid <= HK_LR_HMI_HRANGE))
01435 {
01436 if( !strcmp(tmp_ptr->hmi_id_version_number, p_version_number))
01437 {
01438 return tmp_ptr->file_version_number;
01439 }
01440 }
01441 else if ((aid >= HK_HSB_AIA_LRANGE && aid <= HK_HSB_AIA_HRANGE ) || (aid >= HK_LR_AIA_LRANGE && aid <= HK_LR_AIA_HRANGE))
01442 {
01443 if( !strcmp(tmp_ptr->aia_id_version_number, p_version_number))
01444 {
01445 return tmp_ptr->file_version_number;
01446 }
01447 }
01448 }
01449 return ("");
01450 }
01451
01452
01453
01454
01455
01456
01457
01458 SHCIDS_Version_Number * read_shcids_hk_file()
01459 {
01460
01461 char *hk_shcids_directory ;
01462 char *hk_shcids_filename;
01463 char hk_shcids_directory_filename[MAX_FILE_NAME];
01464 FILE *file_ptr;
01465 char line[MAXLINE_IN_FILE];
01466 SHCIDS_Version_Number *top_ptr_shcids_vn;
01467 SHCIDS_Version_Number *ptr_shcids_vn;
01468 char new_str[9];
01469
01470
01471 hk_shcids_directory = getenv("HK_SHCIDS_DIRECTORY");
01472 hk_shcids_filename= getenv("HK_SHCIDS_FILE");
01473 if(hk_shcids_filename == NULL)
01474 hk_shcids_filename = "shcids.txt";
01475 if(hk_shcids_directory == NULL)
01476 hk_shcids_directory = "/home/production/cvs/TBL_JSOC/lev0/hk_config_file/sdo_hk";
01477 sprintf(hk_shcids_directory_filename, "%s/%s", hk_shcids_directory,
01478 hk_shcids_filename);
01479
01480
01481 file_ptr = fopen(hk_shcids_directory_filename, "r");
01482 if(!file_ptr)
01483 {
01484 printkerr("ERROR:Couldn't open SDO HK Code IDS file %s.\n",hk_shcids_directory_filename);
01485 printkerr("Set the enviroment variables HK_SHCIDS_DIRECTORY"
01486 " to point to config directory and HK_SHCIDS_FILE"
01487 " environment variable to point to the correct file name\n");
01488 return NULL;
01489 }
01490 top_ptr_shcids_vn = NULL;
01491 while( fgets(line, MAXLINE_IN_FILE, file_ptr) != NULL )
01492 {
01493 if(line[0] == '#')
01494 continue;
01495 else
01496 {
01497 if (top_ptr_shcids_vn == NULL)
01498 {
01499 top_ptr_shcids_vn = ptr_shcids_vn = malloc(sizeof(SHCIDS_Version_Number));
01500 ptr_shcids_vn->next = (SHCIDS_Version_Number*)NULL;
01501 }
01502 else
01503 {
01504 ptr_shcids_vn->next = malloc(sizeof(SHCIDS_Version_Number));
01505 ptr_shcids_vn = ptr_shcids_vn->next;
01506 ptr_shcids_vn->next = (SHCIDS_Version_Number*)NULL;
01507 }
01508 ptr_shcids_vn->next= NULL;
01509
01510
01511
01512 sscanf( line,
01513 "%s %s |%d |%s | %*s",
01514 ptr_shcids_vn->change_date,
01515 ptr_shcids_vn->change_time,
01516 &ptr_shcids_vn->apid,
01517 ptr_shcids_vn->file_version_number);
01518
01519
01520 for(int i=0; i < 9; new_str[i++]='\0');
01521 strncpy(new_str,ptr_shcids_vn->change_date,4);
01522 strncat(new_str,&ptr_shcids_vn->change_date[5],2);
01523 strncat(new_str,&ptr_shcids_vn->change_date[8],2);
01524 sscanf(new_str,"%d",&ptr_shcids_vn->date);
01525 }
01526 }
01527 fclose(file_ptr);
01528 global_shcids_vn = top_ptr_shcids_vn;
01529 return(top_ptr_shcids_vn);
01530 }
01531
01532
01533
01534
01535
01536
01537
01538 char * find_fvn_from_shcids(SHCIDS_Version_Number *top, char p_date[MAX_SIZE_PKT_DATE], int apid)
01539 {
01540
01541 SHCIDS_Version_Number *tmp_ptr;
01542 char new_str[9];
01543 char *saved_fvn;
01544 char saved_fvn_str[50];
01545 int current_date;
01546 int pkt_date;
01547 int saved_date;
01548 int saved_flg=0;
01549 saved_fvn=saved_fvn_str;
01550
01551
01552 for(int i=0; i < 9; new_str[i++]='\0');
01553 strncpy(new_str,p_date,4);
01554 strncat(new_str,&p_date[5],2);
01555 strncat(new_str,&p_date[8],2);
01556 sscanf(new_str,"%d",&pkt_date);
01557
01558
01559 for(tmp_ptr=top;tmp_ptr;tmp_ptr=tmp_ptr->next)
01560 {
01561 if(pkt_date >= tmp_ptr->date && tmp_ptr->apid == apid)
01562 {
01563 if(saved_flg)
01564 {
01565 current_date=tmp_ptr->date;
01566 if(current_date >= saved_date)
01567 {
01568
01569 saved_date=current_date;
01570 saved_fvn=tmp_ptr->file_version_number;
01571 }
01572 }
01573 else
01574 {
01575
01576 saved_date=tmp_ptr->date;
01577 saved_fvn=tmp_ptr->file_version_number;
01578 saved_flg=1;
01579 }
01580 }
01581 }
01582 if(saved_flg)
01583 {
01584 return ((char*)saved_fvn);
01585 }
01586 else
01587 {
01588
01589 strcpy(saved_fvn,"BAD PKT DATE");
01590 printkerr("ERROR at %s, line %d: Could not find date in shcids.txt file "
01591 "to look up file version to reference for config files. "
01592 "Problem Packet Date used was:<%s>. Probably bad data for timecodes\n",
01593 __FILE__,__LINE__,new_str);
01594 return ((char*)saved_fvn);
01595 }
01596 }
01597
01598
01599
01600
01601
01602 int check_for_sdo_apid(int apid)
01603 {
01604
01605
01606
01607
01608 return(0);
01609
01610 if ((apid >= 96) && (apid <= 399))
01611 {
01612 return (1);
01613 }
01614 else
01615 {
01616 return (0);
01617 }
01618
01619 }
01620