line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Device::MindWave::Packet::ThinkGear::DataValue::EEG; |
2
|
|
|
|
|
|
|
|
3
|
5
|
|
|
5
|
|
38881
|
use strict; |
|
5
|
|
|
|
|
9
|
|
|
5
|
|
|
|
|
166
|
|
4
|
5
|
|
|
5
|
|
24
|
use warnings; |
|
5
|
|
|
|
|
9
|
|
|
5
|
|
|
|
|
179
|
|
5
|
|
|
|
|
|
|
|
6
|
5
|
|
|
5
|
|
573
|
use Device::MindWave::Utils qw(checksum); |
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
284
|
|
7
|
|
|
|
|
|
|
|
8
|
5
|
|
|
5
|
|
24
|
use base qw(Device::MindWave::Packet::ThinkGear::DataValue); |
|
5
|
|
|
|
|
18
|
|
|
5
|
|
|
|
|
2891
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
my @FIELDS = qw(delta theta low_alpha high_alpha |
11
|
|
|
|
|
|
|
low_beta high_beta low_gamma high_gamma); |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub new |
14
|
|
|
|
|
|
|
{ |
15
|
1
|
|
|
1
|
1
|
24
|
my ($class, $bytes, $index) = @_; |
16
|
|
|
|
|
|
|
|
17
|
1
|
|
|
|
|
4
|
$index += 2; |
18
|
|
|
|
|
|
|
|
19
|
1
|
|
|
|
|
3
|
my @values; |
20
|
1
|
|
|
|
|
9
|
for (my $i = 0; $i < 8; $i++) { |
21
|
8
|
|
|
|
|
10
|
my $offset = $i * 3; |
22
|
8
|
|
|
|
|
26
|
push @values, (($bytes->[$index + $offset] << 16) | |
23
|
|
|
|
|
|
|
($bytes->[$index + $offset + 1] << 8) | |
24
|
|
|
|
|
|
|
($bytes->[$index + $offset + 2])); |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
1
|
|
|
|
|
3
|
my $self = {}; |
28
|
1
|
|
|
|
|
4
|
@{$self}{@FIELDS} = @values; |
|
1
|
|
|
|
|
11
|
|
29
|
1
|
|
|
|
|
5
|
bless $self, $class; |
30
|
1
|
|
|
|
|
5
|
return $self; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub _value_to_three_bytes |
34
|
|
|
|
|
|
|
{ |
35
|
8
|
|
|
8
|
|
11
|
my ($value) = @_; |
36
|
|
|
|
|
|
|
|
37
|
8
|
|
|
|
|
27
|
return ((($value >> 16) & 0xFF), |
38
|
|
|
|
|
|
|
(($value >> 8) & 0xFF), |
39
|
|
|
|
|
|
|
(($value) & 0xFF)); |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub as_bytes |
43
|
|
|
|
|
|
|
{ |
44
|
1
|
|
|
1
|
1
|
878
|
my ($self) = @_; |
45
|
|
|
|
|
|
|
|
46
|
1
|
|
|
|
|
5
|
return [ 0x83, 0x18, map { _value_to_three_bytes($self->{$_}) } @FIELDS ]; |
|
8
|
|
|
|
|
672
|
|
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub length |
50
|
|
|
|
|
|
|
{ |
51
|
1
|
|
|
1
|
1
|
5
|
return 26; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub as_string |
55
|
|
|
|
|
|
|
{ |
56
|
1
|
|
|
1
|
1
|
532
|
my ($self) = @_; |
57
|
|
|
|
|
|
|
|
58
|
8
|
|
|
|
|
28
|
return "EEG: ". |
59
|
|
|
|
|
|
|
(join ', ', |
60
|
1
|
|
|
|
|
3
|
map { my $key = $_; |
61
|
8
|
|
|
|
|
17
|
$key =~ s/_/ /g; |
62
|
8
|
|
|
|
|
32
|
"$key=".$self->{$_} } @FIELDS); |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub as_hashref |
66
|
|
|
|
|
|
|
{ |
67
|
1
|
|
|
1
|
1
|
3
|
my ($self) = @_; |
68
|
|
|
|
|
|
|
|
69
|
1
|
|
|
|
|
2
|
return { map { my $key = $_; |
|
8
|
|
|
|
|
11
|
|
70
|
8
|
|
|
|
|
32
|
$key =~ s/_(.)/\U$1/g; |
71
|
8
|
|
|
|
|
15
|
$key = ucfirst $key; |
72
|
8
|
|
|
|
|
44
|
"EEG.$key" => $self->{$_} } @FIELDS }; |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
1; |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
__END__ |