Esempio n. 1
0
AiSelector::AiSelector(QWidget * parent, Qt::WindowFlags f)
{
    Q_UNUSED(parent)
    Q_UNUSED(f)

    ui.setupUi(this);
#if QT_NO_DEBUG
    #ifdef Q_OS_X11
    darknocksBrain::PatternSet pSet("/usr/share/darknock/data/input");
    #endif
    #ifdef Q_OS_MAC
    //TODO: use bundle Resources path
    darknocksBrain::PatternSet pSet("/usr/share/darknock/data/input");
    #endif
    #ifdef Q_OS_WIN
    darknocksBrain::PatternSet pSet("data/input");
    #endif
#else
    #ifdef Q_OS_MAC
    darknocksBrain::PatternSet pSet("../Resources/data/input");
    #else
    darknocksBrain::PatternSet pSet("data/input");
    #endif
#endif

    hamming = new darknocksBrain::Hamming(&pSet);

    connect(ui.horizontalSlider, SIGNAL(sliderReleased()), this, SLOT(updateAi()));
    connect(ui.checkBox, SIGNAL(stateChanged(int)), this, SLOT(checkChange()));
    connect(ui.checkBoxBlur, SIGNAL(stateChanged(int)), this, SLOT(checkBlurChange()));
    connect(ui.previewLabel, SIGNAL(dragingFinished()), this, SLOT(updateAi()));
}
Esempio n. 2
0
void cclnt_parse_pkt(unsigned char *pBuf) 
{
	int nType = 0;
	//CCMS_PKT_T *pPkt;
	//CCMS_PKT_ACK_T *pAck;
	CCMS_PKT_SET_T *pSetT;
	//int nRtnSend = 0;
	//unsigned char chTxBuf[32];
	//point_info point;
	//unsigned short wRemoteId = 0;
	//unsigned char chPcm = 0;
	//unsigned char chPno = 0;
	//unsigned short wValue = 0;

	nType = pBuf[1];

	switch (nType) {
	// Notice Packet.
	case 'S':
		pSetT = (CCMS_PKT_SET_T *)pBuf;
		if ( pSetT->chStx == '<' && pSetT->chEtx == '>') {
			fprintf( stdout, "Set = %d, %d, %d \n", 
					 pSetT->chPcm,
					 pSetT->chPno,
					 pSetT->wData);
			fflush( stdout );

			pSet(pSetT->chPcm, pSetT->chPno, pSetT->wData);
		}
		break;
	}	
}
Esempio n. 3
0
bool ParameterSet::Write2XML(TiXmlNode& root)
{
	TiXmlElement pSet("ParameterSet");
	//pSet.SetAttribute("QtyParameter",(int)vParameter.size());
	for (size_t i=0;i<vParameter.size();++i) vParameter.at(i)->Write2XML(pSet);

	root.InsertEndChild(pSet);
	return true;
}
Esempio n. 4
0
void daegu_get_grpnum(int n_idx) 
{

	int n_pno = g_UnitData[n_idx].pno;

	g_UnitData[n_idx].group = pGet(GHP_GROUP_PCM, n_pno);

	// 학사모드는 모드가 항상 "시간"으로 되어야 한다.
	if (g_UnitData[n_idx].group == 0) {
		pSet(GHP_GROUP_MODE_PCM, g_UnitData[n_idx].pno, 1);
		g_UnitData[n_idx].group_mode = 1;
		return;
	}

	if ( g_UnitData[n_idx].group > 10 ) {
		pSet(GHP_GROUP_PCM, n_pno, 10);
		g_UnitData[n_idx].group = pGet(GHP_GROUP_PCM, n_pno);
	}
}
Esempio n. 5
0
void Write_Error_Table(int block_number, int point_number, int val)
/****************************************************************/
{
	int pno = 0;
	
	for( pno = 0; pno < g_unitCnt; pno++) {
		if(block_number == g_UnitData[pno].block) {

			if ( g_dbgShow ) {
				printf("Pset Error(%d %d 1)\n", GHP_ERROR_PCM,  pno);
				printf("Pset Error(%d %d 1)\n", GHP_ERROR_NUM_PCM,  pno);
			}

			pSet(GHP_ERROR_PCM, pno, 1); 
			pSet(GHP_ERROR_NUM_PCM, pno, 1); 
			
			prePtbl[GHP_ERROR_PCM][pno] = 1;
			prePtbl[GHP_ERROR_NUM_PCM][pno] = 1;	

			continue;
		}
	}	
}
Esempio n. 6
0
void IfaceModem_On_Recv_Parse(IfaceModem_T *p)
{
	int i = 0;
	unsigned char *pBuf;
	int nPcm = 0;
	int nPno = 0;
	int nValue = 0;

	/* Initialize */
	pBuf = (unsigned char *) p->rxbuf;	
	
	printf("RX(%d) = ", p->recvLength);
	for (i = 0; i < p->recvLength ;i++) {
		printf("%c ", pBuf[i]);	
	}
	printf("\n");
	
	
	for (i = 0; i < p->recvLength ;i++) {
		if ( pBuf[i] == 'A' &&  pBuf[i+1] == 'D' 
			&& pBuf[i+2] == 'D' &&  pBuf[i+3] == 'A'
			&& pBuf[i+4] == 'T' &&  pBuf[i+5] == 'A' ) {
				printf(">> pBuf[i+6] = %c\n", pBuf[i+6]);
				printf(">> pBuf[i+7] = %c\n", pBuf[i+7]);
				printf(">> pBuf[i+8] = %c\n", pBuf[i+8]);
				printf(">> pBuf[i+9] = %c\n", pBuf[i+9]);
				printf(">> pBuf[i+10] = %c\n", pBuf[i+10]);
				printf(">> pBuf[i+11] = %c\n", pBuf[i+11]);
				printf(">> pBuf[i+12] = %c\n", pBuf[i+12]);
				printf(">> pBuf[i+13] = %c\n", pBuf[i+13]);
				printf(">> pBuf[i+14] = %c\n", pBuf[i+14]);
				printf(">> pBuf[i+15] = %c\n", pBuf[i+15]);

				if ( pBuf[i+6] == '=' && pBuf[i+7] == '0' && pBuf[i+9] == '0' ) {		
					nPcm = pBuf[i+8] - 0x30;
					nPno = pBuf[i+10] - 0x30;
					nValue = pBuf[i+14] - 0x30;
					pSet(nPcm, nPno, nValue);
				}
			}
	}	
}
Esempio n. 7
0
void dbsvr_handler(DBSVR_T *p, int nLength)
{
	DBSVR_ACK_MSG_T *pMsg;

	if ( nLength != sizeof(DBSVR_ACK_MSG_T) ) {
		return;
	}

	pMsg = (DBSVR_ACK_MSG_T *)p->rxbuf;


	if ( pMsg->stx == '<' && pMsg->etx == '>' ) {
		if ( pMsg->pcm == 0xffff &&  pMsg->pno == 0xffff ) {
			return;
		}

		pSet(pMsg->pcm, pMsg->pno, pMsg->value);
		fprintf( stdout, "%x %x %x \n", 
				 pMsg->pcm, pMsg->pno, pMsg->value);
		fflush( stdout );
	}
}
Esempio n. 8
0
void daegu_while(void)
{
	int i = 0;
	//int j = 0;
	int st = 0;												// Fsm status
	int result = 0;
	int n_val = 0;											// value
	int n_tempval = 0;										// Temp value		
	//int n_chkval = 0;										// check value
	int now_time = 0 ;
	int set_time = 0;
	int n_loopcnt = 0;
	struct timeval diff_time;
	time_t     tm_nd;
	unsigned int n_temp_minute = 0;
	struct tm *tm_ptr;

	
	st = ST_GET_POLLING;

	while (1) {
		//IfaceGhpSelectSleep(1, 0);
		//continue;

		// 대구대학교 스케쥴
		for (i = 0; i < g_unitCnt; i++) {
			daegu_TimeSched_Make(i);
			daegu_TimeSched_Execution(i);
		}
		
		// 1분마다 시간을 Point에 기록한다.		
		time(&tm_nd);
		tm_ptr = localtime(&tm_nd);
		fprintf(stdout, " >> TIME  %d, %d \n", tm_ptr->tm_hour, tm_ptr->tm_min);
		fflush(stdout);	
		now_time = (tm_ptr->tm_hour * 100) +  tm_ptr->tm_min; 
		n_tempval = pGet(GHP_MODE_STATUS_PCM, 250);
		if ( n_tempval != now_time ) {
			pSet(GHP_MODE_STATUS_PCM, 250, now_time);
			pSet(GHP_MODE_STATUS_PCM, 251, now_time);
			set_time = now_time;
		}


		// GHP 값을 읽어오거나 제어한다. 
		switch (st) {
			case ST_GET_POLLING:
				result = Send_Polling();
				switch(result)
				{
					case POLL_REQUIRE_STARTUP:	
						st = ST_STARTUP;	
						break;
					
					case POLL_EMPTY_DATA:
					case POLL_OK:		
						if (Send_Polling() == POLL_REQUIRE_STARTUP) {
							st = ST_STARTUP;	
							break;
						}
						else {
							st = ST_CHK_USER_CONTROL;
							break;
						}
					
					default: 
						st = ST_CHK_USER_CONTROL;
						break;
				}
				break;

			case ST_CHK_USER_CONTROL:
				CheckUserControl();
				st = ST_GET_USER_CONTROL;
				break;

			case ST_GET_USER_CONTROL:
				while(Do_User_Control()) {

					if (Send_Polling() == POLL_REQUIRE_STARTUP) {
						st = ST_STARTUP;	
						break;
					}
				}
				st = ST_GET_GHP_UNIT;
				break;

			case ST_GET_GHP_UNIT:
				Get_Ghp_Unit();
				if (Send_Polling() == POLL_REQUIRE_STARTUP) {
					st = ST_STARTUP;	
					break;
				}   
				st = ST_GET_POLLING;
				break;

			case ST_STARTUP:
				Startup_SDDC();
				st = ST_GET_POLLING;
				break;

			default:
				st = ST_GET_POLLING;
				break;
		}


		if ( n_loopcnt++ > 60 ) {
			n_loopcnt = 0;
			system( "hwclock --hctosys" );
		}
		
		// 사용자의 시간설정을 처리한다. 
		n_tempval = pGet(GHP_MODE_STATUS_PCM, 251);
		if ( n_tempval != set_time ) {
			fprintf(stdout, " >> SET TIME  %d \n", n_tempval);
			fflush(stdout);	

			if ( n_tempval > set_time ) {
				n_temp_minute = set_time % 100;
				
				set_time = set_time - n_temp_minute;
								
				n_val = ((n_tempval - set_time) / 100) * 3600;
				fprintf(stdout, " >> hour  %d \n", n_val);
				n_val += ((n_tempval - set_time) % 100) * 60;
				fprintf(stdout, " >> minute  %d \n", n_val);

				gettimeofday( &diff_time, NULL );
				//fprintf(stdout, " >> diff_time.tv_sec  %d \n", diff_time.tv_sec);
				diff_time.tv_sec = diff_time.tv_sec + n_val - (n_temp_minute * 60);
				settimeofday( &diff_time, NULL );
				//fprintf(stdout, " >> ++ diff_time.tv_sec  %d \n", diff_time.tv_sec);
				fflush(stdout);
			}
			
			if ( n_tempval < set_time ) {
				n_temp_minute = set_time % 100;
				
				set_time = set_time - n_temp_minute;
				
				n_val = ((set_time - n_tempval) / 100) * 3600;
				fprintf(stdout, " >> hour  %d \n", n_val);
				n_val += ((set_time - n_tempval) % 100) * 60;
				fprintf(stdout, " >> minute  %d \n", n_val);
				
				
				if ( ((set_time - n_tempval) % 100) > 60 ) {
					n_val -= 40 * 60;
				}

				gettimeofday( &diff_time, NULL );
				//fprintf(stdout, " >> diff_time.tv_sec  %d \n", diff_time.tv_sec);
				diff_time.tv_sec = diff_time.tv_sec - n_val - (n_temp_minute * 60);
				settimeofday( &diff_time, NULL );
				//fprintf(stdout, " >> -- diff_time.tv_sec  %d \n", diff_time.tv_sec);
				fflush(stdout);
			}

			pSet(GHP_MODE_STATUS_PCM, 251, n_tempval);
			set_time = n_tempval;

			// 현장에서 테스트 할것..
			system( "hwclock --systohc" );
		}
	}
}
void SpectralLibraryMatchResults::locateSignaturesInScene()
{
   const RasterElement* pRaster = getRasterElementForCurrentPage();
   if (pRaster == NULL)
   {
      Service<DesktopServices>()->showMessageBox("Spectral Library Match",
         "Unable to determine the RasterElement for the current page.");
      return;
   }

   // get selected signatures
   std::vector<Signature*> signatures = getSelectedSignatures();
   if (signatures.empty())
   {
      Service<DesktopServices>()->showMessageBox("Spectral Library Match",
         "No signatures are selected to be located.");
      return;
   }

   ModelResource<SignatureSet> pSet("Match Result signatures", const_cast<RasterElement*>(pRaster));
   for (std::vector<Signature*>::iterator it = signatures.begin(); it != signatures.end(); ++it)
   {
      pSet->insertSignature(*it);
   }

   // get default algorithm
   SpectralLibraryMatch::LocateAlgorithm locateAlg = StringUtilities::fromXmlString<
      SpectralLibraryMatch::LocateAlgorithm>(SpectralLibraryMatchOptions::getSettingLocateAlgorithm());

   // get default threshold
   double threshold(0.0); 
   switch (locateAlg)
   {
   case SpectralLibraryMatch::SLLA_CEM:
      threshold = SpectralLibraryMatchOptions::getSettingLocateCemThreshold();
      break;

   case SpectralLibraryMatch::SLLA_SAM:
      threshold = SpectralLibraryMatchOptions::getSettingLocateSamThreshold();
      break;

   case SpectralLibraryMatch::SLLA_WBI:
      threshold = SpectralLibraryMatchOptions::getSettingLocateWbiThreshold();
      break;

   default:
      VERIFYNRV_MSG(false, "Unknown value for Spectral Library Match locate algorithm");
   }

   std::string layerName;
   AoiElement* pAoi(NULL);
   if (SpectralLibraryMatchOptions::getSettingDisplayLocateOptions())
   {
      LocateDialog dlg(pRaster, Service<DesktopServices>()->getMainWidget());
      if (dlg.exec() != QDialog::Accepted)
      {
         return;
      }
      locateAlg = dlg.getLocateAlgorithm();
      threshold = dlg.getThreshold();
      layerName = dlg.getOutputLayerName();
      pAoi = dlg.getAoi(); 
   }

   std::string plugInName;
   switch (locateAlg)
   {
   case SpectralLibraryMatch::SLLA_CEM:
      plugInName = "CEM";
      break;

   case SpectralLibraryMatch::SLLA_SAM:
      plugInName = "SAM";
      break;

   case SpectralLibraryMatch::SLLA_WBI:
      plugInName = "Wang-Bovik Index";
      break;

   default:
      VERIFYNRV_MSG(false, "Unknown value for Spectral Library Match locate algorithm");
   }

   if (layerName.empty())
   {
      layerName = "Spectral Library Match Locate Results - ";
      switch (locateAlg)
      {
      case SpectralLibraryMatch::SLLA_CEM:
         layerName += "CEM";
         break;

      case SpectralLibraryMatch::SLLA_SAM:
         layerName += "SAM";
         break;

      case SpectralLibraryMatch::SLLA_WBI:
         layerName += "WBI";
         break;

      default:
         VERIFYNRV_MSG(false, "Unknown value for Spectral Library Match locate algorithm");
      }
   }

   ExecutableResource pLocate(plugInName);
   pLocate->getInArgList().setPlugInArgValue(Executable::DataElementArg(), const_cast<RasterElement*>(pRaster));
   pLocate->getInArgList().setPlugInArgValue("Target Signatures", static_cast<Signature*>(pSet.get()));
   pLocate->getInArgList().setPlugInArgValue("Threshold", &threshold);
   pLocate->getInArgList().setPlugInArgValue("AOI", pAoi);
   bool display(true);
   pLocate->getInArgList().setPlugInArgValue("Display Results", &display);
   pLocate->getInArgList().setPlugInArgValue("Results Name", &layerName);
   pLocate->execute();
}
Esempio n. 10
0
void elba_parsing (unsigned char *pBuf)
// ----------------------------------------------------------------------------
// PARSING MESSAGE
// Description	: Message를 parsing 한다. 
// 
// Arguments	: pBuf				Is a pointer to the receive message buffer 
// Returns		: none
{
	//int i = 0;
	int nIsTimeMsg = 0;
	int nType = 0;
	point_info sPoint;
	struct timeval set_time;
	time_t     tm_st;
	time_t     tm_nd;
	double     d_diff;
	struct tm  user_stime;	
	

	nType = pBuf[8];
	nIsTimeMsg = pBuf[5];

	if ( nIsTimeMsg == 0x0f ) {
		if ( nType == 0x40 ) {
			// 기준이 되는 시간. 1970-01-01 00:00
			user_stime.tm_year   = 1970 - 1900;   // 주의 :년도는 1900년부터 시작
			user_stime.tm_mon    = 1      -1;      // 주의 :월은 0부터 시작
			user_stime.tm_mday   = 1;
			user_stime.tm_hour   = 0;
			user_stime.tm_min    = 0;
			user_stime.tm_sec    = 0;
			user_stime.tm_isdst  = 0;              // 썸머 타임 사용 안함
			tm_st = mktime( &user_stime );
			
			user_stime.tm_year   = (2000 + pBuf[12])  -1900;   // 주의 :년도는 1900년부터 시작
			user_stime.tm_mon    = (int)pBuf[13] - 1;      // 주의 :월은 0부터 시작
			user_stime.tm_mday   = (int)pBuf[14];
			user_stime.tm_hour   = (int)pBuf[15];
			user_stime.tm_min    = (int)pBuf[16];
			user_stime.tm_sec    = 0;
			user_stime.tm_isdst  = 0;              // 썸머 타임 사용 안함
			tm_nd = mktime( &user_stime );	
			
			d_diff   = difftime( tm_nd, tm_st );
			fprintf( stdout, "[Time Set] d_diff %f \n",	d_diff );
			gettimeofday( &set_time, NULL );
			set_time.tv_sec = (long)d_diff;
			fprintf( stdout, "[Time Set] set_time.tv_sec %ld \n", set_time.tv_sec );
			settimeofday( &set_time, NULL );
			fprintf( stdout, "[Time Set] %d-%d-%d %d:%d \n", 
					 pBuf[12], pBuf[13], pBuf[14], pBuf[15], pBuf[16] );
			fflush( stdout);

			system( "hwclock --systohc" );
		}						
		
		if ( gc_view_elba ) {
			fprintf(stdout, "\nGet Time  ");
			fflush(stdout);
		}		
		return;		
	}

	switch (nType) {
	// Request Message
	// ex message > 0x7b 0x48 0x45 0x41 0x44 0x09 0xfe 0xfe 0x00 0x08 0xfe 0xfe 0x00 0x01 0xf6 0x15 0x54 0x41 0x49 0x4c 0x7d
	case 0x00:
		// get point information.
		sPoint.pcm = pBuf[12];
		sPoint.pno = pBuf[13];
		pthread_mutex_lock( &pointTable_mutex );
		sPoint.value = g_fExPtbl[sPoint.pcm][sPoint.pno];	
		pthread_mutex_unlock( &pointTable_mutex );
		
		// point_table의 값은 항상 update된 값을 가지고 있는 DB이기 때문에
		// point_table의 값을 바로 올려보내줘도 괜찮을 것이라고 생각한다.
		// 만약 net32가 연결되어 있다면, 
		// Net32는 느린 Device이기 때문에 먼저 3iS에서 요청을 처리하고
		// Queue를 사용해서 새로운 값을 갱신하도록 한다.
		// 그러므로 Net32가 연결되어 있다면, 
		// 3iS의 요청에 의해 2번의 응답을 보내게 되는 것이다.
		
		// only alive pcm
		/*
		for ( i = 0; i < 32; i++ ) {
			if ( g_cNode[i] > 0 && i == sPoint.pcm && sPoint.pcm != g_nMyPcm )	{
				sPoint.message_type = NET32_TYPE_REQUIRE;
				net32_push_queue(&sPoint);		// send to net32_queue	
			}
		}	
		*/
		sPoint.message_type = NET32_TYPE_REQUIRE;
		net32_push_queue(&sPoint);		// send to net32_queue	
		
		sPoint.message_type = NET32_TYPE_REPORT;
		elba_push_queue(&sPoint);			// send to elba queue.

		if ( gc_view_elba ) {
			fprintf(stdout, "\nRequest %d, %d  ", sPoint.pcm, sPoint.pno);
			fflush(stdout);
		}		
		break;
			
	// Commnad Message
	case 0x40:
		// get point information.
		sPoint.pcm = pBuf[12];
		sPoint.pno = pBuf[13];
		memcpy( &sPoint.value, (pBuf + 14), sizeof(float) );
		sPoint.value = elba_change_byte_order(sPoint.value);

		// Interface for PLC
		//pthread_mutex_lock( &plcQ_mutex );
		//putq( &plc_message_queue, &sPoint );
		//pthread_mutex_unlock( &plcQ_mutex );	
		//g_iChkControl = 1;

		// 만약 Net32를 사용한다면, 
		// point_table의 값을 갱신하지 않고 Net32로 data를 보낸다.
		// 하지만 Net32를 사용하지 않는 경우에는, 
		// point_table의 값을 갱신하고 그 값을 3iS로 보낸다.
		sPoint.message_type = NET32_TYPE_COMMAND;
		pSet(sPoint.pcm, sPoint.pno, sPoint.value);
		
		if ( g_nMultiDdcFlag )	{
			pthread_mutex_lock( &pointTable_mutex );
			g_fExPtbl[sPoint.pcm][sPoint.pno] = sPoint.value;
			pthread_mutex_unlock( &pointTable_mutex );
			elba_push_queue(&sPoint);								
		}

		if ( gc_view_elba ) {
			fprintf(stdout, "\nCommand %d, %d  %0.1f", sPoint.pcm, sPoint.pno, sPoint.value);
			fflush(stdout);
		}		
		break;
				
	default:
		break;
	}		
}
Esempio n. 11
0
void Write_Point(int point_number, int pno, int val)
/****************************************************************/
{
	float value = (float)val;
	
	switch(point_number) {
		case 1:		//On Off			
			if (pGet(GHP_ERROR_PCM, pno) > 0 || pGet(GHP_ERROR_NUM_PCM, pno) > 0) {
				pSet(GHP_ONOFF_PCM, pno, 0); 
				pSet(GHP_ONOFF_FAN_PCM, pno, 0); 
				prePtbl[GHP_ONOFF_PCM][pno] = 0;
				prePtbl[GHP_ONOFF_FAN_PCM][pno] = 0;				
				return;
			}
			
			if (prePtbl[GHP_ONOFF_PCM][pno] != g_fExPtbl[GHP_ONOFF_PCM][pno]) {
				if ( g_dbgShow )
					printf("blocking >>>>>>>>>>>>>>>>>>>>\n");
				break;	
			}
			else {				
				pSet(GHP_ONOFF_PCM, pno, value); 
				pSet(GHP_ONOFF_FAN_PCM, pno, value); 
				prePtbl[GHP_ONOFF_PCM][pno] = value;
				prePtbl[GHP_ONOFF_FAN_PCM][pno] = value;
				break;
			}
			break;

		case 4:		//Mode
			if (prePtbl[GHP_ONOFF_PCM][pno] != g_fExPtbl[GHP_ONOFF_PCM][pno]) {
				if ( g_dbgShow )
					printf("blocking >>>>>>>>>>>>>>>>>>>>\n");
				break;	
			}
			else {			
				pSet(GHP_MODE_PCM, pno, value); 
				prePtbl[GHP_MODE_PCM][pno] = value;
				if ( g_dbgShow )
					printf("Pset Mode(%d %d %f)\n", GHP_MODE_PCM, pno, value); 
				break;
			}
		case 2:		//Set temperature
			if (prePtbl[GHP_ONOFF_PCM][pno] != g_fExPtbl[GHP_ONOFF_PCM][pno]) {
				if ( g_dbgShow )
					printf("blocking >>>>>>>>>>>>>>>>>>>>\n");
				break;	
			}
			else {			
				pSet(GHP_SET_TEMP_PCM, pno, value); 
				prePtbl[GHP_SET_TEMP_PCM][pno] = value;
				if ( g_dbgShow )
					printf("Pset SetTemp(%d %d %f)\n ", GHP_SET_TEMP_PCM,  pno, value); 
				break;
			}
			
		case 5:		//Room temperature
			pSet(GHP_TEMP_PCM, pno, value); 
			prePtbl[GHP_TEMP_PCM][pno] = value;
			if ( g_dbgShow ) {
				printf("Pset Temp(%d %d %f)\n ", GHP_TEMP_PCM,  pno, value); 
		
				printf("Pset OnOff(%d %d %f)\n", GHP_ONOFF_PCM,  pno, value);
				printf("Pset OnOff(%d %d %f)\n", GHP_ONOFF_FAN_PCM,  pno, value);
			}
			
			pSet(GHP_ERROR_PCM, pno, 0); 
			pSet(GHP_ERROR_NUM_PCM, pno, 0); 
			
			prePtbl[GHP_ERROR_PCM][pno] = 0;
			prePtbl[GHP_ERROR_NUM_PCM][pno] = 0;					
			
			break;

		case 30:	//Wind Speed
			if (prePtbl[GHP_ONOFF_PCM][pno] != g_fExPtbl[GHP_ONOFF_PCM][pno]) {
				if ( g_dbgShow )
					printf("blocking >>>>>>>>>>>>>>>>>>>>\n");
				break;	
			}
			else {			
				pSet(GHP_WINDSPEED_PCM, pno, value); 
				prePtbl[GHP_WINDSPEED_PCM][pno] = value;
				if ( g_dbgShow )
					printf("Pset Speed(%d %d %f)\n ", GHP_WINDSPEED_PCM,  pno, value); 
				break;
			}

		case 31:	//Wind Direction
			if (prePtbl[GHP_ONOFF_PCM][pno] != g_fExPtbl[GHP_ONOFF_PCM][pno]) {
				if ( g_dbgShow )
					printf("blocking >>>>>>>>>>>>>>>>>>>>\n");
				break;	
			}
			else {			
				// 풍향인 경우에만 값에 1을 빼서 값을 쓴다.
				value = value - 1;
				
				pSet(GHP_WINDDIRECTION_PCM, pno, value);
				prePtbl[GHP_WINDDIRECTION_PCM][pno] = value;
				if ( g_dbgShow )
					printf("Pset Direction(%d %d %f)\n ", GHP_WINDDIRECTION_PCM,  pno, value);  
				break;
			}
		
		#ifdef DAEGU_GHP	
		// Remote mode 1 
		// 실내기 리모콘의 운전/정지 버튼을 제어합니다. 
		case 6:	
			if (prePtbl[GHP_ONOFF_PCM][pno] != g_fExPtbl[GHP_ONOFF_PCM][pno]) {
				if ( g_dbgShow )
					printf("blocking >>>>>>>>>>>>>>>>>>>>\n");
				break;	
			}
			else {			
				pSet(GHP_REMOTE_1_PCM, pno, value);
				prePtbl[GHP_REMOTE_1_PCM][pno] = value;
				if ( g_dbgShow )
					printf("Pset Remote 1 (%d %d %f)\n ", GHP_REMOTE_1_PCM,  pno, value);  
				break;
			}
			break;

		// Remote mode 2 
		// 실내기 리모콘의 온도설정 버튼을 제어합니다. 
		case 7:		
			if (prePtbl[GHP_ONOFF_PCM][pno] != g_fExPtbl[GHP_ONOFF_PCM][pno]) {
				if ( g_dbgShow )
					printf("blocking >>>>>>>>>>>>>>>>>>>>\n");
				break;	
			}
			else {			
				pSet(GHP_REMOTE_2_PCM, pno, value);
				prePtbl[GHP_REMOTE_2_PCM][pno] = value;
				if ( g_dbgShow )
					printf("Pset Remote 2 (%d %d %f)\n ", GHP_REMOTE_2_PCM,  pno, value);  
				break;
			}
			break;

		// Remote mode 3 
		// 실내기 리모콘의 냉난방 버튼을 제어합니다. 
		case 8:		
			if (prePtbl[GHP_ONOFF_PCM][pno] != g_fExPtbl[GHP_ONOFF_PCM][pno]) {
				if ( g_dbgShow )
					printf("blocking >>>>>>>>>>>>>>>>>>>>\n");
				break;	
			}
			else {			
				pSet(GHP_REMOTE_3_PCM, pno, value);
				prePtbl[GHP_REMOTE_3_PCM][pno] = value;
				if ( g_dbgShow )
					printf("Pset Remote 3 (%d %d %f)\n ", GHP_REMOTE_3_PCM,  pno, value);  
				break;
			}
			break;
		#endif

		default:
			pno = 254;	
			value = 0;
			break;
	}
	//printf("Pno (%d), Val (%f)\n", pno, value);  	
}
Esempio n. 12
0
void ccms_parse_pkt(CCMS_T *p, int nSockFd, unsigned char *pData) 
// ----------------------------------------------------------------------------
// PARSE PACKET
// Description		: 전송받은 Packet을 Parse 한다. 
// Arguments		: nSockFd			Client Socket
// 					  pData				Is a pointer to th Rxbuffer
// Returns			: none.
{
	int i = 0;
	int nType = 0;
	CCMS_PKT_T *pPkt;
	CCMS_PKT_ACK_T *pAck;
	CCMS_PKT_SET_T *pSetT;
	int nRtnSend = 0;
	unsigned char chTxBuf[32];
	point_info point;
	unsigned char chRemoteId = 0;
	unsigned char chPcm = 0;
	unsigned char chPno = 0;
	unsigned short wValue = 0;

	nType = pData[1];

	switch (nType) {
	// Notice Packet.
	case 'N':
		pPkt = (CCMS_PKT_T *)pData;
		if ( pPkt->chStx == '<' && pPkt->chEtx == '>') {

			ccms_register_node(p, nSockFd, pPkt->chId);

			/*
			fprintf( stdout, "Recv Index = %d \n", pPkt->wIndex);
			fprintf( stdout, "Recv Index = %d \n", pPkt->wIndex);
			fprintf( stdout, "Recv Data[0] = %f \n", pPkt->fData[0]);
			fprintf( stdout, "Recv Data[1] = %f \n", pPkt->fData[1]);
			fflush( stdout );
			*/

			for ( i = 0; i < CCMS_PKT_DATA_CNT; i++ ) {
				point.pcm = pPkt->chId;
				point.pno = g_nPnoTable[pPkt->wIndex] + i;
				point.value = pPkt->fData[i];
				
				if (g_fExPtbl[point.pcm][point.pno] == point.value )
					continue;
				
				pthread_mutex_lock( &pointTable_mutex );
				g_fExPtbl[point.pcm][point.pno] = point.value;
				pthread_mutex_unlock( &pointTable_mutex );
				elba_push_queue( &point );					
			}

			memset(chTxBuf, 0x00, sizeof(chTxBuf));
			if ( ccms_get_queue(p, nSockFd, &point) == SUCCESS ) {
				
				chRemoteId = (unsigned char)point.message_type;
				chPcm = (unsigned char)point.pcm;
				chPno = (unsigned char)point.pno;
				wValue = (unsigned short)point.value;

				pSetT = (CCMS_PKT_SET_T *)chTxBuf;
				pSetT->chStx = '<';
				pSetT->chCmd = 'S';
				pSetT->chId = chRemoteId;
				pSetT->chPcm = chPcm;
				pSetT->chPno = chPno;
				pSetT->wData = wValue;
				pSetT->chEtx = '>';

				fprintf( stdout, "Set %d %d %d %f\n", 
						 point.message_type, point.pcm, 
						 point.pno, point.value);
				fflush( stdout );

				nRtnSend = send(nSockFd, pSetT, sizeof(CCMS_PKT_SET_T), 0 );
			}
			else {
				pAck = (CCMS_PKT_ACK_T *)chTxBuf;
				pAck->chStx = '<';
				pAck->chCmd = 'A';
				pAck->chId = pPkt->chId;
				pAck->chEtx = '>';
				
				nRtnSend = send(nSockFd, pAck, sizeof(CCMS_PKT_ACK_T), 0 );
			}
		}
		break;

	case 'S':
		pSetT = (CCMS_PKT_SET_T *)pData;
		if ( pSetT->chStx == '<' && pSetT->chEtx == '>') {
			point.pcm = (short)pSetT->chPcm;
			point.pno = (short)pSetT->chPno;
			point.value = (float)pSetT->wData;
			point.message_type = (int)pSetT->chId;

			fprintf( stdout, "Recv 'S' Command\n");
			fflush( stdout );
							
			fprintf( stdout, "Recv  %d %d %d %f\n", 
					 point.message_type, point.pcm, 
					 point.pno, point.value);
			fflush( stdout );

			if ( point.pcm != g_nMyPcm ) {
				ccms_put_queue(&point);
				fprintf( stdout, "Put Queue\n");
				fflush( stdout );				
			}

			pSet(point.pcm, point.pno, point.value);

			pAck = (CCMS_PKT_ACK_T *)chTxBuf;
			pAck->chStx = '<';
			pAck->chCmd = 'A';
			pAck->chId = pSetT->chId;
			pAck->chEtx = '>';
			
			nRtnSend = send(nSockFd, pAck, sizeof(CCMS_PKT_ACK_T), 0 );
		}
		break;
	}
}
Esempio n. 13
0
void
SetTest::run() {
    CSetT<TestKey, TestSetFuncs> defSet;
	TestKey tk1; tk1.setValue("obj1");
    TestKey tk2; tk2.setValue("obj2");
    TestKey tk3; tk3.setValue("obj3");

    defSet.addObject(tk1);
    defSet.addObject(tk2);
    defSet.addObject(tk3);

    if (3 != defSet.count()) testFail(er0);

    CSetT<TestKey, TestSetFuncs>::Iterator iter1(&defSet);

    while (iter1.next()) {
        if (TestSetFuncs<TestKey>::isEqualKeys(&iter1.object(), &tk1, nil)) continue;
        if (TestSetFuncs<TestKey>::isEqualKeys(&iter1.object(), &tk2, nil)) continue;
        if (TestSetFuncs<TestKey>::isEqualKeys(&iter1.object(), &tk3, nil)) continue;
        testFail(er1);
    }

    defSet.removeObject(tk3);
    if (2 != defSet.count()) testFail(er2);

    defSet.removeAllObjects();
    if (0 != defSet.count()) testFail(er3);

	TestKey k5; k5.setValue("k5");
    TestKey k6; k6.setValue("k6");
    TestKey k7; k7.setValue("k7");
	TestKey k8; k8.setValue("k8");
	TestKey k9; k9.setValue("k9");
	TestKey s_1; s_1.setValue("s1");
	TestKey s_2; s_2.setValue("s2");
	TestKey s_3; s_3.setValue("s3");

    TestKey arrms[] = { k5, k6, k7, k8 };
    CArrayT<TestKey> arr(arrms, 4);
    
    TestKey tkss[] = { s_1, s_2, s_3 };
    CSetT<TestKey, TestSetFuncs> set(tkss, 3);

    set.addObjectsFromArray(&arr);

    if (7 != set.count()) testFail(er4);

    CSetT<TestKey, TestSetFuncs> set2(&arr);
    if (4 != set2.count()) testFail(er5);
    
    set.removeObject(s_1);
    set.removeObject(s_2);
    set.removeObject(s_3);

    if (!set2.isEqualToSet(&set)) testFail(er6);
    if (!set2.containsObject(k5)) testFail(er7);
    if (set2.containsObject(s_1)) testFail(er7);

    set.allObjects(&arr);

    if (arr.count() != set.count()) testFail(er8);
    for (dInteger i = 0, cnt = arr.count(); i < cnt; ++i)
        if (!set.containsObject(arr.objectAtIndex(i))) testFail(er8);

    try {
        set.member(k6);
    } catch (CSetT<TestKey, TestSetFuncs>::ExSetObjectNotFound* e) {
        testFail(er9);
        SAFE_DELETE(e);
    }
    try {
        set.member(k9);
        testFail(er9);
    } catch (CSetT<TestKey, TestSetFuncs>::ExSetObjectNotFound* e) {
        SAFE_DELETE(e);
    }


    CSetT<TestKey, TestSetFuncs> set3(set2);

    if (!set3.isEqualToSet(&set2)) testFail(er5);

    TestKey* cSet = new TestKey[3];
    cSet[0].setValue("b1");
    cSet[1].setValue("b2");
    cSet[2].setValue("b3");

    CSetT<TestKey, TestSetFuncs> setCSet(cSet, 3);
    SAFE_DELETE_ARRAY(cSet);

    if (3 != setCSet.count()) testFail(er5);
	
	TestKey b1; b1.setValue("b1");
    TestKey b2; b2.setValue("b2");
    TestKey b3; b3.setValue("b3");
	TestKey b4; b4.setValue("b4");

    if (!setCSet.containsObject(b1)) testFail(er5);
    if (!setCSet.containsObject(b2)) testFail(er5);
    if (!setCSet.containsObject(b3)) testFail(er5);
    if (setCSet.containsObject(b4)) testFail(er5);

    try {
        TestKey anyKey = setCSet.anyObject();
        if (!setCSet.containsObject(anyKey)) testFail(er10);
    } catch (CSetT<TestKey, TestSetFuncs>::ExSetObjectNotFound* e) {
        testFail(er10);
        SAFE_DELETE(e);
    }

    setCSet.removeAllObjects();

    try {
        setCSet.anyObject();
        testFail(er10);
    } catch (CSetT<TestKey, TestSetFuncs>::ExSetObjectNotFound* e) {
        SAFE_DELETE(e);
    }


	TestKey newobj; newobj.setValue("newObj");
    CSetT<TestKey, TestSetFuncs>* newly = set3.newSetByAddingObject(newobj);
    if (!newly->containsObject(newobj)) testFail(er11);
    SAFE_DELETE(newly);

	TestKey k1; k1.setValue("kk1");
	TestKey k2; k2.setValue("kk2");
	TestKey k3; k3.setValue("kk3");
	TestKey k4; k4.setValue("kk4");
	TestKey l1; l1.setValue("l1");
	TestKey l2; l2.setValue("l2");
	TestKey l3; l3.setValue("l3");
	
    TestKey keysms[] = { k1, k2, k3 };
	CArrayT<TestKey> keys(keysms, 3);
    CSetT<TestKey, TestSetFuncs>* newly2 = set3.newSetByAddingObjectsFromArray(&keys);
    if (!newly2->containsObject(k1)) testFail(er12);
    if (!newly2->containsObject(k2)) testFail(er12);
    if (newly2->containsObject(k4)) testFail(er12);
    if (!newly2->containsObject(k3)) testFail(er12);
    if (!newly2->containsObject(set3.anyObject())) testFail(er12);
    SAFE_DELETE(newly2);

    TestKey oness[] = { l1, l2 };
    CSetT<TestKey, TestSetFuncs> oneSet(oness, 2);
    CSetT<TestKey, TestSetFuncs> secondSet(&l3, 1);
    secondSet.unionSet(&oneSet);

    if (3 != secondSet.count()) testFail(er14);
    if (!secondSet.containsObject(l2)) testFail(er14);
    if (!secondSet.containsObject(l3)) testFail(er14);
    if (!secondSet.containsObject(l1)) testFail(er14);


    CSetT<TestKey, TestSetFuncs>* thirdSet = secondSet.newSetByAddingObjectsFromSet(&set3);
    if (!thirdSet->containsObject(l2)) testFail(er13);
    if (!thirdSet->containsObject(set3.anyObject())) testFail(er13);
    if (!thirdSet->containsObject(l3)) testFail(er13);
    if (!thirdSet->containsObject(l1)) testFail(er13);
    SAFE_DELETE(thirdSet);


	TestKey one; one.setValue("one");
	TestKey two; two.setValue("two");
	TestKey three; three.setValue("three");
	TestKey four; four.setValue("four");
	TestKey fifth; fifth.setValue("fifth");
	TestKey six; six.setValue("six");
	
    TestKey rss[] = { one, two, three, four };
    CSetT<TestKey, TestSetFuncs> rSet(rss, 4);
    TestKey r2ss[] = { one, three, four };
    CSetT<TestKey, TestSetFuncs> rSet2(r2ss, 3);
    rSet.minusSet(&rSet2);

    if (1 != rSet.count()) testFail(er15);
    TestKey tTwo; tTwo.setValue("two");
    if (!TestSetFuncs<TestKey>::isEqualKeys(&rSet.anyObject(), &tTwo, nil)) testFail(er15);


    TestKey iss[] = { one, fifth, six, four };
    CSetT<TestKey, TestSetFuncs> iSet(rss, 4);
    CSetT<TestKey, TestSetFuncs> iSet2(iss, 4);
    iSet.intersectSet(&iSet2);

    CSetT<TestKey, TestSetFuncs>::Iterator iSetIter(&iSet);
    TestKey tOne; tOne.setValue("one");
    TestKey tFour; tFour.setValue("four");

    while (iSetIter.next()) {
        if (TestSetFuncs<TestKey>::isEqualKeys(&iSetIter.object(), &tOne, nil)) continue;
        if (TestSetFuncs<TestKey>::isEqualKeys(&iSetIter.object(), &tFour, nil)) continue;
        testFail(er16);
    }

	TestKey boo1; boo1.setValue("boo1");
	TestKey boo2; boo2.setValue("boo2");
	TestKey boo3; boo3.setValue("boo3");
	TestKey boo4; boo4.setValue("boo4");
	TestKey capacity; capacity.setValue("capacity");
	TestKey other; other.setValue("other");
	TestKey bla; bla.setValue("bla-bla");
	TestKey yahoo; yahoo.setValue("yahoo");
	
    TestKey pss[] = { boo1, boo2, boo3 };
    CSetT<TestKey, TestSetFuncs> pSet(pss, 3);
    iSet.setSet(&pSet);

    if (iSet.containsObject(one)) testFail(er17);
    if (iSet.containsObject(four)) testFail(er17);
    if (!iSet.containsObject(boo1)) testFail(er17);
    if (!iSet.containsObject(boo3)) testFail(er17);

    CSetT<TestKey, TestSetFuncs> capacitySet(10);
    capacitySet.addObject(capacity);
    if (1 != capacitySet.count()) testFail(er5);
    if (!capacitySet.containsObject(capacity)) testFail(er5);


    iSet.addObject(other);
    TestKey subss[] = { boo1, boo3 };
    CSetT<TestKey, TestSetFuncs> subSet(subss, 2);

    if (!subSet.isSubsetOfSet(&iSet)) testFail(er18);
    if (subSet.isSubsetOfSet(&capacitySet)) testFail(er18);


    TestKey i1ss[] = { yahoo, bla, boo3 };
    CSetT<TestKey, TestSetFuncs> interSet1(i1ss, 3);
    TestKey i2ss[] = { yahoo, bla, boo4 };
    CSetT<TestKey, TestSetFuncs> interSet2(i2ss, 3);

    if (!subSet.intersectsSet(&interSet1)) testFail(er19);
    if (subSet.intersectsSet(&interSet2)) testFail(er19);
}