line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Device::Modbus::ADU; |
2
|
|
|
|
|
|
|
|
3
|
7
|
|
|
7
|
|
92935
|
use Carp; |
|
7
|
|
|
|
|
16
|
|
|
7
|
|
|
|
|
483
|
|
4
|
7
|
|
|
7
|
|
37
|
use strict; |
|
7
|
|
|
|
|
13
|
|
|
7
|
|
|
|
|
142
|
|
5
|
7
|
|
|
7
|
|
33
|
use warnings; |
|
7
|
|
|
|
|
14
|
|
|
7
|
|
|
|
|
161
|
|
6
|
7
|
|
|
7
|
|
88
|
use v5.10; |
|
7
|
|
|
|
|
21
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub new { |
9
|
68
|
|
|
68
|
0
|
27711
|
my ($class, %args) = @_; |
10
|
68
|
|
|
|
|
210
|
return bless \%args, $class; |
11
|
|
|
|
|
|
|
} |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub message { |
14
|
232
|
|
|
232
|
0
|
4685
|
my ($self, $msg) = @_; |
15
|
232
|
100
|
|
|
|
634
|
if ($msg) { |
16
|
53
|
|
|
|
|
116
|
$self->{message} = $msg; |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
croak "This ADU does not contain any messages" |
19
|
232
|
100
|
|
|
|
710
|
unless exists $self->{message}; |
20
|
231
|
|
|
|
|
835
|
return $self->{message}; |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub success { |
24
|
3
|
|
|
3
|
0
|
8
|
my $self = shift; |
25
|
3
|
|
100
|
|
|
24
|
return exists $self->{message} && $self->{message}->{code} < 0x80; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub function { |
29
|
2
|
|
|
2
|
0
|
8
|
my $self = shift; |
30
|
2
|
|
|
|
|
5
|
return $self->message->{function}; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub code { |
34
|
73
|
|
|
73
|
0
|
130
|
my $self = shift; |
35
|
73
|
|
|
|
|
129
|
return $self->message->{code}; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub values { |
39
|
2
|
|
|
2
|
0
|
6
|
my $self = shift; |
40
|
2
|
|
100
|
|
|
5
|
return $self->message->{values} // [$self->message->{value}]; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub unit { |
44
|
80
|
|
|
80
|
0
|
1716
|
my ($self, $unit) = @_; |
45
|
80
|
100
|
100
|
|
|
449
|
croak "Unit number is invalid" |
|
|
|
66
|
|
|
|
|
46
|
|
|
|
|
|
|
if defined $unit && ($unit < 1 || $unit > 0xff); |
47
|
|
|
|
|
|
|
|
48
|
78
|
100
|
|
|
|
153
|
if (defined $unit) { |
49
|
29
|
|
|
|
|
47
|
$self->{unit} = $unit; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
croak "Unit has not been declared" |
52
|
78
|
100
|
|
|
|
253
|
unless exists $self->{unit}; |
53
|
77
|
|
|
|
|
255
|
return $self->{unit}; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub binary_message { |
57
|
0
|
|
|
0
|
0
|
|
croak "binary_message must be implemented by a subclass of Device::Modbus::ADU"; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
1; |