Connection/VICP.pm

filter: Statementstmt 42.8% 21 / 49 Branchbran 0.0% 0 / 6 Conditioncond 0.0% 0 / 9 MC/DCmcdc 0.0% 0 / 6 Subroutinesub 60.0% 6 / 10 Podpod 100% 4 / 4 totaltotal 36.9% 31 / 84 SCAR 30.8
CC
7
Cov
33%
Write
12.0
Read
12.0
new
6.0
CRAP 21.9
« Moose/Sweep/Step.pm ↑ Summary Moose/Instrument/AdjustRange.pm »
1 package Lab::Connection::VICP;
2 #ABSTRACT: VICP ethernet protocol connection
3 1 $Lab::Connection::VICP::VERSION = '3.881';
4 1 ▶use v5.20;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use Time::HiRes qw (usleep sleep);
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use Lab::Connection::GPIB;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 1 our @ISA = ("Lab::Connection");
13  
14 1 our %fields = (
15 bus_class => 'Lab::Bus::VICP',
16 wait_status => 0, # usec;
17 wait_query => 10e-6, # sec;
18 read_length => 1000, # bytes
19 timeout => 1, # seconds
20 );
21  
22 sub new {
23 0 ▶ my $proto = shift;
Subroutine new: not called CC=2 SCAR=17.9
Pod documented
24 0 ▶ my $class = ref($proto) || $proto;
Condition0%0/3
ref $proto || $proto
l!l&&r!l&&!r
000
MC/DC0%0/2
ref $proto || $proto
ref $proto $proto
Truth table0%0/3
A || B
A= ref $protoB= $proto
ABresult
1X1
011
000
25 0 my $twin = undef;
26 0 my $self = $class->SUPER::new(@_)
27 ; # getting fields and _permitted from parent class
28 0 $self->${ \( __PACKAGE__ . '::_construct' ) }(__PACKAGE__);
29  
30 0 return $self;
31 }
32  
33 sub Write {
34 0 ▶ my $self = shift;
Subroutine Write: not called CC=3 SCAR=24.8
Pod documented
35 0 my $options = undef;
36 0 ▶ if ( ref $_[0] eq 'HASH' ) { $options = shift }
Branch: 1 branch
BranchTrueFalseTotal
if (ref $_[0] eq 'HASH') { } 0 0 0
37 0 else { $options = {@_} }
38  
39 0 ▶ my $timeout = $options->{'timeout'} || $self->{timeout};
Condition0%0/3
$options->{'timeout'} || $self->{'timeout'}
l!l&&r!l&&!r
000
MC/DC0%0/2
$options->{'timeout'} || $self->{'timeout'}
$options->{'timeout'} $self->{'timeout'}
Truth table0%0/3
A || B
A= $options->{'timeout'}B= $self->{'timeout'}
ABresult
1X1
011
000
40  
41 # $self->bus()->timeout( $self->connection_handle(), $timeout );
42  
43 0 return $self->bus()
44 ->connection_write( $self->connection_handle(), $options );
45 }
46  
47 sub Read {
48 0 ▶ my $self = shift;
Subroutine Read: not called CC=3 SCAR=24.8
Pod documented
49 0 my $options = undef;
50 0 ▶ if ( ref $_[0] eq 'HASH' ) { $options = shift }
Branch: 1 branch
BranchTrueFalseTotal
if (ref $_[0] eq 'HASH') { } 0 0 0
51 0 else { $options = {@_} }
52  
53 0 ▶ my $timeout = $options->{'timeout'} || $self->{timeout};
Condition0%0/3
$options->{'timeout'} || $self->{'timeout'}
l!l&&r!l&&!r
000
MC/DC0%0/2
$options->{'timeout'} || $self->{'timeout'}
$options->{'timeout'} $self->{'timeout'}
Truth table0%0/3
A || B
A= $options->{'timeout'}B= $self->{'timeout'}
ABresult
1X1
011
000
54  
55 # $self->bus()->timeout( $self->connection_handle(), $timeout );
56  
57 0 return $self->bus()
58 ->connection_read( $self->connection_handle(), $options );
59 }
60  
61 sub Query {
62 0 ▶ my $self = shift;
Subroutine Query: not called CC=2 SCAR=17.9
Pod documented
63 0 my $options = undef;
64 0 ▶ if ( ref $_[0] eq 'HASH' ) { $options = shift }
Branch: 1 branch
BranchTrueFalseTotal
if (ref $_[0] eq 'HASH') { } 0 0 0
65 0 else { $options = {@_} }
66  
67 0 $self->Write($options);
68 0 return $self->Read($options);
69  
70 # return $self->bus()->connection_query( $self->connection_handle(), $options );
71 }
72  
73 #
74 # Query from Lab::Connection is sufficient
75 # EnableTermChar, SetTermChar from Lab::Connection::GPIB are sufficient.
76 #
77  
78  
79 1 1;
80  
81 __END__
82  
83 =pod
84  
85 =encoding utf-8
86  
87 =head1 NAME
88  
89 Lab::Connection::VICP - VICP ethernet protocol connection
90  
91 =head1 VERSION
92  
93 version 3.881
94  
95 =head1 SYNOPSIS
96  
97 Connection class which uses the VICP ethernet protocol backend.
98 The communication is primarily GPIB/IEEE-488 syntax.
99  
100 This is not called directly. To make a GPIB suppporting instrument use Lab::Connection::VICP, set
101 the connection_type parameter accordingly:
102  
103 $instrument = new LeCroy640 (
104 connection_type => 'VICP',
105 host_addr => 192.168.1.100,
106 )
107  
108 =head1 DESCRIPTION
109  
110 C<Lab::Connection::VICP> provides a GPIB-type connection with the bus L<Lab::Bus::VICP>,
111 using GPIB over ethernet (with special GPIB-ish header packets) as a backend.
112  
113 It inherits from L<Lab::Connection::GPIB> and subsequently from L<Lab::Connection>.
114  
115 For L<Lab::Bus::VICP>, the generic methods of L<Lab::Connection> suffice, so only a few defaults are set:
116 wait_status=>0, # usec;
117 wait_query=>10, # usec;
118 read_length=>1000, # bytes
119  
120 =head1 CONSTRUCTOR
121  
122 =head2 new
123  
124 my $connection = new Lab::Connection::VICP(
125 host_addr => 192.168.1.100, # or host specified by name
126 host_port => 1861, # default lecroy-vicp port
127 timeout => 10, # timeout, seconds.
128 }
129  
130 =head1 METHODS
131  
132 This just falls back on the methods inherited from L<Lab::Connection>.
133  
134 =head2 config
135  
136 Provides unified access to the fields in initial @_ to all the child classes.
137 E.g.
138  
139 Without arguments, returns a reference to the complete $self->Config aka @_ of the constructor.
140  
141 $Config = $connection->Config();
142 $ipaddr = $connection->Config()->{'host_addr'};
143  
144 =head1 CAVEATS/BUGS
145  
146 Probably few. Mostly because there's not a lot to be done here. Please report.
147  
148 =head1 SEE ALSO
149  
150 =over 4
151  
152 =item * L<Lab::Connection>
153  
154 =item * L<Lab::Connection::GPIB>
155  
156 =back
157  
158 =head1 COPYRIGHT AND LICENSE
159  
160 This software is copyright (c) 2023 by the Lab::Measurement team; in detail:
161  
162 Copyright 2016 Charles Lane
163 2017 Andreas K. Huettel
164 2020 Andreas K. Huettel
165  
166  
167 This is free software; you can redistribute it and/or modify it under
168 the same terms as the Perl 5 programming language system itself.
169  
170 =cut
« Moose/Sweep/Step.pm ↑ Summary Moose/Instrument/AdjustRange.pm »