Top Level Namespace
Defined Under Namespace
Modules: DmmUtil
Instance Method Summary collapse
- #do_info ⇒ Object
- #do_measure_now ⇒ Object
- #do_recordings ⇒ Object
- #do_saved_measurements(type = :saved_measurements) ⇒ Object
- #do_set(property, value) ⇒ Object
- #do_sync_time ⇒ Object
- #parse_int_if(val) ⇒ Object
- #usage ⇒ Object
Instance Method Details
#do_info ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'bin/dmm_util', line 24 def do_info meter = DmmUtil.open info = meter.driver.id puts "Model: #{info[:model_number]}" puts "Software Version: #{info[:software_version]}" puts "Serial Number: #{info[:serial_number]}" puts "Current meter time: #{meter.driver.clock}" [:company, :contact, :operator, :site].each do |prop| val = meter.driver.send(prop) puts "#{prop.to_s.capitalize}: #{val}" unless val == "" end end |
#do_measure_now ⇒ Object
96 97 98 99 100 |
# File 'bin/dmm_util', line 96 def do_measure_now meter = DmmUtil.open measurement = meter.measure_now puts "NOW: #{measurement.to_s}" end |
#do_recordings ⇒ Object
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'bin/dmm_util', line 70 def do_recordings meter = DmmUtil.open if ARGV.size == 1 # List all recordings meter.recordings.each do |recording| puts "#{recording.name} [#{recording.start_ts} - #{recording.end_ts}] : #{recording.num_samples} measurements" end else ARGV[1..-1].each do |idx| idx = parse_int_if(idx) if idx.is_a?(String) recording = meter.recordings.find{|r| r.name == idx} else recording = meter.recordings[idx] end raise "Recording '#{idx}' not found" unless recording puts "#{recording.name} (detail) [#{recording.start_ts} - #{recording.end_ts}] : #{recording.num_samples} measurements" recording.measurements.each do |measurement| puts "#{measurement.start_ts} : #{measurement.to_s}" end end end end |
#do_saved_measurements(type = :saved_measurements) ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'bin/dmm_util', line 49 def do_saved_measurements(type = :saved_measurements) meter = DmmUtil.open measurements = meter.send(type) if ARGV.size == 1 measurements.each do |measurement| puts "#{measurement.name} [#{measurement.ts}] : #{measurement.to_s}" end else ARGV[1..-1].each do |idx| idx = parse_int_if(idx) if idx.is_a?(String) measurement = measurements.find{|r| r.name == idx} else measurement = measurements[idx] end raise "Measurement '#{idx}' not found" unless measurement puts "#{measurement.name} [#{measurement.ts}] : #{measurement.to_s}" end end end |
#do_set(property, value) ⇒ Object
37 38 39 40 41 |
# File 'bin/dmm_util', line 37 def do_set(property, value) meter = DmmUtil.open meter.driver.send(:"#{property}=", value) puts "Sucsessfully set #{property} value" end |
#do_sync_time ⇒ Object
43 44 45 46 47 |
# File 'bin/dmm_util', line 43 def do_sync_time meter = DmmUtil.open meter.driver.clock = Time.now puts "Sucsessfully synced the clock of the DMM" end |
#parse_int_if(val) ⇒ Object
18 19 20 21 22 |
# File 'bin/dmm_util', line 18 def parse_int_if(val) return Integer(val) rescue ArgumentError return val end |
#usage ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'bin/dmm_util', line 5 def usage $stderr.write "Usage: dmm_util info : Display info about the meter\n" $stderr.write " dmm_util recordings [index|name] ... : Display one or all recordings\n" $stderr.write " dmm_util saved_measurements [index|name] : Display one or all saved measurements\n" $stderr.write " dmm_util saved_min_max [index|name] : Display one or all saved min max measurements\n" $stderr.write " dmm_util saved_peak [index|name] : Display one or all saved peak measurements\n" $stderr.write " dmm_util measure_now : Display the current meter value\n" $stderr.write " dmm_util set <company|contact|operator|site> <value> : Set meter contact info\n" $stderr.write " dmm_util sync_time : Sync the clock on the DMM to the computer clock\n" $stderr.write "\n" exit(1) end |