diff -r 200d69222aed -r 6f1e9c4bee3c Quancom/Result.pm --- a/Quancom/Result.pm Tue Dec 09 15:58:11 2008 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,82 +0,0 @@ -package Quancom::Result; - -use strict; -use warnings; - -sub new { - my $class = ref $_[0] ? ref shift : shift; - return bless {} => $class; -} - -sub ok { - my $self = shift; - return $self->{ok}; -} - -sub result { - my $self = shift; - return undef if not $self->{ok}; - return $self->{result}; -} - -sub error { - my $self = shift; - return undef if $self->{ok}; - return $self->{error_code}; -} - -sub error_message { - my $self = shift; - - return undef if !@_ and $self->{ok}; - - return ("checksum error", "character error", "invalid command", - "invalid width")[ @_ ? $_[0] : $self->{error_code} ]; -} - -1; - -__END__ - -=head1 NAME - -Quancom::Result - perl module to access the usb opto quancom device result - -=head1 SYNOPSIS - - use Quancom; - - my $q = new Quancom 172.16.0.22; - my $r = $q->cmd("xxxxxx") - or die $r->error_message; - -=head1 METHODS - -=over - -=item B ( ) - -Use this method to query the last operations status. - -=item B ( ) - -Returns the last result. This is valid only if the last status is ok, -otherwise you'll get "undef". - -=item B ( [I] ) - -Returns a message describing the last error. Of if you pass an error -code it will the return the associated message. - -=item B ( ) - -Returns the last error code (numerical). - -=back - -=head1 AUTHOR - - Maik Schueller - Heiko Schlittermann - -=cut