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