line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Lab::Moose::Instrument::SCPI::Format; |
2
|
|
|
|
|
|
|
$Lab::Moose::Instrument::SCPI::Format::VERSION = '3.880'; |
3
|
|
|
|
|
|
|
#ABSTRACT: Role for SCPI FORMat subsystem. |
4
|
|
|
|
|
|
|
|
5
|
4
|
|
|
4
|
|
2637
|
use v5.20; |
|
4
|
|
|
|
|
15
|
|
6
|
|
|
|
|
|
|
|
7
|
4
|
|
|
4
|
|
25
|
use Moose::Role; |
|
4
|
|
|
|
|
14
|
|
|
4
|
|
|
|
|
40
|
|
8
|
4
|
|
|
4
|
|
21785
|
use Lab::Moose::Instrument qw/setter_params getter_params validated_getter/; |
|
4
|
|
|
|
|
18
|
|
|
4
|
|
|
|
|
250
|
|
9
|
4
|
|
|
4
|
|
1120
|
use Lab::Moose::Instrument::Cache; |
|
4
|
|
|
|
|
15
|
|
|
4
|
|
|
|
|
40
|
|
10
|
4
|
|
|
4
|
|
2495
|
use MooseX::Params::Validate; |
|
4
|
|
|
|
|
10
|
|
|
4
|
|
|
|
|
30
|
|
11
|
4
|
|
|
4
|
|
1862
|
use Carp; |
|
4
|
|
|
|
|
30
|
|
|
4
|
|
|
|
|
2108
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
cache format_data => ( getter => 'format_data_query' ); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub format_data_query { |
17
|
3
|
|
|
3
|
1
|
15
|
my ( $self, %args ) = validated_getter( \@_ ); |
18
|
|
|
|
|
|
|
|
19
|
3
|
|
|
|
|
1691
|
my $format = $self->query( command => 'FORM?', %args ); |
20
|
|
|
|
|
|
|
|
21
|
3
|
50
|
|
|
|
31
|
if ( $format !~ /^(?<format>\w+)(,\+?(?<length>\d+))?$/ ) { |
22
|
0
|
|
|
|
|
0
|
croak "illegal value of DATA:FORMat: $format"; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
3
|
|
|
|
|
68
|
return $self->cached_format_data( [ $+{format}, $+{length} ] ); |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub format_data { |
29
|
3
|
|
|
3
|
1
|
18
|
my ( $self, %args ) = validated_hash( |
30
|
|
|
|
|
|
|
\@_, |
31
|
|
|
|
|
|
|
setter_params(), |
32
|
|
|
|
|
|
|
format => { isa => 'Str' }, |
33
|
|
|
|
|
|
|
length => { isa => 'Int', optional => 1 }, |
34
|
|
|
|
|
|
|
); |
35
|
|
|
|
|
|
|
|
36
|
3
|
|
|
|
|
2693
|
my $format = delete $args{format}; |
37
|
3
|
|
|
|
|
10
|
my $length = delete $args{length}; |
38
|
3
|
|
|
|
|
12
|
my $command = "FORM $format"; |
39
|
3
|
50
|
|
|
|
14
|
if ( defined $length ) { |
40
|
3
|
|
|
|
|
16
|
$command .= ", $length"; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
3
|
|
|
|
|
17
|
$self->write( command => $command, %args ); |
44
|
|
|
|
|
|
|
|
45
|
3
|
|
|
|
|
30
|
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
|
6
|
my ( $self, %args ) = validated_getter( \@_ ); |
53
|
|
|
|
|
|
|
|
54
|
1
|
|
|
|
|
484
|
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.880 |
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 |