Class: LXP::Packet::WriteSingle

Inherits:
Base
  • Object
show all
Defined in:
lib/lxp/packet/write_single.rb

Instance Attribute Summary

Attributes inherited from Base

#chksum, #data, #header

Instance Method Summary collapse

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

#initializeWriteSingle

Returns a new instance of WriteSingle.



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

def initialize
  super

  self.tcp_function = TcpFunctions::TRANSLATED_DATA
  self.device_function = DeviceFunctions::WRITE_SINGLE
  self.data_length = 18
end

Instance Method Details

#discharge_cut_off=(value) ⇒ Object



21
22
23
24
# File 'lib/lxp/packet/write_single.rb', line 21

def discharge_cut_off=(value)
  self.register = Registers::DISCHG_CUT_OFF_SOC_EOD
  self.value = value
end

#discharge_rate=(value) ⇒ Object



16
17
18
19
# File 'lib/lxp/packet/write_single.rb', line 16

def discharge_rate=(value)
  self.register = Registers::DISCHG_POWER_PERCENT_CMD
  self.value = value
end

#valueObject

WriteSingle packets should always (I think) have two byte values.

Raise if not, as that is not expected?



30
31
32
33
34
# File 'lib/lxp/packet/write_single.rb', line 30

def value
  raise 'value_length not 2?' unless value_length == 2

  Utils.int(values[0, 2])
end