示例#1
0
void CFoulerDoc::AddDataFromText(DWORD dwSize, char *pHeader)
{
	char seps[] = "abcdfghijklmnopqrstuvwxyzABCDFGHIJKLMNOPQRSTUVWXYZ= ,\t\n:()";
	char *token, *cpTextData;
	int i, iOrg, iData, itemno, iIndex;
	double dData;
	BeginWaitCursor();
	for (DWORD dw = 0; dw < dwSize; dw++)
	{
		if (pHeader[dw] == NULL) pHeader[dw] = ' ';
	}
	cpTextData = new char[dwSize];
	memcpy( cpTextData, pHeader, dwSize );
	itemno = GetItemNo( cpTextData );
	delete[] cpTextData;
	if( itemno < 1 ) return;
	CProgressBar* pBar = new CProgressBar();
	iData = m_iNo;
	iOrg = m_iOriginNo;
	InsertData( itemno );
	iIndex = 0;
	token = strtok( pHeader, seps );
	while( token!= NULL )
	{
		dData = atof(token);
		if( dData != 0 )
		{
			m_pOrgData[iOrg]->SetItem( dData );
			m_iSubGroupIndex++;
			if( m_iSubGroupIndex >= m_iSubGroupSize )
			{
				m_iSubGroupIndex = 0;
				dData = 0;
				for( i=iOrg+1-m_iSubGroupSize ; i<iOrg+1 ; i++ )
				{
					dData += m_pOrgData[i]->GetItem();
				}
				m_pData[iData]->SetItem(dData/m_iSubGroupSize);
				iData++;
				AnalysisData();
			}
			iOrg++;
			iIndex++;
			pBar->SetPos((iIndex<<8)/itemno);
		}
		token = strtok( NULL, seps );
	}
	delete pBar;
	EndWaitCursor();
}
示例#2
0
BOOL CFoulerDoc::OpenCCA(HANDLE hFileRead)
{
	char cHeader[32];
	double dData = 0;
	DWORD nCount;
	DWORD dwHighSize, dwLowSize;
	int i;
	ZeroMemory( cHeader, sizeof(cHeader) );
	dwLowSize = GetFileSize( hFileRead, &dwHighSize );
	SetFilePointer( hFileRead, 0, NULL, FILE_BEGIN);
	ReadFile( hFileRead, cHeader, 32, &nCount, NULL );
	if( strcmp( cHeader, "Control Chart Analyzer File" ) != 0 ) return FALSE;
	int itemno = 0;
	ReadFile( hFileRead, &itemno, sizeof(itemno), &nCount, NULL );
	if( itemno < 0 ) return FALSE;
	if( dwLowSize < itemno*sizeof(dData)+32+sizeof(itemno)+sizeof(m_histogram)+sizeof(m_shewart)+sizeof(m_cusum)+sizeof(m_sprt) ) return FALSE;
	ClearData();
	ReadFile( hFileRead, &m_histogram, sizeof(m_histogram), &nCount, NULL );
	ReadFile( hFileRead, &m_shewart, sizeof(m_shewart), &nCount, NULL );
	ReadFile( hFileRead, &m_cusum, sizeof(m_cusum), &nCount, NULL );
	ReadFile( hFileRead, &m_sprt, sizeof(m_sprt), &nCount, NULL );
	double* pData;
	pData = new double[itemno];
	ReadFile( hFileRead, pData, sizeof(dData)*itemno, &nCount, NULL );
	double *dp;
	dp = pData;
	CProgressBar* pBar = new CProgressBar();
	InsertData( itemno );
	for( i=0 ; i<itemno ; i++ )
	{
		m_pOrgData[i]->SetItem( *dp );
		m_iSubGroupIndex++;
		if( m_iSubGroupIndex >= m_iSubGroupSize )
		{
			m_iSubGroupIndex = 0;
			dData = 0;
			for( int j=i+1-m_iSubGroupSize ; j<i+1 ; j++ )
			{
				dData += m_pOrgData[j]->GetItem();
			}
			m_pData[i/m_iSubGroupSize]->SetItem(dData/m_iSubGroupSize);
			AnalysisData();
		}
		dp++;
		pBar->SetPos( (i<<8)/itemno );
	}
	delete[] pData;
	delete pBar;
	return TRUE;
}
示例#3
0
void CFoulerDoc::InsertOneData(double dData)
{
	int i;
	double dSum = 0;
	if( m_iOriginNo >= DEF_MAX_DATASIZE ) return;
	m_pOrgData[m_iOriginNo] = new CData;
	m_pOrgData[m_iOriginNo]->SetItem(dData);
	m_iOriginNo++;
	m_iSubGroupIndex++;
	if( m_iSubGroupIndex >= m_iSubGroupSize )
	{
		m_iSubGroupIndex = 0;
		for( i=m_iOriginNo-m_iSubGroupSize ; i<m_iOriginNo ; i++ )
		{
			dSum += m_pOrgData[i]->GetItem();
		}
		m_pData[m_iNo] = new CData;
		m_pData[m_iNo]->SetItem(dSum/m_iSubGroupSize);
		m_iNo++;
		AnalysisData();
		if( m_pLeftView != NULL ) m_pLeftView->Update();
	}
}
示例#4
0
void CFoulerDoc::OnEditNewdata() 
{
	double dAverage=0, dDeviation=0, dMoveRate=0;
	int i=0, iNo = 0;
	char cStr[64];
	if( m_generator.GetReady() )
	{
		iNo = 0;
		dAverage = m_generator.GetAverage();
		dDeviation = m_generator.GetDeviation();
		dMoveRate = m_generator.GetMoveRate();
	}
	else
	{
		iNo = 0;
		dAverage = 0;
		dDeviation = 1;
		dMoveRate = 0;
	}
	CNewData dlg( dAverage, iNo, dDeviation, dMoveRate );
	if( dlg.DoModal() == IDCANCEL ) return;
	BeginWaitCursor();
	m_generator.SetReady(TRUE);
	m_generator.SetAverage(dlg.m_average);
	m_generator.SetDeviation(dlg.m_deviation);
	m_generator.SetGenMode(dlg.m_iGenMode);
	m_generator.SetMoveRate(dlg.m_moverate);
	CMainFrame *pFrame = (CMainFrame*)AfxGetMainWnd();
	ZeroMemory( cStr, sizeof(cStr) );
	sprintf( cStr, "%f", m_generator.GetAverage() );
	if( pFrame != NULL ) pFrame->m_edit.SetWindowText( cStr );
	m_dIndex += dlg.m_datano;
	CProgressBar* pBar = new CProgressBar();
	iNo = m_iNo;
	InsertData( dlg.m_datano );
	for( i=iNo ; i<m_iNo ; i++ )
	{
		m_pOrgData[i]->SetItem( m_generator.Gen() );
		m_iSubGroupIndex++;
		if( m_iSubGroupIndex >= m_iSubGroupSize )
		{
			m_iSubGroupIndex = 0;
			dAverage = 0;
			for( int j=i+1-m_iSubGroupSize ; j<i+1 ; j++ )
			{
				dAverage += m_pOrgData[j]->GetItem();
			}
			m_pData[i/m_iSubGroupSize]->SetItem(dAverage/m_iSubGroupSize);
			AnalysisData();
		}
		pBar->SetPos( ((i-iNo)<<8)/dlg.m_datano );
	}
	delete pBar;

	if( m_histogram.GetReady() == FALSE )
	{
		EndWaitCursor();
		OnEditAnalysis();
		BeginWaitCursor();
	}
	m_pRightView->Refresh();
	ChangeViewMode(m_iViewMode);
	EndWaitCursor();
}
int SpiderThread::Run(void *param)
{
	HANDLE		httpNotifyEvent[MAX_SPIDER_THREAD+1];
	int waitR=0;
	CMyAsyncHttp::HTTP_STATE state;
	int idleHttpCount=0;
	bool	exit=false;

	m_InterfaceConfig.Lock();
	for(int i=0;i<m_HttpCount;i++)
	{
		httpNotifyEvent[i]=m_Http[i].m_FinishNotify;
		m_Http[i].SetMark(false);
	}
	httpNotifyEvent[i]=m_EndEvent;
	
	UrlInfo*	url=m_MassMem_UrlInfo.AllocMem();
	url->iUrl	=(char*)param;
	
	m_UrlList.push_back(url);
	
	m_SameRegex=(m_UrlRegex==HTTP_REGEX);

	AddHashMap(CUrl::GetUrlHost(url->iUrl),url->iUrl);
	
	while(1)
	{
		idleHttpCount	=0;
		for(int i=0;i<m_HttpCount;i++)
		{
			//检查退出指令
			if(WaitEvent(m_EndEvent,0)==0)
			{
				exit	=true;
				break;
			}
			//判断当前连接是否空闲
			if(m_Http[i].IsIdle())
			{
				state	=m_Http[i].GetHttpState();
				if(state==CMyAsyncHttp::HTTP_FINISH&&m_Http[i].GetCurrentUrl()!="")
				{
					//http请求正确
					int state=m_Http[i].GetStatusCode();
					if(state<400)
					{
						//服务器返回正常
						if(state<300)
							AnalysisData(&m_Http[i]);
						else
							RelocateUrl(&m_Http[i]);
					}
					else
					{
						ErrorProcess(&m_Http[i]);
					}
					m_Http[i].SetMark(true);
				}
				else if(state==CMyAsyncHttp::HTTP_TIMEOUT||state==CMyAsyncHttp::HTTP_STOP)
				{
					//http请求超时
					ErrorProcess(&m_Http[i]);
					m_Http[i].SetMark(true);
				}
				
				if(GetNextUrl())
				{
					m_Http[i].SetParentUrl(m_CurrentUrl->iParentUrl);
					m_Http[i].Get(m_CurrentUrl->iUrl.GetBuffer());

					m_MassMem_UrlInfo.FreeMem(m_CurrentUrl);
					m_Http[i].SetMark(false);

printf("url count:%d\n",m_MassMem_UrlInfo.GetAllocCount());
				}
				else
				{
					idleHttpCount	=0;
					for(int i=0;i<m_HttpCount;i++)
					{
						if(m_Http[i].GetMark())idleHttpCount++;
					}
					if(idleHttpCount==m_HttpCount)
					{
						exit	=true;
						break;
					}
				}
			}
		}

		if(exit)break;
		
		waitR=::WaitForMultipleObjects(m_HttpCount+1,httpNotifyEvent,false,-1);
		
		if(waitR==m_HttpCount)
			break;
	}
	
	m_InterfaceConfig.m_SpiderFinish->OnFinish();
	ClearUrlList();
	return 1;
}