File Coverage

blib/lib/Rinchi/CIGIPP/EventNotification.pm
Criterion Covered Total %
statement 42 192 21.8
branch 5 80 6.2
condition 1 3 33.3
subroutine 12 36 33.3
pod 32 32 100.0
total 92 343 26.8


line stmt bran cond sub pod time code
1             #
2             # Rinchi Common Image Generator Interface for Perl
3             # Class Identifier: f78b3dec-200e-11de-bdd4-001c25551abc
4             # Author: Brian M. Ames
5             #
6              
7             package Rinchi::CIGIPP::EventNotification;
8              
9 1     1   26 use 5.006;
  1         5  
  1         47  
10 1     1   7 use strict;
  1         3  
  1         36  
11 1     1   6 use warnings;
  1         2  
  1         40  
12 1     1   5 use Carp;
  1         3  
  1         4498  
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.01';
36              
37             # Preloaded methods go here.
38              
39             =head1 NAME
40              
41             Rinchi::CIGIPP::EventNotification - Perl extension for the Common Image
42             Generator Interface - Event Notification data packet.
43             data packet.
44             =head1 SYNOPSIS
45              
46             use Rinchi::CIGIPP::EventNotification;
47             my $evt_ntc = Rinchi::CIGIPP::EventNotification->new();
48              
49             $packet_type = $evt_ntc->packet_type();
50             $packet_size = $evt_ntc->packet_size();
51             $event_ident = $evt_ntc->event_ident(37952);
52             $event_data1 = $evt_ntc->event_data1(285);
53             $event_data2 = $evt_ntc->event_data2(36545);
54             $event_data3 = $evt_ntc->event_data3(12715);
55              
56             =head1 DESCRIPTION
57              
58             The Event Notification packet is used to pass event data to the Host. The Host
59             may enable and disable individual events using either the Component Control or
60             Short Component Control packet.
61              
62             This packet contains three user-defined 32-bit word values that may contain
63             data describing the attributes of the event (e.g., time of occurrence,
64             position). These data may be formatted as needed; however, they must be
65             byte-swapped as 32-bit fields when byte swapping is necessary. Refer to the
66             description of the Component Control packet for more information.
67              
68             =head2 EXPORT
69              
70             None by default.
71              
72             #==============================================================================
73              
74             =item new $evt_ntc = Rinchi::CIGIPP::EventNotification->new()
75              
76             Constructor for Rinchi::EventNotification.
77              
78             =cut
79              
80             sub new {
81 1     1 1 47 my $class = shift;
82 1   33     7 $class = ref($class) || $class;
83              
84 1         10 my $self = {
85             '_Buffer' => '',
86             '_ClassIdent' => 'f78b3dec-200e-11de-bdd4-001c25551abc',
87             '_Pack' => 'CCSIII',
88             '_Swap1' => 'CCvVVV',
89             '_Swap2' => 'CCnNNN',
90             'packetType' => 116,
91             'packetSize' => 16,
92             'eventIdent' => 0,
93             'eventData1' => 0,
94             'eventData2' => 0,
95             'eventData3' => 0,
96             };
97              
98 1 50       3 if (@_) {
99 0 0       0 if (ref($_[0]) eq 'ARRAY') {
    0          
100 0         0 $self->{'_Buffer'} = $_[0][0];
101             } elsif (ref($_[0]) eq 'HASH') {
102 0         0 foreach my $attr (keys %{$_[0]}) {
  0         0  
103 0 0       0 $self->{"_$attr"} = $_[0]->{$attr} unless ($attr =~ /^_/);
104             }
105             }
106             }
107 1         7 $self->{'_LittleEndian'} = (CORE::unpack('v',CORE::pack('S',0x8000)) == 0x8000);
108              
109 1         2 bless($self,$class);
110 1         4 return $self;
111             }
112              
113             #==============================================================================
114              
115             =item sub packet_type()
116              
117             $value = $evt_ntc->packet_type();
118              
119             Data Packet Identifier.
120              
121             This attribute identifies this data packet as the Event Notification packet.
122             The value of this attribute must be 116.
123              
124             =cut
125              
126             sub packet_type() {
127 1     1 1 6 my ($self) = @_;
128 1         7 return $self->{'packetType'};
129             }
130              
131             #==============================================================================
132              
133             =item sub packet_size()
134              
135             $value = $evt_ntc->packet_size();
136              
137             Data Packet Size.
138              
139             This attribute indicates the number of bytes in this data packet. The value of
140             this attribute must be 16.
141              
142             =cut
143              
144             sub packet_size() {
145 1     1 1 5 my ($self) = @_;
146 1         3 return $self->{'packetSize'};
147             }
148              
149             #==============================================================================
150              
151             =item sub event_ident([$newValue])
152              
153             $value = $evt_ntc->event_ident($newValue);
154              
155             Event ID.
156              
157             This attribute indicates which event has occurred. Event ID assignments are IG-specific.
158              
159             =cut
160              
161             sub event_ident() {
162 1     1 1 6 my ($self,$nv) = @_;
163 1 50       4 if (defined($nv)) {
164 1         2 $self->{'eventIdent'} = $nv;
165             }
166 1         3 return $self->{'eventIdent'};
167             }
168              
169             #==============================================================================
170              
171             =item sub event_data1([$newValue])
172              
173             $value = $evt_ntc->event_data1($newValue);
174              
175             Event Data 1.
176              
177             This attribute is one of three 32-bit words used for user-defined event data.
178             If this attribute is not needed to describe the event, this value is ignored.
179              
180             Note: This attribute will be byte-swapped as a 32-bit value if the receiver and
181             sender use different byte ordering schemes. If the attribute is used to store
182             multiple 8- or 16-bit values, the data should be packed so that byte swapping
183             will be performed correctly. Use event_data1_short1 and event_data1_short2 for
184             16-bit values, or event_data1_byte1, event_data1_byte2, event_data1_byte3, and
185             event_data1_byte4 for 8-bit values.
186              
187             =cut
188              
189             sub event_data1() {
190 1     1 1 5 my ($self,$nv) = @_;
191 1 50       17 if (defined($nv)) {
192 1         2 $self->{'eventData1'} = $nv;
193             }
194 1         3 return $self->{'eventData1'};
195             }
196              
197             #==============================================================================
198              
199             =item sub event_data1_float([$newValue])
200              
201             $value = $evt_ntc->event_data1_float($newValue);
202              
203             Event Data 1.
204              
205             This attribute represents as a float one of three 32-bit words used for user-defined
206             event data. If this attribute is not needed by the event, this value is
207             ignored.
208              
209             Note: This attribute will be byte-swapped as a 32-bit value if the receiver and
210             sender use different byte ordering schemes. If the attribute is used to store
211             multiple 8- or 16-bit values, the data should be packed so that byte swapping
212             will be performed correctly.
213              
214             =cut
215              
216             sub event_data1_float() {
217 0     0 1 0 my ($self,$nv) = @_;
218 0 0       0 if (defined($nv)) {
219 0         0 my $nvp = CORE::pack('f',$nv);
220 0 0       0 if($self->{'_LittleEndian'}) {
221 0         0 $self->{'eventData1'} = CORE::unpack('V',$nvp);
222             } else {
223 0         0 $self->{'eventData1'} = CORE::unpack('N',$nvp);
224             }
225             }
226 0 0       0 if($self->{'_LittleEndian'}) {
227 0         0 return CORE::unpack('f',CORE::pack('V',$self->{'eventData1'}));
228             } else {
229 0         0 return CORE::unpack('f',CORE::pack('N',$self->{'eventData1'}));
230             }
231             }
232              
233             #==============================================================================
234              
235             =item sub event_data1_short1([$newValue])
236              
237             $value = $evt_ntc->event_data1_short1($newValue);
238              
239             Event Data 1.
240              
241             This attribute represents as a short the two most significant bytes of one of
242             three 32-bit words used for user-defined event data. If this attribute is not
243             needed by the event, this value is ignored.
244              
245             Note: This attribute will be byte-swapped as a 32-bit value if the receiver and
246             sender use different byte ordering schemes. If the attribute is used to store
247             multiple 8- or 16-bit values, the data should be packed so that byte swapping
248             will be performed correctly.
249              
250             =cut
251              
252             sub event_data1_short1() {
253 0     0 1 0 my ($self,$nv) = @_;
254 0 0       0 if (defined($nv)) {
255 0         0 $nv = (($nv & 0xFFFF) << 16) | ($self->{'eventData1'} & 0xFFFF);
256 0         0 $self->{'eventData1'} = $nv;
257             }
258 0         0 return ($self->{'eventData1'} >> 16) & 0xFFFF;
259             }
260              
261             #==============================================================================
262              
263             =item sub event_data1_short2([$newValue])
264              
265             $value = $evt_ntc->event_data1_short2($newValue);
266              
267             Event Data 1.
268              
269             This attribute represents as a short the two least significant bytes of one of
270             three 32-bit words used for user-defined event data. If this attribute is not
271             needed by the event, this value is ignored.
272              
273             Note: This attribute will be byte-swapped as a 32-bit value if the receiver and
274             sender use different byte ordering schemes. If the attribute is used to store
275             multiple 8- or 16-bit values, the data should be packed so that byte swapping
276             will be performed correctly.
277              
278             =cut
279              
280             sub event_data1_short2() {
281 0     0 1 0 my ($self,$nv) = @_;
282 0 0       0 if (defined($nv)) {
283 0         0 $nv = ($nv & 0xFFFF) | ($self->{'eventData1'} & 0xFFFF0000);
284 0         0 $self->{'eventData1'} = $nv;
285             }
286 0         0 return $self->{'eventData1'} & 0xFFFF;
287             }
288              
289             #==============================================================================
290              
291             =item sub event_data1_byte1([$newValue])
292              
293             $value = $evt_ntc->event_data1_byte1($newValue);
294              
295             Event Data 1.
296              
297             This attribute represents the most significant byte of one of
298             three 32-bit words used for user-defined event data. If this attribute is not
299             needed by the event, this value is ignored.
300              
301             Note: This attribute will be byte-swapped as a 32-bit value if the receiver and
302             sender use different byte ordering schemes. If the attribute is used to store
303             multiple 8- or 16-bit values, the data should be packed so that byte swapping
304             will be performed correctly.
305              
306             =cut
307              
308             sub event_data1_byte1() {
309 0     0 1 0 my ($self,$nv) = @_;
310 0 0       0 if (defined($nv)) {
311 0         0 $nv = (($nv & 0xFF) << 24) | ($self->{'eventData1'} & 0xFFFFFF);
312 0         0 $self->{'eventData1'} = $nv;
313             }
314 0         0 return ($self->{'eventData1'} >> 24) & 0xFF;
315             }
316              
317             #==============================================================================
318              
319             =item sub event_data1_byte2([$newValue])
320              
321             $value = $evt_ntc->event_data1_byte2($newValue);
322              
323             Event Data 1.
324              
325             This attribute represents the second most significant byte of one of
326             three 32-bit words used for user-defined event data. If this attribute is not
327             needed by the event, this value is ignored.
328              
329             Note: This attribute will be byte-swapped as a 32-bit value if the receiver and
330             sender use different byte ordering schemes. If the attribute is used to store
331             multiple 8- or 16-bit values, the data should be packed so that byte swapping
332             will be performed correctly.
333              
334             =cut
335              
336             sub event_data1_byte2() {
337 0     0 1 0 my ($self,$nv) = @_;
338 0 0       0 if (defined($nv)) {
339 0         0 $nv = (($nv & 0xFF) << 16) | ($self->{'eventData1'} & 0xFF00FFFF);
340 0         0 $self->{'eventData1'} = $nv;
341             }
342 0         0 return ($self->{'eventData1'} >> 16) & 0xFF;
343             }
344              
345             #==============================================================================
346              
347             =item sub event_data1_byte3([$newValue])
348              
349             $value = $evt_ntc->event_data1_byte3($newValue);
350              
351             Event Data 1.
352              
353             This attribute represents the second least significant byte of one of
354             three 32-bit words used for user-defined event data. If this attribute is not
355             needed by the event, this value is ignored.
356              
357             Note: This attribute will be byte-swapped as a 32-bit value if the receiver and
358             sender use different byte ordering schemes. If the attribute is used to store
359             multiple 8- or 16-bit values, the data should be packed so that byte swapping
360             will be performed correctly.
361              
362             =cut
363              
364             sub event_data1_byte3() {
365 0     0 1 0 my ($self,$nv) = @_;
366 0 0       0 if (defined($nv)) {
367 0         0 $nv = (($nv & 0xFF) << 8) | ($self->{'eventData1'} & 0xFFFF00FF);
368 0         0 $self->{'eventData1'} = $nv;
369             }
370 0         0 return ($self->{'eventData1'} >> 8) & 0xFF;
371             }
372              
373             #==============================================================================
374              
375             =item sub event_data1_byte4([$newValue])
376              
377             $value = $evt_ntc->event_data1_byte4($newValue);
378              
379             Event Data 1.
380              
381             This attribute represents the least significant byte of one of
382             three 32-bit words used for user-defined event data. If this attribute is not
383             needed by the event, this value is ignored.
384              
385             Note: This attribute will be byte-swapped as a 32-bit value if the receiver and
386             sender use different byte ordering schemes. If the attribute is used to store
387             multiple 8- or 16-bit values, the data should be packed so that byte swapping
388             will be performed correctly.
389              
390             =cut
391              
392             sub event_data1_byte4() {
393 0     0 1 0 my ($self,$nv) = @_;
394 0 0       0 if (defined($nv)) {
395 0         0 $nv = ($nv & 0xFF) | ($self->{'eventData1'} & 0xFFFFFF00);
396 0         0 $self->{'eventData1'} = $nv;
397             }
398 0         0 return $self->{'eventData1'} & 0xFF;
399             }
400              
401             #==============================================================================
402              
403             =item sub event_data1_and_2_double([$newValue])
404              
405             $value = $evt_ntc->event_data1_and_2_double($newValue);
406              
407             Event Data 1.
408              
409             This attribute represents as a double two of three 32-bit words used for user-defined
410             event data. If this attribute is not needed by the event, this value is
411             ignored.
412              
413             Note: This attribute will be byte-swapped as a 32-bit value if the receiver and
414             sender use different byte ordering schemes. If the attribute is used to store
415             multiple 8- or 16-bit values, the data should be packed so that byte swapping
416             will be performed correctly.
417              
418             =cut
419              
420             sub event_data1_and_2_double() {
421 0     0 1 0 my ($self,$nv) = @_;
422 0 0       0 if (defined($nv)) {
423 0         0 my $nvp = CORE::pack('d',$nv);
424 0 0       0 if($self->{'_LittleEndian'}) {
425 0         0 ($self->{'eventData2'}, $self->{'eventData1'}) = CORE::unpack('VV',$nvp);
426             } else {
427 0         0 ($self->{'eventData1'}, $self->{'eventData2'}) = CORE::unpack('NN',$nvp);
428             }
429             }
430 0 0       0 if($self->{'_LittleEndian'}) {
431 0         0 return CORE::unpack('d',CORE::pack('VV',$self->{'eventData2'}, $self->{'eventData1'}));
432             } else {
433 0         0 return CORE::unpack('d',CORE::pack('NV',$self->{'eventData1'}, $self->{'eventData2'}));
434             }
435             }
436              
437             #==============================================================================
438              
439             =item sub event_data2([$newValue])
440              
441             $value = $evt_ntc->event_data2($newValue);
442              
443             Event Data 2.
444              
445             This attribute is one of three 32-bit words used for user-defined event data.
446             If this attribute is not needed to describe the event, this value is ignored.
447              
448             Note: This attribute will be byte-swapped as a 32-bit value if the receiver and
449             sender use different byte ordering schemes. If the attribute is used to store
450             multiple 8- or 16-bit values, the data should be packed so that byte swapping
451             will be performed correctly. Use event_data2_short1 and event_data2_short2 for
452             16-bit values, or event_data2_byte1, event_data2_byte2, event_data2_byte3, and
453             event_data2_byte4 for 8-bit values.
454              
455             =cut
456              
457             sub event_data2() {
458 1     1 1 6 my ($self,$nv) = @_;
459 1 50       4 if (defined($nv)) {
460 1         2 $self->{'eventData2'} = $nv;
461             }
462 1         3 return $self->{'eventData2'};
463             }
464              
465             #==============================================================================
466              
467             =item sub event_data2_float([$newValue])
468              
469             $value = $evt_ntc->event_data2_float($newValue);
470              
471             Event Data 2.
472              
473             This attribute represents as a float one of three 32-bit words used for user-defined
474             event data. If this attribute is not needed by the event, this value is
475             ignored.
476              
477             Note: This attribute will be byte-swapped as a 32-bit value if the receiver and
478             sender use different byte ordering schemes. If the attribute is used to store
479             multiple 8- or 16-bit values, the data should be packed so that byte swapping
480             will be performed correctly.
481              
482             =cut
483              
484             sub event_data2_float() {
485 0     0 1 0 my ($self,$nv) = @_;
486 0 0       0 if (defined($nv)) {
487 0         0 my $nvp = CORE::pack('f',$nv);
488 0 0       0 if($self->{'_LittleEndian'}) {
489 0         0 $self->{'eventData2'} = CORE::unpack('V',$nvp);
490             } else {
491 0         0 $self->{'eventData2'} = CORE::unpack('N',$nvp);
492             }
493             }
494 0 0       0 if($self->{'_LittleEndian'}) {
495 0         0 return CORE::unpack('f',CORE::pack('V',$self->{'eventData2'}));
496             } else {
497 0         0 return CORE::unpack('f',CORE::pack('N',$self->{'eventData2'}));
498             }
499             }
500              
501             #==============================================================================
502              
503             =item sub event_data2_short1([$newValue])
504              
505             $value = $evt_ntc->event_data2_short1($newValue);
506              
507             Event Data 2.
508              
509             This attribute represents as a short the two most significant bytes of one of
510             three 32-bit words used for user-defined event data. If this attribute is not
511             needed by the event, this value is ignored.
512              
513             Note: This attribute will be byte-swapped as a 32-bit value if the receiver and
514             sender use different byte ordering schemes. If the attribute is used to store
515             multiple 8- or 16-bit values, the data should be packed so that byte swapping
516             will be performed correctly.
517              
518             =cut
519              
520             sub event_data2_short1() {
521 0     0 1 0 my ($self,$nv) = @_;
522 0 0       0 if (defined($nv)) {
523 0         0 $nv = (($nv & 0xFFFF) << 16) | ($self->{'eventData2'} & 0xFFFF);
524 0         0 $self->{'eventData2'} = $nv;
525             }
526 0         0 return ($self->{'eventData2'} >> 16) & 0xFFFF;
527             }
528              
529             #==============================================================================
530              
531             =item sub event_data2_short2([$newValue])
532              
533             $value = $evt_ntc->event_data2_short2($newValue);
534              
535             Event Data 2.
536              
537             This attribute represents as a short the two least significant bytes of one of
538             three 32-bit words used for user-defined event data. If this attribute is not
539             needed by the event, this value is ignored.
540              
541             Note: This attribute will be byte-swapped as a 32-bit value if the receiver and
542             sender use different byte ordering schemes. If the attribute is used to store
543             multiple 8- or 16-bit values, the data should be packed so that byte swapping
544             will be performed correctly.
545              
546             =cut
547              
548             sub event_data2_short2() {
549 0     0 1 0 my ($self,$nv) = @_;
550 0 0       0 if (defined($nv)) {
551 0         0 $nv = ($nv & 0xFFFF) | ($self->{'eventData2'} & 0xFFFF0000);
552 0         0 $self->{'eventData2'} = $nv;
553             }
554 0         0 return $self->{'eventData2'} & 0xFFFF;
555             }
556              
557             #==============================================================================
558              
559             =item sub event_data2_byte1([$newValue])
560              
561             $value = $evt_ntc->event_data2_byte1($newValue);
562              
563             Event Data 2.
564              
565             This attribute represents the most significant byte of one of
566             three 32-bit words used for user-defined event data. If this attribute is not
567             needed by the event, this value is ignored.
568              
569             Note: This attribute will be byte-swapped as a 32-bit value if the receiver and
570             sender use different byte ordering schemes. If the attribute is used to store
571             multiple 8- or 16-bit values, the data should be packed so that byte swapping
572             will be performed correctly.
573              
574             =cut
575              
576             sub event_data2_byte1() {
577 0     0 1 0 my ($self,$nv) = @_;
578 0 0       0 if (defined($nv)) {
579 0         0 $nv = (($nv & 0xFF) << 24) | ($self->{'eventData2'} & 0xFFFFFF);
580 0         0 $self->{'eventData2'} = $nv;
581             }
582 0         0 return ($self->{'eventData2'} >> 24) & 0xFF;
583             }
584              
585             #==============================================================================
586              
587             =item sub event_data2_byte2([$newValue])
588              
589             $value = $evt_ntc->event_data2_byte2($newValue);
590              
591             Event Data 2.
592              
593             This attribute represents the second most significant byte of one of
594             three 32-bit words used for user-defined event data. If this attribute is not
595             needed by the event, this value is ignored.
596              
597             Note: This attribute will be byte-swapped as a 32-bit value if the receiver and
598             sender use different byte ordering schemes. If the attribute is used to store
599             multiple 8- or 16-bit values, the data should be packed so that byte swapping
600             will be performed correctly.
601              
602             =cut
603              
604             sub event_data2_byte2() {
605 0     0 1 0 my ($self,$nv) = @_;
606 0 0       0 if (defined($nv)) {
607 0         0 $nv = (($nv & 0xFF) << 16) | ($self->{'eventData2'} & 0xFF00FFFF);
608 0         0 $self->{'eventData2'} = $nv;
609             }
610 0         0 return ($self->{'eventData2'} >> 16) & 0xFF;
611             }
612              
613             #==============================================================================
614              
615             =item sub event_data2_byte3([$newValue])
616              
617             $value = $evt_ntc->event_data2_byte3($newValue);
618              
619             Event Data 2.
620              
621             This attribute represents the second least significant byte of one of
622             three 32-bit words used for user-defined event data. If this attribute is not
623             needed by the event, this value is ignored.
624              
625             Note: This attribute will be byte-swapped as a 32-bit value if the receiver and
626             sender use different byte ordering schemes. If the attribute is used to store
627             multiple 8- or 16-bit values, the data should be packed so that byte swapping
628             will be performed correctly.
629              
630             =cut
631              
632             sub event_data2_byte3() {
633 0     0 1 0 my ($self,$nv) = @_;
634 0 0       0 if (defined($nv)) {
635 0         0 $nv = (($nv & 0xFF) << 8) | ($self->{'eventData2'} & 0xFFFF00FF);
636 0         0 $self->{'eventData2'} = $nv;
637             }
638 0         0 return ($self->{'eventData2'} >> 8) & 0xFF;
639             }
640              
641             #==============================================================================
642              
643             =item sub event_data2_byte4([$newValue])
644              
645             $value = $evt_ntc->event_data2_byte4($newValue);
646              
647             Event Data 2.
648              
649             This attribute represents the least significant byte of one of
650             three 32-bit words used for user-defined event data. If this attribute is not
651             needed by the event, this value is ignored.
652              
653             Note: This attribute will be byte-swapped as a 32-bit value if the receiver and
654             sender use different byte ordering schemes. If the attribute is used to store
655             multiple 8- or 16-bit values, the data should be packed so that byte swapping
656             will be performed correctly.
657              
658             =cut
659              
660             sub event_data2_byte4() {
661 0     0 1 0 my ($self,$nv) = @_;
662 0 0       0 if (defined($nv)) {
663 0         0 $nv = ($nv & 0xFF) | ($self->{'eventData2'} & 0xFFFFFF00);
664 0         0 $self->{'eventData2'} = $nv;
665             }
666 0         0 return $self->{'eventData2'} & 0xFF;
667             }
668              
669             #==============================================================================
670              
671             =item sub event_data3([$newValue])
672              
673             $value = $evt_ntc->event_data3($newValue);
674              
675             Event Data 3.
676              
677             This attribute is one of three 32-bit words used for user-defined event data.
678             If this attribute is not needed to describe the event, this value is ignored.
679              
680             Note: This attribute will be byte-swapped as a 32-bit value if the receiver and
681             sender use different byte ordering schemes. If the attribute is used to store
682             multiple 8- or 16-bit values, the data should be packed so that byte swapping
683             will be performed correctly. Use event_data3_short1 and event_data3_short2 for
684             16-bit values, or event_data3_byte1, event_data3_byte2, event_data3_byte3, and
685             event_data3_byte4 for 8-bit values.
686              
687             =cut
688              
689             sub event_data3() {
690 1     1 1 5 my ($self,$nv) = @_;
691 1 50       4 if (defined($nv)) {
692 1         2 $self->{'eventData3'} = $nv;
693             }
694 1         3 return $self->{'eventData3'};
695             }
696              
697             #==========================================================================
698              
699             =item sub pack()
700              
701             $value = $evt_ntc->pack();
702              
703             Returns the packed data packet.
704              
705             =cut
706              
707             sub pack($) {
708 1     1 1 5 my $self = shift ;
709            
710 1         5 $self->{'_Buffer'} = CORE::pack($self->{'_Pack'},
711             $self->{'packetType'},
712             $self->{'packetSize'},
713             $self->{'eventIdent'},
714             $self->{'eventData1'},
715             $self->{'eventData2'},
716             $self->{'eventData3'},
717             );
718              
719 1         4 return $self->{'_Buffer'};
720             }
721              
722             #==========================================================================
723              
724             =item sub unpack()
725              
726             $value = $evt_ntc->unpack();
727              
728             Unpacks the packed data packet.
729              
730             =cut
731              
732             sub unpack($) {
733 0     0 1   my $self = shift @_;
734            
735 0 0         if (@_) {
736 0           $self->{'_Buffer'} = shift @_;
737             }
738 0           my ($a,$b,$c,$d,$e,$f) = CORE::unpack($self->{'_Pack'},$self->{'_Buffer'});
739 0           $self->{'packetType'} = $a;
740 0           $self->{'packetSize'} = $b;
741 0           $self->{'eventIdent'} = $c;
742 0           $self->{'eventData1'} = $d;
743 0           $self->{'eventData2'} = $e;
744 0           $self->{'eventData3'} = $f;
745              
746 0           return $self->{'_Buffer'};
747             }
748              
749             #==========================================================================
750              
751             =item sub byte_swap()
752              
753             $obj_name->byte_swap();
754              
755             Byte swaps the packed data packet.
756              
757             =cut
758              
759             sub byte_swap($) {
760 0     0 1   my $self = shift @_;
761            
762 0 0         if (@_) {
763 0           $self->{'_Buffer'} = shift @_;
764             } else {
765 0           $self->pack();
766             }
767 0           my ($a,$b,$c,$d,$e,$f) = CORE::unpack($self->{'_Swap1'},$self->{'_Buffer'});
768              
769 0           $self->{'_Buffer'} = CORE::pack($self->{'_Swap2'},$a,$b,$c,$d,$e,$f);
770 0           $self->unpack();
771              
772 0           return $self->{'_Buffer'};
773             }
774              
775             #==============================================================================
776              
777             =item sub event_data3_float([$newValue])
778              
779             $value = $evt_ntc->event_data3_float($newValue);
780              
781             Event Data 3.
782              
783             This attribute represents as a float one of three 32-bit words used for user-defined
784             event data. If this attribute is not needed by the event, this value is
785             ignored.
786              
787             Note: This attribute will be byte-swapped as a 32-bit value if the receiver and
788             sender use different byte ordering schemes. If the attribute is used to store
789             multiple 8- or 16-bit values, the data should be packed so that byte swapping
790             will be performed correctly.
791              
792             =cut
793              
794             sub event_data3_float() {
795 0     0 1   my ($self,$nv) = @_;
796 0 0         if (defined($nv)) {
797 0           my $nvp = CORE::pack('f',$nv);
798 0 0         if($self->{'_LittleEndian'}) {
799 0           $self->{'eventData3'} = CORE::unpack('V',$nvp);
800             } else {
801 0           $self->{'eventData3'} = CORE::unpack('N',$nvp);
802             }
803             }
804 0 0         if($self->{'_LittleEndian'}) {
805 0           return CORE::unpack('f',CORE::pack('V',$self->{'eventData3'}));
806             } else {
807 0           return CORE::unpack('f',CORE::pack('N',$self->{'eventData3'}));
808             }
809             }
810              
811             #==============================================================================
812              
813             =item sub event_data3_short1([$newValue])
814              
815             $value = $evt_ntc->event_data3_short1($newValue);
816              
817             Event Data 3.
818              
819             This attribute represents as a short the two most significant bytes of one of
820             three 32-bit words used for user-defined event data. If this attribute is not
821             needed by the event, this value is ignored.
822              
823             Note: This attribute will be byte-swapped as a 32-bit value if the receiver and
824             sender use different byte ordering schemes. If the attribute is used to store
825             multiple 8- or 16-bit values, the data should be packed so that byte swapping
826             will be performed correctly.
827              
828             =cut
829              
830             sub event_data3_short1() {
831 0     0 1   my ($self,$nv) = @_;
832 0 0         if (defined($nv)) {
833 0           $nv = (($nv & 0xFFFF) << 16) | ($self->{'eventData3'} & 0xFFFF);
834 0           $self->{'eventData3'} = $nv;
835             }
836 0           return ($self->{'eventData3'} >> 16) & 0xFFFF;
837             }
838              
839             #==============================================================================
840              
841             =item sub event_data3_short2([$newValue])
842              
843             $value = $evt_ntc->event_data3_short2($newValue);
844              
845             Event Data 3.
846              
847             This attribute represents as a short the two least significant bytes of one of
848             three 32-bit words used for user-defined event data. If this attribute is not
849             needed by the event, this value is ignored.
850              
851             Note: This attribute will be byte-swapped as a 32-bit value if the receiver and
852             sender use different byte ordering schemes. If the attribute is used to store
853             multiple 8- or 16-bit values, the data should be packed so that byte swapping
854             will be performed correctly.
855              
856             =cut
857              
858             sub event_data3_short2() {
859 0     0 1   my ($self,$nv) = @_;
860 0 0         if (defined($nv)) {
861 0           $nv = ($nv & 0xFFFF) | ($self->{'eventData3'} & 0xFFFF0000);
862 0           $self->{'eventData3'} = $nv;
863             }
864 0           return $self->{'eventData3'} & 0xFFFF;
865             }
866              
867             #==============================================================================
868              
869             =item sub event_data3_byte1([$newValue])
870              
871             $value = $evt_ntc->event_data3_byte1($newValue);
872              
873             Event Data 3.
874              
875             This attribute represents the most significant byte of one of
876             three 32-bit words used for user-defined event data. If this attribute is not
877             needed by the event, this value is ignored.
878              
879             Note: This attribute will be byte-swapped as a 32-bit value if the receiver and
880             sender use different byte ordering schemes. If the attribute is used to store
881             multiple 8- or 16-bit values, the data should be packed so that byte swapping
882             will be performed correctly.
883              
884             =cut
885              
886             sub event_data3_byte1() {
887 0     0 1   my ($self,$nv) = @_;
888 0 0         if (defined($nv)) {
889 0           $nv = (($nv & 0xFF) << 24) | ($self->{'eventData3'} & 0xFFFFFF);
890 0           $self->{'eventData3'} = $nv;
891             }
892 0           return ($self->{'eventData3'} >> 24) & 0xFF;
893             }
894              
895             #==============================================================================
896              
897             =item sub event_data3_byte2([$newValue])
898              
899             $value = $evt_ntc->event_data3_byte2($newValue);
900              
901             Event Data 3.
902              
903             This attribute represents the second most significant byte of one of
904             three 32-bit words used for user-defined event data. If this attribute is not
905             needed by the event, this value is ignored.
906              
907             Note: This attribute will be byte-swapped as a 32-bit value if the receiver and
908             sender use different byte ordering schemes. If the attribute is used to store
909             multiple 8- or 16-bit values, the data should be packed so that byte swapping
910             will be performed correctly.
911              
912             =cut
913              
914             sub event_data3_byte2() {
915 0     0 1   my ($self,$nv) = @_;
916 0 0         if (defined($nv)) {
917 0           $nv = (($nv & 0xFF) << 16) | ($self->{'eventData3'} & 0xFF00FFFF);
918 0           $self->{'eventData3'} = $nv;
919             }
920 0           return ($self->{'eventData3'} >> 16) & 0xFF;
921             }
922              
923             #==============================================================================
924              
925             =item sub event_data3_byte3([$newValue])
926              
927             $value = $evt_ntc->event_data3_byte3($newValue);
928              
929             Event Data 3.
930              
931             This attribute represents the second least significant byte of one of
932             three 32-bit words used for user-defined event data. If this attribute is not
933             needed by the event, this value is ignored.
934              
935             Note: This attribute will be byte-swapped as a 32-bit value if the receiver and
936             sender use different byte ordering schemes. If the attribute is used to store
937             multiple 8- or 16-bit values, the data should be packed so that byte swapping
938             will be performed correctly.
939              
940             =cut
941              
942             sub event_data3_byte3() {
943 0     0 1   my ($self,$nv) = @_;
944 0 0         if (defined($nv)) {
945 0           $nv = (($nv & 0xFF) << 8) | ($self->{'eventData3'} & 0xFFFF00FF);
946 0           $self->{'eventData3'} = $nv;
947             }
948 0           return ($self->{'eventData3'} >> 8) & 0xFF;
949             }
950              
951             #==============================================================================
952              
953             =item sub event_data3_byte4([$newValue])
954              
955             $value = $evt_ntc->event_data3_byte4($newValue);
956              
957             Event Data 3.
958              
959             This attribute represents the least significant byte of one of
960             three 32-bit words used for user-defined event data. If this attribute is not
961             needed by the event, this value is ignored.
962              
963             Note: This attribute will be byte-swapped as a 32-bit value if the receiver and
964             sender use different byte ordering schemes. If the attribute is used to store
965             multiple 8- or 16-bit values, the data should be packed so that byte swapping
966             will be performed correctly.
967              
968             =cut
969              
970             sub event_data3_byte4() {
971 0     0 1   my ($self,$nv) = @_;
972 0 0         if (defined($nv)) {
973 0           $nv = ($nv & 0xFF) | ($self->{'eventData3'} & 0xFFFFFF00);
974 0           $self->{'eventData3'} = $nv;
975             }
976 0           return $self->{'eventData3'} & 0xFF;
977             }
978              
979             #==============================================================================
980              
981             1;
982             __END__