File Coverage

blib/lib/HiPi/Interface.pm
Criterion Covered Total %
statement 12 22 54.5
branch n/a
condition n/a
subroutine 4 8 50.0
pod 0 3 0.0
total 16 33 48.4


line stmt bran cond sub pod time code
1             #########################################################################################
2             # Package HiPi::Interface
3             # Description : Base class for interfaces
4             # Copyright : Copyright (c) 2013-2017 Mark Dootson
5             # License : This is free software; you can redistribute it and/or modify it under
6             # the same terms as the Perl 5 programming language system itself.
7             #########################################################################################
8              
9             package HiPi::Interface;
10              
11             #########################################################################################
12              
13 1     1   506 use strict;
  1         2  
  1         28  
14 1     1   5 use warnings;
  1         2  
  1         26  
15 1     1   4 use parent qw( HiPi::Class );
  1         2  
  1         9  
16 1     1   656 use Time::HiRes qw( usleep );
  1         1739  
  1         4  
17              
18             __PACKAGE__->create_accessors( qw( device ) );
19              
20             our $VERSION ='0.81';
21              
22             sub new {
23 0     0 0   my ($class, %params) = @_;
24 0           my $self = $class->SUPER::new(%params);
25 0           return $self;
26             }
27              
28             sub delay {
29 0     0 0   my($class, $millis) = @_;
30 0           usleep( int($millis * 1000) );
31             }
32              
33             sub delayMicroseconds {
34 0     0 0   my($class, $micros) = @_;
35 0           usleep( int($micros) );
36             }
37              
38             *HiPi::Interface::sleep_milliseconds = \&delay;
39             *HiPi::Interface::sleep_microseconds = \&delayMicroseconds;
40              
41             sub DESTROY {
42 0     0     my $self = shift;
43 0           $self->SUPER::DESTROY;
44 0           $self->device( undef );
45             }
46              
47             1;