BST_ERR_ENUM_UINT8  BST_DSPP_CUlLayerBase::Pack ( BST_DSPP_HEAD_STRU *const pstTxHeadInfo )
{
    BST_DSPP_CUlLayerBase              *pcNextLayer;
    BST_DSPP_VERION_ENUM_UINT8          enNextVer;
    BST_ERR_ENUM_UINT8                  ucRrnVal;

    enNextVer                           = BST_DSPP_VER_INVALID;
    pcNextLayer                         = BST_NULL_PTR;

    ucRrnVal                            = PackInternal ( pstTxHeadInfo, &enNextVer );
    if ( BST_NO_ERROR_MSG != ucRrnVal )
    {
        return BST_ERR_LAYER_VER;
    }

    if ( BST_DSPP_VER_VOID == enNextVer )
    {
        return BST_ERR_LAYER_VER;
    }

    pcNextLayer                         = GetNextStrategy ( enNextVer );
    if ( BST_NULL_PTR != pcNextLayer )
    {
        ucRrnVal                        = pcNextLayer->Pack ( pstTxHeadInfo );
    }
    else
    {
        ucRrnVal                        = BST_NO_ERROR_MSG;
    }
    return ucRrnVal;
}
BST_ERR_ENUM_UINT8  BST_DSPP_CDlLayerBase::UnPack ( BST_DSPP_HEAD_STRU *const pstRxHeadInfo )
{
    BST_DSPP_CDlLayerBase              *pcNextLayer;
    BST_DSPP_VERION_ENUM_UINT8          enNextVer;
    BST_ERR_ENUM_UINT8                  ucRtnVal;

    enNextVer                           = BST_DSPP_VER_INVALID;
    pcNextLayer                         = BST_NULL_PTR;
    BST_DBG_LOG ( "BST_DSPP_CDlLayerBase::UnPack is called" );

    ucRtnVal                            =  UnpackInternal ( pstRxHeadInfo, &enNextVer );
    if ( BST_NO_ERROR_MSG != ucRtnVal )
    {
        BST_RLS_LOG1( "BST_DSPP_CDlLayerBase::UnPack UnpackInternal Err=%u",
                      ucRtnVal );
        return BST_ERR_LAYER_VER;
    }

    if ( BST_DSPP_VER_VOID == enNextVer )
    {
        return BST_ERR_LAYER_VER;
    }

    pcNextLayer                         = GetNextStrategy ( enNextVer );
    if ( BST_NULL_PTR != pcNextLayer )
    {
        ucRtnVal                        = pcNextLayer->UnPack ( pstRxHeadInfo );
    }
    else
    {
        ucRtnVal                        = BST_NO_ERROR_MSG;
    }
    return ucRtnVal;
}
Ejemplo n.º 3
0
BOOL CStkUIApp::ExistStrategy( CStrategy * pStrategy )
{
	POSITION pos = GetFirstStrategyPosition( );
	while( NULL != pos )
	{
		CStrategy * p = GetNextStrategy( pos );
		if( p == pStrategy )
			return TRUE;
	}
	return FALSE;
}
Ejemplo n.º 4
0
CStrategy* CStkUIApp::OpenStrategyFile( LPCTSTR lpszPathName )
{
	// Resolve File Name
	TCHAR szPath[_MAX_PATH];
	ASSERT(lstrlen(lpszPathName) < sizeof(szPath));
	if( NULL != lpszPathName )
	{
		TCHAR szTemp[_MAX_PATH];
		if (lpszPathName[0] == '\"')
			++lpszPathName;
		lstrcpyn(szTemp, lpszPathName, _MAX_PATH);
		LPTSTR lpszLast = _tcsrchr(szTemp, '\"');
		if (lpszLast != NULL)
			*lpszLast = 0;
		AfxFullPath(szPath, szTemp);
		TCHAR szLinkName[_MAX_PATH];
		if (AfxResolveShortcut(AfxGetMainWnd(), szPath, szLinkName, _MAX_PATH))
			lstrcpy(szPath, szLinkName);
	}

	if( NULL != lpszPathName )
	{
		POSITION pos = GetFirstStrategyPosition();
		while (pos != NULL)
		{
			CStrategy* pStrategy = GetNextStrategy(pos);
			if( 0 == pStrategy->GetPathName().CompareNoCase( szPath ) )
			{
				if( m_bAutoUpdateViews )
				{
					::SendMessage( AfxGetStrategyView()->GetSafeHwnd(), WM_USER_ACTIVATESTRATEGY, DWORD(pStrategy), 0 );
					AfxGetStaticDoc()->UpdateAllViews( NULL, UPDATE_HINT_WIZARDVIEW, NULL );
					// AfxGetMainFrame()->ShowWorkspBar( );
				}
				return pStrategy;
			}
		}
	}

	CStrategy   * pStrategy = new CStrategy();
	if( NULL == pStrategy )
		return NULL;
	char	szErr[256];
	if( !pStrategy->OpenStrategyFile( szPath, szErr, sizeof(szErr)-1 ) )
	{
		AfxMessageBox( szErr, MB_OK|MB_ICONINFORMATION );
		delete	pStrategy;
		return NULL;
	}
	
	AddStrategy( pStrategy );
	return pStrategy;
}
Ejemplo n.º 5
0
BOOL CStkUIApp::IsFileOpened( LPCTSTR lpszFileName )
{
	POSITION pos = GetFirstStrategyPosition();
	while (pos != NULL)
	{
		CStrategy* pStrategy = GetNextStrategy(pos);
		if( 0 == pStrategy->GetPathName().CompareNoCase( lpszFileName ) )
		{
			return TRUE;
		}
	}
	return FALSE;
}
Ejemplo n.º 6
0
void CStkUIApp::SaveLastOpenedStrategy( )
{
	CSPStringArray astr;
	POSITION	pos	=	GetFirstStrategyPosition();
	while(pos != NULL)
	{
		CStrategy* pStrategy = GetNextStrategy(pos);
		if( pStrategy )
			astr.Add( pStrategy->GetPathName() );
	}

	AfxGetProfile().SetLastOpenedStrategy( astr );
}
Ejemplo n.º 7
0
CString	CStkUIApp::GetNextNewStrategyTitle( CString & strExtBuffer, CString strPath )
{
	CString	string;
	VERIFY( string.LoadString( IDS_STRATEGY_NONAME ) );

	CString strExt	=	AfxGetStrategyFileExt( );
	if( !strExt.IsEmpty())
		strExtBuffer	=	strExt;

	CStringArray	astrExistTitle;
	POSITION pos = GetFirstStrategyPosition();
	while( NULL != pos )
	{
		CStrategy * pStrategy = GetNextStrategy( pos );
		astrExistTitle.Add( AfxGetFileTitleNoExt(pStrategy->GetPathName()) );
	}

	CFileFind finder;
	BOOL	bWorking	=	finder.FindFile( AfxGetFilePath( (LPCTSTR)strPath, LPCTSTR("*" + strExt) ) );
	while( bWorking )
	{
		bWorking	=	finder.FindNextFile();
		astrExistTitle.Add( finder.GetFileTitle( ) );
	}
	finder.Close();

	for( int i=1; ; i++ )
	{
		CString	strTemp;
		strTemp.Format( "%s(%d)", string, i );
		
		BOOL	bHas	=	FALSE;
		for( int k=0; k<astrExistTitle.GetSize(); k++ )
		{
			if( 0 == strTemp.CompareNoCase( astrExistTitle.ElementAt(k) ) )
			{
				bHas	=	TRUE;
				break;
			}
		}
		
		if( !bHas )
		{
			string	=	strTemp;
			break;
		}
	}
	return string;
}
Ejemplo n.º 8
0
void CStkUIApp::CloseAllStrategy( BOOL bEndSession )
{
	POSITION pos = GetFirstStrategyPosition();
	while (pos != NULL)
	{
		CStrategy* pStrategy = GetNextStrategy(pos);
		pStrategy->OnClose();
		delete	pStrategy;
	}
	m_strategyList.RemoveAll();
	
	if( ! bEndSession && m_bAutoUpdateViews )
	{
		::SendMessage( AfxGetStrategyView()->GetSafeHwnd(), WM_USER_REMOVESTRATEGY, 0, 0 );
		AfxGetStaticDoc()->UpdateAllViews( NULL, UPDATE_HINT_WIZARDVIEW, NULL );
	}
}