Changeset 5000
- Timestamp:
- Sep 12, 2005, 11:36:54 AM (21 years ago)
- Location:
- trunk/psLib
- Files:
-
- 7 edited
-
src/types/psMetadata.c (modified) (3 diffs)
-
src/types/psMetadata.h (modified) (4 diffs)
-
src/xml/psXML.c (modified) (8 diffs)
-
src/xml/psXML.h (modified) (2 diffs)
-
test/xml/psTime.xml (modified) (1 diff)
-
test/xml/tst_psXML.c (modified) (3 diffs)
-
test/xml/verified/tst_psXML.stdout (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/types/psMetadata.c
r4985 r5000 12 12 * @author Ross Harman, MHPCC 13 13 * 14 * @version $Revision: 1.8 1$ $Name: not supported by cvs2svn $15 * @date $Date: 2005-09-1 0 00:16:59$14 * @version $Revision: 1.82 $ $Name: not supported by cvs2svn $ 15 * @date $Date: 2005-09-12 21:36:54 $ 16 16 * 17 17 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 247 247 case PS_META_MULTI: 248 248 case PS_META_ARRAY: 249 case PS_META_TIME: 249 250 // Copy of input data not performed due to variability of data types 250 251 metadataItem->data.V = psMemIncrRefCounter(va_arg(argPtr, psPtr)); … … 440 441 METADATA_ADD_TYPE(Metadata,psMetadata*,PS_META_META) 441 442 METADATA_ADD_TYPE(Array,psArray*,PS_META_ARRAY) 443 METADATA_ADD_TYPE(Time,psTime*,PS_META_TIME) 442 444 443 445 bool psMetadataRemove(psMetadata *md, -
trunk/psLib/src/types/psMetadata.h
r4920 r5000 11 11 * @author Ross Harman, MHPCC 12 12 * 13 * @version $Revision: 1.6 1$ $Name: not supported by cvs2svn $14 * @date $Date: 2005-0 8-31 02:07:12$13 * @version $Revision: 1.62 $ $Name: not supported by cvs2svn $ 14 * @date $Date: 2005-09-12 21:36:54 $ 15 15 * 16 16 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 26 26 #include "psHash.h" 27 27 #include "psList.h" 28 #include "ps Image.h"28 #include "psTime.h" 29 29 #include "psLookupTable.h" 30 30 … … 53 53 PS_META_MULTI, ///< Used internally, do not create an metadata item of this type. 54 54 PS_META_META, ///< Metadata data (Stored as item.data.md). 55 PS_META_ARRAY ///< Array data (Stored as item.data.V). 55 PS_META_ARRAY, ///< Array data (Stored as item.data.V). 56 PS_META_TIME ///< psTime data (Stored as item.data.V). 56 57 } psMetadataType; 57 58 #define PS_META_IS_PRIMITIVE(TYPE) \ … … 440 441 ); 441 442 443 /** Add a Time to metadata collection. 444 * 445 * @return psBool: True for success, False for failure. 446 */ 447 psBool psMetadataAddTime( 448 psMetadata* md, ///< Metadata collection to insert metadata item 449 long location, ///< Index number, PS_LIST_HEAD, or PS_LIST_TAIL 450 const char* name, ///< Name of metadata item 451 int format, ///< psMetadataFlag options/flags 452 const char* comment, ///< Comment for metadata item 453 psTime* value ///< Time for metadata item data 454 ); 455 442 456 /** Add a Hash to metadata collection. 443 457 * -
trunk/psLib/src/xml/psXML.c
r4891 r5000 10 10 * @author David Robbins, MHPCC 11 11 * 12 * @version $Revision: 1.3 8$ $Name: not supported by cvs2svn $13 * @date $Date: 2005-0 8-27 01:33:41$12 * @version $Revision: 1.39 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2005-09-12 21:36:54 $ 14 14 * 15 15 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 54 54 char content[MAXSTR]; 55 55 char vec[MAXVEC]; 56 char timeVal[MAXSTR]; 56 57 int i; 57 58 psMetadataIterator *iter = psMetadataIteratorAlloc(*(psMetadata**)&md, PS_LIST_HEAD, NULL); … … 73 74 if ( type == 65547) 74 75 type = PS_DATA_METADATA; 76 if ( type == 65549) 77 type = PS_DATA_TIME; 75 78 switch (type) { 76 79 case PS_DATA_BOOL: … … 123 126 new_node = xmlAddSibling(cur_node, new_root); 124 127 psFree(newDoc); 128 break; 129 case PS_DATA_TIME: 130 cur_node = xmlNewChild(root, NULL, (const xmlChar*)"time", (const xmlChar*)"\n"); 131 prop = xmlNewProp(cur_node, (const xmlChar*)"name", (const xmlChar*)item->name); 132 if ( ((psTime*)(item->data.V))->type == PS_TIME_UTC ) 133 prop = xmlNewProp(cur_node, (const xmlChar*)"psType", (const xmlChar*)"PS_TIME_UTC"); 134 else if ( ((psTime*)(item->data.V))->type == PS_TIME_TAI ) 135 prop = xmlNewProp(cur_node, (const xmlChar*)"psType", (const xmlChar*)"PS_TIME_TAI"); 136 else if ( ((psTime*)(item->data.V))->type == PS_TIME_UT1 ) 137 prop = xmlNewProp(cur_node, (const xmlChar*)"psType", (const xmlChar*)"PS_TIME_UT1"); 138 else if ( ((psTime*)(item->data.V))->type == PS_TIME_TT ) 139 prop = xmlNewProp(cur_node, (const xmlChar*)"psType", (const xmlChar*)"PS_TIME_TT"); 140 else { 141 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 142 PS_ERRORTEXT_psXML_INVALID_CONTENT); 143 return NULL; 144 } 145 snprintf(content, MAXSTR, "%ld, ", ((psTime*)(item->data.V))->sec); 146 strncpy(timeVal, content, MAXSTR); 147 snprintf(content, MAXSTR, "%u, ", ((psTime*)(item->data.V))->nsec); 148 strncat(timeVal, content, MAXSTR); 149 if ( ((psTime*)(item->data.V))->leapsecond ) 150 strncat(timeVal, "T", MAXSTR); 151 else 152 strncat(timeVal, "F", MAXSTR); 153 prop = xmlNewProp(cur_node, (const xmlChar*)"value", (const xmlChar*)timeVal); 125 154 break; 126 155 case PS_DATA_VECTOR: … … 140 169 strncat(vec, content, MAXSTR); 141 170 } 142 143 171 break; 144 172 case PS_DATA_F32: … … 266 294 } 267 295 296 static void storeTime(psTime *out, char *in) 297 { 298 char *endp; 299 long sec = 0; 300 unsigned int nsec = 0; 301 302 sec = strtol(in, &endp, 10); 303 out->sec = sec; 304 if ( !strncmp(endp, ",", 1) ) 305 endp++; 306 else 307 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 308 PS_ERRORTEXT_psXML_INVALID_CONTENT); 309 in = endp; 310 nsec = (unsigned int)strtol(in, &endp, 10); 311 out->nsec = nsec; 312 if ( !strncmp(endp, ",", 1) ) 313 endp++; 314 else 315 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 316 PS_ERRORTEXT_psXML_INVALID_CONTENT); 317 in = endp; 318 if ( !strncmp(in, "false", 10) || !strncmp(in, "f", 10) || 319 !strncmp(in, "FALSE", 10) || !strncmp(in, " F", 10) ) 320 out->leapsecond = false; 321 else if ( !strncmp(in, "true", 10) || !strncmp(in, "t", 10) || 322 !strncmp(in, "TRUE", 10) || !strncmp(in, "T", 10) ) 323 out->leapsecond = true; 324 else { 325 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 326 PS_ERRORTEXT_psXML_INVALID_CONTENT); 327 } 328 } 329 268 330 //Check the xml item for errors. Returns the data type or PS_DATA_UNKNOWN for errors.// 269 331 static psDataType chkType(xmlNode *node) … … 309 371 } 310 372 } 373 if(!strncmp((const char*)node->name, "time", MAXSTR) || !strncmp((const char*)node->name, "TIME", MAXSTR) ) { 374 if (node->properties != NULL && node->properties->name 375 && node->properties->next != NULL && node->properties->next->name != NULL) { 376 return(PS_DATA_TIME); 377 } else { 378 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 379 PS_ERRORTEXT_psXML_INVALID_CONTENT); 380 return(PS_DATA_UNKNOWN); 381 } 382 } 311 383 return(PS_DATA_UNKNOWN); 312 384 } … … 385 457 psFree(vec); 386 458 break; 459 case PS_DATA_TIME: 460 strncpy(name, (const char*)cur_node->properties->children->content, MAXSTR); 461 strncpy(content, 462 (const char*)cur_node->properties->next->next->children->content, MAXSTR); 463 psTimeType timeType; 464 char type[MAXSTR]; 465 strncpy(type, (const char*)cur_node->properties->next->children->content, MAXSTR); 466 if ( !strncmp(type, "PS_TIME_UTC", MAXSTR) ) 467 timeType = PS_TIME_UTC; 468 else if ( !strncmp(type, "PS_TIME_TAI", MAXSTR) ) 469 timeType = PS_TIME_TAI; 470 else if ( !strncmp(type, "PS_TIME_UT1", MAXSTR) ) 471 timeType = PS_TIME_UT1; 472 else if ( !strncmp(type, "PS_TIME_TT", MAXSTR) ) 473 timeType = PS_TIME_TT; 474 else { 475 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 476 PS_ERRORTEXT_psXML_INVALID_CONTENT); 477 psFree(meta); 478 return NULL; 479 } 480 481 psTime *time; 482 time = psTimeAlloc(timeType); 483 storeTime(time, content); 484 psMetadataAddTime(meta, PS_LIST_TAIL, name, 0, "", time); 485 psFree(time); 486 break; 387 487 case PS_DATA_METADATA: 388 488 strncpy(name, (const char*)cur_node->properties->children->content, MAXSTR); 389 // psMetadata *temp = psMetadataAlloc();390 489 psMetadata *temp = NULL; 391 490 temp = xml2metadata(cur_node->children, nodeNum); -
trunk/psLib/src/xml/psXML.h
r4815 r5000 10 10 * @author David Robbins, MHPCC 11 11 * 12 * @version $Revision: 1.1 8$ $Name: not supported by cvs2svn $13 * @date $Date: 2005-0 8-18 21:44:40$12 * @version $Revision: 1.19 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2005-09-12 21:36:54 $ 14 14 * 15 15 * Copyright 2005 Maui High Performance Computing Center, University of Hawaii … … 31 31 #include "psString.h" 32 32 #include "psConstants.h" 33 #include "psTime.h" 33 34 #include "psErrorText.h" 34 35 -
trunk/psLib/test/xml/psTime.xml
r4785 r5000 12 12 <item name = "psLib.time.BOOL.value3" psType = "BOOL" value = "t" /> 13 13 <item name = "psLib.time.BOOL.value4" psType = "BOOL" value = "F" /> 14 <time name = "psLib.TIME.Magazine" psType = "PS_TIME_UTC" value = "1000, 25, F" /> 14 15 <vector name = "psLib.time.Vector.S32" psType = "S32" value = "-4, -2, 506"/> 15 16 <vector name = "psLib.time.Vector.F32" psType = "F32" value = "-0.4944, -0.00023, 53262.0"/> -
trunk/psLib/test/xml/tst_psXML.c
r4822 r5000 15 15 * @author Dave Robbins, MHPCC 16 16 * 17 * @version $Revision: 1. 3$ $Name: not supported by cvs2svn $18 * @date $Date: 2005-0 8-20 01:49:03$17 * @version $Revision: 1.4 $ $Name: not supported by cvs2svn $ 18 * @date $Date: 2005-09-12 21:36:54 $ 19 19 * 20 20 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 121 121 printf("Key Type: F64 Key Value: %15.3f ", metadataItem->data.F64); 122 122 break; 123 case PS_ DATA_METADATA:123 case PS_META_META: 124 124 printf("Key Type: METADATA "); 125 125 break; … … 138 138 printf("%s", (char*)metadataItem->data.V ); 139 139 printf("\n"); 140 } else if ( !strncmp(metadataItem->name, "psLib.TIME.Magazine", 256) ) { 141 printf("Key Value: "); 142 printf("%ld, ", ((psTime*)(metadataItem->data.V))->sec ); 143 printf("%u, ", ((psTime*)(metadataItem->data.V))->nsec ); 144 if( ((psTime*)(metadataItem->data.V))->leapsecond ) 145 printf("TRUE "); 146 else 147 printf("FALSE "); 148 if( ((psTime*)(metadataItem->data.V))->type == PS_TIME_UTC ) 149 printf("PS_TIME_UTC "); 150 else if( ((psTime*)(metadataItem->data.V))->type == PS_TIME_TAI ) 151 printf("PS_TIME_TAI "); 152 else if( ((psTime*)(metadataItem->data.V))->type == PS_TIME_UT1 ) 153 printf("PS_TIME_UT1 "); 154 else if( ((psTime*)(metadataItem->data.V))->type == PS_TIME_TT ) 155 printf("PS_TIME_TT "); 156 printf("\n"); 140 157 } else 141 158 printf("Key Comment: %s\n", metadataItem->comment); -
trunk/psLib/test/xml/verified/tst_psXML.stdout
r4791 r5000 7 7 Key Name: psLib.time.BOOL.value3 Key Type: BOOL Key Value: 1 Key Comment: 8 8 Key Name: psLib.time.BOOL.value4 Key Type: BOOL Key Value: 0 Key Comment: 9 Key Name: psLib.TIME.Magazine Key type: psPtr Key Value: 1000, 25, FALSE PS_TIME_UTC 9 10 Key Name: psLib.time.Vector.S32 Key type: psPtr Key Values: -4 -2 506 10 11 Key Name: psLib.time.Vector.F32 Key type: psPtr Key Comment: 11 12 Key Name: psLib.time.Vector.F64 Key type: psPtr Key Comment: 12 Key Name: cell Key type: psPtrKey Comment:13 Key Name: cell Key Type: METADATA Key Comment: 13 14 Key Name: psLib.time.tables.dir Key type: psPtr Key Value: ../../data 14 15 … … 16 17 Key Name: psLib.time.BOOL.value4 Key Type: BOOL Key Value: 0 Key Comment: 17 18 Key Name: psLib.time.F32.value Key Type: F32 Key Value: 50324.422 Key Comment: 18 Key Name: cell Key type: psPtrKey Comment:19 Key Name: cell Key Type: METADATA Key Comment: 19 20 Key Name: psLib.time.Vector.F64 Key type: psPtr Key Comment: 21 Key Name: psLib.TIME.Magazine Key type: psPtr Key Value: 1000, 25, FALSE PS_TIME_UTC 20 22 Key Name: psLib.time.F64.value Key Type: F64 Key Value: 80112.490 Key Comment: 21 23 Key Name: psLib.time.Vector.S32 Key type: psPtr Key Values: -4 -2 506
Note:
See TracChangeset
for help on using the changeset viewer.
