1*cdf0e10cSrcweir#!/usr/bin/perl 2*cdf0e10cSrcweir######################################################################### 3*cdf0e10cSrcweir 4*cdf0e10cSrcweir #************************************************************************* 5*cdf0e10cSrcweir # 6*cdf0e10cSrcweir# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 7*cdf0e10cSrcweir# 8*cdf0e10cSrcweir# Copyright 2000, 2010 Oracle and/or its affiliates. 9*cdf0e10cSrcweir# 10*cdf0e10cSrcweir# OpenOffice.org - a multi-platform office productivity suite 11*cdf0e10cSrcweir# 12*cdf0e10cSrcweir# This file is part of OpenOffice.org. 13*cdf0e10cSrcweir# 14*cdf0e10cSrcweir# OpenOffice.org is free software: you can redistribute it and/or modify 15*cdf0e10cSrcweir# it under the terms of the GNU Lesser General Public License version 3 16*cdf0e10cSrcweir# only, as published by the Free Software Foundation. 17*cdf0e10cSrcweir# 18*cdf0e10cSrcweir# OpenOffice.org is distributed in the hope that it will be useful, 19*cdf0e10cSrcweir# but WITHOUT ANY WARRANTY; without even the implied warranty of 20*cdf0e10cSrcweir# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 21*cdf0e10cSrcweir# GNU Lesser General Public License version 3 for more details 22*cdf0e10cSrcweir# (a copy is included in the LICENSE file that accompanied this code). 23*cdf0e10cSrcweir# 24*cdf0e10cSrcweir# You should have received a copy of the GNU Lesser General Public License 25*cdf0e10cSrcweir# version 3 along with OpenOffice.org. If not, see 26*cdf0e10cSrcweir# <http://www.openoffice.org/license.html> 27*cdf0e10cSrcweir# for a copy of the LGPLv3 License. 28*cdf0e10cSrcweir# 29*cdf0e10cSrcweir #************************************************************************* 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir#################################################################### 32*cdf0e10cSrcweir# File Name: converterlib.pm 33*cdf0e10cSrcweir# Version : 1.0 34*cdf0e10cSrcweir# Project : XMerge 35*cdf0e10cSrcweir# Author : Brian Cameron 36*cdf0e10cSrcweir# Date : 5th Sept. 2001 37*cdf0e10cSrcweir# 38*cdf0e10cSrcweir# This script enters text at position x,y on screen. 39*cdf0e10cSrcweir# 40*cdf0e10cSrcweir# Parameter 41*cdf0e10cSrcweir# x-coordinate 42*cdf0e10cSrcweir# y-coordinate 43*cdf0e10cSrcweir# Text to enter 44*cdf0e10cSrcweir# 45*cdf0e10cSrcweir########################################################################## 46*cdf0e10cSrcweir 47*cdf0e10cSrcweiruse EmRPC; # EmRPC::OpenConnection, CloseConnection 48*cdf0e10cSrcweiruse EmFunctions; 49*cdf0e10cSrcweiruse EmUtils; 50*cdf0e10cSrcweir 51*cdf0e10cSrcweir# Set global_debug flag 52*cdf0e10cSrcweir# 53*cdf0e10cSrcweir$global_debug = $ENV{'ZENDEBUG'}; 54*cdf0e10cSrcweir#$em_script_home = "/export/home/test/qadir/bin"; 55*cdf0e10cSrcweir$em_script_home = $ENV{'EM_SCRIPT_HOME'}; 56*cdf0e10cSrcweir#$qa_script_home = "/export/home/test/qadir/qa-new/bin"; 57*cdf0e10cSrcweir $qa_script_home = $ENV{'QA_SCRIPT_HOME'}; 58*cdf0e10cSrcweir# 59*cdf0e10cSrcweir# CONVERT FUNCTIONS 60*cdf0e10cSrcweir# 61*cdf0e10cSrcweir 62*cdf0e10cSrcweir# convert_to_pdb 63*cdf0e10cSrcweir# directory - directory containing the xml-orig and pdb-orig 64*cdf0e10cSrcweir# subdirectories. 65*cdf0e10cSrcweir# file - file to convert 66*cdf0e10cSrcweir# extension - extension of file to convert (sxw or sxc) 67*cdf0e10cSrcweir# convert_to - what PDB format to convert into. 68*cdf0e10cSrcweir# 69*cdf0e10cSrcweir# Returns 0 if success, -1 otherwise. 70*cdf0e10cSrcweir# 71*cdf0e10cSrcweir# Converts file from XML to PDB 72*cdf0e10cSrcweir# 73*cdf0e10cSrcweirsub convert_to_pdb 74*cdf0e10cSrcweir{ 75*cdf0e10cSrcweir my $directory = $_[0]; 76*cdf0e10cSrcweir my $file = $_[1]; 77*cdf0e10cSrcweir my $extension = $_[2]; 78*cdf0e10cSrcweir my $convert_to = $_[3]; 79*cdf0e10cSrcweir my $pdb_directory = $_[4]; 80*cdf0e10cSrcweir my $rc = 0; 81*cdf0e10cSrcweir my $xmlfile = "$directory/$file.$extension"; 82*cdf0e10cSrcweir my $pdbdir = "$pdb_directory"; 83*cdf0e10cSrcweir 84*cdf0e10cSrcweir &enter_func("convert_to_pdb"); 85*cdf0e10cSrcweir 86*cdf0e10cSrcweir if (! -f "$xmlfile") 87*cdf0e10cSrcweir { 88*cdf0e10cSrcweir print "\nERROR, file $xmlfile does not exist\n"; 89*cdf0e10cSrcweir $rc = -1; 90*cdf0e10cSrcweir } 91*cdf0e10cSrcweir if (! -d "$pdbdir") 92*cdf0e10cSrcweir { 93*cdf0e10cSrcweir print "\nERROR, directory $directory/pdb-orig does not exist\n"; 94*cdf0e10cSrcweir $rc = -1; 95*cdf0e10cSrcweir } 96*cdf0e10cSrcweir 97*cdf0e10cSrcweir if ($rc != -1) 98*cdf0e10cSrcweir { 99*cdf0e10cSrcweir if ("$convert_to" eq "application/x-minicalc") 100*cdf0e10cSrcweir { 101*cdf0e10cSrcweir # Move all files over. 102*cdf0e10cSrcweir # 103*cdf0e10cSrcweir my $i = 1; 104*cdf0e10cSrcweir 105*cdf0e10cSrcweir while (-f "$pdbdir/$file-Sheet$i.pdb") 106*cdf0e10cSrcweir { 107*cdf0e10cSrcweir my $pdbfile = "$pdbdir/$file-Sheet$i.pdb"; 108*cdf0e10cSrcweir 109*cdf0e10cSrcweir print "\n"; 110*cdf0e10cSrcweir 111*cdf0e10cSrcweir if (-f "$pdbfile.old") 112*cdf0e10cSrcweir { 113*cdf0e10cSrcweir print "Removing $pdbfile.old\n"; 114*cdf0e10cSrcweir `/bin/rm -f $pdbfile.old`; 115*cdf0e10cSrcweir } 116*cdf0e10cSrcweir 117*cdf0e10cSrcweir print "Moving $pdbfile file to $pdbfile.old\n"; 118*cdf0e10cSrcweir `mv "$pdbfile" "$pdbfile.old"`; 119*cdf0e10cSrcweir 120*cdf0e10cSrcweir $i++; 121*cdf0e10cSrcweir } 122*cdf0e10cSrcweir } 123*cdf0e10cSrcweir else 124*cdf0e10cSrcweir { 125*cdf0e10cSrcweir if (-f "$pdbdir/$file.pdb") 126*cdf0e10cSrcweir { 127*cdf0e10cSrcweir print "\n"; 128*cdf0e10cSrcweir 129*cdf0e10cSrcweir if (-f "$pdbdir/$file.pdb.old") 130*cdf0e10cSrcweir { 131*cdf0e10cSrcweir print "Removing $pdbdir/$file.pdb.old\n"; 132*cdf0e10cSrcweir `/bin/rm -f $pdbdir/$file.pdb.old`; 133*cdf0e10cSrcweir } 134*cdf0e10cSrcweir 135*cdf0e10cSrcweir print "Moving $pdbdir/$file.pdb file to $pdbdir/$file.pdb.old\n"; 136*cdf0e10cSrcweir `mv "$pdbdir/$file.pdb" "$pdbdir/$file.pdb.old"` 137*cdf0e10cSrcweir } 138*cdf0e10cSrcweir } 139*cdf0e10cSrcweir 140*cdf0e10cSrcweir &start_rd($extension, $convert_to, $xmlfile, ""); 141*cdf0e10cSrcweir 142*cdf0e10cSrcweir if ("$convert_to" eq "application/x-minicalc") 143*cdf0e10cSrcweir { 144*cdf0e10cSrcweir # Must handle minicalc separately since it can 145*cdf0e10cSrcweir # convert to multiple files with this file name 146*cdf0e10cSrcweir # convention. 147*cdf0e10cSrcweir # 148*cdf0e10cSrcweir print "Moving $file-Sheet*.pdb files to $pdbdir\n"; 149*cdf0e10cSrcweir `mv $file-Sheet*.pdb $pdbdir`; 150*cdf0e10cSrcweir `chmod 666 $pdbdir/$file-*.pdb`; 151*cdf0e10cSrcweir } 152*cdf0e10cSrcweir else 153*cdf0e10cSrcweir { 154*cdf0e10cSrcweir print "Moving $file.pdb file to $pdbdir\n"; 155*cdf0e10cSrcweir `mv $file.pdb $pdbdir`; 156*cdf0e10cSrcweir `chmod 666 $pdbdir/$file.pdb`; 157*cdf0e10cSrcweir } 158*cdf0e10cSrcweir } 159*cdf0e10cSrcweir 160*cdf0e10cSrcweir &leave_func("convert_to_pdb"); 161*cdf0e10cSrcweir 162*cdf0e10cSrcweir return $rc; 163*cdf0e10cSrcweir} 164*cdf0e10cSrcweir 165*cdf0e10cSrcweir# convert_to_xml 166*cdf0e10cSrcweir# xmldir - directory to contain the xml output. 167*cdf0e10cSrcweir# xmlorigdir - directory to contain the xml input (used for merge) 168*cdf0e10cSrcweir# pdbfile - file to convert 169*cdf0e10cSrcweir# convert_from - what PDB format to convert from. 170*cdf0e10cSrcweir# extension - extension of file to convert (sxw or sxc) 171*cdf0e10cSrcweir# output - output filename to create 172*cdf0e10cSrcweir# merge_opt - 1 if convert and merge, 0 if convert only 173*cdf0e10cSrcweir# 174*cdf0e10cSrcweir# Returns 0 if success, -1 otherwise. 175*cdf0e10cSrcweir# 176*cdf0e10cSrcweir# Converts file from PDB to XML 177*cdf0e10cSrcweir# 178*cdf0e10cSrcweirsub convert_to_xml 179*cdf0e10cSrcweir{ 180*cdf0e10cSrcweir my $xmldir = $_[0]; 181*cdf0e10cSrcweir my $xmlorigdir = $_[1]; 182*cdf0e10cSrcweir my $pdbfile = $_[2]; 183*cdf0e10cSrcweir my $convert_from = $_[3]; 184*cdf0e10cSrcweir my $extension = $_[4]; 185*cdf0e10cSrcweir my $output = $_[5]; 186*cdf0e10cSrcweir my $merge_opt = $_[6]; 187*cdf0e10cSrcweir my $rc = 0; 188*cdf0e10cSrcweir 189*cdf0e10cSrcweir &enter_func("convert_to_xml"); 190*cdf0e10cSrcweir 191*cdf0e10cSrcweir my @args = split(/ /,$pdbfile); 192*cdf0e10cSrcweir 193*cdf0e10cSrcweir for ($i=0;$i <= $#args; $i++) 194*cdf0e10cSrcweir { 195*cdf0e10cSrcweir if (! -f "@args[$i]") 196*cdf0e10cSrcweir { 197*cdf0e10cSrcweir print "\nERROR, file $pdbfile does not exist\n"; 198*cdf0e10cSrcweir $rc = -1; 199*cdf0e10cSrcweir } 200*cdf0e10cSrcweir } 201*cdf0e10cSrcweir 202*cdf0e10cSrcweir if (! -f "$xmlorigdir/$output.$extension") 203*cdf0e10cSrcweir { 204*cdf0e10cSrcweir print "\nERROR, file $xmlorigdir/$output.$extension does not exist\n"; 205*cdf0e10cSrcweir $rc = -1; 206*cdf0e10cSrcweir } 207*cdf0e10cSrcweir if (! -d "$xmldir") 208*cdf0e10cSrcweir { 209*cdf0e10cSrcweir print "\nERROR, directory $xmlorigdir does not exist\n"; 210*cdf0e10cSrcweir $rc = -1; 211*cdf0e10cSrcweir } 212*cdf0e10cSrcweir if (! -d "$xmlorigdir") 213*cdf0e10cSrcweir { 214*cdf0e10cSrcweir print "\nERROR, directory $xmldir does not exist\n"; 215*cdf0e10cSrcweir $rc = -1; 216*cdf0e10cSrcweir } 217*cdf0e10cSrcweir 218*cdf0e10cSrcweir if ($rc != -1) 219*cdf0e10cSrcweir { 220*cdf0e10cSrcweir if ($merge_opt == 1) 221*cdf0e10cSrcweir { 222*cdf0e10cSrcweir print "Copying <$xmlorigdir/$output.$extension> to <$xmldir>\n"; 223*cdf0e10cSrcweir `cp $xmlorigdir/$output.$extension $xmldir/`; 224*cdf0e10cSrcweir 225*cdf0e10cSrcweir my $check_stamp = (stat("$xmldir/$output.$extension"))[9]; 226*cdf0e10cSrcweir 227*cdf0e10cSrcweir &start_rd($convert_from, $extension, $pdbfile, 228*cdf0e10cSrcweir "$xmldir/$output.$extension"); 229*cdf0e10cSrcweir 230*cdf0e10cSrcweir 231*cdf0e10cSrcweir # No need to move the file to the $xmldir since the merge 232*cdf0e10cSrcweir # argument specifies the output file. 233*cdf0e10cSrcweir 234*cdf0e10cSrcweir my $check_stamp_update = (stat("$xmldir/$output.$extension"))[9]; 235*cdf0e10cSrcweir if ($check_stamp eq $check_stamp_update) 236*cdf0e10cSrcweir { 237*cdf0e10cSrcweir print "\nERROR, Problem while merging <$xmldir/$output.$extension>\n"; 238*cdf0e10cSrcweir `mv $xmldir/$output.$extension $xmldir/$output.$extension.err`; 239*cdf0e10cSrcweir } 240*cdf0e10cSrcweir } 241*cdf0e10cSrcweir else 242*cdf0e10cSrcweir { 243*cdf0e10cSrcweir &start_rd($convert_from, $extension, $pdbfile, ""); 244*cdf0e10cSrcweir 245*cdf0e10cSrcweir print "Moving $output.$extension to $xmldir\n"; 246*cdf0e10cSrcweir `mv $output.$extension $xmldir`; 247*cdf0e10cSrcweir `chmod 666 $xmldir/$output.$extension`; 248*cdf0e10cSrcweir } 249*cdf0e10cSrcweir } 250*cdf0e10cSrcweir 251*cdf0e10cSrcweir &leave_func("convert_to_xml"); 252*cdf0e10cSrcweir 253*cdf0e10cSrcweir return $rc; 254*cdf0e10cSrcweir} 255*cdf0e10cSrcweir 256*cdf0e10cSrcweir# start_rd 257*cdf0e10cSrcweir# from - format to convert from 258*cdf0e10cSrcweir# to - format to convert to 259*cdf0e10cSrcweir# file - file to convert 260*cdf0e10cSrcweir# merge - merge filename ("" indicates convert-only with no merge) 261*cdf0e10cSrcweir# 262*cdf0e10cSrcweir# converts file from/to the specified formats. 263*cdf0e10cSrcweir# 264*cdf0e10cSrcweirsub start_rd 265*cdf0e10cSrcweir{ 266*cdf0e10cSrcweir my $from = $_[0]; 267*cdf0e10cSrcweir my $to = $_[1]; 268*cdf0e10cSrcweir my $file = $_[2]; 269*cdf0e10cSrcweir my $merge = $_[3]; 270*cdf0e10cSrcweir 271*cdf0e10cSrcweir print "\nConverting from $from to $to.\n"; 272*cdf0e10cSrcweir if ($global_debug) 273*cdf0e10cSrcweir { 274*cdf0e10cSrcweir &print_debug ("rd command is:\n"); 275*cdf0e10cSrcweir } 276*cdf0e10cSrcweir 277*cdf0e10cSrcweir if ($merge eq "") 278*cdf0e10cSrcweir { 279*cdf0e10cSrcweir &print_debug (" $em_script_home/rd -from $from -to $to $file\n"); 280*cdf0e10cSrcweir print "\nConverting from $from to $to with no merge.\n"; 281*cdf0e10cSrcweir `$em_script_home/rd -from $from -to $to $file`; 282*cdf0e10cSrcweir } 283*cdf0e10cSrcweir else 284*cdf0e10cSrcweir { 285*cdf0e10cSrcweir &print_debug (" $em_script_home/rd -from $from -to $to -merge $merge $file\n"); 286*cdf0e10cSrcweir print "\nConverting from $from to $to with merge.\n"; 287*cdf0e10cSrcweir `$em_script_home/rd -from $from -to $to -merge $merge $file`; 288*cdf0e10cSrcweir } 289*cdf0e10cSrcweir 290*cdf0e10cSrcweir print "Done converting.\n\n"; 291*cdf0e10cSrcweir} 292*cdf0e10cSrcweir 293*cdf0e10cSrcweir# 294*cdf0e10cSrcweir# POSE INTERACTION FUNCTIONS 295*cdf0e10cSrcweir# 296*cdf0e10cSrcweir 297*cdf0e10cSrcweir# open_connection 298*cdf0e10cSrcweir# display_debug - debug will be displayed if not 0 299*cdf0e10cSrcweir# 300*cdf0e10cSrcweir# Opens the connection to pose. 301*cdf0e10cSrcweir# 302*cdf0e10cSrcweirsub open_connection 303*cdf0e10cSrcweir{ 304*cdf0e10cSrcweir my $display_debug = $_[0]; 305*cdf0e10cSrcweir my $rc; 306*cdf0e10cSrcweir 307*cdf0e10cSrcweir EmRPC::OpenConnection(6415, "localhost"); 308*cdf0e10cSrcweir 309*cdf0e10cSrcweir if ($display_debug && $global_debug) 310*cdf0e10cSrcweir { 311*cdf0e10cSrcweir print "\nPose Connection Opened\n"; 312*cdf0e10cSrcweir } 313*cdf0e10cSrcweir} 314*cdf0e10cSrcweir 315*cdf0e10cSrcweir# close_connection 316*cdf0e10cSrcweir# display_debug - debug will be displayed if not 0 317*cdf0e10cSrcweir# 318*cdf0e10cSrcweir# Closes the connection to pose. 319*cdf0e10cSrcweir# 320*cdf0e10cSrcweirsub close_connection 321*cdf0e10cSrcweir{ 322*cdf0e10cSrcweir my $display_debug = $_[0]; 323*cdf0e10cSrcweir 324*cdf0e10cSrcweir EmRPC::CloseConnection(); 325*cdf0e10cSrcweir 326*cdf0e10cSrcweir if ($display_debug && $global_debug) 327*cdf0e10cSrcweir { 328*cdf0e10cSrcweir print "\nPose Connection Closed\n"; 329*cdf0e10cSrcweir } 330*cdf0e10cSrcweir} 331*cdf0e10cSrcweir 332*cdf0e10cSrcweir# start_pose 333*cdf0e10cSrcweir# pose_exe - name of pose executable. 334*cdf0e10cSrcweir# apps_load - The PRC files to load into pose, can be a comma 335*cdf0e10cSrcweir# separated list. 336*cdf0e10cSrcweir# run_prog - Program to run at startup. 337*cdf0e10cSrcweir# timeout - Timeout value to use when starting pose. 338*cdf0e10cSrcweir# 339*cdf0e10cSrcweir# Starts the Palm OS Emulator, loads PRC files, and starts 340*cdf0e10cSrcweir# a program. 341*cdf0e10cSrcweir# 342*cdf0e10cSrcweirsub start_pose 343*cdf0e10cSrcweir{ 344*cdf0e10cSrcweir my $pose_exe = $_[0]; 345*cdf0e10cSrcweir my $sessionfile = $ENV{'EM_SESSION_FILE'}; 346*cdf0e10cSrcweir my $romfile = $ENV{'EM_ROM_FILE'}; 347*cdf0e10cSrcweir my $apps_load = $_[1]; 348*cdf0e10cSrcweir my $run_prog = $_[2]; 349*cdf0e10cSrcweir my $timeout = $_[3]; 350*cdf0e10cSrcweir my $stay_in_loop = 1; 351*cdf0e10cSrcweir my $address; 352*cdf0e10cSrcweir my $title; 353*cdf0e10cSrcweir my $form; 354*cdf0e10cSrcweir my $label_id; 355*cdf0e10cSrcweir my $num_objects; 356*cdf0e10cSrcweir my $i; 357*cdf0e10cSrcweir my $ii; 358*cdf0e10cSrcweir my $rc = 1; 359*cdf0e10cSrcweir 360*cdf0e10cSrcweir my $pose_cmd = "$pose_exe "; 361*cdf0e10cSrcweir $pose_cmd .= " -psf $sessionfile "; 362*cdf0e10cSrcweir $pose_cmd .= "-load_apps $apps_load "; 363*cdf0e10cSrcweir $pose_cmd .= "-run_app $run_prog"; 364*cdf0e10cSrcweir 365*cdf0e10cSrcweir# It is more effective to use the -psf argument to 366*cdf0e10cSrcweir# set these values. 367*cdf0e10cSrcweir# 368*cdf0e10cSrcweir# $pose_cmd .= -rom $romfile "; 369*cdf0e10cSrcweir# $pose_cmd .= "-ram_size 8192 "; 370*cdf0e10cSrcweir# $pose_cmd .= "-device PalmVx "; 371*cdf0e10cSrcweir 372*cdf0e10cSrcweir &enter_func("start_pose"); 373*cdf0e10cSrcweir 374*cdf0e10cSrcweir if ($global_debug) 375*cdf0e10cSrcweir { 376*cdf0e10cSrcweir &print_debug("\n"); 377*cdf0e10cSrcweir &print_debug("pose command is:\n"); 378*cdf0e10cSrcweir &print_debug(" $pose_cmd\n"); 379*cdf0e10cSrcweir } 380*cdf0e10cSrcweir 381*cdf0e10cSrcweir print "\nLaunching pose...\n"; 382*cdf0e10cSrcweir system ("$pose_cmd &"); 383*cdf0e10cSrcweir 384*cdf0e10cSrcweir # Give time for pose to get started... 385*cdf0e10cSrcweir # 386*cdf0e10cSrcweir for ($i=0; $i < $timeout; $i++) 387*cdf0e10cSrcweir { 388*cdf0e10cSrcweir $tmp = $i + 1; 389*cdf0e10cSrcweir print "$tmp\n"; 390*cdf0e10cSrcweir 391*cdf0e10cSrcweir # Do not use pose_sleep here 392*cdf0e10cSrcweir # 393*cdf0e10cSrcweir sleep(1); 394*cdf0e10cSrcweir } 395*cdf0e10cSrcweir 396*cdf0e10cSrcweir # Verify pose started successfully, and fail otherwise... 397*cdf0e10cSrcweir # 398*cdf0e10cSrcweir $rc = &verify_pose(5); 399*cdf0e10cSrcweir if ($rc != 0) 400*cdf0e10cSrcweir { 401*cdf0e10cSrcweir $stay_in_loop = 0; 402*cdf0e10cSrcweir } 403*cdf0e10cSrcweir else 404*cdf0e10cSrcweir { 405*cdf0e10cSrcweir # Sleep before opening the connection again, after testing in 406*cdf0e10cSrcweir # the verify_pose function. 407*cdf0e10cSrcweir # 408*cdf0e10cSrcweir pose_sleep(2); 409*cdf0e10cSrcweir &open_connection(1); 410*cdf0e10cSrcweir print "\nChecking if the appropriate window is on screen...\n"; 411*cdf0e10cSrcweir } 412*cdf0e10cSrcweir 413*cdf0e10cSrcweir # Stop looping when the specified window has started. 414*cdf0e10cSrcweir # 415*cdf0e10cSrcweir for ($i=0; $i < $timeout && $stay_in_loop == 1; $i++) 416*cdf0e10cSrcweir { 417*cdf0e10cSrcweir $form = FrmGetActiveForm(); 418*cdf0e10cSrcweir $num_objects = FrmGetNumberOfObjects($form); 419*cdf0e10cSrcweir 420*cdf0e10cSrcweir for $ii (0..$num_objects - 1) 421*cdf0e10cSrcweir { 422*cdf0e10cSrcweir my ($object_type) = FrmGetObjectType($form, $ii); 423*cdf0e10cSrcweir 424*cdf0e10cSrcweir if ("$run_prog" eq "Quickword") 425*cdf0e10cSrcweir { 426*cdf0e10cSrcweir if ($object_type == frmTitleObj) 427*cdf0e10cSrcweir { 428*cdf0e10cSrcweir ($address, $title) = FrmGetTitle($form,); 429*cdf0e10cSrcweir 430*cdf0e10cSrcweir # Display count and title. 431*cdf0e10cSrcweir # 432*cdf0e10cSrcweir $tmp = $i + 1; 433*cdf0e10cSrcweir print "$tmp - title is $title\n"; 434*cdf0e10cSrcweir 435*cdf0e10cSrcweir if ("$title" eq "Quickword") 436*cdf0e10cSrcweir { 437*cdf0e10cSrcweir $stay_in_loop = 0; 438*cdf0e10cSrcweir $rc = 0; 439*cdf0e10cSrcweir last; 440*cdf0e10cSrcweir } 441*cdf0e10cSrcweir } 442*cdf0e10cSrcweir } 443*cdf0e10cSrcweir elsif ("$run_prog" eq "MiniCalc") 444*cdf0e10cSrcweir { 445*cdf0e10cSrcweir if ($object_type == frmLabelObj) 446*cdf0e10cSrcweir { 447*cdf0e10cSrcweir $label_id = FrmGetObjectId ($form, $ii); 448*cdf0e10cSrcweir ($address, $label) = FrmGetLabel($form, $label_id); 449*cdf0e10cSrcweir 450*cdf0e10cSrcweir # Display count and label. 451*cdf0e10cSrcweir # 452*cdf0e10cSrcweir $tmp = $i + 1; 453*cdf0e10cSrcweir print "$tmp - label is $label\n"; 454*cdf0e10cSrcweir if ("$label" =~ "Solutions In Hand") 455*cdf0e10cSrcweir { 456*cdf0e10cSrcweir $stay_in_loop = 0; 457*cdf0e10cSrcweir $rc = 0; 458*cdf0e10cSrcweir last; 459*cdf0e10cSrcweir } 460*cdf0e10cSrcweir } 461*cdf0e10cSrcweir } 462*cdf0e10cSrcweir } 463*cdf0e10cSrcweir 464*cdf0e10cSrcweir # Do not use pose_sleep here 465*cdf0e10cSrcweir # 466*cdf0e10cSrcweir sleep(1); 467*cdf0e10cSrcweir } 468*cdf0e10cSrcweir 469*cdf0e10cSrcweir # Do not use pose_sleep here 470*cdf0e10cSrcweir # 471*cdf0e10cSrcweir sleep(1); 472*cdf0e10cSrcweir 473*cdf0e10cSrcweir &leave_func("start_pose"); 474*cdf0e10cSrcweir return($rc); 475*cdf0e10cSrcweir} 476*cdf0e10cSrcweir 477*cdf0e10cSrcweir# kill_pose 478*cdf0e10cSrcweir# 479*cdf0e10cSrcweir# Kills all pose processes 480*cdf0e10cSrcweir# 481*cdf0e10cSrcweirsub kill_pose 482*cdf0e10cSrcweir{ 483*cdf0e10cSrcweir if ($global_debug) 484*cdf0e10cSrcweir { 485*cdf0e10cSrcweir print "Stopping pose process...\n"; 486*cdf0e10cSrcweir } 487*cdf0e10cSrcweir 488*cdf0e10cSrcweir `pkill pose`; 489*cdf0e10cSrcweir} 490*cdf0e10cSrcweir 491*cdf0e10cSrcweir# verify_pose 492*cdf0e10cSrcweir# timeout - timeout to wait for pose 493*cdf0e10cSrcweir# 494*cdf0e10cSrcweir# Tries to do a connect/close to Pose to see if 495*cdf0e10cSrcweir# it is working okay. 496*cdf0e10cSrcweir# 497*cdf0e10cSrcweirsub verify_pose 498*cdf0e10cSrcweir{ 499*cdf0e10cSrcweir my $timeout = $_[0]; 500*cdf0e10cSrcweir my $rc = 0; 501*cdf0e10cSrcweir 502*cdf0e10cSrcweir $rc = system("$em_script_home/verify_sane.pl $timeout"); 503*cdf0e10cSrcweir return $rc; 504*cdf0e10cSrcweir} 505*cdf0e10cSrcweir 506*cdf0e10cSrcweir# db_export 507*cdf0e10cSrcweir# dbname - Name of database to export 508*cdf0e10cSrcweir# 509*cdf0e10cSrcweir# Exports a palmdb file to /tmp 510*cdf0e10cSrcweir# 511*cdf0e10cSrcweirsub db_export 512*cdf0e10cSrcweir{ 513*cdf0e10cSrcweir my $dbname = $_[0]; 514*cdf0e10cSrcweir 515*cdf0e10cSrcweir &enter_func("db_export"); 516*cdf0e10cSrcweir print "\nExporting PDB file <$dbname> from pose\n"; 517*cdf0e10cSrcweir &pose_tap_pen(22, 20, 2); 518*cdf0e10cSrcweir &pose_tap_pen (15, 85, 2); 519*cdf0e10cSrcweir &enter_string($dbname, 1); 520*cdf0e10cSrcweir &pose_tap_pen (15, 126, 1); 521*cdf0e10cSrcweir &enter_string("/tmp/", 1); 522*cdf0e10cSrcweir &pose_tap_button("OK", 4); 523*cdf0e10cSrcweir &tap_applications(3); 524*cdf0e10cSrcweir print "Export of PDB file <$dbname> completed.\n"; 525*cdf0e10cSrcweir &leave_func("db_export"); 526*cdf0e10cSrcweir} 527*cdf0e10cSrcweir 528*cdf0e10cSrcweir# 529*cdf0e10cSrcweir# QUICKWORD SPECIFIC 530*cdf0e10cSrcweir# 531*cdf0e10cSrcweir 532*cdf0e10cSrcweir# start_quickword 533*cdf0e10cSrcweir# 534*cdf0e10cSrcweir# Assuming pose was launched with the -run_app flag to launch 535*cdf0e10cSrcweir# QuickWord on startup, this starts up QuickWord with the first 536*cdf0e10cSrcweir# file in the list and turns off write-protect. 537*cdf0e10cSrcweir# 538*cdf0e10cSrcweirsub start_quickword 539*cdf0e10cSrcweir{ 540*cdf0e10cSrcweir &enter_func("start_quickword"); 541*cdf0e10cSrcweir 542*cdf0e10cSrcweir # This will open the first file in the list. 543*cdf0e10cSrcweir # Assuming this will always be the case. 544*cdf0e10cSrcweir # 545*cdf0e10cSrcweir &pose_tap_pen(20, 18, 1); 546*cdf0e10cSrcweir &quickword_press_write_protect(); 547*cdf0e10cSrcweir 548*cdf0e10cSrcweir &leave_func("start_quickword"); 549*cdf0e10cSrcweir} 550*cdf0e10cSrcweir 551*cdf0e10cSrcweir# quickword_press_write_protect 552*cdf0e10cSrcweir# 553*cdf0e10cSrcweir# Useful function for pressing the write protect button 554*cdf0e10cSrcweir# to allow changes to be made. 555*cdf0e10cSrcweir# 556*cdf0e10cSrcweirsub quickword_press_write_protect 557*cdf0e10cSrcweir{ 558*cdf0e10cSrcweir &enter_func("quickword_press_write_protect"); 559*cdf0e10cSrcweir 560*cdf0e10cSrcweir my ($form) = FrmGetActiveForm(); 561*cdf0e10cSrcweir my ($num_objects) = FrmGetNumberOfObjects($form); 562*cdf0e10cSrcweir 563*cdf0e10cSrcweir for $ii (0..$num_objects - 1) 564*cdf0e10cSrcweir { 565*cdf0e10cSrcweir my ($object_type) = FrmGetObjectType($form, $ii); 566*cdf0e10cSrcweir 567*cdf0e10cSrcweir # The write protect button is the only frmGadgetObj 568*cdf0e10cSrcweir # on the QuickWord screen. 569*cdf0e10cSrcweir # 570*cdf0e10cSrcweir if ($object_type == frmGadgetObj) 571*cdf0e10cSrcweir { 572*cdf0e10cSrcweir my (%bounds) = FrmGetObjectBounds($form, $ii); 573*cdf0e10cSrcweir 574*cdf0e10cSrcweir if ($global_debug) 575*cdf0e10cSrcweir { 576*cdf0e10cSrcweir &print_debug(" Found QuickWord WriteProtect button\n"); 577*cdf0e10cSrcweir &print_debug(" left = $bounds{left}\n"); 578*cdf0e10cSrcweir &print_debug(" right = $bounds{right}\n"); 579*cdf0e10cSrcweir &print_debug(" top = $bounds{top}\n"); 580*cdf0e10cSrcweir &print_debug(" bottom = $bounds{bottom}\n"); 581*cdf0e10cSrcweir } 582*cdf0e10cSrcweir 583*cdf0e10cSrcweir # For some reason, the tapping of the write-protect button 584*cdf0e10cSrcweir # doesn't work unless you tap somewhere else first. 585*cdf0e10cSrcweir # 586*cdf0e10cSrcweir &pose_sleep(1); 587*cdf0e10cSrcweir &pose_tap_pen($bounds{left} + 2, $bounds{top} + 2, 1); 588*cdf0e10cSrcweir last; 589*cdf0e10cSrcweir } 590*cdf0e10cSrcweir } 591*cdf0e10cSrcweir 592*cdf0e10cSrcweir &leave_func("quickword_press_write_protect"); 593*cdf0e10cSrcweir} 594*cdf0e10cSrcweir 595*cdf0e10cSrcweir# quickword_find_replace 596*cdf0e10cSrcweir# from_string - string to replace 597*cdf0e10cSrcweir# to_string - string to replace with 598*cdf0e10cSrcweir# 599*cdf0e10cSrcweir# Uses QuickWord's find/replace utility to replace 600*cdf0e10cSrcweir# one string with another. 601*cdf0e10cSrcweir# 602*cdf0e10cSrcweirsub quickword_find_replace 603*cdf0e10cSrcweir{ 604*cdf0e10cSrcweir my $from_string = $_[0]; 605*cdf0e10cSrcweir my $to_string = $_[1]; 606*cdf0e10cSrcweir 607*cdf0e10cSrcweir &enter_func("quickword_find_replace"); 608*cdf0e10cSrcweir 609*cdf0e10cSrcweir # Move cursor to beginning... 610*cdf0e10cSrcweir # 611*cdf0e10cSrcweir &quickword_tap_at_top(1); 612*cdf0e10cSrcweir 613*cdf0e10cSrcweir # Move to "Find" field: 614*cdf0e10cSrcweir # Triple-click to highlight all the text in the field, 615*cdf0e10cSrcweir # so it is removed when the string is entered... 616*cdf0e10cSrcweir # 617*cdf0e10cSrcweir &pose_tap_button("Find", 2); 618*cdf0e10cSrcweir &pose_tap_pen(50, 100, 0); 619*cdf0e10cSrcweir &pose_tap_pen(50, 100, 0); 620*cdf0e10cSrcweir &pose_tap_pen(50, 100, 1); 621*cdf0e10cSrcweir 622*cdf0e10cSrcweir # sleep for 2 seconds to avoid double click after moving 623*cdf0e10cSrcweir # to replace field 624*cdf0e10cSrcweir # 625*cdf0e10cSrcweir &enter_string("$from_string", 2); 626*cdf0e10cSrcweir 627*cdf0e10cSrcweir # Move to "Replace" field: 628*cdf0e10cSrcweir # Triple-click to highlight all the text in the field, 629*cdf0e10cSrcweir # so it is removed when the string is entered... 630*cdf0e10cSrcweir # 631*cdf0e10cSrcweir &pose_tap_pen(50, 120, 0); 632*cdf0e10cSrcweir &pose_tap_pen(50, 120, 0); 633*cdf0e10cSrcweir &pose_tap_pen(50, 120, 1); 634*cdf0e10cSrcweir &enter_string("$to_string", 1); 635*cdf0e10cSrcweir 636*cdf0e10cSrcweir # Do find, then replace... 637*cdf0e10cSrcweir # 638*cdf0e10cSrcweir &pose_tap_button("Find", 1); 639*cdf0e10cSrcweir &pose_tap_button("Replace", 1); 640*cdf0e10cSrcweir &pose_tap_button("Cancel", 1); 641*cdf0e10cSrcweir 642*cdf0e10cSrcweir &leave_func("quickword_find_replace"); 643*cdf0e10cSrcweir} 644*cdf0e10cSrcweir 645*cdf0e10cSrcweir# quickword_tap_at_top 646*cdf0e10cSrcweir# secs - seconds to sleep after the tap 647*cdf0e10cSrcweir# 648*cdf0e10cSrcweir# Tap's at the top of the QuickWord document. 649*cdf0e10cSrcweir# 650*cdf0e10cSrcweirsub quickword_tap_at_top 651*cdf0e10cSrcweir{ 652*cdf0e10cSrcweir my $secs = $_[0]; 653*cdf0e10cSrcweir 654*cdf0e10cSrcweir &enter_func("quickword_tap_at_top"); 655*cdf0e10cSrcweir 656*cdf0e10cSrcweir # Sleep for a second to avoid any double-clicks 657*cdf0e10cSrcweir # from happening. 658*cdf0e10cSrcweir # 659*cdf0e10cSrcweir &pose_sleep(1); 660*cdf0e10cSrcweir 661*cdf0e10cSrcweir &pose_tap_pen(0, 15, $secs); 662*cdf0e10cSrcweir &leave_func("quickword_tap_at_top"); 663*cdf0e10cSrcweir} 664*cdf0e10cSrcweir 665*cdf0e10cSrcweir# Saves file and returns to the Application list. 666*cdf0e10cSrcweir# 667*cdf0e10cSrcweirsub close_quickword 668*cdf0e10cSrcweir{ 669*cdf0e10cSrcweir &enter_func("close_quickword"); 670*cdf0e10cSrcweir 671*cdf0e10cSrcweir &pose_tap_button("Done", 2); 672*cdf0e10cSrcweir &tap_applications(2); 673*cdf0e10cSrcweir 674*cdf0e10cSrcweir &leave_func("close_quickword"); 675*cdf0e10cSrcweir} 676*cdf0e10cSrcweir 677*cdf0e10cSrcweir# 678*cdf0e10cSrcweir# MINICALC SPECIFIC 679*cdf0e10cSrcweir# 680*cdf0e10cSrcweir 681*cdf0e10cSrcweir# start_minicalc 682*cdf0e10cSrcweir# 683*cdf0e10cSrcweir# Assuming pose was launched with the -run_app flag to launch 684*cdf0e10cSrcweir# Minicalc on startup, this starts up Minicalc with the first 685*cdf0e10cSrcweir# file in the list. 686*cdf0e10cSrcweir# 687*cdf0e10cSrcweirsub start_minicalc 688*cdf0e10cSrcweir{ 689*cdf0e10cSrcweir &enter_func("start_minicalc"); 690*cdf0e10cSrcweir &pose_tap_button("OK", 1); 691*cdf0e10cSrcweir 692*cdf0e10cSrcweir # For now just tap on the first spreadsheet. Add support 693*cdf0e10cSrcweir # for multiple sheets later. 694*cdf0e10cSrcweir # 695*cdf0e10cSrcweir &pose_tap_pen(10, 40, 5); 696*cdf0e10cSrcweir 697*cdf0e10cSrcweir &leave_func("start_minicalc"); 698*cdf0e10cSrcweir} 699*cdf0e10cSrcweir 700*cdf0e10cSrcweir# close_minicalc 701*cdf0e10cSrcweir# 702*cdf0e10cSrcweir# Returns to the Application list (no need to save). 703*cdf0e10cSrcweir# 704*cdf0e10cSrcweirsub close_minicalc 705*cdf0e10cSrcweir{ 706*cdf0e10cSrcweir &enter_func("close_minicalc"); 707*cdf0e10cSrcweir &tap_applications(3); 708*cdf0e10cSrcweir &leave_func("close_minicalc"); 709*cdf0e10cSrcweir} 710*cdf0e10cSrcweir 711*cdf0e10cSrcweir# minicalc_enter_cell 712*cdf0e10cSrcweir# row - row to enter value, starting with 1 713*cdf0e10cSrcweir# col - column to enter value, starting with 1 714*cdf0e10cSrcweir# val - value to enter 715*cdf0e10cSrcweir# 716*cdf0e10cSrcweir# Only valid for minicalc. 717*cdf0e10cSrcweir# 718*cdf0e10cSrcweir# This only works if the val passed in has a '\n' at the 719*cdf0e10cSrcweir# end. 720*cdf0e10cSrcweir# 721*cdf0e10cSrcweirsub minicalc_enter_cell 722*cdf0e10cSrcweir{ 723*cdf0e10cSrcweir my $row = $_[0]; 724*cdf0e10cSrcweir my $col = $_[1]; 725*cdf0e10cSrcweir my $val = $_[2]; 726*cdf0e10cSrcweir my $i; 727*cdf0e10cSrcweir my $j; 728*cdf0e10cSrcweir 729*cdf0e10cSrcweir &enter_func("minicalc_enter_cell"); 730*cdf0e10cSrcweir 731*cdf0e10cSrcweir if ($global_debug) 732*cdf0e10cSrcweir { 733*cdf0e10cSrcweir &print_debug (" tapping to cell row=<$row> col=<$col>\n"); 734*cdf0e10cSrcweir } 735*cdf0e10cSrcweir 736*cdf0e10cSrcweir # Tap pen on home button to start with row=1, col=A 737*cdf0e10cSrcweir # at top left. 738*cdf0e10cSrcweir # 739*cdf0e10cSrcweir pose_tap_pen(1, 1, 3); 740*cdf0e10cSrcweir 741*cdf0e10cSrcweir # Now the cell should be in the top-left corner, 742*cdf0e10cSrcweir # so click there. However we must first click 743*cdf0e10cSrcweir # in another cell or pose doesn't acknowledge the 744*cdf0e10cSrcweir # click. 745*cdf0e10cSrcweir # 746*cdf0e10cSrcweir # pose_tap_pen(120, 95, 1); 747*cdf0e10cSrcweir # pose_tap_pen(21, 9, 1); 748*cdf0e10cSrcweir 749*cdf0e10cSrcweir # Click the down button once for each row. 750*cdf0e10cSrcweir # Must pause 3 seconds each time, otherwise MiniCalc 751*cdf0e10cSrcweir # will not keep up. 752*cdf0e10cSrcweir # 753*cdf0e10cSrcweir for ($i=0; $i < $row; $i++) 754*cdf0e10cSrcweir { 755*cdf0e10cSrcweir if ($global_debug) 756*cdf0e10cSrcweir { 757*cdf0e10cSrcweir &print_debug (" Typing carrage return to go down\n"); 758*cdf0e10cSrcweir } 759*cdf0e10cSrcweir enter_string("\n", 1); 760*cdf0e10cSrcweir } 761*cdf0e10cSrcweir 762*cdf0e10cSrcweir # Click the right button once for each col. 763*cdf0e10cSrcweir # Must pause 3 seconds each time, otherwise MiniCalc 764*cdf0e10cSrcweir # will not keep up. 765*cdf0e10cSrcweir # 766*cdf0e10cSrcweir for ($i=0; $i < $col; $i++) 767*cdf0e10cSrcweir { 768*cdf0e10cSrcweir if ($global_debug) 769*cdf0e10cSrcweir { 770*cdf0e10cSrcweir &print_debug (" Typing tab to go right\n"); 771*cdf0e10cSrcweir } 772*cdf0e10cSrcweir 773*cdf0e10cSrcweir enter_string("\t", 1); 774*cdf0e10cSrcweir } 775*cdf0e10cSrcweir 776*cdf0e10cSrcweir # enter string 777*cdf0e10cSrcweir # 778*cdf0e10cSrcweir &enter_string($val, 1); 779*cdf0e10cSrcweir 780*cdf0e10cSrcweir &leave_func("minicalc_enter_cell"); 781*cdf0e10cSrcweir} 782*cdf0e10cSrcweir 783*cdf0e10cSrcweir# 784*cdf0e10cSrcweir# GENERIC UTILIIES (pose) 785*cdf0e10cSrcweir# 786*cdf0e10cSrcweir 787*cdf0e10cSrcweir# tap_applications 788*cdf0e10cSrcweir# secs - seconds to sleep after the tap 789*cdf0e10cSrcweir# 790*cdf0e10cSrcweir# taps pen on the Applications button. 791*cdf0e10cSrcweir# 792*cdf0e10cSrcweirsub tap_applications 793*cdf0e10cSrcweir{ 794*cdf0e10cSrcweir my $secs = $_[0]; 795*cdf0e10cSrcweir 796*cdf0e10cSrcweir &enter_func("tap_applications"); 797*cdf0e10cSrcweir 798*cdf0e10cSrcweir &pose_tap_pen(15, 170, 1); 799*cdf0e10cSrcweir &pose_tap_pen(155, 10, 1); 800*cdf0e10cSrcweir &pose_tap_pen(155, 10, $secs); 801*cdf0e10cSrcweir 802*cdf0e10cSrcweir &leave_func("tap_applications"); 803*cdf0e10cSrcweir} 804*cdf0e10cSrcweir 805*cdf0e10cSrcweir# enter_string_at_location 806*cdf0e10cSrcweir# x - x-location to enter string 807*cdf0e10cSrcweir# y - y-location to enter string 808*cdf0e10cSrcweir# in_string - string to enter 809*cdf0e10cSrcweir# application - appliation (QUICKWORD or MINICALC) 810*cdf0e10cSrcweir# 811*cdf0e10cSrcweir# Enters a string at the specified x,y position. 812*cdf0e10cSrcweir# 813*cdf0e10cSrcweirsub enter_string_at_location 814*cdf0e10cSrcweir{ 815*cdf0e10cSrcweir my $x_val = $_[0]; 816*cdf0e10cSrcweir my $y_val = $_[1]; 817*cdf0e10cSrcweir my $in_string = $_[2]; 818*cdf0e10cSrcweir my $application = $_[3]; 819*cdf0e10cSrcweir my $x; 820*cdf0e10cSrcweir my $y; 821*cdf0e10cSrcweir 822*cdf0e10cSrcweir &enter_func("enter_string_at_location"); 823*cdf0e10cSrcweir 824*cdf0e10cSrcweir $x = $x_val; 825*cdf0e10cSrcweir $y = $y_val; 826*cdf0e10cSrcweir 827*cdf0e10cSrcweir if ($application eq "QUICKWORD") 828*cdf0e10cSrcweir { 829*cdf0e10cSrcweir # Allow users to specify TOP/BOTTOM/LEFT/RIGHT 830*cdf0e10cSrcweir # for QuickWord. 831*cdf0e10cSrcweir # 832*cdf0e10cSrcweir if ($y_val eq "TOP") 833*cdf0e10cSrcweir { 834*cdf0e10cSrcweir if ($global_debug) 835*cdf0e10cSrcweir { 836*cdf0e10cSrcweir &print_debug(" Converting TOP to 15\n"); 837*cdf0e10cSrcweir } 838*cdf0e10cSrcweir 839*cdf0e10cSrcweir $y = 15; 840*cdf0e10cSrcweir } 841*cdf0e10cSrcweir if ($y_val eq "BOTTOM") 842*cdf0e10cSrcweir { 843*cdf0e10cSrcweir if ($global_debug) 844*cdf0e10cSrcweir { 845*cdf0e10cSrcweir &print_debug(" Converting BOTTOM to 144\n"); 846*cdf0e10cSrcweir } 847*cdf0e10cSrcweir 848*cdf0e10cSrcweir $y = 144; 849*cdf0e10cSrcweir } 850*cdf0e10cSrcweir if ($x_val eq "LEFT") 851*cdf0e10cSrcweir { 852*cdf0e10cSrcweir if ($global_debug) 853*cdf0e10cSrcweir { 854*cdf0e10cSrcweir &print_debug(" Converting LEFT to 0\n"); 855*cdf0e10cSrcweir } 856*cdf0e10cSrcweir 857*cdf0e10cSrcweir $x = 0; 858*cdf0e10cSrcweir } 859*cdf0e10cSrcweir if ($x_val eq "RIGHT") 860*cdf0e10cSrcweir { 861*cdf0e10cSrcweir if ($global_debug) 862*cdf0e10cSrcweir { 863*cdf0e10cSrcweir &print_debug(" Converting RIGHT to 152\n"); 864*cdf0e10cSrcweir } 865*cdf0e10cSrcweir 866*cdf0e10cSrcweir $x = 152; 867*cdf0e10cSrcweir } 868*cdf0e10cSrcweir } 869*cdf0e10cSrcweir 870*cdf0e10cSrcweir # Just to make sure the offset isn't outside the 871*cdf0e10cSrcweir # proper area. 872*cdf0e10cSrcweir # 873*cdf0e10cSrcweir if ($x >= 100) 874*cdf0e10cSrcweir { 875*cdf0e10cSrcweir $offset = -2; 876*cdf0e10cSrcweir } 877*cdf0e10cSrcweir else 878*cdf0e10cSrcweir { 879*cdf0e10cSrcweir $offset = 2; 880*cdf0e10cSrcweir } 881*cdf0e10cSrcweir 882*cdf0e10cSrcweir &off_tap_pen($x, $y, $offset); 883*cdf0e10cSrcweir &enter_string($in_string, 1); 884*cdf0e10cSrcweir 885*cdf0e10cSrcweir &leave_func("enter_string_at_location"); 886*cdf0e10cSrcweir} 887*cdf0e10cSrcweir 888*cdf0e10cSrcweir# off_tap_pen 889*cdf0e10cSrcweir# x - x-location to tap 890*cdf0e10cSrcweir# y - y-location to tap 891*cdf0e10cSrcweir# offset - x-offset to use for first tap. 892*cdf0e10cSrcweir# 893*cdf0e10cSrcweir# For some reason, pose does not register a single 894*cdf0e10cSrcweir# pen tap if the last single pen tap was also 895*cdf0e10cSrcweir# at the same x,y coordinate (even if the last tap 896*cdf0e10cSrcweir# was a while ago). So this function does two 897*cdf0e10cSrcweir# slightly different pen taps to ensure then pen 898*cdf0e10cSrcweir# tap happens. 899*cdf0e10cSrcweir# 900*cdf0e10cSrcweirsub off_tap_pen 901*cdf0e10cSrcweir{ 902*cdf0e10cSrcweir my $x = $_[0]; 903*cdf0e10cSrcweir my $y = $_[1]; 904*cdf0e10cSrcweir my $offset = $_[2]; 905*cdf0e10cSrcweir 906*cdf0e10cSrcweir &enter_func("off_tap_pen"); 907*cdf0e10cSrcweir 908*cdf0e10cSrcweir # sleep for 2 seconds to avoid double-click. 909*cdf0e10cSrcweir # 910*cdf0e10cSrcweir &pose_tap_pen_hard($x + $offset, $y, 2); 911*cdf0e10cSrcweir &pose_tap_pen_hard($x, $y, 1); 912*cdf0e10cSrcweir 913*cdf0e10cSrcweir &leave_func("off_tap_pen"); 914*cdf0e10cSrcweir} 915*cdf0e10cSrcweir 916*cdf0e10cSrcweir# enter_string 917*cdf0e10cSrcweir# in_string - string to enter 918*cdf0e10cSrcweir# secs - seconds to sleep after entering the string 919*cdf0e10cSrcweir# 920*cdf0e10cSrcweir# Enters a string 921*cdf0e10cSrcweir# 922*cdf0e10cSrcweirsub enter_string 923*cdf0e10cSrcweir{ 924*cdf0e10cSrcweir my $in_string = $_[0]; 925*cdf0e10cSrcweir my $secs = $_[1]; 926*cdf0e10cSrcweir my $j; 927*cdf0e10cSrcweir 928*cdf0e10cSrcweir &enter_func("enter_string"); 929*cdf0e10cSrcweir 930*cdf0e10cSrcweir if ($global_debug) 931*cdf0e10cSrcweir { 932*cdf0e10cSrcweir # Display in_string so \n and \t values 933*cdf0e10cSrcweir # show up as normal ASCII. 934*cdf0e10cSrcweir # 935*cdf0e10cSrcweir if ($in_string eq "\n") 936*cdf0e10cSrcweir { 937*cdf0e10cSrcweir &print_debug(" Entering string : <\\n>\n"); 938*cdf0e10cSrcweir } 939*cdf0e10cSrcweir elsif ($in_string eq "\t") 940*cdf0e10cSrcweir { 941*cdf0e10cSrcweir &print_debug(" Entering string : <\\t>\n"); 942*cdf0e10cSrcweir } 943*cdf0e10cSrcweir else 944*cdf0e10cSrcweir { 945*cdf0e10cSrcweir &print_debug(" Entering string : <$in_string>\n"); 946*cdf0e10cSrcweir } 947*cdf0e10cSrcweir } 948*cdf0e10cSrcweir 949*cdf0e10cSrcweir # Replace "\n" with real carrage returns. 950*cdf0e10cSrcweir # 951*cdf0e10cSrcweir my $string_val = $in_string; 952*cdf0e10cSrcweir $string_val =~ s#\\n#\n#g; 953*cdf0e10cSrcweir 954*cdf0e10cSrcweir # Replace "\t" with a real tab. 955*cdf0e10cSrcweir # 956*cdf0e10cSrcweir $string_val =~ s#\\t#\t#g; 957*cdf0e10cSrcweir 958*cdf0e10cSrcweir # Convert string to ASCII numeric values 959*cdf0e10cSrcweir # 960*cdf0e10cSrcweir my @array = unpack("C*", $string_val); 961*cdf0e10cSrcweir 962*cdf0e10cSrcweir # Enter string one key at a time. 963*cdf0e10cSrcweir # 964*cdf0e10cSrcweir for ($j=0; $j <= $#array; $j++) 965*cdf0e10cSrcweir { 966*cdf0e10cSrcweir $queue_size = EnterKey($array[$j], 0, 0); 967*cdf0e10cSrcweir } 968*cdf0e10cSrcweir 969*cdf0e10cSrcweir if ($secs > 0) 970*cdf0e10cSrcweir { 971*cdf0e10cSrcweir pose_sleep($secs); 972*cdf0e10cSrcweir } 973*cdf0e10cSrcweir 974*cdf0e10cSrcweir &leave_func("enter_string"); 975*cdf0e10cSrcweir} 976*cdf0e10cSrcweir 977*cdf0e10cSrcweir# 978*cdf0e10cSrcweir# GENERIC UTILIIES (non pose) 979*cdf0e10cSrcweir# 980*cdf0e10cSrcweir 981*cdf0e10cSrcweir# get_date_string 982*cdf0e10cSrcweir# 983*cdf0e10cSrcweir# Returns a timestampe string in yyyymmddHHMM format, where: 984*cdf0e10cSrcweir# yyyy = year 985*cdf0e10cSrcweir# mm = month 986*cdf0e10cSrcweir# dd = day 987*cdf0e10cSrcweir# HH = hour 988*cdf0e10cSrcweir# MM = minute 989*cdf0e10cSrcweir# 990*cdf0e10cSrcweir# This sort of datestamp is used to create the output directory 991*cdf0e10cSrcweir# names, so it used in various places. 992*cdf0e10cSrcweir# 993*cdf0e10cSrcweirsub get_date_string 994*cdf0e10cSrcweir{ 995*cdf0e10cSrcweir my $cur_secs = time; 996*cdf0e10cSrcweir my @lu = localtime $cur_secs; 997*cdf0e10cSrcweir my $lu_secs = $lu[1]; 998*cdf0e10cSrcweir my $lu_hours = $lu[2]; 999*cdf0e10cSrcweir my $lu_day = $lu[3]; 1000*cdf0e10cSrcweir my $lu_mon = $lu[4] + 1; 1001*cdf0e10cSrcweir my $lu_year = $lu[5] + 1900; 1002*cdf0e10cSrcweir my $lu_str = $lu_year; 1003*cdf0e10cSrcweir 1004*cdf0e10cSrcweir if ($lu_mon < 10) 1005*cdf0e10cSrcweir { 1006*cdf0e10cSrcweir $lu_str .= "0"; 1007*cdf0e10cSrcweir } 1008*cdf0e10cSrcweir $lu_str .= $lu_mon; 1009*cdf0e10cSrcweir 1010*cdf0e10cSrcweir if ($lu_day < 10) 1011*cdf0e10cSrcweir { 1012*cdf0e10cSrcweir $lu_str .= "0"; 1013*cdf0e10cSrcweir } 1014*cdf0e10cSrcweir $lu_str .= $lu_day; 1015*cdf0e10cSrcweir 1016*cdf0e10cSrcweir if ($lu_hours < 10) 1017*cdf0e10cSrcweir { 1018*cdf0e10cSrcweir $lu_str .= "0"; 1019*cdf0e10cSrcweir } 1020*cdf0e10cSrcweir $lu_str .= $lu_hours; 1021*cdf0e10cSrcweir 1022*cdf0e10cSrcweir if ($lu_secs < 10) 1023*cdf0e10cSrcweir { 1024*cdf0e10cSrcweir $lu_str .= "0"; 1025*cdf0e10cSrcweir } 1026*cdf0e10cSrcweir $lu_str .= $lu_secs; 1027*cdf0e10cSrcweir 1028*cdf0e10cSrcweir return $lu_str; 1029*cdf0e10cSrcweir} 1030*cdf0e10cSrcweir 1031*cdf0e10cSrcweir# 1032*cdf0e10cSrcweir# DEBUG FUNCTIONS - Wrapper functions 1033*cdf0e10cSrcweir# 1034*cdf0e10cSrcweir 1035*cdf0e10cSrcweir# pose_tap_pen 1036*cdf0e10cSrcweir# x - x-position of pen tap 1037*cdf0e10cSrcweir# y - y-position of pen tap 1038*cdf0e10cSrcweir# secs - seconds to sleep after the tap 1039*cdf0e10cSrcweir# 1040*cdf0e10cSrcweir# Taps pen at specified position and displays debug info 1041*cdf0e10cSrcweir# 1042*cdf0e10cSrcweirsub pose_tap_pen 1043*cdf0e10cSrcweir{ 1044*cdf0e10cSrcweir my $x = $_[0]; 1045*cdf0e10cSrcweir my $y = $_[1]; 1046*cdf0e10cSrcweir my $secs = $_[2]; 1047*cdf0e10cSrcweir 1048*cdf0e10cSrcweir if ($global_debug) 1049*cdf0e10cSrcweir { 1050*cdf0e10cSrcweir &print_debug(" Tapping pen at : $x,$y\n"); 1051*cdf0e10cSrcweir } 1052*cdf0e10cSrcweir 1053*cdf0e10cSrcweir TapPen($x, $y); 1054*cdf0e10cSrcweir 1055*cdf0e10cSrcweir if ($secs > 0) 1056*cdf0e10cSrcweir { 1057*cdf0e10cSrcweir pose_sleep($secs); 1058*cdf0e10cSrcweir } 1059*cdf0e10cSrcweir} 1060*cdf0e10cSrcweir 1061*cdf0e10cSrcweir# pose_tap_pen_hard 1062*cdf0e10cSrcweir# x - x-position of pen tap 1063*cdf0e10cSrcweir# y - y-position of pen tap 1064*cdf0e10cSrcweir# secs - seconds to sleep after the tap 1065*cdf0e10cSrcweir# 1066*cdf0e10cSrcweir# Taps pen at specified position and displays debug info 1067*cdf0e10cSrcweir# This function works more effectively in situations where 1068*cdf0e10cSrcweir# pose_tap_pen is flakey. This function is not good for 1069*cdf0e10cSrcweir# double/triple click situations since it is slow. 1070*cdf0e10cSrcweir# 1071*cdf0e10cSrcweirsub pose_tap_pen_hard 1072*cdf0e10cSrcweir{ 1073*cdf0e10cSrcweir my $x = $_[0]; 1074*cdf0e10cSrcweir my $y = $_[1]; 1075*cdf0e10cSrcweir my $secs = $_[2]; 1076*cdf0e10cSrcweir 1077*cdf0e10cSrcweir if ($global_debug) 1078*cdf0e10cSrcweir { 1079*cdf0e10cSrcweir &print_debug(" Tapping pen hard at : $x,$y\n"); 1080*cdf0e10cSrcweir } 1081*cdf0e10cSrcweir 1082*cdf0e10cSrcweir `$qa_script_home/tappen.pl $x $y`; 1083*cdf0e10cSrcweir 1084*cdf0e10cSrcweir if ($secs > 0) 1085*cdf0e10cSrcweir { 1086*cdf0e10cSrcweir pose_sleep($secs); 1087*cdf0e10cSrcweir } 1088*cdf0e10cSrcweir} 1089*cdf0e10cSrcweir 1090*cdf0e10cSrcweir# pose_tap_button 1091*cdf0e10cSrcweir# button - button to press 1092*cdf0e10cSrcweir# secs - seconds to sleep after the button press 1093*cdf0e10cSrcweir# 1094*cdf0e10cSrcweir# Presses specified button and displays debug info 1095*cdf0e10cSrcweir# 1096*cdf0e10cSrcweirsub pose_tap_button 1097*cdf0e10cSrcweir{ 1098*cdf0e10cSrcweir my $button = $_[0]; 1099*cdf0e10cSrcweir my $secs = $_[1]; 1100*cdf0e10cSrcweir 1101*cdf0e10cSrcweir if ($global_debug) 1102*cdf0e10cSrcweir { 1103*cdf0e10cSrcweir &print_debug(" Tapping button : $button\n"); 1104*cdf0e10cSrcweir } 1105*cdf0e10cSrcweir 1106*cdf0e10cSrcweir TapButton($button); 1107*cdf0e10cSrcweir 1108*cdf0e10cSrcweir if ($secs > 0) 1109*cdf0e10cSrcweir { 1110*cdf0e10cSrcweir pose_sleep($secs); 1111*cdf0e10cSrcweir } 1112*cdf0e10cSrcweir} 1113*cdf0e10cSrcweir 1114*cdf0e10cSrcweir# pose_sleep 1115*cdf0e10cSrcweir# secs - seconds to sleep 1116*cdf0e10cSrcweir# 1117*cdf0e10cSrcweir# Sleeps the specified amount of time and displays debug info 1118*cdf0e10cSrcweir# 1119*cdf0e10cSrcweirsub pose_sleep 1120*cdf0e10cSrcweir{ 1121*cdf0e10cSrcweir my $secs = $_[0]; 1122*cdf0e10cSrcweir 1123*cdf0e10cSrcweir if ($global_debug) 1124*cdf0e10cSrcweir { 1125*cdf0e10cSrcweir &print_debug(" Sleeping : $secs seconds\n"); 1126*cdf0e10cSrcweir } 1127*cdf0e10cSrcweir 1128*cdf0e10cSrcweir sleep($secs); 1129*cdf0e10cSrcweir} 1130*cdf0e10cSrcweir 1131*cdf0e10cSrcweir# enter_func 1132*cdf0e10cSrcweir# func - function name 1133*cdf0e10cSrcweir# 1134*cdf0e10cSrcweir# Displays debug info about entering specified function. 1135*cdf0e10cSrcweir# 1136*cdf0e10cSrcweirsub enter_func 1137*cdf0e10cSrcweir{ 1138*cdf0e10cSrcweir my $func = $_[0]; 1139*cdf0e10cSrcweir 1140*cdf0e10cSrcweir if ($global_debug) 1141*cdf0e10cSrcweir { 1142*cdf0e10cSrcweir &print_debug("Function enter : $func\n"); 1143*cdf0e10cSrcweir } 1144*cdf0e10cSrcweir} 1145*cdf0e10cSrcweir 1146*cdf0e10cSrcweir# leave_func 1147*cdf0e10cSrcweir# func - function name 1148*cdf0e10cSrcweir# 1149*cdf0e10cSrcweir# Displays debug info about leaving specified function. 1150*cdf0e10cSrcweir# 1151*cdf0e10cSrcweirsub leave_func 1152*cdf0e10cSrcweir{ 1153*cdf0e10cSrcweir my $func = $_[0]; 1154*cdf0e10cSrcweir 1155*cdf0e10cSrcweir if ($global_debug) 1156*cdf0e10cSrcweir { 1157*cdf0e10cSrcweir &print_debug("Function exit : $func\n"); 1158*cdf0e10cSrcweir } 1159*cdf0e10cSrcweir} 1160*cdf0e10cSrcweir 1161*cdf0e10cSrcweir# print_debug 1162*cdf0e10cSrcweir# string - string to print 1163*cdf0e10cSrcweir# 1164*cdf0e10cSrcweir# Displays debug message with a # at the beginning of the line. 1165*cdf0e10cSrcweir# 1166*cdf0e10cSrcweirsub print_debug 1167*cdf0e10cSrcweir{ 1168*cdf0e10cSrcweir my $string = $_[0]; 1169*cdf0e10cSrcweir 1170*cdf0e10cSrcweir print "# $string"; 1171*cdf0e10cSrcweir} 1172*cdf0e10cSrcweir 1173*cdf0e10cSrcweir1; 1174*cdf0e10cSrcweir 1175