Changeset - 734207e4d1f8
[Not reviewed]
default
0 3 0
LordOfWar - 16 years ago 2009-10-07 12:50:19

added width and height variables to the distrenjob structure, then integrated that into the new xml writer function, and added the new variables to the makeshift user interface in main()
3 files changed with 20 insertions and 6 deletions:
0 comments (0 inline, 0 general)
src/server/distrend.c
Show inline comments
 
@@ -218,25 +218,27 @@ int restoreJobState(struct distrenjob *j
 
    }
 

	
 
  return isJobDone;
 
}
 

	
 
/** creates a structure from starting data, then calls another function to actually add that struct to the queue */
 
void prepare_distrenjob(struct distrenjob *head, int type, char *name, char *submitter, char *email, int priority, int start_frame, int end_frame)
 
void prepare_distrenjob(struct distrenjob *head, int type, char *name, char *submitter, char *email, int priority, int start_frame, int end_frame, int width, int height)
 
{
 
  int counter2;
 
  int counter;
 

	
 
  struct distrenjob *distrenjob;
 
  distrenjob_new(&distrenjob);
 

	
 
  distrenjob->type = 1;
 
  distrenjob->name = name;
 
  distrenjob->submitter = submitter;
 
  distrenjob->email = email;
 
  distrenjob->priority = priority;
 
  distrenjob->width = width;
 
  distrenjob->height = height;
 
  distrenjob->total_frames = (end_frame - start_frame + 1); // sets the total number of frames in animation for status purposes
 

	
 
  /* prepares all the frames by setting that status to "unassigned" */
 
  counter2 = start_frame;
 
  for(counter = 0; counter <= (end_frame- start_frame + 1); counter++){
 
    distrenjob->frameset[counter].num = counter2;
 
@@ -466,16 +468,18 @@ int distrend_config_free(struct distrend
 
  options_free(config->options);
 
  free(config);
 

	
 
  return 0;
 
}
 
/* ************************** XML Functions ************************* */
 
int makeSlaveDataXML(struct distrenjob *job, char *height, char *width)
 

	
 
// returns 1 on successful completion of xml file
 
int makeSlaveDataXML(struct distrenjob *job)
 
{
 
  xmlTextWriterPtr writer;
 
  char *tmp;
 
  char *tmp; // temporarily holds strings to be given to the xml writer
 

	
 
  _distren_asprintf(&tmp, "stor/job%d/job_info.xml", job->jobnum);
 

	
 
  // create xml document at the location tmp with no compression
 
  writer = xmlNewTextWriterFilename(tmp, 0);
 
  xmlTextWriterStartDocument(writer, NULL, "UTF-8", NULL);
 
@@ -486,14 +490,16 @@ int makeSlaveDataXML(struct distrenjob *
 
  xmlTextWriterWriteAttribute(writer, (xmlChar*)"submitter", (xmlChar*)job->submitter);
 
  _distren_asprintf(&tmp, "%d", job->priority);
 
  xmlTextWriterWriteAttribute(writer, (xmlChar*)"priority", (xmlChar*)tmp);
 

	
 
  // write resolution element and add its attributes
 
  xmlTextWriterStartElement(writer, (xmlChar*)"resolution");
 
  xmlTextWriterWriteAttribute(writer, (xmlChar*)"width", (xmlChar*)height);
 
  xmlTextWriterWriteAttribute(writer, (xmlChar*)"height", (xmlChar*)width);
 
  _distren_asprintf(&tmp, "%d", job->width);
 
  xmlTextWriterWriteAttribute(writer, (xmlChar*)"width", (xmlChar*)tmp);
 
  _distren_asprintf(&tmp, "%d", job->height);
 
  xmlTextWriterWriteAttribute(writer, (xmlChar*)"height", (xmlChar*)tmp);
 
  xmlTextWriterEndElement(writer);
 

	
 
  // end document
 
  xmlTextWriterEndDocument(writer);
 

	
 
  // free writer and save xml file to disk
 
@@ -615,12 +621,14 @@ int main(int argc, char *argv[])
 
  struct frameset *tmp_frame;
 
  int type;
 
  char *name = "";
 
  char *submitter = "";
 
  char *email = "";
 
  int priority;
 
  int width;
 
  int height;
 
  int start_frame;
 
  int end_frame;
 

	
 
  while(test == 1)
 
  {
 
    fprintf(stderr, "Welcome to DistRen Alpha Interactive Test Mode\n\n");
 
@@ -656,13 +664,15 @@ int main(int argc, char *argv[])
 
      fprintf(stderr, "\nName: ");                     scanf("%s", name);
 
      fprintf(stderr, "\nSubmitter: ");                scanf("%s", submitter);
 
      fprintf(stderr, "\nEmail: ");                    scanf("%s", email);
 
      fprintf(stderr, "\nPriority: ");                 scanf("%d", &priority);
 
      fprintf(stderr, "\nStart frame: ");              scanf("%d", &start_frame);
 
      fprintf(stderr, "\nEnd frame: ");                scanf("%d", &end_frame);
 
      prepare_distrenjob(&head, type, name, submitter, email, priority, start_frame, end_frame);
 
      fprintf(stderr, "\nWidth: ");                    scanf("%d", &width);
 
      fprintf(stderr, "\nHeight: ");                   scanf("%d", &height);
 
      prepare_distrenjob(&head, type, name, submitter, email, priority, start_frame, end_frame, width, height);
 
      break;
 
    case 5:
 
      fprintf(stderr, "\nJob number: ");
 
      scanf("%d", &jobnum);
 
      distrenjob_remove(&head, distrenjob_get(&head, jobnum));
 
      break;
src/server/distrenjob.c
Show inline comments
 
@@ -55,12 +55,14 @@ int distrenjob_new(struct distrenjob **d
 
  dj->next = NULL;
 
  dj->name = (char *)NULL;
 
  dj->submitter = (char *)NULL;
 
  dj->email = (char *)NULL;
 
  dj->jobnum = 0; /*< @todo there should be a central jobnum allocator and a way to save the maximum jobnumber allocated */
 
  dj->priority = 0;
 
  dj->width = 0;
 
  dj->height = 0;
 
  dj->completed_frames = 0;
 
  dj->assigned_frames = 0;
 
  dj->total_render_time = 0;
 
  dj->hibernate = 0;
 
  dj->frameset = (struct frameset *)NULL; /*< @todo does frameset need to be initialized here? */
 

	
src/server/distrenjob.h
Show inline comments
 
@@ -36,12 +36,14 @@ struct distrenjob {
 
  struct distrenjob *next; /*< next will be NULL unless if there is another distrenjob */
 
  short int type; // 1:Blender, 2:something else
 
  char *name;
 
  char *submitter;
 
  char *email; /*< This should be looked up based on the value of submitter, not stored in this struct */
 
  jobnum_t jobnum;
 
  int width; // width in pixels of the frames to be rendered
 
  int height; //height in pixels of the frames to be rendered
 
  int priority;  // 1 is lowest, 10 is highest, 0 means the job is done
 
  int completed_frames; // number of completed frames for stats/etc
 
  int assigned_frames; // number of assigned frames (that are not yet completed) for stats/etc
 
  int total_frames; // how many frames are in the animation for stats/etc (unassigned frames)
 
  int watchdog_forgiveness; // how many seconds till the frame is re-assigned (if client computer crashes etc);
 
  short int hibernate;
0 comments (0 inline, 0 general)