Lab-Measurement-Legacy

 view release on metacpan or  search on metacpan

lib/Lab/Instrument/TDS2024B.pm  view on Meta::CPAN

    my $time = sprintf('%02d:%02d:%02d',$hour,$min,$sec);

    $self->write("DATE \"$date\"");
    $self->write("TIME \"$time\"");

    return "$date $time";
}

    

sub wait_done {
    my $self = shift;
    my ( $time, $dt, $tail )
        = $self->_check_args( \@_, qw(timeout checkinterval) );

    my $tmax;

    $time = '10s' unless defined $time;

    if ( $time =~ /\s*(INF|MAX)/i ) {
        $tmax = -1;
    }
    else {
        $tmax = _parseNRf( $time, 's' );
        if ( $time =~ /(ERR|MIN|MAX)/ || $tmax <= 0 ) {
            Lab::Exception::CorruptParameter->throw(
                "Invalid time input '$time'\n");
            return;
        }
    }

    my $dtcheck;
    $dt = '500ms' unless defined $dt;
    $dtcheck = _parseNRf( $dt, 's' );
    if ( $dtcheck =~ /(ERR|MIN|MAX)/ || $dtcheck <= 0 ) {
        Lab::Exception::CorruptParameter->throw(
            "Invalid time check interval input '$dt'\n");
        return;
    }

    my $n;
    if ( $tmax == -1 ) {
        $n = -1;
    }
    else {
        $n = $tmax / $dtcheck;

        $n = int( $n + 0.5 );
        $n = 1 if $n < 1;
        $n++;
    }

    while (1) {
        return 1 if $self->query('BUSY?') =~ /^(:BUSY )?\s*0/i;
        return 0 if $n-- == 0;
        sleep($dtcheck);
    }
}


sub test_busy {
    my $self = shift;
    return 1 if $self->query('BUSY?') =~ /^(:BUSY )?\s*1/i;
    return 0;
}


sub get_id {
    my $self = shift;
    my ($tail) = $self->_check_args( \@_ );

    $tail->{read_mode} = $self->{config}->{default_read_mode}
        unless exists( $tail->{read_mode} ) && defined( $tail->{read_mode} );

    if ( $tail->{read_mode} ne 'cache'
        || !defined( $self->{device_cache}->{ID} ) ) {
        $self->{device_cache}->{ID} = $self->query('*IDN?');
        $self->_debug();
    }
    return $self->{device_cache}->{ID};
}


sub get_header {
    my $self = shift;

    my ($tail) = $self->_check_args( \@_ );

    $tail->{read_mode} = $self->{config}->{default_read_mode}
        unless exists( $tail->{read_mode} ) && defined( $tail->{read_mode} );

    if ( $tail->{read_mode} ne 'cache'
        || !defined( $self->{device_cache}->{HEADER} ) ) {
        my $r = $self->query('HEAD?');
        $self->_debug();

        # can't use the _parseReply here...
        if ( $r =~ /HEAD(er)?\s+([\w]+)/i ) {
            $r = $2;
        }
        if ( $r =~ /(1|ON)/i ) {
            $self->{device_cache}->{HEADER} = 1;
        }
        else {
            $self->{device_cache}->{HEADER} = 0;
        }
    }
    return $self->{device_cache}->{HEADER};
}


sub save {
    my $self = shift;
    my ($in) = $self->_check_args_strict( \@_, 'setup' );

    if ( $in !~ /^s*\d+\s*$/ || $in < 1 || $in > 10 || int($in) != $in ) {
        Lab::Exception::CorruptParameter->throw(
            "Invalid save setup number '$in'\n");
        return;
    }

lib/Lab/Instrument/TDS2024B.pm  view on Meta::CPAN


=over

B<PON>: Power on

B<URQ>: User Request (not used)

B<CME>: Command Error

B<EXE>: Execution Error

B<DDE>: Device Error

B<QYE>: Query Error

B<RQC>: Request Control (not used)

B<OPC>: Operation Complete

B<ERROR>: CME or EXE or DDE or QYE

=back

=head2 get_datetime

$datetime = $s->get_datetime();

fetches the date and time from the scope, returned
in form "YYYY-MM-DD HH:MM:SS"  (numeric month, 24hr time)

=head2 set_datetime

$s->set_datetime();           set to current date and time
$s->set_datetime($unixtime);  set to unix time $unixtime

Note that the TDS2024B has no notion of 'time zones', so
default is 'local time'. 

Returns the date and time in the same format as get_datetime.

=head2 wait_done

$s->wait_done([$time[,$deltaT]);

$s->wait_done(timeout => $time, checkinterval=>$deltaT);

Wait for "operation complete". If the $time optional argument
is given, it is the (max) number of seconds to wait for completion
before returning, otherwise a timeout of 10 seconds is used.
$time can be a simple number of seconds, or a text string with
magnitude and unit suffix. (Ex: $time = "200ms"). If $time="INF"
then this routine will run indefinitely until completion (or some
I/O error). 

If $deltaT is given, checks are performed in intervals of $deltaT
seconds (again, number or text), except when $deltaT is less than $time.
$deltaT defaults to 500ms. 

Returns 1 if completed, 0 if timed out. 

=head2 test_busy

$busy = $s->test_busy();

Returns 1 if busy (waiting for trigger, etc), 0 if not busy.

=head2 get_id

$s->get_id()

Fetch the *IDN? string from device

=head2 get_header

$header = $s->get_header();

Fetch whether headers are included
with query response; returns 0 or 1.

=head2 save

$s->save($n);

$s->save(setup=>$n);

Save the scope setup to a nonvolatile internal memory $n = 1..10

=head2 recall

$s->recall($n);

$s->recall(setup=>$n);

Recall scope setup from internal memory location $n = 1..10

=head2 set_header

$s->set_header($boolean);
$s->set_header(header=>$boolean);

Turns on or off headers in query replies; Boolean
values described above.

=head2 get_verbose

$verb = $s->get_verbose();

Fetch boolean indicating whether query responses
(headers, if enabled, and response keywords)
are returned in 'long form'

=head2 set_verbose

$s->set_verbose($bool);
$s->set_verbose(verbose=>$bool);

Sets the 'verbose' mode for replies, with
the longer form of command headers (if enabled) and
keyword values. Note that
when using the get_* routines, the replies are
processed before being returned as 'long' values, 
so this routine only affects the communication
between the scope and this code. 

=head2 get_locked



( run in 3.228 seconds using v1.01-cache-2.11-cpan-437f7b0c052 )