| 1 | package Lab::Moose::Instrument::OI_Common; | ||||||||||
| 2 | 2 | $Lab::Moose::Instrument::OI_Common::VERSION = '3.931'; | |||||||||
| 3 | #ABSTRACT: Role for handling Oxfords Instruments pseudo-SCPI commands | ||||||||||
| 4 | |||||||||||
| 5 | 2 | ▶ | use v5.20; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | |||||||||||
| 7 | 2 | ▶ | use Moose::Role; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 2 | ▶ | use MooseX::Params::Validate; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | 2 | ▶ | use Lab::Moose::Instrument qw/validated_getter validated_setter/; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | |||||||||||
| 11 | 2 | ▶ | use Carp; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 12 | 2 | ▶ | use namespace::autoclean; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 13 | |||||||||||
| 14 | |||||||||||
| 15 | 0 | ▶ | sub get_temperature_channel { | ||||||||
|
Subroutine
get_temperature_channel: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 16 | 0 | my ( $self, %args ) = validated_getter( | |||||||||
| 17 | \@_, | ||||||||||
| 18 | channel => { isa => 'Str' } | ||||||||||
| 19 | ); | ||||||||||
| 20 | |||||||||||
| 21 | 0 | my $channel = delete $args{channel}; | |||||||||
| 22 | |||||||||||
| 23 | 0 | my $rv | |||||||||
| 24 | = $self->oi_getter( cmd => "READ:DEV:$channel:TEMP:SIG:TEMP", %args ); | ||||||||||
| 25 | 0 | $rv =~ s/K.*$//; | |||||||||
| 26 | 0 | return $rv; | |||||||||
| 27 | } | ||||||||||
| 28 | |||||||||||
| 29 | 0 | ▶ | sub get_temperature_channel_resistance { | ||||||||
|
Subroutine
get_temperature_channel_resistance: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 30 | 0 | my ( $self, %args ) = validated_getter( | |||||||||
| 31 | \@_, | ||||||||||
| 32 | channel => { isa => 'Str' } | ||||||||||
| 33 | ); | ||||||||||
| 34 | |||||||||||
| 35 | 0 | my $channel = delete $args{channel}; | |||||||||
| 36 | |||||||||||
| 37 | 0 | my $rv | |||||||||
| 38 | = $self->oi_getter( cmd => "READ:DEV:$channel:TEMP:SIG:RES", %args ); | ||||||||||
| 39 | 0 | $rv =~ s/Ohm.*$//; | |||||||||
| 40 | 0 | return $rv; | |||||||||
| 41 | } | ||||||||||
| 42 | |||||||||||
| 43 | 6 | ▶ | sub _parse_setter_retval { | ||||||||
|
Subroutine
_parse_setter_retval: called CC=2 SCAR=7.2
| |||||||||||
| 44 | 6 | my $self = shift; | |||||||||
| 45 | 6 | my ( $header, $retval ) = @_; | |||||||||
| 46 | |||||||||||
| 47 | 6 | $header = 'STAT:' . $header; | |||||||||
| 48 | 6 | ▶ | if ( $retval !~ /^\Q$header\E:([^:]+):VALID$/ ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 49 | 0 | croak "Invalid return value of setter for header $header:\n $retval"; | |||||||||
| 50 | } | ||||||||||
| 51 | 6 | return $1; | |||||||||
| 52 | } | ||||||||||
| 53 | |||||||||||
| 54 | 11 | ▶ | sub _parse_getter_retval { | ||||||||
|
Subroutine
_parse_getter_retval: called CC=2 SCAR=7.2
| |||||||||||
| 55 | 11 | my $self = shift; | |||||||||
| 56 | 11 | my ( $header, $retval ) = @_; | |||||||||
| 57 | |||||||||||
| 58 | 11 | $header =~ s/^READ:/STAT:/; | |||||||||
| 59 | |||||||||||
| 60 | 11 | ▶ | if ( $retval !~ /^\Q$header\E:(.+)/ ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 61 | 0 | croak "Invalid return value of getter for header $header:\n $retval"; | |||||||||
| 62 | } | ||||||||||
| 63 | 11 | return $1; | |||||||||
| 64 | } | ||||||||||
| 65 | |||||||||||
| 66 | |||||||||||
| 67 | 11 | ▶ | sub oi_getter { | ||||||||
|
Subroutine
oi_getter: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 68 | 11 | my ( $self, %args ) = validated_getter( | |||||||||
| 69 | \@_, | ||||||||||
| 70 | cmd => { isa => 'Str' } | ||||||||||
| 71 | ); | ||||||||||
| 72 | 11 | my $cmd = delete $args{cmd}; | |||||||||
| 73 | 11 | my $rv = $self->query( command => $cmd, %args ); | |||||||||
| 74 | 11 | return $self->_parse_getter_retval( $cmd, $rv ); | |||||||||
| 75 | } | ||||||||||
| 76 | |||||||||||
| 77 | |||||||||||
| 78 | 6 | ▶ | sub oi_setter { | ||||||||
|
Subroutine
oi_setter: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 79 | 6 | my ( $self, $value, %args ) = validated_setter( | |||||||||
| 80 | \@_, | ||||||||||
| 81 | cmd => { isa => 'Str' } | ||||||||||
| 82 | ); | ||||||||||
| 83 | 6 | my $cmd = delete $args{cmd}; | |||||||||
| 84 | 6 | my $rv = $self->query( command => "$cmd:$value", %args ); | |||||||||
| 85 | 6 | return $self->_parse_setter_retval( $cmd, $rv ); | |||||||||
| 86 | } | ||||||||||
| 87 | |||||||||||
| 88 | 2 | 1; | |||||||||
| 89 | |||||||||||
| 90 | __END__ | ||||||||||