File Coverage

blib/lib/Lab/Moose/Instrument/NanonisTramea.pm
Criterion Covered Total %
statement 32 1496 2.1
branch 0 194 0.0
condition 0 84 0.0
subroutine 11 143 7.6
pod 10 121 8.2
total 53 2038 2.6


line stmt bran cond sub pod time code
1             package Lab::Moose::Instrument::NanonisTramea;
2             $Lab::Moose::Instrument::NanonisTramea::VERSION = '3.880';
3             #ABSTRACT: Nanonis Tramea
4              
5 1     1   2446 use v5.20;
  1         5  
6              
7 1     1   6 use Moose;
  1         2  
  1         7  
8 1     1   7123 use Moose::Util::TypeConstraints;
  1         9  
  1         12  
9 1     1   2687 use MooseX::Params::Validate;
  1         3  
  1         13  
10 1     1   533 use Carp;
  1         6  
  1         61  
11 1     1   6 use PDL::Core;
  1         2  
  1         16  
12 1     1   437 use PDL::IO::CSV ":all";
  1         3  
  1         19  
13 1     1   226 use List::Util qw(max);
  1         3  
  1         83  
14 1     1   7 use Lab::Moose;
  1         4  
  1         18  
15 1         74 use Lab::Moose::Instrument qw/
16 1     1   7 validated_getter validated_setter/;
  1         2  
17             extends 'Lab::Moose::Instrument';
18             class_type 'Lab::Moose::Sweep';
19             class_type 'Lab::Moose::DataFile';
20 1     1   8 use namespace::autoclean;
  1         2  
  1         9  
