File Coverage

blib/lib/BACnet/ServiceRequestSequences/ReadProperty.pm
Criterion Covered Total %
statement 42 42 100.0
branch 4 4 100.0
condition n/a
subroutine 13 13 100.0
pod 0 3 0.0
total 59 62 95.1


line stmt bran cond sub pod time code
1             #!/usr/bin/perl
2              
3             package BACnet::ServiceRequestSequences::ReadProperty;
4              
5 27     27   171 use warnings;
  27         57  
  27         1574  
6 27     27   141 use strict;
  27         48  
  27         583  
7              
8 27     27   132 use bytes;
  27         46  
  27         181  
9              
10 27     27   756 use BACnet::ServiceRequestSequences::Utils;
  27         93  
  27         875  
11 27     27   158 use BACnet::DataTypes::Enum;
  27         94  
  27         950  
12 27     27   184 use BACnet::DataTypes::ObjectIdentifier;
  27         75  
  27         713  
13 27     27   125 use BACnet::DataTypes::UnsignedInt;
  27         81  
  27         755  
14 27     27   121 use BACnet::DataTypes::SequenceValue;
  27         130  
  27         688  
15 27     27   121 use BACnet::DataTypes::Bone;
  27         54  
  27         837  
16 27     27   125 use BACnet::DataTypes::Enums::PropertyIdentifier;
  27         64  
  27         14783  
17              
18             our $request_skeleton = [
19             BACnet::DataTypes::Bone->construct(
20             tag => 0,
21             name => 'object_identifier',
22             dt => 'BACnet::DataTypes::ObjectIdentifier'
23             ),
24             BACnet::DataTypes::Bone->construct(
25             tag => 1,
26             name => 'property_identifier',
27             dt => 'BACnet::DataTypes::Enum'
28             ),
29             BACnet::DataTypes::Bone->construct(
30             tag => 2,
31             name => 'property_array_index',
32             dt => 'BACnet::DataTypes::UnsignedInt'
33             )
34             ];
35              
36             sub request {
37 2     2 0 151251 my %args = (
38             object_identifier_type => undef,
39             object_identifier_instance => undef,
40             property_identifier => undef,
41             property_array_index => undef,
42             @_,
43             );
44              
45             my $sequence_elements = [
46             [
47             'object_identifier',
48             BACnet::DataTypes::ObjectIdentifier->construct(
49             $args{object_identifier_type},
50             $args{object_identifier_instance},
51             0x00
52             )
53             ],
54             [
55             'property_identifier',
56             BACnet::DataTypes::Enum->construct(
57 2         24 $args{property_identifier}, 0x01
58             )
59             ],
60             ];
61              
62 2 100       8 if ( defined $args{property_array_index} ) {
63             push @$sequence_elements,
64             [
65             'property_array_index',
66             BACnet::DataTypes::UnsignedInt->construct(
67 1         13 $args{property_array_index}, 0x02
68             )
69             ];
70             }
71              
72 2         19 return BACnet::DataTypes::SequenceValue->construct($sequence_elements);
73             }
74              
75             our $negative_response_skeleton =
76             $BACnet::ServiceRequestSequences::Utils::error_type_skeleton;
77              
78             sub negative_response {
79 1     1 0 4563 return BACnet::ServiceRequestSequences::Utils::_error_type(@_);
80             }
81              
82             our $positive_response_skeleton = [
83             BACnet::DataTypes::Bone->construct(
84             tag => 0,
85             name => 'object_identifier',
86             dt => 'BACnet::DataTypes::ObjectIdentifier'
87             ),
88             BACnet::DataTypes::Bone->construct(
89             tag => 1,
90             name => 'property_identifier',
91             dt => 'BACnet::DataTypes::Enum'
92             ),
93             BACnet::DataTypes::Bone->construct(
94             tag => 2,
95             name => 'property_array_index',
96             dt => 'BACnet::DataTypes::UnsignedInt'
97             ),
98             BACnet::DataTypes::Bone->construct(
99             tag => 3,
100             name => 'property_value',
101             dt => 'property_identifier',
102             substitution =>
103             $BACnet::DataTypes::Enums::PropertyIdentifier::prop_type_type,
104             )
105              
106             ];
107              
108             sub positive_response {
109 2     2 0 27 my %args = (
110             object_identifier_type => undef,
111             object_identifier_instance => undef,
112             property_identifier => undef,
113             property_array_index => undef,
114             property_value => undef,
115             @_,
116             );
117              
118             my $sequence_elements = [
119             [
120             'object_identifier',
121             BACnet::DataTypes::ObjectIdentifier->construct(
122             $args{object_identifier_type},
123             $args{object_identifier_instance},
124             0x00
125             )
126             ],
127             [
128             'property_identifier',
129             BACnet::DataTypes::Enum->construct(
130 2         13 $args{property_identifier}, 0x01
131             )
132             ],
133             ];
134              
135 2 100       9 if ( defined $args{property_array_index} ) {
136             push @$sequence_elements,
137             [
138             'property_array_index',
139             BACnet::DataTypes::UnsignedInt->construct(
140 1         9 $args{property_array_index}, 0x02
141             )
142             ];
143             }
144              
145             #have to have context tag 0x03
146 2         8 push @$sequence_elements, [ 'property_value', $args{property_value}, ];
147              
148 2         29 return BACnet::DataTypes::SequenceValue->construct($sequence_elements);
149             }
150              
151             1;