Changeset - 7a41ccaab4c9
[Not reviewed]
default
0 1 0
LordOfWar - 16 years ago 2009-10-01 01:21:36

changed up printJob and printFrame to require less parameters, and now printJob only passes a pointer to a frame to printFrame

create a loop in the main function to interact with the queue in order to test it... it still needs a bit of work though
1 file changed with 39 insertions and 6 deletions:
0 comments (0 inline, 0 general)
src/server/distrend.c
Show inline comments
 
@@ -417,78 +417,77 @@ int distrend_do_config(int argc, char *a
 
    fprintf(stderr, "xml2distrenjob() returned %d. Try to cd to distren/doc if you want to test out the xml2distrenjob() function. (This will only fix this error if the error is due to an inability of the xml library to access distrenjob.xml.example)\n\n", tmp);
 
  else
 
    fprintf(stderr, "using email ``%s'' for user ``%s'' -- reading in XML files and pulling data from them using libxml2+XPath works!!!\n", distrenjob->email, distrenjob->submitter);
 

	
 
  fprintf(stderr, "%s:%d running config\n", __FILE__, __LINE__);
 

	
 
  *config = malloc(sizeof(struct distrend_config));
 
  myopts[1].simple_value = &(*config)->datadir;
 

	
 
  options_init(argc, argv, &(*config)->mycfg, myopts, "server", &(*config)->options);
 

	
 
  fprintf(stderr, "using %s as datadir\n", (*config)->datadir);
 

	
 
  xmlcleanup();
 
  return 0;
 
}
 
int distrend_config_free(struct distrend_config *config)
 
{
 
  options_free(config->options);
 
  free(config);
 

	
 
  return 0;
 
}
 
/* ************************** Test Functions ************************* */
 
void printFrameInfo(struct distrenjob *head, struct distrenjob *job, int frame_num)
 
void printFrameInfo(struct frameset *frame)
 
{
 
  char *status = "";
 
  frame_num = frame_num - job->frameset[0].num;
 

	
 
  switch(job->frameset[frame_num].status)
 
  switch(frame->status)
 
  {
 
    case FRAMESETSTATUS_UNASSIGNED:
 
      _distren_asprintf(&status, "%s", "unassigned");
 
      break;
 
    case FRAMESETSTATUS_ASSIGNED:
 
      _distren_asprintf(&status, "%s", "assigned");
 
      break;
 
    case FRAMESETSTATUS_DONE:
 
      _distren_asprintf(&status, "%s", "completed");
 
      break;
 
    case FRAMESETSTATUS_CANCELED:
 
      _distren_asprintf(&status, "%s", "canceled");
 
  }
 

	
 
  printf("frame #: %d --> %s", frame_num, status);
 
  printf("frame #: %d --> %s", frame->num, status);
 
}
 

	
 
void printJob(struct distrenjob *head, struct distrenjob *job)
 
void printJob(struct distrenjob *job)
 
{
 
  int counter;
 
  printf("frame_num: status");
 
  for(counter = 0; counter < job->total_frames; counter++)
 
    {
 
      printFrameInfo(head, job, job->frameset[counter].num);
 
      printFrameInfo(&job->frameset[counter]);
 
    }
 
}
 

	
 
void printJobInfo(struct distrenjob *head, struct distrenjob *job)
 
{
 
  printf("type: %d", job->type);
 
  printf("name: %s", job->email);
 
  printf("submitter: %s", job->submitter);
 
  printf("e-mail: %s", job->email);
 
  printf("priority, %d", job->priority);
 
  printf("completed: %d", job->completed_frames);
 
  printf("assigned: %d", job->assigned_frames);
 
  printf("total: %d", job->total_frames);
 
  printf("watchdog: %d", job->watchdog_forgiveness);
 
  printf("hibernate: %d", job->hibernate);
 
  printf("prev_frame: %d", job->prev_frame_index);
 
}
 

	
 
/* ************************** Main ************************* */
 

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

	
 
  /* Argument-parser */
 
@@ -515,48 +514,82 @@ int main(int argc, char *argv[])
 
    return 3;
 
  }
 

	
 
  struct distrenjob head;
 
  head.priority = 0; // make head have the highest priority
 

	
 
  int cont;
 
  struct distrend_listenset *listenset;
 
  struct distrend_config *config;
 

	
 
  enum clientstatus
 
  {
 
    CLIENTSTATUS_UNINITIALIZED = 0,
 
    CLIENTSTATUS_BUSY = 1,
 
    CLIENTSTATUS_IDLE = 2
 
  } clientstatus;
 

	
 
  cont = 1;
 
  memset(&head, '\0', sizeof(struct distrenjob));
 

	
 
  start_data(); // Starts fresh or loads data from xml dump. Should we grab the return?
 

	
 
  distrend_do_config(argc, argv, &config);
 

	
 
  while(t==1)
 
  {
 
	  int command;
 
	  printf("1-->print all frames in a job");
 
	  printf("2-->examine certain job");
 
	  printf("3-->get a frame to render");
 
	  printf("4-->add a job");
 
	  printf("5-->delete a job");
 
	  printf("6-->exit menu");
 

	
 
	  command = scanf();
 

	
 
	  if(command == 6)
 
		  break;
 

	
 
	  switch(command)
 
	  {
 
	  case 1:
 
		  printf("job number:");
 
		  command = scanf();
 
		  printJob(distrenjob_get(head, command));
 
		  break;
 
	  case 2:
 

	
 
		  break;
 
	  case 3:
 
		  break;
 
	  case 4:
 
		  break;
 
	  case 5:
 
		  break;
 
	  }
 
  }
 

	
 
  distrend_listen(&listenset, config);
 
  /* This is called the "main loop" */
 
  while(cont)
 
    {
 
      struct distren_action *action;
 
      int clientsays = 0; /*< temporary example variable, will be replaced when we can handle messages */
 

	
 
      distrend_accept(&action);
 
      cont = distrend_do(action);
 

	
 
      /* Make the following code more event-driven */
 
      frame_watchdog(&head);
 

	
 

	
 
      struct frameset *frame;
 
      struct distrenjob *job;
 

	
 
      /* If the client is idle, must be modified for climbing through linked list of clients (client->clientnum) */
 
      if(clientstatus == CLIENTSTATUS_IDLE)
 
	{
 
	  int returnnum = find_jobframe(&head, &job, &frame); // Finds a frame to render
 
	  if(returnnum)
 
	    {
 
	      fprintf(stderr,"No frames are available to render at this time. Idling...\n");
0 comments (0 inline, 0 general)