Class: LXP::Packet::ReadInput1

Inherits:
ReadInput show all
Defined in:
lib/lxp/packet/read_input1.rb

Instance Attribute Summary

Attributes inherited from Base

#chksum, #data, #header

Instance Method Summary collapse

Methods inherited from ReadInput

parse

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 ⇒ ReadInput1

Returns a new instance of ReadInput1.



8
9
10
11
12
13
# File 'lib/lxp/packet/read_input1.rb', line 8

def initialize
  super

  self.register = 0
  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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/lxp/packet/read_input1.rb', line 16

def to_h
  {
    # 0 = static 1
    # 1 = R_INPUT
    # 2..12 = serial
    # 13/14 = length

    status: Utils.int(@data[15, 2]),

    v_pv_1: Utils.int(@data[17, 2]) / 10.0, # V
    v_pv_2: Utils.int(@data[19, 2]) / 10.0, # V
    v_pv_3: Utils.int(@data[21, 2]) / 10.0, # V

    v_bat: Utils.int(@data[23, 2]) / 10.0, # V
    soc: @data[25], # %
    # 26 used for anything?

    # 27 always been 0 so far
    # 28 I've seen anything from 0 to 53, changes occasionally but
    # not spotted a pattern yet.
    _unknown_i1_27: @data[27],
    _unknown_i1_28: @data[28],

    # this might be useless if 27 and 28 are independent
    _unknown_i1_27_28: Utils.int(@data[27, 2]),

    p_pv: Utils.int(@data[29, 2]) +
      Utils.int(@data[31, 2]) +
      Utils.int(@data[33, 2]), # W
    p_pv_1: Utils.int(@data[29, 2]), # W
    p_pv_2: Utils.int(@data[31, 2]), # W
    p_pv_3: Utils.int(@data[33, 2]), # W
    p_charge: Utils.int(@data[35, 2]), # W
    p_discharge: Utils.int(@data[37, 2]), # W
    v_ac_r: Utils.int(@data[39, 2]) / 10.0, # V
    v_ac_s: Utils.int(@data[41, 2]) / 10.0, # V
    v_ac_t: Utils.int(@data[43, 2]) / 10.0, # V
    f_ac: Utils.int(@data[45, 2]) / 100.0, # Hz

    p_inv: Utils.int(@data[47, 2]), # W
    p_rec: Utils.int(@data[49, 2]), # W

    # this seems to track with charge/discharge but at lower values.
    # no idea what this means.
    _unknown_i1_51_52: Utils.int(@data[51, 2]), # W ?

    pf: Utils.int(@data[53, 2]) / 1000.0, # Hz

    v_eps_r: Utils.int(@data[55, 2]) / 10.0, # V
    v_eps_s: Utils.int(@data[57, 2]) / 10.0, # V
    v_eps_t: Utils.int(@data[59, 2]) / 10.0, # V
    f_eps: Utils.int(@data[61, 2]) / 100.0, # Hz

    # peps and seps in 63..66?

    p_to_grid: Utils.int(@data[67, 2]), # W
    p_to_user: Utils.int(@data[69, 2]), # W

    e_pv_day: (Utils.int(@data[71, 2]) +
               Utils.int(@data[73, 2]) + Utils.int(@data[75, 2])) / 10.0, # kWh
    e_pv_1_day: Utils.int(@data[71, 2]) / 10.0, # kWh
    e_pv_2_day: Utils.int(@data[73, 2]) / 10.0, # kWh
    e_pv_3_day: Utils.int(@data[75, 2]) / 10.0, # kWh
    e_inv_day: Utils.int(@data[77, 2]) / 10.0, # kWh
    e_rec_day: Utils.int(@data[79, 2]) / 10.0, # kWh
    e_chg_day: Utils.int(@data[81, 2]) / 10.0, # kWh
    e_dischg_day: Utils.int(@data[83, 2]) / 10.0, # kWh
    e_eps_day: Utils.int(@data[85, 2]) / 10.0, # kWh
    e_to_grid_day: Utils.int(@data[87, 2]) / 10.0, # kWh
    e_to_user_day: Utils.int(@data[89, 2]) / 10.0, # kWh

    v_bus_1: Utils.int(@data[91, 2]) / 10.0, # V
    v_bus_2: Utils.int(@data[93, 2]) / 10.0 # V
  }
end