Instrument/TemperatureDiode.pm

filter: Statementstmt 20.5% 28 / 136 Branchbran 0.0% 0 / 40 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 42.1% 8 / 19 Podpod 0.0% 0 / 7 totaltotal 16.9% 36 / 212 SCAR 61.5
CC
27
Cov
15%
_check_args
132.0
new
42.0
get_T
30.0
CRAP 468.6
« Instrument/OI_ITC503.pm ↑ Summary Moose/Instrument/OI_IPS.pm »
1 package Lab::Instrument::TemperatureDiode;
2 #ABSTRACT: ?????
3 1 $Lab::Instrument::TemperatureDiode::VERSION = '3.881';
4 1 ▶use v5.20;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use Math::Complex;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use Lab::Exception;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use Scalar::Util qw(weaken);
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use Carp qw(croak cluck);
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 1 our $AUTOLOAD;
13  
14 1 our %fields = (
15 instrument => undef,
16  
17 device_cache => {
18 id => undef,
19 },
20  
21 device_cache_order => ['id'],
22 );
23  
24 1 our @ISA = ();
25  
26 sub new {
27 0 ▶ my $proto = shift;
Subroutine new: not called CC=6 SCAR=37.4
Pod undocumented
28 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
29 0 my $config = undef;
30 0 ▶ if ( ref $_[0] eq 'HASH' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $_[0] eq 'HASH') { } 0 0 0
31 0 $config = shift;
32 } # try to be flexible about options as hash/hashref
33 0 else { $config = {@_} }
34 0 my $self = {};
35 0 bless( $self, $class );
36 0 $self->${ \( __PACKAGE__ . '::_construct' ) }(__PACKAGE__);
37  
38 0 ▶ while ( my ( $k, $v ) = each %{$config} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %{$config;}) 0 0 0
39 0 $self->{$k} = $v;
40 }
41  
42 0 ▶ if ( not defined $self->instrument() ) {
Branch: 2 branches
BranchTrueFalseTotal
if (not defined $self->instrument) { } 0 0 0
elsif (not ref($self->instrument) =~ /^(Lab::Instrument)/u) { } 0 0 0
43 0 Lab::Exception::Error->throw( error => $self->get_id()
44 . ": No intrument for temperature measurment defined!" );
45 }
46 elsif ( not ref( $self->instrument() ) =~ /^(Lab::Instrument)/ ) {
47 0 Lab::Exception::Error->throw( error => $self->get_id()
48 . ": Object for temperature measurement is not an instrument!"
49 );
50 }
51  
52 0 return $self;
53 }
54  
55 sub _construct { # _construct(__PACKAGE__);
56 0 ▶ ( my $self, my $package ) = ( shift, shift );
Subroutine _construct: not called CC=2 SCAR=14.4
57 0 my $class = ref($self);
58 0 my $fields = undef;
59 {
60 1 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.2
61 0 $fields = *${ \( $package . '::fields' ) }{HASH};
62 }
63 0 my $twin = undef;
64  
65 0 foreach my $element ( keys %{$fields} ) {
66 0 $self->{_permitted}->{$element} = $fields->{$element};
67 }
68 0 @{$self}{ keys %{$fields} } = values %{$fields};
69 }
70  
71 # converts given measurementvalue to a temperature in Kelvin
72  
73 sub config { # $value = self->config($key);
74 0 ▶ ( my $self, my $key ) = ( shift, shift );
Subroutine config: not called CC=3 SCAR=24.8
Pod undocumented
75  
76 0 ▶ if ( !defined $key ) {
Branch: 2 branches
BranchTrueFalseTotal
if (not defined $key) { } 0 0 0
elsif (ref($key) =~ /HASH/u) { } 0 0 0
77 0 return $self->{'config'};
78 }
79 elsif ( ref($key) =~ /HASH/ ) {
80 0 return $self->{'config'} = $key;
81 }
82 else {
83 0 return $self->{'config'}->{$key};
84 }
85 }
86  
87 sub set_id {
88 0 ▶ my $self = shift;
Subroutine set_id: not called CC=1 SCAR=6.9
Pod undocumented
89 0 my ($id) = $self->_check_args( \@_, ['id'] );
90 0 $self->{'device_cache'}->{'id'} = $id;
91  
92 }
93  
94 sub get_id {
95 0 ▶ my $self = shift;
Subroutine get_id: not called CC=1 SCAR=6.9
Pod undocumented
96 0 return $self->{'device_cache'}->{'id'};
97 }
98  
99 sub get_value {
100 0 ▶ my $self = shift;
Subroutine get_value: not called CC=1 SCAR=6.9
Pod undocumented
101  
102 0 return $self->get_T(@_);
103 }
104  
105 sub get_T {
106 0 ▶ my $self = shift;
Subroutine get_T: not called CC=5 SCAR=34.0
Pod undocumented
107 0 my $options = undef;
108 0 ▶ if ( ref $_[0] eq 'HASH' ) { $options = shift }
Branch: 1 branch
BranchTrueFalseTotal
if (ref $_[0] eq 'HASH') { } 0 0 0
109 0 else { $options = {@_} }
110  
111 0 ▶ if ( $options->{read_mode} eq 'cache'
Branch: 1 branch
BranchTrueFalseTotal
if ($options->{"read_mode"} eq "cache" and defined $self->{"device_cache"}{"T"}) 0 0 0
Condition0%0/3
$options->{"read_mode"} eq "cache" and defined $self->{"device_cache"}{"T"}
!ll&&!rl&&r
000
MC/DC0%0/2
$options->{"read_mode"} eq "cache" and defined $self->{"device_cache"}{"T"}
$options->{"read_mode"} eq "cache" defined $self->{"device_cache"}{"T"}
Truth table0%0/3
A and B
A= $options->{"read_mode"} eq "cache"B= defined $self->{"device_cache"}{"T"}
ABresult
0X0
100
111
112 and defined $self->{'device_cache'}->{'T'} ) {
113 0 return $self->{'device_cache'}->{'T'};
114 }
115  
116 0 my $value = $self->instrument()->get_value($options);
117 0 ▶ if ( defined $value ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value) { } 0 0 0
118 0 return $self->device_cache()->{T} = $self->convert2Kelvin($value);
119 }
120 else {
121 0 return undef;
122 }
123 }
124  
125 sub convert2Kelvin {
126 0 ▶ my $self = shift;
Subroutine convert2Kelvin: not called CC=1 SCAR=6.9
Pod undocumented
127 0 return;
128 }
129  
130 sub _check_args {
131 0 ▶ my $self = shift;
Subroutine _check_args: not called CC=11 SCAR=48.8
132 0 my $args = shift;
133 0 my $params = shift;
134  
135 0 my $arguments;
136  
137 0 my $i = 0;
138 0 my $tempo_hash = {};
139  
140 0 foreach my $arg ( @{$args} ) {
141 0 ▶ if ( ref($arg) ne "HASH" ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $arg ne 'HASH') { } 0 0 0
142 0 ▶ if ( defined @{$params}[$i] ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined @{$params;}[$i]) 0 0 0
143 0 $tempo_hash->{ @{$params}[$i] } = $arg;
144  
145 }
146 0 $i++;
147 }
148 else {
149 0 %{$arguments} = ( %{$tempo_hash}, %{ @{$args}[$i] } );
150 0 last;
151 }
152 }
153  
154 0 ▶ if ( not defined $arguments ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $arguments) 0 0 0
155 0 $arguments = $tempo_hash;
156 }
157  
158 0 my @return_args = ();
159  
160 0 foreach my $param ( @{$params} ) {
161  
162 0 ▶ if ( exists $arguments->{$param} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $arguments->{$param}) { } 0 0 0
163 0 push( @return_args, $arguments->{$param} );
164 0 delete $arguments->{$param};
165 }
166 else {
167 0 push( @return_args, undef );
168 }
169 }
170  
171 0 foreach my $param ( 'from_device', 'from_cache'
172 ) # Delete Standard option parameters from $arguments hash if not defined in device driver function
173 {
174 0 ▶ if ( exists $arguments->{$param} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $arguments->{$param}) 0 0 0
175 0 delete $arguments->{$param};
176 }
177 }
178  
179 0 ▶ if ( scalar( keys %{$arguments} ) > 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar keys %{$arguments;} > 0) 0 0 0
180 0 my $errmess = "Unknown parameter given in $self :";
181 0 ▶ while ( my ( $k, $v ) = each %{$arguments} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %{$arguments;}) 0 0 0
182 0 $errmess .= $k . " => " . $v . "\t";
183 }
184 0 print Lab::Exception::Warning->new( error => $errmess );
185 }
186  
187 0 return @return_args;
188 }
189  
190 sub AUTOLOAD {
191  
192 0 ▶ my $self = shift;
Subroutine AUTOLOAD: not called CC=4 SCAR=30.0
193 0 ▶ my $type = ref($self) or croak "$self is not an object";
Branch: 1 branch
BranchTrueFalseTotal
my $type = ref $self or croak("$self is not an object") 0 0 0
194  
195 0 my $name = $AUTOLOAD;
196 0 $name =~ s/.*://; # strip fully qualified portion
197  
198 0 ▶ unless ( exists $self->{_permitted}->{$name} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $self->{"_permitted"}{$name}) 0 0 0
199 0 cluck( "AUTOLOAD in "
200 . __PACKAGE__
201 . " couldn't access field '${name}'.\n" );
202 0 Lab::Exception::Error->throw( error => "AUTOLOAD in "
203 . __PACKAGE__
204 . " couldn't access field '${name}'.\n" );
205 }
206  
207 0 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) { } 0 0 0
208 0 return $self->{$name} = shift;
209 }
210 else {
211 0 return $self->{$name};
212 }
213 }
214  
215 # needed so AUTOLOAD doesn't try to call DESTROY on cleanup and prevent the inherited DESTROY
216 sub DESTROY {
217 0 ▶ my $self = shift;
Subroutine DESTROY: not called CC=2 SCAR=17.9
218 0 ▶ $self->SUPER::DESTROY if $self->can("SUPER::DESTROY");
Branch: 1 branch
BranchTrueFalseTotal
if $self->can("SUPER::DESTROY") 0 0 0
219 }
220  
221 # defined sensors
222  
223 1 1;
224  
225 __END__
226  
227 =pod
228  
229 =encoding UTF-8
230  
231 =head1 NAME
232  
233 Lab::Instrument::TemperatureDiode - ?????
234  
235 =head1 VERSION
236  
237 version 3.881
238  
239 =head1 COPYRIGHT AND LICENSE
240  
241 This software is copyright (c) 2023 by the Lab::Measurement team; in detail:
242  
243 Copyright 2013 Christian Butschkow
244 2016 Simon Reinhardt
245 2017 Andreas K. Huettel
246 2020 Andreas K. Huettel
247  
248  
249 This is free software; you can redistribute it and/or modify it under
250 the same terms as the Perl 5 programming language system itself.
251  
252 =cut
« Instrument/OI_ITC503.pm ↑ Summary Moose/Instrument/OI_IPS.pm »