Changeset 1427
- Timestamp:
- Apr 29, 2009 10:02:27 AM (15 years ago)
- Location:
- trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lang/python/Rappture/PyRpUnits.cc
r1368 r1427 423 423 424 424 static char *kwlist[] = { 425 (char *)"fromVal", 426 (char *)"to", 427 (char *)"units", 428 425 (char *)"fromVal", 426 (char *)"to", 427 (char *)"units", 428 NULL 429 429 }; 430 430 … … 433 433 if (!PyArg_ParseTupleAndKeywords(args, keywds, "ss|s", 434 434 kwlist, &fromVal, &to, &units)) { 435 return NULL; 435 return NULL; 436 436 } 437 437 } -
trunk/lang/tcl/tests/units.test
r1157 r1427 884 884 885 885 #-------------------------------------------------------------------- 886 # Magnetic Field Conversions 887 #-------------------------------------------------------------------- 888 889 test convert_units-5.4.11.0 {Rappture::Units::convert, T->G} { 890 list [catch {Rappture::Units::convert 5T -to G} msg] $msg 891 } {0 50000G} 892 893 test convert_units-5.4.11.1 {Rappture::Units::convert, G->T} { 894 list [catch {Rappture::Units::convert 5G -to T} msg] $msg 895 } {0 0.0005T} 896 897 test convert_units-5.4.11.2 {Rappture::Units::convert, G->mT} { 898 list [catch {Rappture::Units::convert 50G -to mT} msg] $msg 899 } {0 5mT} 900 901 test convert_units-5.4.11.3 {Rappture::Units::convert, Mx->Wb} { 902 list [catch {Rappture::Units::convert 5Mx -to Wb} msg] $msg 903 } {0 5e-08Wb} 904 905 test convert_units-5.4.11.4 {Rappture::Units::convert, Wb->Mx} { 906 list [catch {Rappture::Units::convert 5e-8Wb -to Mx} msg] $msg 907 } {0 5Mx} 908 909 test convert_units-5.4.11.5 {Rappture::Units::convert, wB->mX} { 910 list [catch {Rappture::Units::convert 5e-8wB -to mX} msg] $msg 911 } {0 5Mx} 912 913 #-------------------------------------------------------------------- 886 914 # Rappture::Units::Search::for <units> 887 915 #-------------------------------------------------------------------- -
trunk/src/core/RpUnits.cc
r1006 r1427 2389 2389 retVal = RpUnitsPreset::addPresetForce(); 2390 2390 } 2391 else if (group.compare(RP_TYPE_MAGNETIC) == 0) { 2392 retVal = RpUnitsPreset::addPresetMagnetic(); 2393 } 2391 2394 else if (group.compare(RP_TYPE_MISC) == 0) { 2392 2395 retVal = RpUnitsPreset::addPresetMisc(); … … 2421 2424 result += addPresetConcentration(); 2422 2425 result += addPresetForce(); 2426 result += addPresetMagnetic(); 2423 2427 result += addPresetMisc(); 2424 2428 … … 2880 2884 2881 2885 /**********************************************************************/ 2886 // METHOD: addPresetMagnetic() 2887 /// Add concentration related units to the dictionary 2888 /** 2889 * 2890 * http://en.wikipedia.org/wiki/Tesla_(unit) 2891 * http://en.wikipedia.org/wiki/Gauss_(unit) 2892 * http://en.wikipedia.org/wiki/Maxwell_(unit) 2893 * http://en.wikipedia.org/wiki/Weber_(unit) 2894 * 2895 * Defines the following units: 2896 * tesla (T) 2897 * gauss (G) 2898 * maxwell (Mx) 2899 * weber (Wb) 2900 * 2901 * Return codes: 0 success, anything else is error 2902 */ 2903 2904 int 2905 RpUnitsPreset::addPresetMagnetic () { 2906 2907 RpUnits* tesla = NULL; 2908 RpUnits* gauss = NULL; 2909 RpUnits* maxwell = NULL; 2910 RpUnits* weber = NULL; 2911 2912 tesla = RpUnits::define("T", NULL, RP_TYPE_MAGNETIC, RPUNITS_METRIC); 2913 gauss = RpUnits::define("G", NULL, RP_TYPE_MAGNETIC); 2914 maxwell = RpUnits::define("Mx", NULL, RP_TYPE_MAGNETIC); 2915 weber = RpUnits::define("Wb", NULL, RP_TYPE_MAGNETIC, RPUNITS_METRIC); 2916 2917 RpUnits::define(tesla,gauss,tesla2gauss,gauss2tesla); 2918 RpUnits::define(maxwell,weber,maxwell2weber,weber2maxwell); 2919 2920 return 0; 2921 } 2922 2923 /**********************************************************************/ 2882 2924 // METHOD: addPresetMisc() 2883 2925 /// Add Misc related units to the dictionary … … 2947 2989 return &RpUnitsTypes::hintTypeConc; 2948 2990 } 2949 else if (type.compare(RP_TYPE_ CONC) == 0) {2991 else if (type.compare(RP_TYPE_FORCE) == 0) { 2950 2992 return &RpUnitsTypes::hintTypeForce; 2993 } 2994 else if (type.compare(RP_TYPE_MAGNETIC) == 0) { 2995 return &RpUnitsTypes::hintTypeMagnetic; 2951 2996 } 2952 2997 else if (type.compare(RP_TYPE_MISC) == 0) { … … 3108 3153 3109 3154 if ( (unitObj->getType()).compare(RP_TYPE_FORCE) == 0 ) { 3155 retVal = true; 3156 } 3157 3158 return retVal; 3159 } 3160 3161 bool 3162 RpUnitsTypes::hintTypeMagnetic ( RpUnits* unitObj ) { 3163 3164 bool retVal = false; 3165 3166 if ( (unitObj->getType()).compare(RP_TYPE_MAGNETIC) == 0 ) { 3110 3167 retVal = true; 3111 3168 } -
trunk/src/core/RpUnits.h
r709 r1427 46 46 #define RP_TYPE_CONC "concentration" 47 47 #define RP_TYPE_FORCE "force" 48 #define RP_TYPE_MAGNETIC "magnetic" 48 49 #define RP_TYPE_MISC "misc" 49 50 … … 84 85 static int addPresetConcentration(); 85 86 static int addPresetForce(); 87 static int addPresetMagnetic(); 86 88 static int addPresetMisc(); 87 89 }; … … 106 108 static bool hintTypeConc ( RpUnits* unitObj ); 107 109 static bool hintTypeForce ( RpUnits* unitObj ); 110 static bool hintTypeMagnetic ( RpUnits* unitObj ); 108 111 static bool hintTypeMisc ( RpUnits* unitObj ); 109 112 … … 515 518 // RP_TYPE_CONC "concentration" load units related to concentration 516 519 // RP_TYPE_FORCE "force" load units related to force 520 // RP_TYPE_MAGNETIC "magnetic" load units related to magnetics 517 521 // RP_TYPE_MISC "misc" load units related to everything else 518 522 // (no other groups have been created) -
trunk/src/core/RpUnitsStd.cc
r1018 r1427 567 567 } 568 568 569 /**************************************** 570 * MAGNETIC CONVERSIONS 571 * http://en.wikipedia.org/wiki/Tesla_(unit) 572 * http://en.wikipedia.org/wiki/Gauss_(unit) 573 * http://en.wikipedia.org/wiki/Maxwell_(unit) 574 * http://en.wikipedia.org/wiki/Weber_(unit) 575 ****************************************/ 576 577 double tesla2gauss (double tesla) 578 { 579 return (tesla*1e4); 580 } 581 582 double gauss2tesla (double gauss) 583 { 584 return (gauss*1e-4); 585 } 586 587 double maxwell2weber (double maxwell) 588 { 589 return (maxwell*1e-8); 590 } 591 592 double weber2maxwell (double weber) 593 { 594 return (weber*1e8); 595 } 596 -
trunk/src/core/RpUnitsStd.h
r999 r1427 146 146 double pOH2pH (double pOH); 147 147 148 149 150 double tesla2gauss (double tesla); 151 double gauss2tesla (double gauss); 152 double maxwell2weber (double maxwell); 153 double weber2maxwell (double weber); 154 148 155 #ifdef __cplusplus 149 156 }
Note: See TracChangeset
for help on using the changeset viewer.