| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Lab::Instrument::TemperatureDiode; |
|
2
|
|
|
|
|
|
|
#ABSTRACT: ????? |
|
3
|
|
|
|
|
|
|
$Lab::Instrument::TemperatureDiode::VERSION = '3.880'; |
|
4
|
1
|
|
|
1
|
|
1760
|
use v5.20; |
|
|
1
|
|
|
|
|
5
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
6
|
use strict; |
|
|
1
|
|
|
|
|
5
|
|
|
|
1
|
|
|
|
|
21
|
|
|
7
|
1
|
|
|
1
|
|
10
|
use Math::Complex; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
184
|
|
|
8
|
1
|
|
|
1
|
|
9
|
use Lab::Exception; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
26
|
|
|
9
|
1
|
|
|
1
|
|
5
|
use Scalar::Util qw(weaken); |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
54
|
|
|
10
|
1
|
|
|
1
|
|
8
|
use Carp qw(croak cluck); |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
49
|
|
|
11
|
1
|
|
|
1
|
|
6
|
use Data::Dumper; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
385
|
|
|
12
|
|
|
|
|
|
|
our $AUTOLOAD; |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
our %fields = ( |
|
15
|
|
|
|
|
|
|
instrument => undef, |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
device_cache => { |
|
18
|
|
|
|
|
|
|
id => undef, |
|
19
|
|
|
|
|
|
|
}, |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
device_cache_order => ['id'], |
|
22
|
|
|
|
|
|
|
); |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
our @ISA = (); |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub new { |
|
27
|
0
|
|
|
0
|
0
|
|
my $proto = shift; |
|
28
|
0
|
|
0
|
|
|
|
my $class = ref($proto) || $proto; |
|
29
|
0
|
|
|
|
|
|
my $config = undef; |
|
30
|
0
|
0
|
|
|
|
|
if ( ref $_[0] eq 'HASH' ) { |
|
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__); |
|
|
0
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
|
|
38
|
0
|
|
|
|
|
|
while ( my ( $k, $v ) = each %{$config} ) { |
|
|
0
|
|
|
|
|
|
|
|
39
|
0
|
|
|
|
|
|
$self->{$k} = $v; |
|
40
|
|
|
|
|
|
|
} |
|
41
|
|
|
|
|
|
|
|
|
42
|
0
|
0
|
|
|
|
|
if ( not defined $self->instrument() ) { |
|
|
|
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
|
|
|
0
|
|
|
( my $self, my $package ) = ( shift, shift ); |
|
57
|
0
|
|
|
|
|
|
my $class = ref($self); |
|
58
|
0
|
|
|
|
|
|
my $fields = undef; |
|
59
|
|
|
|
|
|
|
{ |
|
60
|
1
|
|
|
1
|
|
11
|
no strict 'refs'; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
1069
|
|
|
|
0
|
|
|
|
|
|
|
|
61
|
0
|
|
|
|
|
|
$fields = *${ \( $package . '::fields' ) }{HASH}; |
|
|
0
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
} |
|
63
|
0
|
|
|
|
|
|
my $twin = undef; |
|
64
|
|
|
|
|
|
|
|
|
65
|
0
|
|
|
|
|
|
foreach my $element ( keys %{$fields} ) { |
|
|
0
|
|
|
|
|
|
|
|
66
|
0
|
|
|
|
|
|
$self->{_permitted}->{$element} = $fields->{$element}; |
|
67
|
|
|
|
|
|
|
} |
|
68
|
0
|
|
|
|
|
|
@{$self}{ keys %{$fields} } = values %{$fields}; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
} |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
# converts given measurementvalue to a temperature in Kelvin |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
sub config { # $value = self->config($key); |
|
74
|
0
|
|
|
0
|
0
|
|
( my $self, my $key ) = ( shift, shift ); |
|
75
|
|
|
|
|
|
|
|
|
76
|
0
|
0
|
|
|
|
|
if ( !defined $key ) { |
|
|
|
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
|
|
|
0
|
0
|
|
my $self = shift; |
|
89
|
0
|
|
|
|
|
|
my ($id) = $self->_check_args( \@_, ['id'] ); |
|
90
|
0
|
|
|
|
|
|
$self->{'device_cache'}->{'id'} = $id; |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
} |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
sub get_id { |
|
95
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
96
|
0
|
|
|
|
|
|
return $self->{'device_cache'}->{'id'}; |
|
97
|
|
|
|
|
|
|
} |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
sub get_value { |
|
100
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
101
|
|
|
|
|
|
|
|
|
102
|
0
|
|
|
|
|
|
return $self->get_T(@_); |
|
103
|
|
|
|
|
|
|
} |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
sub get_T { |
|
106
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
107
|
0
|
|
|
|
|
|
my $options = undef; |
|
108
|
0
|
0
|
|
|
|
|
if ( ref $_[0] eq 'HASH' ) { $options = shift } |
|
|
0
|
|
|
|
|
|
|
|
109
|
0
|
|
|
|
|
|
else { $options = {@_} } |
|
110
|
|
|
|
|
|
|
|
|
111
|
0
|
0
|
0
|
|
|
|
if ( $options->{read_mode} eq 'cache' |
|
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
|
0
|
|
|
|
|
if ( defined $value ) { |
|
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
|
|
|
0
|
0
|
|
my $self = shift; |
|
127
|
0
|
|
|
|
|
|
return; |
|
128
|
|
|
|
|
|
|
} |
|
129
|
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
sub _check_args { |
|
131
|
0
|
|
|
0
|
|
|
my $self = shift; |
|
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} ) { |
|
|
0
|
|
|
|
|
|
|
|
141
|
0
|
0
|
|
|
|
|
if ( ref($arg) ne "HASH" ) { |
|
142
|
0
|
0
|
|
|
|
|
if ( defined @{$params}[$i] ) { |
|
|
0
|
|
|
|
|
|
|
|
143
|
0
|
|
|
|
|
|
$tempo_hash->{ @{$params}[$i] } = $arg; |
|
|
0
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
} |
|
146
|
0
|
|
|
|
|
|
$i++; |
|
147
|
|
|
|
|
|
|
} |
|
148
|
|
|
|
|
|
|
else { |
|
149
|
0
|
|
|
|
|
|
%{$arguments} = ( %{$tempo_hash}, %{ @{$args}[$i] } ); |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
150
|
0
|
|
|
|
|
|
last; |
|
151
|
|
|
|
|
|
|
} |
|
152
|
|
|
|
|
|
|
} |
|
153
|
|
|
|
|
|
|
|
|
154
|
0
|
0
|
|
|
|
|
if ( not defined $arguments ) { |
|
155
|
0
|
|
|
|
|
|
$arguments = $tempo_hash; |
|
156
|
|
|
|
|
|
|
} |
|
157
|
|
|
|
|
|
|
|
|
158
|
0
|
|
|
|
|
|
my @return_args = (); |
|
159
|
|
|
|
|
|
|
|
|
160
|
0
|
|
|
|
|
|
foreach my $param ( @{$params} ) { |
|
|
0
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
|
|
162
|
0
|
0
|
|
|
|
|
if ( exists $arguments->{$param} ) { |
|
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
|
0
|
|
|
|
|
if ( exists $arguments->{$param} ) { |
|
175
|
0
|
|
|
|
|
|
delete $arguments->{$param}; |
|
176
|
|
|
|
|
|
|
} |
|
177
|
|
|
|
|
|
|
} |
|
178
|
|
|
|
|
|
|
|
|
179
|
0
|
0
|
|
|
|
|
if ( scalar( keys %{$arguments} ) > 0 ) { |
|
|
0
|
|
|
|
|
|
|
|
180
|
0
|
|
|
|
|
|
my $errmess = "Unknown parameter given in $self :"; |
|
181
|
0
|
|
|
|
|
|
while ( my ( $k, $v ) = each %{$arguments} ) { |
|
|
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
|
|
|
0
|
|
|
my $self = shift; |
|
193
|
0
|
0
|
|
|
|
|
my $type = ref($self) or croak "$self is not an object"; |
|
194
|
|
|
|
|
|
|
|
|
195
|
0
|
|
|
|
|
|
my $name = $AUTOLOAD; |
|
196
|
0
|
|
|
|
|
|
$name =~ s/.*://; # strip fully qualified portion |
|
197
|
|
|
|
|
|
|
|
|
198
|
0
|
0
|
|
|
|
|
unless ( exists $self->{_permitted}->{$name} ) { |
|
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
|
0
|
|
|
|
|
if (@_) { |
|
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
|
|
|
0
|
|
|
my $self = shift; |
|
218
|
0
|
0
|
|
|
|
|
$self->SUPER::DESTROY if $self->can("SUPER::DESTROY"); |
|
219
|
|
|
|
|
|
|
} |
|
220
|
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
# defined sensors |
|
222
|
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
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.880 |
|
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 |