Beispiel #1
0
int main( int argc, char *argv[]) //get options from command line
{
	
	 int mainfd=0; //mainfd is like file pointer execpt with no buff
 mainfd = open_port(); //call the open port command in signfp.c
		       //Oh magical serial port config is done there! 

	int temp; //temp count of number of chars in buffer
	char stringtemp[1024]; //HUGE BUFFER for strings

		if (argc > 3 || argv[1] == NULL) //check to see if there are the correct # of args
		{
		printf("usage: %s  color \"text\"\n",argv[0]);
		return 1;
		}

                         


	starttext(mainfd,'Z','0','A'); //See signfp.c and datasheet for the alpha protocol 
				       // but basickly it says HEY ALL SIGNS WRITE TO Label A
	temp=sprintf(stringtemp,"%c a %c%c",smf,fontmode,largetimesfont); //Set the sign to scroll on all lines 
									// and largetimes font in to buffer
	temp=write(mainfd,stringtemp,temp); //write buffer to mainfd (which should be the serial port see signfp.c)
	printf("wrote %d",temp); //debug 
                if (strcmp(argv[1],"red") == 0) //argv 1 ahould be the color att. for the sign  from command line
                {
                       if (debug == 1)
			 printf("red\n");
			temp=sprintf(stringtemp,"%c%c",cc,red);// set the color code
		        temp=write(mainfd,stringtemp,temp); //and shove it out the door
             if (debug == 1)
	printf("wrote %d",temp);

                }
                else if (strcmp(argv[1],"green") == 0)
                {
			if (debug == 1)
                        printf("green\n");
			temp=sprintf(stringtemp,"%c%c",cc,green);
      			  temp=write(mainfd,stringtemp,temp);
     if (debug == 1)
        printf("wrote %d",temp);

                }
		else if (strcmp(argv[1],"amber") == 0)
                {
                        if (debug == 1)
                        printf("amber\n");
                        temp=sprintf(stringtemp,"%c%c",cc,amb);
        		temp=write(mainfd,stringtemp,temp);
     if (debug == 1)
        printf("wrote %d",temp);

                }
		else
		{
                        if (debug == 1)
                        printf("defult\n");
                        temp=sprintf(stringtemp,"%c%c",cc,green);
        		temp=write(mainfd,stringtemp,temp);
     if (debug == 1)
        printf("wrote %d",temp);

		}

	temp=strlen(argv[2]);  //count the argv2 which should be a string
        temp=write(mainfd,argv[2],temp); // and shove x chars out the door
     if (debug == 1)
        printf("wrote %d",temp);
        temp=sprintf(stringtemp,"%c",end); // tell the sign were done
	temp=write(mainfd,stringtemp,temp); // output it
     if (debug == 1)
        printf("wrote %d",temp);


close(mainfd); //close the serialport pointer


return 0;
}
Beispiel #2
0
void IO_GO(int sig){
 syslog(LOG_ERR, "SIG IO SIG IO!!!!!!"); //Log it
mainfd = open_port();

        struct sockaddr_in clientName = { 0 };
        int BuffCount;  // Got Count 
	char Buff[1024]; //Buffer size 
        bzero(Buff,sizeof(Buff)); //Zero out the buffer
	int simpleChildSocket = 0;
        int clientNameLength = sizeof(clientName);
	int flag=0;
	char endL[3];
	char TempBuff[256];
	int TempCount;
	int returnstatus;
	bzero(endL,sizeof(endL));
	//transbridgeon(mainfd);
	sprintf(endL,"%c%c",end,0x82);

        simpleChildSocket = accept(simpleSocket,(struct sockaddr *)&clientName, &clientNameLength);

        if (simpleChildSocket == -1) {

            syslog(LOG_ERR, "Cannot accept connections!\n");
            close(simpleSocket);
            exit(1);

        }
        BuffCount=read(simpleChildSocket, Buff, 3);
	TempCount=sprintf(TempBuff,"%d",BuffCount);
        syslog(LOG_WARNING, "I read %d : %s",BuffCount,Buff);
	//trying a switch case to select the begining mode of the sign protocoll
	switch(Buff[0]){
	case 'A':// Sign Type, Sign Addr (last bit)
	startc(mainfd,Buff[1],Buff[2]);
        TempCount=sprintf(TempBuff,"CASE A");
	write(simpleChildSocket, TempBuff, strlen(TempBuff) );
	bzero(Buff,sizeof(Buff));

	break;
	case 'B': //simple mode 
	starttext(mainfd,'Z','0','A');
        TempCount=sprintf(TempBuff," CASE B");
        write(simpleChildSocket, TempBuff, strlen(TempBuff));
	bzero(Buff,sizeof(Buff));

	break;
	case 'C': //set 2 line mem
        TempCount=sprintf(TempBuff,"CASE C");
        write(simpleChildSocket, TempBuff, strlen(TempBuff));
    	syslog(LOG_ERR, "CASE C Buff1=%c",Buff[1]);
    	setmem(mainfd,Buff[1]);

        bzero(Buff,sizeof(Buff));

	flag =1;	// skip loop
	break;
	case 'D': //Single line set memory
        TempCount=sprintf(TempBuff,"CASE D");
        write(simpleChildSocket, TempBuff, strlen(TempBuff));

 syslog(LOG_ERR, "CASE D"); //Log it

	slsetmem(mainfd,Buff[1]);
	bzero(Buff,sizeof(Buff));
	 syslog(LOG_ERR, "End of Case D"); //Log it


	flag =1;
	break;
	case 'P': 
	plotit();
	flag=1;
	break;
	case 'X':
	 TempCount=sprintf(TempBuff,"CASE X");
        write(simpleChildSocket, TempBuff, strlen(TempBuff));
        bzero(Buff,sizeof(Buff));
	break;
	}
       while(flag != 1){

	BuffCount=read(simpleChildSocket, Buff, sizeof(Buff));
	if(DEBUG == 1)
	syslog(LOG_WARNING, "I read %d : %s",BuffCount,Buff);	
		if(endsearch(Buff)==1 )
		{
			flag=1;
		}
		if(BuffCount == 0){
			flag =1;
		}
        /* handle the new connection request  */
        /* write out our message to the client */

			write(mainfd,Buff,strlen(Buff));
			bzero(Buff,sizeof(Buff));
/* OLD CODE SNIPPIT
        write(simpleChildSocket, ACKMESSAGE, strlen(ACKMESSAGE));
        close(simpleChildSocket);
        transbridgeon(mainfd);
        write(mainfd,Buff,strlen(Buff));
        transbridgeoff(mainfd);

*/
	}
	//transbridgeoff(mainfd);
	        write(simpleChildSocket, ACKMESSAGE, strlen(ACKMESSAGE));

	close(simpleChildSocket);
	close(mainfd);
	flag = 0;
	usleep(250);


}
Beispiel #3
0
void drvPDF::show_text(const TextInfo & textinfo)
{
	const float toRadians = 3.14159265359f / 180.0f;
	const float angleInRadians = textinfo.currentFontAngle * toRadians;
	int PDFFontNum = getFontNumber(textinfo.currentFontName.value());
	if (PDFFontNum == -1) {
		PDFFontNum = getSubStringFontNumber(textinfo.currentFontName.value());
		if (PDFFontNum == -1) {
			PDFFontNum = getSubStringFontNumber(defaultFontName);
			if (PDFFontNum == -1) {
				errf << "Warning, unsupported font " << textinfo.
					currentFontName.value() << ", using Courier instead" << endl;
				PDFFontNum = 0;	// Courier
			} else {
				errf << "Warning, unsupported font " << textinfo.
					currentFontName.value() << ", using " << defaultFontName << " instead" << endl;
			}
		} else {
			errf << "Warning, unsupported font " << textinfo.
				currentFontName.value() << ", using " << PDFFonts[PDFFontNum] << " instead" << endl;
		}
	}
	starttext();
// define TFALWAYSONE
// note TFALWAYSONE does not work correctly with awidthshow. See showex.ps
#ifdef TFALWAYSONE
	const float Sx = textinfo.currentFontSize;
	const float Sy = textinfo.currentFontSize;
	buffer << "/F" << PDFFontNum << ' ' << 1 << " Tf" << endl;
	// use size 1 and scale via Tm
#else
	// previously we used currentFontSize for SX and SY
	// and fontsize 1 in Tm, now we use the fontsize in tm and set
	// sx and sy to 1
	const float Sx = 1.0f;
	const float Sy = 1.0f;
	buffer << "/F" << PDFFontNum << ' ' << textinfo.currentFontSize << " Tf" << endl;
#endif
	const float cosphi = (float) cos(angleInRadians);
	const float sinphi = (float) sin(angleInRadians);
	// OK, we could get the real transformation matrix from the interpreter,
	// but this approximation should do it in most cases.
//    buffer.precision(3);
//    buffer.setf(ios::fixed);
//    buffer.width(0); // to force minimal width
//    buffer.unsetf(ios::showpoint);

	adjustbbox(textinfo.x + x_offset, textinfo.y + y_offset);
	buffer << RND3(Sx * cosphi) << " "
		<< RND3(Sx * sinphi) << " "
		<< RND3(-Sy * sinphi) << " "
		<< RND3(Sy * cosphi) << " "
		<< RND3(textinfo.x + x_offset) << " " << RND3(textinfo.y + y_offset) << " Tm" << endl;
	buffer << RND3(textinfo.currentR) << " " << RND3(textinfo.
													 currentG) << " " <<
		RND3(textinfo.currentB) << " rg" << endl;
#ifdef TFALWAYSONE
	buffer << RND3(textinfo.cx /
				   textinfo.currentFontSize) << ' ' << RND3(textinfo.ax / textinfo.currentFontSize)
		<< ' ';
#else
	buffer << RND3(textinfo.cx) << ' ' << RND3(textinfo.ax) << ' ';
#endif
	buffer << "(";
	const char *start_of_text = textinfo.thetext.value();
	while (*start_of_text) {
		if ((*start_of_text == '(') || (*start_of_text == ')') || (*start_of_text == '\\')) {
			buffer << '\\';
		}
		buffer << *start_of_text;
		start_of_text++;
	}
	buffer << ") \"" << endl;
//    buffer << ") Tj"  << endl;
	// endtext(); // not done here to avoid ET BT, done on demand 
}