Beispiel #1
0
int CXmlItem::CompareItems(const CXmlItem* pXIItem1, const CXmlItem* pXIItem2, 
						   const CString& sKeyName, XI_SORTKEY nKey)
{
	const CString& sValue1 = pXIItem1->GetItemValue(sKeyName);
	const CString& sValue2 = pXIItem2->GetItemValue(sKeyName);
	
	double dDiff = 0;
	
	switch (nKey)
	{
	case XISK_STRING:
		dDiff = (double)CString(sValue1).CompareNoCase(sValue2);
		break;
		
	case XISK_INT:
		dDiff = (double)(_ttoi(sValue1) - _ttoi(sValue2));
		break;
		
	case XISK_FLOAT:
		dDiff = _ttof(sValue1) - _ttof(sValue2);
		break;
	}
	
	return (dDiff < 0) ? -1 : ((dDiff > 0) ? 1 : 0);
}
Beispiel #2
0
// 把对话框中的设置写入文件
void CSettingDlg::SaveOptionsInDlg(LPCTSTR path)
{
	gzFile f = gzopen_w(path, "wb");
	if (f == NULL)
		return;

	// 头部
	gzwrite(f, "TB", 2);

	// 违规内容
	WriteRegexTexts(f, m_keywordsPage.m_list);

	// 屏蔽用户
	WriteRegexTexts(f, m_blackListPage.m_list);

	// 信任用户
	int size;
	gzwrite(f, &(size = m_whiteListPage.m_list.GetCount()), sizeof(int)); // 长度
	CString strBuf;
	for (int i = 0; i < size; i++)
	{
		m_whiteListPage.m_list.GetText(i, strBuf);
		WriteText(f, strBuf);
	}

	// 信任内容
	WriteRegexTexts(f, m_whiteContentPage.m_list);

	int intBuf;
	BOOL boolBuf;
	float floatBuf;
	double doubleBuf;
	m_prefPage.m_scanIntervalEdit.GetWindowText(strBuf);
	gzwrite(f, &(intBuf = _ttoi(strBuf)), sizeof(int));								// 扫描间隔
	gzwrite(f, &(boolBuf = m_prefPage.m_banIDCheck.GetCheck()), sizeof(BOOL));		// 封ID
	intBuf = m_prefPage.m_banDurationCombo.GetCurSel();
	intBuf = intBuf == 0 ? 1 : (intBuf == 1 ? 3 : 10);
	gzwrite(f, &intBuf, sizeof(int));												// 封禁时长
	gzwrite(f, &(boolBuf = FALSE), sizeof(BOOL));									// 封IP
	m_prefPage.m_trigCountEdit.GetWindowText(strBuf);
	gzwrite(f, &(intBuf = _ttoi(strBuf)), sizeof(int));								// 封禁违规次数
	gzwrite(f, &(boolBuf = m_prefPage.m_onlyScanTitleCheck.GetCheck()), sizeof(BOOL)); // 只扫描标题
	m_prefPage.m_deleteIntervalEdit.GetWindowText(strBuf);
	gzwrite(f, &(floatBuf = (float)_ttof(strBuf)), sizeof(float));					// 删帖间隔
	gzwrite(f, &(boolBuf = m_prefPage.m_confirmCheck.GetCheck()), sizeof(BOOL));	// 操作前提示
	m_prefPage.m_scanPageCountEdit.GetWindowText(strBuf);
	gzwrite(f, &(intBuf = _ttoi(strBuf)), sizeof(int));								// 扫描最后页数
	gzwrite(f, &(boolBuf = m_prefPage.m_briefLogCheck.GetCheck()), sizeof(BOOL));	// 只输出删帖封号
	gzwrite(f, &(boolBuf = m_prefPage.m_deleteCheck.GetCheck()), sizeof(BOOL));		// 删帖
	m_prefPage.m_threadCountEdit.GetWindowText(strBuf);
	gzwrite(f, &(intBuf = _ttoi(strBuf)), sizeof(int));								// 线程数
	m_prefPage.m_banReasonEdit.GetWindowText(strBuf);
	WriteText(f, strBuf);															// 封禁原因
	m_imagePage.m_dirEdit.GetWindowText(strBuf);
	WriteText(f, strBuf);															// 违规图片目录
	m_imagePage.m_thresholdEdit.GetWindowText(strBuf);
	gzwrite(f, &(doubleBuf = _ttof(strBuf)), sizeof(double));						// 阈值

	gzclose(f);
}
bool DayStockGraph::OnRender(char* szStockCode)
{
	Company* pCompany = StockFacade::GetInstance()->GetCompany(szStockCode);

	if (!pCompany)
		return false;

	lineRGBA(screen, START_POINT_X, START_POINT_Y,
		START_POINT_X + SCREEN_WIDTH, START_POINT_Y,
		255, 0, 0, 255);

	auto& data = pCompany->m_mapTR1302;
	auto& iter = data.begin();
	int i = 0;
	t1302OutBlock1* pPrevData = NULL;
	t1302OutBlock1* pCurData = NULL;
	for (; iter != data.end(); iter++, i++)
	{
		pCurData = &iter->second;
		if (i != 0)
		{
			float fPrevDiff = _ttof(pPrevData->diff);
			float fCurDiff = _ttof(pCurData->diff);

			lineRGBA(screen, (START_POINT_X + POINT_INTERVAL * (i - 1)) * SCREEN_RATIO, START_POINT_Y + fPrevDiff * -20.0f,
				(START_POINT_X + POINT_INTERVAL * (i)) * SCREEN_RATIO, START_POINT_Y + fCurDiff * -20.0f,
				255, 255, 255, 255);
		}
		
		pPrevData = &iter->second;					

	}

	return true;
}
Beispiel #4
0
// 应用对话框中的设置
void CSettingDlg::ApplyOptionsInDlg()
{
	CString strBuf;
	int intBuf;
	m_prefPage.m_scanIntervalEdit.GetWindowText(strBuf);
	g_scanInterval = _ttoi(strBuf);								// 扫描间隔
	g_banID = m_prefPage.m_banIDCheck.GetCheck();				// 封ID
	intBuf = m_prefPage.m_banDurationCombo.GetCurSel();
	g_banDuration = intBuf == 0 ? 1 : (intBuf == 1 ? 3 : 10);	// 封禁时长
	m_prefPage.m_trigCountEdit.GetWindowText(strBuf);
	g_trigCount = _ttoi(strBuf);								// 封禁违规次数
	g_onlyScanTitle = m_prefPage.m_onlyScanTitleCheck.GetCheck(); // 只扫描标题
	m_prefPage.m_deleteIntervalEdit.GetWindowText(strBuf);
	g_deleteInterval = (float)_ttof(strBuf);					// 删帖间隔
	g_confirm = m_prefPage.m_confirmCheck.GetCheck();			// 操作前提示
	m_prefPage.m_scanPageCountEdit.GetWindowText(strBuf);
	g_scanPageCount = _ttoi(strBuf);							// 扫描最后页数
	g_briefLog = m_prefPage.m_briefLogCheck.GetCheck();			// 只输出删帖封号
	g_delete = m_prefPage.m_deleteCheck.GetCheck();				// 删帖
	m_prefPage.m_threadCountEdit.GetWindowText(strBuf);
	g_threadCount = _ttoi(strBuf);								// 线程数
	m_prefPage.m_banReasonEdit.GetWindowText(strBuf);
	g_banReason = strBuf;										// 封禁原因
	m_imagePage.m_dirEdit.GetWindowText(g_imageDir);			// 违规图片目录
	m_imagePage.m_thresholdEdit.GetWindowText(strBuf);
	g_SSIMThreshold = _ttof(strBuf);							// 阈值

	g_optionsLock.Lock();
	// 违规内容
	ApplyRegexTexts(g_keywords, m_keywordsPage.m_list);

	// 屏蔽用户
	ApplyRegexTexts(g_blackList, m_blackListPage.m_list);

	// 信任用户
	int size = m_whiteListPage.m_list.GetCount();
	g_whiteList.resize(size);
	for (int i = 0; i < size; i++)
	{
		m_whiteListPage.m_list.GetText(i, g_whiteList[i]);
	}

	// 信任内容
	ApplyRegexTexts(g_whiteContent, m_whiteContentPage.m_list);

	// 违规图片
	if (m_imagePage.m_updateImage)
		ReadImages(g_imageDir);
	g_optionsLock.Unlock();

	if (m_clearScanCache)
	{
		if (!g_briefLog)
			((CTiebaManagerDlg*)AfxGetApp()->m_pMainWnd)->Log(_T("<font color=green>清除扫描记录</font>"));
		g_reply.clear();
	}
}
Beispiel #5
0
void CalculateDlgChild1::OnDeltaposSpinDx(NMHDR *pNMHDR, LRESULT *pResult)
{
    LPNMUPDOWN pNMUpDown = reinterpret_cast<LPNMUPDOWN>(pNMHDR);
    // TODO: Add your control notification handler code here
//*
    if(pNMUpDown->iDelta > 0) {
        // 响应点击向下
        //::MessageBox(NULL,_T("OKOK"),_T("OKOK"),MB_OK);
        CString tempText ;
        GetDlgItemText(IDC_EDIT_DX,tempText);
        this->m_edit_dx= (float)_ttof(tempText);

        if (this->m_edit_dx>10.0) {
            tempText.Format(_T("%0.1f"),10.0);
            this->m_edit_dx=10.0f;
            SetDlgItemText(IDC_EDIT_DX,tempText);
        } else if (this->m_edit_dx<=1.0) {
            tempText.Format(_T("%0.1f"),1.0);
            this->m_edit_dx=1.0f;
            SetDlgItemText(IDC_EDIT_DX,tempText);
        } else {
            this->m_edit_dx-=0.1f;
            tempText.Format(_T("%0.1f"),this->m_edit_dx);
            SetDlgItemText(IDC_EDIT_DX,tempText);
        }
    }
    else if(pNMUpDown->iDelta < 0) {
        // 相应点击向上
        CString tempText ;
        GetDlgItemText(IDC_EDIT_DX,tempText);
        this->m_edit_dx= (float)_ttof(tempText);

        if (this->m_edit_dx<1.0f) {
            tempText.Format(_T("%0.1f"),1.0);
            this->m_edit_dx=1.0f;
            SetDlgItemText(IDC_EDIT_DX,tempText);
        } else if(this->m_edit_dx>=10.0f) {
            tempText.Format(_T("%0.1f"),10.0);
            this->m_edit_dx=10.0f;
            SetDlgItemText(IDC_EDIT_DX,tempText);
        } else {
            this->m_edit_dx+=0.1f;
            tempText.Format(_T("%0.1f"),this->m_edit_dx);
            SetDlgItemText(IDC_EDIT_DX,tempText);
        }
    }
    //*/

    *pResult = 0;
}
//点菜完成,点击确定按钮将数据存储到数据库中,
void OrderDish::OnButtonOrderdishok()
{
	// TODO:  在此添加命令处理程序代码
	//MessageBox(_T("确定"));
	UpdateData();
	CString sqlCommand;
	int countNumbers = m_recipeOrderedList.GetItemCount();
	if (countNumbers == 0)
	{
		AfxMessageBox(_T("请点菜"));
		return;
	}
	sqlCommand = "update tableUse set tableState='使用' where tableID=";
	sqlCommand += m_tableNumber;
	theApp.m_PConn->Execute((_bstr_t)sqlCommand, NULL, adCmdText);


	CString OrderList(""), dishName(""), dishNumbers(""),unitCost,totalCost;
	//将此单点菜信息添加到数据库表
#pragma region
	for (size_t i = 0; i < countNumbers; i++)
	{
		dishName = m_recipeOrderedList.GetItemText(i,0);  //菜名
		dishNumbers = m_recipeOrderedList.GetItemText(i,1); //数量
		sqlCommand = "select * from caishInfo where 菜名='";
		sqlCommand += dishName;
		sqlCommand += "'";

		m_pRs = theApp.m_PConn->Execute((_bstr_t)sqlCommand,NULL,adCmdText);
		unitCost= m_pRs->GetCollect("菜价");
		
		char * puc = (char *)unitCost.GetBuffer(unitCost.GetLength());
		totalCost =(char *)(_bstr_t)( _ttof(unitCost)*_ttof(dishNumbers));
		//totalCost = (char*)(_bstr_t)(atof(puc)*atof((char *)dishNumbers.GetBuffer(dishNumbers.GetLength())));
		//%%%%%%%%%%%此处编写sql语句应当注意中英文符号的切换
		sqlCommand = "insert into paybill(桌号,菜名,数量,消费) values('";
		sqlCommand += m_tableNumber;
		sqlCommand += "','";
		sqlCommand += dishName; sqlCommand += "','";
		sqlCommand += dishNumbers; sqlCommand += "','";
		sqlCommand += totalCost; sqlCommand += "')";
		//sqlCommand = "insert into paybill(桌号,菜名,数量,消费) values('6601','金银豆腐',1,30)";
		theApp.m_PConn->Execute((_bstr_t)sqlCommand,NULL,adCmdText);
	}

	
#pragma endregion
	MessageBox(_T("此订单已被系统接收,请稍后~"));
	CDialog::OnOK();
}
void CDialogProcess::getJfResultFromFile(int model)
{
	CLineComputeView* pView = (CLineComputeView*)((CMainFrame *)AfxGetMainWnd())->GetActiveView();
	CStdioFile file;
	CString fileName;
	if(model == 1)//单独绝缘子
	{
		fileName = _T("single_fpj.dat");
	}
	else//耦合模型
	{
		if(0 == pView->m_data->m_windType)//静风
		{
			fileName = _T("jf_couple_fpj.dat");
		}
	}
	structFpjResult result[10];
	CString path = pView->m_data->m_workspace + _T("\\result\\") + fileName;
	CString line;
	if(!PathFileExists(path))
	{
		MessageBox(_T("结果文件") + path + _T("不存在!"), MsgCaption);
		return ;
	}
	file.Open(path, CStdioFile::modeRead);
	int index = 0;
	while(file.ReadString(line))
	{
		result[index].id = index+1;
		result[index].lh = abs(_ttof(line.Mid(0, 15).TrimLeft()));
		result[index].lv = abs(_ttof(line.Mid(15, 15).TrimLeft()));
		result[index].fpj = abs(_ttof(line.Mid(30, 15).TrimLeft()));
		index ++;
	}
	file.Close();
	if(model==1)//单独绝缘子模型
	{
		for(int i=0; i<index; i++)
		{
			pView->m_data->m_resultSingleFpj[i] = result[i];
		}		
	}
	else //耦合模型
	{
		for(int i=0; i<index; i++)
		{
			pView->m_data->m_resultCoupleFpj[i] = result[i];
		}
	}
}
	void press(){
		CString value;
		GetDlgItemText(IDC_MYEDIT1, value);
		MAX = _ttof(value);
		MAX *= 1.495978707e+11;
		GetDlgItemText(IDC_MYEDIT2, value);
		MOON = _ttof(value);
		GetDlgItemText(IDC_MYEDIT3, value);
		T = _ttof(value);
		T *= 86400;
		GetDlgItemText(IDC_MYEDIT4, value);
		H = _ttof(value);
		H *= 60;
		this->InvalidateRect(0);
	}
