Пример #1
0
void CMainDlg::ThreadConnectFn( ) 
{
	WTL::CComboBox port ;
	port.Attach( GetDlgItem( IDC_COMBO_RS232 ) ) ;
	int sel = port.GetCurSel( ) ;
	if ( sel == -1 ){
		MessageBox( "Выберите ком-порт" , "Внимание" , MB_OK | MB_ICONWARNING ) ;
		port.Detach() ;
		_endthread( ) ;
	}
	char szPortName[ 1024 ] ;
	*szPortName = NULL ;
	if ( port.GetLBTextLen( sel ) < 1 ) {
		MessageBox( "Выбрано пустое имя, выберите имя порта, начинающееся с COM.." , 
			"Внимание" , MB_OK | MB_ICONWARNING ) ;
		port.Detach( ) ;
		_endthread( ) ;
	}
	port.GetLBText( sel , szPortName ) ;
	port.Detach( ) ;

	char status[ 1024 ] ;
	*status = NULL ;
	sprintf( status , "Попытка подключиться к %s ..." , szPortName ) ;
	Status( status ) ;

	BOOL ok = FALSE ;
	ok = Connect( szPortName ) ;

	if ( !ok ){
		Disconnect() ;
		sprintf( status , "FAILED!Не могу подкл-ся к %s !!!" , szPortName ) ;
		StatusAppendLine( status ) ;
		_endthread( ) ;
	}else{
		sprintf( status , "OK! Подключиться к %s удалось успешно!" , szPortName ) ;
		StatusAppendLine( status ) ;
	}
	
	/*
	вставить обработку отсутствия АЦП
	if ( AdcGetCount( ) < 1 ){
		sprintf( status , "WARN! Не найдено ни одного модуля АЦП" ) ;
		StatusAppendLine( status ) ;
		Disconnect( ) ;
		sprintf( status , "OK! Произведено отключение от %s" , szPortName ) ;
		StatusAppendLine( status ) ;
		_endthread( ) ;
	}*/

	m_status = CONNECTED ;
	UpdateControls( ) ;

	HANDLE h = TableGetHandle( 0 ) ;
	if ( h ) TableCallback( h , UpdatePos ) ;

	_endthread( ) ;

}
Пример #2
0
std::set<Item> RecipePanel::getItemList(const std::list<Item>& itemsInDatabase) const {
    WTL::CComboBox templatecb = GetDlgItem(IDC_RECIPECOMBO);
    if (templatecb.GetCurSel() > 0) {
        TCHAR buf[256] = {0};
        templatecb.GetLBText(templatecb.GetCurSel(), buf);
        std::tstring recipe(buf);

        const RecipeList* const r = m_recipeLoader.getRecipe(recipe);
        if (r == NULL)
            return std::set<Item>();
        else
            return r->getItemList(itemsInDatabase);
    }
    else
        return std::set<Item>();
}
Пример #3
0
std::list<unsigned int> RecipePanel::getDesiredItemRefs() const {
    WTL::CComboBox templatecb = GetDlgItem(IDC_RECIPECOMBO);
    if (templatecb.GetCurSel() > 0) {
        TCHAR buf[256] = {0};
        templatecb.GetLBText(templatecb.GetCurSel(), buf);
        std::tstring recipe(buf);

        const RecipeList* const r = m_recipeLoader.getRecipe(recipe);
        if (r == NULL)
            return std::list<unsigned int>();
        else
            return r->getDesiredItemRefs();
    }
    else
        return std::list<unsigned int>();
}
Пример #4
0
std::tstring RecipePanel::getRecipeName() const {

    WTL::CComboBox templatecb = GetDlgItem(IDC_RECIPECOMBO);
    if (templatecb.GetCurSel() > 0) {
        TCHAR buf[256] = {0};
        templatecb.GetLBText(templatecb.GetCurSel(), buf);
        std::tstring recipe(buf);

        const RecipeList* const r = m_recipeLoader.getRecipe(recipe);
        if (r == NULL)
            return _T("Unknown recipe??");
        else
            return r->getName();
    }
    else
        return _T("Unknown recipe??");
}