icharger-log 0.0.1 → 0.1.0
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 +4 -4
- data/lib/icharger/log/row.rb +54 -21
- data/lib/icharger/log/version.rb +1 -1
- data/spec/data/LiPo[Storage_952_CH1].txt +447 -447
- data/spec/data/LiPo[Storage_953_CH2].txt +629 -629
- data/spec/data/LiPo[Storage_965_CH2].txt +868 -0
- data/spec/file_spec.rb +15 -1
- data/spec/row_spec.rb +81 -27
- metadata +4 -2
data/spec/file_spec.rb
CHANGED
@@ -30,6 +30,20 @@ describe ICharger::Log::File do
|
|
30
30
|
|
31
31
|
end
|
32
32
|
|
33
|
+
context 'data file LiPo[Storage_965_CH2].txt' do
|
34
|
+
|
35
|
+
before(:all) { @file = ICharger::Log::File.new(data_file('LiPo[Storage_965_CH2].txt')) }
|
36
|
+
|
37
|
+
subject { @file }
|
38
|
+
|
39
|
+
it { should have(868).rows }
|
40
|
+
|
41
|
+
its(:channel) { should eql(2) }
|
42
|
+
|
43
|
+
its(:duration) { should be_within(0.1).of(86.7) }
|
44
|
+
|
45
|
+
end
|
46
|
+
|
33
47
|
describe '#icharger?' do
|
34
48
|
|
35
49
|
it 'should be false for invalid or missing files' do
|
@@ -43,7 +57,7 @@ describe ICharger::Log::File do
|
|
43
57
|
|
44
58
|
it 'should be true for valid files' do
|
45
59
|
files = data_files
|
46
|
-
files.should have(
|
60
|
+
files.should have(3).files
|
47
61
|
|
48
62
|
files.each do |f|
|
49
63
|
expect(ICharger::Log::File.icharger?(f)).to be_true
|
data/spec/row_spec.rb
CHANGED
@@ -6,21 +6,34 @@ describe ICharger::Log::Row do
|
|
6
6
|
|
7
7
|
context 'channel 1, 6 cells' do
|
8
8
|
|
9
|
-
let(:data) { '$1;1;18000;1;0;-53;23746;22752;1;
|
9
|
+
let(:data) { '$1;1;18000;1;0;-53;23746;22752;1;391;0;3795;3793;3798;3795;3793;3789;0;0;0;0;50' }
|
10
10
|
|
11
11
|
its(:channel) { should eql(1) }
|
12
12
|
|
13
|
+
its(:state) { should eql('charging') }
|
14
|
+
|
13
15
|
its(:current) { should be_within(0.01).of(-0.53) }
|
14
16
|
|
17
|
+
its(:input_voltage) { should be_within(0.1).of(23.75) }
|
18
|
+
|
19
|
+
its(:pack_voltage) { should be_within(0.1).of(22.75) }
|
20
|
+
|
21
|
+
its(:capacity) { should be_within(0.1).of(0.1) }
|
22
|
+
|
23
|
+
it 'should have internal temperatures' do
|
24
|
+
expect(subject.internal_temperature(:c)).to be_within(0.1).of(39.1)
|
25
|
+
expect(subject.internal_temperature(:f)).to be_within(0.1).of(102.4)
|
26
|
+
end
|
27
|
+
|
15
28
|
its(:cell_count) { should eql(6) }
|
16
29
|
|
17
30
|
it 'should have known cell voltages' do
|
18
|
-
expect(subject.
|
19
|
-
expect(subject.
|
20
|
-
expect(subject.
|
21
|
-
expect(subject.
|
22
|
-
expect(subject.
|
23
|
-
expect(subject.
|
31
|
+
expect(subject.cell_voltage(0)).to be_within(0.01).of(3.79)
|
32
|
+
expect(subject.cell_voltage(1)).to be_within(0.01).of(3.79)
|
33
|
+
expect(subject.cell_voltage(2)).to be_within(0.01).of(3.79)
|
34
|
+
expect(subject.cell_voltage(3)).to be_within(0.01).of(3.79)
|
35
|
+
expect(subject.cell_voltage(4)).to be_within(0.01).of(3.79)
|
36
|
+
expect(subject.cell_voltage(5)).to be_within(0.01).of(3.79)
|
24
37
|
end
|
25
38
|
|
26
39
|
end
|
@@ -31,59 +44,100 @@ describe ICharger::Log::Row do
|
|
31
44
|
|
32
45
|
its(:channel) { should eql(2) }
|
33
46
|
|
47
|
+
its(:state) { should eql('charging') }
|
48
|
+
|
34
49
|
its(:current) { should be_within(0.01).of(0.41) }
|
35
50
|
|
51
|
+
its(:input_voltage) { should be_within(0.1).of(23.84) }
|
52
|
+
|
53
|
+
its(:pack_voltage) { should be_within(0.1).of(22.85) }
|
54
|
+
|
55
|
+
its(:capacity) { should be_within(0.1).of(0.0) }
|
56
|
+
|
57
|
+
it 'should have internal temperatures' do
|
58
|
+
expect(subject.internal_temperature(:c)).to be_within(0.1).of(38.0)
|
59
|
+
expect(subject.internal_temperature(:f)).to be_within(0.1).of(100.4)
|
60
|
+
end
|
61
|
+
|
36
62
|
its(:cell_count) { should eql(6) }
|
37
63
|
|
38
64
|
it 'should have known cell voltages' do
|
39
|
-
expect(subject.
|
40
|
-
expect(subject.
|
41
|
-
expect(subject.
|
42
|
-
expect(subject.
|
43
|
-
expect(subject.
|
44
|
-
expect(subject.
|
65
|
+
expect(subject.cell_voltage(0)).to be_within(0.01).of(3.81)
|
66
|
+
expect(subject.cell_voltage(1)).to be_within(0.01).of(3.80)
|
67
|
+
expect(subject.cell_voltage(2)).to be_within(0.01).of(3.81)
|
68
|
+
expect(subject.cell_voltage(3)).to be_within(0.01).of(3.81)
|
69
|
+
expect(subject.cell_voltage(4)).to be_within(0.01).of(3.80)
|
70
|
+
expect(subject.cell_voltage(5)).to be_within(0.01).of(3.81)
|
45
71
|
end
|
46
72
|
|
47
73
|
end
|
48
74
|
|
49
75
|
context 'channel 1, 10 cells' do
|
50
76
|
|
51
|
-
let(:data) { '$1;
|
77
|
+
let(:data) { '$1;2;106000;1;0;397;23760;22853;-601;380;0;3810;3807;3813;3811;3806;3812;3811;3814;3809;3812;40' }
|
52
78
|
|
53
79
|
its(:channel) { should eql(1) }
|
54
80
|
|
81
|
+
its(:state) { should eql('discharging') }
|
82
|
+
|
55
83
|
its(:current) { should be_within(0.1).of(3.97) }
|
56
84
|
|
85
|
+
its(:input_voltage) { should be_within(0.1).of(23.76) }
|
86
|
+
|
87
|
+
its(:pack_voltage) { should be_within(0.1).of(22.85) }
|
88
|
+
|
89
|
+
its(:capacity) { should be_within(0.1).of(-6.01) }
|
90
|
+
|
91
|
+
it 'should have internal temperatures' do
|
92
|
+
expect(subject.internal_temperature(:c)).to be_within(0.1).of(38.0)
|
93
|
+
expect(subject.internal_temperature(:f)).to be_within(0.1).of(100.4)
|
94
|
+
end
|
95
|
+
|
57
96
|
its(:cell_count) { should eql(10) }
|
58
97
|
|
59
98
|
it 'should have known cell voltages' do
|
60
|
-
expect(subject.
|
61
|
-
expect(subject.
|
62
|
-
expect(subject.
|
63
|
-
expect(subject.
|
64
|
-
expect(subject.
|
65
|
-
expect(subject.
|
66
|
-
expect(subject.
|
67
|
-
expect(subject.
|
68
|
-
expect(subject.
|
69
|
-
expect(subject.
|
99
|
+
expect(subject.cell_voltage(0)).to be_within(0.01).of(3.81)
|
100
|
+
expect(subject.cell_voltage(1)).to be_within(0.01).of(3.80)
|
101
|
+
expect(subject.cell_voltage(2)).to be_within(0.01).of(3.81)
|
102
|
+
expect(subject.cell_voltage(3)).to be_within(0.01).of(3.81)
|
103
|
+
expect(subject.cell_voltage(4)).to be_within(0.01).of(3.80)
|
104
|
+
expect(subject.cell_voltage(5)).to be_within(0.01).of(3.81)
|
105
|
+
expect(subject.cell_voltage(6)).to be_within(0.01).of(3.81)
|
106
|
+
expect(subject.cell_voltage(7)).to be_within(0.01).of(3.81)
|
107
|
+
expect(subject.cell_voltage(8)).to be_within(0.01).of(3.80)
|
108
|
+
expect(subject.cell_voltage(9)).to be_within(0.01).of(3.81)
|
70
109
|
end
|
71
110
|
|
72
111
|
end
|
73
112
|
|
74
113
|
context 'channel 2, 2 cells' do
|
75
114
|
|
76
|
-
let(:data) { '$2;1;87000;1;0;402;23840;22853;
|
115
|
+
let(:data) { '$2;1;87000;1;0;402;23840;22853;150;380;0;3810;3807;0;0;0;0;0;0;0;0;40' }
|
77
116
|
|
78
117
|
its(:channel) { should eql(2) }
|
79
118
|
|
119
|
+
its(:state) { should eql('charging') }
|
120
|
+
|
121
|
+
its(:time) { should eql(87000) }
|
122
|
+
|
80
123
|
its(:current) { should be_within(0.1).of(4.02) }
|
81
124
|
|
125
|
+
its(:input_voltage) { should be_within(0.1).of(23.84) }
|
126
|
+
|
127
|
+
its(:pack_voltage) { should be_within(0.1).of(22.85) }
|
128
|
+
|
129
|
+
its(:capacity) { should be_within(0.1).of(1.5) }
|
130
|
+
|
131
|
+
it 'should have internal temperatures' do
|
132
|
+
expect(subject.internal_temperature(:c)).to be_within(0.1).of(38.0)
|
133
|
+
expect(subject.internal_temperature(:f)).to be_within(0.1).of(100.4)
|
134
|
+
end
|
135
|
+
|
82
136
|
its(:cell_count) { should eql(2) }
|
83
137
|
|
84
138
|
it 'should have known cell voltages' do
|
85
|
-
expect(subject.
|
86
|
-
expect(subject.
|
139
|
+
expect(subject.cell_voltage(0)).to be_within(0.01).of(3.81)
|
140
|
+
expect(subject.cell_voltage(1)).to be_within(0.01).of(3.81)
|
87
141
|
end
|
88
142
|
|
89
143
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: icharger-log
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nick Veys
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-11-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: awesome_print
|
@@ -142,6 +142,7 @@ files:
|
|
142
142
|
- lib/icharger/log/version.rb
|
143
143
|
- spec/data/LiPo[Storage_952_CH1].txt
|
144
144
|
- spec/data/LiPo[Storage_953_CH2].txt
|
145
|
+
- spec/data/LiPo[Storage_965_CH2].txt
|
145
146
|
- spec/file_spec.rb
|
146
147
|
- spec/row_spec.rb
|
147
148
|
- spec/spec_helper.rb
|
@@ -172,6 +173,7 @@ summary: iCharger log file reader
|
|
172
173
|
test_files:
|
173
174
|
- spec/data/LiPo[Storage_952_CH1].txt
|
174
175
|
- spec/data/LiPo[Storage_953_CH2].txt
|
176
|
+
- spec/data/LiPo[Storage_965_CH2].txt
|
175
177
|
- spec/file_spec.rb
|
176
178
|
- spec/row_spec.rb
|
177
179
|
- spec/spec_helper.rb
|