line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# Rinchi Common Image Generator Interface for Perl |
3
|
|
|
|
|
|
|
# Class Identifier: f78b3ded-200e-11de-bdd4-001c25551abc |
4
|
|
|
|
|
|
|
# Author: Brian M. Ames |
5
|
|
|
|
|
|
|
# |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
package Rinchi::CIGIPP::ImageGeneratorMessage; |
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
26
|
use 5.006; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
43
|
|
10
|
1
|
|
|
1
|
|
7
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
39
|
|
11
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
235
|
|
12
|
1
|
|
|
1
|
|
6
|
use Carp; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
1650
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
require Exporter; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
our @ISA = qw(Exporter); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
# Items to export into callers namespace by default. Note: do not export |
19
|
|
|
|
|
|
|
# names by default without a very good reason. Use EXPORT_OK instead. |
20
|
|
|
|
|
|
|
# Do not simply export all your public functions/methods/constants. |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
# This allows declaration use Rinchi::CIGI::AtmosphereControl ':all'; |
23
|
|
|
|
|
|
|
# If you do not need this, moving things directly into @EXPORT or @EXPORT_OK |
24
|
|
|
|
|
|
|
# will save memory. |
25
|
|
|
|
|
|
|
our %EXPORT_TAGS = ( 'all' => [ qw( |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
) ] ); |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } ); |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
our @EXPORT = qw( |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
); |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
our $VERSION = '0.02'; |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
# Preloaded methods go here. |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=head1 NAME |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
Rinchi::CIGIPP::ImageGeneratorMessage - Perl extension for the Common Image |
42
|
|
|
|
|
|
|
Generator Interface - Image Generator Message data packet. |
43
|
|
|
|
|
|
|
data packet. |
44
|
|
|
|
|
|
|
=head1 SYNOPSIS |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
use Rinchi::CIGIPP::ImageGeneratorMessage; |
47
|
|
|
|
|
|
|
my $ig_msg = Rinchi::CIGIPP::ImageGeneratorMessage->new(); |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
$packet_type = $ig_msg->packet_type(); |
50
|
|
|
|
|
|
|
$packet_size = $ig_msg->packet_size(); |
51
|
|
|
|
|
|
|
$message_ident = $ig_msg->message_ident(32020); |
52
|
|
|
|
|
|
|
$message = $ig_msg->message('Error 1234'); |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=head1 DESCRIPTION |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
The Image Generator Message packet is used to pass error, debugging, and other |
57
|
|
|
|
|
|
|
text messages to the Host. |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
These messages may be saved to a log file and/or written to the console or |
60
|
|
|
|
|
|
|
other user interface. Because file and console I/O are not typically real-time |
61
|
|
|
|
|
|
|
in nature, it is recommended that the IG only send Image Generator Message |
62
|
|
|
|
|
|
|
packets while in Debug mode. |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
Each message is composed of multiple eight-bit character data. The text message |
65
|
|
|
|
|
|
|
must be terminated by NULL, or zero (0). If the terminating byte is not the |
66
|
|
|
|
|
|
|
last byte of the eight-byte double-word, then the remainder of the double-word |
67
|
|
|
|
|
|
|
must be padded with zeroes. Zero-length messages must be terminated with four |
68
|
|
|
|
|
|
|
bytes containing NULL (to maintain 64-bit alignment). The maximum text length |
69
|
|
|
|
|
|
|
is 100 characters, including a terminating NULL. |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=head2 EXPORT |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
None by default. |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
#============================================================================== |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=item new $ig_msg = Rinchi::CIGIPP::ImageGeneratorMessage->new() |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
Constructor for Rinchi::ImageGeneratorMessage. |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=cut |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
sub new { |
84
|
1
|
|
|
1
|
1
|
49
|
my $class = shift; |
85
|
1
|
|
33
|
|
|
15
|
$class = ref($class) || $class; |
86
|
|
|
|
|
|
|
|
87
|
1
|
|
|
|
|
16
|
my $self = { |
88
|
|
|
|
|
|
|
'_Buffer' => '', |
89
|
|
|
|
|
|
|
'_ClassIdent' => 'f78b3ded-200e-11de-bdd4-001c25551abc', |
90
|
|
|
|
|
|
|
'_Pack' => 'CCS', |
91
|
|
|
|
|
|
|
'_Swap1' => 'CCv', |
92
|
|
|
|
|
|
|
'_Swap2' => 'CCn', |
93
|
|
|
|
|
|
|
'packetType' => 117, |
94
|
|
|
|
|
|
|
'packetSize' => 8, |
95
|
|
|
|
|
|
|
'messageIdent' => 0, |
96
|
|
|
|
|
|
|
'message' => '', |
97
|
|
|
|
|
|
|
'_pad' => "\0\0\0\0", |
98
|
|
|
|
|
|
|
}; |
99
|
|
|
|
|
|
|
|
100
|
1
|
50
|
|
|
|
5
|
if (@_) { |
101
|
0
|
0
|
|
|
|
0
|
if (ref($_[0]) eq 'ARRAY') { |
|
|
0
|
|
|
|
|
|
102
|
0
|
|
|
|
|
0
|
$self->{'_Buffer'} = $_[0][0]; |
103
|
|
|
|
|
|
|
} elsif (ref($_[0]) eq 'HASH') { |
104
|
0
|
|
|
|
|
0
|
foreach my $attr (keys %{$_[0]}) { |
|
0
|
|
|
|
|
0
|
|
105
|
0
|
0
|
|
|
|
0
|
$self->{"_$attr"} = $_[0]->{$attr} unless ($attr =~ /^_/); |
106
|
|
|
|
|
|
|
} |
107
|
|
|
|
|
|
|
} |
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
|
110
|
1
|
|
|
|
|
3
|
bless($self,$class); |
111
|
1
|
|
|
|
|
3
|
return $self; |
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
#============================================================================== |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=item sub packet_type() |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
$value = $ig_msg->packet_type(); |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
Data Packet Identifier. |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
This attribute identifies this data packet as the Image Generation Message |
123
|
|
|
|
|
|
|
packet. The value of this attribute must be 117. |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=cut |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
sub packet_type() { |
128
|
1
|
|
|
1
|
1
|
6
|
my ($self) = @_; |
129
|
1
|
|
|
|
|
8
|
return $self->{'packetType'}; |
130
|
|
|
|
|
|
|
} |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
#============================================================================== |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=item sub packet_size([$newValue]) |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
$value = $ig_msg->packet_size($newValue); |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
Data Packet Size. |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
This attribute indicates the number of bytes in this data packet. The value of |
141
|
|
|
|
|
|
|
this attribute must be 4 plus the length of the message text, including NULL |
142
|
|
|
|
|
|
|
characters. The value of this attribute must be at least 8 and no more than 104 |
143
|
|
|
|
|
|
|
bytes. This allows for a message length of up to 100 characters, including the |
144
|
|
|
|
|
|
|
terminating NULL. |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
Note: Because all packets must begin and end on a 64-bit boundary, the value of |
147
|
|
|
|
|
|
|
this attribute must be an even multiple of eight (8). |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=cut |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
sub packet_size() { |
152
|
1
|
|
|
1
|
1
|
6
|
my ($self,$nv) = @_; |
153
|
1
|
50
|
|
|
|
11
|
if (defined($nv)) { |
154
|
0
|
|
|
|
|
0
|
$self->{'packetSize'} = $nv; |
155
|
|
|
|
|
|
|
} |
156
|
1
|
|
|
|
|
3
|
return $self->{'packetSize'}; |
157
|
|
|
|
|
|
|
} |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
#============================================================================== |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
=item sub message_ident([$newValue]) |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
$value = $ig_msg->message_ident($newValue); |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
Message ID. |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
This attribute specifies a numerical identifier for the message. |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
=cut |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
sub message_ident() { |
172
|
1
|
|
|
1
|
1
|
5
|
my ($self,$nv) = @_; |
173
|
1
|
50
|
|
|
|
9
|
if (defined($nv)) { |
174
|
1
|
|
|
|
|
2
|
$self->{'messageIdent'} = $nv; |
175
|
|
|
|
|
|
|
} |
176
|
1
|
|
|
|
|
3
|
return $self->{'messageIdent'}; |
177
|
|
|
|
|
|
|
} |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
#============================================================================== |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
=item sub message([$newValue]) |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
$value = $ig_msg->message($newValue); |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
Message string. |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
These 8-bit data are used to store the ANSI codes for each character in the |
188
|
|
|
|
|
|
|
message string. |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
Note: The maximum number of characters, including a terminating NULL, is 100. |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
=cut |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
sub message() { |
195
|
3
|
|
|
3
|
1
|
121
|
my ($self,$nv) = @_; |
196
|
3
|
50
|
|
|
|
8
|
if (defined($nv)) { |
197
|
3
|
|
|
|
|
5
|
my $len = length($nv); |
198
|
3
|
50
|
|
|
|
9
|
if ($len < 100) { |
199
|
3
|
|
|
|
|
7
|
$self->{'message'} = $nv; |
200
|
3
|
|
|
|
|
8
|
$self->{'_pad'} = substr("\0\0\0\0\0\0\0\0",(($len+4)%8)); |
201
|
3
|
|
|
|
|
8
|
$self->{'packetSize'} = $len + 4 + length($self->{'_pad'}); |
202
|
|
|
|
|
|
|
} else { |
203
|
0
|
|
|
|
|
0
|
carp "New value exceeds 99 bytes"; |
204
|
|
|
|
|
|
|
} |
205
|
|
|
|
|
|
|
} |
206
|
|
|
|
|
|
|
|
207
|
3
|
50
|
|
|
|
7
|
if (defined($nv)) { |
208
|
3
|
|
|
|
|
5
|
$self->{'message'} = $nv; |
209
|
|
|
|
|
|
|
} |
210
|
3
|
|
|
|
|
8
|
return $self->{'message'}; |
211
|
|
|
|
|
|
|
} |
212
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
#========================================================================== |
214
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
=item sub pack() |
216
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
$value = $ig_msg->pack(); |
218
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
Returns the packed data packet. |
220
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
=cut |
222
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
sub pack($) { |
224
|
4
|
|
|
4
|
1
|
16
|
my $self = shift ; |
225
|
|
|
|
|
|
|
|
226
|
4
|
|
|
|
|
18
|
$self->{'_Buffer'} = CORE::pack($self->{'_Pack'}, |
227
|
|
|
|
|
|
|
$self->{'packetType'}, |
228
|
|
|
|
|
|
|
$self->{'packetSize'}, |
229
|
|
|
|
|
|
|
$self->{'messageIdent'} |
230
|
|
|
|
|
|
|
) . $self->{'message'} . $self->{'_pad'}; |
231
|
|
|
|
|
|
|
|
232
|
4
|
|
|
|
|
10
|
return $self->{'_Buffer'}; |
233
|
|
|
|
|
|
|
} |
234
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
#========================================================================== |
236
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
=item sub unpack() |
238
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
$value = $ig_msg->unpack(); |
240
|
|
|
|
|
|
|
|
241
|
|
|
|
|
|
|
Unpacks the packed data packet. |
242
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
=cut |
244
|
|
|
|
|
|
|
|
245
|
|
|
|
|
|
|
sub unpack($) { |
246
|
0
|
|
|
0
|
1
|
|
my $self = shift @_; |
247
|
|
|
|
|
|
|
|
248
|
0
|
0
|
|
|
|
|
if (@_) { |
249
|
0
|
|
|
|
|
|
$self->{'_Buffer'} = shift @_; |
250
|
|
|
|
|
|
|
} |
251
|
0
|
|
|
|
|
|
my ($a,$b,$c) = CORE::unpack($self->{'_Pack'},$self->{'_Buffer'}); |
252
|
0
|
|
|
|
|
|
my $d = substr($self->{'_Buffer'},4); |
253
|
0
|
|
|
|
|
|
$d =~ s/(\0+)$//; |
254
|
0
|
|
|
|
|
|
my $e = $1; |
255
|
0
|
|
|
|
|
|
$self->{'packetType'} = $a; |
256
|
0
|
|
|
|
|
|
$self->{'packetSize'} = $b; |
257
|
0
|
|
|
|
|
|
$self->{'messageIdent'} = $c; |
258
|
0
|
|
|
|
|
|
$self->{'message'} = $d; |
259
|
0
|
|
|
|
|
|
$self->{'_pad'} = $e; |
260
|
|
|
|
|
|
|
|
261
|
0
|
|
|
|
|
|
return $self->{'_Buffer'}; |
262
|
|
|
|
|
|
|
} |
263
|
|
|
|
|
|
|
|
264
|
|
|
|
|
|
|
#========================================================================== |
265
|
|
|
|
|
|
|
|
266
|
|
|
|
|
|
|
=item sub byte_swap() |
267
|
|
|
|
|
|
|
|
268
|
|
|
|
|
|
|
$obj_name->byte_swap(); |
269
|
|
|
|
|
|
|
|
270
|
|
|
|
|
|
|
Byte swaps the packed data packet. |
271
|
|
|
|
|
|
|
|
272
|
|
|
|
|
|
|
=cut |
273
|
|
|
|
|
|
|
|
274
|
|
|
|
|
|
|
sub byte_swap($) { |
275
|
0
|
|
|
0
|
1
|
|
my $self = shift @_; |
276
|
|
|
|
|
|
|
|
277
|
0
|
0
|
|
|
|
|
if (@_) { |
278
|
0
|
|
|
|
|
|
$self->{'_Buffer'} = shift @_; |
279
|
|
|
|
|
|
|
} else { |
280
|
0
|
|
|
|
|
|
$self->pack(); |
281
|
|
|
|
|
|
|
} |
282
|
0
|
|
|
|
|
|
my ($a,$b,$c) = CORE::unpack($self->{'_Swap1'},$self->{'_Buffer'}); |
283
|
0
|
|
|
|
|
|
my $padded_message = substr($self->{'_Buffer'},4); |
284
|
|
|
|
|
|
|
|
285
|
0
|
|
|
|
|
|
$self->{'_Buffer'} = CORE::pack($self->{'_Swap2'},$a,$b,$c) . $padded_message; |
286
|
0
|
|
|
|
|
|
$self->unpack(); |
287
|
|
|
|
|
|
|
|
288
|
0
|
|
|
|
|
|
return $self->{'_Buffer'}; |
289
|
|
|
|
|
|
|
} |
290
|
|
|
|
|
|
|
|
291
|
|
|
|
|
|
|
1; |
292
|
|
|
|
|
|
|
__END__ |