File Coverage

blib/lib/Lab/Moose/Instrument/Synctek_MCL1_540.pm
Criterion Covered Total %
statement 26 86 30.2
branch n/a
condition n/a
subroutine 9 37 24.3
pod 0 28 0.0
total 35 151 23.1


line stmt bran cond sub pod time code
1             package Lab::Moose::Instrument::Synctek_MCL1_540;
2             $Lab::Moose::Instrument::Synctek_MCL1_540::VERSION = '3.881';
3             #ABSTRACT: Synctek MCL1-540 Lock-in Amplifier
4              
5 1     1   2304 use v5.20;
  1         4  
6              
7 1     1   6 use strict;
  1         4  
  1         27  
8 1     1   5 use Moose;
  1         3  
  1         11  
9 1     1   7770 use Moose::Util::TypeConstraints qw/enum/;
  1         3  
  1         11  
10 1     1   573 use MooseX::Params::Validate;
  1         3  
  1         13  
11 1         78 use Lab::Moose::Instrument qw/
12             validated_getter
13             validated_setter
14             validated_no_param_setter
15             setter_params
16 1     1   605 /;
  1         2  
17 1     1   6 use Carp;
  1         3  
  1         56  
18 1     1   9 use namespace::autoclean;
  1         4  
  1         9  
19 1     1   107 use Time::HiRes qw/time usleep/;
  1         3  
  1         33  
