line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Lab::Moose::Instrument::SCPI::Format; |
2
|
|
|
|
|
|
|
$Lab::Moose::Instrument::SCPI::Format::VERSION = '3.900'; |
3
|
|
|
|
|
|
|
#ABSTRACT: Role for SCPI FORMat subsystem. |
4
|
|
|
|
|
|
|
|
5
|
4
|
|
|
4
|
|
2487
|
use v5.20; |
|
4
|
|
|
|
|
17
|
|
6
|
|
|
|
|
|
|
|
7
|
4
|
|
|
4
|
|
25
|
use Moose::Role; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
29
|
|
8
|
4
|
|
|
4
|
|
20561
|
use Lab::Moose::Instrument qw/setter_params getter_params validated_getter/; |
|
4
|
|
|
|
|
11
|
|
|
4
|
|
|
|
|
217
|
|
9
|
4
|
|
|
4
|
|
1016
|
use Lab::Moose::Instrument::Cache; |
|
4
|
|
|
|
|
13
|
|
|
4
|
|
|
|
|
24
|
|
10
|
4
|
|
|
4
|
|
2369
|
use MooseX::Params::Validate; |
|
4
|
|
|
|
|
10
|
|
|
4
|
|
|
|
|
23
|
|
11
|
4
|
|
|
4
|
|
1805
|
use Carp; |
|
4
|
|
|
|
|
17
|
|
|
4
|
|
|
|
|
2036
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
cache format_data => ( getter => 'format_data_query' ); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub format_data_query { |
17
|
3
|
|
|
3
|
1
|
16
|
my ( $self, %args ) = validated_getter( \@_ ); |
18
|
|
|
|
|
|
|
|
19
|
3
|
|
|
|
|
1658
|
my $format = $self->query( command => 'FORM?', %args ); |
20
|
|
|
|
|
|
|
|
21
|
3
|
50
|
|
|
|
30
|
if ( $format !~ /^(?<format>\w+)(,\+?(?<length>\d+))?$/ ) { |
22
|
0
|
|
|
|
|
0
|
croak "illegal value of DATA:FORMat: $format"; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
3
|
|
|
|
|
60
|
return $self->cached_format_data( [ $+{format}, $+{length} ] ); |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub format_data { |
29
|
3
|
|
|
3
|
1
|
19
|
my ( $self, %args ) = validated_hash( |
30
|
|
|
|
|
|
|
\@_, |
31
|
|
|
|
|
|
|
setter_params(), |
32
|
|
|
|
|
|
|
format => { isa => 'Str' }, |
33
|
|
|
|
|
|
|
length => { isa => 'Int', optional => 1 }, |
34
|
|
|
|
|
|
|
); |
35
|
|
|
|
|
|
|
|
36
|
3
|
|
|
|
|
2688
|
my $format = delete $args{format}; |
37
|
3
|
|
|
|
|
10
|
my $length = delete $args{length}; |
38
|
3
|
|
|
|
|
13
|
my $command = "FORM $format"; |
39
|
3
|
50
|
|
|
|
17
|
if ( defined $length ) { |
40
|
3
|
|
|
|
|
11
|
$command .= ", $length"; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
3
|
|
|
|
|
21
|
$self->write( command => $command, %args ); |
44
|
|
|
|
|
|
|
|
45
|
3
|
|
|
|
|
25
|
return $self->cached_format_data( [ $format, $length ] ); |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
cache format_border => ( getter => 'format_border_query' ); |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub format_border_query { |
52
|
1
|
|
|
1
|
1
|
5
|
my ( $self, %args ) = validated_getter( \@_ ); |
53
|
|
|
|
|
|
|
|
54
|
1
|
|
|
|
|
483
|
return $self->cached_format_border( |
55
|
|
|
|
|
|
|
$self->query( command => 'FORM:BORD?', %args ) ); |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub format_border { |
59
|
0
|
|
|
0
|
1
|
|
my ( $self, $value, %args ) = validated_setter( \@_ ); |
60
|
|
|
|
|
|
|
|
61
|
0
|
|
|
|
|
|
$self->write( command => "FORM:BORD $value", %args ); |
62
|
0
|
|
|
|
|
|
return $self->cached_format_border($value); |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
1; |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
__END__ |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=pod |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=encoding UTF-8 |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=head1 NAME |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
Lab::Moose::Instrument::SCPI::Format - Role for SCPI FORMat subsystem. |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head1 VERSION |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
version 3.900 |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head1 METHODS |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head2 format_data_query |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=head2 format_data |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
# set to binary single precision |
88
|
|
|
|
|
|
|
$instr->format_data(format => 'REAL', length => 32); |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
# set to binary double precision |
91
|
|
|
|
|
|
|
$instr->format_data(format => 'REAL', length => 64); |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
# set to ASCII, 10 significant digits |
94
|
|
|
|
|
|
|
$instr->format_data(format => 'ASC', length => 10); |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
my $format = $instr->cached_format_data(); |
97
|
|
|
|
|
|
|
print "format: $format->[0], len: $format->[1]\n"; |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
Set/Get data format. |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=head2 format_border_query |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=head2 format_border |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
$instr->format_border(value => 'NORM'); # or 'SWAP' |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
Set/Get byte order of transferred data. Normally you want 'SWAP' |
108
|
|
|
|
|
|
|
(little-endian), which is the native machine format of the measurement PC. |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
This software is copyright (c) 2023 by the Lab::Measurement team; in detail: |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
Copyright 2016 Simon Reinhardt |
115
|
|
|
|
|
|
|
2017 Andreas K. Huettel, Simon Reinhardt |
116
|
|
|
|
|
|
|
2018 Simon Reinhardt |
117
|
|
|
|
|
|
|
2020 Andreas K. Huettel, Sam Bingner |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
121
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=cut |