| 1 | package Device::Modbus::ADU; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | 7 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 7 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | 7 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||
| 7 | 68 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | 68 | my ($class, %args) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 9 | 68 | return bless \%args, $class; | |||||||||||||||||||||||||||||||||||||||||
| 10 | } | ||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||
| 12 | 232 | ▶ | sub message { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
message: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 13 | 232 | my ($self, $msg) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 14 | 232 | ▶ | if ($msg) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 15 | 53 | $self->{message} = $msg; | |||||||||||||||||||||||||||||||||||||||||
| 16 | } | ||||||||||||||||||||||||||||||||||||||||||
| 17 | croak "This ADU does not contain any messages" | ||||||||||||||||||||||||||||||||||||||||||
| 18 | 232 | ▶ | unless exists $self->{message}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 19 | 231 | return $self->{message}; | |||||||||||||||||||||||||||||||||||||||||
| 20 | } | ||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||
| 22 | 3 | ▶ | sub success { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
success: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 23 | 3 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 24 | 3 | ▶ | return exists $self->{message} && $self->{message}->{code} < 0x80; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
exists $self->{'message'} && $self->{'message'}{'code'} < 128
MC/DC100%2/2
exists $self->{'message'} && $self->{'message'}{'code'} < 128
exists $self->{'message'}
$self->{'message'}{'code'} < 128
Truth table100%3/3
A && B
A= exists $self->{'message'}B= $self->{'message'}{'code'} < 128
| |||||||||||||||||||||||||||||||||||||||||||
| 25 | } | ||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||
| 27 | 2 | ▶ | sub function { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
function: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 28 | 2 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 29 | 2 | return $self->message->{function}; | |||||||||||||||||||||||||||||||||||||||||
| 30 | } | ||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||
| 32 | 73 | ▶ | sub code { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
code: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 33 | 73 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 34 | 73 | return $self->message->{code}; | |||||||||||||||||||||||||||||||||||||||||
| 35 | } | ||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||
| 37 | 2 | ▶ | sub values { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
values: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 38 | 2 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 39 | 2 | ▶ | return $self->message->{values} // [$self->message->{value}]; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$self->message->{"values"} // [$self->message->{"value"}]
MC/DC100%1/1
$self->message->{"values"} // [$self->message->{"value"}]
$self->message->{"values"}
Truth table100%2/2
A
A= $self->message->{"values"}
| |||||||||||||||||||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||
| 42 | 80 | ▶ | sub unit { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
unit: called CC=6 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 43 | 80 | my ($self, $unit) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 44 | 80 | ▶ | croak "Unit number is invalid" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
defined $unit and $unit < 1 || $unit > 255
$unit < 1 or $unit > 255
MC/DC100%3/3
defined $unit and $unit < 1 || $unit > 255
defined $unit
$unit < 1
$unit > 255
Truth table100%4/4
A and B or C
A= defined $unitB= $unit < 1C= $unit > 255
| |||||||||||||||||||||||||||||||||||||||||||
| 45 | if defined $unit && ($unit < 1 || $unit > 0xff); | ||||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||
| 47 | 78 | ▶ | if (defined $unit) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 48 | 29 | $self->{unit} = $unit; | |||||||||||||||||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||||||||||||||||
| 50 | croak "Unit has not been declared" | ||||||||||||||||||||||||||||||||||||||||||
| 51 | 78 | ▶ | unless exists $self->{unit}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 52 | 77 | return $self->{unit}; | |||||||||||||||||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||
| 55 | 0 | ▶ | sub binary_message { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
binary_message: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 56 | 0 | croak "binary_message must be implemented by a subclass of Device::Modbus::ADU"; | |||||||||||||||||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||
| 59 | 7 | 1; | |||||||||||||||||||||||||||||||||||||||||