Moose/Connection/Debug.pm

filter: Statementstmt 62.7% 27 / 43 Branchbran 50.0% 2 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 80.0% 8 / 10 Podpod 100% 4 / 4 totaltotal 67.2% 41 / 61 SCAR 12.5
CC
3
Cov
62%
Clear
2.3
Write
2.1
Read
2.0
CRAP 3.5
« Moose/Instrument/HP3458A.pm ↑ Summary Moose/Instrument/Cryomagnetics_4G.pm »
1 package Lab::Moose::Connection::Debug;
2 4 $Lab::Moose::Connection::Debug::VERSION = '3.881';
3 #ABSTRACT: Debug connection, printing / reading on terminal
4  
5 4 ▶use v5.20;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 4 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 4 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 4 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 4 ▶use YAML::XS;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 4 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 4 has verbose => (
15 is => 'ro',
16 isa => 'Bool',
17 default => 1,
18 );
19  
20  
21 sub Write {
22 172 ▶ my $self = shift;
Subroutine Write: called CC=2 SCAR=7.6
Pod documented
23 172 my %args = @_;
24 172 ▶ if ( $self->verbose() ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->verbose) 0 172 172
25 0 carp "Write called with args:\n", Dump \%args, "\n";
26 }
27 }
28  
29  
30 sub Read {
31 0 ▶ my $self = shift;
Subroutine Read: not called CC=1 SCAR=6.9
Pod documented
32 0 my %args = @_;
33 0 carp "Read called with args:\n", Dump \%args, "\n";
34 0 say "enter return value:";
35 0 my $retval = <STDIN>;
36 0 chomp $retval;
37 0 return $retval;
38 }
39  
40  
41 sub Query {
42 0 ▶ my $self = shift;
Subroutine Query: not called CC=1 SCAR=6.9
Pod documented
43 0 my %args = @_;
44 0 carp "Query called with args:\n", Dump \%args, "\n";
45 0 say "enter return value:";
46 0 my $retval = <STDIN>;
47 0 chomp $retval;
48 0 return $retval;
49 }
50  
51  
52 sub Clear {
53 18 ▶ my $self = shift;
Subroutine Clear: called CC=2 SCAR=8.1
Pod documented
54 18 ▶ if ( $self->verbose ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->verbose) 0 18 18
55 0 carp "Clear called";
56 }
57 }
58  
59 4 with 'Lab::Moose::Connection';
60  
61 4 __PACKAGE__->meta->make_immutable();
62 4 1;
63  
64 __END__
65  
66 =pod
67  
68 =encoding UTF-8
69  
70 =head1 NAME
71  
72 Lab::Moose::Connection::Debug - Debug connection, printing / reading on terminal
73  
74 =head1 VERSION
75  
76 version 3.881
77  
78 =head1 SYNOPSIS
79  
80 use Lab::Moose;
81  
82 my $instrument = instrument(
83 type => 'DummySource',
84 connection_type => 'DEBUG'
85 connection_options => {
86 verbose => 0, # do not print arguments of all Write commands (default is 1).
87 }
88 );
89  
90 =head1 DESCRIPTION
91  
92 Debug connection object. Print out C<Write> commands and prompt answer for
93 C<Read> commands.
94  
95 =head1 METHODS
96  
97 =head2 Write
98  
99 If the connection option verbose is set, output the content of all write
100 commands to the terminal. Otherwise, do nothing.
101  
102 =head2 Read
103  
104 Output the arguments of the read command to the terminal, and request
105 a response there, which is given as result of the read.
106  
107 =head2 Query
108  
109 Output the arguments of the query command to the terminal, and request
110 a response there, which is given as result of the query.
111  
112 =head2 Clear
113  
114 Output "Clear called" on the terminal.
115  
116 =head1 COPYRIGHT AND LICENSE
117  
118 This software is copyright (c) 2023 by the Lab::Measurement team; in detail:
119  
120 Copyright 2016 Simon Reinhardt
121 2017 Andreas K. Huettel, Simon Reinhardt
122 2020 Andreas K. Huettel
123  
124  
125 This is free software; you can redistribute it and/or modify it under
126 the same terms as the Perl 5 programming language system itself.
127  
128 =cut
« Moose/Instrument/HP3458A.pm ↑ Summary Moose/Instrument/Cryomagnetics_4G.pm »