Changeset - 901eddfe43e9
[Not reviewed]
default
0 1 0
ethanzonca - 16 years ago 2009-07-25 00:42:17

Updated \"while rendering\" code
1 file changed with 10 insertions and 8 deletions:
0 comments (0 inline, 0 general)
src/server/slave.c
Show inline comments
 
@@ -24,19 +24,19 @@
 
 *
 
 * Slave listens on server for a command in the format of each function...
 
 * We need if's for returns... ==> watchdog
 
 * **********************************************************************************
 
*/
 

	
 
// Provides DISTREN_REQUEST* which is in reality, DISTREN_SEND(signal)
 
// Provides DISTREN_REQUEST* which is in reality, DISTREN_SEND(signal) in the minds of your average joe
 
#include "protocol.h"
 

	
 
int main(int argc, char *arvg[])
 
{
 

	
 
	///////////////////// Semi-pseudo Slave Code ///////////////////////////
 
	/* Semi-pseudo Slave Code */
 

	
 

	
 
	int slavestatus = 0;
 

	
 
	if('no username in config file, no key present'){
 
		fprintf(stderr "run distrend -c username] [emailaddr] to register")
 
@@ -51,24 +51,26 @@ int main(int argc, char *arvg[])
 
	}
 

	
 
	if('slave recieves "start frame#, job#"'){
 
		fprintf(stderr, "Got frame %d in job %d, preparing to render...",frame,job);
 
		get('http://distren.protofusion.org/srv/job#.tgz');
 
		exec('tar -xvf job#.tgz /tmp/distren/job#'); // somehow
 
		exec_blender(jobname.blendfile, jobnum.framenum.JPG, jobnum); // (check the args, we'll need to adjust for different output formats)... set SLAVESTATUS=1 while rendering, SLAVESTATUS=2 when done
 
		exec_blender(jobname.blendfile, jobnum.framenum.JPG, jobnum); // (check the args, we'll need to adjust for different output formats, include this in the blendjob struct later)
 
			while('blender is running'){
 
				SLAVESTATUS=1; // really quite pointless now, but why not. Could be nice for logging.
 
				tell_the_server(DISTREN_REQUEST_PROGRESS);
 
				fprintf(stderr, "Rendering frame %d in job %d...",framenum,jobnum);
 
				delay(1000); // or not... this should be more event-driven, but should still give a heartbeat to the server
 
			}
 
		SLAVESTATUS=2; // When done rendering, set this.
 
	}
 
	if(SLAVESTATUS==2){
 
		fprintf(stderr, "Finished frame %d in job %d",framenum,jobnum);
 
		SLAVESTATUS=0;
 
	}
 
	if(SLAVESTATUS==0){
 
		tell_the_server(DISTREN_REQUEST_DONEFRAME);
 
		fprintf(stderr, "Idle. No frames to render.");
 
	}
 
	while(SLAVESTATUS==1){
 
		tell_the_server(DISTREN_REQUEST_PROGRESS);
 
		fprintf(stderr, "Rendering frame %d in job %d...",framenum,jobnum);
 
		delay(1000); // or not... this should be more event-driven, but should still give a heartbeat to the server
 
	}
 

	
 
  return 0;
 
}
0 comments (0 inline, 0 general)