Changeset - fabe5785df0c
[Not reviewed]
default
0 1 0
LordOfWar - 16 years ago 2009-07-05 02:11:18

frame_finder now takes into account priority, which I defined. 0 priority is done, 1 priority is the lowest, 10 is the highest. While creating this and my status_report_generator function (which is still a thought) I have created some new global variables.

Instead of starting a scan at jobnum zero every time, I decided to make the global variable hcfjob (highest consecutive finished job).
1 file changed with 54 insertions and 15 deletions:
0 comments (0 inline, 0 general)
src/server/distrend.c
Show inline comments
 
@@ -39,13 +39,22 @@
 

	
 
int jobnum = 0;
 

	
 
int hcfjob; //highest consecutively finished job
 

	
 
int highest_jobnum; // The job number of the most recently created job, this is used when creating new jobs
 

	
 
// Structures for storing job information
 
// OOOOOOkay so we really need a struct for frameset rather than just an array, because we should track who each frame was sent out to. Please do this, someone! :D
 
struct {
 
  char *name;
 
  char *submitter;
 
  char *email;
 
  int priority;  // 1 is highest, 10 is lowest, 0 is done
 
  int priority;  // 1 is lowest, 10 is highest, 0 is done
 

	
 
  int percent_done;
 
  int completed_frames; // number of completed frames
 
  int total_frames; // how many frames are in the animation
 

	
 
  struct frameset **frameset; // What exactly is this now? hehe
 
} blendjob[max];
 

	
 
@@ -258,52 +267,82 @@ void loginuser(char *username, int secre
 

	
 

	
 
/* This function creates frame array based on the total number of frames to be rendered, which will then be parsed by function frame_farmer. */
 
void frame_num_struct_builder(int jobnum, int sframe, int eframe) {
 
void frame_num_struct_builder(int sframe, int eframe) {
 
	int jobnum_new = highest_jobnum + 1;
 
	int total = sframe - eframe;
 
	int fcount = sframe; // Used to create all the frames in the structure from sframe to eframe
 
	int x = 0;
 

	
 
	while(x < total){
 
		blendjob[jobnum].frameset[x].frame_num = fcount;
 
		blendjob[jobnum_new].frameset[x].frame_num = fcount;
 
		x++;
 
		fcount++;
 
	}
 

	
 
	highest_jobnum++;
 
}
 

	
 
// matches your computer up with a lovely frame to render
 
int frame_finder(){
 
	int your_frame = null;  // your_frame is an interger value that will be given to the client as the frame number to render
 
	int x = 0; // the frameset number
 
	int priority = 1; // start the scan for the next frame with priority 1
 
	int finder_jobnum = 0;
 
	int frameset_count = 0; // the frameset number, because frames in an animation don't start at zero
 
	short int done = 0;
 

	
 
	for(int priority = 10; priority >= 1; priority--){ // start the scan for the next job with the highest priority
 
		finder_jobnum = hcfjob + 1; // reset it to start scanning at first uncompleted job for the pass at each priority level
 

	
 
		while(finder_jobnum <= highest_jobnum){
 
			if(blendjob[finder_jobnum].priority = priority){  // looks for a job with the current priority value
 
				done = 1;									  // notice it starts by looking at the oldest job first
 
				break;
 
			}
 

	
 
			if(done = 1)  // If it has found a job with the current priority value, it will break out of the loop
 
				break;    // If none is found it goes to the next job to see if it is of the current priority value
 
			else
 
				finder_jobnum++;
 
		}
 

	
 
		if(done = 1) // if job has been found, it lets it out of the priority changer loop
 
			break;
 
	}
 

	
 
	while(your_frame <= (sframe - eframe)){ // Finds the frameset number with a frame that needs to be rendered
 
		if (blendjob[jobnum].frameset[x].frame_status = 0)
 
			break;
 
		if (blendjob[finder_jobnum].frameset[frameset_count].frame_status = 0)  // If frame that is not assigned has been found, frameset_count is not changed
 
			break;																// and frameset_count is used to give the frame number later in this funciton
 

	
 
		x++;  // If frame is assigned or done, it goes to next frame
 
	}
 

	
 
blendjob[jobnum].frameset[x].frame_status++; // sets the value of the frame to 2, which means its taken
 

	
 
your_frame = blendjob[jobnum].frameset[x].frame_num; //  Takes the frameset found in the while statement above, and extracts the frame number from it and assigns it to the int your_frame
 

	
 
if(your_frame = null)  // If that job had no open frames for some reason, run the status report generator so that
 
	status_report_generator();  //the job priority can be changed to 0
 

	
 
return your_frame; // your_frame is returned as the frame to be rendered
 
}
 

	
 
// This figures out how much of the job is done, where jobnum corresponds to the job number
 
// This uses pointers, so when it is run it updates certain values in memory
 
void status_report_generator(){
 
	int num1 = 0;
 
	int num1 = hcfjob+1;
 
	int num2 = 0;
 
	int num3 = 0;
 

	
 
	while(num1 >= 0){
 
		while(blendjob[num1].frameset[num2].name != null){
 
			if(blendjob[num1].frameset[num2].priority = 0) // if job is done, go to next one
 
				num1++;
 
	if(blendjob[num1].priority = 0)
 
		hcfjob+1;  // adds 1 to the highest consecutively finished job
 

	
 
			if(blendjob[num1].frameset[num2].priority !=0)
 
				break;
 
		}
 
	while(blendjob[num1].frameset[num2].name != null){
 
		if(blendjob[num1].priority = 0) // if job is done, go to next one
 
			num1++;
 

	
 
		if(blendjob[num1].frameset[num2].priority !=0)
 
			break;
 
	}
 

	
 
}
 

	
 
// This function makes the value of the frame 2, which means its completed.
0 comments (0 inline, 0 general)