Archive

Posts Tagged ‘automation’

Automated Linux GUI Applications using X11::GuiTest

November 3rd, 2015 No comments

Lately, I wanted to extract from application-embedded medical lexicon to construct a database for easy use of the lexicon data.  The application was ancient (1998) and Windows 32bit.  The application does not work in Windows version beyond Windows XP 32bit.  But fortunately, the application was very runnable in Ubuntu 14.04 over Wine layer.  A snapshot of the application is shown below:

app

There were several restrictions in the application, viz.,  “Select All” does not work, direct copy-paste does not work.  But the traversal of lookup items on the left pane could be fully done using keyboard keys.  So, the process for extracting every item is:

  1. TAB + TAB to go to the left pane containing the lookup items
  2. TAB to move to the right pane.
  3. Ctrl + Shift + End would select the entire text on the right pane.
  4. Ctrl + C copies the selected text to the clipboard
  5. Using “xclip”, it is possible to get the clipboard data into the driver script.
  6. Save the recovered clipboard content to a file.
  7. Move back to the left pane by Shift + TAB.
  8. Down arrow to move to the next item in the list.
  9. Goto Step 2, until exhaustion.

The ideal toolkit for this project is the X11::GuiTest library in Perl (https://metacpan.org/pod/X11::GUITest). The same toolkit is available in software repository, which could be installed using sudo apt-get install libx11-guitest-perl.  The codeblock that I’d used in Perl for getting is done is listed below.

# Start the application 
StartApp('/path/to/app');

# wait unconditionally for 5 seconds to allow the app to come to front.
WaitSeconds(5);

# move the cursor to the scroll list
SendKeys('{TAB 2}');
sleep(2);

for (my $i = 0; $i < 20; $i++ )
{
 # move the cursor to the right pane
 SendKeys('{TAB}');

 # select all
 SendKeys('^(+({END}))');

 # perform copy
 SendKeys('^(c)');
 
 # read the data from clipboard and print that in stdout
 my $clipboard = `xclip -selection clipboard -o`;

 if ( $clipboard ne $clipboard_prev ) { print '-'x 80; print "\n$i\t$clipboard\n" };
 $clipboard_prev = $clipboard;
 
 # move back to scroll list
 SendKeys('+({TAB})');

 # goto next item in the list.
 SendKeys('{DOWN}');
 WaitSeconds(0.7);
}

 

Another Automation Project

May 2nd, 2009 No comments

Powered by ScribeFire.

Timer Controller for our apartment water pump..

March 29th, 2009 14 comments
We have a 1.5HP compressor pump for pumping water from 350 feet deep to a 100 feet over head tank.  Since, we have water scarcity through out the year, we run the pump following a timing.  Typically in 24 hours, the pump runs for 6 hours in 1 hour slots spaced by 3 hours for water to accumulate in the borewell.

We have assigned the task of switching on and off the water pump to our security guards.  They are doing a good job in keep the pumps up and running, but sometime they either overrun or underrun the pumps.  Being the technical adviser of the apartment, I had decided to replace the security guards to an automatic timer controller.

I did some investigation about timer controllers via Internet and yellow pages but I was not very successful in finding a single stop solution.  There are many vendor who provide water level controllers, but not the timer controller.  So, I decided to go to Parry’s corner in search of an expert who can do the task for me.  I found a vendor in Thambu Chetty street who gave me the contact phone of a person who does erection of pump controllers.  I called the guy and he said he does not handle timer controller, but definitely give me a call back after consulting with his group.

I continued by search in the street and ended at “Switchgears India”, 149/2 Thambu Chetty Street, Chennai 1 and enquired about timer controllers.  He immediately showed me a product which he claimed to be useful for industrial timed switching purposes.  The guy should be Rajesh Bhandari (9840133670).  He showed me the product named “Frontier Timer TM-619H-2”, which had 8 On and Off timers.  There was another engineer who was sitting there helped me in configuring the timer.  When I tried setting the times, I found it very versatile and immediately useful.  They priced this product at Rs 600 without bill or warranty.  The shopkeeper promised that the product is doing well and he had sold over 1000 pieces.  This product also comes with an internal battery for keeping up with the LCD display and clock feature.

The product showed that it can switch on a 2HP motor directly, which I did not believe.  I guess the internal switching is by a TRIAC semiconductor which may burn out if connected directly to an Inductive load like water pump motor.   The shop keeper insisted me to get a Contactor which is typically a Electro Magnetic Relay to do the switching of the pump.  I asked him to offer a product and he gave me a contactor namely “IDEAL ID1-22 1a1b AC220V 50Hz”, which by the spec should be able to switch even a 5 HP motor.

The contactor that he gave is 3 phase relay, which I could use for a single phase motor.  I connected the L1 to supply and T1 to the motor with neutral short directly; L1 and T1 are in N/O connection.  Similarly the contactor had L2 -> T2 and L3 -> T3 for 3 phase switching. I connected the A1 and A2 of the contactor to the Output of the Timer.  The input of the Timer is connected to LIVE supply.  The contactor also provides a N/C connection which I did not use.

I programmed the timer for 6 time slots and connected the supply and load to the contactor.  It works super cool.

Powered by ScribeFire.