line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Lab::Moose::Connection::WWW; |
2
|
|
|
|
|
|
|
$Lab::Moose::Connection::WWW::VERSION = '3.900'; |
3
|
|
|
|
|
|
|
#ABSTRACT: Connection with URL requests |
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
2561
|
use v5.20; |
|
1
|
|
|
|
|
5
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
8
|
use Moose; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
11
|
|
9
|
1
|
|
|
1
|
|
7281
|
use MooseX::Params::Validate; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
16
|
|
10
|
1
|
|
|
1
|
|
487
|
use Moose::Util::TypeConstraints qw(enum); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
16
|
|
11
|
1
|
|
|
1
|
|
550
|
use Carp; |
|
1
|
|
|
|
|
7
|
|
|
1
|
|
|
|
|
88
|
|
12
|
|
|
|
|
|
|
|
13
|
1
|
|
|
1
|
|
7
|
use Lab::Moose::Instrument qw/timeout_param read_length_param/; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
53
|
|
14
|
|
|
|
|
|
|
|
15
|
1
|
|
|
1
|
|
582
|
use LWP::Simple; |
|
1
|
|
|
|
|
9282
|
|
|
1
|
|
|
|
|
6
|
|
16
|
|
|
|
|
|
|
|
17
|
1
|
|
|
1
|
|
383
|
use namespace::autoclean; |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
12
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
has ip => ( |
21
|
|
|
|
|
|
|
is => 'ro', |
22
|
|
|
|
|
|
|
isa => 'Str', |
23
|
|
|
|
|
|
|
required => 1, |
24
|
|
|
|
|
|
|
); |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
has port => ( |
27
|
|
|
|
|
|
|
is => 'ro', |
28
|
|
|
|
|
|
|
isa => 'Lab::Moose::PosNum', |
29
|
|
|
|
|
|
|
required => 1, |
30
|
|
|
|
|
|
|
); |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub Read { |
33
|
0
|
|
|
0
|
0
|
|
my ( $self, %args ) = validated_hash( |
34
|
|
|
|
|
|
|
\@_, |
35
|
|
|
|
|
|
|
command => { isa => 'Str' }, |
36
|
|
|
|
|
|
|
); |
37
|
0
|
|
|
|
|
|
my $command = $args{'command'}; |
38
|
0
|
|
|
|
|
|
my $url = "http://$self->ip():$self->port()$command"; |
39
|
0
|
|
|
|
|
|
return get( $url ); |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub Write { |
43
|
0
|
|
|
0
|
0
|
|
my ( $self, %args ) = validated_hash( |
44
|
|
|
|
|
|
|
\@_, |
45
|
|
|
|
|
|
|
command => { isa => 'Str' }, |
46
|
|
|
|
|
|
|
); |
47
|
0
|
|
|
|
|
|
my $command = $args{'command'}; |
48
|
0
|
|
|
|
|
|
my $url = "http://$self->ip():$self->port()$command"; |
49
|
0
|
|
|
|
|
|
get( $url ); |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
1; |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
__END__ |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=pod |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=encoding UTF-8 |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head1 NAME |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
Lab::Moose::Connection::WWW - Connection with URL requests |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=head1 VERSION |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
version 3.900 |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=head1 SYNOPSIS |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
use Lab::Moose |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
my $instrument = instrument( |
73
|
|
|
|
|
|
|
type => 'random_instrument', |
74
|
|
|
|
|
|
|
connection_type => 'WWW', |
75
|
|
|
|
|
|
|
connection_options => {ip => 172.22.11.2, port => 8002}, |
76
|
|
|
|
|
|
|
); |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=head1 DESCRIPTION |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
This module provides a connection for devices with an integrated web |
81
|
|
|
|
|
|
|
server. |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
This software is copyright (c) 2023 by the Lab::Measurement team; in detail: |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
Copyright 2022 Mia Schambeck |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
91
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=cut |