Пример #1
0
void PlayInfoBox::setsong(char * song)
{
	sprintf (message[0], "%s",song); // bof??
	setCDKLabel (
			infobox,
			(char**)message,
			2,
			TRUE
			);
}
Пример #2
0
void PlayInfoBox::setelapsed(char * newelap)
{
	snprintf(elapsed,32,"</B>Elapsed:<!B>%s",newelap);
	snprintf(message[1],255,"%s %s %s",elapsed,mode,curract);

	setCDKLabel (
			infobox,
			(char**)message,
			2,
			TRUE
		      );
}
Пример #3
0
void PlayInfoBox::setmode (char * newmode)
{
	func ("PlayInfoBox::setmode()");
	
  	snprintf(mode,32,"</B>Mode:<!B> %s",newmode);
	snprintf(message[1],255,"%s %s %s",elapsed,mode,curract);
	setCDKLabel (
			infobox,
			(char**)message,
			2,
			TRUE
			);
}
Пример #4
0
void __setCDKLabel (CDKLABEL *label, char *msg, int n, boolean box) {
	int i;
//	FILE *fd = fopen("/tmp/otro", "aw");
	char **dblmsg;

	dblmsg = toCharDblPtr(msg, n);

//	fprintf(fd,"__setCDKLabel:\n");
//	fprintf(fd,"MSG: %s<----\n", msg);
//	fflush(fd);

	setCDKLabel(label, dblmsg, n, box);
	for (i=0;i<n;i++)
		free(dblmsg[i]);
	free(dblmsg);
}
Пример #5
0
int main (void)
{
   /* *INDENT-EQLS* */
   CDKSCREEN *cdkscreen = 0;
   CDKLABEL *stopSign   = 0;
   CDKLABEL *title      = 0;
   const char *mesg[5];
   const char *sign[4];
   chtype key;
   boolean functionKey;

   cdkscreen = initCDKScreen (NULL);

   /* Start CDK Colors. */
   initCDKColor ();

   /* Set the labels up. */
   mesg[0] = "<C><#HL(40)>";
   mesg[1] = "<C>Press </B/16>r<!B!16> for the </B/16>red light";
   mesg[2] = "<C>Press </B/32>y<!B!32> for the </B/32>yellow light";
   mesg[3] = "<C>Press </B/24>g<!B!24> for the </B/24>green light";
   mesg[4] = "<C><#HL(40)>";
   sign[0] = " <#DI> ";
   sign[1] = " <#DI> ";
   sign[2] = " <#DI> ";

   /* Declare the labels. */
   title = newCDKLabel (cdkscreen, CENTER, TOP,
			(CDK_CSTRING2) mesg, 5,
			FALSE, FALSE);
   stopSign = newCDKLabel (cdkscreen, CENTER, CENTER,
			   (CDK_CSTRING2) sign, 3,
			   TRUE, TRUE);

   /* Do this until they hit q or escape. */
   for (;;)
   {
      drawCDKLabel (title, FALSE);
      drawCDKLabel (stopSign, TRUE);

      key = (chtype)getchCDKObject (ObjOf (stopSign), &functionKey);
      if (key == KEY_ESC || key == 'q' || key == 'Q')
      {
	 break;
      }
      else if (key == 'r' || key == 'R')
      {
	 sign[0] = " </B/16><#DI> ";
	 sign[1] = " o ";
	 sign[2] = " o ";
      }
      else if (key == 'y' || key == 'Y')
      {
	 sign[0] = " o ";
	 sign[1] = " </B/32><#DI> ";
	 sign[2] = " o ";
      }
      else if (key == 'g' || key == 'G')
      {
	 sign[0] = " o ";
	 sign[1] = " o ";
	 sign[2] = " </B/24><#DI> ";
      }

      /* Set the contents of the label and re-draw it. */
      setCDKLabel (stopSign, (CDK_CSTRING2) sign, 3, TRUE);
   }

   /* Clean up. */
   destroyCDKLabel (title);
   destroyCDKLabel (stopSign);
   destroyCDKScreen (cdkscreen);
   endCDK ();
   ExitProgram (EXIT_SUCCESS);
}
Пример #6
0
int main (int argc, char **argv)
{
   /* Declare variables. */
   CDKSCREEN *cdkscreen = 0;
   CDKLABEL *demo	= 0;
   WINDOW *cursesWin	= 0;
   int boxLabel		= 0;
   char *mesg[4], temp[256];
   struct tm *currentTime;
   time_t clck;
   int ret;

   /* Parse up the command line. */
   while ((ret = getopt (argc, argv, "b")) != -1)
   {
      switch (ret)
      {
	 case 'b' :
	      boxLabel = 1;
      }
   }

   /* Set up CDK */ 
   cursesWin = initscr();
   cdkscreen = initCDKScreen (cursesWin);

   /* Start CDK Colors */
   initCDKColor();

   /* Set the labels up. */
   mesg[0] = "</1/B>HH:MM:SS";

   /* Declare the labels. */
   demo = newCDKLabel (cdkscreen, CENTER, CENTER, mesg, 1, boxLabel, FALSE);

   /* Is the label null??? */
   if (demo == 0)
   {
      /* Clean up the memory. */
      destroyCDKScreen (cdkscreen);

      /* End curses... */
      endCDK();

      /* Spit out a message. */
      printf ("Oops. Can't seem to create the label. Is the window too small?\n");
      ExitProgram (EXIT_FAILURE);
   }

   curs_set(0);
   wtimeout (WindowOf(demo), 50);

   /* Do this for-a-while... */
   do
   {
      /* Get the current time. */
      time(&clck);
      currentTime = localtime (&clck);

      /* Put the current time in a string. */
      sprintf (temp, "<C></B/29>%02d:%02d:%02d", currentTime->tm_hour, currentTime->tm_min, currentTime->tm_sec);
      mesg[0] = copyChar (temp);

      /* Set the label contents. */
      setCDKLabel (demo, mesg, 1, ObjOf(demo)->box);

      /* Clean up the memory used. */
      freeChar (mesg[0]);

      /* Draw the label, and sleep. */
      drawCDKLabel (demo, ObjOf(demo)->box);
      napms (500);
   }
   while (wgetch(WindowOf(demo)) == ERR);

   /* Clean up */
   destroyCDKLabel (demo);
   destroyCDKScreen (cdkscreen);
   endCDK();

   ExitProgram (EXIT_SUCCESS);
}
Пример #7
0
int main()
{
	char *mesg[4],*infobuf[2];
	char *shared_memory;
	char string[1024],temp[1024];
	FILE *file;
	Nodeinfo *mynode;
	int segment_id, sem_id, i = 1024, k = 1024, line, j, count;
	void *buf;
	
	signal(SIGTERM, cleanup_handler);
	signal(SIGINT, cleanup_handler);

	req.tv_nsec = 5000000;
	cursesWin = initscr();
	cdkscreen = initCDKScreen(cursesWin);

	initCDKColor();
	sprintf(temp,"<C></B/3>Process Migration - GUI for Statistics and Testing");
	mesg[0] = copyChar(temp);
	title = newCDKLabel(cdkscreen, CENTER, TOP, mesg,1,1,0);
      	setCDKLabel (title, mesg, 1, 1);
      	drawCDKLabel (title, 1);
	freeChar (mesg[0]);

	loadDaemon = newCDKSwindow (cdkscreen, (COLS - 50) * 0.10, (LINES - 12) * 0.40, 12, 50, "<C></B/5>Load Daemon", 1000, 1, 0);
	commsDaemon = newCDKSwindow (cdkscreen, (COLS - 50) * 0.90, (LINES - 12) * 0.40, 12, 50, "<C></B/5>Communication Daemon", 1000, 1, 0);
	migrateDaemon = newCDKSwindow (cdkscreen, (COLS - 50) * 0.10, (LINES - 12) * 0.90, 12, 50, "<C></B/5>Migration Control Daemon", 1000, 1, 0);
	extraInfo = newCDKSwindow (cdkscreen, (COLS - 50) * 0.90, (LINES - 12) * 0.90, 12, 50, "<C></B/5>Information", 1000, 1, 0);


	//setCDKSwindowBackgroundColor(loadDaemon, "</5>");
	//setCDKSwindowBackgroundColor(commsDaemon, "</5>");
	//setCDKSwindowBackgroundColor(migrateDaemon, "</5>");
	//setCDKSwindowBackgroundColor(extraInfo, "</5>");

	file = fopen("/var/log/load","r");
	while(fgets(string, 1025, file) != NULL) {
		substr(&temp[0],&string[0]);
		addCDKSwindow (loadDaemon, temp, BOTTOM);
	}
	fclose(file);
	
	
	file = fopen("/var/log/migrate","r");
	while(fgets(string, 1025, file) != NULL) {
		substr(&temp[0],&string[0]);
		addCDKSwindow (migrateDaemon, temp, BOTTOM);
	}
	fclose(file);
	
	buf = malloc(33);

	file = fopen(INFO_SHM_ID_PATH,"r");
	fgets(string,33,file);
	segment_id = atoi(string);
	fclose(file);

	file = fopen(INFO_SEM_ID_PATH,"r");
	fgets(string,33,file);
	sem_id = atoi(string);
	fclose(file);
	
	info = newCDKLabel(cdkscreen, 0, (LINES - 5) * 0.15, infobuf,3,0,0);
	shared_memory = (void *) shmat(segment_id, 0, 0);
	//setCDKLabelBackgroundColor(info, "</55>");
	refreshCDKScreen(cdkscreen);
	binary_semaphore_post(sem_id);
	cp_loadlog();
	cp_migratelog();
	for(;;) {
		if(i-- == 0) {
			cp_loadlog();
			i = 1024;
		}
		file = popen("diff /tmp/migrate/load.temp /var/log/load | sed 1d | wc -l","r");
		strcpy(string,"\0");
		fgets(string, 1025, file);
		count = atoi(string);
		pclose(file);
		sprintf(string,"count: %d",count);
		if(count != 0) {
			file = popen("diff /tmp/migrate/load.temp /var/log/load | sed 1d","r");
			for(j = 0; j < count; j++) {
				fgets(string, 1025, file);
				substr(&temp[0],&string[0]);
				addCDKSwindow (loadDaemon, temp, BOTTOM);
			}
			pclose(file);
			i = 0;
		}
		/*if(k-- == 0) {
			cp_migratelog();
			k = 1024;
		}
		file = popen("diff /tmp/migrate/migrate.temp /var/log/migrate | sed 1d | wc -l","r");
		strcpy(string,"\0");
		fgets(string, 1025, file);
		count = atoi(string);
		pclose(file);
		sprintf(string,"count: %d",count);
		if(count != 0) {
			file = popen("diff /tmp/migrate/migrate.temp /var/log/migrate | sed 1d","r");
			for(j = 0; j < count; j++) {
				fgets(string, 1025, file);
				substr(&temp[0],&string[0]);
				addCDKSwindow (migrateDaemon, temp, BOTTOM);
			}
			pclose(file);
			k = 0;
		}*/
		binary_semaphore_wait(sem_id);
		memcpy(buf, shared_memory, 33);
		binary_semaphore_post(sem_id);
		mynode = nodeinfo__unpack(NULL, 33, buf);
		if(mynode == NULL) {
			fprintf(stderr,"error unpacking message\n");
			exit(1);
		}
		sprintf(temp,"\t\t\t\t\t\t\t</B/U/7>STATISTICS");
		infobuf[0] = copyChar(temp);
		sprintf(temp,"\t</B>Load:<!B> %0.2f\t</B>No. of peers connected:<!B> %d\t</B>No. of processes migrated:<!B> %d\t</B>No. of processes accepted:<!B> %d\t",mynode->load,mynode->np,mynode->npm,mynode->npa);
		infobuf[1] = copyChar(temp);
		sprintf(temp,"\t\t\t\t</B>Upper Threshold:<!B> %.2f\t</B>Lower Threshold:<!B> %.2f",mynode->uthresh,mynode->lthresh);
		infobuf[2] = copyChar(temp);
		setCDKLabel (info, infobuf, 3, 0);
		drawCDKLabel (info, 0);
		freeChar (infobuf[0]);
		freeChar (infobuf[1]);
		freeChar (infobuf[2]);
		sleep(1);
	}
	exit(0);
}