⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mainserv.c

📁 这是一个linux下基于MiniGUI的手机界面设计源码
💻 C
📖 第 1 页 / 共 5 页
字号:
				newLoc.dwxx.minute,				newLoc.dwxx.second); 				SetWindowText (locatetime_loclocate, buffer);//显示时间							}			Pthread_mutex_unlock(&newLoc_Mutex);			break;	case MUTIPLE:			printf("-------New thread AcceptLoc Enter!---------------------------------\n");			while( startLocFlag == LOCSTART )//when we press the "Start",it setted to  			{					 //LOCSTART;we press "End" the value is LOCSTOP					Pthread_mutex_lock(&newLoc_Mutex);				//printf("Enter new thread newLoc.flag is %d\n",newLoc.flag );				//printf("Enter new thread startLocFlag is %d\n",startLocFlag );				//printf("Enter new thread LOCSTART is %d\n",LOCSTART );				while ( (newLoc.flag == 0) && (startLocFlag == LOCSTART) )					Pthread_cond_wait( &newLoc_cond, &newLoc_Mutex );				if( startLocFlag == LOCSTART)					newLoc.flag--;				else if( startLocFlag == LOCSTOP )				{					newLoc.usable = FALSE;					printf("-------New thread AcceptLoc jump the while!---------\n");					Pthread_mutex_unlock(&newLoc_Mutex);					break;				}				if( ENQUE_CIRNEWLOC ( newLoc ) )					printf("Successful to enter circular queue\n");				else					printf("Unsuccessful to enter circular queue\n");				printf("After In thread AcceptLoc newLoc.flag is %d\n",newLoc.flag );				if( win_locOpen == WIN_LOCOPEN || win_reportOpen == WIN_REPORTOPEN  )				{					//Flush the window					printf("Flush the window!\n");					ShowByDaDi (J_hwndedit_loclocate ,W_hwndedit_loclocate,					newLoc.dwxx.longitude , 					newLoc.dwxx.latitude) ;//显示"经度""纬度"													ShowHighByDaDiGao (locatehight_loclocate,locateErr_loclocate ,					newLoc.dwxx.height,					newLoc.dwxx.abnormalHeigtht,					newLoc.dwxx.normalSign,					newLoc.dwxx.abnormalSign);//显示"高程"""高程误差" 				 					sprintf(buffer ,"%4d-%2d-%2d %2d:%2d:%2d",					newLoc.dwxx.year,					newLoc.dwxx.mon,					newLoc.dwxx.day,					newLoc.dwxx.hour,					newLoc.dwxx.minute,					newLoc.dwxx.second); 					SetWindowText (locatetime_loclocate, buffer);//显示时间								}				Pthread_mutex_unlock(&newLoc_Mutex);				newLoc.usable = FALSE;			}			printf("-------New thread AcceptLoc Leave!---------------------------------\n");			break;	case EMERGENCY:			printf("-------New thread AcceptLoc Enter!---------------------------------\n");			Pthread_mutex_lock(&newLoc_Mutex);						while ( newLoc.flag == 0 )			Pthread_cond_wait( &newLoc_cond, &newLoc_Mutex );			newLoc.flag--;			newLoc.usable = TRUE;			printf("After In thread AcceptLoc newLoc.flag is %d\n",newLoc.flag );			if( win_locOpen == WIN_LOCOPEN || win_reportOpen == WIN_REPORTOPEN )			{				//Flush the window				printf("Flush the window!\n");				ShowByDaDi (J_hwndedit_loclocate ,W_hwndedit_loclocate,				newLoc.dwxx.longitude , 				newLoc.dwxx.latitude) ;//显示"经度""纬度"												ShowHighByDaDiGao (locatehight_loclocate,locateErr_loclocate ,				newLoc.dwxx.height,				newLoc.dwxx.abnormalHeigtht,				newLoc.dwxx.normalSign,				newLoc.dwxx.abnormalSign);//显示"高程"""高程误差" 				 				sprintf(buffer ,"%4d-%2d-%2d %2d:%2d:%2d",				newLoc.dwxx.year,				newLoc.dwxx.mon,				newLoc.dwxx.day,				newLoc.dwxx.hour,				newLoc.dwxx.minute,				newLoc.dwxx.second); 				SetWindowText (locatetime_loclocate, buffer);//显示时间			}						Pthread_mutex_unlock(&newLoc_Mutex);			printf("-------New thread AcceptLoc Leave!---------------------------------\n");						break;		}	startLocFlag = LOCSTOP;			}void ObtainSendLocArg( LOCTYPE locType  ){		char buff[10];								//(char *)GetUserID();		memset(sendArg.srcID, '\0', 10);		memcpy(sendArg.srcID, "105006", 6);		printf("MUTIPLEReportLoc sendArg.srcID %s \n",sendArg.srcID);		GetLocSet (  &pLocSet );		sendArg.cmd  ="$DWSQ";		sendArg.fixedLen = LEN_OF_DWSQ;		sendArg.length = 0;					dwsq->altimetryMode = pLocSet->ceGaoMode;		printf("^^^^^^^^^^^dwsq->altimetryMode is %d^^^^^^^^^\n",dwsq->altimetryMode);		dwsq->heightType = pLocSet->heightMode; 		printf("^^^^^^^^^^^dwsq->heightType is %d^^^^^^^^^\n",dwsq->heightType); 						snprintf (buff,sizeof(buff),"%ld", pLocSet->tianXian );		memset( dwsq->antAltitude ,'\0',10); 		memcpy(dwsq->antAltitude, buff, 8); 		printf("======dwsq->antAltitude====%s==\n",dwsq->antAltitude);				dwsq->loc_AltitudeSign = pLocSet->loc_AltitudeSign; 		snprintf (buff,sizeof(buff),"%ld", pLocSet->height );		memset( dwsq->locAltitude ,'\0',10);  		memcpy(dwsq->locAltitude, buff, 8); 		printf("======dwsq->locAltitude====%s==\n",dwsq->locAltitude); 			   		dwsq->temperatureValSign = pLocSet->temperatureValSign; 		snprintf (buff,sizeof(buff),"%ld", pLocSet->temper );		memset( dwsq->temperature ,'\0',10);   		memcpy(dwsq->temperature, buff, 8); 		printf("======dwsq->temperature====%s==\n",dwsq->temperature); 			
		snprintf (buff,sizeof(buff),"%ld", pLocSet->qiYa );		memset( dwsq->airPressure ,'\0',10); 		memcpy(dwsq->airPressure, buff, 8); 		printf("======dwsq->airPressure====%s==\n",dwsq->airPressure); 				if( locType == MUTIPLE )		{			snprintf (buff,sizeof(buff),"%d", GetMutiReportFreq( ));			memset( dwsq->commFrequency ,'\0',10); 			memcpy(dwsq->commFrequency, buff, 6); 						}		else		{			snprintf (buff,sizeof(buff),"%d", 0 );			memset( dwsq->commFrequency ,'\0',10); 			memcpy(dwsq->commFrequency, buff, 6);		}		sendArg.dwsq = dwsq;		printf("======dwsq->airPressure====%s==\n",dwsq->airPressure);  		printf("======sendArg.dwsq->locAltitude====%s==\n",sendArg.dwsq->locAltitude);  		printf("======dwsq->locAltitude====%s==\n",dwsq->locAltitude); 		}void SingleReportLoc( void ){	memset(sendArg.srcID, '\0', 210);	sprintf (buffer1, "latitude  %d %02d' %d\"  longitude %d %02d' %d\" ",	newLoc.dwxx.latitude.du, 	newLoc.dwxx.latitude.fen, 	newLoc.dwxx.latitude.miao,	newLoc.dwxx.longitude.du, 	newLoc.dwxx.longitude.fen, 	newLoc.dwxx.longitude.miao );			if( newLoc.dwxx.normalSign == 0 )	{		sprintf (buffer ," height %10ld",newLoc.dwxx.height );	}	else	{		sprintf (buffer ," height -%10ld",newLoc.dwxx.height );	}	strcat( buffer1, buffer);			if( newLoc.dwxx.abnormalSign == 0 )	{		sprintf (buffer ," abnormalHeigtht +%2d",newLoc.dwxx.abnormalHeigtht );	}	else	{		sprintf (buffer ," abnormalHeigtht -%2d",newLoc.dwxx.abnormalHeigtht );	}	strcat( buffer1, buffer);				printf("---Sended SingleReportLoc is %s\n",buffer1);	memset(sendArg.srcID, '\0', 10);	memcpy(sendArg.srcID, "105006", 6);
	sendArg.cmd  ="$TXSQ";
	sendArg.txsq = txsq;
	sendArg.fixedLen = LEN_OF_TXSQ;
	sendArg.length = convert(buffer1,&(sendArg.txsq->content), 1);	CheckTidCount();
	Pthread_create( &tid_Processing[tidProcessing], &attr, SendDataGram, NULL);	}void *MutiReportLoc( void *arg ){	printf("*------New thread MutiReportLoc Enter!---------------------------******\n");	while( startLocFlag == LOCSTART )//when we press the "Start",it setted to  	{					 //LOCSTART;we press "End" the value is LOCSTOP		if( DEQUE_CIRNEWLOC( &repLoc ) != 0)		{			memset(sendArg.srcID, '\0', 210);			sprintf (buffer1, "latitude  %d %02d' %d\"  longitude %d %02d' %d\" ",		 	repLoc->dwxx.latitude.du, 		 	repLoc->dwxx.latitude.fen, 		 	repLoc->dwxx.latitude.miao,		 	repLoc->dwxx.longitude.du, 		 	repLoc->dwxx.longitude.fen, 		 	repLoc->dwxx.longitude.miao );					if( repLoc->dwxx.normalSign == 0 )			{				sprintf (buffer ,"height %10ld",repLoc->dwxx.height );			}			else			{				sprintf (buffer ,"height -%10ld",repLoc->dwxx.height );			}			strcat( buffer1, buffer);					if( repLoc->dwxx.abnormalSign == 0 )			{				sprintf (buffer ,"abnormalHeigtht +%2d",repLoc->dwxx.abnormalHeigtht );			}			else			{				sprintf (buffer ,"abnormalHeigtht -%2d",repLoc->dwxx.abnormalHeigtht );			}			strcat( buffer1, buffer);						printf("---Sended MutiReportLoc is %s\n",buffer1);			memset(sendArg.srcID, '\0', 10);			memcpy(sendArg.srcID, "105006", 6);
			sendArg.cmd  ="$TXSQ";
			sendArg.txsq = txsq;
			sendArg.fixedLen = LEN_OF_TXSQ;
			sendArg.length = convert(buffer1,&(sendArg.txsq->content), 1);
						SendDataGram( NULL );		}			printf(" GetMutiReportFreq () is %d\n",GetMutiReportFreq ());			sleep( GetMutiReportFreq () );	}		printf("-------New thread ReportLoc Leave!---------------------------------\n");	/* We shall flush the circular buffer after MutiReportLoc */	INIT_CIRNEWLOC( ) ;}int GetBoShuStat( unsigned char value ){	switch( value )	{		case 0x00:						return 0;			break;		case 0x01:						return 1;			break;		case 0x02:					return 2;			break;		case 0x03:					return 3;			break;		case 0x04:					return 4;			break;	}}void *Consume( void *arg ) {	int		i,j=0,signal=0;	/* For Debug */static int counter=0,cnt=0,oFlowSymbol=0;	static 	FILE	*fp;	BOSHU *pBoShu;	MYSHM *ptr=(MYSHM *)arg;	while( 1 )	{		Pthread_mutex_lock(&ptr->nready_mutex);		while (ptr->nready == 0)			Pthread_cond_wait(&ptr->cond, &ptr->nready_mutex);		ptr->nready--;		Pthread_mutex_unlock(&ptr->nready_mutex);		/******There is no need for the following line*****/		Pthread_mutex_lock(&ptr->curMesg_mutex);		switch( ptr->currentMesg )		{		case TYPE_OF_DWXX:									ptr->dwxx.year = currTime.year;			ptr->dwxx.mon = currTime.mon;			ptr->dwxx.day = currTime.mday;			//printf("year:%d,mon:%d,day:%d\n",ptr->dwxx.year,ptr->dwxx.mon,ptr->dwxx.day);			//printf("Hour:%d,Minute:%d,DESID:%X\n",ptr->dwxx.hour,ptr->dwxx.minute,ptr->dwxx.srcID);			newMesg.dwxx = ptr->dwxx;			AutoRecord( TYPE_OF_DWXX );			//perror("Error occured for");			/* For Debug*/counter++;						/* Flush the display of the opend Loc or locReport windows */			if( startLocFlag == LOCSTART )			{				printf("Now Enter thread Consume to reflush the window!\n" );				Pthread_mutex_lock(&newLoc_Mutex);				printf("Before In thread Consume  newLoc.flag == %d\n",newLoc.flag);				signal = (newLoc.flag == 0);								newLoc.flag++;				printf("After In thread Consume newLoc.flag is %d\n",newLoc.flag );				newLoc.dwxx = ptr->dwxx;				Pthread_mutex_unlock( &newLoc_Mutex );								if(signal)				Pthread_cond_signal(&newLoc_cond);			}							//if( counter==4)			//	return NULL;			printf("counter is %d\n",counter);						break;		case TYPE_OF_TXXX:			//Check if the situation of overflowing happened 			Pthread_mutex_lock(&numOverFlow_Mutex);			cnt = ++numOverFlow;			Pthread_mutex_unlock(&numOverFlow_Mutex);			oFlowSymbol = GetOverFlowBit( );			if( cnt <= AUTOROLLVAL_TX &&  oFlowSymbol == FALSE)			{								AddCountNMesg( 1 );							printf("SRCID is %X\n",ptr->txxx.srcID);							newMesg.txIndex.hour = ptr->txxx.hour;				newMesg.txIndex.minute = ptr->txxx.minute;
				newMesg.txIndex.srcID = ptr->txxx.srcID;
				newMesg.txIndex.contentLen = ptr->txxx.contentLen;							newMesg.txIndex.lockSymbol = 0;
				newMesg.txIndex.CRC_Sign = ptr->txxx.CRC_Sign;
				newMesg.txIndex.chType = ptr->txxx.chType;
				newMesg.txIndex.commType = ptr->txxx.commType;
				newMesg.txIndex.isSecretKey = ptr->txxx.isSecretKey;								if( ptr->txxx.contentLen <= 20 )				{				//only stored the whole message in file F_TXINDEX				memcpy( newMesg.txIndex.message, ptr->txxx.message,20);				printf("New message Content is %s\n",newMesg.txIndex.message);				newMesg.txIndex.mainIndex = -1;							}				else				{					/* divide the message to two parts,one of it is the      */					/* content the other part is the indexer of the message  */ 					memcpy( newMesg.txIndex.message, ptr->txxx.message,20);					newMesg.txIndex.mainIndex = AddCountMain( INBOX, 1 );					/* Add the big data block to file TXMAIN.data*/					if( GetCountMain( INBOX ) <= AUTOROLLVAL_TX )					{						fp = Fopen( "TXMAIN.data","a+");						Fwrite( &(ptr->txxx.message),MAXSIZE,1,fp );						Fclose( fp );					}					else					{						if( (i = DEQUEUE( INBOX )) != 0)						{							fp = Fopen( "TXMAIN.data","a+");							fseek( fp, (i-1)*MAXSIZE, SEEK_SET );							Fwrite( &(ptr->txxx.message),MAXSIZE,1,fp );							Fclose( fp );						}						else if( i == 0)						{							printf("****Fail to get data from empty queue****\n");						}					}									}				AutoRecord( TYPE_OF_TXXX );								if( newMesg.txIndex.CRC_Sign == 0x01 )				{					ShowErrs( ALARM_CRC );					alarmFlag[CRC_ERR] = 1;					}				printf("**************************************************************\n");						}			else if( cnt>AUTOROLLVAL_TX || oFlowSymbol == TRUE)//Not enough space to stored the new,it's overflow so just buffer it to show			{			printf("Not enough space to stored the new,it's overflow so just buffer it to show!\n");				if( oFlowSymbol == FALSE)					SetOverFlowBit( TRUE );				Pthread_mutex_lock( &nStaCount_Mutex );				Pthread_mutex_lock( &cntOverFlow_Mutex );				if( overFlowStarter == 0 )				{					overFlowStarter = 	messageStatusCount+1;					}							cntOverFlow++;							Pthread_mutex_unlock( &cntOverFlow_Mutex );				Pthread_mutex_unlock( &nStaCount_Mutex );				printf("!!!!!!!!!!!!!!!!overFlowStarter  cntOverFlow-- %d %d\n",overFlowStarter,cntOverFlow);				ENQUE_CIROVERFLOW( ptr->txxx );							}			/* For Debug*/counter++;			/* Notify the user by flushing the interface */			ShowMessage ( HAS_INFOMATION );						//if( counter==4)			//	return NULL;			printf("counter is %d\n",counter);			break;		case TYPE_OF_ICXX:					printf("BroadcastID is %X\n",ptr->icxx.broadcastID);			newMesg.icxx = ptr->icxx;			AutoRecord( TYPE_OF_ICXX );			/*SetServFreq (int serv);*/						break;		case TYPE_OF_ZJXX:			printf("ElecQuantity is %f\n",ptr->zjxx.elecQuantity);			/* Print the Value of each member of ZJXX */						/* Obtain the elecQuantity value */			zjInfo.elecQuantity = ptr->zjxx.elecQuantity;			if( zjInfo.elecQuantity>= 0 &&  zjInfo.elecQuantity<= 0.2 )			{				ShowCell( 0, 1 , 1);			}			else if( zjInfo.elecQuantity> 0.2 &&  zjInfo.elecQuantity<= 0.4 )			{				ShowCell( 0, 2 , 1);			}			else if( zjInfo.elecQuantity> 0.4 &&  zjInfo.elecQuantity<= 0.6)			{				ShowCell( 0, 3 , 1);			}			else if( zjInfo.elecQuantity> 0.6 &&  zjInfo.elecQuantity<= 0.8)			{				ShowCell( 0, 4 , 1);			}			else if( zjInfo.elecQuantity> 0.8 &&  zjInfo.elecQuantity<= 1.0)			{				ShowCell( 0, 5 , 1);			}			/* Obtain the PowerStat value */			zjInfo.powerStat[0] = GetBoShuStat (ptr->zjxx.fstPowerStat );
			zjInfo.powerStat[1] = GetBoShuStat (ptr->zjxx.secPowerStat );
			zjInfo.powerStat[2] = GetBoShuStat (ptr->zjxx.thrPowerStat );
			zjInfo.powerStat[3] = GetBoShuStat (ptr->zjxx.forPowerStat );
			zjInfo.powerStat[4] = GetBoShuStat (ptr->zjxx.fifPowerStat );
			zjInfo.powerStat[5] = GetBoShuStat (ptr->zjxx.sixPowerStat

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -