Moose/Instrument/Common.pm

filter: Statementstmt 48.0% 25 / 52 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 52.9% 9 / 17 Podpod 100% 11 / 11 totaltotal 54.8% 45 / 82 SCAR 9.6
CC
2
Cov
46%
opc_sync
6.0
idn
2.0
idn_manufacturer
2.0
CRAP 2.6
« Connection/Socket.pm ↑ Summary XPRESS/Sweep/Dummy.pm »
1 package Lab::Moose::Instrument::Common;
2 #ABSTRACT: Role for common commands declared mandatory by IEEE 488.2
3 14 $Lab::Moose::Instrument::Common::VERSION = '3.881';
4 14 ▶use v5.20;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 14 ▶use Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 14 ▶use MooseX::Params::Validate;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 14 use Lab::Moose::Instrument qw/
10 validated_getter
11 validated_setter
12 validated_no_param_setter
13 14 ▶ /;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 14 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 14 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18  
19 sub cls {
20 9 ▶ my ( $self, %args ) = validated_no_param_setter( \@_ );
Subroutine cls: called CC=1 SCAR=0.0
Pod documented
21 9 return $self->write( command => '*CLS', %args );
22 }
23  
24  
25 sub idn {
26 0 ▶ my ( $self, %args ) = validated_getter( \@_ );
Subroutine idn: not called CC=1 SCAR=6.9
Pod documented
27 0 return $self->query( command => '*IDN?', %args );
28 }
29  
30  
31 sub idn_manufacturer {
32 0 ▶ my ( $self, %args ) = validated_getter( \@_ );
Subroutine idn_manufacturer: not called CC=1 SCAR=6.9
Pod documented
33 0 my $i=$self->query( command => '*IDN?', %args );
34 0 my ($man, $mod, $ser, $fir) = split /,\s*/, $i, 4;
35 0 return $man;
36 }
37  
38  
39 sub idn_model {
40 0 ▶ my ( $self, %args ) = validated_getter( \@_ );
Subroutine idn_model: not called CC=1 SCAR=6.9
Pod documented
41 0 my $i=$self->query( command => '*IDN?', %args );
42 0 my ($man, $mod, $ser, $fir) = split /,\s*/, $i, 4;
43 0 return $mod;
44 }
45  
46  
47 sub idn_serial {
48 0 ▶ my ( $self, %args ) = validated_getter( \@_ );
Subroutine idn_serial: not called CC=1 SCAR=6.9
Pod documented
49 0 my $i=$self->query( command => '*IDN?', %args );
50 0 my ($man, $mod, $ser, $fir) = split /,\s/, $i, 4;
51 0 return $ser;
52 }
53  
54  
55 sub idn_firmware {
56 0 ▶ my ( $self, %args ) = validated_getter( \@_ );
Subroutine idn_firmware: not called CC=1 SCAR=6.9
Pod documented
57 0 my $i=$self->query( command => '*IDN?', %args );
58 0 my ($man, $mod, $ser, $fir) = split /,\s/, $i, 4;
59 0 return $fir;
60 }
61  
62  
63 sub opc {
64 0 ▶ my ( $self, %args ) = validated_no_param_setter( \@_ );
Subroutine opc: not called CC=1 SCAR=6.9
Pod documented
65 0 return $self->write( command => '*OPC', %args );
66 }
67  
68  
69 sub opc_query {
70 0 ▶ my ( $self, %args ) = validated_getter( \@_ );
Subroutine opc_query: not called CC=1 SCAR=6.9
Pod documented
71 0 return $self->query( command => '*OPC?', %args );
72 }
73  
74  
75 sub opc_sync {
76 0 ▶ my ( $self, %args ) = validated_getter( \@_ );
Subroutine opc_sync: not called CC=2 SCAR=17.9
Pod documented
77 0 my $one = $self->opc_query(%args);
78 0 ▶ if ( $one ne '1' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($one ne 1) 0 0 0
79 0 croak "OPC query did not return '1'";
80 }
81 0 return $one;
82 }
83  
84  
85 sub rst {
86 14 ▶ my ( $self, %args ) = validated_no_param_setter( \@_ );
Subroutine rst: called CC=1 SCAR=0.0
Pod documented
87 14 return $self->write( command => '*RST', %args );
88 }
89  
90  
91 sub wai {
92 9 ▶ my ( $self, %args ) = validated_no_param_setter( \@_ );
Subroutine wai: called CC=1 SCAR=0.0
Pod documented
93 9 return $self->write( command => '*WAI', %args );
94 }
95  
96 14 1;
97  
98 __END__
99  
100 =pod
101  
102 =encoding UTF-8
103  
104 =head1 NAME
105  
106 Lab::Moose::Instrument::Common - Role for common commands declared mandatory by IEEE 488.2
107  
108 =head1 VERSION
109  
110 version 3.881
111  
112 =head1 METHODS
113  
114 =head2 cls
115  
116 Send I<*CLS> command.
117  
118 =head2 idn
119  
120 Return result of I<*IDN?> query.
121  
122 =head2 idn_manufacturer
123  
124 Returns the manufacturer field from an I<*IDN?> query.
125  
126 =head2 idn_model
127  
128 Returns the model field from an I<*IDN?> query.
129  
130 =head2 idn_serial
131  
132 Returns the serial number field from an I<*IDN?> query.
133  
134 =head2 idn_firmware
135  
136 Returns the firmware version field from an I<*IDN?> query.
137  
138 =head2 opc
139  
140 Send I<*OPC> command.
141  
142 =head2 opc_query
143  
144 Return result of I<*OPC?> query.
145  
146 =head2 opc_sync
147  
148 Perform C<opc_query> and croak if it does not return '1'. Make sure to provide
149 a sufficient timeout.
150  
151 =head2 rst
152  
153 Send I<*RST> command.
154  
155 =head2 wai
156  
157 Send I<*WAI> command.
158  
159 =head1 COPYRIGHT AND LICENSE
160  
161 This software is copyright (c) 2023 by the Lab::Measurement team; in detail:
162  
163 Copyright 2016 Simon Reinhardt
164 2017 Andreas K. Huettel, Simon Reinhardt
165 2018 Andreas K. Huettel
166 2020 Andreas K. Huettel, Sam Bingner
167  
168  
169 This is free software; you can redistribute it and/or modify it under
170 the same terms as the Perl 5 programming language system itself.
171  
172 =cut
« Connection/Socket.pm ↑ Summary XPRESS/Sweep/Dummy.pm »