From 49e1be1a94ba3dc9d951056ebec2784286d3e928 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sat, 27 Jun 2009 00:27:12 +0100 Subject: [PATCH 1/1] Properly wait for /w output to appear --- pctb/TODO | 1 - pctb/convert.c | 2 +- pctb/convert.h | 3 ++- pctb/pages.c | 30 ++++++++++++------------------ pctb/structure.c | 32 +++++++++++++++++--------------- 5 files changed, 32 insertions(+), 36 deletions(-) diff --git a/pctb/TODO b/pctb/TODO index b51ee69..020b4c9 100644 --- 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 diff --git a/pctb/convert.c b/pctb/convert.c index c79477f..3bc7554 100644 --- a/pctb/convert.c +++ b/pctb/convert.c @@ -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); } diff --git a/pctb/convert.h b/pctb/convert.h index d38c38e..0abdf93 100644 --- a/pctb/convert.h +++ b/pctb/convert.h @@ -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); diff --git a/pctb/pages.c b/pctb/pages.c index 80f176a..a87b021 100644 --- a/pctb/pages.c +++ b/pctb/pages.c @@ -513,28 +513,18 @@ static void prepare_ypp_client(void) { raise_and_get_details(); wait_for_stability(¤t,0,0, "checking current YPP client screen..."); -#if 0 -timestamp(); -snapshot(¤t); -snapshot(¤t); -snapshot(¤t); -snapshot(¤t); -snapshot(¤t); -snapshot(¤t); -snapshot(¤t); -snapshot(¤t); -snapshot(¤t); -snapshot(¤t); -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(¤t); - progress("requesting status information..."); + wait_for_stability(¤t,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(¤t); + free_snapshot(&status); } void take_screenshots(void) { diff --git a/pctb/structure.c b/pctb/structure.c index 6ccbb5e..2dc98d1 100644 --- a/pctb/structure.c +++ b/pctb/structure.c @@ -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"); -- 2.30.2