From 27c4fa9943f43629d7a0233652fd463c79b06c4f Mon Sep 17 00:00:00 2001 From: David Anderson Date: Wed, 29 Jan 2003 23:03:19 +0000 Subject: [PATCH] countries, graphics svn path=/trunk/boinc/; revision=846 --- api/Makefile.in | 2 +- api/graphics_data.C | 58 ++++++++++++++++++++++++++++++++ api/graphics_data.h | 80 ++++++++++++++++++++++++++++++++++++++++++++ checkin_notes | 14 ++++++++ doc/index.html | 1 + lib/countries.C | 40 +++++++++++----------- sched/Makefile.in | 7 +++- sched/db_dump.C | 81 +++++++++++++++++++++++++++++++++++++++++++++ todo | 4 +++ 9 files changed, 265 insertions(+), 22 deletions(-) create mode 100644 api/graphics_data.C create mode 100644 api/graphics_data.h create mode 100644 sched/db_dump.C diff --git a/api/Makefile.in b/api/Makefile.in index ee25296684..c64403d6e5 100644 --- a/api/Makefile.in +++ b/api/Makefile.in @@ -18,7 +18,7 @@ CLIBS = @LIBS@ PROGS = api_app api_test #all: $(PROGS) -all: mfile.o boinc_api.o graphics_api.o +all: mfile.o boinc_api.o graphics_api.o graphics_data.o APP_OBJS = \ api_app.o \ diff --git a/api/graphics_data.C b/api/graphics_data.C new file mode 100644 index 0000000000..d7c59c6cfa --- /dev/null +++ b/api/graphics_data.C @@ -0,0 +1,58 @@ +#include "graphics_data.h" + +void GRAPHICS_DOUBLE_BUFFER::init(GRAPHICS_BUFFER* _b1, GRAPHICS_BUFFER* _b2) { + b1 = _b1; + b2 = _b2; +} + +GRAPHICS_BUFFER* GRAPHICS_DOUBLE_BUFFER::get_buffer(int state) { + if (b1->state == state) return b1; + if (b2->state == state) return b2; + return 0; +} + +GRAPHICS_BUFFER* GRAPHICS_DOUBLE_BUFFER::other_buffer(GRAPHICS_BUFFER* b) { + if (b == b1) return b2; + if (b == b2) return b1; + return 0; +} + +GRAPHICS_BUFFER* GRAPHICS_DOUBLE_BUFFER::get_render_buffer() { + GRAPHICS_BUFFER* b, *other; + + b = get_buffer(GB_STATE_RENDERING); + if (!b) b = get_buffer(GB_STATE_RENDERED); + if (b) { + if (b->state == GB_STATE_RENDERED) { + other = get_buffer(GB_STATE_GENERATED); + if (other) { + b->clear(); + b->state = GB_STATE_IDLE; + b = other; + b->state = GB_STATE_RENDERING; + } + } + } + return b; +} + +void GRAPHICS_DOUBLE_BUFFER::render_done(GRAPHICS_BUFFER* b) { + b->state = GB_STATE_RENDERED; +} + +GRAPHICS_BUFFER* GRAPHICS_DOUBLE_BUFFER::get_generate_buffer(bool first) { + GRAPHICS_BUFFER* b; + + b = get_buffer(GB_STATE_GENERATING); + if (!b && first) { + b = get_buffer(GB_STATE_IDLE); + if (b) { + b->state = GB_STATE_GENERATING; + } + } + return b; +} + +void GRAPHICS_DOUBLE_BUFFER::generate_done(GRAPHICS_BUFFER* b) { + b->state = GB_STATE_GENERATED; +} diff --git a/api/graphics_data.h b/api/graphics_data.h new file mode 100644 index 0000000000..0b3154730f --- /dev/null +++ b/api/graphics_data.h @@ -0,0 +1,80 @@ +// The contents of this file are subject to the Mozilla Public License +// Version 1.0 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.mozilla.org/MPL/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations +// under the License. +// +// The Original Code is the Berkeley Open Infrastructure for Network Computing. +// +// The Initial Developer of the Original Code is the SETI@home project. +// Portions created by the SETI@home project are Copyright (C) 2002 +// University of California at Berkeley. All Rights Reserved. +// +// Contributor(s): +// + +// The class GRAPHICS_DOUBLE_BUFFER provides a handy mechanism +// for synchronizing the generation of graphics information +// (done by the "science thread") +// with the graphics rendering (done by the "GUI thread", +// which periodically calls the application-supplied render() function) +// +// We assume that graphics info is generated incrementally +// and displayed incrementally. +// The scheme handles mismatches between generation and rendering rates: +// - if generation is faster than display, data cycles will be skipped +// - if display is faster than generation, the display will "linger" +// on a cycle until the next cycle is available in its entirety. +// +// Here's what the application programmer does: +// - subclass GRAPHICS_BUFFER, adding your application-specific data +// - declare a GRAPHICS_DOUBLE_BUFFER object (call it gdb), +// initializing it with pointers to two GRAPHICS_BUFFER structures. +// - when the science thread wants to add an increment of data, +// it calls gdb->get_generate_buffer(first) +// ("first" indicates whether this is the first data increment of a cycle). +// If this returns nonzero, it adds data to the buffer. +// If this addition causes it to be full, it calls gdb->generate_done(); +// - render() calls gdb->get_render_buffer(). +// If this returns nonzero, it displays some or all the data. +// If this completes the display of the data, it calls gdb->render_done(). + +// Here's how it works: +// There are two buffers, each with a "state" (see below). +// In a given state, only one thread can access the data or change the state. +// +#define GB_STATE_IDLE 0 +#define GB_STATE_GENERATING 1 +#define GB_STATE_GENERATED 2 +#define GB_STATE_RENDERING 3 +#define GB_STATE_RENDERED 4 + +// subclass this for your applications +// +class GRAPHICS_BUFFER { +public: + virtual void clear(); + int state; +}; + +class GRAPHICS_DOUBLE_BUFFER { + GRAPHICS_BUFFER* b1, *b2; + GRAPHICS_BUFFER* get_buffer(int state); + GRAPHICS_BUFFER* other_buffer(GRAPHICS_BUFFER*); +public: + void init(GRAPHICS_BUFFER*, GRAPHICS_BUFFER*); + + // the following called by app's render() + // + GRAPHICS_BUFFER* get_render_buffer(); + void render_done(GRAPHICS_BUFFER*); + + // the following called by app's science thread + // + GRAPHICS_BUFFER* get_generate_buffer(bool first); + void generate_done(GRAPHICS_BUFFER*); +}; diff --git a/checkin_notes b/checkin_notes index 0060380c98..e5a2cceff4 100755 --- a/checkin_notes +++ b/checkin_notes @@ -3029,3 +3029,17 @@ David Jan 22 2003 tools/ backend_lib.C create_work.C + +David Jan 29 2003 + - updated country-name list according to CIA site + - added program to generate XML stats files + - added classes to assist double-buffered graphics info for applications + + api/ + graphics_data.C,h (new) + Makefile.in + lib/ + countries.C + sched/ + db_dump.C (new) + Makefile.in diff --git a/doc/index.html b/doc/index.html index b1f85f8559..401ddcac27 100644 --- a/doc/index.html +++ b/doc/index.html @@ -51,6 +51,7 @@ Help debug and enhance the BOINC software. Non-English pages about BOINC:
    +Chinese French German Russian diff --git a/lib/countries.C b/lib/countries.C index 467965c3e8..7f0d04ed20 100644 --- a/lib/countries.C +++ b/lib/countries.C @@ -20,7 +20,7 @@ char *countries[NUM_COUNTRIES] = { "Australia", "Austria", "Azerbaijan", - "Bahamas", + "Bahamas, The", "Bahrain", "Bangladesh", "Barbados", @@ -35,7 +35,7 @@ char *countries[NUM_COUNTRIES] = { "Botswana", "Brazil", "British Virgin Islands", - "Brunei Darussalam", + "Brunei", "Bulgaria", "Burkina Faso", "Burundi", @@ -51,7 +51,8 @@ char *countries[NUM_COUNTRIES] = { "China", "Colombia", "Comoros", - "Congo", + "Congo, Democratic Republic of the", + "Congo, Republic of the", "Cook Islands", "Costa Rica", "Cote d'Ivoire", @@ -59,8 +60,6 @@ char *countries[NUM_COUNTRIES] = { "Cuba", "Cyprus", "Czech Republic", - "Democratic People's Republic of Korea", - "Democratic Republic of the Congo", "Denmark", "Djibouti", "Dominica", @@ -73,15 +72,15 @@ char *countries[NUM_COUNTRIES] = { "Eritrea", "Estonia", "Ethiopia", - "Faeroe Islands", "Falkland Islands", + "Faroe Islands", "Fiji", "Finland", "France", "French Guiana", "French Polynesia", "Gabon", - "Gambia", + "Gambia, The", "Gaza Strip", "Georgia", "Germany", @@ -98,6 +97,7 @@ char *countries[NUM_COUNTRIES] = { "Guyana", "Haiti", "Honduras", + "Hong Kong", "Hungary", "Iceland", "India", @@ -105,13 +105,14 @@ char *countries[NUM_COUNTRIES] = { "Iran", "Iraq", "Ireland", - "Isle of Man", "Israel", "Italy", "Jamaica", "Japan", "Jordan", - "Kazakstan", + "Kazakhstan", + "Korea, North", + "Korea, South", "Kenya", "Kiribati", "Kuwait", @@ -126,7 +127,7 @@ char *countries[NUM_COUNTRIES] = { "Lithuania", "Luxembourg", "Macau", - "Macedonia", + "Macedonia, The Former Yugoslav Republic of", "Madagascar", "Malawi", "Malaysia", @@ -138,12 +139,12 @@ char *countries[NUM_COUNTRIES] = { "Mauritania", "Mexico", "Micronesia", + "Moldova", "Monaco", "Mongolia", "Montserrat", "Morocco", "Mozambique", - "Myanmar", "Namibia", "Nauru", "Nepal", @@ -170,16 +171,14 @@ char *countries[NUM_COUNTRIES] = { "Portugal", "Puerto Rico", "Qatar", - "Republic of Korea", - "Republic of Moldova", "Reunion", "Romania", - "Russian Federation", + "Russia", "Rwanda", "Saint Kitts and Nevis", "Saint Lucia", "Saint Pierre and Miquelon", - "Saint Vincent and Grenadines", + "Saint Vincent and the Grenadines", "Samoa", "San Marino", "Sao Tome and Principe", @@ -200,9 +199,10 @@ char *countries[NUM_COUNTRIES] = { "Swaziland", "Sweden", "Switzerland", - "Syrian Arab Republic", + "Syria", "Taiwan", "Tajikistan", + "Tanzania", "Thailand", "Togo", "Tokelau", @@ -217,14 +217,14 @@ char *countries[NUM_COUNTRIES] = { "Ukraine", "United Arab Emirates", "United Kingdom", - "United Republic of Tanzania", - "United States Virgin Islands", "Uruguay", "Uzbekistan", "Vanuatu", "Venezuela", - "Viet Nam", - "Wallis and Futuna Islands", + "Vietnam", + "Virgin Islands", + "Wallis and Futuna", + "West Bank", "Western Sahara", "Yemen", "Yugoslavia", diff --git a/sched/Makefile.in b/sched/Makefile.in index 797f4252c4..ad94c66cfa 100644 --- a/sched/Makefile.in +++ b/sched/Makefile.in @@ -18,7 +18,7 @@ CC = g++ $(CFLAGS) CLIBS = @LIBS@ -PROGS = cgi feeder show_shmem file_upload_handler validate_test make_work result_retry file_deleter assimilator +PROGS = cgi feeder show_shmem file_upload_handler validate_test make_work result_retry file_deleter assimilator db_dump all: $(PROGS) @@ -109,6 +109,11 @@ RESULT_RETRY_OBJS = \ ../tools/process_result_template.o \ ../RSAEuro/source/rsaeuro.a +DB_DUMP_OBJS = \ + ../db/db_mysql.fcgi.o \ + ../db/mysql_util.fcgi.o \ + db_dump.o + FCGI_OBJS = \ handle_request.fcgi.o \ main.fcgi.o \ diff --git a/sched/db_dump.C b/sched/db_dump.C new file mode 100644 index 0000000000..827438578b --- /dev/null +++ b/sched/db_dump.C @@ -0,0 +1,81 @@ +// The contents of this file are subject to the Mozilla Public License +// Version 1.0 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://www.mozilla.org/MPL/ +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations +// under the License. +// +// The Original Code is the Berkeley Open Infrastructure for Network Computing. +// +// The Initial Developer of the Original Code is the SETI@home project. +// Portions created by the SETI@home project are Copyright (C) 2002 +// University of California at Berkeley. All Rights Reserved. +// +// Contributor(s): +// + +// db_dump: dump parts of database in XML form + +// files: +// +// team_totalcredit_N.xml N = 0, 1, ... +// team_avgcredit_N.xml N = 0, 1, ... +// user_totalcredit_N.xml N = 0, 1, ... +// user_avgcredit_N.xml N = 0, 1, ... +// user_team_N.xml N = team ID +// host_user_N.xml N = user ID +// host_totalcredit_N.xml N = 0, 1, ... +// host_avgcredit_N.xml N = 0, 1, ... + +#include + +#include "db.h" +#include "config.h" + +void write_team(TEAM& team, FILE* f) { + fprintf(f, + "" + ); +} + +void team_totalcredit() { + TEAM team; + FILE* f; + int nfile=0, nrec; + char buf[256]; + + while (!db_team_enum_total_credit(team)) { + if (!f) { + sprintf(buf, "team_totalcredit_%d", nf); + f = fopen(buf, "w"); + nf++; + nrec = 0; + } + write_team(team, f); + nrec++; + if (nrec == NRECS_PER_FILE) { + fclose(f); + f = 0; + } + } +} + +main() { + CONFIG config; + int retval; + + retval = config.parse_file(); + if (retval) { + fprintf(stderr, "Can't parse config file\n"); + exit(1); + } + retval = boinc_db_open(config.db_name, config.db_passwd); + if (retval) { + fprintf(stderr, "Can't open DB\n"); + exit(1); + } + team_totalcredit(); +} diff --git a/todo b/todo index c0fe7fc832..57211e1213 100755 --- a/todo +++ b/todo @@ -69,9 +69,12 @@ THINGS TO TEST (preferably with test scripts) MEDIUM-PRIORITY (should do before public release) ----------------------- +user profiles on web (borrow logic from SETI@home) + Devise system for porting applications password-protected web-based interface for uploading app versions and adding them to DB + XXX should do this manually since need to sign Figure out how to support people with computers at home/work with different preferences. @@ -182,6 +185,7 @@ prevent file_xfer->req1 from overflowing. This problems seems to be test HTTP redirect mechanism for all types of ops Add batch features to ops web + ----------------------- LONG-TERM IDEAS AND PROJECTS -----------------------