| 1 | package Lab::Moose::Instrument::SCPI::Format; | ||||||||||
| 2 | 4 | $Lab::Moose::Instrument::SCPI::Format::VERSION = '3.931'; | |||||||||
| 3 | #ABSTRACT: Role for SCPI FORMat subsystem. | ||||||||||
| 4 | |||||||||||
| 5 | 4 | ▶ | use v5.20; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | |||||||||||
| 7 | 4 | ▶ | use Moose::Role; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 4 | ▶ | use Lab::Moose::Instrument qw/setter_params getter_params validated_getter/; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | 4 | ▶ | use Lab::Moose::Instrument::Cache; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | 4 | ▶ | use MooseX::Params::Validate; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | 4 | ▶ | use Carp; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 12 | |||||||||||
| 13 | |||||||||||
| 14 | 4 | cache format_data => ( getter => 'format_data_query' ); | |||||||||
| 15 | |||||||||||
| 16 | 3 | ▶ | sub format_data_query { | ||||||||
|
Subroutine
format_data_query: called CC=2 SCAR=7.4
Pod
documented
| |||||||||||
| 17 | 3 | my ( $self, %args ) = validated_getter( \@_ ); | |||||||||
| 18 | |||||||||||
| 19 | 3 | my $format = $self->query( command => 'FORM?', %args ); | |||||||||
| 20 | |||||||||||
| 21 | 3 | ▶ | if ( $format !~ /^(?<format>\w+)(,\+?(?<length>\d+))?$/ ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 22 | 0 | croak "illegal value of DATA:FORMat: $format"; | |||||||||
| 23 | } | ||||||||||
| 24 | |||||||||||
| 25 | 3 | return $self->cached_format_data( [ $+{format}, $+{length} ] ); | |||||||||
| 26 | } | ||||||||||
| 27 | |||||||||||
| 28 | 3 | ▶ | sub format_data { | ||||||||
|
Subroutine
format_data: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||
| 29 | 3 | my ( $self, %args ) = validated_hash( | |||||||||
| 30 | \@_, | ||||||||||
| 31 | setter_params(), | ||||||||||
| 32 | format => { isa => 'Str' }, | ||||||||||
| 33 | length => { isa => 'Int', optional => 1 }, | ||||||||||
| 34 | ); | ||||||||||
| 35 | |||||||||||
| 36 | 3 | my $format = delete $args{format}; | |||||||||
| 37 | 3 | my $length = delete $args{length}; | |||||||||
| 38 | 3 | my $command = "FORM $format"; | |||||||||
| 39 | 3 | ▶ | if ( defined $length ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 40 | 3 | $command .= ", $length"; | |||||||||
| 41 | } | ||||||||||
| 42 | |||||||||||
| 43 | 3 | $self->write( command => $command, %args ); | |||||||||
| 44 | |||||||||||
| 45 | 3 | return $self->cached_format_data( [ $format, $length ] ); | |||||||||
| 46 | } | ||||||||||
| 47 | |||||||||||
| 48 | |||||||||||
| 49 | 4 | cache format_border => ( getter => 'format_border_query' ); | |||||||||
| 50 | |||||||||||
| 51 | 1 | ▶ | sub format_border_query { | ||||||||
|
Subroutine
format_border_query: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 52 | 1 | my ( $self, %args ) = validated_getter( \@_ ); | |||||||||
| 53 | |||||||||||
| 54 | 1 | return $self->cached_format_border( | |||||||||
| 55 | $self->query( command => 'FORM:BORD?', %args ) ); | ||||||||||
| 56 | } | ||||||||||
| 57 | |||||||||||
| 58 | 0 | ▶ | sub format_border { | ||||||||
|
Subroutine
format_border: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 59 | 0 | 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 | 4 | 1; | |||||||||
| 66 | |||||||||||
| 67 | __END__ | ||||||||||