XPRESS/hub.pm

filter: Statementstmt 45.5% 51 / 112 Branchbran 33.3% 8 / 24 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 76.4% 13 / 17 Podpod 0.0% 0 / 7 totaltotal 43.6% 72 / 165 SCAR 42.8
CC
17
Cov
42%
show_available_objects
30.0
Frame
12.0
new
6.0
CRAP 72.1
« Moose/Connection/VISA.pm ↑ Summary Moose/Instrument/Bluefors_Temp.pm »
1 package Lab::XPRESS::hub;
2 8 $Lab::XPRESS::hub::VERSION = '3.881';
3 #ABSTRACT: The XPRESS main hub
4  
5 8 ▶use v5.20;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 8 ▶use Lab::Exception;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 8 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 8 ▶use Exporter 'import';
Subroutine BEGIN: called CC=1 SCAR=0.0
10 8 ▶use Module::Load qw/load autoload/;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 8 ▶use Try::Tiny;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 8 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 8 our @EXPORT_OK = qw(DataFile Sweep Frame Instrument Connection);
15  
16 sub new {
17 0 ▶ my $proto = shift;
Subroutine new: not called CC=2 SCAR=17.9
Pod undocumented
18 0 ▶ my $class = ref($proto) || $proto;
Condition0%0/3
ref $proto || $proto
l!l&&r!l&&!r
000
MC/DC0%0/2
ref $proto || $proto
ref $proto $proto
Truth table0%0/3
A || B
A= ref $protoB= $proto
ABresult
1X1
011
000
19  
20 0 my $self = {};
21 0 bless( $self, $class );
22  
23 0 return $self;
24  
25 }
26  
27 sub DataFile {
28 2 ▶ my $self = shift if ref( $_[0] ) eq __PACKAGE__;
Subroutine DataFile: called CC=3 SCAR=11.2
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
if ref $_[0] eq __PACKAGE__ 0 2 2
29 2 my ( $filenamebase, $foldername ) = @_;
30  
31 8 ▶ use Lab::XPRESS::Data::XPRESS_DataFile;
Subroutine BEGIN: called CC=1 SCAR=0.0
32 2 ▶ my $xFile
Branch: 1 branch
BranchTrueFalseTotal
my $xFile = "Lab::XPRESS::Data::XPRESS_DataFile"->new($filenamebase, $foldername) or die "Lab::Exception::CorruptParameter"->throw("error", "Can't open file $filenamebase\n") 0 2 2
33 = new Lab::XPRESS::Data::XPRESS_DataFile( $filenamebase, $foldername )
34 or die Lab::Exception::CorruptParameter->throw(
35 error => "Can't open file $filenamebase\n" );
36 2 return $xFile;
37  
38 }
39  
40 sub Sweep {
41 2 ▶ my $self = shift if ref( $_[0] ) eq __PACKAGE__;
Subroutine Sweep: called CC=3 SCAR=11.3
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
if ref $_[0] eq __PACKAGE__ 0 2 2
42 2 my $sweep = shift;
43  
44 2 $sweep = "Lab::XPRESS::Sweep::" . $sweep;
45 2 ▶ eval "require $sweep; $sweep->import(); 1;"
Branch: 1 branch
BranchTrueFalseTotal
eval "require $sweep; $sweep->import(); 1;" or do "Lab::Exception::CorruptParameter"->throw("error", $@) 0 2 2
46 or do Lab::Exception::CorruptParameter->throw( error => $@ );
47  
48 2 return $sweep->new(@_);
49  
50 }
51  
52 sub Frame {
53 0 ▶ my $self = shift if ref( $_[0] ) eq __PACKAGE__;
Subroutine Frame: not called CC=3 SCAR=24.8
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
if ref $_[0] eq __PACKAGE__ 0 0 0
54  
55 0 my $frame = "Lab::XPRESS::Sweep::Frame";
56 0 ▶ eval "require $frame; $frame->import(); 1;"
Branch: 1 branch
BranchTrueFalseTotal
eval "require $frame; $frame->import(); 1;" or do "Lab::Exception::CorruptParameter"->throw("error", $@) 0 0 0
57 or do Lab::Exception::CorruptParameter->throw( error => $@ );
58  
59 #or do Lab::Exception::CorruptParameter->throw( error => "Can't locate module $frame\n" );
60  
61 0 return $frame->new(@_);
62  
63 }
64  
65 sub Instrument {
66 10 ▶ my $self = shift;
Subroutine Instrument: called CC=3 SCAR=14.2
Pod undocumented
67 10 my $instrument;
68 10 ▶ if ( ref($self) eq __PACKAGE__ ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $self eq __PACKAGE__) { } 0 10 10
69 0 $instrument = shift;
70 }
71 else {
72 10 $instrument = $self;
73 }
74  
75 10 my $module = "Lab::Instrument::" . $instrument;
76 10 my $found_module;
77  
78 try {
79 10 ▶ autoload($module);
Subroutine __ANON__: called CC=1 SCAR=0.0
80 10 $found_module = 1;
81 }
82 catch {
83 # Do not try to load a Moose driver, if the problem is just
84 # a syntax error in the non-Moose driver.
85 0 ▶ if ( $_ =~ /Compilation failed in require/ ) {
Subroutine __ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
BranchTrueFalseTotal
if ($_ =~ /Compilation failed in require/u) 0 0 0
86 0 die $_;
87 }
88 10 };
89  
90 10 ▶ if ($found_module) {
Branch: 1 branch
BranchTrueFalseTotal
if ($found_module) 10 0 10
91 10 return $module->new(@_);
92 }
93  
94 0 $module = "Lab::Moose::Instrument::" . $instrument;
95 0 load($module);
96  
97 0 my $args_ref = shift;
98 0 my $connection_type = delete $args_ref->{connection_type};
99  
100 # Somewhat problematic, as the args_ref mixes connection options
101 # with instrument options. => Better use the Lab::Moose constructor ;)
102 return $module->new(
103 connection_type => $connection_type,
104 connection_options => $args_ref,
105 0 %{$args_ref},
106 );
107 }
108  
109 sub Connection {
110 1 ▶ my $self = shift if ref( $_[0] ) eq __PACKAGE__;
Subroutine Connection: called CC=3 SCAR=11.3
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
if ref $_[0] eq __PACKAGE__ 0 1 1
111 1 my $connection = shift;
112  
113 1 $connection = "Lab::Connection::" . $connection;
114 1 ▶ eval "require $connection; $connection->import(); 1;"
Branch: 1 branch
BranchTrueFalseTotal
eval "require $connection; $connection->import(); 1;" or do "Lab::Exception::CorruptParameter"->throw("error", $@) 0 1 1
115 or do Lab::Exception::CorruptParameter->throw( error => $@ );
116  
117 #or do Lab::Exception::CorruptParameter->throw( error => "Can't locate module $connection\n" );
118  
119 1 return $connection->new(@_);
120  
121 }
122  
123 sub show_available_objects {
124 0 ▶ my $self = shift if ref( $_[0] ) eq __PACKAGE__;
Subroutine show_available_objects: not called CC=5 SCAR=34.0
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
if ref $_[0] eq __PACKAGE__ 0 0 0
125  
126 0 my $xDIR = $INC{"Lab/XPRESS/hub.pm"};
127 0 $xDIR =~ s/hub.pm//g;
128  
129 0 opendir( DIR, $xDIR . "Sweep" );
130 0 my @sweeps = readdir(DIR);
131 0 shift @sweeps; # shift "."
132 0 shift @sweeps; # shift ".."
133  
134 0 $xDIR =~ s/XPRESS\///g;
135 0 opendir( DIR, $xDIR . "Instrument" );
136 0 my @instruments = readdir(DIR);
137 0 shift @instruments; # shift "."
138 0 shift @instruments; # shift ".."
139  
140 0 $xDIR =~ s/Instrument\///g;
141 0 opendir( DIR, $xDIR . "Connection" );
142 0 my @connections = readdir(DIR);
143 0 shift @connections; # shift "."
144 0 shift @connections; # shift ".."
145  
146 0 print "\n\n";
147 0 print "================\n";
148 0 print " XPRESS add-on: \n";
149 0 print "================\n";
150 0 print "\n\n";
151  
152 0 print "available connections:\n";
153 0 print "--------------------------\n";
154 0 foreach my $module (@connections) {
155 0 $module =~ s/\.pm//g;
156 0 print $module. "\n";
157 }
158 0 print "--------------------------\n";
159 0 print "\n\n";
160  
161 0 print "available Instruments:\n";
162 0 print "--------------------------\n";
163 0 foreach my $module (@instruments) {
164 0 $module =~ s/\.pm//g;
165 0 print $module. "\n";
166 }
167 0 print "--------------------------\n";
168 0 print "\n\n";
169  
170 0 print "available sweep modules:\n";
171 0 print "--------------------------\n";
172 0 foreach my $module (@sweeps) {
173 0 $module =~ s/\.pm//g;
174 0 print $module. "\n";
175 }
176 0 print "--------------------------\n";
177 0 print "\n\n";
178  
179 }
180  
181 8 1;
182  
183 __END__
184  
185 =pod
186  
187 =encoding UTF-8
188  
189 =head1 NAME
190  
191 Lab::XPRESS::hub - The XPRESS main hub
192  
193 =head1 VERSION
194  
195 version 3.881
196  
197 =head1 COPYRIGHT AND LICENSE
198  
199 This software is copyright (c) 2023 by the Lab::Measurement team; in detail:
200  
201 Copyright 2012 Stefan Geissler
202 2013 Alois Dirnaichner, Andreas K. Huettel, Christian Butschkow
203 2016 Simon Reinhardt
204 2017 Andreas K. Huettel, Simon Reinhardt
205 2020 Andreas K. Huettel
206  
207  
208 This is free software; you can redistribute it and/or modify it under
209 the same terms as the Perl 5 programming language system itself.
210  
211 =cut
« Moose/Connection/VISA.pm ↑ Summary Moose/Instrument/Bluefors_Temp.pm »