#!/usr/bin/env ruby $LOAD_PATH.unshift(File.dirname(__FILE__) + '/lib') require 'jfy/client' require 'awesome_print' client = Jfy::Client.new retries = 0 begin print 'Re Register all the arrays... ' client.re_register puts 'Done.' print 'Offine Query an the array... ' serial = client.offline_query puts 'Done.' rescue BadPacket, ReadTimeout => e puts "Bad Packet #{e} ... Retrying" if @debug puts if @debug retries += 1 exit if retries > 5 retry end print 'Register the first array... ' serial_num = 0x02 client.register(serial, serial_num) puts 'Done.' puts print 'Description: ' description = client.description(serial_num) puts description puts print 'RW Description: ' rw_description = client.rw_description(serial_num) puts rw_description puts puts 'Inverter Info:' data = client.query_inverter_info(serial_num) ap data puts puts 'Normal Info:' data = client.query_normal_info(serial_num) ap data puts puts 'Set Info:' data = client.query_set_info(serial_num) ap data puts