icharger-log 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 83fe244f4cffe07bc9221289d2410bcee33e0431
4
- data.tar.gz: bb590fbbf8ae4d5b5dda4ce03ee2ff8967e45ae9
3
+ metadata.gz: b999dcb75233cefd928ba79642df2d27978d49e5
4
+ data.tar.gz: 4b9873a57bc5a3974857171ab25431e8cc437b6d
5
5
  SHA512:
6
- metadata.gz: 24ba7de017d7b1fd4f884229b65d3b9ce61f016d2e92e885236c855aa58dc4a2bfc7eca1919c3464ee11c8f58a6a490a5e890656f6226e001b7a44a6ce2f2aa6
7
- data.tar.gz: bd09bee625fa854cf8c8c613885b9af1baadc007e3144b08d99ffc9948d8c8e937c5bdd1f6f8266f0a8570ab9e47b79a29d133fb71e80319faa95ce9d4b3ed07
6
+ metadata.gz: 3877f364dad88f3f9ebda8fa9c3a3607d9949d7f808bf71a653ebd020764cb52ca4f94d21f6be3788a62196372fd9b99bf4364d40d8aa16bc18757ca1660d7d5
7
+ data.tar.gz: 95ca4c863e2f70ab4cb61dd996d7d8dab2378e21cd651a1c00c9993c8613c9a09033cac8b5759869df34ba2f4e3d5b5acbd57e04b24458d4f502d5b98a3f67c0
@@ -24,10 +24,16 @@ module ICharger
24
24
  raise ArgumentError, "File does not appear to be an iCharger log (#{e})"
25
25
  end
26
26
 
27
+ # Gets the charger channel number.
28
+ #
29
+ # @return [Number] charger channel number
27
30
  def channel
28
31
  @rows.first.channel
29
32
  end
30
33
 
34
+ # Gets the duration of the log, in seconds.
35
+ #
36
+ # @return [Float] duration of the log, in seconds
31
37
  def duration
32
38
  @rows.last.time / 10000.0
33
39
  end
@@ -8,16 +8,22 @@ module ICharger
8
8
  throw ArgumentError, "Unexpected field count (#{@fields.length})" unless @fields.length == 22
9
9
  end
10
10
 
11
+ # Gets the charger channel number.
12
+ #
13
+ # @return [Number] charger channel number
11
14
  def channel
12
15
  /(?<ch>\d)/.match(@fields[0])[:ch].to_i
13
16
  end
14
17
 
15
- # this is a guess...
18
+ # Gets the current state of operation.
19
+ #
20
+ # @return :charging, :discharging, :unknown
21
+ # @note This is a guess...
16
22
  def state
17
23
  {
18
- 1 => 'charging',
19
- 2 => 'discharging'
20
- }.fetch(@fields[1].to_i, 'unknown')
24
+ 1 => :charging,
25
+ 2 => :discharging
26
+ }.fetch(@fields[1].to_i, :unknown)
21
27
  end
22
28
 
23
29
  # Gets the time in milliseconds.
@@ -37,35 +43,35 @@ module ICharger
37
43
  @fields[4].to_i
38
44
  end
39
45
 
40
- # Instantaneous charge (+) or discharge (-) current, in amps.
46
+ # Gets the instantaneous charge (+) or discharge (-) current, in amps.
41
47
  #
42
48
  # @return [Float] instantaneous current (A)
43
49
  def current
44
50
  @fields[5].to_i / 100.0
45
51
  end
46
52
 
47
- # Input power supply voltage, in volts.
53
+ # Gets the input power supply voltage, in volts.
48
54
  #
49
55
  # @return [Float] input power supply (V)
50
56
  def input_voltage
51
57
  @fields[6].to_i / 1000.0
52
58
  end
53
59
 
54
- # Total battery pack voltage, in volts.
60
+ # Gets the total battery pack voltage, in volts.
55
61
  #
56
62
  # @return [Float] battery pack voltage (V)
57
63
  def pack_voltage
58
64
  @fields[7].to_i / 1000.0
59
65
  end
60
66
 
61
- # Capacity stored or removed so far, in amp-hours.
67
+ # Gets the capacity stored or removed so far, in amp-hours.
62
68
  #
63
69
  # @return [Float] amp-hours stored (+) or removed (-)
64
70
  def capacity
65
71
  @fields[8].to_i / 100.0
66
72
  end
67
73
 
68
- # Internal temperature sensor value, in celsius or fahrenheit.
74
+ # Gets the internal temperature sensor value, in celsius or fahrenheit.
69
75
  #
70
76
  # @param unit :c or :f for celsius or fahrenheit
71
77
  # @return [Float] temperature in requested unit
@@ -73,7 +79,7 @@ module ICharger
73
79
  convert_temperature((@fields[9].to_i / 10.0), unit)
74
80
  end
75
81
 
76
- # External temperature sensor value, in celsius or fahrenheit.
82
+ # Gets the external temperature sensor value, in celsius or fahrenheit.
77
83
  #
78
84
  # @param unit :c or :f for celsius or fahrenheit
79
85
  # @return [Float] temperature in requested unit
@@ -81,15 +87,19 @@ module ICharger
81
87
  convert_temperature((@fields[10].to_i / 10.0), unit)
82
88
  end
83
89
 
84
- # Individual cell voltage, in volts.
90
+ # Gets the individual cell voltage, in volts.
85
91
  #
86
92
  # @param index index of the cell (0-based)
87
- # @return [Float] input power supply (V)
93
+ # @return [Float] specified cell voltage (V)
88
94
  # @see #cell_count
89
95
  def cell_voltage(index)
90
96
  @fields[11 + index].to_i / 1000.0
91
97
  end
92
98
 
99
+ # Gets the number of individual cells measured.
100
+ #
101
+ # @return [Number] number of individual cells
102
+ # @see #cell_voltage
93
103
  def cell_count
94
104
  @fields[11..20].reject{ |v| v.to_i == 0 }.length
95
105
  end
@@ -1,5 +1,5 @@
1
1
  module ICharger
2
2
  module Log
3
- VERSION = "0.1.0"
3
+ VERSION = "0.1.1"
4
4
  end
5
5
  end
data/spec/row_spec.rb CHANGED
@@ -10,7 +10,7 @@ describe ICharger::Log::Row do
10
10
 
11
11
  its(:channel) { should eql(1) }
12
12
 
13
- its(:state) { should eql('charging') }
13
+ its(:state) { should eql(:charging) }
14
14
 
15
15
  its(:current) { should be_within(0.01).of(-0.53) }
16
16
 
@@ -44,7 +44,7 @@ describe ICharger::Log::Row do
44
44
 
45
45
  its(:channel) { should eql(2) }
46
46
 
47
- its(:state) { should eql('charging') }
47
+ its(:state) { should eql(:charging) }
48
48
 
49
49
  its(:current) { should be_within(0.01).of(0.41) }
50
50
 
@@ -78,7 +78,7 @@ describe ICharger::Log::Row do
78
78
 
79
79
  its(:channel) { should eql(1) }
80
80
 
81
- its(:state) { should eql('discharging') }
81
+ its(:state) { should eql(:discharging) }
82
82
 
83
83
  its(:current) { should be_within(0.1).of(3.97) }
84
84
 
@@ -116,7 +116,7 @@ describe ICharger::Log::Row do
116
116
 
117
117
  its(:channel) { should eql(2) }
118
118
 
119
- its(:state) { should eql('charging') }
119
+ its(:state) { should eql(:charging) }
120
120
 
121
121
  its(:time) { should eql(87000) }
122
122
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: icharger-log
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nick Veys