line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Lab::Moose::Connection; |
2
|
|
|
|
|
|
|
$Lab::Moose::Connection::VERSION = '3.880'; |
3
|
|
|
|
|
|
|
#ABSTRACT: Role for connections |
4
|
|
|
|
|
|
|
|
5
|
29
|
|
|
29
|
|
1821
|
use v5.20; |
|
29
|
|
|
|
|
109
|
|
6
|
|
|
|
|
|
|
|
7
|
29
|
|
|
29
|
|
183
|
use warnings; |
|
29
|
|
|
|
|
72
|
|
|
29
|
|
|
|
|
784
|
|
8
|
29
|
|
|
29
|
|
156
|
use strict; |
|
29
|
|
|
|
|
89
|
|
|
29
|
|
|
|
|
605
|
|
9
|
|
|
|
|
|
|
|
10
|
29
|
|
|
29
|
|
13419
|
use Moose::Role; |
|
29
|
|
|
|
|
139562
|
|
|
29
|
|
|
|
|
134
|
|
11
|
29
|
|
|
29
|
|
171225
|
use MooseX::Params::Validate qw/validated_hash/; |
|
29
|
|
|
|
|
95
|
|
|
29
|
|
|
|
|
232
|
|
12
|
29
|
|
|
29
|
|
21282
|
use Lab::Moose::Instrument qw/timeout_param read_length_param/; |
|
29
|
|
|
|
|
141
|
|
|
29
|
|
|
|
|
2913
|
|
13
|
29
|
|
|
29
|
|
298
|
use namespace::autoclean; |
|
29
|
|
|
|
|
86
|
|
|
29
|
|
|
|
|
260
|
|
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
|
|
12
|
my $self = shift; |
26
|
6
|
|
|
|
|
16
|
my %arg = @_; |
27
|
6
|
|
33
|
|
|
211
|
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
|
|
|
|
|
6
|
my %arg = @_; |
39
|
3
|
|
66
|
|
|
71
|
return $arg{read_length} // $self->read_length(); |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub Query { |
44
|
3
|
|
|
3
|
1
|
42
|
my ( $self, %arg ) = validated_hash( |
45
|
|
|
|
|
|
|
\@_, |
46
|
|
|
|
|
|
|
timeout_param, |
47
|
|
|
|
|
|
|
read_length_param, |
48
|
|
|
|
|
|
|
command => { isa => 'Str' }, |
49
|
|
|
|
|
|
|
); |
50
|
|
|
|
|
|
|
|
51
|
3
|
|
|
|
|
2294
|
my %write_arg = %arg; |
52
|
3
|
|
|
|
|
8
|
delete $write_arg{read_length}; |
53
|
3
|
|
|
|
|
27
|
$self->Write(%write_arg); |
54
|
|
|
|
|
|
|
|
55
|
3
|
|
|
|
|
9
|
delete $arg{command}; |
56
|
3
|
|
|
|
|
13
|
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.880 |
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 |