Moose/Connection/VISA/USB.pm untested

filter: Statementstmt 0.0% 0 / 32 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 6 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 43 SCAR 24.8
CC
3
Cov
0%
gen_resource_name
12.0
BEGIN
2.0
BEGIN
2.0
CRAP 12.0
1 package Lab::Moose::Connection::VISA::USB;
2 $Lab::Moose::Connection::VISA::USB::VERSION = '3.881';
3 #ABSTRACT: USB-TMC frontend to National Instruments' VISA library.
4  
5 use v5.20;
6  
7  
8  
9 use Moose;
10 use Moose::Util::TypeConstraints qw(enum);
11  
12 use Carp;
13  
14 use namespace::autoclean;
15  
16 extends 'Lab::Moose::Connection::VISA';
17  
18 has vid => (
19 is => 'ro',
20 isa => 'Str',
21 required => 1
22 );
23  
24 has pid => (
25 is => 'ro',
26 isa => 'Str',
27 required => 1
28 );
29  
30 has serial => (
31 is => 'ro',
32 isa => 'Str',
33 required => 1
34 );
35  
36 has '+resource_name' => (
37 required => 0,
38 );
39  
40 sub gen_resource_name {
41 my $self = shift;
42  
43 my $vid = $self->vid;
44 my $pid = $self->pid;
45 my $serial = $self->serial;
46 if ( $vid =~ /^0x/i ) {
47 $vid = hex($vid);
48 }
49 if ( $pid =~ /^0x/i ) {
50 $pid = hex($pid);
51 }
52  
53 return sprintf( "USB::0x%04x::0x%04x::%s::INSTR", $vid, $pid, $serial );
54 }
55  
56 __PACKAGE__->meta->make_immutable();
57  
58 1;
59  
60 __END__
61  
62 =pod
63  
64 =encoding UTF-8
65  
66 =head1 NAME
67  
68 Lab::Moose::Connection::VISA::USB - USB-TMC frontend to National Instruments' VISA library.
69  
70 =head1 VERSION
71  
72 version 3.881
73  
74 =head1 SYNOPSIS
75  
76 use Lab::Moose
77 my $instrument = instrument(
78 type => 'random_instrument',
79 connection_type => 'VISA::USB',
80 connection_options => {vid => 0xabcd, pid => 0x1234, serial => 'MY47000419'}
81 );
82  
83 =head1 DESCRIPTION
84  
85 Creates a USB resource name for the VISA backend.
86  
87 =head1 COPYRIGHT AND LICENSE
88  
89 This software is copyright (c) 2023 by the Lab::Measurement team; in detail:
90  
91 Copyright 2018-2019 Simon Reinhardt
92 2020 Andreas K. Huettel
93  
94  
95 This is free software; you can redistribute it and/or modify it under
96 the same terms as the Perl 5 programming language system itself.
97  
98 =cut