| 1 | 10 | ▶ | use utf8; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | package Net::EGTS::Record; | ||||||||||||||||||||||||||||
| 4 | 10 | ▶ | use namespace::autoclean; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 10 | ▶ | use Mouse; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 10 | ▶ | use Carp; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 10 | ▶ | use List::MoreUtils qw(natatime); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | 10 | ▶ | use Net::EGTS::Util qw(str2time time2new new2time usize dumper_bitstring); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 10 | ▶ | use Net::EGTS::Types; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | 10 | require Net::EGTS::SubRecord; | |||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | 10 | our $RN = 0; | |||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | =head1 NAME | ||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | Net::EGTS::Record - Record | ||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | =cut | ||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | # Record Length | ||||||||||||||||||||||||||||
| 24 | has RL => | ||||||||||||||||||||||||||||
| 25 | is => 'rw', | ||||||||||||||||||||||||||||
| 26 | isa => 'USHORT', | ||||||||||||||||||||||||||||
| 27 | lazy => 1, | ||||||||||||||||||||||||||||
| 28 | builder => sub { | ||||||||||||||||||||||||||||
| 29 | 6 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 30 | 10 | ▶ | use bytes; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 31 | 6 | return length($self->RD); | |||||||||||||||||||||||||||
| 32 | }, | ||||||||||||||||||||||||||||
| 33 | 10 | ; | |||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | # Record Number | ||||||||||||||||||||||||||||
| 36 | has RN => | ||||||||||||||||||||||||||||
| 37 | is => 'rw', | ||||||||||||||||||||||||||||
| 38 | isa => 'USHORT', | ||||||||||||||||||||||||||||
| 39 | lazy => 1, | ||||||||||||||||||||||||||||
| 40 | builder => sub { | ||||||||||||||||||||||||||||
| 41 | 4 | ▶ | my $rn = $RN; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=12.5
| |||||||||||||||||||||||||||||
| 42 | 4 | ▶ | $RN = 0 unless ++$RN >= 0 && $RN <= 65535; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
++$Net::EGTS::Record::RN >= 0 and $Net::EGTS::Record::RN <= 65535
MC/DC0%0/2
++$Net::EGTS::Record::RN >= 0 and $Net::EGTS::Record::RN <= 65535
++$Net::EGTS::Record::RN >= 0
$Net::EGTS::Record::RN <= 65535
Truth table33%1/3
A and B
A= ++$Net::EGTS::Record::RN >= 0B= $Net::EGTS::Record::RN <= 65535
| |||||||||||||||||||||||||||||
| 43 | 4 | return $rn; | |||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||
| 45 | 10 | ; | |||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | # Flags: | ||||||||||||||||||||||||||||
| 49 | # Source Service On Device | ||||||||||||||||||||||||||||
| 50 | 10 | has SSOD => is => 'rw', isa => 'BIT1', default => 0x0; | |||||||||||||||||||||||||||
| 51 | # Recipient Service On Device | ||||||||||||||||||||||||||||
| 52 | 10 | has RSOD => is => 'rw', isa => 'BIT1', default => 0x0; | |||||||||||||||||||||||||||
| 53 | # Group | ||||||||||||||||||||||||||||
| 54 | 10 | has GRP => is => 'rw', isa => 'BIT1', default => 0x0; | |||||||||||||||||||||||||||
| 55 | # Record Processing Priority | ||||||||||||||||||||||||||||
| 56 | 10 | has RPP => is => 'rw', isa => 'BIT2', default => 0x00; | |||||||||||||||||||||||||||
| 57 | # Time Field Exists | ||||||||||||||||||||||||||||
| 58 | has TMFE => | ||||||||||||||||||||||||||||
| 59 | is => 'rw', | ||||||||||||||||||||||||||||
| 60 | isa => 'BIT1', | ||||||||||||||||||||||||||||
| 61 | lazy => 1, | ||||||||||||||||||||||||||||
| 62 | 6 | ▶ | builder => sub{ defined $_[0]->TM ? 0x1 : 0x0 }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.6
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 63 | 10 | ; | |||||||||||||||||||||||||||
| 64 | # Event ID Field Exists | ||||||||||||||||||||||||||||
| 65 | has EVFE => | ||||||||||||||||||||||||||||
| 66 | is => 'rw', | ||||||||||||||||||||||||||||
| 67 | isa => 'BIT1', | ||||||||||||||||||||||||||||
| 68 | lazy => 1, | ||||||||||||||||||||||||||||
| 69 | 6 | ▶ | builder => sub{ defined $_[0]->EVID ? 0x1 : 0x0 }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.6
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 70 | 10 | ; | |||||||||||||||||||||||||||
| 71 | # Object ID Field Exists | ||||||||||||||||||||||||||||
| 72 | has OBFE => | ||||||||||||||||||||||||||||
| 73 | is => 'rw', | ||||||||||||||||||||||||||||
| 74 | isa => 'BIT1', | ||||||||||||||||||||||||||||
| 75 | lazy => 1, | ||||||||||||||||||||||||||||
| 76 | 6 | ▶ | builder => sub{ defined $_[0]->OID ? 0x1 : 0x0 }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 77 | 10 | ; | |||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | # Optional: | ||||||||||||||||||||||||||||
| 80 | # Object Identifier | ||||||||||||||||||||||||||||
| 81 | 10 | has OID => is => 'rw', isa => 'Maybe[UINT]'; | |||||||||||||||||||||||||||
| 82 | # Event Identifier | ||||||||||||||||||||||||||||
| 83 | 10 | has EVID => is => 'rw', isa => 'Maybe[UINT]'; | |||||||||||||||||||||||||||
| 84 | # Time | ||||||||||||||||||||||||||||
| 85 | 10 | has TM => is => 'rw', isa => 'Maybe[UINT]'; | |||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||
| 87 | # Source Service Type | ||||||||||||||||||||||||||||
| 88 | 10 | has SST => is => 'rw', isa => 'BYTE'; | |||||||||||||||||||||||||||
| 89 | # Recipient Service Type | ||||||||||||||||||||||||||||
| 90 | 10 | has RST => is => 'rw', isa => 'BYTE'; | |||||||||||||||||||||||||||
| 91 | # Record Data | ||||||||||||||||||||||||||||
| 92 | has RD => | ||||||||||||||||||||||||||||
| 93 | is => 'rw', | ||||||||||||||||||||||||||||
| 94 | isa => 'BINARY', | ||||||||||||||||||||||||||||
| 95 | trigger => sub { | ||||||||||||||||||||||||||||
| 96 | 17 | ▶ | my ($self, $value, $old) = @_; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.7
| |||||||||||||||||||||||||||||
| 97 | 17 | ▶ | die 'Record Data too short' if length($value) < 3; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 98 | 17 | ▶ | die 'Record Data too long' if length($value) > 65498; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 99 | } | ||||||||||||||||||||||||||||
| 100 | 10 | ; | |||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||
| 102 | # Record binary | ||||||||||||||||||||||||||||
| 103 | 10 | has bin => is => 'rw', isa => 'Str', default => ''; | |||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||
| 105 | # Array of decoded subrecords | ||||||||||||||||||||||||||||
| 106 | has subrecords => | ||||||||||||||||||||||||||||
| 107 | is => 'rw', | ||||||||||||||||||||||||||||
| 108 | isa => 'ArrayRef[Net::EGTS::SubRecord]', | ||||||||||||||||||||||||||||
| 109 | lazy => 1, | ||||||||||||||||||||||||||||
| 110 | builder => sub { | ||||||||||||||||||||||||||||
| 111 | 6 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.4
| |||||||||||||||||||||||||||||
| 112 | 6 | ▶ | return [] unless defined $self->RD; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 113 | 6 | ▶ | return [] unless length $self->RD; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 114 | 6 | return Net::EGTS::SubRecord->decode_all( $self->RD ); | |||||||||||||||||||||||||||
| 115 | }, | ||||||||||||||||||||||||||||
| 116 | 10 | ; | |||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||
| 118 | around BUILDARGS => sub { | ||||||||||||||||||||||||||||
| 119 | 17 | ▶ | my $orig = shift; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||
| 120 | 17 | my $class = shift; | |||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||
| 122 | # simple scalar decoding support | ||||||||||||||||||||||||||||
| 123 | 17 | ▶ | my $bin = @_ % 2 ? shift : undef; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 124 | 17 | my %opts = @_; | |||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||
| 126 | # simple time support | ||||||||||||||||||||||||||||
| 127 | 17 | ▶ | if( defined( my $time = delete $opts{time} ) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 128 | 1 | $opts{TM} = time2new str2time $time; | |||||||||||||||||||||||||||
| 129 | 1 | ▶ | $opts{TMFE} = 1 if $opts{TM}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 130 | } | ||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||
| 132 | 17 | ▶ | return $class->$orig( bin => $bin, %opts ) if $bin; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 133 | 16 | return $class->$orig( %opts ); | |||||||||||||||||||||||||||
| 134 | 10 | }; | |||||||||||||||||||||||||||
| 135 | sub BUILD { | ||||||||||||||||||||||||||||
| 136 | 17 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
BUILD: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 137 | 17 | my $args = shift; | |||||||||||||||||||||||||||
| 138 | 17 | ▶ | $self->decode( \$self->bin ) if length $self->bin; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 139 | } | ||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||
| 141 | # Get chunk from binary and store it | ||||||||||||||||||||||||||||
| 142 | sub take { | ||||||||||||||||||||||||||||
| 143 | 61 | ▶ | my ($self, $bin, $mask, $length) = @_; | ||||||||||||||||||||||||||
|
Subroutine
take: called CC=3 SCAR=11.1
Pod
undocumented
| |||||||||||||||||||||||||||||
| 144 | 10 | ▶ | use bytes; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||
| 146 | 61 | ▶ | $length //= usize($mask); | ||||||||||||||||||||||||||
|
Condition66%2/3
$length //= &usize($mask)
MC/DC0%0/2
$length //= &usize($mask)
$length
&usize($mask)
Truth table66%2/3
A //= B
A= $lengthB= &usize($mask)
| |||||||||||||||||||||||||||||
| 147 | 61 | ▶ | confess "Can`t get chunk of length $length" if $length > length $$bin; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||
| 149 | 61 | my $chunk = substr $$bin, 0 => $length, ''; | |||||||||||||||||||||||||||
| 150 | 61 | $self->bin( $self->bin . $chunk ); | |||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||
| 152 | 61 | return unpack $mask => $chunk; | |||||||||||||||||||||||||||
| 153 | } | ||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||
| 155 | # Helper to get portion of data | ||||||||||||||||||||||||||||
| 156 | sub nip { | ||||||||||||||||||||||||||||
| 157 | 0 | ▶ | my ($self, $bin, $mask, $length) = @_; | ||||||||||||||||||||||||||
|
Subroutine
nip: not called CC=3 SCAR=19.6
Pod
undocumented
| |||||||||||||||||||||||||||||
| 158 | 10 | ▶ | use bytes; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||
| 160 | 0 | ▶ | $length //= usize($mask); | ||||||||||||||||||||||||||
|
Condition0%0/3
$length //= &usize($mask)
MC/DC0%0/2
$length //= &usize($mask)
$length
&usize($mask)
Truth table0%0/3
A //= B
A= $lengthB= &usize($mask)
| |||||||||||||||||||||||||||||
| 161 | 0 | ▶ | confess "Can`t get chunk of length $length" if $length > length $$bin; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||
| 163 | 0 | my $chunk = substr $$bin, 0 => $length, ''; | |||||||||||||||||||||||||||
| 164 | 0 | return unpack $mask => $chunk; | |||||||||||||||||||||||||||
| 165 | } | ||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||
| 167 | =head2 encode | ||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||
| 169 | Build record as binary | ||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||
| 171 | =cut | ||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||
| 173 | sub encode { | ||||||||||||||||||||||||||||
| 174 | 6 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||
|
Subroutine
encode: called CC=10 SCAR=25.5
Pod
documented
| |||||||||||||||||||||||||||||
| 175 | 10 | ▶ | use bytes; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||
| 177 | 6 | ▶ | croak 'Source Service Type required' unless defined $self->SST; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 178 | 6 | ▶ | croak 'Recipient Service Type required' unless defined $self->RST; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 179 | 6 | ▶ | croak 'Record Data required' unless defined $self->RD; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 180 | 6 | ▶ | croak 'Wrong Record Length' unless $self->RL >= 3 && | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->RL >= 3 and $self->RL <= 65498
MC/DC0%0/2
$self->RL >= 3 and $self->RL <= 65498
$self->RL >= 3
$self->RL <= 65498
Truth table33%1/3
A and B
A= $self->RL >= 3B= $self->RL <= 65498
| |||||||||||||||||||||||||||||
| 181 | $self->RL <= 65498; | ||||||||||||||||||||||||||||
| 182 | 6 | my $mask = 'S S B8'; | |||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||
| 184 | # Optional fields | ||||||||||||||||||||||||||||
| 185 | 6 | my @optional; | |||||||||||||||||||||||||||
| 186 | 6 | ▶ | if( $self->OBFE || $self->GRP ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$self->OBFE or $self->GRP
MC/DC50%1/2
$self->OBFE or $self->GRP
$self->OBFE
$self->GRP
Truth table66%2/3
A or B
A= $self->OBFEB= $self->GRP
| |||||||||||||||||||||||||||||
| 187 | 2 | $mask = join ' ', $mask, 'L'; | |||||||||||||||||||||||||||
| 188 | 2 | push @optional, $self->OID; | |||||||||||||||||||||||||||
| 189 | } | ||||||||||||||||||||||||||||
| 190 | 6 | ▶ | if( $self->EVFE ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 191 | 0 | $mask = join ' ', $mask, 'L'; | |||||||||||||||||||||||||||
| 192 | 0 | push @optional, $self->EVID; | |||||||||||||||||||||||||||
| 193 | } | ||||||||||||||||||||||||||||
| 194 | 6 | ▶ | if( $self->TMFE ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 195 | 0 | $mask = join ' ', $mask, 'L'; | |||||||||||||||||||||||||||
| 196 | 0 | push @optional, $self->TM; | |||||||||||||||||||||||||||
| 197 | } | ||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||
| 199 | 6 | $mask = join ' ', $mask, 'C C a*'; | |||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||
| 201 | 6 | my $bin = pack $mask => | |||||||||||||||||||||||||||
| 202 | $self->RL, $self->RN, | ||||||||||||||||||||||||||||
| 203 | sprintf( | ||||||||||||||||||||||||||||
| 204 | '%b%b%b%02b%b%b%b', | ||||||||||||||||||||||||||||
| 205 | $self->SSOD, $self->RSOD, $self->GRP, $self->RPP, $self->TMFE, | ||||||||||||||||||||||||||||
| 206 | $self->EVFE, $self->OBFE, | ||||||||||||||||||||||||||||
| 207 | ), | ||||||||||||||||||||||||||||
| 208 | @optional, | ||||||||||||||||||||||||||||
| 209 | $self->SST, $self->RST, $self->RD | ||||||||||||||||||||||||||||
| 210 | ; | ||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||
| 212 | 6 | $self->bin( $bin ); | |||||||||||||||||||||||||||
| 213 | 6 | return $bin; | |||||||||||||||||||||||||||
| 214 | } | ||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||
| 216 | =head2 decode \$bin | ||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||
| 218 | Decode binary I<$bin> into record object. | ||||||||||||||||||||||||||||
| 219 | The binary stream will be truncated! | ||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||
| 221 | =cut | ||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||
| 223 | sub decode { | ||||||||||||||||||||||||||||
| 224 | 10 | ▶ | my ($self, $bin) = @_; | ||||||||||||||||||||||||||
|
Subroutine
decode: called CC=5 SCAR=16.1
Pod
documented
| |||||||||||||||||||||||||||||
| 225 | 10 | ▶ | use bytes; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||
| 227 | 10 | $self->RL( $self->take($bin => 'S') ); | |||||||||||||||||||||||||||
| 228 | 10 | $self->RN( $self->take($bin => 'S') ); | |||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||
| 230 | 10 | my $flags = $self->take($bin => 'C'); | |||||||||||||||||||||||||||
| 231 | 10 | $self->SSOD( ($flags & 0b10000000) >> 7 ); | |||||||||||||||||||||||||||
| 232 | 10 | $self->RSOD( ($flags & 0b01000000) >> 6 ); | |||||||||||||||||||||||||||
| 233 | 10 | $self->GRP( ($flags & 0b00100000) >> 5 ); | |||||||||||||||||||||||||||
| 234 | 10 | $self->RPP( ($flags & 0b00011000) >> 3 ); | |||||||||||||||||||||||||||
| 235 | 10 | $self->TMFE( ($flags & 0b00000100) >> 2 ); | |||||||||||||||||||||||||||
| 236 | 10 | $self->EVFE( ($flags & 0b00000010) >> 1 ); | |||||||||||||||||||||||||||
| 237 | 10 | $self->OBFE( ($flags & 0b00000001) ); | |||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||
| 239 | 10 | ▶ | $self->OID( $self->take($bin => 'L') ) if $self->OBFE || $self->GRP; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$self->OBFE or $self->GRP
MC/DC50%1/2
$self->OBFE or $self->GRP
$self->OBFE
$self->GRP
Truth table66%2/3
A or B
A= $self->OBFEB= $self->GRP
| |||||||||||||||||||||||||||||
| 240 | 10 | ▶ | $self->EVID( $self->take($bin => 'L') ) if $self->EVFE; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 241 | 10 | ▶ | $self->TM( $self->take($bin => 'L') ) if $self->TMFE; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||
| 243 | 10 | $self->SST( $self->take($bin => 'C') ); | |||||||||||||||||||||||||||
| 244 | 10 | $self->RST( $self->take($bin => 'C') ); | |||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||
| 246 | 10 | $self->RD( $self->take($bin => 'a*' => $self->RL) ); | |||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||
| 248 | 10 | return $self; | |||||||||||||||||||||||||||
| 249 | } | ||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||
| 251 | =head2 decode_all \$bin | ||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||
| 253 | Parse all records from packet Service Frame Data | ||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||
| 255 | =cut | ||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||
| 257 | sub decode_all { | ||||||||||||||||||||||||||||
| 258 | 7 | ▶ | my ($class, $bin) = @_; | ||||||||||||||||||||||||||
|
Subroutine
decode_all: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||
| 259 | 10 | ▶ | use bytes; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||
| 261 | 7 | my @result; | |||||||||||||||||||||||||||
| 262 | 7 | ▶ | while( my $length = length $bin ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 263 | 8 | my $self = Net::EGTS::Record->new->decode( \$bin ); | |||||||||||||||||||||||||||
| 264 | 8 | ▶ | die 'Something wrong in records decode' unless $self; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||
| 266 | 8 | push @result, $self; | |||||||||||||||||||||||||||
| 267 | } | ||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||
| 269 | 7 | ▶ | return wantarray ? @result : \@result; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 270 | } | ||||||||||||||||||||||||||||
| 271 | |||||||||||||||||||||||||||||
| 272 | =head2 as_debug | ||||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||
| 274 | Return human readable string | ||||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||
| 276 | =cut | ||||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||
| 278 | sub as_debug { | ||||||||||||||||||||||||||||
| 279 | 6 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||
|
Subroutine
as_debug: called CC=5 SCAR=16.1
Pod
documented
| |||||||||||||||||||||||||||||
| 280 | 10 | ▶ | use bytes; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||
| 282 | 6 | my @bytes = ((unpack('B*', $self->bin)) =~ m{.{8}}g); | |||||||||||||||||||||||||||
| 283 | |||||||||||||||||||||||||||||
| 284 | 6 | my @str; | |||||||||||||||||||||||||||
| 285 | 6 | push @str => sprintf('RL: %s %s', splice @bytes, 0 => usize('S')); | |||||||||||||||||||||||||||
| 286 | 6 | push @str => sprintf('RN: %s %s', splice @bytes, 0 => usize('S')); | |||||||||||||||||||||||||||
| 287 | 6 | push @str => sprintf('FLAGS: %s', splice @bytes, 0 => usize('C')); | |||||||||||||||||||||||||||
| 288 | |||||||||||||||||||||||||||||
| 289 | 6 | ▶ | push @str => sprintf('OID: %s %s %s %s', splice @bytes, 0 => usize('L')) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 290 | if defined $self->OID; | ||||||||||||||||||||||||||||
| 291 | 6 | ▶ | push @str => sprintf('EVID: %s %s %s %s', splice @bytes, 0 => usize('L')) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 292 | if defined $self->EVID; | ||||||||||||||||||||||||||||
| 293 | 6 | ▶ | push @str => sprintf('TM: %s %s %s %s', splice @bytes, 0 => usize('L')) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 294 | if defined $self->TM; | ||||||||||||||||||||||||||||
| 295 | |||||||||||||||||||||||||||||
| 296 | 6 | push @str => sprintf('SST: %s', splice @bytes, 0 => usize('C')); | |||||||||||||||||||||||||||
| 297 | 6 | push @str => sprintf('RST: %s', splice @bytes, 0 => usize('C')); | |||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||
| 299 | 6 | my $it = natatime 4, @bytes; | |||||||||||||||||||||||||||
| 300 | 6 | my @chunks; | |||||||||||||||||||||||||||
| 301 | 6 | ▶ | while (my @vals = $it->()) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 302 | 13 | push @chunks, join(' ', @vals); | |||||||||||||||||||||||||||
| 303 | } | ||||||||||||||||||||||||||||
| 304 | 6 | push @str => sprintf('RD: %s', join("\n ", @chunks)); | |||||||||||||||||||||||||||
| 305 | |||||||||||||||||||||||||||||
| 306 | 6 | return join "\n", @str; | |||||||||||||||||||||||||||
| 307 | } | ||||||||||||||||||||||||||||
| 308 | |||||||||||||||||||||||||||||
| 309 | 10 | __PACKAGE__->meta->make_immutable(); | |||||||||||||||||||||||||||