Moose/Connection/VISA/GPIB.pm untested

filter: Statementstmt 0.0% 0 / 40 Branchbran 0.0% 0 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 6 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 53 SCAR 30.0
CC
4
Cov
0%
gen_resource_name
20.0
BEGIN
2.0
BEGIN
2.0
CRAP 20.0
1 package Lab::Moose::Connection::VISA::GPIB;
2 $Lab::Moose::Connection::VISA::GPIB::VERSION = '3.881';
3 #ABSTRACT: GPIB 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 pad => (
19 is => 'ro',
20 isa => enum( [ ( 0 .. 30 ) ] ),
21 predicate => 'has_pad',
22 writer => '_pad'
23 );
24  
25 has gpib_address => (
26 is => 'ro',
27 isa => enum( [ ( 0 .. 30 ) ] ),
28 predicate => 'has_gpib_address'
29 );
30  
31 has sad => (
32 is => 'ro',
33 isa => enum( [ 0, ( 96 .. 126 ) ] ),
34 predicate => 'has_sad',
35 );
36  
37 has board_index => (
38 is => 'ro',
39 isa => 'Int',
40 default => 0,
41 );
42  
43 has '+resource_name' => (
44 required => 0,
45 );
46  
47 sub gen_resource_name {
48 my $self = shift;
49 if ( $self->has_gpib_address() ) {
50 $self->_pad( $self->gpib_address() );
51 }
52  
53 if ( not $self->has_pad() ) {
54 croak "no primary GPIB address provided";
55 }
56  
57 my $resource_name = "GPIB" . $self->board_index() . '::' . $self->pad();
58 if ( $self->has_sad ) {
59 $resource_name .= '::' . $self->sad();
60 }
61 $resource_name .= '::INSTR';
62 return $resource_name;
63 }
64  
65 __PACKAGE__->meta->make_immutable();
66  
67 1;
68  
69 __END__
70  
71 =pod
72  
73 =encoding UTF-8
74  
75 =head1 NAME
76  
77 Lab::Moose::Connection::VISA::GPIB - GPIB frontend to National Instruments' VISA library.
78  
79 =head1 VERSION
80  
81 version 3.881
82  
83 =head1 SYNOPSIS
84  
85 use Lab::Moose
86 my $instrument = instrument(
87 type => 'random_instrument',
88 connection_type => 'VISA::GPIB',
89 connection_options => {gpib_address => 10}
90 );
91  
92 =head1 DESCRIPTION
93  
94 Creates a GPIB resource name for the VISA backend. Valid connection options:
95 gpib_address (or pad), sad (secondary address), board_index (defaults to 0).
96  
97 =head1 COPYRIGHT AND LICENSE
98  
99 This software is copyright (c) 2023 by the Lab::Measurement team; in detail:
100  
101 Copyright 2017-2018 Simon Reinhardt
102 2020 Andreas K. Huettel
103  
104  
105 This is free software; you can redistribute it and/or modify it under
106 the same terms as the Perl 5 programming language system itself.
107  
108 =cut