File Coverage

blib/lib/CryoTel/CryoCon.pm
Criterion Covered Total %
statement 12 18 66.6
branch 0 2 0.0
condition n/a
subroutine 4 5 80.0
pod 1 1 100.0
total 17 26 65.3


line stmt bran cond sub pod time code
1             package CryoTel::CryoCon;
2 1     1   28361 use warnings;
  1         3  
  1         34  
3 1     1   7 use strict;
  1         2  
  1         29  
4 1     1   2033 use IO::Socket::INET;
  1         42953  
  1         6  
5 1     1   589 use base 'Exporter';
  1         2  
  1         366  
6             our @EXPORT = qw(getcc %CryoTelFunctionsA %CryoTelFunctionsB %CryoTelFunctionsC %CryoTelFunctionsD);
7             our $VERSION = '0.0.6';
8             our $MODDATE = '07-08-09';
9              
10             =head1 NAME
11              
12             CryoTel::CryoCon - A module for interfacing with CryoTel Cryocontrollers via TCP
13              
14             =head1 SYNOPSIS
15              
16             use CryoTel::CryoCon;
17              
18             =head1 REQUIRES
19              
20             Only core modules required
21              
22             =head1 DESCRIPTION
23              
24             Function library for interfacing with CryoTel Cryocontrollers
25              
26             =head1 AUTHOR/LICENSE
27              
28             Perl Module CryoTel::CryoCon - Function library for interfacing with CryoTel Cryocontrollers. Copyright (C) 2009 Stanford University, Authored by Sam Kerr kerr@cpan.org
29              
30             This program is free software; you can redistribute it and/or modify
31             it under the terms of the GNU General Public License as published by
32             the Free Software Foundation; either version 2 of the License, or
33             (at your option) any later version.
34              
35             This program is distributed in the hope that it will be useful,
36             but WITHOUT ANY WARRANTY; without even the implied warranty of
37             MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
38             GNU General Public License for more details.
39              
40             You should have received a copy of the GNU General Public License
41             along with this program; if not, write to the Free Software
42             Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
43              
44              
45             =head2 Functions
46              
47             1 Function and 4 hashes of functions (one for each channel) exported by default.
48              
49             getcc();
50             %CryoTelFunctionsA
51             %CryoTelFunctionsB
52             %CryoTelFunctionsC
53             %CryoTelFunctionsD
54              
55             Each hash contains a code reference to getcc with supplied arguments. 1 function currently 'getCurrentTemp'.
56              
57             &{$CryoTelFunctionsA{getCurrentTempA}};
58              
59              
60             =head3 getcc() - Send CryoCon a command as an argument
61              
62             $temp = getcc('input? a');
63              
64             =cut
65              
66              
67             our %CryoTelFunctionsA = (
68             getCurrentTemp => sub {return getcc('input? a')},
69            
70             );
71              
72             our %CryoTelFunctionsB = (
73             getCurrentTemp => sub {return getcc('input? b')},
74             );
75              
76             our %CryoTelFunctionsC = (
77             getCurrentTemp => sub {return getcc('input? c')},
78             );
79              
80             our %CryoTelFunctionsD = (
81             getCurrentTemp => sub {return getcc('input? d')},
82             );
83              
84             sub getcc{
85 0     0 1   my $arg = shift;
86 0 0         my $sock = IO::Socket::INET->new(PeerAddr => '192.168.0.5',
87             PeerPort => '5000',
88             Proto => 'tcp',
89             Type => SOCK_STREAM)
90             or
91             die "Could not open socket to CryoCon, $!\n";
92              
93 0           print $sock "$arg";
94              
95 0           my $line = <$sock>;
96 0           print "$line\n";
97 0           close($sock);
98             }
99              
100             __END__