Beispiel #1
0
CResult *CBox::OnChart(CDataInterface *pDataInterface, string VO)
{
	bool bRet = false;
	m_pDataInterface = pDataInterface;
	//图形
	SetChartType(CHART_BOXPLOT);
	//解析
	if (!GetValueFromVo(VO))
	{
		CRsltElementText *pText = new CRsltElementText(MSG_TITLE_STR);
		CTString szMsg = GetLastErrMsg();
		pText->AddString(szMsg);
		m_pResult->Add(pText);
		return m_pResult;
	}
	//验证
	if (!Verify())
	{
		CRsltElementText *pText = new CRsltElementText(MSG_TITLE_STR);
		CTString szMsg = GetLastErrMsg();
		pText->AddString(szMsg);
		m_pResult->Add(pText);
		return m_pResult;
	}
	//初始化
	Init();
	if (m_eMode == CLASS) bRet = CalcBox1();
	else if (m_eMode == VARI) bRet = CalcBox2();
	if (!bRet)
	{
		CRsltElementText *pText = new CRsltElementText(MSG_TITLE_STR);
		CTString szMsg = GetLastErrMsg();
		pText->AddString(szMsg);
		m_pResult->Add(pText);
		return m_pResult;
	}
	return m_pResult;
}
CResult *CHistogram::OnChart(CDataInterface *pDataInterface, string VO)
{
	bool bRet = false;
	m_pDataInterface = pDataInterface;
	//图形
	SetChartType(CHART_HISTOGRAM);
	//解析
	if (!GetValueFromVo(VO))
	{
		CRsltElementText *pText = new CRsltElementText(MSG_TITLE_STR);
		CTString szMsg = GetLastErrMsg();
		pText->AddString(szMsg);
		m_pResult->Add(pText);
		return m_pResult;
	}
	//验证
	if (!Verify())
	{
		CRsltElementText *pText = new CRsltElementText(MSG_TITLE_STR);
		CTString szMsg = GetLastErrMsg();
		pText->AddString(szMsg);
		m_pResult->Add(pText);
		return m_pResult;
	}
	//初始化
	Init();
	bRet = CalcHistogram();
	if (!bRet || m_szErrMsg.GetLength() > 0)
	{
		CRsltElementText *pText = new CRsltElementText(MSG_TITLE_STR);
		CTString szMsg = GetLastErrMsg();
		pText->AddString(szMsg);
		m_pResult->Add(pText);
		return m_pResult;
	}
	return m_pResult;
}
Beispiel #3
0
//ファイル保存を終了する
//戻り値:
// TRUE(成功)、FALSE(失敗)
BOOL CWriteMain::_StopSave(
	)
{
	if( this->file != NULL ){
		if( this->writeBuffPos > 0 ){
			DWORD writeSize = 0;
			DWORD err = 0;
			wstring errMsg = L"";
			if( WriteFile(this->file, this->writeBuff, this->writeBuffPos, &writeSize, NULL) == FALSE ){
				err = GetLastError();
				GetLastErrMsg(err, errMsg);
				_OutputDebugString(L"★_StopSave WriteFile Err:0x%08X %s", err, errMsg.c_str());
			}else{
				this->writeBuffPos = 0;
			}
		}
		SetEndOfFile(this->file);
		CloseHandle(this->file);
		this->file = NULL;
	}

	return TRUE;
}
Beispiel #4
0
//保存用TSデータを送る
//空き容量不足などで書き出し失敗した場合、writeSizeの値を元に
//再度保存処理するときの送信開始地点を決める
//戻り値:
// TRUE(成功)、FALSE(失敗)
//引数:
// data					[IN]TSデータ
// size					[IN]dataのサイズ
// writeSize			[OUT]保存に利用したサイズ
BOOL CWriteMain::_AddTSBuff(
	BYTE* data,
	DWORD size,
	DWORD* writeSize
	)
{
	BOOL ret = FALSE;
	wstring errMsg = L"";
	DWORD err = 0;
	if( this->file != NULL && data != NULL && size > 0 ){
		if( this->writeBuffSize > 0 && this->writeBuff != NULL){
			if( size > this->writeBuffSize ){
				//バッファサイズより大きいのでそのまま出力
				if( this->writeBuffPos > 0 ){
					//前回のバッファあるので先に出力
					DWORD write = 0;
					wstring errMsg = L"";
					if( WriteFile(this->file, this->writeBuff, this->writeBuffPos, &write, NULL) == FALSE ){
						//エラーが出た
						err = GetLastError();
						GetLastErrMsg(err, errMsg);
						_OutputDebugString(L"★_StopSave WriteFile Err:0x%08X %s", err, errMsg.c_str());
						*writeSize = 0;
						//書き込めなかった部分をバッファの先頭へコピー
						DWORD tempBuffSize = this->writeBuffPos-write;
						if( tempBuffSize > 0 ){
							BYTE* tempBuff = new BYTE[tempBuffSize];
							memcpy( tempBuff, this->writeBuff+write, tempBuffSize);
							this->writeBuffPos = tempBuffSize;
							memcpy(this->writeBuff, tempBuff, tempBuffSize);
							SAFE_DELETE_ARRAY(tempBuff);
						}

						SetEndOfFile(this->file);
						CloseHandle(this->file);
						this->file = NULL;

						return FALSE;
					}else{
						this->writeBuffPos = 0;
					}
				}
				//ファイル出力
				if( WriteFile(this->file, data, size, writeSize, NULL) == FALSE ){
					//エラーが出た
					err = GetLastError();
					GetLastErrMsg(err, errMsg);
					_OutputDebugString(L"★WriteFile Err:0x%08X %s", err, errMsg.c_str());

					SetEndOfFile(this->file);
					CloseHandle(this->file);
					this->file = NULL;

					return FALSE;
				}else{
					ret = TRUE;
				}
			}else{
				if(this->writeBuffSize < this->writeBuffPos + size){
					//バッファ埋まるので出力
					DWORD tempSize = this->writeBuffSize - this->writeBuffPos;
					memcpy( this->writeBuff+this->writeBuffPos, data, tempSize );
					DWORD tempWriteSize = 0;
					if( WriteFile(this->file, this->writeBuff, this->writeBuffSize, &tempWriteSize, NULL) == FALSE ){
						//エラー
						err = GetLastError();
						GetLastErrMsg(err, errMsg);
						_OutputDebugString(L"★_StopSave WriteFile Err:0x%08X %s", err, errMsg.c_str());
						*writeSize = 0;
						//ファイルポインタ戻す
						LONG lpos = (LONG)tempWriteSize;
						SetFilePointer(this->file, -lpos, NULL, FILE_CURRENT);

						SetEndOfFile(this->file);
						CloseHandle(this->file);
						this->file = NULL;

						return FALSE;
					}else{
						//バッファにコピー
						memcpy( this->writeBuff, data+tempSize, size-tempSize );
						this->writeBuffPos = size-tempSize;
						*writeSize = size;
						ret = TRUE;
					}
				}else{
					//バッファにコピー
					memcpy( this->writeBuff+this->writeBuffPos, data, size );
					this->writeBuffPos += size;
					*writeSize = size;
					ret = TRUE;
				}
			}
		}else{
			ret = WriteFile(this->file, data, size, writeSize, NULL);
			if( ret == FALSE ){
				err = GetLastError();
				GetLastErrMsg(err, errMsg);
				_OutputDebugString(L"★WriteFile Err:0x%08X %s", err, errMsg.c_str());

				SetEndOfFile(this->file);
				CloseHandle(this->file);
				this->file = NULL;
			}
		}
	}
	return ret;
}
Beispiel #5
0
bool CBox::CalcBox2()
{
	int i=0, nCount=0;
	int nDataType = 0, nColIndex=0, nRowCount=0;
	CDWordArray arrCol;
	CDoubleMatrix dataMatrix;
	CTString szTemp("");
	CTString szFldName("");
	bool bHasBox=false;
	CTStringArray arrFldName;
	
	if (m_tVarX.iCount < 1)
	{
		m_szErrMsg.Format("盒状图中的数据不完整,至少需要一个变量,请检查!Line=%d,File=%s",__LINE__,__FILE__);
		return false;
	}
	m_szErrMsg.Empty();
	//数据处理
	TDataPointStrArr *pDPFB = NULL;
	CTChartBoxplot *pBox = new CTChartBoxplot;
	if (m_bSplit) //分开
	{
		for (i=0; i<m_tVarX.iCount; i++)
		{
			nColIndex = m_tVarX.pValue[i];
			nDataType = m_pDataInterface->GetFieldType(nColIndex);
			szFldName = m_pDataInterface->GetFieldName(nColIndex);
			if (nDataType != fInt && nDataType != fDouble && 
				nDataType != fBoolean && nDataType != fCurrency)
			{
				szTemp.Format("盒状图中的X轴参数(%s)不是数字型,无法绘图,请检查!Line=%d,File=%s",szFldName.GetData(),__LINE__,__FILE__);
				m_szErrMsg += szTemp;
				continue;
			}
			arrCol.RemoveAll();
			dataMatrix.destroy();
			arrCol.Add(nColIndex);
			nRowCount = m_pDataInterface->GetColsData(arrCol,dataMatrix,0);
			if (nRowCount < 1)
			{
				szTemp.Format("盒状图中的X轴变量(%s)有效数据太少,无法绘图,请检查!Line=%d,File=%s",szFldName.GetData(),__LINE__,__FILE__);
				m_szErrMsg += szTemp;
				continue;
			}
			//计算盒状图
			CIntVector vecInd;
			CDoubleVector w;
			CDoubleVector v = dataMatrix(0);
			pBox->SetParam(false,false,false);
			pBox->CalcPercent(v,w,vecInd);
			pBox->CalcBoxPlot(v,(void **)&pDPFB,nCount);
			pDPFB->strName += SEP_RISER + szFldName;
			pBox->SetBoxplot(pDPFB,1,StrArr);
			delete pDPFB;
			bHasBox = true;
		}
	}
	else
	{
		for (i=0; i<m_tVarX.iCount; i++)
		{
			nColIndex = m_tVarX.pValue[i];
			nDataType = m_pDataInterface->GetFieldType(nColIndex);
			szFldName = m_pDataInterface->GetFieldName(nColIndex);
			if (nDataType != fInt && nDataType != fDouble && 
				nDataType != fBoolean && nDataType != fCurrency)
			{
				szTemp.Format("盒状图中的X轴参数(%s)不是数字型,无法绘图,请检查!Line=%d,File=%s\n",szFldName.GetData(),__LINE__,__FILE__);
				m_szErrMsg += szTemp;
				continue;
			}
			arrCol.Add(nColIndex);
			arrFldName.Add(szFldName);
		}
		if (arrCol.GetSize() < 1)
		{
			m_szErrMsg.Format("盒状图中的X轴参数均为非数字型,无法绘图,请检查!Line=%d,File=%s\n",__LINE__,__FILE__);
			return false;
		}
		//读数据
		nRowCount = m_pDataInterface->GetColsData(arrCol,dataMatrix,0);
		if (nRowCount < 1)
		{
			m_szErrMsg.Format("盒状图中的X轴变量有效数据太少,无法绘图,请检查!Line=%d,File=%s\n",__LINE__,__FILE__);
			return false;
		}
		for (i=0; i<arrCol.GetSize(); i++)
		{
			//计算盒状图
			CIntVector vecInd;
			CDoubleVector w;
			CDoubleVector v = dataMatrix(i);
			pBox->SetParam(false,false,false);
			pBox->CalcPercent(v,w,vecInd);
			pBox->CalcBoxPlot(v,(void **)&pDPFB,nCount);
			pDPFB->strName += SEP_RISER + arrFldName.GetAt(i);
			pBox->SetBoxplot(pDPFB,1,StrArr);
			delete pDPFB;
			bHasBox = true;
		}
	}
	if (m_szErrMsg.GetLength() > 0)
	{
		CRsltElementText *pText = new CRsltElementText(MSG_TITLE_STR);
		CTString szMsg = GetLastErrMsg();
		pText->AddString(szMsg);
		m_pResult->Add(pText);
	}
	//Add
	if (bHasBox)
	{
		CRsltElementChart *pChart = new CRsltElementChart("盒状图",pBox);
		pBox->SetXAxilLabel("组项");
		m_pResult->SetName("盒状图"); 
		m_pResult->Add(pChart); 
	}
	else
	{
		delete pBox;
		pBox = NULL;
	}
	return true;
}