Beispiel #9
0
float FileINI_GetFloat(LPCTSTR Section, LPCTSTR Key, float Default)
{
	InitFileINI();
	if(GetPrivateProfileString(Section, Key, NULL, Buffer, sizeof(Buffer), FileINI))
		return (float)_ttof(Buffer);
	return Default;
}
Beispiel #10
0
// elevation conversion
// tempchar = the string containing the elevation value
// unit = the unit for elevation
// return value = the converted elevation with unit; if fail, return original string
void GetElev(TCHAR *tempchar, TCHAR *unit, TCHAR *str) 
{
	// unit can be ft, m
	double tempunit = 0, output;
	int intunit;

	// convert the string to a floating point number (always positive)
	// if it end up with 0, then it's not a number, return the original string and quit
	output = _ttof(tempchar);
	if (output == 0) {
		_tcscpy(str, tempchar);
		return;
	}

	// convert all to m first
	if ( !_tcsicmp(unit, _T("M")))
		tempunit = (double)output;
	else if ( !_tcsicmp(unit, _T("FT")))
		tempunit = (double)output / 3.28;

	// convert to apporiate unit
	switch (opt.eUnit) {
	case 1:
		intunit = (int)((tempunit*10 * 3.28) + 0.5);
		mir_sntprintf(str, MAX_DATA_LEN, _T("%i.%i %s"), intunit/10, intunit%10, opt.DoNotAppendUnit ? _T("") : TranslateT("ft"));
		break;
	case 2:
		intunit = (int)((tempunit*10) + 0.5);
		mir_sntprintf(str, MAX_DATA_LEN, _T("%i.%i %s"), intunit/10, intunit%10, opt.DoNotAppendUnit ? _T("") : TranslateT("m"));
		break;
	default:
		_tcscpy(str, tempchar);
		break;
	}
}
Beispiel #11
0
float CIniFile::GetFloat(CString Section, CString Item, float Value)
{
	CString strtemp;
	strtemp.Format(_T("%f"),Value);
	strtemp = GetFileString(Section, Item, strtemp);
	return  _ttof(strtemp);
}
SyntaxNode *SqlCompiler::fetchDefaultValueNode(const ColumnDefinition &col) {
  if(col.m_defaultValue.length() == 0) { // has no default-value
    if(col.m_nullAllowed)
      return fetchTokenNode(NULLVAL,NULL);
    else
      return NULL; // no default, nulls not allowed. i.e. syntaxError !
  }
  else { // defaultvalue specified. now find the type an return a syntaxnode of the right type
    switch(getMainType(col.getType())) {
    case MAINTYPE_NUMERIC  :
      return fetchNumberNode(_ttof(col.m_defaultValue.cstr()));
    case MAINTYPE_STRING   :
    case MAINTYPE_VARCHAR  :
      return fetchStringNode(col.m_defaultValue.cstr());
    case MAINTYPE_DATE     :
      return fetchDateNode(Date(col.m_defaultValue.cstr()));
    case MAINTYPE_TIME     :
      return fetchTimeNode(Time(col.m_defaultValue.cstr()));
    case MAINTYPE_TIMESTAMP:
      return fetchTimestampNode(Timestamp(col.m_defaultValue.cstr()));
    default               :
      throwSqlError(SQL_FATAL_ERROR,_T("Unexpected datatype in fetchDefaultValueNode:%d col:<%s>\n"),col.getType(),col.m_name.cstr());
      return NULL; //  to make compiler happy
    }
  }
}
int CProcessPara::GetWriteAddrByteIndex()
{
	float temp = _ttof(m_strWriteAddrIndex);
	temp = temp * 10;
	int addIndex = temp / 10; //取十位为字节位置

	return addIndex;
}
Beispiel #14
0
// 阈值
void CImagePage::OnEnKillfocusEdit5()
{
	CString tmp;
	m_thresholdEdit.GetWindowText(tmp);
	double threshold = _ttof(tmp);
	if (threshold < 1.0 || threshold > 3.0)
		m_thresholdEdit.SetWindowText(_T("2.43"));
}
	void press(){
		T = 2.0e+10;
		CString value;
		GetDlgItemText(IDC_MYEDIT1, value);
		Planet.x = _ttof(value);
		Planet.x *= 1.495978707e+11;
		GetDlgItemText(IDC_MYEDIT2, value);
		Planet.y = _ttof(value);
		Planet.y *= 1.495978707e+11;
		GetDlgItemText(IDC_MYEDIT3, value);
		Planet.vx = _ttof(value);
		Planet.vx *= 1.0e+3;
		GetDlgItemText(IDC_MYEDIT4, value);
		Planet.vy = _ttof(value);
		Planet.vy *= 1.0e+3;
		this->InvalidateRect(0);
	}
