Changes between Version 18 and Version 19 of rappture_perl_api
- Timestamp:
- Jun 24, 2010 9:48:44 AM (14 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
rappture_perl_api
v18 v19 11 11 12 12 13 ''' RpLibrary''' Class13 '''!RpLibrary''' Class 14 14 15 15 This module provides an interface to Rappture I/O (!RpLibrary) library. … … 18 18 __'''Constructor'''__ [[BR]] 19 19 20 ''$library'' = '''Rappture::RpLibrary (''' ''$path'' ''')''' [[BR]]20 ''$library'' = '''Rappture::RpLibrary->new(''' ''$path'' ''')''' [[BR]] 21 21 22 22 __'''Methods'''__ [[BR]] … … 24 24 ''$library''->'''get(''' ''$path'' ''')''' [[BR]] 25 25 ''$library''->'''put(''' ''$path'', ''$value'', ''$append'' ''')''' [[BR]] 26 ''$library''->'''putFile(''' ''$path'', ''$fileName'', ''$compress'', ''$append'' 26 27 ''$library''->'''result( )''' [[BR]] 27 28 28 '''R pUnits''' Class [[BR]]29 '''Rappture::RpUnits''' Class [[BR]] 29 30 30 31 This module provides an interface to Rappture Units (!RpUnits) library. … … 32 33 __'''Static Methods'''__ [[BR]] 33 34 34 ''' !RpUnits::convert(''' ''$fromVal'', ''$to'', ''$units'' ''')'''35 36 '''R pUtils''' Module [[BR]]35 '''Rappture::RpUnits::convert(''' ''$fromVal'', ''$to'', ''$showUnits'' ''')''' 36 37 '''Rappture::Utils''' Module [[BR]] 37 38 38 39 This module provides an interface to Rappture Utils Module. … … 49 50 50 51 51 '''Rappture::RpLibrary ''' (''$path'') [[BR]]52 '''Rappture::RpLibrary->new''' (''$path'') [[BR]] 52 53 53 54 Purpose:[[BR]] … … 61 62 62 63 {{{ 64 # Contents of driver.xml 65 # <run> 66 # <input> 67 # <number id="Ef"> 68 # <units>eV</units> 69 # <min>-10eV</min> 70 # <max>10eV</max> 71 # <default>0eV</default> 72 # <current>3eV</current> 73 # </number> 74 # </input> 75 # </run> 76 77 use Rappture; 78 79 my $lib = Rappture::RpLibrary->new("driver.xml"); 80 81 if (not defined $lib) { 82 print "creation of library successful\n"; 83 } else { 84 print "creation of library failed\n"; 85 } 86 87 print "lib = $lib"; 88 # $lib->delete; 89 90 # Result: 91 # creation of library successful 92 # lib = Rappture::RpLibrary=SCALAR(0x1bd9060) 63 93 }}} 64 94 … … 66 96 67 97 Purpose:[[BR]] 68 .[[BR]]98 Retrieves the data held at location ''$path'' from the rappture object.[[BR]] 69 99 70 100 Input Arguments: [[BR]] … … 72 102 73 103 Return Value: [[BR]] 74 . [[BR]] 75 76 77 {{{ 104 String representation of the data at ''path'' within the rappture object.[[BR]] 105 106 107 {{{ 108 # Contents of driver.xml 109 # <run> 110 # <input> 111 # <number id="Ef"> 112 # <units>eV</units> 113 # <min>-10eV</min> 114 # <max>10eV</max> 115 # <default>0eV</default> 116 # <current>3eV</current> 117 # </number> 118 # </input> 119 # </run> 120 121 use Rappture; 122 123 my $lib = Rappture::RpLibrary->new("driver.xml"); 124 125 my $Ef = $lib->get("input.number(Ef).current"); 126 127 print "Ef = $Ef"; 128 129 # Result: 130 # Ef = 3eV 78 131 }}} 79 132 … … 81 134 82 135 Purpose:[[BR]] 83 .[[BR]] 84 85 Input Arguments: [[BR]] 86 . [[BR]] 87 . [[BR]] 88 89 Return Value: [[BR]] 90 . [[BR]] 91 92 {{{ 93 }}} 136 Place data ''$value'' into this object at the xml location ''$path''. If the ''$append'' flag is set to 1, then ''$value'' will be appended to data that already exists at path. If the ''$append'' flag is set to 0, then ''$value'' will overwrite data that may have existed at path.[[BR]] 137 138 Input Arguments: [[BR]] 139 1. ''$path'' - xml path (location) to store value. 140 2. ''$value'' - data to store in this object. 141 3. ''$append' - overwrite flag (1 or 0). if set to 0, data at ''$path'' will be overwritten. if set to 1, data will be appended. 142 143 Return Value: [[BR]] 144 No value is returned. [[BR]] 145 146 {{{ 147 # Contents of driver.xml 148 # <run> 149 # <input> 150 # <number id="Ef"> 151 # <units>eV</units> 152 # <min>-10eV</min> 153 # <max>10eV</max> 154 # <default>0eV</default> 155 # <current>3eV</current> 156 # </number> 157 # </input> 158 # </run> 159 160 161 use Rappture; 162 163 my $lib = Rappture::RpLibrary->new("driver.xml"); 164 165 print "Overwrite:\n"; 166 $lib->put("input.number(Ef).current", "6", 0); 167 my $Ef = $lib->get("input.number(Ef).current"); 168 print "Ef = $Ef"; 169 170 print "\n"; 171 print "Append:\n"; 172 $lib->put("input.number(Ef).current", "eV", 1); 173 $Ef = $lib->get("input.number(Ef).current"); 174 print "Ef = $Ef"; 175 176 # Result: 177 # 178 # Overwrite: 179 # Ef = 6 180 # 181 # Append: 182 # Ef = 6eV 183 184 }}} 185 186 187 ''instance''->'''putFile(''' ''$path'', ''$fileName'', ''$compress'', ''$append'' ''')''' [[BR]] 188 189 Purpose:[[BR]] 190 Place data from file ''$fileName'' into this object at the xml location ''$path''. If the ''$compress'' flag is set to 1, the data will be gzip compressed and base64 encoded. If the ''$append'' flag is set to 1, then ''$value'' will be appended to data that already exists at path. If the ''$append'' flag is set to 0, then ''$value'' will overwrite data that may have existed at path.[[BR]] 191 192 Input Arguments: [[BR]] 193 1. ''$path'' - xml path (location) to store value. 194 2. ''$fileName'' - name of the file to store in this object. 195 3. ''$compress'' - flag (1 or 0). if set to 1, file data will be gzip compressed and base64 encoded. 196 3. ''$append' - overwrite flag (1 or 0). if set to 0, data at ''$path'' will be overwritten. if set to 1, data will be appended. 197 198 Return Value: [[BR]] 199 No value is returned. [[BR]] 200 201 {{{ 202 # Contents of driver.xml 203 # <run> 204 # <input> 205 # <number id="Ef"> 206 # <units>eV</units> 207 # <min>-10eV</min> 208 # <max>10eV</max> 209 # <default>0eV</default> 210 # <current>3eV</current> 211 # </number> 212 # </input> 213 # </run> 214 # 215 # temp.jpg is a JPEG image file 216 217 use Rappture; 218 219 my $lib = Rappture::RpLibrary->new("driver.xml"); 220 221 $lib->putFile("input.image.current", "temp.jpg", 1, 0); 222 223 }}} 224 94 225 95 226 ''instance''->'''result(''' ''')''' [[BR]] 96 227 97 228 Purpose:[[BR]] 98 .[[BR]] 99 100 Input Arguments: [[BR]] 101 . [[BR]] 102 . [[BR]] 103 104 Return Value: [[BR]] 105 . [[BR]] 106 107 {{{ 108 }}} 109 110 111 '''!RpUnits::convert(''' ''$fromVal'', ''$to'', ''$units'' ''')''' [[BR]] 229 Write the data from the Rappture Library object instance to file and signal the end of processing to the graphical user interface.[[BR]] 230 231 Input Arguments: [[BR]] 232 None [[BR]] 233 234 Return Value: [[BR]] 235 None [[BR]] 236 237 {{{ 238 # Contents of driver.xml 239 # <run> 240 # <input> 241 # <number id="Ef"> 242 # <units>eV</units> 243 # <min>-10eV</min> 244 # <max>10eV</max> 245 # <default>0eV</default> 246 # <current>3eV</current> 247 # </number> 248 # </input> 249 # </run> 250 251 use Rappture; 252 253 my $lib = Rappture::RpLibrary->new("driver.xml"); 254 255 $lib->result(); 256 }}} 257 258 259 '''Rappture::RpUnits::convert(''' ''$fromVal'', ''$to'', ''$showUnits'' ''')''' [[BR]] 112 260 113 261 Purpose:[[BR]] … … 117 265 1. ''$fromVal'' - String with numeric portion and optional units (ie. "3m" or "3"). [[BR]] 118 266 2. ''$to'' - String name of the units you want to convert to. [[BR]] 119 3. ''$ units'' - String "1" or "0" to tell if you want units to show up in the result.120 121 Return Value: [[BR]] 122 Return converted value as a string. Return undef on failure. ''$ units'' are set to on ("1") by default.[[BR]]267 3. ''$showUnits'' - String "1" or "0" to tell if you want units to show up in the result. 268 269 Return Value: [[BR]] 270 Return converted value as a string. Return undef on failure. ''$showUnits'' are set to on ("1") by default.[[BR]] 123 271 124 272 Notes: [[BR]] 125 1.. [[BR]]273 None. [[BR]] 126 274 127 275 {{{ … … 134 282 # result is "80.329999999999998" 135 283 136 $result = Rappture: RpUnits::convert( "3cm", "A" )284 $result = Rappture::RpUnits::convert( "3cm", "A" ) 137 285 # result is "3e+08A" 138 286 139 $result = Rappture::RpUnits .convert( "3", "m" )287 $result = Rappture::RpUnits::convert( "3", "m" ) 140 288 # result is "3m" 141 289 … … 145 293 }}} 146 294 295 '''Rappture::Utils::progress(''' ''$value'', ''$message'' ''')''' [[BR]] 296 297 Purpose:[[BR]] 298 Print a progress percentage and message on the screen during simulation. [[BR]] 299 300 Input Arguments: [[BR]] 301 1. ''$value'' - Percentage to display. Value between 0 and 100. [[BR]] 302 2. ''$message'' - Comment associated with ''$value''. [[BR]] 303 304 Return Value: [[BR]] 305 None. [[BR]] 306 307 Notes: [[BR]] 308 None. [[BR]] 309 310 {{{ 311 use Rappture; 312 313 Rappture::Utils::progress(45,"Iterating..."); 314 }}}