20              
21             extends 'Lab::Moose::Instrument';
22              
23              
24             # TODO
25             # ====
26             # - how is ip address and port configured?
27             # --> port 8002 is fixed
28             # --> ip is required for init
29             # - type checks for write arguments - done
30             # - URL structure - done
31             # - names of outputs
32             # - which functions to implement?
33              
34              
35             # default connection options:
36             around default_connection_options => sub {
37             my $orig = shift;
38             my $self = shift;
39             my $options = $self->$orig();
40              
41             $options->{WWW}{port} = 8002;
42             return $options;
43             };
44              
45              
46             # html escape sequences
47             sub request {
48 0     0 0   my ( $self, %args ) = validated_getter(
49             \@_,
50             type => { isa => enum( [qw/config data/] ) },
51             id => { isa => 'Str' },
52             action => { isa => enum( [qw/get set/] ) },
53             path => { isa => 'Str' },
54             );
55 0           my $type = delete $args{'type'};
56 0           my $id = delete $args{'id'};
57 0           my $action = delete $args{'action'};
58 0           my $path = delete $args{'path'};
59 0           return query( command =>
60             "/MCL/api?type=$type&id=$id&action=$action&path=$path"
61             );
62             }
63              
64             # Configuration dump and write todo
65              
66             # WTF is das System mit dem Array?
67             # TODO: - use a single function to return all DC voltages
68             # => use hash to match A_V1->id=L1,DC[0] etc
69             sub get_A_V1_DC {
70 0     0 0   my $self = shift;
71 0           return $self->request(
72             type => "data",
73             id => "L1",
74             action => "get",
75             path => "/output_cluster/DataReadings/DC[0]/"
76             );
77             }
78              
79             sub get_A_V2_DC {
80 0     0 0   my $self = shift;
81 0           return $self->request(
82             type => "data",
83             id => "L1",
84             action => "get",
85             path => "/output_cluster/DataReadings/DC[1]/"
86             );
87             }
88              
89             sub get_B_V1_DC {
90 0     0 0   my $self = shift;
91 0           return $self->request(
92             type => "data",
93             id => "L1",
94             action => "get",
95             path => "/output_cluster/DataReadings/DC[2]/"
96             );
97             }
98              
99             sub get_B_V2_DC {
100 0     0 0   my $self = shift;
101 0           return $self->request(
102             type => "data",
103             id => "L1",
104             action => "get",
105             path => "/output_cluster/DataReadings/DC[3]/"
106             );
107             }
108              
109             sub get_C_V1_DC {
110 0     0 0   my $self = shift;
111 0           return $self->request(
112             type => "data",
113             id => "L1",
114             action => "get",
115             path => "/output_cluster/DataReadings/DC[4]/"
116             );
117             }
118              
119             sub get_C_V2_DC {
120 0     0 0   my $self = shift;
121 0           return $self->request(
122             type => "data",
123             id => "L1",
124             action => "get",
125             path => "/output_cluster/DataReadings/DC[5]/"
126             );
127             }
128              
129             sub get_D_V1_DC {
130 0     0 0   my $self = shift;
131 0           return $self->request(
132             type => "data",
133             id => "L1",
134             action => "get",
135             path => "/output_cluster/DataReadings/DC[6]/"
136             );
137             }
138              
139             sub get_D_V2_DC {
140 0     0 0   my $self = shift;
141 0           return $self->request(
142             type => "data",
143             id => "L1",
144             action => "get",
145             path => "/output_cluster/DataReadings/DC[7]/"
146             );
147             }
148              
149             sub get_E_V1_DC {
150 0     0 0   my $self = shift;
151 0           return $self->request(
152             type => "data",
153             id => "L1",
154             action => "get",
155             path => "/output_cluster/DataReadings/DC[8]/"
156             );
157             }
158              
159             sub get_E_V2_DC {
160 0     0 0   my $self = shift;
161 0           return $self->request(
162             type => "data",
163             id => "L1",
164             action => "get",
165             path => "/output_cluster/DataReadings/DC[9]/"
166             );
167             }
168              
169             sub get_AI {
170 0     0 0   my $self = shift;
171 0           return $self->request(
172             type => "data",
173             id => "L1",
174             action => "get",
175             path => "/output_cluster/DataReadings/DC[10]/"
176             );
177             }
178              
179             sub get_BI {
180 0     0 0   my $self = shift;
181 0           return $self->request(
182             type => "data",
183             id => "L1",
184             action => "get",
185             path => "/output_cluster/DataReadings/DC[11]/"
186             );
187             }
188              
189             sub get_CI {
190 0     0 0   my $self = shift;
191 0           return $self->request(
192             type => "data",
193             id => "L1",
194             action => "get",
195             path => "/output_cluster/DataReadings/DC[12]/"
196             );
197             }
198              
199             sub get_DI {
200 0     0 0   my $self = shift;
201 0           return $self->request(
202             type => "data",
203             id => "L1",
204             action => "get",
205             path => "/output_cluster/DataReadings/DC[13]/"
206             );
207             }
208              
209             sub get_EI {
210 0     0 0   my $self = shift;
211 0           return $self->request(
212             type => "data",
213             id => "L1",
214             action => "get",
215             path => "/output_cluster/DataReadings/DC[14]/"
216             );
217             }
218              
219             sub get_L1_X_0 {
220 0     0 0   my $self = shift;
221 0           return $self->request(
222             type => "data",
223             id => "L1",
224             action => "get",
225             path => "/output_cluster/DataReadings/X[0]/"
226             );
227             }
228              
229             sub get_L1_Y_0 {
230 0     0 0   my $self = shift;
231 0           return $self->request(
232             type => "data",
233             id => "L1",
234             action => "get",
235             path => "/output_cluster/DataReadings/Y[0]/"
236             );
237             }
238              
239             sub get_L1_X_10 {
240 0     0 0   my $self = shift;
241 0           return $self->request(
242             type => "data",
243             id => "L1",
244             action => "get",
245             path => "/output_cluster/DataReadings/X[10]/"
246             );
247             }
248              
249             sub get_L1_Y_10 {
250 0     0 0   my $self = shift;
251 0           return $self->request(
252             type => "data",
253             id => "L1",
254             action => "get",
255             path => "/output_cluster/DataReadings/Y[10]/"
256             );
257             }
258              
259             sub get_L1_frq {
260 0     0 0   my $self = shift;
261 0           return $self->request(
262             type => "data",
263             id => "L1",
264             action => "get",
265             path =>
266             "/output_cluster/GeneralReadings/Lock-in_f_(Hz)"
267             );
268             }
269              
270             sub set_L1_frq {
271 0     0 0   my $self = shift;
272 0           return $self->request(
273             type => "config",
274             id => "Freq_1",
275             action => "set",
276             path =>
277             "/FrequencyCtrl/Frequency_(Hz)&value=..."
278             );
279             }
280              
281             sub get_Offset_1 {
282 0     0 0   my $self = shift;
283 0           return $self->request(
284             type => "config",
285             id => "Offset_1",
286             action => "get",
287             path =>
288             "/OffsetCtrl/Offset_(V)"
289             );
290             }
291              
292             sub set_Offset_1 {
293 0     0 0   my $self = shift;
294 0           return $self->request(
295             type => "config",
296             id => "Offset_1",
297             action => "set",
298             path =>
299             "/OffsetCtrl/Offset_(V)&value=..."
300             );
301             }
302              
303             sub get_Amplitude_1 {
304 0     0 0   my $self = shift;
305 0           return $self->request(
306             type => "config",
307             id => "Amplitude_1",
308             action => "get",
309             path =>
310             "/AmplitudeCtrl/Amplitude:Amplitude"
311             );
312             }
313              
314             sub set_Amplitude_1 {
315 0     0 0   my $self = shift;
316 0           return $self->request(
317             type => "config",
318             id => "Amplitude_1",
319             action => "set",
320             path =>
321             "/AmplitudeCtrl/Amplitude:Amplitude&value=..."
322             );
323             }
324              
325             sub get_time_constant_1 {
326 0     0 0   my $self = shift;
327 0           return $self->request(
328             type => "config",
329             id => "Lockin_L1",
330             action => "get",
331             path =>
332             "/LockinCtrl/Time_constant_(s)"
333             );
334             }
335              
336             sub set_time_constant_1 {
337 0     0 0   my $self = shift;
338 0           return $self->request(
339             type => "config",
340             id => "Lockin_L1",
341             action => "set",
342             path =>
343             "/LockinCtrl/Time_constant_(s)&value=..."
344             );
345             }
346              
347              
348              
349             __PACKAGE__->meta()->make_immutable();
350              
351             1;
352              
353             __END__
354              
355             =pod
356              
357             =encoding UTF-8
358              
359             =head1 NAME
360              
361             Lab::Moose::Instrument::Synctek_MCL1_540 - Synctek MCL1-540 Lock-in Amplifier
362              
363             =head1 VERSION
364              
365             version 3.881
366              
367             =head1 SYNOPSIS
368              
369             use Lab::Moose;
370              
371             my $lockin = instrument(...);
372              
373             TODO
374              
375             =head2 Consumed Roles
376              
377             This driver consumes the following roles:
378              
379             =over
380              
381             =item TODO
382              
383             =back
384              
385             =head1 COPYRIGHT AND LICENSE
386              
387             This software is copyright (c) 2023 by the Lab::Measurement team; in detail:
388              
389             Copyright 2022 Jonas Schambeck, Mia Schambeck, Simon Reinhardt
390             2023 Mia Schambeck
391              
392              
393             This is free software; you can redistribute it and/or modify it under
394             the same terms as the Perl 5 programming language system itself.
395              
396             =cut