Robotics
view release on metacpan or search on metacpan
lib/Robotics/Tecan/Gemini.pm view on Meta::CPAN
=item (Special method - Not normally used - Experimental)
Attempt to start the Windows GUI application associated with Tecan (such as
running "Gemini.exe"). Since this will occur under Win32, and there is no
mechanism for forking, this call will likely never return. Best not to
call this method if the Tecan application is already running: unexpected
Win32 results may occur.
This method should only be used when "Desktop" access to start the Tecan
application is unavailable (such as starting the service from a remote
machine over the network).
Usage, for Tecan:
Do query() first, to see if the robotics is "not started"; if it is not, use
this function to start Gemini, then query() again (the second time should find
the named pipe).
=cut
sub probe {
my $class = shift;
my %found;
=begin text
# Note: cygwin-perl cant
# access or test the named pipe. If attempting to open a
# nonexistant pipe with Win32::Pipe and Gemini is not running, then
# Win32::Pipe will create it as a new pipe, thus the perl process will
# hang at the next read waiting for input from no one.
# No good alternatives except to look for Gemini.exe in process
# list.
# Pipe name begins with \\ to assure Win32 local server context.
# It is created by Tecan 'Gemini' gui app at application start.
# Win32 Incompatibility note:
# On Win32, the named pipe string is accessed differently running under
# cygwin-perl or running under cmd.exe+ActivePerl. cygwin-perl will
# fail to open the pipe if open() or sysopen() is attempted.
# cygwin+activestate perl
# will succeed (because apparently it handles the network path properly).
# Win32 Named Pipe "filename" format is: '\\\\SERVER/pipe/filename'
# or use dot for local server '\\\\./pipe/filename'
# '\\\\./pipe/gemini' or any combination does not work under cygwin+perl.
# '\\\\./pipe/gemini' works under cmd.exe+ActivePerl or cygwin+ActivePerl.
=cut
if ($^O =~ m^cygwin^i || $^O =~ m^MSWin^i) {
# Found windows machine
if ($^O =~ m^MSWin^i) {
# Activestate perl
warn "Recommend using cygwin-perl not Activestate Perl for Tecan named pipe: not tested\n";
}
else {
# found cygwin-perl
}
# Assume running under cygwin+ActiveState Perl or cmd.exe+ActiveState Perl
# or cygwin+cygwin-perl
# Tested under: "This is perl, v5.10.0 built for MSWin32-x86-multi-thread"
# Tested under: "This is perl, v5.10.0 built for cygwin-thread-multi-64int"
$PIPENAME="\\\\.\\pipe\\gemini";
# For compatibility reasons, always use Win32::Pipe to access this pipe.
if (-d "c:/Program Files/Tecan/Gemini") {
# For Win32 support only
my $incompatibility = "Win32::Process::List";
eval "use $incompatibility";
# -- end Win32 modules
warn "Found Tecan Gemini, checking if running\n";
# Found Gemini application however it may not be running.
$found{"Tecan-Gemini"} = "not-started";
# Must search for Gemini as running process or attempting to
# open the pipe will permanentily hang the parent process.
# But, no way to do this in Win32.
my $obj = Win32::Process::List->new();
if ($obj->GetProcessPid("gemini")) {
$found{"Tecan-Gemini"} = "ok";
warn "Robotics.pm: Found Tecan Gemini, App is Running\n";
}
else {
warn "Robotics.pm: Found Tecan Gemini, App is NOT RUNNING\n";
}
# TODO Enhance this to return multiple machines with enumerated names
my $index_name = "0";
my $index_firmware = "1";
$found{"Tecan-Gemini"} .= ",Robotics::Tecan::Genesis";
$found{"Tecan-Gemini"} .= ",genesis$index_name,M$index_firmware";
}
}
else {
# not on Win32 so assume for simulation/test only
warn "!! Not on Win32 -- no local Tecan hardware is accessable\n";
$PIPENAME = '/tmp/__gemini';
unlink($PIPENAME); # XXX: revisit this
#$found{"Tecan-Gemini"} .= "network,Robotics::Tecan::Genesis,genesis0,M1";
}
return \%found;
}
sub BUILD {
my ($self) = shift;
my $incompatibility = "Win32::Pipe";
eval "use $incompatibility";
my $pipename = $PIPENAME;
if (!$pipename) {
die "no pipe name; notreached";
}
# Win32::Pipe constants:
# timeout = in millisec
# flags = PIPE_TYPE_BYTE(=0x0)
# state = PIPE_READMODE_BYTE(=0x0)
$| = 1;
my $timeout = 0; # NMPWAIT_NOWAIT;
my $flags = 0;
my $pipe;
( run in 2.396 seconds using v1.01-cache-2.11-cpan-0d23b851a93 )