#!/usr/bin/ruby
#
# Indices into the parsed values array 'v'
# 
BV = 17
GF = 21
HY = 22

# Array of label/index pairs for output
# 
vals = [
   ["Volts", BV],
   ["GrndFltCurr", GF],
   ["%Hydrogen", HY]
]

Signal.trap("INT") { STDOUT.flush(); puts("\nDone"); exit }

# Execute continuously or just once
# 
n = 0
while(1) do
   next unless (line = gets())

   # Examine every tenth line
   # 
   n += 1
   next unless (n >= 10) 

   n = 0
   # This parses the line using ',' as a separator.
   # Array 'v' contains the string values.
   # 
   v = line.split(',')

   # Write the labels and values
   # 
   vals.each do |i|
      STDOUT.write("#{i[0]}=#{v[i[1]].lstrip}  ")
   end
   STDOUT.write("\n")
   STDOUT.flush()

   #break  # Just once for now

end
