%s | | "
"",
n->name);
#if DEBUG
fprintf(stderr, "Node %s\n", n->name);
#endif
/* This is where we figure out what reservation to output */
/* It traverse two linked list and handles all events (start, end) that
occurs. Job reservation are always visible. User reservations "under"
job reservations are not visible. */
curtime = 0;
jobres = n->jobres;
userres = n->userres;
while (jobres || userres) {
if (jobres && jobres->start <= curtime) {
if (jobres->end > curtime) {
switch (jobres->state) {
case 'R':
type = res_running;
break;
case 'I':
type = res_idle;
break;
}
printres(curtime, jobres->end, type);
curtime = jobres->end;
}
jobres = jobres->next;
continue;
}
if (userres && userres->start <= curtime) {
if (userres->end > curtime) {
/* Use another color on development reservations */
type = (strstr(userres->id, DEVELRES)) ? res_devel : res_user;
if (jobres && jobres->start < userres->end) {
printres(curtime, jobres->start, type);
curtime = jobres->start;
/* The user_res may contine after the job_res */
continue;
}
/* limit the length of user reservations */
t = userres->end;
/* t = MIN(userres->end, jobmaxtime); */
printres(curtime, t, type);
curtime = userres->end;
}
userres = userres->next;
continue;
}
/* The node is currently free.
Figuring out when next reservation occurs */
t = INT_MAX;
if (jobres) t = MIN(t, jobres->start);
if (userres) t = MIN(t, userres->start);
printres(curtime, t, res_none);
curtime = t;
}
/* Unallocated nodes needs something between | and | .
( adds extra vertical space ???) */
printres(0, 3600, res_none);
printf("
\n");
}
void printdays()
{
int curtime, tim, day, diff;
struct tm midnight;
time_t t;
int i;
struct tm *now;
curtime = 0;
diff = time(&t);
now = localtime(&t);
midnight = *now;
midnight.tm_hour = midnight.tm_min = midnight.tm_sec = 0;
tim = mktime(&midnight) - diff;
day = now->tm_wday;
#if DEBUG
fprintf(stderr, "seconds to midnight=%d day=%d\n", tim-curtime, day);
#endif
printf(" | | "
"");
printres(0, end, res_bg);
printf(" = 1 node-hour ");
printres(0, end, res_running);
printf(" = running job ");
printres(0, end, res_idle);
printf(" = advance job reservation ");
printres(0, end, res_user);
printf(" = static reservation ");
printres(0, end, res_devel);
printf(" = development reservation (max walltime: 1 h) ");
printf(" |
\n");
}
void printtable()
{
struct node *n;
#if DEBUG
fprintf(stderr, "mintime=%d maxtime=%d\n", mintime, maxtime);
#endif
printf("