blib/lib/Device/SaleaeLogic.pm untested

filter: Statementstmt 0.0% 0 / 69 Branchbran 0.0% 0 / 20 Conditioncond 0.0% 0 / 21 MC/DCmcdc 0.0% 0 / 14 Subroutinesub 0.0% 0 / 25 Podpod 0.0% 0 / 19 totaltotal 0.0% 0 / 168 CC 11 SCAR 29.3
CC
11
Cov
0%
new
72.0
DESTROY
6.0
set_use5volts
6.0
CRAP 18.7
1 package Device::SaleaeLogic;
2  
3 use 5.010001;
4 use strict;
5 use warnings;
6  
7 require Exporter;
8 use AutoLoader qw(AUTOLOAD);
9  
10 our @ISA = qw(Exporter);
11  
12 # Items to export into callers namespace by default. Note: do not export
13 # names by default without a very good reason. Use EXPORT_OK instead.
14 # Do not simply export all your public functions/methods/constants.
15  
16 # This allows declaration use Device::SaleaeLogic ':all';
17 # If you do not need this, moving things directly into @EXPORT or @EXPORT_OK
18 # will save memory.
19 our %EXPORT_TAGS = ( 'all' => [ qw(
20
21 ) ] );
22  
23 our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
24  
25 our @EXPORT = qw(
26
27 );
28  
29 our $VERSION = '0.02';
30  
31 require XSLoader;
32 XSLoader::load('Device::SaleaeLogic', $VERSION);
33  
34 # Preloaded methods go here.
35  
36 sub new {
37 my $self = shift;
38 my $class = ref($self) || $self;
39 my %args = @_;
40 my $this = bless({%args}, $class);
41 if ($args{verbose} or $args{debug}) {
42 saleaeinterface_verbose();
43 }
44 my $obj = saleaeinterface_new($this);
45 $this->{obj} = $obj;
46 if (exists $args{on_connect} and ref $args{on_connect} eq 'CODE') {
47 saleaeinterface_register_on_connect($obj, $args{on_connect});
48 }
49 if (exists $args{on_disconnect} and ref $args{on_disconnect} eq 'CODE') {
50 saleaeinterface_register_on_disconnect($obj, $args{on_disconnect});
51 }
52 if (exists $args{on_readdata} and ref $args{on_readdata} eq 'CODE') {
53 saleaeinterface_register_on_readdata($obj, $args{on_readdata});
54 }
55 if (exists $args{on_writedata} and ref $args{on_writedata} eq 'CODE') {
56 saleaeinterface_register_on_writedata($obj, $args{on_writedata});
57 }
58 if (exists $args{on_error} and ref $args{on_error} eq 'CODE') {
59 saleaeinterface_register_on_error($obj, $args{on_error});
60 }
61 if ($args{begin}) {
62 saleaeinterface_begin_connect($obj);
63 }
64 return $this;
65 }
66  
67 sub begin {
68 saleaeinterface_begin_connect($_[0]->{obj});
69 }
70  
71 sub DESTROY {
72 saleaeinterface_DESTROY($_[0]->{obj}) if $_[0]->{obj};
73 }
74  
75 sub is_usb2 {
76 return saleaeinterface_is_usb2($_[0]->{obj}, $_[1]);
77 }
78  
79 sub is_streaming {
80 return saleaeinterface_is_streaming($_[0]->{obj}, $_[1]);
81 }
82  
83 sub get_channel_count {
84 return saleaeinterface_get_channel_count($_[0]->{obj}, $_[1]);
85 }
86  
87 sub get_sample_rate {
88 return saleaeinterface_get_sample_rate($_[0]->{obj}, $_[1]);
89 }
90  
91 sub set_sample_rate {
92 saleaeinterface_set_sample_rate($_[0]->{obj}, $_[1], $_[2]);
93 }
94  
95 sub get_supported_sample_rates {
96 return saleaeinterface_get_supported_sample_rates($_[0]->{obj}, $_[1]);
97 }
98  
99 sub is_logic16 {
100 return saleaeinterface_is_logic16($_[0]->{obj}, $_[1]);
101 }
102  
103 sub is_logic {
104 return saleaeinterface_is_logic($_[0]->{obj}, $_[1]);
105 }
106  
107 sub get_device_id {
108 return saleaeinterface_get_device_id($_[0]->{obj}, $_[1]);
109 }
110  
111 sub read_start {
112 saleaeinterface_read_start($_[0]->{obj}, $_[1]);
113 }
114  
115 sub write_start {
116 saleaeinterface_write_start($_[0]->{obj}, $_[1]);
117 }
118  
119 sub stop {
120 saleaeinterface_stop($_[0]->{obj}, $_[1]);
121 }
122  
123 sub set_use5volts {
124 saleaeinterface_set_use5volts($_[0]->{obj}, $_[1], $_[2] ? 1 : 0);
125 }
126  
127 sub get_use5volts {
128 return saleaeinterface_get_use5volts($_[0]->{obj}, $_[1]);
129 }
130  
131 sub get_active_channels {
132 return saleaeinterface_get_active_channels($_[0]->{obj}, $_[1]);
133 }
134  
135 sub set_active_channels {
136 return unless ref $_[2] eq 'ARRAY';
137 saleaeinterface_set_active_channels($_[0]->{obj}, $_[1], $_[2]);
138 }
139  
140 # Autoload methods go after =cut, and are processed by the autosplit program.
141  
142 1;
143 __END__