Changes between Version 9 and Version 10 of BossaExampleOne
- Timestamp:
- Feb 12, 2008, 11:36:04 AM (17 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
BossaExampleOne
v9 v10 30 30 31 31 Visit http://a.b.c/test_ops/bossa_ops.php, 32 and create an application with short name "ellipse". 32 and create an application with short name "bossa_example". 33 34 The application is define by three scripts in~/projects/test/html/: 35 36 * '''ops/bossa_example_workgen.php''': this generates more jobs. 37 * '''user/bossa_example_display.php''': show a job, and handle user response. 38 * '''inc/bossa_example_backend.php''': compare and handle completed jobs. 39 40 We'll go through these scripts and explain how they work. 41 To develop your own Bossa applications you'll need to write corresponding scripts. 33 42 34 43 == A script to generate jobs == 35 44 36 45 First, let's generate some jobs. 37 We'll do this with a PHP script, html/ops/bossa_test.php: copy this from 38 [source:/trunk/boinc/html/ops/bossa_test.php html/ops/bossa_test.php]. 46 We'll do this with a PHP script, [source:/trunk/boinc/html/ops/bossa_example_workgen.php html/ops/bossa_example_workgen.php]. 39 47 40 48 The first part of this script is code for generating an image; … … 78 86 }}} 79 87 80 This function creates one job. 81 It does the following: 88 This function creates one job, as follows: 82 89 83 90 * Choose a name for the job, and a name for the corresponding image file. … … 119 126 looks up the application in the database, and creates some jobs. 120 127 You can invoke this by visiting 121 '''http://a.b.c/test_ops/bossa_test.php?make_jobs=10'''. 128 '''http://a.b.c/test_ops/bossa_example_workgen.php?make_jobs=10''' 129 (or use the link on the http://a.b.c/test_ops/bossa_ops.php). 122 130 123 131 == Displaying jobs == 124 132 125 Next we'll need a script that displays a job to a volunteer, 126 and handles their response. 127 This uses a PHP script, html/user/ellipse_display.php: copy this from 128 [source:/trunk/boinc/html/user/bossa_example.php html/user/bossa_example.php]. 133 Next we'll explain the script that displays a job to a volunteer 134 and handles their response: [source:/trunk/boinc/html/user/bossa_example.php bossa_example_display.php]. 129 135 {{{ 130 136 function show_job($bj, $bji) { … … 132 138 $img_url = $info.url; 133 139 echo " 134 <form method=get action= ellipse_display.php>140 <form method=get action=bossa_example_display.php> 135 141 Click on the center of the ellipse. 136 142 If you don't see one, click here: … … 166 172 }}} 167 173 168 The script calls '''Bossa::script_init()''' to get objects describing174 The script calls '''Bossa::script_init()''' to get PHP objects describing 169 175 the user, the job, and the job instance. 170 176 … … 181 187 182 188 Finally, we need to specify how results are handled. 183 This is specified in "html/inc/ellipse_handler.inc".189 This is specified in [source:/trunk/boinc/html/inc/bossa_example_backend.inc bossa_example_backend.inc]. 184 190 185 191 This defines two functions, which must have names '''X_compare''' and '''X_handle''' … … 188 194 The first function compares two instances and decides if they are compatible: 189 195 {{{ 190 function ellipse_compare($r1, $r2) {196 function bossa_example_compare($r1, $r2) { 191 197 if ($r1->have_ellipse) { 192 198 if ($r2->have_ellipse) { … … 208 214 i.e. a consensus set has been found: 209 215 {{{ 210 function ellipse_handle($bj, $c) {216 function bossa_example_handle($bj, $c) { 211 217 $res = $c[0]; 212 218 if ($res->have_ellipse) {