21              
22              
23              
24             sub nt_string {
25 0     0 1   my $s = shift;
26 0           return (pack "N", length($s)) . $s;
27             }
28              
29             sub nt_int {
30 0     0 1   my $i = shift;
31 0           return pack "N!", $i;
32             }
33              
34             sub nt_uint16 {
35 0     0 1   my $i = shift;
36 0           return pack "n", $i;
37             }
38              
39             sub nt_uint32 {
40 0     0 1   my $i = shift;
41 0           return pack "N", $i;
42             }
43              
44             sub nt_float32 {
45 0     0 1   my $f = shift;
46 0           return pack "f>", $f;
47             }
48              
49             sub nt_float64 {
50 0     0 1   my $f = shift;
51 0           return pack "d>", $f;
52             }
53              
54              
55             sub nt_header {
56 0     0 1   my ($self,$command,$b_size,$response) =@_;
57 0           $command = lc($command);
58 0           my ($pad_len) = 32 - length($command);
59 0           my($template)="A".length($command);
60 0           for (1..$pad_len){
61              
62 0           $template=$template."x"
63             }
64 0           my $cmd= pack($template,$command);
65 0           my $bodysize= nt_int($b_size);
66 0           my $rsp= nt_uint16($response);
67 0           return $cmd.$bodysize.$rsp.nt_uint16(0);
68             }
69              
70              
71             sub _end_of_com
72             {
73 0     0     my $self = shift;
74 0           my $response = $self->tramea_read();
75 0 0         if(length($response)==40){
76 0           my $response_bodysize = unpack("N!",substr($response,32,4));
77 0 0         if($response_bodysize>0)
78             {
79 0           print(substr($response,40,$response_bodysize)."\n");
80 0           die "(Proto) Error returned by nanonis software"
81             }
82             }
83 0           return $response
84             }
85              
86             sub tramea_read {
87 0     0 0   my $self = shift;
88 0           my $head = $self->binary_read(read_length=>40);
89 0           my $body_length = unpack("N!", substr $head,32,4);
90 0           my $body = $self->binary_read(read_length=>$body_length);
91 0           return $head.$body;
92             }
93              
94              
95             sub strArrayUnpacker {
96 0     0 1   my ($self, $elementNum, $strArray) = @_;
97 0           my $position = 0;
98 0           my %unpckStrArray;
99 0           for(0..$elementNum-1){
100 0           my $strlen = unpack("N!",substr $strArray,$position,4);
101 0           $position+=4;
102 0           my $string = substr $strArray,$position,$strlen;
103 0           $position+=$strlen;
104 0           $unpckStrArray{$_}=$string;
105             }
106 0           return %unpckStrArray;
107             }
108              
109             sub intArrayUnpacker {
110 0     0 1   my ($self,$elementNum,$intArray) = @_;
111 0           my $position = 0;
112 0           my @intArray;
113 0           for(0...$elementNum-1){
114 0           my $int = unpack("N!", substr $intArray,$position,4);
115 0           push @intArray, $int;
116 0           $position+=4;
117             }
118              
119 0           return @intArray;
120             }
121              
122             sub float32ArrayUnpacker {
123 0     0 1   my ($self,$elementNum,$Array) = @_;
124 0           my $position = 0;
125 0           my @floatArray;
126 0           for(0...$elementNum-1){
127 0           my $float = unpack("f>", substr $Array,$position,4);
128 0           push @floatArray, $float;
129 0           $position+=4;
130             }
131              
132 0           return @floatArray;
133             }
134              
135              
136              
137             sub oneDSwp_AcqChsSet {
138 0     0 0   my $self = shift;
139 0           my @channels;
140 0           foreach(@_){
141 0           push @channels,$_;
142             }
143 0           my $command_name="1dswp.acqchsset";
144 0           my $bodysize= (1 + scalar(@channels))*4;
145 0           my $head= $self->nt_header($command_name,$bodysize,0);
146             #Create body
147 0           my $body= nt_int($#channels+1);
148 0           foreach(@channels){
149 0           $body= $body.nt_int($_);
150             }
151 0           $self->write(command=>$head.$body);
152             }
153              
154              
155             sub oneDSwp_AcqChsGet {
156 0     0 0   my $self = shift;
157 0           my $command_name="1dswp.acqchsget";
158 0           my $bodysize = 0;
159 0           my $head= $self->nt_header($command_name,$bodysize,1);
160 0           $self->write(command=>$head);
161              
162 0           my $return = $self->tramea_read();
163 0           my $channelNum = unpack("N!",substr $return,40,4);
164 0           my @channels = $self->intArrayUnpacker($channelNum,(substr $return,44));
165 0           return(@channels);
166             }
167              
168             sub oneDSwp_SwpSignalSet {
169 0     0 0   my ($self, $channelName) = @_;
170 0           my $strlen = length($channelName);
171 0           my $command_name="1dswp.swpsignalset";
172 0           my $bodysize = $strlen+4;
173 0           $strlen=nt_int($strlen);
174 0           my $head= $self->nt_header($command_name,$bodysize,1);
175 0           $self->write(command=>$head.$strlen.$channelName);
176             }
177              
178             sub oneDSwp_SwpSignalGet {
179 0     0 0   my $self = shift;
180 0           my $option= "select";
181 0 0         if (scalar(@_)>0){
182 0           $option = shift;
183             }
184 0           my $command_name="1dswp.swpsignalget";
185 0           my $head= $self->nt_header($command_name,0,1);
186 0           $self->write(command=>$head);
187 0           my $response = $self->tramea_read();
188 0           my $strlen= unpack("N!",substr $response,40,4);
189              
190 0 0         if (($option eq "select") == 1){
    0          
191 0           my $selected = substr $response,44,$strlen;
192             }
193             elsif (($option eq "info")==1){
194 0           my $elementNum = unpack("N!", substr $response,48+$strlen,4);
195 0           my $strArray= substr $response,52+$strlen;
196 0           my %channels = $self->strArrayUnpacker($elementNum,$strArray);
197 0           return %channels;
198             }
199             else{
200 0           return "Invalid Options!"
201             }
202             }
203              
204             sub oneDSwp_LimitsSet {
205 0     0 0   my $self = shift;
206 0           my ($Lower_limit,$Upper_limit,)= @_;
207 0           my $command_name= "1dswp.limitsset";
208 0           my $bodysize = 8;
209 0           my $head = $self->nt_header($command_name,$bodysize,0);
210 0           my $body=nt_float32($Lower_limit);
211 0           $body=$body.nt_float32($Upper_limit);
212 0           $self->write(command=>$head.$body)
213             }
214              
215             sub oneDSwp_LimitsGet {
216 0     0 0   my $self = shift;
217 0           my $command_name= "1dswp.limitsget";
218 0           my $bodysize = 0;
219 0           my $rbodysize = 8;
220 0           my $head= $self->nt_header($command_name,$bodysize,1);
221 0           $self->write(command=>$head);
222 0           my $return = $self->tramea_read();
223 0           $return = $self->tramea_read();
224 0           my $Lower_limit= substr $return,40,4;
225 0           $Lower_limit= unpack("f>",$Lower_limit);
226 0           my $Upper_limit= substr $return,44,4;
227 0           $Upper_limit= unpack("f>",$Upper_limit);
228 0           return($Lower_limit,$Upper_limit);
229             }
230              
231             sub oneDSwp_PropsSet {
232 0     0 0   my $self = shift;
233 0           my ($Initial_Settling_time_ms,$Maximum_slew_rate,$Number_of_steps,$Period_ms,$Autosave,$Save_dialog_box,$Settling_time_ms)= @_;
234 0           my $command_name= "1dswp.propsset";
235 0           my $bodysize = 26;
236 0           my $head= $self->nt_header($command_name,$bodysize,0);
237 0           my $body=nt_float32($Initial_Settling_time_ms);
238 0           $body=$body.nt_float32($Maximum_slew_rate);
239 0           $body=$body.nt_int($Number_of_steps);
240 0           $body=$body.nt_uint16($Period_ms);
241 0           $body=$body.nt_int($Autosave);
242 0           $body=$body.nt_int($Save_dialog_box);
243 0           $body=$body.nt_float32($Settling_time_ms);
244 0           $self->write(command=>$head.$body);
245             }
246              
247             sub oneDSwp_PropsGet {
248 0     0 0   my $self = shift;
249 0           my $command_name= "1dswp.propsget";
250 0           my $bodysize = 0;
251 0           my $head= $self->nt_header($command_name,$bodysize,1);
252 0           $self->write(command=>$head);
253              
254 0           my $return = $self->tramea_read();
255 0           my $Initial_Settling_time_ms= substr $return,40,4;
256 0           $Initial_Settling_time_ms= unpack("f>",$Initial_Settling_time_ms);
257 0           my $s= substr $return,44,4;
258 0           $s= unpack("f>",$s);
259 0           my $Number_of_steps= substr $return,48,4;
260 0           $Number_of_steps= unpack("N!",$Number_of_steps);
261 0           my $Period_ms= substr $return,52,2;
262 0           $Period_ms= unpack("n",$Period_ms);
263 0           my $Autosave= substr $return,54,4;
264 0           $Autosave= unpack("N",$Autosave);
265 0           my $Save_dialog_box= substr $return,58,4;
266 0           $Save_dialog_box= unpack("N",$Save_dialog_box);
267 0           my $Settling_time_ms= substr $return,62,4;
268 0           $Settling_time_ms= unpack("f>",$Settling_time_ms);
269 0           return($Initial_Settling_time_ms,$s,$Number_of_steps,$Period_ms,$Autosave,$Save_dialog_box,$Settling_time_ms);
270             }
271              
272             sub oneDSwp_Start {
273 0     0 0   my ($self,$get,$direction,$name,$reset,$timeout) = @_;
274 0           my $command_name= "1dswp.start";
275 0           my $name_len= length($name);
276 0           my $bodysize = 16 +$name_len;
277            
278 0 0         if($get!= 0){
279 0           $get = 1;
280             }
281 0 0         if($direction!= 0){
282 0           $direction = 1;
283             }
284 0 0         if($reset!= 0){
285 0           $reset = 1;
286             }
287 0           my $head= $self->nt_header($command_name,$bodysize,$get);
288 0           my $body = nt_uint32($get);
289 0           $body = $body.nt_uint32($direction);
290 0           $body = $body.nt_int($name_len);
291 0           $body = $body.$name;
292 0           $body = $body.nt_uint32($reset);
293 0           $self->write(command=>$head.$body);
294              
295 0 0         if($get==1){
296 0           my $return = $self->binary_read(timeout=>$timeout);
297 0           my $channelSize = unpack("N!",substr($return,40,4));
298 0           my $channelNum =unpack("N!",substr($return,44,4));
299 0           my %channels = $self->strArrayUnpacker($channelNum,substr($return,48,$channelSize));
300 0           $channels{0}=$channels{0}."*";
301 0           my $newPos = 48 +$channelSize;
302 0           my $rowNum = unpack("N!",substr($return,$newPos,4));
303 0           my $colNum = unpack("N!",substr($return,$newPos+4,4));
304 0           my $rawData = substr($return,$newPos+8,$rowNum*$colNum*4);
305 0           my %data;
306 0           my $pos = 0;
307 0           for(my $row = 0;$row<$rowNum;$row++)
308             {
309 0           my @rowBuffer;
310 0           for(my $col = 0;$col<$colNum;$col++)
311             {
312 0           push @rowBuffer , unpack("f>",substr($rawData,$pos,4));
313 0           $pos +=4;
314             }
315 0           $data{$channels{$row}} = [@rowBuffer];
316             }
317 0           return %data;
318             }
319             else{
320 0           return 0;
321             }
322              
323             }
324              
325             sub oneDSwp_Stop {
326 0     0 0   my $self = shift;
327 0           my $command_name= "1dswp.stop";
328 0           my $bodysize = 0;
329 0           my $head= $self->nt_header($command_name,$bodysize,0);
330 0           $self->write(command=>$head);
331             }
332              
333              
334             sub oneDSwp_Open {
335 0     0 0   my $self = shift;
336 0           my $command_name= "1dswp.open";
337 0           my $bodysize = 0;
338 0           my $head= $self->nt_header($command_name,$bodysize,0);
339 0           $self->write(command=>$head);
340             }
341              
342              
343              
344              
345              
346              
347              
348              
349              
350             sub threeDSwp_AcqChsSet {
351 0     0 0   my $self = shift;
352 0           my $channels_ref = shift;
353 0           my @channels = @{$channels_ref};
  0            
354 0           my $Number_of_Channels= scalar @channels;
355 0           my $command_name = "3dswp.acqchsset";
356 0           my $bodysize = 4*($Number_of_Channels+1);
357 0           my $header = $self->nt_header($command_name,$bodysize,1);
358 0           my $body = nt_int($Number_of_Channels);
359 0           for(my $i = 0;$i<$Number_of_Channels;$i++)
360             {
361 0           $body=$body.nt_int($channels[$i]);
362             }
363 0           $self->write(command=>$header.$body);
364 0           $self->_end_of_com();
365             }
366              
367             sub threeDSwp_AcqChsGet {
368              
369 0     0 0   my $self = shift;
370 0           my $command_name = "3dswp.acqchsget";
371 0           $self->write(command=>$self->nt_header($command_name,0,1));
372              
373 0           my $return= $self->tramea_read();
374 0           my $Number_of_Channels = unpack("N!", substr($return,40,4));
375 0           my $pos = 4*($Number_of_Channels);
376 0           my @indexes = $self->intArrayUnpacker($Number_of_Channels,substr($return,44,$pos));
377 0           $pos +=44;
378 0           my $Channel_names_size = unpack("N!",substr($return,$pos,4));
379 0           my $Channel_num = unpack("N!",substr($return,$pos+4,4));
380 0           my %names = $self->strArrayUnpacker($Channel_num,substr($return,$pos+8,$Channel_names_size));
381 0           my %combined;
382              
383 0           for(my $idx = 0; $idx<scalar(@indexes);$idx++){
384 0           $combined{$indexes[$idx]}=$names{$idx}
385             }
386 0           return(%combined);
387             }
388              
389             sub threeDSwp_SaveOptionsSet {
390 0     0 0   my $self = shift;
391 0           my $Series_Name= shift;
392 0           my $Create_Date_Time =shift;
393 0           my $Comment = shift;
394 0           my @Modules_Names= ();
395 0 0         if(scalar(@_) >0)
396             {
397 0           my $Modules_Names_ref = shift;
398 0           @Modules_Names = @{$Modules_Names_ref};
  0            
399             }
400 0           my $command_name = "3dswp.saveoptionsset";
401 0           my $bodysize = 20;
402 0           my $body = nt_int(0);
403 0 0         if(length($Series_Name)!=0)
404             {
405 0           $body=nt_int(length($Series_Name));
406 0           $body=$body.$Series_Name;
407 0           $bodysize+=length($Series_Name);
408             }
409 0 0         if($Create_Date_Time >0)
    0          
410             {
411 0           $Create_Date_Time =1;
412             }
413             elsif ($Create_Date_Time<0)
414             {
415 0           $Create_Date_Time = -1;
416             }
417 0           $body= $body.nt_int($Create_Date_Time);
418 0 0         if(length($Comment)!=0)
419             {
420 0           $body = $body.nt_int(length($Comment)).$Comment;
421 0           $bodysize+= length($Comment);
422             }
423             else
424             {
425 0           $body=$body.nt_int(0);
426             }
427 0 0         if (scalar(@Modules_Names) != 0)
428             {
429 0           my $buffer_size = 0;
430 0           my $buffer_body = "";
431 0           foreach(@Modules_Names)
432             {
433 0           $buffer_body = $buffer_body.nt_int(length($_)).$_;
434 0           $buffer_size+= 4+length($_);
435             }
436 0           $body = $body.nt_int($buffer_size);
437 0           $body = $body.nt_int(scalar(@Modules_Names));
438 0           $body = $body.$buffer_body;
439 0           $bodysize += $buffer_size;
440             }
441             else
442             {
443 0           $body= $body.nt_int(0).nt_int(0);
444             }
445 0           $self->write(command=>$self->nt_header($command_name,$bodysize,1).$body);
446 0           $self->_end_of_com();
447             }
448              
449             sub threeDSwp_SaveOptionsGet {
450 0     0 0   my $self = shift;
451 0           my $command_name = "3dswp.saveoptionsget";
452 0           $self->write(command=>$self->nt_header($command_name,0,1));
453              
454 0           my $return = $self->tramea_read();
455 0           my $pos = unpack("N!",substr($return,40,4));
456 0           my $Series_Name = substr($return,44,$pos);
457 0           $pos+=44;
458 0           my $DT_Folder_opt = unpack("N",substr($return,$pos,4));
459 0           $pos += 12 + unpack("N!",substr($return,$pos+4,4));
460 0           my $strLen = unpack("N!",substr($return,$pos,4));
461 0           my $Comment = substr($return,$pos+4,$strLen);
462 0           $pos+=4+$strLen;
463 0           my $MP_size = unpack("N!",substr($return,$pos,4));
464 0           my $MP_number = unpack("N!",substr($return,$pos+4,4));
465 0           my %Modules_parameters = $self->strArrayUnpacker($MP_number,substr($return,$pos+8,$MP_size));
466 0           my @Modules_param = @Modules_parameters{0...(scalar(keys %Modules_parameters)-1)};
467 0           return($Series_Name,$DT_Folder_opt,$Comment,@Modules_param);
468              
469             }
470              
471             sub threeDSwp_Start {
472 0     0 0   my $self = shift;
473 0           my $command_name= "3dswp.start";
474 0           my $bodysize = 0;
475 0           my $head= $self->nt_header($command_name,$bodysize,1);
476 0           $self->write(command=>$head);
477 0           $self->_end_of_com();
478             }
479              
480             sub threeDSwp_Stop {
481 0     0 0   my $self = shift;
482 0           my $command_name= "3dswp.stop";
483 0           my $bodysize = 0;
484 0           my $head= $self->nt_header($command_name,$bodysize,0);
485 0           $self->write(command=>$head);
486             }
487              
488             sub threeDSwp_Open {
489 0     0 0   my $self = shift;
490 0           my $command_name= "3dswp.open";
491 0           my $bodysize = 0;
492 0           my $head= $self->nt_header($command_name,$bodysize,0);
493 0           $self->write(command=>$head);
494             }
495              
496             sub threeDSwp_StatusGet {
497 0     0 0   my $self = shift;
498 0           my $command_name= "3dswp.statusget";
499 0           my $bodysize = 0;
500 0           my $head= $self->nt_header($command_name,$bodysize,1);
501 0           $self->write(command=>$head);
502 0           my $return = $self->tramea_read();
503 0           my $Status= substr $return,40,4;
504 0           $Status= unpack("N",$Status);
505 0           return($Status);
506             }
507              
508              
509             sub threeDSwp_SwpChSignalSet {
510 0     0 0   my $self = shift;
511 0           my $Sweep_channel_index = shift;
512 0           my $command_name= "3dswp.swpchsignalset";
513 0           my $bodysize = 4;
514 0           my $head= $self->nt_header($command_name,$bodysize,1);
515 0           $self->write(command=>$head.nt_int($Sweep_channel_index));
516 0           $self->_end_of_com();
517             }
518              
519             sub threeDSwp_SwpChLimitsSet {
520 0     0 0   my $self = shift;
521 0           my ($Start,$Stop)= @_;
522 0           my $command_name= "3dswp.swpchlimitsset";
523 0           my $bodysize = 8;
524 0           my $head= $self->nt_header($command_name,$bodysize,1);
525 0           my $body=nt_float32($Start);
526 0           $body=$body.nt_float32($Stop);
527 0           $self->write(command=>$head.$body);
528 0           $self->_end_of_com();
529             }
530              
531             sub threeDSwp_SwpChLimitsGet {
532 0     0 0   my $self = shift;
533 0           my $command_name= "3dswp.swpchlimitsget";
534 0           my $bodysize = 0;
535 0           my $head= $self->nt_header($command_name,$bodysize,1);
536 0           $self->write(command=>$head);
537 0           my $return = $self->tramea_read();
538 0           my $Start= substr $return,40,4;
539 0           $Start= unpack("f>",$Start);
540 0           my $Stop= substr $return,44,4;
541 0           $Stop= unpack("f>",$Stop);
542 0           return($Start,$Stop);
543             }
544              
545             sub threeDSwp_SwpChPropsSet {
546 0     0 0   my $self = shift;
547 0           my ($Number_of_points,$Number_of_sweeps,$Backward_sweep,$End_of_sweep_action,$End_of_sweep_arbitrary_value,$Save_all)= @_;
548 0           my $command_name= "3dswp.swpchpropsset";
549 0           my $bodysize = 24;
550 0           my $head= $self->nt_header($command_name,$bodysize,1);
551 0           my $body=nt_int($Number_of_points);
552 0           $body=$body.nt_int($Number_of_sweeps);
553 0           $body=$body.nt_int($Backward_sweep);
554 0           $body=$body.nt_int($End_of_sweep_action);
555 0           $body=$body.nt_float32($End_of_sweep_arbitrary_value);
556 0           $body=$body.nt_int($Save_all);
557 0           $self->write(command=>$head.$body);
558 0           $self->_end_of_com();
559             }
560              
561             sub threeDSwp_SwpChPropsGet {
562 0     0 0   my $self = shift;
563 0           my $command_name= "3dswp.swpchpropsget";
564 0           my $bodysize = 0;
565 0           my $head= $self->nt_header($command_name,$bodysize,1);
566 0           $self->write(command=>$head);
567 0           my $return = $self->tramea_read();
568 0           my $Number_of_points= substr $return,40,4;
569 0           $Number_of_points= unpack("N!",$Number_of_points);
570 0           my $Number_of_sweeps= substr $return,44,4;
571 0           $Number_of_sweeps= unpack("N!",$Number_of_sweeps);
572 0           my $Backward_sweep= substr $return,48,4;
573 0           $Backward_sweep= unpack("N",$Backward_sweep);
574 0           my $End_of_sweep_action= substr $return,52,4;
575 0           $End_of_sweep_action= unpack("N",$End_of_sweep_action);
576 0           my $End_of_sweep_arbitrary_value= substr $return,56,4;
577 0           $End_of_sweep_arbitrary_value= unpack("f>",$End_of_sweep_arbitrary_value);
578 0           my $Save_all= substr $return,60,4;
579 0           $Save_all= unpack("N",$Save_all);
580 0           return($Number_of_points,$Number_of_sweeps,$Backward_sweep,$End_of_sweep_action,$End_of_sweep_arbitrary_value,$Save_all);
581             }
582              
583             sub threeDSwp_SwpChTimingSet {
584 0     0 0   my $self = shift;
585 0           my ($Initial_settling_time_s,$Settling_time_s,$Integration_time_s,$End_settling_time_s,$Maximum_slw_rate)= @_;
586 0           my $command_name= "3dswp.swpchtimingset";
587 0           my $bodysize = 20;
588 0           my $head= $self->nt_header($command_name,$bodysize,1);
589 0           my $body=nt_float32($Initial_settling_time_s);
590 0           $body=$body.nt_float32($Settling_time_s);
591 0           $body=$body.nt_float32($Integration_time_s);
592 0           $body=$body.nt_float32($End_settling_time_s);
593 0           $body=$body.nt_float32($Maximum_slw_rate);
594 0           $self->write(command=>$head.$body);
595 0           $self->_end_of_com();
596             }
597              
598             sub threeDSwp_SwpChTimingGet {
599 0     0 0   my $self = shift;
600 0           my $command_name= "3dswp.swpchtimingget";
601 0           my $bodysize = 0;
602 0           my $head= $self->nt_header($command_name,$bodysize,1);
603 0           $self->write(command=>$head);
604 0           my $return = $self->tramea_read();
605 0           my $Initial_settling_time_s= substr $return,40,4;
606 0           $Initial_settling_time_s= unpack("f>",$Initial_settling_time_s);
607 0           my $Settling_time_s= substr $return,44,4;
608 0           $Settling_time_s= unpack("f>",$Settling_time_s);
609 0           my $Integration_time_s= substr $return,48,4;
610 0           $Integration_time_s= unpack("f>",$Integration_time_s);
611 0           my $End_settling_time_s= substr $return,52,4;
612 0           $End_settling_time_s= unpack("f>",$End_settling_time_s);
613 0           my $Maximum_slw_rate= substr $return,56,4;
614 0           $Maximum_slw_rate= unpack("f>",$Maximum_slw_rate);
615 0           return($Initial_settling_time_s,$Settling_time_s,$Integration_time_s,$End_settling_time_s,$Maximum_slw_rate);
616             }
617              
618             sub threeDSwp_SwpChModeSet {
619 0     0 0   my $self = shift;
620 0           my $Channel_name = shift;
621 0           my $name_len = length($Channel_name);
622 0           my $bodysize = 4*($name_len+1);
623 0           my $command_name = "3dswp.swpchmodeset";
624 0           my $head= $self->nt_header($command_name,$bodysize,0);
625 0           $self->write(command=>$head.nt_int($name_len).$Channel_name);
626             }
627              
628             sub threeDSwp_SwpChModeGet {
629 0     0 0   my $self = shift;
630 0           my $command_name = "3dswp.swpchmodeget";
631 0           my $head = $self->nt_header($command_name,0,1);
632 0           $self->write(command=>$head);
633 0           my $return= $self->tramea_read();
634 0           return substr($return,44,unpack("N!",substr($return,40,4)));
635             }
636              
637              
638             sub threeDSwp_StpCh1SignalSet {
639 0     0 0   my $self = shift;
640 0           my $Step_channel_1_index = shift;
641 0           my $command_name= "3dswp.stpch1signalset";
642 0           my $bodysize = 4;
643 0           my $head= $self->nt_header($command_name,$bodysize,1);
644 0           $self->write(command=>$head.nt_int($Step_channel_1_index));
645 0           $self->_end_of_com();
646             }
647              
648             sub threeDSwp_StpCh1LimitsSet {
649 0     0 0   my $self = shift;
650 0           my ($Start,$Stop)= @_;
651 0           my $command_name= "3dswp.stpch1limitsset";
652 0           my $bodysize = 8;
653 0           my $head= $self->nt_header($command_name,$bodysize,1);
654 0           my $body=nt_float32($Start);
655 0           $body=$body.nt_float32($Stop);
656 0           $self->write(command=>$head.$body);
657 0           $self->_end_of_com();
658             }
659              
660             sub threeDSwp_StpCh1LimitsGet {
661 0     0 0   my $self = shift;
662 0           my $command_name= "3dswp.stpch1limitsget";
663 0           my $bodysize = 0;
664 0           my $head= $self->nt_header($command_name,$bodysize,1);
665 0           $self->write(command=>$head);
666 0           my $return = $self->tramea_read();
667 0           my $Start= substr $return,40,4;
668 0           $Start= unpack("f>",$Start);
669 0           my $Stop= substr $return,44,4;
670 0           $Stop= unpack("f>",$Stop);
671 0           return($Start,$Stop);
672             }
673              
674             sub threeDSwp_StpCh1PropsSet {
675 0     0 0   my $self = shift;
676 0           my ($Number_of_points,$Backward_sweep,$End_of_sweep_action,$End_of_sweep_arbitrary_value)= @_;
677 0           my $command_name= "3dswp.stpch1propsset";
678 0           my $bodysize = 16;
679 0           my $head= $self->nt_header($command_name,$bodysize,1);
680 0           my $body=nt_int($Number_of_points);
681 0           $body=$body.nt_int($Backward_sweep);
682 0           $body=$body.nt_int($End_of_sweep_action);
683 0           $body=$body.nt_float32($End_of_sweep_arbitrary_value);
684 0           $self->write(command=>$head.$body);
685 0           $self->_end_of_com();
686             }
687              
688             sub threeDSwp_StpCh1PropsGet {
689 0     0 0   my $self = shift;
690 0           my $command_name= "3dswp.stpch1propsget";
691 0           my $bodysize = 0;
692 0           my $head= $self->nt_header($command_name,$bodysize,1);
693 0           $self->write(command=>$head);
694 0           my $return = $self->tramea_read();
695 0           my $Number_of_points= substr $return,40,4;
696 0           $Number_of_points= unpack("N!",$Number_of_points);
697 0           my $Backward_sweep= substr $return,44,4;
698 0           $Backward_sweep= unpack("N",$Backward_sweep);
699 0           my $End_of_sweep_action= substr $return,48,4;
700 0           $End_of_sweep_action= unpack("N",$End_of_sweep_action);
701 0           my $End_of_sweep_arbitrary_value= substr $return,52,4;
702 0           $End_of_sweep_arbitrary_value= unpack("f>",$End_of_sweep_arbitrary_value);
703 0           return($Number_of_points,$Backward_sweep,$End_of_sweep_action,$End_of_sweep_arbitrary_value);
704             }
705              
706             sub threeDSwp_StpCh1TimingSet {
707 0     0 0   my $self = shift;
708 0           my ($Initial_settling_time_s,$End_settling_time_s,$Maximum_slw_rate)= @_;
709 0           my $command_name= "3dswp.stpch1timingset";
710 0           my $bodysize = 12;
711 0           my $head= $self->nt_header($command_name,$bodysize,0);
712 0           my $body=nt_float32($Initial_settling_time_s);
713 0           $body=$body.nt_float32($End_settling_time_s);
714 0           $body=$body.nt_float32($Maximum_slw_rate);
715 0           $self->write(command=>$head.$body);
716 0           $self->_end_of_com();
717             }
718              
719             sub threeDSwp_StpCh1TimingGet {
720 0     0 0   my $self = shift;
721 0           my $command_name= "3dswp.stpch1timingget";
722 0           my $bodysize = 0;
723 0           my $head= $self->nt_header($command_name,$bodysize,1);
724 0           $self->write(command=>$head);
725 0           my $return = $self->tramea_read();
726 0           my $Initial_settling_time_s= substr $return,40,4;
727 0           $Initial_settling_time_s= unpack("f>",$Initial_settling_time_s);
728 0           my $End_settling_time_s= substr $return,44,4;
729 0           $End_settling_time_s= unpack("f>",$End_settling_time_s);
730 0           my $Maximum_slw_rate= substr $return,48,4;
731 0           $Maximum_slw_rate= unpack("f>",$Maximum_slw_rate);
732 0           return($Initial_settling_time_s,$End_settling_time_s,$Maximum_slw_rate);
733             }
734              
735              
736             sub threeDSwp_StpCh2SignalSet {
737 0     0 0   my $self = shift;
738 0           my $Channel_name = shift;
739 0           my $name_len = length($Channel_name);
740 0           my $bodysize = 4+($name_len);
741 0           my $command_name = "3dswp.stpch2signalset";
742 0           my $head= $self->nt_header($command_name,$bodysize,1);
743 0           $self->write(command=>$head.nt_int($name_len).$Channel_name);
744 0           $self->_end_of_com();
745             }
746              
747              
748             sub threeDSwp_StpCh2SignalGet {
749 0     0 0   my $self = shift;
750 0           my $command_name = "3dswp.stpch2signalget";
751 0           my $head = $self->nt_header($command_name,0,1);
752 0           $self->write(command=>$head);
753 0           my $return= $self->tramea_read();
754 0           return substr($return,44,unpack("N!",substr($return,40,4)));
755             }
756              
757             sub threeDSwp_StpCh2LimitsSet {
758 0     0 0   my $self = shift;
759 0           my ($Start,$Stop)= @_;
760 0           my $command_name= "3dswp.stpch2limitsset";
761 0           my $bodysize = 8;
762 0           my $head= $self->nt_header($command_name,$bodysize,1);
763 0           my $body=nt_float32($Start);
764 0           $body=$body.nt_float32($Stop);
765 0           $self->write(command=>$head.$body);
766 0           $self->_end_of_com();
767             }
768              
769             sub threeDSwp_StpCh2LimitsGet {
770 0     0 0   my $self = shift;
771 0           my $command_name= "3dswp.stpch2limitsget";
772 0           my $bodysize = 0;
773 0           my $head= $self->nt_header($command_name,$bodysize,1);
774 0           $self->write(command=>$head);
775 0           my $return = $self->tramea_read();
776 0           my $Start= substr $return,40,4;
777 0           $Start= unpack("f>",$Start);
778 0           my $Stop= substr $return,44,4;
779 0           $Stop= unpack("f>",$Stop);
780 0           return($Start,$Stop);
781             }
782              
783             sub threeDSwp_StpCh2PropsSet {
784 0     0 0   my $self = shift;
785 0           my ($Number_of_points,$Backward_sweep,$End_of_sweep_action,$End_of_sweep_arbitrary_value)= @_;
786 0           my $command_name= "3dswp.stpch2propsset";
787 0           my $bodysize = 16;
788 0           my $head= $self->nt_header($command_name,$bodysize,1);
789 0           my $body=nt_int($Number_of_points);
790 0           $body=$body.nt_int($Backward_sweep);
791 0           $body=$body.nt_int($End_of_sweep_action);
792 0           $body=$body.nt_float32($End_of_sweep_arbitrary_value);
793 0           $self->write(command=>$head.$body);
794 0           $self->_end_of_com();
795             }
796              
797             sub threeDSwp_StpCh2PropsGet {
798 0     0 0   my $self = shift;
799 0           my $command_name= "3dswp.stpch2propsget";
800 0           my $bodysize = 0;
801 0           my $head= $self->nt_header($command_name,$bodysize,1);
802 0           $self->write(command=>$head);
803 0           my $return = $self->tramea_read();
804 0           my $Number_of_points= substr $return,40,4;
805 0           $Number_of_points= unpack("N!",$Number_of_points);
806 0           my $Backward_sweep= substr $return,44,4;
807 0           $Backward_sweep= unpack("N",$Backward_sweep);
808 0           my $End_of_sweep_action= substr $return,48,4;
809 0           $End_of_sweep_action= unpack("N",$End_of_sweep_action);
810 0           my $End_of_sweep_arbitrary_value= substr $return,52,4;
811 0           $End_of_sweep_arbitrary_value= unpack("f>",$End_of_sweep_arbitrary_value);
812 0           return($Number_of_points,$Backward_sweep,$End_of_sweep_action,$End_of_sweep_arbitrary_value);
813             }
814              
815             sub threeDSwp_StpCh2TimingSet {
816 0     0 0   my $self = shift;
817 0           my ($Initial_settling_time_s,$End_settling_time_s,$Maximum_slw_rate)= @_;
818 0           my $command_name= "3dswp.stpch2timingset";
819 0           my $bodysize = 12;
820 0           my $head= $self->nt_header($command_name,$bodysize,0);
821 0           my $body=nt_float32($Initial_settling_time_s);
822 0           $body=$body.nt_float32($End_settling_time_s);
823 0           $body=$body.nt_float32($Maximum_slw_rate);
824 0           $self->write(command=>$head.$body);
825             }
826              
827             sub threeDSwp_StpCh2TimingGet {
828 0     0 0   my $self = shift;
829 0           my $command_name= "3dswp.stpch2timingget";
830 0           my $bodysize = 0;
831 0           my $head= $self->nt_header($command_name,$bodysize,1);
832 0           $self->write(command=>$head);
833 0           my $return = $self->tramea_read();
834 0           my $Initial_settling_time_s= substr $return,40,4;
835 0           $Initial_settling_time_s= unpack("f>",$Initial_settling_time_s);
836 0           my $End_settling_time_s= substr $return,44,4;
837 0           $End_settling_time_s= unpack("f>",$End_settling_time_s);
838 0           my $Maximum_slw_rate= substr $return,48,4;
839 0           $Maximum_slw_rate= unpack("f>",$Maximum_slw_rate);
840 0           return($Initial_settling_time_s,$End_settling_time_s,$Maximum_slw_rate);
841             }
842              
843              
844             sub threeDSwp_TimingRowLimitSet {
845             #Everythinbg seems set properlly, wierd Behavior on nanonis Software side.
846 0     0 0   my $self = shift;
847 0           my ($Row_index,$Maximum_time_seconds,$Channel_index)= @_;
848 0           my $command_name= "3dswp.timingrowlimitset";
849 0           my $bodysize = 12;
850 0           my $head= $self->nt_header($command_name,$bodysize,0);
851 0           my $body=nt_int($Row_index);
852 0           $body=$body.nt_int($Maximum_time_seconds); #Gets translated to int software side..I don't know,should be f32.
853 0           $body=$body.nt_int($Channel_index);
854 0           $self->write(command=>$head.$body);
855             }
856              
857             sub threeDSwp_TimingRowLimitGet {
858 0     0 0   my $self = shift;
859 0           my $Row_index = shift;
860 0           my $command_name= "3dswp.timingrowlimitget";
861 0           my $bodysize = 4;
862 0           my $head= $self->nt_header($command_name,$bodysize,1);
863 0           $self->write(command=>$head.nt_int($Row_index));
864              
865 0           my $return = $self->tramea_read();
866 0           my $Maximum_time= unpack("f>",substr($return,40,4));
867 0           my $Channel_index = unpack("N!",substr($return,44,4));
868 0           my $Channel_names_size = unpack("N!",substr($return,48,4));
869 0           my $Channel_num= unpack("N!",substr($return,52,4));
870 0           my $strArray = substr $return,56,$Channel_names_size;
871 0           my %channels = $self->strArrayUnpacker($Channel_num,$strArray);
872              
873 0           return($Maximum_time,$Channel_index,%channels);
874             }
875              
876             sub threeDSwp_TimingRowMethodsSet {
877 0     0 0   my $self = shift;
878 0           my ($Row_index,$Method_lower,$Method_middle,$Method_upper,$Method_alternative)= @_;
879 0           my $command_name= "3dswp.timingrowmethodsset";
880 0           my $bodysize = 20;
881 0           my $head= $self->nt_header($command_name,$bodysize,0);
882 0           my $body=nt_int($Row_index);
883 0           $body=$body.nt_int($Method_lower);
884 0           $body=$body.nt_int($Method_middle);
885 0           $body=$body.nt_int($Method_upper);
886 0           $body=$body.nt_int($Method_alternative);
887 0           $self->write(command=>$head.$body);
888             }
889              
890             sub threeDSwp_TimingRowMethodsGet {
891 0     0 0   my $self = shift;
892 0           my ($Row_index)= @_;
893 0           my $command_name= "3dswp.timingrowmethodsget";
894 0           my $bodysize = 4;
895 0           my $head= $self->nt_header($command_name,$bodysize,1);
896 0           my $body=nt_int($Row_index);
897 0           $self->write(command=>$head.$body);
898 0           my $return = $self->tramea_read();
899 0           my $Method_lower= substr $return,40,4;
900 0           $Method_lower= unpack("N!",$Method_lower);
901 0           my $Method_middle= substr $return,44,4;
902 0           $Method_middle= unpack("N!",$Method_middle);
903 0           my $Method_upper= substr $return,48,4;
904 0           $Method_upper= unpack("N!",$Method_upper);
905 0           my $Method_alternative= substr $return,52,4;
906 0           $Method_alternative= unpack("N!",$Method_alternative);
907 0           return($Method_lower,$Method_middle,$Method_upper,$Method_alternative);
908             }
909              
910              
911             sub threeDSwp_TimingRowValsSet {
912             #The documentation indicates that this function requires float32 input but actually gets f64
913 0     0 0   my $self = shift;
914 0           my ($Row_index,$MR_from,$LR_value,$MR_value,$MR_to,$UR_value,$AR_value)= @_;
915 0           my $command_name= "3dswp.timingrowvalsset";
916 0           my $bodysize = 52;
917 0           my $head= $self->nt_header($command_name,$bodysize,0);
918 0           my $body=nt_int($Row_index);
919 0           $body=$body.nt_float64($MR_from);
920 0           $body=$body.nt_float64($LR_value);
921 0           $body=$body.nt_float64($MR_value);
922 0           $body=$body.nt_float64($MR_to);
923 0           $body=$body.nt_float64($UR_value);
924 0           $body=$body.nt_float64($AR_value);
925 0           $self->write(command=>$head.$body);
926             }
927              
928             sub threeDSwp_TimingRowValsGet {
929             #The documentation indicates that this function returns float32 but actually returns f64
930 0     0 0   my $self = shift;
931 0           my ($Row_index)= @_;
932 0           my $command_name= "3dswp.timingrowvalsget";
933 0           my $bodysize = 4;
934 0           my $head= $self->nt_header($command_name,$bodysize,1);
935 0           my $body=nt_int($Row_index);
936 0           $self->write(command=>$head.$body);
937 0           my $return = $self->tramea_read();
938 0           my $MR_from= unpack("d>",substr($return,40,8));
939 0           my $LR_value = unpack("d>",substr($return,48,8));
940 0           my $MR_value = unpack("d>",substr($return,56,8));
941 0           my $MR_to = unpack("d>",substr($return,64,8));
942 0           my $UR_value = unpack("d>",substr($return,72,8));
943 0           my $AR_value = unpack("d>",substr($return,80,8));
944 0           return($MR_from,$LR_value,$MR_value,$MR_to,$UR_value,$AR_value);
945              
946             }
947              
948             sub threeDSwp_TimingEnable {
949 0     0 0   my $self = shift;
950 0           my ($Enable)= @_;
951 0           my $command_name= "3dswp.timingenable";
952 0           my $bodysize = 4;
953 0           my $head= $self->nt_header($command_name,$bodysize,0);
954 0           my $body=nt_uint32($Enable);
955 0           $self->write(command=>$head.$body);
956             }
957              
958             sub threeDSwp_TimingSend {
959 0     0 0   my $self = shift;
960 0           my $command_name= "3dswp.timingsend";
961 0           my $bodysize = 0;
962 0           my $head= $self->nt_header($command_name,$bodysize,0);
963 0           $self->write(command=>$head);
964             }
965              
966              
967             sub threeDSwp_FilePathsGet {
968             # This sleep function deals with an internal issue of the tramea software
969             # If one askes for filenames too soon after sweep it tries to access
970             # files of previous sweep
971 0     0 0   sleep(1);
972 0           my $self = shift;
973 0           my $command_name = "3dswp.filepathsget";
974 0           my $head =
975             $self->write(command=>$self->nt_header($command_name,0,1));
976 0           my $response = $self->tramea_read();
977 0           my $strArraySize = unpack("N!", substr $response,40,4);
978 0           my $strNumber = unpack("N!", substr $response, 44, 4 );
979 0           my $strArray = substr $response,48,$strArraySize;
980 0           my %strings = $self->strArrayUnpacker($strNumber,$strArray);
981 0           return %strings;
982             }
983              
984              
985             sub Signals_NamesGet {
986 0     0 0   my $self =shift;
987 0           my $command_name="signals.namesget";
988 0           my $head = $self->nt_header($command_name,0,1);
989              
990 0           $self->write(command=>$head);
991              
992 0           my $response =$self->tramea_read();
993 0           my $strArraySize = unpack("N!", substr $response,40,4);
994 0           my $strNumber = unpack("N!", substr $response, 44, 4 );
995 0           my $strArray = substr $response,48,$strArraySize;
996 0           my %strings = $self->strArrayUnpacker($strNumber,$strArray);
997 0           return %strings;
998             }
999              
1000             sub Signals_InSlotSet {
1001 0     0 0   my $self = shift;
1002 0           my ($Slot,$RT_signal_index)= @_;
1003 0           my $command_name= "signals.inslotset";
1004 0           my $bodysize = 8;
1005 0           my $head= $self->nt_header($command_name,$bodysize,0);
1006 0           my $body=nt_int($Slot);
1007 0           $body=$body.nt_int($RT_signal_index);
1008 0           $self->write(command=>$head.$body);
1009             }
1010              
1011             sub Signals_InSlotsGet {
1012 0     0 0   my $self = shift;
1013 0           my $command_name= "signals.inslotsget";
1014 0           my $head = $self->nt_header($command_name,0,1);
1015 0           $self->write(command=>$head);
1016              
1017 0           my $response = $self->tramea_read();
1018 0           my $namesSize= unpack("N!",substr $response,40,4);
1019 0           my $namesNumber= unpack("N!",substr $response,44,4);
1020 0           my %Strings = $self->strArrayUnpacker($namesNumber,substr($response,48,$namesSize));
1021 0           my $idxNumber = unpack("N!",substr $response,48+$namesSize,4);
1022 0           my @idxArray = $self->intArrayUnpacker($idxNumber,substr($response,52+$namesSize,4*$idxNumber));
1023 0           foreach(keys %Strings){
1024 0           $Strings{$_}= join(" RT ",$Strings{$_},$idxArray[$_]);
1025             }
1026 0           return (%Strings);
1027             }
1028              
1029             sub Signals_CalibrGet {
1030 0     0 0   my $self = shift;
1031 0           my ($Signal_index)= @_;
1032 0           my $command_name= "signals.calibrget";
1033 0           my $bodysize = 4;
1034 0           my $head= $self->nt_header($command_name,$bodysize,1);
1035 0           my $body=nt_int($Signal_index);
1036 0           $self->write(command=>$head.$body);
1037 0           my $return = $self->tramea_read();
1038 0           my $Calibration_per_volt= substr $return,40,4;
1039 0           $Calibration_per_volt= unpack("f>",$Calibration_per_volt);
1040 0           my $Offset_in_physical_units= substr $return,44,4;
1041 0           $Offset_in_physical_units= unpack("f>",$Offset_in_physical_units);
1042 0           return($Calibration_per_volt,$Offset_in_physical_units);
1043             }
1044              
1045             sub Signals_RangeGet {
1046 0     0 0   my $self = shift;
1047 0           my ($Signal_index)= @_;
1048 0           my $command_name= "signals.rangeget";
1049 0           my $bodysize = 4;
1050 0           my $head= $self->nt_header($command_name,$bodysize,1);
1051 0           my $body=nt_int($Signal_index);
1052 0           $self->write(command=>$head.$body);
1053 0           my $return = $self->tramea_read();
1054 0           my $Maximum_limit= substr $return,40,4;
1055 0           $Maximum_limit= unpack("f>",$Maximum_limit);
1056 0           my $Minimum_limit= substr $return,44,4;
1057 0           $Minimum_limit= unpack("f>",$Minimum_limit);
1058 0           return($Maximum_limit,$Minimum_limit);
1059             }
1060              
1061             sub Signals_ValGet {
1062 0     0 0   my $self = shift;
1063 0           my ($Signal_index,$Wait_for_newest_data)= @_;
1064 0           my $command_name= "signals.valget";
1065 0           my $bodysize = 8;
1066 0           my $head= $self->nt_header($command_name,$bodysize,1);
1067 0           my $body=nt_int($Signal_index);
1068 0           $body=$body.nt_uint32($Wait_for_newest_data);
1069 0           $self->write(command=>$head.$body);
1070 0           my $return = $self->tramea_read();
1071 0           my $Signal_value= substr $return,40,4;
1072 0           $Signal_value= unpack("f>",$Signal_value);
1073 0           return($Signal_value);
1074             }
1075              
1076             sub Signals_ValsGet {
1077             #this function behaves differently.
1078             #Usualy requested size is actual Byte size, here is element count.
1079              
1080 0     0 0   my $self = shift;
1081 0           my @idxArray = @_;
1082 0           my $WFND = pop @idxArray;
1083 0           my $command_name = "signals.valsget";
1084              
1085 0 0         if($WFND > 0){
1086 0           $WFND=1;
1087             }
1088             else{
1089 0           $WFND = 0;
1090             }
1091              
1092 0           my $bodysize = 8+ 4 * scalar @idxArray;
1093 0           my $head = $self->nt_header($command_name,$bodysize,1);
1094 0           my $body = pack("N!",(scalar @idxArray));
1095 0           foreach(@idxArray){
1096 0           $body = $body.pack("N!",$_);
1097             }
1098 0           $body= $body.pack("N",$WFND);
1099              
1100 0           $self->write(command=>$head.$body);
1101              
1102 0           my $response = $self->tramea_read();
1103 0           my $valuesSize = unpack("N!", substr $response,40,4);
1104 0           my @floatArray = $self->float32ArrayUnpacker($valuesSize,substr($response,44,$valuesSize*4));
1105 0           return @floatArray;
1106             }
1107              
1108             sub Signals_MeasNamesGet {
1109 0     0 0   my $self = shift;
1110 0           my $command_name= "signals.measnamesget";
1111 0           my $bodysize = 0;
1112 0           my $head= $self->nt_header($command_name,$bodysize,1);
1113 0           $self->write(command=>$head);
1114 0           my $response = $self->tramea_read();
1115 0           my $channelSize= unpack("N!",substr $response,40,4);
1116 0           my $channelNum= unpack("N!",substr $response,44,4);
1117 0           my $strArray = substr $response,48,$channelSize;
1118 0           my %channels = $self->strArrayUnpacker($channelNum,$strArray);
1119 0           return %channels;
1120             }
1121              
1122             sub Signals_AddRTGet() {
1123            
1124 0     0 0   my $self = shift;
1125 0           my $command_name="signals.addrtget";
1126 0           my $head = $self->nt_header($command_name,0,1);
1127 0           $self->write(command=>$head);
1128              
1129 0           my $response = $self->tramea_read();
1130 0           my $namesSize = unpack("N!",substr $response,40,4);
1131 0           my $namesNumber = unpack("N!",substr $response,44,4);
1132 0           my %addRtArray = $self->strArrayUnpacker($namesNumber,substr($response,48,$namesSize));
1133 0           return %addRtArray;
1134              
1135             }
1136              
1137             sub Signals_AddRTSet {
1138 0     0 0   my $self = shift;
1139 0           my ($Additional_RT_signal_1,$Additional_RT_signal_2)= @_;
1140 0           my $command_name= "signals.addrtset";
1141 0           my $bodysize = 8;
1142 0           my $head= $self->nt_header($command_name,$bodysize,0);
1143 0           my $body=nt_int($Additional_RT_signal_1);
1144 0           $body=$body.nt_int($Additional_RT_signal_2);
1145 0           $self->write(command=>$head.$body);
1146             }
1147              
1148              
1149             sub UserIn_CalibrSet {
1150 0     0 0   my $self = shift;
1151 0           my ($Input_index,$Calibration_per_volt,$Offset_in_physical_units)= @_;
1152 0           my $command_name= "userin.calibrset";
1153 0           my $bodysize = 12;
1154 0           my $head= $self->nt_header($command_name,$bodysize,0);
1155 0           my $body=nt_int($Input_index);
1156 0           $body=$body.nt_float32($Calibration_per_volt);
1157 0           $body=$body.nt_float32($Offset_in_physical_units);
1158 0           $self->write(command=>$head.$body);
1159             }
1160              
1161             sub UserOut_ModeSet {
1162 0     0 0   my $self = shift;
1163 0           my ($Output_index,$Output_mode)= @_;
1164 0           my $command_name= "userout.modeset";
1165 0           my $bodysize = 6;
1166 0           my $head= $self->nt_header($command_name,$bodysize,0);
1167 0           my $body=nt_int($Output_index);
1168 0           $body=$body.nt_uint16($Output_mode);
1169 0           $self->write(command=>$head.$body);
1170             }
1171              
1172             sub UserOut_ModeGet {
1173 0     0 0   my $self = shift;
1174 0           my ($Output_index)= @_;
1175 0           my $command_name= "userout.modeget";
1176 0           my $bodysize = 4;
1177 0           my $head= $self->nt_header($command_name,$bodysize,1);
1178 0           my $body=nt_int($Output_index);
1179 0           $self->write(command=>$head.$body);
1180 0           my $return = $self->tramea_read();
1181 0           my $Output_mode= substr $return,40,2;
1182 0           $Output_mode= unpack("n",$Output_mode);
1183 0           return($Output_mode);
1184             }
1185              
1186             sub UserOut_MonitorChSet {
1187 0     0 0   my $self = shift;
1188 0           my ($Output_index,$Monitor_channel_index)= @_;
1189 0           my $command_name= "userout.monitorchset";
1190 0           my $bodysize = 8;
1191 0           my $head= $self->nt_header($command_name,$bodysize,0);
1192 0           my $body=nt_int($Output_index);
1193 0           $body=$body.nt_int($Monitor_channel_index);
1194 0           $self->write(command=>$head.$body);
1195             }
1196              
1197              
1198             sub UserOut_MonitorChGet {
1199 0     0 0   my $self = shift;
1200 0           my ($Output_index)= @_;
1201 0           my $command_name= "userout.monitorchget";
1202 0           my $bodysize = 4;
1203 0           my $head= $self->nt_header($command_name,$bodysize,1);
1204 0           my $body=nt_int($Output_index);
1205 0           $self->write(command=>$head.$body);
1206 0           my $return = $self->tramea_read();
1207 0           my $Monitor_channel_index= substr $return,40,4;
1208 0           $Monitor_channel_index= unpack("N!",$Monitor_channel_index);
1209 0           return($Monitor_channel_index);
1210             }
1211              
1212             sub UserOut_ValSet {
1213 0     0 0   my $self = shift;
1214 0           my ($Output_index,$Output_value)= @_;
1215 0           my $command_name= "userout.valset";
1216 0           my $bodysize = 8;
1217 0           my $head= $self->nt_header($command_name,$bodysize,0);
1218 0           my $body=nt_int($Output_index);
1219 0           $body=$body.nt_float32($Output_value);
1220 0           $self->write(command=>$head.$body);
1221             }
1222              
1223             sub UserOut_CalibrSet {
1224 0     0 0   my $self = shift;
1225 0           my ($Output_index,$Calibration_per_volt,$Offset_in_physical_units)= @_;
1226 0           my $command_name= "userout.calibrset";
1227 0           my $bodysize = 12;
1228 0           my $head= $self->nt_header($command_name,$bodysize,0);
1229 0           my $body=nt_int($Output_index);
1230 0           $body=$body.nt_float32($Calibration_per_volt);
1231 0           $body=$body.nt_float32($Offset_in_physical_units);
1232 0           $self->write(command=>$head.$body);
1233             }
1234              
1235              
1236             sub UserOut_CalcSignalNameSet {
1237 0     0 0   my $self = shift;
1238 0           my $output_index = shift;
1239 0           my $string = shift;
1240 0           my $command_name = "userout.calcsignalnameset";
1241 0           my $bodysize= 8 + length($string);
1242 0           my $head = $self->nt_header($command_name,$bodysize,1);
1243 0           my $body = nt_int($output_index).nt_int(length($string)).$string;
1244              
1245 0           $self->write(command=>$head.$body);
1246             }
1247              
1248             sub UserOut_CalcSignalNameGet {
1249              
1250 0     0 0   my $self = shift;
1251 0           my $output_index = shift;
1252 0           my $command_name = "userout.calcsignalnameget";
1253              
1254 0           $self->write(command=>$self->nt_header($command_name,4,1).nt_int($output_index));
1255              
1256 0           my $return = $self->tramea_read();
1257 0           my $strLen = unpack("N!",substr($return,40,4));
1258 0           return substr $return,44,$strLen;
1259              
1260             }
1261              
1262             sub UserOut_CalcSignalConfigSet {
1263 0     0 0   my $self = shift;
1264 0           my ($Output_index,$Operation_1,$Value_1,$Operation_2,$Value_2,$Operation_3,$Value_3,$Operation_4,$Value_4)= @_;
1265 0           my $command_name= "userout.calcsignalconfigset";
1266 0           my $bodysize = 28;
1267 0           my $head= $self->nt_header($command_name,$bodysize,0);
1268 0           my $body=nt_int($Output_index);
1269 0           $body=$body.nt_uint16($Operation_1);
1270 0           $body=$body.nt_float32($Value_1);
1271 0           $body=$body.nt_uint16($Operation_2);
1272 0           $body=$body.nt_float32($Value_2);
1273 0           $body=$body.nt_uint16($Operation_3);
1274 0           $body=$body.nt_float32($Value_3);
1275 0           $body=$body.nt_uint16($Operation_4);
1276 0           $body=$body.nt_float32($Value_4);
1277 0           $self->write(command=>$head.$body);
1278             }
1279              
1280             sub UserOut_CalcSignalConfigGet {
1281 0     0 0   my $self = shift;
1282 0           my ($Output_index)= @_;
1283 0           my $command_name= "userout.calcsignalconfigget";
1284 0           my $bodysize = 4;
1285 0           my $head= $self->nt_header($command_name,$bodysize,1);
1286 0           my $body=nt_int($Output_index);
1287 0           $self->write(command=>$head.$body);
1288 0           my $return = $self->tramea_read();
1289 0           my $Operation_1= substr $return,40,2;
1290 0           $Operation_1= unpack("n",$Operation_1);
1291 0           my $Value_1= substr $return,42,4;
1292 0           $Value_1= unpack("f>",$Value_1);
1293 0           my $Operation_2= substr $return,46,2;
1294 0           $Operation_2= unpack("n",$Operation_2);
1295 0           my $Value_2= substr $return,48,4;
1296 0           $Value_2= unpack("f>",$Value_2);
1297 0           my $Operation_3= substr $return,52,2;
1298 0           $Operation_3= unpack("n",$Operation_3);
1299 0           my $Value_3= substr $return,54,4;
1300 0           $Value_3= unpack("f>",$Value_3);
1301 0           my $Operation_4= substr $return,58,2;
1302 0           $Operation_4= unpack("n",$Operation_4);
1303 0           my $Value_4= substr $return,60,4;
1304 0           $Value_4= unpack("f>",$Value_4);
1305 0           return($Operation_1,$Value_1,$Operation_2,$Value_2,$Operation_3,$Value_3,$Operation_4,$Value_4);
1306             }
1307              
1308             sub UserOut_LimitsSet {
1309 0     0 0   my $self = shift;
1310 0           my ($Output_index,$Upper_limit,$Lower_limit)= @_;
1311 0           my $command_name= "userout.limitsset";
1312 0           my $bodysize = 12;
1313 0           my $head= $self->nt_header($command_name,$bodysize,0);
1314 0           my $body=nt_int($Output_index);
1315 0           $body=$body.nt_float32($Upper_limit);
1316 0           $body=$body.nt_float32($Lower_limit);
1317 0           $self->write(command=>$head.$body);
1318             }
1319             sub UserOut_LimitsGet {
1320 0     0 0   my $self = shift;
1321 0           my ($Output_index)= @_;
1322 0           my $command_name= "userout.limitsget";
1323 0           my $bodysize = 4;
1324 0           my $head= $self->nt_header($command_name,$bodysize,1);
1325 0           my $body=nt_int($Output_index);
1326 0           $self->write(command=>$head.$body);
1327 0           my $return = $self->tramea_read();
1328 0           my $Upper_limit= substr $return,40,4;
1329 0           $Upper_limit= unpack("f>",$Upper_limit);
1330 0           my $Lower_limit= substr $return,44,4;
1331 0           $Lower_limit= unpack("f>",$Lower_limit);
1332 0           return($Upper_limit,$Lower_limit);
1333             }
1334             sub UserOut_SlewRateSet {
1335 0     0 0   my $self = shift;
1336 0           my ($Output_index,$Slew_Rate)= @_;
1337 0           my $command_name= "userout.slewrateset";
1338 0           my $bodysize = 12;
1339 0           my $head= $self->nt_header($command_name,$bodysize,0);
1340 0           my $body=nt_int($Output_index);
1341 0           $body=$body.nt_float64($Slew_Rate);
1342 0           $self->write(command=>$head.$body);
1343             }
1344              
1345             sub UserOut_SlewRateGet {
1346 0     0 0   my $self = shift;
1347 0           my ($Output_index)= @_;
1348 0           my $command_name= "userout.slewrateget";
1349 0           my $bodysize = 4;
1350 0           my $head= $self->nt_header($command_name,$bodysize,1);
1351 0           my $body=nt_int($Output_index);
1352 0           $self->write(command=>$head.$body);
1353 0           my $return = $self->tramea_read();
1354 0           my $Slew_Rate= substr $return,40,8;
1355 0           $Slew_Rate= unpack("d>",$Slew_Rate);
1356 0           return($Slew_Rate);
1357             }
1358              
1359              
1360             sub DigLines_PropsSet {
1361 0     0 0   my $self = shift;
1362 0           my ($Digital_line,$Port,$Direction,$Polarity)= @_;
1363 0           my $command_name= "diglines.propsset";
1364 0           my $bodysize = 16;
1365 0           my $head= $self->nt_header($command_name,$bodysize,0);
1366 0           my $body=nt_uint32($Digital_line);
1367 0           $body=$body.nt_uint32($Port);
1368 0           $body=$body.nt_uint32($Direction);
1369 0           $body=$body.nt_uint32($Polarity);
1370 0           $self->write(command=>$head.$body);
1371             }
1372              
1373             sub DigLines_OutStatusSet {
1374 0     0 0   my $self = shift;
1375 0           my ($Port,$Digital_line,$Status)= @_;
1376 0           my $command_name= "diglines.outstatusset";
1377 0           my $bodysize = 12;
1378 0           my $head= $self->nt_header($command_name,$bodysize,0);
1379 0           my $body=nt_uint32($Port);
1380 0           $body=$body.nt_uint32($Digital_line);
1381 0           $body=$body.nt_uint32($Status);
1382 0           $self->write(command=>$head.$body);
1383             }
1384              
1385             sub DigLines_TTLValGet {
1386            
1387 0     0 0   my $self = shift;
1388 0           my $port = shift;
1389 0           my $command_name = "diglines.ttlvalget";
1390 0           my $head = $self->nt_header($command_name,4,1);
1391              
1392 0           $self->write(command=>$head.nt_uint16($port));
1393              
1394 0           my $return = $self->tramea_read();
1395              
1396 0           my $intArraySize = unpack("N!",substr($return,40,4));
1397 0           my @intArray = $self->intArrayUnpacker($intArraySize,substr($return,44,$intArraySize*4));
1398 0           return @intArray;
1399             }
1400              
1401             sub DigLines_Pulse {
1402             #Changing different order of args here, we pass the lines array as last argument
1403 0     0 0   my $self = shift;
1404 0           my $port = shift;
1405 0           my $Pulse_width = shift;
1406 0           my $Pulse_pause = shift;
1407 0           my $Pulse_number = shift;
1408 0           my $Wait_param = shift;
1409 0           my @lines = @_;
1410 0           my $command_name = "diglines.pulse";
1411 0           my $head = $self->nt_header($command_name,22 + scalar(@lines),0);
1412 0           my $body = nt_uint16($port).nt_int(scalar(@lines));
1413 0           foreach(@lines){
1414 0           $body = $body.pack("c",$_);
1415             }
1416 0           $body = $body.nt_float32($Pulse_width).nt_float32($Pulse_pause);
1417 0           $body = $body.nt_int($Pulse_number).nt_uint32($Wait_param);
1418 0           $self->write(command=>$head.$body);
1419             }
1420              
1421              
1422             sub Util_SessionPathGet {
1423 0     0 0   my $self = shift;
1424 0           my $command_name ="util.sessionpathget";
1425 0           my $head = $self->nt_header($command_name,0,1);
1426 0           $self->write(command=>$head);
1427              
1428 0           my $response = $self->tramea_read();
1429 0           return substr $response,44,unpack("N!",substr $response,40,4);
1430             }
1431              
1432             sub Util_SessionPathSet {
1433 0     0 0   my $self = shift ;
1434 0           my $command_name ="util.sessionpathset" ;
1435 0           my $session_path = shift;
1436 0           my $save_settings = shift;
1437 0           my $bodysize = 8 + length($session_path);
1438 0           my $head = $self->nt_header($command_name,$bodysize,1) ;
1439 0           $self->write(command=>$head.nt_int(length($session_path)).$session_path.nt_uint32($save_settings));
1440 0           $self->_end_of_com();
1441             }
1442              
1443             sub Util_SettingsLoad {
1444             #Not sure if working
1445 0     0 0   my $self = shift;
1446 0           my ($path,$Automatic_Load) = @_;
1447 0           my $command_name = "util.settingsload";
1448 0 0         if($Automatic_Load> 0){
1449 0           $Automatic_Load = 1;
1450             }
1451             else{
1452 0           $Automatic_Load = 0;
1453             }
1454 0           my $bodysize = 8 + 4*length($path);
1455 0           my $head = $self->nt_header($command_name,$bodysize,0);
1456 0           my $body = pack("N!",length($path)).$path.pack("N",$Automatic_Load);
1457 0           $self->write( command => $head.$body);
1458             }
1459              
1460             sub Util_SettingsSave {
1461             #Not sure if working
1462 0     0 0   my $self = shift;
1463 0           my ($path,$Automatic_save) = @_;
1464 0           my $command_name = "util.settingssave";
1465              
1466 0 0         if($Automatic_save> 0){
1467 0           $Automatic_save= 1;
1468             }
1469             else{
1470 0           $Automatic_save = 0;
1471             }
1472              
1473 0           my $bodysize = 8 + 4*length($path);
1474 0           my $head = $self->nt_header($command_name,$bodysize,1);
1475 0           my $body = pack("N!",length($path)).$path.pack("N",$Automatic_save);
1476 0           $self->write( command => $head.$body);
1477 0           $self->_end_of_com();
1478             }
1479              
1480             sub Util_LayoutLoad {
1481             #Not sure if working
1482 0     0 0   my $self = shift;
1483 0           my ($path,$Automatic_Load) = @_;
1484 0           my $command_name = "util.layoutload";
1485 0 0         if($Automatic_Load> 0){
1486 0           $Automatic_Load= 1;
1487             }
1488             else{
1489 0           $Automatic_Load = 0;
1490             }
1491 0           my $bodysize = 8 + 4*length($path);
1492 0           my $head = $self->nt_header($command_name,$bodysize,0);
1493 0           my $body = pack("N!",length($path)).$path.pack("N",$Automatic_Load);
1494 0           $self->write( command => $head.$body);
1495             }
1496              
1497             sub Util_LayoutSave {
1498             #Not sure if working
1499 0     0 0   my $self = shift;
1500 0           my ($path,$Automatic_save) = @_;
1501 0           my $command_name = "util.layoutsave";
1502 0 0         if($Automatic_save> 0){
1503 0           $Automatic_save= 1;
1504             }
1505             else{
1506 0           $Automatic_save = 0;
1507             }
1508 0           my $bodysize = 8 + 4*length($path);
1509 0           my $head = $self->nt_header($command_name,$bodysize,1);
1510 0           my $body = pack("N!",length($path)).$path.pack("N",$Automatic_save);
1511 0           $self->write( command => $head.$body);
1512 0           $self->_end_of_com()
1513             }
1514              
1515             sub Util_Lock {
1516 0     0 0   my $self = shift;
1517 0           my $command_name= "util.lock";
1518 0           my $bodysize = 0;
1519 0           my $head= $self->nt_header($command_name,$bodysize,0);
1520 0           $self->write(command=>$head);
1521             }
1522              
1523             sub Util_UnLock {
1524 0     0 0   my $self = shift;
1525 0           my $command_name= "util.unlock";
1526 0           my $bodysize = 0;
1527 0           my $head= $self->nt_header($command_name,$bodysize,0);
1528 0           $self->write(command=>$head);
1529             }
1530              
1531             sub Util_RTFreqSet {
1532 0     0 0   my $self = shift;
1533 0           my ($RT_frequency)= @_;
1534 0           my $command_name= "util.rtfreqset";
1535 0           my $bodysize = 4;
1536 0           my $head= $self->nt_header($command_name,$bodysize,0);
1537 0           my $body=nt_float32($RT_frequency);
1538 0           $self->write(command=>$head.$body);
1539             }
1540              
1541             sub Util_RTFreqGet {
1542 0     0 0   my $self = shift;
1543 0           my $command_name= "util.rtfreqget";
1544 0           my $bodysize = 0;
1545 0           my $head= $self->nt_header($command_name,$bodysize,1);
1546 0           $self->write(command=>$head);
1547 0           my $return = $self->tramea_read();
1548 0           my $RT_frequency= substr $return,40,4;
1549 0           $RT_frequency= unpack("f>",$RT_frequency);
1550 0           return($RT_frequency);
1551             }
1552              
1553             sub Util_AcqPeriodSet {
1554 0     0 0   my $self = shift;
1555 0           my ($Acquisition_Period_s)= @_;
1556 0           my $command_name= "util.acqperiodset";
1557 0           my $bodysize = 4;
1558 0           my $head= $self->nt_header($command_name,$bodysize,0);
1559 0           my $body=nt_float32($Acquisition_Period_s);
1560 0           $self->write(command=>$head.$body);
1561             }
1562              
1563             sub Util_AcqPeriodGet {
1564 0     0 0   my $self = shift;
1565 0           my $command_name= "util.acqperiodget";
1566 0           my $bodysize = 0;
1567 0           my $head= $self->nt_header($command_name,$bodysize,1);
1568 0           $self->write(command=>$head);
1569 0           my $return = $self->tramea_read();
1570 0           my $Acquisition_Period_s= substr $return,40,4;
1571 0           $Acquisition_Period_s= unpack("f>",$Acquisition_Period_s);
1572 0           return($Acquisition_Period_s);
1573             }
1574              
1575             sub Util_RTOversamplSet {
1576 0     0 0   my $self = shift;
1577 0           my ($RT_oversampling)= @_;
1578 0           my $command_name= "util.rtoversamplset";
1579 0           my $bodysize = 4;
1580 0           my $head= $self->nt_header($command_name,$bodysize,0);
1581 0           my $body=nt_int($RT_oversampling);
1582 0           $self->write(command=>$head.$body);
1583             }
1584              
1585             sub Util_RTOversamplGet {
1586 0     0 0   my $self = shift;
1587 0           my $command_name= "util.rtoversamplget";
1588 0           my $bodysize = 0;
1589 0           my $head= $self->nt_header($command_name,$bodysize,1);
1590 0           $self->write(command=>$head);
1591 0           my $return = $self->tramea_read();
1592 0           my $RT_oversampling= substr $return,40,4;
1593 0           $RT_oversampling= unpack("N!",$RT_oversampling);
1594 0           return($RT_oversampling);
1595             }
1596             #Some modules are missing
1597              
1598             sub File_datLoad {
1599 0     0 0   my $self = shift;
1600 0           my $file_path = shift;
1601 0           my $header_only = shift;
1602 0           my $command_name = "file.datload";
1603 0           my $bodysize = 8 + length($file_path);
1604 0           my $head = $self->nt_header($command_name,$bodysize,1);
1605             # MISSING: Do not try to read column names and data if you are not asking for it
1606 0           $self->write(command=>$head.nt_int(length($file_path)).$file_path.nt_int($header_only));
1607              
1608 0           my $result_head = $self->binary_read(read_length=>40);
1609 0           my $result_size = unpack("N!",substr $result_head,32,4);
1610              
1611 0           my $result = $self->binary_read(read_length=>$result_size);
1612 0           my $Channel_names_size = unpack('N!', substr $result,0,4);
1613 0           my $Name_number = unpack('N!', substr $result,4,4);
1614 0           my $raw_names = substr $result,8,$Channel_names_size;
1615 0           my %Channel_names = $self->strArrayUnpacker($Name_number,$raw_names);
1616              
1617 0           $result = substr($result,-1*(length($result)-8-$Channel_names_size));
1618              
1619 0           my $Data_rows = unpack("N!",substr($result,0,4));
1620 0           my $Data_cols = unpack ("N!",substr($result,4,8));
1621 0           my $Data_size = 4*$Data_cols*$Data_rows;
1622 0           my @float2Darray = $self->float32ArrayUnpacker($Data_cols*$Data_rows,substr($result,8,$Data_size));
1623              
1624 0           my @channel_names;
1625 0           my $pdl = zeros($Data_rows,$Data_cols);
1626 0           for(my $index = 0;$index <=max(keys %Channel_names);$index++){
1627 0           push @channel_names,$Channel_names{$index};
1628             }
1629 0           my $row_num = 0 ;
1630 0           my $col_num = 0 ;
1631 0           for (my $index = 0; $index< scalar(@float2Darray);$index++){
1632 0           $pdl->slice("$row_num,$col_num") .=$float2Darray[$index];
1633 0           $col_num+=1;
1634 0 0         if(($index+1)%$Data_cols == 0){
1635 0           $row_num+=1;
1636 0           $col_num = 0 ;
1637             }
1638             }
1639              
1640              
1641             # Header Stuff
1642             #Return hash (?)
1643 0           my %head;
1644              
1645 0           $result = substr($result,-1*(length($result)-8-$Data_size));
1646 0           my $Header_rows = unpack("N!", substr $result,0,4);
1647 0           my $Header_col = unpack("N!", substr $result,4,4);
1648 0           my %strings = $self->strArrayUnpacker($Header_rows*$Header_col-1,substr $result,-1*(length($result)-8));
1649 0           my $value_buffer="";
1650 0           for(my $index = 0; $index <= max(keys %strings)-1;$index+=$Header_col)
1651             {
1652 0           for(my $idx2 = 1; $idx2<$Header_col;$idx2++){
1653 0           $value_buffer = $value_buffer.$strings{$index+$idx2};
1654             }
1655 0           $head{$strings{$index}} = $value_buffer;
1656 0           $value_buffer ="";
1657             }
1658 0           return $pdl,\@channel_names,\%head,
1659             }
1660              
1661              
1662              
1663             has _Session_Path => (
1664             is => 'rw',
1665             isa => 'Str',
1666             lazy => 1,
1667             reader => 'Session_Path',
1668             writer => '_Session_Path',
1669             builder =>'_build_Session_Path'
1670             );
1671              
1672             sub _build_Session_Path {
1673 0     0     my $self = shift ;
1674 0           return $self->Util_SessionPathGet();
1675             }
1676              
1677             has sweep_prop_configuration => (
1678             is=>'rw',
1679             isa => 'HashRef',
1680             reader => 'sweep_prop_configuration',
1681             writer => '_sweep_prop_configuration',
1682             builder => '_build_sweep_prop_configuration',
1683             );
1684              
1685             has sweep_timing_configuration =>(
1686             is=>'rw',
1687             isa => 'HashRef',
1688             reader => 'sweep_timing_configuration',
1689             writer => '_sweep_timing_configuration',
1690             builder => '_build_sweep_timing_configuration',
1691             clearer =>'reset_swp_timing',
1692             lazy => 1
1693              
1694             );
1695              
1696             sub _build_sweep_timing_configuration {
1697 0     0     my $self = shift ;
1698 0           my %hash;
1699 0           my @values = $self->threeDSwp_SwpChTimingGet();
1700 0           $hash{initial_settling_time} = $values[0];
1701 0           $hash{settling_time} = $values[1];
1702 0           $hash{integration_time} = $values[2];
1703 0           $hash{end_settling_time} = $values[3];
1704 0           $hash{Maximum_slew_rate} = $values[4];
1705 0           return \%hash;
1706             }
1707              
1708             sub _build_sweep_prop_configuration {
1709 0     0     my $self = shift;
1710 0           my %hash;
1711 0           $hash{point_number}=2;
1712 0           $hash{number_of_sweeps}=1;
1713 0           $hash{backwards}=-1;
1714 0           $hash{at_end}=-1;
1715 0           $hash{at_end_val}=0;
1716 0           $hash{save_all}=-1;
1717 0           return \%hash;
1718             }
1719              
1720             has signals => (
1721             is=>'ro',
1722             isa => 'HashRef',
1723             reader => "signals",
1724             lazy =>1,
1725             builder => '_signals_builder',
1726             );
1727              
1728             sub _signals_builder {
1729 0     0     my $self = shift;
1730 0           my %hash = $self->Signals_InSlotsGet();
1731 0           return \%hash;
1732             }
1733              
1734             has outputs => (
1735             is => 'rw',
1736             isa => 'HashRef',
1737             reader =>'outputs',
1738             writer => '_outputs',
1739             builder => '_outputs_builder'
1740             );
1741              
1742             sub _outputs_builder {
1743 0     0     my $self = shift;
1744 0           my %hash;
1745 0           $hash{0}="Plunger Gate (V)";
1746 0           $hash{1}="Source-Drain (V)";
1747 0           $hash{2}="Left Gate (V)";
1748 0           $hash{3}="Right Gate (V)";
1749 0           $hash{4}="Output 5 (V)";
1750 0           $hash{5}="Output 6 (V)";
1751 0           $hash{6}="Output 7 (V)";
1752 0           $hash{7}="Output 8 (V)";
1753 0           return \%hash;
1754             }
1755              
1756             has step1_prop_configuration => (
1757             is=>'rw',
1758             isa => 'HashRef',
1759             reader => 'step1_prop_configuration',
1760             writer => '_step1_prop_configuration',
1761             builder => '_build_step1_prop_configuration',
1762             );
1763              
1764             sub _build_step1_prop_configuration {
1765 0     0     my $self = shift;
1766 0           my %hash;
1767 0           $hash{point_number}=0;
1768 0           $hash{backwards}=-1;
1769 0           $hash{at_end}=-1;
1770 0           $hash{at_end_val}=0;
1771 0           return \%hash;
1772             }
1773              
1774             has step1_timing_configuration =>(
1775             is=>'rw',
1776             isa => 'HashRef',
1777             reader => 'step1_timing_configuration',
1778             writer => '_step1_timing_configuration',
1779             builder => '_build_step1_timing_configuration',
1780             clearer =>'reset_stp1_timing',
1781             lazy => 1
1782              
1783             );
1784              
1785             sub _build_step1_timing_configuration {
1786 0     0     my $self = shift ;
1787 0           my %hash;
1788 0           my @values = $self->threeDSwp_StpCh1TimingGet;
1789 0           $hash{initial_settling_time} = $values[0];
1790 0           $hash{end_settling_time} = $values[1];
1791 0           $hash{Maximum_slew_rate} = $values[2];
1792 0           return \%hash;
1793             }
1794              
1795              
1796             has step2_prop_configuration => (
1797             is=>'rw',
1798             isa => 'HashRef',
1799             reader => 'step2_prop_configuration',
1800             writer => '_step2_prop_configuration',
1801             builder => '_build_step2_prop_configuration',
1802             );
1803              
1804             sub _build_step2_prop_configuration {
1805 0     0     my $self = shift;
1806 0           my %hash;
1807 0           $hash{point_number}=0;
1808 0           $hash{backwards}=-1;
1809 0           $hash{at_end}=-1;
1810 0           $hash{at_end_val}=0;
1811 0           return \%hash;
1812             }
1813              
1814             has step2_timing_configuration =>(
1815             is=>'rw',
1816             isa => 'HashRef',
1817             reader => 'step2_timing_configuration',
1818             writer => '_step2_timing_configuration',
1819             builder => '_build_step2_timing_configuration',
1820             clearer =>'reset_stp2_timing',
1821             lazy => 1
1822              
1823             );
1824              
1825             sub _build_step2_timing_configuration {
1826 0     0     my $self = shift ;
1827 0           my %hash;
1828 0           my @values = $self->threeDSwp_StpCh2TimingGet;
1829 0           $hash{initial_settling_time} = $values[0];
1830 0           $hash{end_settling_time} = $values[1];
1831 0           $hash{Maximum_slew_rate} = $values[2];
1832 0           return \%hash;
1833             }
1834              
1835              
1836             has sweep_save_configuration => (
1837             is=>'rw',
1838             isa => 'HashRef',
1839             reader => 'sweep_save_configuration',
1840             writer => '_sweep_save_configuration',
1841             builder => '_build_sweep_save_configuration',
1842             );
1843              
1844             sub _build_sweep_save_configuration {
1845 0     0     my $self = shift;
1846 0           my %hash;
1847 0           $hash{series_name}="";
1848 0           $hash{create_datetime}=-1;
1849 0           $hash{comment}="";
1850 0           return \%hash;
1851             }
1852              
1853              
1854             sub set_Session_Path {
1855 0     0 0   my($self,%params) = validated_hash(
1856             \@_,
1857             session_path => {isa => 'Str'},
1858             save_settings => {isa => 'Int',optional => 1}
1859             );
1860            
1861 0 0         if($params{session_path} =~ /^([a-zA-Z]:)(([\\]?[\w _!#()-]+)*[\\])?$/)
1862             {
1863 0 0         if(exists($params{save_settings}))
1864             {
1865 0           $self->Util_SessionPathSet($params{session_path},$params{save_settings});
1866             }
1867             else
1868             {
1869 0           $self->Util_SessionPathSet($params{session_path},0);
1870             }
1871 0           $self->_Session_Path($params{session_path});
1872             }
1873             else
1874             {
1875 0           die "Invalid path in set_Session_Path: Path is not Windows Directory Path";
1876             }
1877             }
1878              
1879              
1880             sub load_data {
1881 0     0 0   my($self,%params) = validated_hash(
1882             \@_,
1883             file_origin => {isa=>"Str"},
1884             return_pdl => {isa=>"Bool", default => 1},
1885             return_head => {isa=>"Bool", default => 0},
1886             return_colnames => {isa=>"Bool", default => 1},
1887             );
1888 0           my %to_return;
1889 0           my ($pdl,$cols_ref,$head) = $self->File_datLoad($params{file_origin},0);
1890              
1891 0 0         if($params{return_pdl}==1)
1892             {
1893 0           $to_return{pdl}= $pdl;
1894             }
1895 0 0         if ($params{return_head} == 1)
1896             {
1897 0           $to_return{header}=$head;
1898             }
1899 0 0         if ($params{return_colnames} == 1)
1900             {
1901 0           $to_return{cols}=$cols_ref;
1902             }
1903 0           return \%to_return;
1904             }
1905              
1906             # Function prototype to add sweep functionalities
1907              
1908             sub load_pdl {
1909 0     0 0   my($self,%params) = validated_hash(
1910             \@_,
1911             file_origin => {isa=> "Str"},
1912             );
1913             my $data_hash = $self->load_data(
1914             file_origin=>$params{file_origin},
1915 0           return_colnames=>1,
1916             return_head=>1);
1917              
1918 0           my $pdl = $data_hash->{pdl};
1919 0           my @colnames = @{$data_hash->{cols}};
  0            
1920 0           my %head = %{$data_hash->{header}};
  0            
1921             # Attempt to detect if it is 2D Sweep by cheking for caratteristic
1922             # string that tels the point number
1923 0 0         if($colnames[-1]=~ m/\[(?<idx_int>[0-9]{5})\]/)
1924             {
1925             # print("Detected 2D SWP\n");
1926             # Extractiong point number, +0 casts to number
1927 0           my $stp1_point_number = $+{idx_int} +0;
1928             # print("Detected point number: $stp1_point_number\n");
1929             # Now Detect total Acq_Channel number
1930 0           my $acq_number = (scalar(@colnames)-1)/$stp1_point_number;
1931             # print("Detected Number of acq_number: $acq_number \n");
1932             # Now lets try and get the extremes of the stp1 channel from header
1933 0           my $stp1_start;
1934             my $stp1_stop;
1935 0           my $using_stp2 =0;
1936 0           my $stp2_level;
1937 0           foreach(keys %head)
1938             {
1939 0 0         if($_=~ m/(?:Step\schannel\s1:\sStart)/)
    0          
1940             {
1941 0           $stp1_start = $head{$_} +0;
1942             }
1943             elsif($_=~m/(?:Step\schannel\s2\s[\w():\s]*\sStart)/)
1944             {
1945 0           $stp1_start = $head{$_} +0;
1946             }
1947 0 0         if($_=~ m/(?:Step\schannel\s1:\sStop)/)
    0          
1948             {
1949 0           $stp1_stop = $head{$_} +0;
1950             }
1951             elsif($_=~m/(?:Step\schannel\s2\s[\w():\s]*\sStop)/)
1952             {
1953 0           $stp1_stop = $head{$_} +0;
1954             }
1955              
1956 0 0         if($_=~m/(?:Step\schannel\s2\s[\w():\s]*\sLevel)/)
1957             {
1958 0           $using_stp2 = 1;
1959 0           $stp2_level = $head{$_}+0;
1960             }
1961             }
1962             # lets format the pdl,2D
1963 0           my @dims = $pdl->dims;
1964 0           my $swp_point_number = $dims[0];
1965 0           my $stp1_values = zeroes($stp1_point_number)->xlinvals($stp1_start,$stp1_stop);
1966 0           my $formatted_pdl = zeroes($stp1_point_number,$dims[0],$acq_number+2);
1967 0           my @newDims = $formatted_pdl->dims;
1968 0           my $col_start;
1969             my $col_end;
1970 0           my $col_end2;
1971 0           for( my $index = 0; $index < $stp1_point_number ;$index++)
1972             {
1973 0           $col_start= $acq_number*$index + 1;
1974 0           $col_end= $acq_number*$index + $acq_number;
1975 0           $col_end2 = $acq_number+1;
1976 0           $stp1_values->at($index);
1977 0           $formatted_pdl->slice("($index),:,(0)")+= $stp1_values->at($index);
1978 0           $formatted_pdl->slice("($index),:,(1)")+= $pdl->slice(":,(0)");
1979 0           $formatted_pdl->slice("($index),:,2:$col_end2") += $pdl->slice(":,$col_start:$col_end");
1980             }
1981             # Now lets check if the sweep was using stpch2
1982 0 0         if($using_stp2)
1983             {
1984 0           my $inflated_pdl = zeroes($stp1_point_number,$dims[0],$acq_number+3);
1985 0           for( my $index = 0; $index < $stp1_point_number ;$index++)
1986             {
1987 0           $inflated_pdl->slice("($index),:,(0)")+=$stp2_level;
1988 0           $inflated_pdl->slice("($index),:,1:-1")+= $formatted_pdl->slice("($index),:,:");
1989             }
1990 0           return $inflated_pdl;
1991             }
1992             else
1993             {
1994 0           return $formatted_pdl;
1995             }
1996             }
1997             else
1998             {
1999 0           return $pdl;
2000             }
2001             }
2002              
2003              
2004             # Multidimensional load prototype
2005              
2006             sub load_last_measurement {
2007 0     0 0   my($self) = validated_hash(\@_);
2008 0           my %files = $self->threeDSwp_FilePathsGet();
2009 0           my $stp2_point_number = scalar(keys %files);
2010 0 0         if($stp2_point_number>1)
2011             {
2012 0           my $pdl3d = $self->load_pdl(file_origin=>$files{0});
2013 0           my @dims = $pdl3d->dims;
2014 0           my $inflated_pdl = zeroes($stp2_point_number,$dims[0],$dims[1],$dims[2]);
2015 0           $inflated_pdl->slice("(0),:,:,:") += $pdl3d;
2016 0           for(my $idx = 1; $idx<$stp2_point_number; $idx++)
2017             {
2018 0           $pdl3d = $self->load_pdl(file_origin=>$files{$idx});
2019 0           $inflated_pdl->slice("($idx),:,:,:") += $pdl3d;
2020             }
2021 0           return $inflated_pdl;
2022            
2023             }
2024             else
2025             {
2026 0           return $self->load_pdl(file_origin=>$files{0});
2027             }
2028             }
2029              
2030             #Lab::Moose::DataFile
2031             # Probably to be deprecated
2032             sub tramea_log_block {
2033 0     0 0   my ($self,$datafile,$prefix, $pdl, $add_newline, $refresh_plots)= validated_list(\@_,
2034             datafile => {isa=>"Lab::Moose::Sweep | Lab::Moose::DataFile"},
2035             prefix => { isa => 'HashRef[Num]', optional => 1 },
2036             pdl => {isa =>"PDL"},
2037             add_newline => { isa => 'Bool', default => 0 },
2038             refresh_plots => { isa => 'Bool', default => 0 },
2039             );
2040            
2041             # Build args
2042 0           my %args;
2043 0 0         if($prefix)
2044             {
2045 0           $args{prefix}= $prefix;
2046             }
2047 0           $args{add_newline}=$add_newline;
2048 0           $args{refresh_plots}=$refresh_plots;
2049              
2050 0           my @dims = $pdl->dims;
2051              
2052 0 0         if (scalar @dims == 4)
    0          
    0          
2053             {
2054 0           for(my $iter = 0; $iter <$dims[0]; $iter++)
2055             {
2056 0           for(my $iter1 = 0; $iter1 <$dims[1]; $iter1++)
2057             {
2058 0           $datafile->log_block(block=>$pdl->slice("($iter),($iter1),:,:"),%args);
2059             }
2060             }
2061             }
2062             elsif (scalar @dims == 3)
2063             {
2064 0           for(my $iter1 = 0; $iter1 <$dims[0]; $iter1++)
2065             {
2066 0           $datafile->log_block(block=>$pdl->slice("($iter1),:,:"),%args);
2067             }
2068             }
2069             elsif (scalar @dims == 2)
2070             {
2071 0           $datafile->log_block(block=>$pdl,%args);
2072             }
2073             else
2074             {
2075 0           croak "Number of dimension is wrong:".scalar(@dims);
2076             }
2077             }
2078             sub parse_last_measurement {
2079 0     0 0   my ($self,%params) = validated_hash(\@_,
2080             folder=>{isa=>'Lab::Moose::DataFolder'});
2081 0           my %files = $self->threeDSwp_FilePathsGet();
2082 0           foreach(keys %files){
2083 0           my ($filename) = $files{$_} =~ m/([ \w-]+\.dat)/g;
2084 0           my $data_hash = $self->load_data(file_origin => $files{$_},return_head=>1,return_colnames=>1);
2085 0           my $new_datafile = datafile(filename => $filename,folder=>$params{folder},columns=>$data_hash->{cols});
2086 0           $new_datafile->log_block(block=>$data_hash->{pdl});
2087             }
2088             }
2089              
2090             sub sweep_save_configure {
2091 0     0 0   my ($self, %params) = validated_hash(
2092             \@_,
2093             series_name=>{isa=>"Str",optional =>1},
2094             create_datetime =>{isa =>"Int",optional =>1},
2095             comment =>{isa=>"Str",optional =>1}
2096             );
2097 0 0         if(!exists($params{series_name})){
2098 0           $params{series_name}=$self->sweep_save_configuration()->{series_name};
2099             }
2100 0 0         if(!exists($params{create_datetime})){
2101 0           $params{create_datetime}=$self->sweep_save_configuration()->{create_datetime};
2102             }
2103 0 0         if(!exists($params{comment})){
2104 0           $params{comment}=$self->sweep_save_configuration()->{comment};
2105             }
2106 0 0 0       if($params{create_datetime}!=-1 && $params{create_datetime}!=0 && $params{create_datetime}!=1)
      0        
2107             {
2108 0           die "Invalid create_date value in sweep_save_configure: value must be -1,0 or 1!"
2109             }
2110              
2111 0           $self->_sweep_save_configuration(\%params);
2112             $self->threeDSwp_SaveOptionsSet($params{series_name},
2113             $params{create_datetime},
2114             $params{comment})
2115 0           }
2116              
2117             sub sweep_timing_configure {
2118 0     0 0   my ($self, %params) = validated_hash(
2119             \@_,
2120             initial_settling_time =>{isa=>"Num",optional =>1},
2121             settling_time => {isa =>"Num",optional =>1},
2122             integration_time=> {isa=>"Num",optional =>1},
2123             end_settling_time => {isa =>"Num",optional =>1},
2124             maximum_slew_rate =>{isa =>"Num",optional =>1}
2125             );
2126             # NOTE : Here some validation may be necessary, Nanonis does not returrn error if Value is invalid
2127 0 0         if(!exists($params{initial_settling_time})){
2128 0           $params{initial_settling_time} = $self->sweep_timing_configuration()->{initial_settling_time};
2129             };
2130 0 0         if(!exists($params{settling_time})){
2131 0           $params{settling_time} = $self->sweep_timing_configuration()->{settling_time};
2132             };
2133 0 0         if(!exists($params{integration_time})){
2134 0           $params{integration_time} = $self->sweep_timing_configuration()->{integration_time};
2135             };
2136 0 0         if(!exists($params{end_settling_time})){
2137 0           $params{end_settling_time} = $self->sweep_timing_configuration()->{end_settling_time};
2138             };
2139 0 0         if(!exists($params{maximum_slew_rate})){
2140 0           $params{maximum_slew_rate} = $self->sweep_timing_configuration()->{maximum_slew_rate};
2141             };
2142 0           $self->reset_swp_timing;
2143             $self->threeDSwp_SwpChTimingSet( $params{initial_settling_time},
2144             $params{settling_time},
2145             $params{integration_time},
2146             $params{end_settling_time},
2147             $params{maximum_slew_rate})
2148              
2149 0           }
2150              
2151             sub step1_timing_configure {
2152 0     0 0   my ($self, %params) = validated_hash(
2153             \@_,
2154             initial_settling_time =>{isa=>"Num",optional =>1},
2155             end_settling_time => {isa =>"Num",optional =>1},
2156             maximum_slew_rate =>{isa =>"Num",optional =>1}
2157             );
2158             # NOTE : Here some validation may be necessary, Nanonis does not returrn error if Value is invalid
2159 0 0         if(!exists($params{initial_settling_time})){
2160 0           $params{initial_settling_time} = $self->step1_timing_configuration()->{initial_settling_time};
2161             };
2162 0 0         if(!exists($params{end_settling_time})){
2163 0           $params{end_settling_time} = $self->step1_timing_configuration()->{end_settling_time};
2164             };
2165 0 0         if(!exists($params{maximum_slew_rate})){
2166 0           $params{maximum_slew_rate} = $self->step1_timing_configuration()->{maximum_slew_rate};
2167             };
2168 0           $self->reset_stp1_timing;
2169             $self->threeDSwp_StpCh1TimingSet( $params{initial_settling_time},
2170             $params{end_settling_time},
2171             $params{maximum_slew_rate})
2172 0           }
2173              
2174             sub step2_timing_configure {
2175 0     0 0   my ($self, %params) = validated_hash(
2176             \@_,
2177             initial_settling_time =>{isa=>"Num",optional =>1},
2178             end_settling_time => {isa =>"Num",optional =>1},
2179             maximum_slew_rate =>{isa =>"Num",optional =>1}
2180             );
2181             # NOTE : Here some validation may be necessary, Nanonis does not returrn error if Value is invalid
2182 0 0         if(!exists($params{initial_settling_time})){
2183 0           $params{initial_settling_time} = $self->step2_timing_configuration()->{initial_settling_time};
2184             };
2185 0 0         if(!exists($params{end_settling_time})){
2186 0           $params{end_settling_time} = $self->step2_timing_configuration()->{end_settling_time};
2187             };
2188 0 0         if(!exists($params{maximum_slew_rate})){
2189 0           $params{maximum_slew_rate} = $self->step2_timing_configuration()->{maximum_slew_rate};
2190             };
2191 0           $self->reset_stp2_timing;
2192             $self->threeDSwp_StpCh1TimingSet( $params{initial_settling_time},
2193             $params{end_settling_time},
2194             $params{maximum_slew_rate})
2195 0           }
2196              
2197              
2198              
2199              
2200             sub sweep_prop_configure {
2201 0     0 0   my $self= shift;
2202 0           my %params = validated_hash(
2203             \@_,
2204             point_number =>{isa=>"Int", optional=>1},
2205             number_of_sweeps =>{isa =>"Int", optional =>1},
2206             backwards =>{isa=>"Int", optional =>1},
2207             at_end=> {isa => "Int", optional =>1},
2208             at_end_val =>{isa =>"Num", optional =>1},
2209             save_all =>{isa=>"Num",optional =>1}
2210             );
2211              
2212 0 0         if(!exists($params{point_number})){
2213 0           $params{point_number}=$self->sweep_prop_configuration()->{point_number};
2214             }
2215 0 0         if(!exists($params{number_of_sweeps})){
2216 0           $params{number_of_sweeps}=$self->sweep_prop_configuration()->{number_of_sweeps};
2217             }
2218 0 0         if(!exists($params{backwards})){
2219 0           $params{backwards}=$self->sweep_prop_configuration()->{backwards};
2220             }
2221 0 0         if(!exists($params{at_end})){
2222 0           $params{at_end}=$self->sweep_prop_configuration()->{at_end};
2223             }
2224 0 0         if(!exists($params{at_end_val})){
2225 0           $params{at_end_val}=$self->sweep_prop_configuration()->{at_end_val};
2226             }
2227 0 0         if(!exists($params{save_all})){
2228 0           $params{save_all}=$self->sweep_prop_configuration()->{save_all};
2229             }
2230              
2231 0 0         if($params{point_number}<0){
2232 0           die "Invalid point_number value in sweep_prop_configure: value must be greater or equal to 0!";
2233             }
2234 0 0         if($params{number_of_sweeps}<0){
2235 0           die "Invalid sweep_number value in sweep_prop_configure: value must be greater or equal to 0!";
2236             }
2237 0 0 0       if($params{backwards}!=-1 && $params{backwards}!=0 && $params{backwards}!=1){
      0        
2238 0           die "Invalid backwards value in sweep_prop_configure: value -1,0 or 1";
2239             }
2240 0 0 0       if($params{at_end}!=-1 && $params{at_end}!=0 && $params{at_end}!=1 && $params{at_end}!=2){
      0        
      0        
2241 0           die "Invalid backwards value in sweep_prop_configure: value -1,0,1 or 2";
2242             }
2243 0 0 0       if($params{save_all}!=-1 && $params{save_all}!=0 && $params{save_all}!=1){
      0        
2244 0           die "Invalid backwards value in sweep_prop_configure: value -1,0 or 1";
2245             }
2246 0           $self->_sweep_prop_configuration(\%params);
2247             $self->threeDSwp_SwpChPropsSet($params{point_number},
2248             $params{number_of_sweeps},
2249             $params{backwards},
2250             $params{at_end},
2251             $params{at_end_val},
2252 0           $params{save_all});
2253             }
2254              
2255             sub step1_prop_configure {
2256 0     0 0   my $self= shift;
2257 0           my %params = validated_hash(
2258             \@_,
2259             point_number =>{isa=>"Int", optional=>1},
2260             backwards =>{isa=>"Int", optional =>1},
2261             at_end=> {isa => "Int", optional =>1},
2262             at_end_val =>{isa =>"Num", optional =>1}
2263             );
2264              
2265 0 0         if(!exists($params{point_number})){
2266 0           $params{point_number}=$self->step1_prop_configuration()->{point_number};
2267             }
2268 0 0         if(!exists($params{backwards})){
2269 0           $params{backwards}=$self->step1_prop_configuration()->{backwards};
2270             }
2271 0 0         if(!exists($params{at_end})){
2272 0           $params{at_end}=$self->step1_prop_configuration()->{at_end};
2273             }
2274 0 0         if(!exists($params{at_end_val})){
2275 0           $params{at_end_val}=$self->step1_prop_configuration()->{at_end_val};
2276             }
2277              
2278 0 0         if($params{point_number}<0){
2279 0           die "Invalid point_number value in step1_prop_configure: value must be greater or equal to 0!";
2280             }
2281 0 0 0       if($params{backwards}!=-1 && $params{backwards}!=0 && $params{backwards}!=1){
      0        
2282 0           die "Invalid backwards value in step1_prop_configure: value -1,0 or 1";
2283             }
2284 0 0 0       if($params{at_end}!=-1 && $params{at_end}!=0 && $params{at_end}!=1 && $params{at_end}!=2){
      0        
      0        
2285 0           die "Invalid backwards value in step1_prop_configure: value -1,0,1 or 2";
2286             }
2287              
2288 0           $self->_step1_prop_configuration(\%params);
2289             $self->threeDSwp_StpCh1PropsSet($params{point_number},
2290             $params{backwards},
2291             $params{at_end},
2292 0           $params{at_end_val});
2293             }
2294              
2295             sub step2_prop_configure {
2296 0     0 0   my $self= shift;
2297 0           my %params = validated_hash(
2298             \@_,
2299             point_number =>{isa=>"Int", optional=>1},
2300             backwards =>{isa=>"Int", optional =>1},
2301             at_end=> {isa => "Int", optional =>1},
2302             at_end_val =>{isa =>"Num", optional =>1}
2303             );
2304              
2305 0 0         if(!exists($params{point_number})){
2306 0           $params{point_number}=$self->step1_prop_configuration()->{point_number};
2307             }
2308 0 0         if(!exists($params{backwards})){
2309 0           $params{backwards}=$self->step1_prop_configuration()->{backwards};
2310             }
2311 0 0         if(!exists($params{at_end})){
2312 0           $params{at_end}=$self->step2_prop_configuration()->{at_end};
2313             }
2314 0 0         if(!exists($params{at_end_val})){
2315 0           $params{at_end_val}=$self->step2_prop_configuration()->{at_end_val};
2316             }
2317              
2318 0 0         if($params{point_number}<0){
2319 0           die "Invalid point_number value in step2_prop_configure: value must be greater or equal to 0!";
2320             }
2321              
2322 0 0 0       if($params{backwards}!=-1 && $params{backwards}!=0 && $params{backwards}!=1){
      0        
2323 0           die "Invalid backwards value in step2_prop_configure: value -1,0 or 1";
2324             }
2325              
2326 0 0 0       if($params{at_end}!=-1 && $params{at_end}!=0 && $params{at_end}!=1 && $params{at_end}!=2){
      0        
      0        
2327 0           die "Invalid backwards value in step2_prop_configure: value -1,0,1 or 2";
2328             }
2329              
2330 0           $self->_step2_prop_configuration(\%params);
2331             $self->threeDSwp_StpCh2PropsSet($params{point_number},
2332             $params{backwards},
2333             $params{at_end},
2334 0           $params{at_end_val});
2335             }
2336              
2337             sub tramea_sweep {
2338 0     0 0   my ($self, %params) = validated_hash(
2339             \@_,
2340             sweep_channel => {isa => "Int"},
2341             step1_channel => {isa => "Int", optional=>1},
2342             step2_channel_idx => {isa => "Int", optional=>1},
2343             step2_channel_name => {isa => "Str", optional=>1},
2344             aquisition_channels => {isa=>"ArrayRef[Int]"},
2345             lower_limit_sweep =>{isa=>"Num"},
2346             upper_limit_sweep =>{isa=>"Num"},
2347             lower_limit_step1 =>{isa=>"Num",optional=>1},
2348             upper_limit_step1 =>{isa=>"Num",optional=>1},
2349             lower_limit_step2 =>{isa=>"Num",optional=>1},
2350             upper_limit_step2 =>{isa=>"Num",optional=>1},
2351             point_number_sweep =>{isa=>"Int", optional=>1},
2352             point_number_step1 =>{isa=>"Int", optional=>1},
2353             point_number_step2 =>{isa=>"Int", optional=>1},
2354             series_name => {isa=> "Str", optional=>1},
2355             comment => {isa=>"Str", optional =>1},
2356             load => {isa=>"Bool", default=>1}
2357             );
2358            
2359              
2360             # PARAMETER CONTROLL FOR Sweep Channel, Need to check for maximum channel?
2361              
2362 0 0 0       if(exists($params{point_number_sweep}) && $params{point_number_sweep}!= $self->sweep_prop_configuration()->{point_number}){
2363 0           $self->sweep_prop_configure(point_number=>$params{point_number_sweep});
2364             }
2365            
2366 0           $self->threeDSwp_SwpChSignalSet($params{sweep_channel});
2367            
2368 0           $self->threeDSwp_SwpChLimitsSet($params{lower_limit_sweep},$params{upper_limit_sweep});
2369             # PARAMETER CONTROLL FOR Step channel 1
2370 0 0         if(exists($params{step1_channel}))
2371             {
2372 0 0         if($params{step1_channel}>=0)
2373             {
2374 0 0 0       if(exists($params{point_number_step1}) && $params{point_number_step1}!= $self->step1_prop_configuration()->{point_number})
2375             {
2376 0           $self->step1_prop_configure(point_number=>$params{point_number_step1});
2377             }
2378              
2379 0 0         if(exists($params{lower_limit_step1}))
2380             {
2381              
2382 0 0         if(exists($params{upper_limit_step1}))
2383             {
2384 0           $self->threeDSwp_StpCh1SignalSet($params{step1_channel});
2385             $self->threeDSwp_StpCh1LimitsSet($params{lower_limit_step1},$params{upper_limit_step1})
2386 0           }
2387             else
2388             {
2389 0           die "No upper limit supplied to Step Channel 1, upper_limit_step1";
2390             }
2391              
2392             }
2393             else
2394             {
2395 0           die "No lower limit supplied to Step Channel 1, lower_limit_step1";
2396             }
2397             }
2398             else
2399             {
2400 0           die "Invalid value for step1_channel, value must be greter or equal to 0!"
2401             }
2402             }
2403             else
2404             {
2405 0           $self->threeDSwp_StpCh1SignalSet(-1);
2406             }
2407              
2408              
2409             # PARAMETER CONTROLL FOR Step channel 2
2410 0 0 0       if(exists($params{step2_channel_idx}) && exists($params{step2_channel_name}))
    0 0        
2411             {
2412 0           croak "Supply either step2_channel_idx or step2_channel_name";
2413             }
2414             elsif(exists($params{step2_channel_idx}) or exists($params{step2_channel_name}))
2415             {
2416 0 0         if (exists($params{step2_channel_idx}))
    0          
2417             {
2418 0           $params{step2_channel_name}=" ";
2419             }
2420             elsif(exists($params{step2_channel_name}))
2421             {
2422 0           $params{step2_channel_idx}=-1;
2423             }
2424 0 0 0       if($params{step2_channel_idx}>=0 or $params{step2_channel_name} ne " ")
2425             {
2426 0 0 0       if(exists($params{point_number_step2}) && $params{point_number_step2}!= $self->step2_prop_configuration()->{point_number})
2427             {
2428 0           $self->step2_prop_configure(point_number=>$params{point_number_step2});
2429             }
2430              
2431 0 0         if(exists($params{lower_limit_step2}))
2432             {
2433              
2434 0 0         if(exists($params{upper_limit_step2}))
2435             {
2436 0 0         if($params{step2_channel_idx}>=0)
    0          
2437             {
2438 0           $self->threeDSwp_StpCh2SignalSet($self->outputs->{$params{step2_channel_idx}});
2439             }
2440             elsif($params{step2_channel_name} ne " ")
2441             {
2442 0           $self->threeDSwp_StpCh2SignalSet($params{step2_channel_name});
2443             }
2444             $self->threeDSwp_StpCh2LimitsSet($params{lower_limit_step2},$params{upper_limit_step2})
2445 0           }
2446             else
2447             {
2448 0           die "No upper limit supplied to Step Channel 2, upper_limit_step2";
2449             }
2450              
2451             }
2452             else
2453             {
2454 0           die "No lower limit supplied to Step Channel 2, lower_limit_step2";
2455             }
2456             }
2457             else
2458             {
2459 0           die "Invalid value for step2_channel_idx, value must be greter or equal to 0!"
2460             }
2461             }
2462             else
2463             {
2464 0           $self->threeDSwp_StpCh2SignalSet("");
2465             }
2466              
2467 0 0 0       if(exists($params{series_name})&& $params{series_name} ne $self->sweep_save_configuration()->{series_name}){
2468 0           $self->sweep_save_configure(series_name=>$params{series_name});
2469             }
2470              
2471 0 0 0       if(exists($params{comment})&& ($params{comment} ne $self->sweep_save_configuration()->{comment})){
2472 0           $self->sweep_save_configure(comment=>$params{comment});
2473             }
2474 0           $self->threeDSwp_AcqChsSet($params{aquisition_channels});
2475             # Still unclear what is happenig here :///////
2476             # Can not find it, report may be needed
2477 0           sleep(1);
2478 0           $self->threeDSwp_Start();
2479 0   0       while($self->threeDSwp_StatusGet()!=0 && $self->threeDSwp_StatusGet()!=2)
2480             {
2481 0           sleep(0.1);
2482             }
2483 0 0         if($params{load}==1)
2484             {
2485 0           return $self->load_last_measurement();
2486             }
2487             }
2488             __PACKAGE__->meta()->make_immutable();
2489              
2490             1;
2491              
2492             __END__
2493              
2494             =pod
2495              
2496             =encoding UTF-8
2497              
2498             =head1 NAME
2499              
2500             Lab::Moose::Instrument::NanonisTramea - Nanonis Tramea
2501              
2502             =head1 VERSION
2503              
2504             version 3.880
2505              
2506             =head1 SYNOPSIS
2507              
2508             my $tramea = instrument(
2509             type => 'NanonisTramea',
2510             connection_type => 'Socket',
2511             connection_options => { host => '000.000.000.00',
2512             port => '0000',
2513             write_termchar => ''
2514             }
2515             );
2516              
2517             =head1 FORMATTERS
2518             Collections of functions to pack or unpack numbers and srings for TCP comunication
2519              
2520             =head2 nt_string
2521              
2522             =head2 nt_int
2523              
2524             =head2 nt_uint16
2525              
2526             =head2 nt_uint32
2527              
2528             =head2 nt_float32
2529              
2530             =head2 nt_float64
2531              
2532             =head2 nt_header
2533              
2534             my $header = $tramea->nt_header($command,$body_size,$response);
2535              
2536             Function to format Header of tcp message.
2537             C<command> refers to command name as reported in the Nanonis Tramea documentation
2538             C<body_size> refers to the size of the message body, not including the header itself.
2539             C<response> Must have value of either 0 or 1. If value is the nanonis Software will send a response according to documentation.
2540              
2541             =head2 _end_of_com
2542              
2543             =head2 strArrayUnpacker
2544              
2545             my %strArray = $tramea->strArrayUnpacker($element_number, $string_array);
2546              
2547             Returns an hash that has as keys the indexes of the strings in the array and as items the strings themselves.
2548             C<element_number> refers to the ammount of strings about to be in the array.
2549             C<string_array> refers to the binary of the strings array.
2550              
2551             =head2 intArrayUnpacker
2552              
2553             my @int_array = $tramea->intArrayUnpacker($element_number, $int_array);
2554              
2555             Unpacks binary array of int and returns into perl Array type.
2556             C<element_number> refers to the expected number of elements in the array.
2557             C<int_array> refers to the int array binary.
2558              
2559             =head2 float32ArrayUnpacker
2560              
2561             my $floeat32_array = $tramea->float32ArrayUnpacker($element_number, $float32_array);
2562              
2563             Unpacks binary array of float32 and returns into perl Array type.
2564             C<element_number> refers to the expected number of elements in the array.
2565             C<float32_array> refers to float32 array binary.
2566              
2567             =head1 1DSweep
2568              
2569             =head1 3DSwp
2570              
2571             =head2 3DSwp.SwpChannel
2572              
2573             =head2 3DSwp.StepChanne1
2574              
2575             =head2 3DSwp.StepChannel2
2576              
2577             =head2 3DSwp.Timing
2578              
2579             =head2 3DSwp.FilePathsGet
2580              
2581             =head1 Signals
2582              
2583             =head1 User
2584              
2585             =head1 Digita Lines
2586              
2587             =head1 Utilities
2588              
2589             =head1 File
2590              
2591             =head1 High Level COM
2592              
2593             =head2 Class Variables
2594              
2595             =head2 Class Methods
2596              
2597             =head1 COPYRIGHT AND LICENSE
2598              
2599             This software is copyright (c) 2023 by the Lab::Measurement team; in detail:
2600              
2601             Copyright 2022 Andreas K. Huettel, Erik Fabrizzi, Simon Reinhardt
2602             2023 Erik Fabrizzi
2603              
2604              
2605             This is free software; you can redistribute it and/or modify it under
2606             the same terms as the Perl 5 programming language system itself.
2607              
2608             =cut