| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Lab::Moose::Connection; |
|
2
|
|
|
|
|
|
|
$Lab::Moose::Connection::VERSION = '3.900'; |
|
3
|
|
|
|
|
|
|
#ABSTRACT: Role for connections |
|
4
|
|
|
|
|
|
|
|
|
5
|
29
|
|
|
29
|
|
1947
|
use v5.20; |
|
|
29
|
|
|
|
|
114
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
29
|
|
|
29
|
|
174
|
use warnings; |
|
|
29
|
|
|
|
|
78
|
|
|
|
29
|
|
|
|
|
814
|
|
|
8
|
29
|
|
|
29
|
|
172
|
use strict; |
|
|
29
|
|
|
|
|
84
|
|
|
|
29
|
|
|
|
|
688
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
29
|
|
|
29
|
|
12984
|
use Moose::Role; |
|
|
29
|
|
|
|
|
137985
|
|
|
|
29
|
|
|
|
|
170
|
|
|
11
|
29
|
|
|
29
|
|
170628
|
use MooseX::Params::Validate qw/validated_hash/; |
|
|
29
|
|
|
|
|
99
|
|
|
|
29
|
|
|
|
|
253
|
|
|
12
|
29
|
|
|
29
|
|
20526
|
use Lab::Moose::Instrument qw/timeout_param read_length_param/; |
|
|
29
|
|
|
|
|
141
|
|
|
|
29
|
|
|
|
|
2941
|
|
|
13
|
29
|
|
|
29
|
|
339
|
use namespace::autoclean; |
|
|
29
|
|
|
|
|
79
|
|
|
|
29
|
|
|
|
|
306
|
|
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
requires qw/Read Write Clear/; |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
has timeout => ( |
|
19
|
|
|
|
|
|
|
is => 'ro', |
|
20
|
|
|
|
|
|
|
isa => 'Num', |
|
21
|
|
|
|
|
|
|
default => 1, |
|
22
|
|
|
|
|
|
|
); |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub _timeout_arg { |
|
25
|
6
|
|
|
6
|
|
21
|
my $self = shift; |
|
26
|
6
|
|
|
|
|
23
|
my %arg = @_; |
|
27
|
6
|
|
33
|
|
|
212
|
return $arg{timeout} // $self->timeout(); |
|
28
|
|
|
|
|
|
|
} |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
has read_length => ( |
|
31
|
|
|
|
|
|
|
is => 'ro', |
|
32
|
|
|
|
|
|
|
isa => 'Int', |
|
33
|
|
|
|
|
|
|
default => 32768 |
|
34
|
|
|
|
|
|
|
); |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub _read_length_arg { |
|
37
|
3
|
|
|
3
|
|
6
|
my $self = shift; |
|
38
|
3
|
|
|
|
|
9
|
my %arg = @_; |
|
39
|
3
|
|
66
|
|
|
71
|
return $arg{read_length} // $self->read_length(); |
|
40
|
|
|
|
|
|
|
} |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub Query { |
|
44
|
3
|
|
|
3
|
1
|
47
|
my ( $self, %arg ) = validated_hash( |
|
45
|
|
|
|
|
|
|
\@_, |
|
46
|
|
|
|
|
|
|
timeout_param, |
|
47
|
|
|
|
|
|
|
read_length_param, |
|
48
|
|
|
|
|
|
|
command => { isa => 'Str' }, |
|
49
|
|
|
|
|
|
|
); |
|
50
|
|
|
|
|
|
|
|
|
51
|
3
|
|
|
|
|
2399
|
my %write_arg = %arg; |
|
52
|
3
|
|
|
|
|
9
|
delete $write_arg{read_length}; |
|
53
|
3
|
|
|
|
|
50
|
$self->Write(%write_arg); |
|
54
|
|
|
|
|
|
|
|
|
55
|
3
|
|
|
|
|
7
|
delete $arg{command}; |
|
56
|
3
|
|
|
|
|
36
|
return $self->Read(%arg); |
|
57
|
|
|
|
|
|
|
} |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
1; |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
__END__ |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=pod |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=encoding UTF-8 |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=head1 NAME |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
Lab::Moose::Connection - Role for connections |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=head1 VERSION |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
version 3.900 |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
This role should be consumed by all connections in the Lab::Moose::Connection |
|
78
|
|
|
|
|
|
|
namespace. It declares the required methods. |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=head2 Query |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
my $data = $connection->Query(command => '*IDN?'); |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
Call C<Write> followed by C<Read>. |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
This software is copyright (c) 2023 by the Lab::Measurement team; in detail: |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
Copyright 2016 Simon Reinhardt |
|
91
|
|
|
|
|
|
|
2017 Andreas K. Huettel, 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 |