Beispiel #16
0
void CPIDSet::OnKillfocusKd() 
{
	// TODO: Add your control notification handler code here
	CLYPESolderingApp *pApp=(CLYPESolderingApp*)AfxGetApp();
	CString str;
	GetDlgItemText(IDC_KD,str);
	pApp->mVar.KD=_ttof(str);
}
void CDialogWindType::OnBnClickedOk()
{
	CLineComputeView* pView = (CLineComputeView*)((CMainFrame *)AfxGetMainWnd())->GetActiveView();
	CString str;
	for(int i=0; i<pView->m_data->m_dxSpanNum; i++) 
    { 
		pView->m_data->m_windLength[i].id = _ttoi(m_windApplyLoc->GetItemText(i, 0));
		pView->m_data->m_windLength[i].left = _ttof(m_windApplyLoc->GetItemText(i, 1));
		pView->m_data->m_windLength[i].length = _ttof(m_windApplyLoc->GetItemText(i, 2));		
    }
	pView->m_data->m_windType = m_windType.GetCurSel();
	pView->m_data->m_windApplyMethod = m_windApplyMehtod.GetCurSel();
	
	pView->OnPaint();
	CMainFrame *pmf = (CMainFrame *)AfxGetMainWnd();
	CLineComputeDoc *doc = (CLineComputeDoc *)pmf->GetActiveDocument();
	doc->isSaved = false;//改动数据需要保存
	CDialog::OnOK();
}
Beispiel #18
0
void CalculateDlgChild1::OnDeltaposSpinTimeStepSize(NMHDR *pNMHDR, LRESULT *pResult)
{
    LPNMUPDOWN pNMUpDown = reinterpret_cast<LPNMUPDOWN>(pNMHDR);
    // TODO: Add your control notification handler code here

    //*
    if(pNMUpDown->iDelta > 0) {
        // 响应点击向下
        //::MessageBox(NULL,_T("OKOK"),_T("OKOK"),MB_OK);
        CString tempText ;
        GetDlgItemText(IDC_EDIT_TIME_STEP_SIZE,tempText);
        this->m_edit_time_step_size=(float) _ttof(tempText);

        if (this->m_edit_time_step_size>10.0) {
            tempText.Format(_T("%0.1f"),10.0);
            SetDlgItemText(IDC_EDIT_TIME_STEP_SIZE,tempText);
        }
        if(this->m_edit_time_step_size>1.0) {
            this->m_edit_time_step_size-=0.1f;
            tempText.Format(_T("%0.1f"),this->m_edit_time_step_size);
            SetDlgItemText(IDC_EDIT_TIME_STEP_SIZE,tempText);
        }
    }
    else if(pNMUpDown->iDelta < 0) {
        // 相应点击向上
        CString tempText ;
        GetDlgItemText(IDC_EDIT_TIME_STEP_SIZE,tempText);
        this->m_edit_time_step_size= (float)_ttof(tempText);

        if (this->m_edit_time_step_size<1.0) {
            tempText.Format(_T("%0.1f"),1.0);
            SetDlgItemText(IDC_EDIT_TIME_STEP_SIZE,tempText);
        }
        if (this->m_edit_time_step_size<10.0) {
            this->m_edit_time_step_size+=0.1f;
            tempText.Format(_T("%0.1f"),this->m_edit_time_step_size);
            SetDlgItemText(IDC_EDIT_TIME_STEP_SIZE,tempText);
        }
    }
    //*/

    *pResult = 0;
}
Beispiel #19
0
void CNodeFloat::Update( const PHOTSPOT Spot )
{
    float FloatValue;

    StandardUpdate( Spot );

    FloatValue = (float)_ttof( Spot->Text.GetString( ) );
    if (Spot->Id == HS_EDIT)
        ReClassWriteMemory( (LPVOID)Spot->Address, &FloatValue, sizeof( float ) );
}
Beispiel #20
0
// temperature conversion
// tempchar = the string containing the pressure value
// unit = the unit for pressure
// return value = the converted pressure with unit; if fail, return the original string
void GetPressure(TCHAR *tempchar, TCHAR *unit, TCHAR* str) 
{
	// unit can be kPa, hPa, mb, in, mm, torr
	double tempunit = 0, output;
	int intunit;

	// convert the string to a floating point number (always positive)
	// if it end up with 0, then it's not a number, return the original string and quit
	output = _ttof(tempchar);
	if (output == 0) {
		_tcscpy(str, tempchar); 
		return;
	}

	// convert all to mb first
	if ( !_tcsicmp(unit, _T("KPA")))
		tempunit = (double)output * 10;
	else if ( !_tcsicmp(unit, _T("HPA")))
		tempunit = (double)output;
	else if ( !_tcsicmp(unit, _T("MB")))
		tempunit = (double)output;
	else if ( !_tcsicmp(unit, _T("IN")))
		tempunit = (double)output * 33.86388;
	else if ( !_tcsicmp(unit, _T("MM")))
		tempunit = (double)output * 1.33322;
	else if ( !_tcsicmp(unit, _T("TORR")))
		tempunit = (double)output * 1.33322;

	// convert to apporiate unit
	switch (opt.pUnit) {
	case 1:
		intunit = (int)(tempunit + 0.5);
		mir_sntprintf(str, MAX_DATA_LEN, _T("%i.%i %s"), intunit/10, intunit%10, opt.DoNotAppendUnit ? _T("") : TranslateT("kPa"));
		break;
	case 2:
		intunit = (int)(tempunit + 0.5);
		mir_sntprintf(str, MAX_DATA_LEN, _T("%i %s"), intunit, opt.DoNotAppendUnit ? _T("") : TranslateT("mb"));
		break;
	case 3:
		intunit = (int)((tempunit*10 / 33.86388) + 0.5);
		mir_sntprintf(str, MAX_DATA_LEN, _T("%i.%i %s"), intunit/10, intunit%10, opt.DoNotAppendUnit ? _T("") : TranslateT("in"));
		break;
	case 4:
		intunit = (int)((tempunit*10 / 1.33322) + 0.5);
		mir_sntprintf(str, MAX_DATA_LEN, _T("%i.%i %s"), intunit/10, intunit%10, opt.DoNotAppendUnit ? _T("") : TranslateT("mm"));
		break;
	default:
		_tcscpy(str, tempchar); 
		break;

	}
}
int CProcessPara::GetWriteBitOffSet()
{
	float temp = _ttof(m_strWriteAddrIndex);

	temp = temp * 10;
	int addrIndex = (int)temp;
	int offset = addrIndex % 10; //获取BIT的位置

	if (offset >= 8)
	{
		offset = 0;
	}
	return offset;
}
Beispiel #22
0
// エリアコードを取得する
void CJpnAreaMeshDlg::OnBnClickedBtnGetMeshCode()
{
	// 緯度
	CString strLat;
	this->m_edtLat.GetWindowText(strLat);
	const double dLat = _ttof(strLat);

	// 経度
	CString strLon;
	this->m_edtLon.GetWindowText(strLon);
	const double dLon = _ttof(strLon);

	// 独自メッシュコード?
	const bool bIsDokujiMesh = (this->m_chkDokujiMeshCode.GetCheck() == BST_CHECKED) ? true : false;

	// メッシュコード取得
	const CString strMeshCode = this->GetMeshCode(dLat, dLon, bIsDokujiMesh);
	TRACE(strMeshCode + _T("\n"));

	// メッシュコード表示
	CString strResultMsg;
	strResultMsg.Format(_T("メッシュコード : %s"), strMeshCode);
	MessageBox(strResultMsg);
}
void CDlgAppConfig::OnBnClickedOk()
{
	// TODO: 在此添加控件通知处理程序代码
	App_Config appconfig;
	CString strTmp;
	GetDlgItemText(EDIT_SECOND,strTmp);
	appconfig.nSeconds =_ttoi((LPCTSTR)strTmp);  
	GetDlgItemText(EDIT_RECORD,strTmp);
	appconfig.nMinRecord =_ttoi((LPCTSTR)strTmp);  
	GetDlgItemText(EDIT_REST,strTmp);
	appconfig.dRest =_ttof((LPCTSTR)strTmp);  
	GetDlgItemText(EDIT_LINGER,strTmp);
	appconfig.dLinger =_ttof((LPCTSTR)strTmp);  
	GetDlgItemText(EDIT_RUN,strTmp);
	appconfig.dRun =_ttof((LPCTSTR)strTmp);  
	if (G_WriteAppConfigToDB(appconfig)){
		g_app_config.nSeconds=appconfig.nSeconds;
		g_app_config.nMinRecord=appconfig.nMinRecord;
		g_app_config.dRest=appconfig.dRest;
		g_app_config.dLinger=appconfig.dLinger;
		g_app_config.dRun=appconfig.dRun;
	}
	CDialogSK::OnOK();
}
int Calculations::doConversionToDecimalRealPart(CString primaryNumberRealPart, double numberSystem)
{
	index = 0;
	resultInt = 0;

	for (int i = primaryNumberRealPart.GetLength() - 1; i >= 0; i--)
	{
		symbol = primaryNumberRealPart.Mid(index, 1);
		index++;
		singleNumber = _ttof(symbol);
		resultInt = resultInt + singleNumber * pow(numberSystem, i);
	}

	return resultInt;
}
double Calculations::doConversionToDecimalDecimalPart(CString primaryNumberDecimalPart, double numberSystem)
{
	index = 0;
	resultDouble = 0.0;

	for (int i = 1; i <= primaryNumberDecimalPart.GetLength(); i++)
	{
		symbol = primaryNumberDecimalPart.Mid(index, 1);
		index++;
		symbolDouble = _ttof(symbol);
		resultDouble = resultDouble + (symbolDouble * pow(numberSystem, (-i)));
	}

	return resultDouble;
}
Beispiel #26
0
// 将 TAB控件“变形镜控制矩阵”标签页的EDIT控件 中的值刷入变形镜
void CDeformMirrorDlg::OnBnClickedButtonSubdlgSubapertureLoad()
{
	// TODO: Add your control notification handler code here
	float temp = 0;
	for (int k_index = 0; k_index < 144; ++k_index)
	{
		GetDlgItem(IDC_EDIT_DM_M001 + k_index)->GetWindowText(m_Edit_DM[k_index]);
		temp = _ttof(m_Edit_DM[k_index]);  // 一维数组转为二维数组
		zernikeMatrix_recon[k_index / 12][k_index % 12] = (temp - 1200) / (500 * pid_d);

	}
	
	write_2d_File("D:\\externLib\\AOS\\Output\\TAB_ZernikeMatrixLoad.txt", zernikeMatrix_recon);


}
Beispiel #27
0
// temperature conversion
// tempchar = the string containing the temperature value
// unit = the unit for temperature
// return value = the converted temperature with degree sign and unit; if fails, return N/A
void GetTemp(TCHAR *tempchar, TCHAR *unit, TCHAR* str) 
{
	// unit can be C, F
	double temp;
	TCHAR tstr[20];

	TrimString(tempchar);
	if (tempchar[0] == '-' && tempchar[1] == ' ')
		memmove(&tempchar[1], &tempchar[2], sizeof(TCHAR)*(_tcslen(&tempchar[2])+1));

	// quit if the value obtained is N/A or not a number
	if ( !_tcscmp(tempchar, NODATA) || !_tcscmp(tempchar, _T("N/A"))) {
		_tcscpy(str, tempchar);
		return;
	}
	if ( !is_number(tempchar)) {
		_tcscpy(str, NODATA);
		return;
	}

	// convert the string to an integer
	temp = _ttof(tempchar);

	// convert all to F first
	if ( !_tcsicmp(unit, _T("C")))		temp = (temp*9/5)+32;
	else if ( !_tcsicmp(unit, _T("K")))	temp = ((temp-273.15)*9/5)+32;

	// convert to apporiate unit
	switch (opt.tUnit) {
	case 1:
		// rounding
		numToStr((temp-32)/9*5, tstr, SIZEOF(tstr));
		if (opt.DoNotAppendUnit)
			mir_sntprintf(str, MAX_DATA_LEN, _T("%s"), tstr);
		else
			mir_sntprintf(str, MAX_DATA_LEN, _T("%s%sC"), tstr, opt.DegreeSign);
		break;

	case 2:
		numToStr(temp, tstr, SIZEOF(tstr));
		if (opt.DoNotAppendUnit)
			mir_sntprintf(str, MAX_DATA_LEN, _T("%s"), tstr);
		else
			mir_sntprintf(str, MAX_DATA_LEN, _T("%s%sF"), tstr, opt.DegreeSign);
		break;
	}
}
Beispiel #28
0
BOOL ManagerChartNew::OnInitDialog()
{
	CDialogEx::OnInitDialog();

	///////////////////////////////产生图表
	CSeries0 lineSeries = (CSeries0)m_chartnew.Series(0);
	lineSeries.Clear();




	CString sqlstr;
	sqlstr.Format(_T("CREATE OR REPLACE VIEW `view_day_property`AS SELECT * FROM day_property ORDER BY day_property.dayproperty_id DESC LIMIT 10;"));
	CDatabase db;
	db.Open("bankmanagement");
	db.ExecuteSQL(sqlstr);
	sqlstr.Format(_T("select day_time,bank_balance from view_day_property  ORDER BY dayproperty_id ASC;"));
	CRecordset rs(&db);
	rs.Open(CRecordset::forwardOnly, (_T("%s"), sqlstr));
	CString strx, strbalance;
	double daybalance;


	for (int i = 0; i<10; i++)
	{

		CString varDayTime;
		rs.GetFieldValue(_T("day_time"), varDayTime);
		strx.Format(_T("%s"), varDayTime);

		CString varBankBalance;
		rs.GetFieldValue(_T("bank_balance"), varBankBalance);
		strbalance.Format(_T("%s"), varBankBalance);
		daybalance = _ttof(strbalance);

		lineSeries.AddXY((double)i, daybalance, strx, 0);
		rs.MoveNext();
	}

	rs.Close();


	db.Close();


	return true;
}
Beispiel #29
0
// speed conversion
// tempchar = the string containing the speed value
// unit = the unit for speed
// return value = the converted speed with unit; if fail, return _T(""
void GetSpeed(TCHAR *tempchar, TCHAR *unit, TCHAR *str) 
{
	// unit can be km/h, mph, m/s, knots
	double tempunit;
	TCHAR tstr[20];

	str[0] = 0;

	// convert the string into an integer (always positive)
	// if the result is 0, then the string is not a number, return _T(""
	tempunit = _ttof(tempchar);
	if (tempunit == 0 && tempchar[0] != '0')
		return;

	// convert all to m/s first
	if ( !_tcsicmp(unit, _T("KM/H")))
		tempunit /= 3.6;
//	else if ( !_tcsicmp(unit, _T("M/S"))
//		tempunit = tempunit;
	else if ( !_tcsicmp(unit, _T("MPH")))
		tempunit *= 0.44704;
	else if ( !_tcsicmp(unit, _T("KNOTS")))
		tempunit *= 0.514444;

	// convert to apporiate unit
	switch (opt.wUnit) {
	case 1:
		numToStr(tempunit * 3.6, tstr, SIZEOF(tstr));
		mir_sntprintf(str, MAX_DATA_LEN, _T("%s %s"), tstr, opt.DoNotAppendUnit ? _T("") : TranslateT("km/h"));
		break;
	case 2:
		numToStr(tempunit, tstr, SIZEOF(tstr));
		mir_sntprintf(str, MAX_DATA_LEN, _T("%s %s"), tstr, opt.DoNotAppendUnit ? _T("") : TranslateT("m/s"));
		break;
	case 3:
		numToStr(tempunit / 0.44704, tstr, SIZEOF(tstr));
		mir_sntprintf(str, MAX_DATA_LEN, _T("%s %s"), tstr, opt.DoNotAppendUnit ? _T("") : TranslateT("mph"));
		break;
	case 4:
		numToStr(tempunit / 0.514444, tstr, SIZEOF(tstr));
		mir_sntprintf(str, MAX_DATA_LEN, _T("%s %s"), tstr, opt.DoNotAppendUnit ? _T("") : TranslateT("knots"));
		break;
	}
}
CString Calculations::doConversionFromDecimalRealPart(CString primaryNumberRealPart, int numberSystem)
{
	primaryNumberRealPartInt = _ttof(primaryNumberRealPart);
	result = _T("");

	if (primaryNumberRealPartInt == 0)
	{
		result = '0';
	}

	while (primaryNumberRealPartInt >= numberSystem)
	{
		copyPrimaryNumberRealPartInt = primaryNumberRealPartInt;
		primaryNumberRealPartInt = primaryNumberRealPartInt / numberSystem;
		singleNumber = copyPrimaryNumberRealPartInt - numberSystem * primaryNumberRealPartInt;
		if (singleNumber < 10)
		{
			symbol = doConversionIntToCString(singleNumber);
			result = symbol + result;
		}
		else
		{
			result = symbolsString[singleNumber - 10] + result;
		}
	}

	if (primaryNumberRealPartInt != 0)
	{
		copyPrimaryNumberRealPartInt = primaryNumberRealPartInt;
		primaryNumberRealPartInt = primaryNumberRealPartInt / numberSystem;
		singleNumber = copyPrimaryNumberRealPartInt - numberSystem * primaryNumberRealPartInt;
		if (singleNumber < 10)
		{
			symbol = doConversionIntToCString(singleNumber);
			result = symbol + result;
		}
		else
		{
			result = symbolsString[singleNumber - 10] + result;
		}
	}

	return result;
}