| | 1 | [wiki:WikiStart Orbit] > [wiki:OTG OTG] > [wiki:OTG/ScriptsRepository Scripts Repository] > otg.rb |
| | 2 | |
| | 3 | {{{ |
| | 4 | |
| | 5 | # |
| | 6 | # Create an application representation from scratch |
| | 7 | # |
| | 8 | require 'handler/appDefinition' |
| | 9 | |
| | 10 | a = AppDefinition.create('test:app:athstats') |
| | 11 | a.name = "athstats" |
| | 12 | a.version(0, 0, 1) |
| | 13 | a.shortDescription = "Application to gather madwifi driver statistics" |
| | 14 | a.description = <<TEXT |
| | 15 | This C application gathers driver statistics and reports them. |
| | 16 | TEXT |
| | 17 | |
| | 18 | # addProperty(name, description, mnemonic, type, isDynamic = false, constraints = nil) |
| | 19 | a.addProperty('interface', 'Use ath0/ath1, ath0 by default', nil, String, false) |
| | 20 | a.addProperty('interval', 'Number of msec between calls to query driver', nil, String, false) |
| | 21 | |
| | 22 | a.addMeasurement("queryport", nil, [ |
| | 23 | ['succ_tx_attempts','int'], |
| | 24 | ['fail_xretries','int'], |
| | 25 | ['total_frames_rcvd','int'] |
| | 26 | ]) |
| | 27 | a.path = "/usr/bin/athstats-oml" |
| | 28 | |
| | 29 | if $0 == __FILE__ |
| | 30 | require 'stringio' |
| | 31 | require 'rexml/document' |
| | 32 | include REXML |
| | 33 | |
| | 34 | sio = StringIO.new() |
| | 35 | a.to_xml.write(sio, 2) |
| | 36 | sio.rewind |
| | 37 | puts sio.read |
| | 38 | |
| | 39 | sio.rewind |
| | 40 | doc = Document.new(sio) |
| | 41 | t = AppDefinition.from_xml(doc.root) |
| | 42 | |
| | 43 | puts |
| | 44 | puts "-------------------------" |
| | 45 | puts |
| | 46 | t.to_xml.write($stdout, 2) |
| | 47 | |
| | 48 | end |
| | 49 | |
| | 50 | |
| | 51 | }}} |