Class: LXP::Packet::ReadInput2
- Defined in:
- lib/lxp/packet/read_input2.rb
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#initialize ⇒ ReadInput2
constructor
A new instance of ReadInput2.
-
#to_h ⇒ Object
Decode the data and return a hash of values in this input packet.
Methods inherited from ReadInput
Methods inherited from Base
#bytes, #data_length, #data_length=, #datalog_serial, #datalog_serial=, #device_function, #device_function=, #inverter_serial, #inverter_serial=, #packet_length, #packet_length=, parse, #protocol, #protocol=, #register, #register=, #tcp_function, #tcp_function=, #to_bin, #update_checksum, #value=, #value_length, #values
Constructor Details
#initialize ⇒ ReadInput2
Returns a new instance of ReadInput2.
8 9 10 11 12 13 |
# File 'lib/lxp/packet/read_input2.rb', line 8 def initialize super self.register = 40 self.value = 40 end |
Instance Method Details
#to_h ⇒ Object
Decode the data and return a hash of values in this input packet
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/lxp/packet/read_input2.rb', line 16 def to_h { # 0 = static 1 # 1 = R_INPUT # 2..12 = serial # 13/14 = length e_pv_all: (Utils.int(@data[15, 4]) + Utils.int(@data[19, 4]) + Utils.int(@data[23, 4])) / 10.0, # kWh e_pv_1_all: Utils.int(@data[15, 4]) / 10.0, # kWh e_pv_2_all: Utils.int(@data[19, 4]) / 10.0, # kWh e_pv_3_all: Utils.int(@data[23, 4]) / 10.0, # kWh e_inv_all: Utils.int(@data[27, 4]) / 10.0, # kWh e_rec_all: Utils.int(@data[31, 4]) / 10.0, # kWh e_chg_all: Utils.int(@data[35, 4]) / 10.0, # kWh e_dischg_all: Utils.int(@data[39, 4]) / 10.0, # kWh e_eps_all: Utils.int(@data[43, 4]) / 10.0, # kWh e_to_grid_all: Utils.int(@data[47, 4]) / 10.0, # kWh e_to_user_all: Utils.int(@data[51, 4]) / 10.0, # kWh # 55 .. 62? # fault code? 4 bytes? # warning code? 4 bytes? t_inner: Utils.int(@data[63, 2]), t_rad_1: Utils.int(@data[65, 2]), t_rad_2: Utils.int(@data[67, 2]), t_bat: Utils.int(@data[69, 2]), # 71..72 ? # this actually seems to be cumulative runtime. # not found an uptime since reboot yet. uptime: Utils.int(@data[73, 4]) # seconds } end |