
I was testing out the BOINC LCS 3.0 Beta (demo here), as I currently have 5 machines working on the SETI@HOME project and thought it might be nice to be able to put online a quick overview of what the machines in my house are working on at any given moment. I found that with my multi-processor machines (one of which is a dual Xeon proc with hyperthreading, which equates to 4 processors as far as BOINC is concerned!) the program was only showing the first of the workunits that the machine was working on. After a quick delve into the code, I found that the problem was that once the correct info had been read from client_state.xml, the array that was produced wasn't being read properly. The offending code was:
<?php
if(is_object($elements->active_task_set)) {
foreach($elements->active_task_set as $task) {
?>
<tr>
<td>Project URL</td>
<td><a href="<?php echo $task->active_task->project_master_url; ?>"><?php echo $task->active_task->project_master_url; ?></a></td>
</tr>
<tr>
<td>Result Name</td>
<td><?php echo $task->active_task->result_name; ?></td>
</tr>
<tr>
<td>Work done</td>
<td><?php echo bcmul($task->active_task->fraction_done,100,2); ?> %</td>
</tr>
<tr class="noh">
<td></td>
<td><div class="fractioncontainer"><div class="fractiondone" style="width:<?php echo bcmul($task->active_task->fraction_done,100,0); ?>%;"></div></div></td>
</tr>
<tr>
<td class="projectdivider">Computing time</td>
<td class="projectdivider"><?php $time = secondstodate(number_format($task->active_task->current_cpu_time,0,'','')); echo $time["hours"]<1 ? '0 Hours ' : $time["hours"].' Hours ' ; echo $time["minutes"]<1 ? '0 Minutes ' : $time["minutes"].' Minutes ' ; echo $time["seconds"]<1 ? '0 Seconds' : $time["seconds"].' Seconds' ; ?></td>
</tr>
<?php
}
}
?>The code references foreach($elements->active_task_set as $task), where $elements->active_task_set is an array element containing a sub-array of active tasks. Instead, we need to change this to reference the sub-array elements, as in foreach($elements->active_task_set->active_task as $task). This way, the foreach statement reads through each sub-array, which contains the info for a single task. Once this has been changed, each subsequent reference to $task->active_task needs to be changed to just $task. Change this code to the following and it should work:
<?php
if(is_object($elements->active_task_set)) {
foreach($elements->active_task_set->active_task as $task) {
?>
<tr>
<td>Project URL</td>
<td><a href="<?php echo $task->project_master_url; ?>"><?php echo $task->project_master_url; ?></a></td>
</tr>
<tr>
<td>Result Name</td>
<td><?php echo $task->result_name; ?></td>
</tr>
<tr>
<td>Work done</td>
<td><?php echo bcmul($task->fraction_done,100,2); ?> %</td>
</tr>
<tr class="noh">
<td></td>
<td><div class="fractioncontainer"><div class="fractiondone" style="width:<?php echo bcmul($task->fraction_done,100,0); ?>%;"></div></div></td>
</tr>
<tr>
<td class="projectdivider">Computing time</td>
<td class="projectdivider"><?php $time = secondstodate(number_format($task->current_cpu_time,0,'','')); echo $time["hours"]<1 ? '0 Hours ' : $time["hours"].' Hours ' ; echo $time["minutes"]<1 ? '0 Minutes ' : $time["minutes"].' Minutes ' ; echo $time["seconds"]<1 ? '0 Seconds' : $time["seconds"].' Seconds' ; ?></td>
</tr>
<?php
}
}
?>This bugfix has been posted to the developer's site, but I've heard nothing back yet. I guess the developer probably just has a single processor machine and as such didn't spot this.
In case anyone's interested in how my BOINC number crunching has been going recently, you can have a look at my BOINC Stats page. I also plan to add a page to this site soon which will grab these graphs and other info (such as that from BOINC LCS) and display them in a nice overview of one of my geek projects!
The author of BOINC LCS, Wilhelm, has now emailed me to confirm that he has received my bugfix and will be incorporating it in his software.