BOOL CDomainListBox::SetCurrentStocks( int nType, LPCTSTR lpszDomain, CDomainContainer & groups )
{
	// Delete All
	ResetContent( );

	CStockContainer & container = AfxGetStockContainer();
	CStockContainer cntn;

	BOOL	bOK	=	FALSE;
	if( nType == CStockContainer::typeGroup )
	{
		CSPStringArray	astrSpecify;
		if( groups.GetDomainStocks( lpszDomain, astrSpecify ) )
			bOK	=	cntn.RetrieveSpecify( astrSpecify );	//	Not Set dwDate
	}
	else
	{
		bOK	=	cntn.RetrieveFromStatic( nType, lpszDomain, NULL, -1 );
	}

	if( bOK )
	{
		InitStorage( cntn.GetSize(), 32 );
		for( int i=0; i<cntn.GetSize(); i++ )
		{
			CStockInfo & info = cntn.ElementAt(i);
			CString	strItem	=	CString(info.GetStockCode()) + "(" + info.GetStockShortName() + ")    ";
			while( strItem.GetLength() < 16 )	strItem	+=	" ";
			strItem	+= info.GetStockName() ;
			int nItem = AddString( strItem );
		}
	}

	return bOK;
}
示例#2
0
文件: main.c 项目: chenneal/postsi
int main(int argc, char *argv[])
{
	pid_t pid;

	/* do some ready work before start the distributed system */
	GetReady();

	if ((pid = fork()) < 0)
	{
	   printf("fork error\n");
	}

	else if(pid == 0)
	{
		int i;
		/* storage process */
		InitStorage();
		ExitSys();
		printf("storage process finished.\n");
	}

	else
	{
	   /* transaction process */
	   InitTransaction();
       dataLoading();
       /* wait other slave nodes until all of them have loaded data. */
       WaitDataReady();
       /* begin run the benchmark. */
       RunTerminals(THREADNUM);

	   printf("transaction process finished.\n");
	}
	return 0;
}
BOOL CSearchBox::InitStocks( BOOL bHasSTTTech, BOOL bShowOnSel, BOOL bDuplicate )
{
	ResetContent( );

	m_bShowOnSel	=	bShowOnSel;

	CStockContainer & container	=	AfxGetStockContainer();
	InitStorage( bDuplicate ? container.GetSize()*2 : container.GetSize(), 32 );
	for( int i=0; i<container.GetSize(); i++ )
	{
		CStockInfo	& info	=	container.ElementAt(i);
		if( !info.IsValidStock() )
			continue;

		CString	strTemp	=	info.GetStockCode();
		while( strTemp.GetLength() < 8 )
			strTemp	+=	' ';
		strTemp	+=	info.GetStockName();
		int	nItem	=	AddString( strTemp );
		SetItemData( nItem, i );

		if( bDuplicate )
		{
			strTemp	=	info.GetStockShortName();
			while( strTemp.GetLength() < 8 )
				strTemp	+=	' ';
			strTemp	+=	info.GetStockName();
			if( CB_ERR == SelectString( 0, strTemp ) )
			{
				nItem = AddString( strTemp );
				SetItemData( nItem, i );
			}
		}
	}
	if( bHasSTTTech )
	{
		// 技术指标项
		UINT nTechUserCount = CTechUser::GetTechUserCount();
		for( UINT i=STT_MIN; i <= STT_MAX+nTechUserCount; i ++ )
		{
			UINT	nTech	=	i;
			if( nTech > STT_MAX )
				nTech	=	i-STT_MAX-1+STT_USER_MIN;
		
			CString	strTemp	=	AfxGetSTTShortName( nTech );
			while( strTemp.GetLength() < 8 )
				strTemp	+=	' ';
			strTemp	+=	AfxGetSTTName( nTech );
			int	nItem	=	AddString( strTemp );
			SetItemData( nItem, nTech | SEARCHBOX_SIGNBIT_STT );
		}
		// 快捷键项
		for( UINT i = ACCE_MIN; i <= ACCE_MAX; i++ )
		{
			CString	strTemp	=	AfxGetAccelerator( i, 8 );
			SetItemData( AddString(strTemp), i | SEARCHBOX_SIGNBIT_ACCE );
		}
	}
	return TRUE;
}
示例#4
0
void CFontComboBox::FillFontList()
{
	//根据桌面DC的属性枚举系统的字体信息
	CDC* pDesktopDC = GetDesktopWindow()->GetWindowDC();       //取DC
	HDC hdc = pDesktopDC->GetSafeHdc();
	LOGFONT lf;
	::ZeroMemory(&lf, sizeof(lf));
	lf.lfCharSet = DEFAULT_CHARSET;
	::EnumFontFamilies(hdc,NULL, (FONTENUMPROC)EnumFontProc,(LPARAM)this);
	GetDesktopWindow()->ReleaseDC(pDesktopDC);      //释放DC
	//运用STL算法进行自定义的对象排序
	//std::sort(m_pFontVec.begin(), m_pFontVec.end(), CFontComboBox::CompareFontName);
	InitStorage(300, LF_FACESIZE);
	//加入字体名称到组合框
	for(UINT N=0; N<m_pFontVec.size(); ++N)
	{
		CString fontname = m_pFontVec[N]->GetFontName();
		if (fontname.Find(_T("@")) != 0)
			AddString(fontname);
	}
	//加载COMDLG32.DLL
	HMODULE hModule = ::LoadLibraryEx(_T("COMDLG32.DLL"), NULL,
		DONT_RESOLVE_DLL_REFERENCES);
	ASSERT (hModule != NULL);
	//加载成功后从这个DLL中加载字体图片
	m_FontBmp = (HBITMAP)::LoadImage(hModule, MAKEINTRESOURCE(38), 
		IMAGE_BITMAP, 100, 24, LR_DEFAULTCOLOR);
	ASSERT(m_FontBmp != NULL);
	::FreeLibrary(hModule);
}
示例#5
0
static INT32 win_otaupg_burnflash(void)
{
    ota_proc_ret = 0;
    ota_user_stop = 0;
    ota_proc_step = OTA_STEP_BURNFLASH;

    osal_flag_clear(g_ota_flg_id,OTA_FLAG_PTN);

#if 1
    InitStorage();
    SetupOtaParameters();
    INT32 ret = BurnFlash();
    osal_flag_set(g_ota_flg_id,(ret == SUCCESS)?PROC_SUCCESS:PROC_FAILURE);
#else

    ota_start_burnflash(win_ota_upgrade_process_update);
#endif
}
BOOL CDateComboBox::InitDates( )
{
	ResetContent( );

	// Add Date ComboBox Members
	CSPDWordArray dwArray;
	AfxGetStockContainer().GetTechDateArray( dwArray );

	InitStorage( dwArray.GetSize()+2, 32 );

	CString strMore;
	strMore.LoadString( IDS_DATECOMBOBOX_MORE );
	int nIndex = AddString( strMore );
	SetItemData( nIndex, -2 );

	/*int	nMaxDaysCalculate	=	AfxGetProfile().GetMaxDaysCalculate( );*/
	// for( int nCount=dwArray.GetSize()-1; nCount >= 0/*nCount > nMaxDaysCalculate*/; nCount -- )
	for( int nCount=0; nCount < dwArray.GetSize(); nCount ++ )
	{
		CSPTime	sptime;
		if( sptime.FromStockTimeDay( dwArray[nCount] ) )
		{
			CSPTime	time( sptime.GetTime() );
			CString	strItem	=	AfxGetTimeString( time.GetTime(), szDateComboBoxTimeFormat, TRUE );
			if( strItem.GetLength() > 0 )
			{
				int nIndex = AddString( strItem );
				SetItemData( nIndex, dwArray[nCount] );
			}
		}
	}

	CString strNow;
	strNow.LoadString( IDS_DATECOMBOBOX_NOW );
	nIndex = AddString( strNow );
	SetItemData( nIndex, -1 );
	SetCurSel( nIndex );

	return TRUE;
}
示例#7
0
bool GetVHDInfo(const string& DeviceName, string &strVolumePath, VIRTUAL_STORAGE_TYPE* StorageType)
{
	const os::fs::file Device(DeviceName, FILE_READ_ATTRIBUTES, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, nullptr, OPEN_EXISTING);
	if (!Device)
		return false;

	block_ptr<STORAGE_DEPENDENCY_INFO> StorageDependencyInfo;

	const auto& InitStorage = [&](size_t Size)
	{
		StorageDependencyInfo.reset(Size);
		StorageDependencyInfo->Version = STORAGE_DEPENDENCY_INFO_VERSION_2;
	};

	DWORD Size = 4096;

	for (;;)
	{
		InitStorage(Size);
		if (Device.GetStorageDependencyInformation(GET_STORAGE_DEPENDENCY_FLAG_HOST_VOLUMES, Size, StorageDependencyInfo.get(), &Size))
			break;
		if (GetLastError() != ERROR_INSUFFICIENT_BUFFER)
			return false;
	}

	if (!StorageDependencyInfo->NumberEntries)
		return false;

	if(StorageType)
		*StorageType = StorageDependencyInfo->Version2Entries[0].VirtualStorageType;

	strVolumePath = StorageDependencyInfo->Version2Entries[0].HostVolumeName;
	strVolumePath += StorageDependencyInfo->Version2Entries[0].DependentVolumeRelativePath;
	// trick: ConvertNameToReal also converts \\?\{GUID} to drive letter, if possible.
	strVolumePath = ConvertNameToReal(strVolumePath);

	return true;
}
示例#8
0
文件: main.c 项目: chenneal/postsi
int main(int argc, char *argv[])
{
	pid_t pid;

	GetReady();

    if ((pid = fork()) < 0)
    {
    	printf("fork error\n");
    }

    else if(pid == 0)
    {
    	/* shmget the shared memory address*/
    	BindShmem();

    	InitStorage();

    	printf("storage process finished.\n");
    }

    else
    {
    	InitTransaction();

    	/* load the benchmark data */
    	dataLoading();
    	/* wait other nodes in the distributed system prepare the data */
    	WaitDataReady();
    	/* run the benchmark */
    	RunTerminals(THREADNUM);

    	printf("transaction process finished.\n");
    }
	return 0;
}
示例#9
0
void UDPReceive (enum Options option, int i_PktNumb)
{
  int nLen, inum = 0, nSelect = 0;
  char szBuf[4096];
  int nRet, errgen=0;
  struct sockaddr_in saUDPClient;
  struct timeval timeout;           // Timeout for select
  fd_set rfds;

  nLen = sizeof(saUDPClient);

  // Initial storage, wait for data from the client
  InitStorage(); 

  // if packetpair, double the packet number.
  if (option == PacketPair) i_PktNumb = 2 * i_PktNumb;

  // Use select to control timeout for 300 ms
  FD_ZERO(&rfds);
  FD_SET(udpSocket, &rfds);

  while(inum < i_PktNumb){
    timeout.tv_sec = 0;             // reset the timout value
    timeout.tv_usec = 300000;       // to 300 ms

    memset(szBuf, 0, sizeof(szBuf));
    nSelect = select(udpSocket+1, &rfds, NULL, NULL, &timeout);
    if ( nSelect < 0) {
      perror("Failed in select function");
      break;
    } 
    else if (nSelect == 0) {
      printf("Receiving UDP packets timeout (300 ms).\n");
      break;
    }
    else {
      nRet = recvfrom(udpSocket,             // Bound socket
		      szBuf,                 // Receive buffer
		      sizeof(szBuf),         // Size of buffer in bytes
		      0,                     // Flags
		      (struct sockaddr *)&saUDPClient, // Buffer to receive client address 
		      &nLen);                // Length of client address buffer
      ////////////////////////
      //   if (errgen%6 == 0) nRet = -1;// Robust test for randomly packet lost at receiver.
      //   if (errgen > 15 && errgen < 25) nRet = -1;// Robust test for bursty lost at receiver.
           errgen++; // for test
      ////////////////////

      if (nRet > 0) {
	gettimeofday(&arrival[inum], NULL);
	seq[inum] = ((struct PP_Pkt *) &szBuf)->seq;
	sendtime[inum] = ((struct PP_Pkt *) &szBuf)->tstamp;
	psize[inum] = nRet;
	if (seq[inum] == i_PktNumb - 1) break;
	inum++;
      }
    }
  }
  return;

} // end UDPReceive()
示例#10
0
int CDomainComboBox::InitStrings( BOOL bHasClass, BOOL bHasDomain, CDomainContainer & groups )
{
	ResetContent( );

	CDomainContainer & domains = AfxGetDomainContainer( );
	CStockContainer & container = AfxGetStockContainer();

	int	nItemCount	=	groups.GetSize();
	if( bHasClass )		nItemCount	+=	8;
	if( bHasDomain )	nItemCount	+=	domains.GetSize();
	
	// Init Storage
	InitStorage( nItemCount, 32 );
	CString	strGroup;

	if( bHasClass )
	{
		strGroup.LoadString( IDS_DOMAIN_ALL );
		int nItem = AddString( strGroup );
		SetItemData( nItem, CStockContainer::typeAll );

		strGroup.LoadString( IDS_DOMAIN_INDEX );
		nItem = AddString( strGroup );
		SetItemData( nItem, CStockContainer::typeIndex );
		
		strGroup.LoadString( IDS_DOMAIN_CLASSSHAA );
		nItem = AddString( strGroup );
		SetItemData( nItem, CStockContainer::typeClassShaa );

		strGroup.LoadString( IDS_DOMAIN_CLASSSHAB );
		nItem = AddString( strGroup );
		SetItemData( nItem, CStockContainer::typeClassShab );

		strGroup.LoadString( IDS_DOMAIN_CLASSSZNA );
		nItem = AddString( strGroup );
		SetItemData( nItem, CStockContainer::typeClassSzna );

		strGroup.LoadString( IDS_DOMAIN_CLASSSZNB );
		nItem = AddString( strGroup );
		SetItemData( nItem, CStockContainer::typeClassSznb );

		strGroup.LoadString( IDS_DOMAIN_CLASSSHABOND );
		nItem = AddString( strGroup );
		SetItemData( nItem, CStockContainer::typeClassShabond );

		strGroup.LoadString( IDS_DOMAIN_CLASSSZNBOND );
		nItem = AddString( strGroup );
		SetItemData( nItem, CStockContainer::typeClassSznbond );
	}

	// Domains
	if( bHasDomain )
	{
		for( int i=0; i<domains.GetSize(); i++ )
		{
			CDomain	& domain = domains.ElementAt(i);
			int nItem = AddString( domain.m_strName );
			SetItemData( nItem, CStockContainer::typeDomain );
		}
	}

	// Groups
	for( int i=0; i<groups.GetSize(); i++ )
	{
		CDomain	& domain = groups.ElementAt(i);
		int nItem = AddString( domain.m_strName );
		SetItemData( nItem, CStockContainer::typeGroup );
	}

	return nItemCount;
}
示例#11
0
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CTextureBox::LoadGraphicList(void)
{
	if (g_pGameConfig->GetTextureFormat() == tfNone)
	{
		return;
	}

	SetRedraw(FALSE);
	ResetContent();
	InitStorage(g_Textures.GetActiveTextureCount() + 32, sizeof(PVOID));

	//
	// Add the MRU textures to the list.
	//
	int nStrCount = 0;
	POSITION pos = g_Textures.MRUGetHeadPosition();
	while (pos != NULL)
	{
		IEditorTexture *pTex = g_Textures.MRUGetNext(pos, g_pGameConfig->GetTextureFormat());
		if (pTex != NULL)
		{
			char szStr[MAX_PATH];
			pTex->GetShortName(szStr);
			int err = AddString(szStr);
			SetItemDataPtr(nStrCount, (void *)pTex);
			nStrCount++;
		}	
	}

	//
	// Add the MRU seperator to the list, unless the MRU was empty.
	//
	if (nStrCount > 0)
	{
		AddString("");
		SetItemDataPtr(nStrCount, NULL);
		nStrCount++;
	}

	//
	// Add the rest of the textures to the list.
	//
	int nIndex = 0;
	IEditorTexture *pTex = g_Textures.EnumActiveTextures(&nIndex, g_pGameConfig->GetTextureFormat());
	while (pTex != NULL)
	{
		char szStr[MAX_PATH];
		pTex->GetShortName(szStr);
		int err = AddString(szStr);
		assert( (err != CB_ERR) && (err != CB_ERRSPACE) );
		SetItemDataPtr(nStrCount, (void *)pTex);
		nStrCount++;

		pTex = g_Textures.EnumActiveTextures(&nIndex, g_pGameConfig->GetTextureFormat());
	}

	//
	// Hack: Select one that doesn't start with '+', '!', or '*', and doesn't have "door" in it.
	//
	SetCurSel(0);

	int nSel = GetCount();
	for (int i = 0; i < nSel; i++)
	{
		IEditorTexture *pTexSearch = (IEditorTexture *)GetItemDataPtr(i);
		if (pTexSearch != NULL)
		{
			char szName[MAX_PATH];
			pTexSearch->GetShortName(szName);

			if ((szName[0] != 0) && (szName[0] != '*') && (szName[0] != '+') && (szName[0] != '!') && (strstr(szName, "door") == NULL))
			{
				// this one is ok
				SetCurSel(i);
				break;
			}
		}
	}

	SetRedraw(TRUE);
	Invalidate();
}