File Coverage

blib/lib/Lab/Connection/VICP.pm
Criterion Covered Total %
statement 17 45 37.7
branch 0 6 0.0
condition 0 9 0.0
subroutine 6 10 60.0
pod 4 4 100.0
total 27 74 36.4


line stmt bran cond sub pod time code
1             package Lab::Connection::VICP;
2             #ABSTRACT: VICP ethernet protocol connection
3             $Lab::Connection::VICP::VERSION = '3.880';
4 1     1   1862 use v5.20;
  1         4  
5              
6 1     1   8 use strict;
  1         2  
  1         30  
7 1     1   6 use Time::HiRes qw (usleep sleep);
  1         2  
  1         6  
8 1     1   106 use Lab::Connection::GPIB;
  1         3  
  1         23  
9 1     1   6 use Carp;
  1         11  
  1         57  
10 1     1   7 use Data::Dumper;
  1         9  
  1         441  
11              
12             our @ISA = ("Lab::Connection");
13              
14             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     0 1   my $proto = shift;
24 0   0       my $class = ref($proto) || $proto;
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__);
  0            
29              
30 0           return $self;
31             }
32              
33             sub Write {
34 0     0 1   my $self = shift;
35 0           my $options = undef;
36 0 0         if ( ref $_[0] eq 'HASH' ) { $options = shift }
  0            
37 0           else { $options = {@_} }
38              
39 0   0       my $timeout = $options->{'timeout'} || $self->{timeout};
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     0 1   my $self = shift;
49 0           my $options = undef;
50 0 0         if ( ref $_[0] eq 'HASH' ) { $options = shift }
  0            
51 0           else { $options = {@_} }
52              
53 0   0       my $timeout = $options->{'timeout'} || $self->{timeout};
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     0 1   my $self = shift;
63 0           my $options = undef;
64 0 0         if ( ref $_[0] eq 'HASH' ) { $options = shift }
  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;
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.880
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