chiark / gitweb /
Properly wait for /w output to appear
authorIan Jackson <ian@liberator.relativity.greenend.org.uk>
Fri, 26 Jun 2009 23:27:12 +0000 (00:27 +0100)
committerIan Jackson <ian@liberator.relativity.greenend.org.uk>
Fri, 26 Jun 2009 23:27:12 +0000 (00:27 +0100)
pctb/TODO
pctb/convert.c
pctb/convert.h
pctb/pages.c
pctb/structure.c

index b51ee694ee75381cdfdd87d5362ae89ce784693c..020b4c9fce8ecf3ef2a0a929ee11782577f0e112 100644 (file)
--- a/pctb/TODO
+++ b/pctb/TODO
@@ -1,4 +1,3 @@
-fix delay thing when looking for answer from /w
 write real uploader
 test real uploader
 speed it up
index c79477f80394810b5ead5abe7644500379693945..3bc7554525e9299968c26196bb19ad1f23b420d8 100644 (file)
@@ -292,7 +292,7 @@ int main(int argc, char **argv) {
   }
   if (o_mode & mf_analyse) {
     if (o_flags & ff_needisland) {
-      find_islandname();
+      find_islandname(page0_rgbimage);
       if (o_flags & ff_printisland)
        printf("%s, %s\n", archipelago, island);
     }
index d38c38efab83362a3ec7cb22e30dcc8539565cfb..0abdf93c5c48e5ee986a1b50cec5fef03963b26e 100644 (file)
@@ -60,8 +60,9 @@ RgbImage *alloc_rgb_image(int w, int h);
 /*----- from structure.c -----*/
 
 void find_structure(const CanonImage *im, int *max_relevant_y_r);
+Rect find_sunshine_widget(void);
 
-void find_islandname(void);
+void find_islandname(RgbImage *ri);
 void check_correct_commodities(void);
 void read_screenshots(void);
 void read_one_screenshot(void);
index 80f176ad567da72d6e87e6bda2b3aaba0ac0a714..a87b0214753316fe293be0e52712a4a14cf0a9a9 100644 (file)
@@ -513,28 +513,18 @@ static void prepare_ypp_client(void) {
   raise_and_get_details();
   wait_for_stability(&current,0,0, "checking current YPP client screen...");
 
-#if 0
-timestamp();
-snapshot(&current);
-snapshot(&current);
-snapshot(&current);
-snapshot(&current);
-snapshot(&current);
-snapshot(&current);
-snapshot(&current);
-snapshot(&current);
-snapshot(&current);
-snapshot(&current);
-timestamp();
-#endif
-
   test= convert_page(current, 0);
   find_structure(test, &max_relevant_y);
   check_correct_commodities();
+  Rect sunshine= find_sunshine_widget();
+
+  progress("poking client...");
+  mouse_1_updown((sunshine.tl.x   + sunshine.br.x) / 2,
+                (sunshine.tl.y*9 + sunshine.br.y) / 10);
+
   free(test);
-  free_snapshot(&current);
 
-  progress("requesting status information...");
+  wait_for_stability(&current,0,0, "checking basic YPP client screen...");
   mouse_1_updown(250, wheight-10);
   mouse_1_updown_here();
   mouse_1_updown_here();
@@ -544,7 +534,11 @@ timestamp();
   send_key(XK_w);
   send_key(XK_Return);
   sync_after_input();
-  sysassert(! usleep(1000000) );
+
+  Snapshot *status=0;
+  wait_for_stability(&status,current,0, "awaiting status information...");
+  free_snapshot(&current);
+  free_snapshot(&status);
 }
 
 void take_screenshots(void) {
index 6ccbb5e76b217518c54b7dcd66c84cb66e1554c4..2dc98d1c77a1590e0ae8d91e78eed19d4cbf90d0 100644 (file)
@@ -525,23 +525,9 @@ void analyse(FILE *tsv_output) {
 
 DEBUG_DEFINE_SOME_DEBUGF(structcolon,colondebugf)
 
-void find_islandname(void) {
+Rect find_sunshine_widget(void) {
   Rect sunshiner;
-  char sunshine[MAXIMGIDENT], archisland[MAXIMGIDENT];
 
-  RgbImage *ri= alloc_rgb_image(page0_rgbimage->w, page0_rgbimage->h);
-  const unsigned char *srcp;
-  unsigned char *destp, *endp;
-  for (srcp=page0_rgbimage->data, destp=ri->data,
-        endp= ri->data + 3 * ri->w * ri->h;
-       destp < endp;
-       srcp++, destp++) {
-    unsigned char c= *srcp & 0xf0;
-    *destp= c | (c>>4);
-  }
-
-  cim= page_images[0];
-  
   sunshiner.tl.x= cim->w - 1034 +  885;
   sunshiner.br.x= cim->w - 1034 + 1020;
   sunshiner.tl.y= 227;
@@ -557,6 +543,22 @@ void find_islandname(void) {
   ADJUST_BOX(sunshiner,"o",20, (cim->w - 1034 + 700), MUST, tl,x,-1);
   ADJUST_BOX(sunshiner,"o",20,  cim->w,               MUST, br,x,+1);
   debug_rect("sunshiner",1, sunshiner);
+  return sunshiner;
+}
+
+void find_islandname(RgbImage *ri) {
+  Rect sunshiner= find_sunshine_widget();
+  char sunshine[MAXIMGIDENT], archisland[MAXIMGIDENT];
+
+  const unsigned char *srcp;
+  unsigned char *destp, *endp;
+  for (srcp=page0_rgbimage->data, destp=ri->data,
+        endp= ri->data + 3 * ri->w * ri->h;
+       destp < endp;
+       srcp++, destp++) {
+    unsigned char c= *srcp & 0xf0;
+    *destp= c | (c>>4);
+  }
 
   identify_rgbimage(ri, sunshiner, sunshine, "sunshine widget");