当前位置: 首页>>代码示例>>C++>>正文


C++ CEvent类代码示例

本文整理汇总了C++中CEvent的典型用法代码示例。如果您正苦于以下问题:C++ CEvent类的具体用法?C++ CEvent怎么用?C++ CEvent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了CEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: assert

void CQEventWidget1::addEvent(UndoEventData *pSData)
{
  assert(CCopasiRootContainer::getDatamodelList()->size() > 0);
  CCopasiDataModel* pDataModel = (*CCopasiRootContainer::getDatamodelList())[0];
  assert(pDataModel != NULL);

  CModel * pModel = pDataModel->getModel();
  assert(pModel != NULL);

  //reinsert the Event
  CEvent *pEvent =  pModel->createEvent(pSData->getName());

  //set the expressions
  pEvent->setTriggerExpression(pSData->getTriggerExpression());
  pEvent->setDelayExpression(pSData->getDelayExpression());
  pEvent->setPriorityExpression(pSData->getPriorityExpression());

  QList <UndoEventAssignmentData *> *assignmentData = pSData->getEventAssignmentData();
  QList <UndoEventAssignmentData *>::const_iterator i;

  for (i = assignmentData->begin(); i != assignmentData->end(); ++i)
    {
      UndoEventAssignmentData * assignData = *i;

      CCopasiObject * pObject = NULL;
      bool speciesExist = false;
      size_t ci;

      for (ci = 0; ci < pModel->getCompartments().size(); ci++)
        {
          CCompartment * pCompartment = pModel->getCompartments()[ci];

          if (pCompartment->getMetabolites().getIndex(assignData->getName()) != C_INVALID_INDEX)
            speciesExist = true;
        }

      if (speciesExist)
        {
          size_t index = pModel->findMetabByName(assignData->getName());
          pObject =  pModel->getMetabolites()[index];
        }
      else if (pModel->getModelValues().getIndex(assignData->getName()) != C_INVALID_INDEX)
        {
          pObject = pModel->getModelValues()[assignData->getName()];
        }
      else if (pModel->getReactions().getIndex(assignData->getName()) != C_INVALID_INDEX)
        {
          pObject = pModel->getReactions()[assignData->getName()];
        }

      const CModelEntity * pEntity = dynamic_cast< const CModelEntity * >(pObject);
      CEventAssignment *eventAssign = new CEventAssignment(pObject->getKey(), pEvent->getObjectParent());
      eventAssign->setExpression(assignData->getExpression());
      eventAssign->getExpressionPtr()->compile();
      pEvent->getAssignments().add(eventAssign);
    }

  std::string key = pEvent->getKey();
  protectedNotify(ListViews::EVENT, ListViews::ADD, key);

  mpListView->switchToOtherWidget(C_INVALID_INDEX, key);
}
开发者ID:PriKalra,项目名称:COPASI,代码行数:62,代码来源:CQEventWidget1.cpp

示例2: sdelt

int 
Cam_int_edit::choose(
   CEvent &e,
   State *&s
   )
{
   DEVice_2d *ptr =(DEVice_2d *)e._d;
   PIXEL      te   (ptr->cur());
   XYvec      delta(ptr->delta());
   double     tdelt(the_time() - _dtime);
   
   _dist += sqrt(delta * delta);

   VEXEL sdelt(te - _start_pix);

   int xa=0,ya=1;
   if (Config::get_var_bool("FLIP_CAM_MANIP",false,true))
      swap(xa,ya);
     
   if (fabs(sdelt[ya])/sdelt.length() > 0.9 && tdelt > 0.05) {
      s = &_cam_zoom;
      ptr->set_old(_start_pix);
   } else if (tdelt < 0.1 && _dist < 0.03)
      return 0;
   else {
      if (fabs(sdelt[xa])/sdelt.length() > 0.6 )
         s = &_cam_pan;
      else s = &_cam_zoom;
      ptr->set_old(_start_pix);
   }
   /* if we got this far, we actually have a valid choice, so save the camera */   VIEWptr         view(e.view());
   view->save_cam();

   return 0;
}
开发者ID:Benignoperez,项目名称:jot-lib,代码行数:35,代码来源:cam_edit.C

示例3: GetTickCount

UINT CProcessPaste::MarkAsPastedThread(LPVOID pParam)
{
	DWORD startTick = GetTickCount();

	static CEvent UpdateTimeEvent(TRUE, TRUE, _T("Ditto_Update_Clip_Time"), NULL);
	UpdateTimeEvent.ResetEvent();

	Log(_T("Start of MarkAsPastedThread"));

	//If running from a U3 device then wait a little before updating the db
	//updating the db can take a second or two and it delays the act of pasting
	if(g_Opt.m_bU3)
	{
		Sleep(350);
	}

	BOOL bRet = FALSE;
	int clipId = 0;

	try
	{
		MarkAsPastedData* pData = (MarkAsPastedData*)pParam;
		if(pData)
		{
			clipId = pData->clipId;
			if(g_Opt.m_bUpdateTimeOnPaste)
			{
				try
				{
					if(pData->pastedFromGroup)
					{
						CppSQLite3Query q = theApp.m_db.execQuery(_T("SELECT clipGroupOrder FROM Main ORDER BY clipGroupOrder DESC LIMIT 1"));

						if(q.eof() == false)
						{
							double latestDate = q.getFloatField(_T("clipGroupOrder"));
							latestDate += 1;

							Log(StrF(_T("Setting clipId: %d, GroupOrder: %f"), pData->clipId, latestDate));

							theApp.m_db.execDMLEx(_T("UPDATE Main SET clipGroupOrder = %f where lID = %d;"), latestDate, pData->clipId);

							theApp.RefreshClipOrder(pData->clipId);
						}
					}
					else
					{
						CppSQLite3Query q = theApp.m_db.execQuery(_T("SELECT clipOrder FROM Main ORDER BY clipOrder DESC LIMIT 1"));

						if(q.eof() == false)
						{
							double latestDate = q.getFloatField(_T("clipOrder"));
							latestDate += 1;

							Log(StrF(_T("Setting clipId: %d, order: %f"), pData->clipId, latestDate));

							theApp.m_db.execDMLEx(_T("UPDATE Main SET clipOrder = %f where lID = %d;"), latestDate, pData->clipId);

							theApp.RefreshClipOrder(pData->clipId);
						}
					}
				}
				CATCH_SQLITE_EXCEPTION
			}

			try
			{
				theApp.m_db.execDMLEx(_T("UPDATE Main SET lastPasteDate = %d where lID = %d;"), (int)CTime::GetCurrentTime().GetTime(), pData->clipId);
			}
			CATCH_SQLITE_EXCEPTION

			delete pData;
			bRet = TRUE;
		}
	}
	CATCH_SQLITE_EXCEPTION

	Log(_T("End of MarkAsPastedThread"));

	DWORD endTick = GetTickCount();
	if((endTick-startTick) > 350)
		Log(StrF(_T("Paste Timing MarkAsPastedThread: %d, ClipId: %d"), endTick-startTick, clipId));

	UpdateTimeEvent.SetEvent();
	return bRet;
}
开发者ID:wilsonr990,项目名称:Ditto-clipboard-manager,代码行数:86,代码来源:ProcessPaste.cpp

示例4: data

int
Cam_int_edit::down2(
   CEvent &e, 
   State *&s
   )
{
   DEVice_buttons *btns = (DEVice_buttons *)e._d;
   DEVice_2d      *ptr  = btns->ptr2d();

   _view = e.view();

   CAMdataptr  data(_view->cam()->data());
   RAYhit      r   (_view->intersect(ptr->cur()));
   if (r.success()) {
      //////////////////
      //Scale Button
      //////////////////
      if(r.geom()->name() == "scale")
         {
            BaseJOTapp::deactivate_button();
            if(s == &_scale)
               s = (State *)-1;
            else
               {
                  BaseJOTapp::activate_button("scale");
                  s = &_scale;
               }
         }
      //////////////////
      //ScaleX Button
      //////////////////
      if(r.geom()->name() == "scalex")
         {
            BaseJOTapp::deactivate_button();
            if(s == &_scalex)
               s = (State *)-1;
            else
               {
                  BaseJOTapp::activate_button("scalex");
                  s = &_scalex;
               }
         }
      //////////////////
      //ScaleY Button
      //////////////////
      if(r.geom()->name() == "scaley")
         {
            BaseJOTapp::deactivate_button();
            if(s == &_scaley)
               s = (State *)-1;
            else
               {
                  BaseJOTapp::activate_button("scaley");
                  s = &_scaley;
               }
         }
      //////////////////
      //ScaleZ Button
      //////////////////
      if(r.geom()->name() == "scalez")
         {
            BaseJOTapp::deactivate_button();
            if(s == &_scalez)
               s = (State *)-1;
            else
               {
                  BaseJOTapp::activate_button("scalez");
                  s = &_scalez;
               }
         }
      //////////////////
      //Rotate Button
      //////////////////
      if(r.geom()->name() == "rotateX")
         {
            BaseJOTapp::deactivate_button();
            if(s == &_rot_x)
               s = (State *)-1;
            else
               {
                  BaseJOTapp::activate_button("rotateX");
                  s = &_rot_x;
               }
         }
      //////////////////
      //RotateY Button
      //////////////////
      if(r.geom()->name() == "rotateY")
         {
            BaseJOTapp::deactivate_button();
            if(s == &_rot_y)
               s = (State *)-1;
            else
               {
                  BaseJOTapp::activate_button("rotateY");
                  s = &_rot_y;
               }
         }
      //////////////////
      //Rotate Button
//.........这里部分代码省略.........
开发者ID:Benignoperez,项目名称:jot-lib,代码行数:101,代码来源:cam_edit.C

示例5:

void
CClient::handleFileChunkSending(const CEvent& event, void*)
{
	sendFileChunk(event.getData());
}
开发者ID:CarloWood,项目名称:synergy,代码行数:5,代码来源:Client.cpp

示例6: debugArg

void
CDaemonApp::handleIpcMessage(const CEvent& e, void*)
{
	CIpcMessage* m = static_cast<CIpcMessage*>(e.getDataObject());
	switch (m->type()) {
		case kIpcCommand: {
			CIpcCommandMessage* cm = static_cast<CIpcCommandMessage*>(m);
			CString command = cm->command();

			// if empty quotes, clear.
			if (command == "\"\"") {
				command.clear();
			}

			if (!command.empty()) {
				LOG((CLOG_DEBUG "new command, elevate=%d command=%s", cm->elevate(), command.c_str()));

				CString debugArg("--debug");
				UInt32 debugArgPos = static_cast<UInt32>(command.find(debugArg));
				if (debugArgPos != CString::npos) {
					UInt32 from = debugArgPos + static_cast<UInt32>(debugArg.size()) + 1;
					UInt32 nextSpace = static_cast<UInt32>(command.find(" ", from));
					CString logLevel(command.substr(from, nextSpace - from));
				
					try {
						// change log level based on that in the command string
						// and change to that log level now.
						ARCH->setting("LogLevel", logLevel);
						CLOG->setFilter(logLevel.c_str());
					}
					catch (XArch& e) {
						LOG((CLOG_ERR "failed to save LogLevel setting, %s", e.what().c_str()));
					}
				}
			}
			else {
				LOG((CLOG_DEBUG "empty command, elevate=%d", cm->elevate()));
			}

			try {
				// store command in system settings. this is used when the daemon
				// next starts.
				ARCH->setting("Command", command);

				// TODO: it would be nice to store bools/ints...
				ARCH->setting("Elevate", CString(cm->elevate() ? "1" : "0"));
			}
			catch (XArch& e) {
				LOG((CLOG_ERR "failed to save settings, %s", e.what().c_str()));
			}

#if SYSAPI_WIN32
			// tell the relauncher about the new command. this causes the
			// relauncher to stop the existing command and start the new
			// command.
			m_watchdog->setCommand(command, cm->elevate());
#endif
			break;
		}

		case kIpcHello:
			CIpcHelloMessage* hm = static_cast<CIpcHelloMessage*>(m);
			CString type;
			switch (hm->clientType()) {
				case kIpcClientGui: type = "gui"; break;
				case kIpcClientNode: type = "node"; break;
				default: type = "unknown"; break;
			}

			LOG((CLOG_DEBUG "ipc hello, type=%s", type.c_str()));

#if SYSAPI_WIN32
			CString watchdogStatus = m_watchdog->isProcessActive() ? "ok" : "error";
			LOG((CLOG_INFO "watchdog status: %s", watchdogStatus.c_str()));
#endif

			m_ipcLogOutputter->notifyBuffer();
			break;
	}
}
开发者ID:findepi,项目名称:synergy,代码行数:80,代码来源:CDaemonApp.cpp

示例7: clear

bool CQRDFTreeView::enterProtected()
{
  clear();

  CCopasiObject *pObject = dynamic_cast< CCopasiObject * >(CCopasiRootContainer::getKeyFactory()->get(mKey));

  if (pObject != NULL)
    {
      CModelEntity * pEntity = NULL;
      CEvent * pEvent = NULL;
      CReaction * pReaction = NULL;
      CFunction * pFunction = NULL;
      const std::string * pMiriamAnnotation = NULL;

      if ((pEntity = dynamic_cast< CModelEntity * >(pObject)) != NULL)
        pMiriamAnnotation = &pEntity->getMiriamAnnotation();
      else if ((pEvent = dynamic_cast< CEvent * >(pObject)) != NULL)
        pMiriamAnnotation = &pEvent->getMiriamAnnotation();
      else if ((pReaction = dynamic_cast< CReaction * >(pObject)) != NULL)
        pMiriamAnnotation = &pReaction->getMiriamAnnotation();
      else if ((pFunction = dynamic_cast< CFunction * >(pObject)) != NULL)
        pMiriamAnnotation = &pFunction->getMiriamAnnotation();

      if (pMiriamAnnotation && *pMiriamAnnotation != "")
        mpGraph = CRDFParser::graphFromXml(*pMiriamAnnotation);
    }

  CCopasiMessage::clearDeque();

  if (CCopasiMessage::size() != 0)
    {
      QString Message = FROM_UTF8(CCopasiMessage::getAllMessageText());
      CQMessageBox::warning(this, QString("RDF Warning"), Message,
                            QMessageBox::Ok, QMessageBox::Ok);
    }

  if (mpGraph == NULL)
    mpGraph = new CRDFGraph;

  // We make sure that we always have an about node.
  mpGraph->createAboutNode(mKey);

  // We iterate of all triplets
  std::set< CRDFTriplet >::const_iterator it = mpGraph->getTriplets().begin();
  std::set< CRDFTriplet >::const_iterator end = mpGraph->getTriplets().end();

  for (; it != end; ++it)
    {
      CQRDFTreeViewItem * pSubjectItem = find(it->pSubject);

      if (pSubjectItem == NULL)
        {
          pSubjectItem = new CQRDFTreeViewItem(mpTreeWidget, NULL);
          insert(it->pSubject, pSubjectItem);
          // Display the subject information

          const CRDFSubject & Subject = it->pSubject->getSubject();

          switch (Subject.getType())
            {
              case CRDFSubject::RESOURCE:
                pSubjectItem->setText(COL_SUBJECT, FROM_UTF8(Subject.getResource()));
                break;

              case CRDFSubject::BLANK_NODE:
                pSubjectItem->setText(COL_SUBJECT, FROM_UTF8(Subject.getBlankNodeID()));
                break;
            }
        }

      CQRDFTreeViewItem * pObjectItem = NULL;

      if (it->Predicate.getURI() == "http://www.w3.org/1999/02/22-rdf-syntax-ns#subject")
        {
          pObjectItem = new CQRDFTreeViewItem(pSubjectItem, NULL);
          insert(it->pObject, pObjectItem);
        }
      else
        pObjectItem = find(it->pObject);

      if (pObjectItem == NULL)
        {
          pObjectItem = new CQRDFTreeViewItem(pSubjectItem, NULL);
          insert(it->pObject, pObjectItem);
        }
      else
        {
          QTreeWidgetItem * pParent = pObjectItem->parent();

          if (pParent == NULL)
            {
              mpTreeWidget->invisibleRootItem()->removeChild(pObjectItem);
              pSubjectItem->addChild(pObjectItem);
            }
          else
            {
              pParent->removeChild(pObjectItem);
              pSubjectItem->addChild(pObjectItem);
            }
        }
//.........这里部分代码省略.........
开发者ID:mgaldzic,项目名称:copasi_api,代码行数:101,代码来源:CQRDFTreeView.cpp

示例8: GetWriteDataBuffer

int CLocalSocket::write(const char * szDataBlock, int nSizeOfBlock)
{
	if (NULL == szDataBlock)
		return FUNCTION_WRONG_PARAMETER;

	if (IsAlreadyConnected())
	{
		HANDLE hDataReadEvent, hDataWrittenEvent;

		s_PacketBuffer * pDataBuffer			= GetWriteDataBuffer();
		CMutex dataAccessMutex					= GetWriteDataAccessMutex();
		CEvent dataReadEvent					= GetWriteDataReadEvent();
		CEvent dataWrittenEvent					= GetWriteDataWrittenEvent();

		int nAmountOfPackets	 = nSizeOfBlock / PACKET_SIZE;
		int nLastUsedPacketBytes = nSizeOfBlock % PACKET_SIZE;

		if (0 != nLastUsedPacketBytes && 0 != nAmountOfPackets)
		{
			nAmountOfPackets++;
		}

		if (0 == nAmountOfPackets)
			nAmountOfPackets++;

		if (!dataAccessMutex.lock())
			return LOCAL_SOCKET_ERROR;
		
		pDataBuffer->nPacketsToBeSent  = nAmountOfPackets;
		pDataBuffer->nBytesToBeSent	= PACKET_SIZE;

		dataAccessMutex.unlock();

		int nAmountOfBytesToBeWritten = PACKET_SIZE;
		int nPacketOffset = 0;

			for (int nCur = 0; nCur < nAmountOfPackets; nCur++)
			{
				dataAccessMutex.lock();

				pDataBuffer->nCurrentNumber = nCur;

				if (nCur == nAmountOfPackets - 1)
				{
					(nLastUsedPacketBytes == 0) ? (nLastUsedPacketBytes = PACKET_SIZE) : (pDataBuffer->nBytesToBeSent = nLastUsedPacketBytes);
					nAmountOfBytesToBeWritten = nLastUsedPacketBytes;
				}

				memcpy(&pDataBuffer->cStorage[0], &szDataBlock[nPacketOffset], nAmountOfBytesToBeWritten);
				nPacketOffset += PACKET_SIZE;
				dataWrittenEvent.fire_signal();
				
				dataAccessMutex.unlock();


				if (!dataReadEvent.get_signal())
					return LOCAL_SOCKET_ERROR;

				if (CheckForDisconnection())
					return LOCAL_SOCKET_ERROR;
			}			

			return (nSizeOfBlock);
	}

	return LOCAL_SOCKET_ERROR;
}
开发者ID:DigitalDigger,项目名称:LocalSocket,代码行数:67,代码来源:CLocalSocket.cpp

示例9: GetReadDataBuffer

int CLocalSocket::read(char * szDataBlock, int nSizeOfBlock)
{
	if (NULL == szDataBlock)
		return FUNCTION_WRONG_PARAMETER;

	if (IsAlreadyConnected())
	{
		HANDLE hDataReadEvent, hDataWrittenEvent;

		s_PacketBuffer * pDataBuffer			= GetReadDataBuffer();
		CMutex dataAccessMutex					= GetReadDataAccessMutex();
		CEvent dataReadEvent					= GetReadDataReadEvent();
		CEvent dataWrittenEvent					= GetReadDataWrittenEvent();

		dataWrittenEvent.SetTimeout(INFINITE);

		if (!dataWrittenEvent.get_signal())
			return LOCAL_SOCKET_ERROR;

		if (CheckForDisconnection())
			return LOCAL_SOCKET_ERROR;

		int nAmountOfIncomingPackets = 0;

		if (!dataAccessMutex.lock())
			return LOCAL_SOCKET_ERROR;

		nAmountOfIncomingPackets = pDataBuffer->nPacketsToBeSent;		

		int nPacketOffset = 0;

		if (nAmountOfIncomingPackets > 1)
		{
			int nLastUsedPacketBytes = 0;
			for(int nCur = 0; nCur < nAmountOfIncomingPackets; nCur++)
			{
				if (nCur > 0)
				{
					if (!dataWrittenEvent.get_signal())
						return LOCAL_SOCKET_ERROR;

					if (CheckForDisconnection())
						return LOCAL_SOCKET_ERROR;

					if (!dataAccessMutex.lock())
						return LOCAL_SOCKET_ERROR;
				}

				if (nCur == nAmountOfIncomingPackets - 1)
					nLastUsedPacketBytes = pDataBuffer->nBytesToBeSent;

				int nAmountOfIncomingBytes = pDataBuffer->nBytesToBeSent;
				if (nAmountOfIncomingBytes > nSizeOfBlock)
					// truncate the data
					memcpy(&szDataBlock[nPacketOffset], &pDataBuffer->cStorage[0], nSizeOfBlock);
				else
					memcpy(&szDataBlock[nPacketOffset], &pDataBuffer->cStorage[0], nAmountOfIncomingBytes);

				nPacketOffset += PACKET_SIZE;

				dataAccessMutex.unlock();

				dataReadEvent.fire_signal();
			}

			return (nLastUsedPacketBytes == 0 ? nAmountOfIncomingPackets * PACKET_SIZE : nAmountOfIncomingPackets * PACKET_SIZE - PACKET_SIZE + nLastUsedPacketBytes);

		}
		else
		{
			int nAmountOfIncomingBytes = pDataBuffer->nBytesToBeSent;
			if (nAmountOfIncomingBytes > nSizeOfBlock)
				// truncate the data
				memcpy(szDataBlock, &pDataBuffer->cStorage[0], nSizeOfBlock);
			else
				memcpy(szDataBlock, &pDataBuffer->cStorage[0], nAmountOfIncomingBytes);

			dataAccessMutex.unlock();

			dataReadEvent.fire_signal();

			return nSizeOfBlock;
		}
	}

	return LOCAL_SOCKET_ERROR;
}
开发者ID:DigitalDigger,项目名称:LocalSocket,代码行数:87,代码来源:CLocalSocket.cpp

示例10: TradeEntry_01

UINT TradeEntry_01(LPVOID pParam)//交易线程1改版
{
#define NUMLADDER 11
	double ladder_01[NUMLADDER] = {-100,-80,-60,-40,-20,0,20,40,60,80,100};//暂时设11档,一定要正负对称且呈阶梯状,否则逻辑混乱
	int needAmount_01[NUMLADDER] = {5,4,3,2,1,0,-1,-2,-3,-4,-5};//每档对应的持仓数量
	int holdA50_01 = 0;//A50持有数量
	int holdIf_01 = 0;//IF持有数量
	int needHoldA50_01 = 0;//A50应该持有数量
	int needHoldIf_01 = 0;//IF应该持有数量
	int nowLadder_01 = 0;//当前梯级
	bool isFirst = true;//第一次操作
	bool isFilledSectionLeft = false;//本区间左侧目标位的买卖操作是否完成
	bool isFilledSectionRight = false;//本区间右侧目标位的买卖操作是否完成
	int nowSection = 4444;//当前所在的区间,由左端点决定,取4444的初值表示还未找到区间
	if(clientDlg == NULL){
		return -1;
	}
	if(pUserApi == NULL){
		return -1;
	}	
	//从对话框初始化
	datumDiff = clientDlg->m_DeltaDatumDiff + clientDlg->m_datumDiff;
#ifdef _debug 
	holdA50_01 = 50;
#endif
	while(true){
		UpdateTrade.Lock(INFINITE);//事件触发
		//获取系统时间
		SYSTEMTIME sys;
		GetLocalTime(&sys);
		CString PREMIUM;	
		calDeviation();
		deviationHigh_save = deviationHigh;
		deviationLow_save = deviationLow;
		PREMIUM.Format(_T("%.4f"),premiumLow);	
		clientDlg->SetDlgItemTextA(IDC_EDIT18,PREMIUM);
		PREMIUM.Format(_T("%.4f"),premiumHigh);	
		clientDlg->SetDlgItemTextA(IDC_EDIT16,PREMIUM);
		//非交易日返回
		if(!isTradeDay(sys.wYear,sys.wMonth,sys.wDay))
		{
			continue;
		}
		//非常规交易时间
		if((sys.wHour == 9 && sys.wMinute < 10) || 
			(sys.wHour == 15 && sys.wMinute > 15) ||
			(sys.wHour == 11 && sys.wMinute > 30) ||
			(sys.wHour == 12)||
			(sys.wHour < 9) || (sys.wHour > 15)){
				continue;
		}
		if(clientDlg->tradeEnd){//终止
			//做清空处理,重新启动时会初始化
			return -1;
		}
		if(clientDlg->stop){//暂停
			continue;
		}
		if(_isnan(datumDiff) != 0 || _isnan(premium)!=0 ||_isnan(deviation)!=0){
			continue;//判断非零值错误
		}
		if(deviationHigh >= 100 || deviationLow <= -100){
			continue;//超过范围,返回
		}
		for(int i = 0;i <= NUMLADDER - 1;i++){//计算当前的区间位置
			if(deviationLow >= ladder_01[i] && deviationHigh <= ladder_01[i + 1]){
				if(isFirst){
					nowSection = i;
					isFirst = false;
					break;
				}
				else{
					if(nowSection != i){
						nowSection = i;
						break;
					}
				}
			}
		}
		if(nowSection == 4444){
			continue;//还未找到区间,返回重新寻找
		}
		bool isFilledL = false,isFilledR = false;
		int needA50L = 0,needA50R = 0;
		int needIfL = 0,needIfR = 0;
		needIfL = -needAmount_01[nowSection];
		needIfR = -needAmount_01[nowSection + 1];
		needA50L = needAmount_01[nowSection] * multiply;
		needA50R = needAmount_01[nowSection + 1] * multiply;
		//强平
		if(holdA50_01 > needA50L){
			//FTA50(holdA50_01 - needA50L,false);
			holdA50_01 = needA50L;
		}
		if(holdIf_01 < needIfL){
			//FTIF(needIfL - holdIf_01,true);
			holdIf_01 = needIfL;
		}
		if(holdA50_01 < needA50R){
			//FTA50(needA50R - holdA50_01,true);
//.........这里部分代码省略.........
开发者ID:dreamtrue,项目名称:hedge_old,代码行数:101,代码来源:trade.cpp

示例11: MCThreadCleanupFn

void MCThreadCleanupFn()
{
	g_MCThreadExitEvent.SetEvent();
}
开发者ID:Adidasman1,项目名称:source-sdk-2013,代码行数:4,代码来源:mpivis.cpp

示例12: MMLCConnect

//以下为Delphi传入数据包
extern "C" _declspec(dllexport) int __stdcall Send(int flag,void * Pin)

{

	try
	{


		if (flag==1||flag==2||flag==3)
		{

		
		if (g_LCStatusFlag<=1 )
		{	
			
			return MMLCConnect(flag,Pin);
			

		}
		else
		{
			return 30040;
		}

		}




		if (flag==1003)
		{
			if (strlen(((SingleFava*)Pin)->chatTxt)>1000)
			{
				return 30030;
			}

		}

		TRACE("调用Send flag:%d",flag);

		if (GetSockStatus()!=0)
		{
			return GetSockStatus();
		}

		g_objectCComAutoCriticalSection.Lock();
		CDataClass * pCDataClass=new CDataClass(flag,Pin);	
		global_socket->ListInPacket_Push(pCDataClass);
		/*int i=SendPackge(g_socketServer);*/

		g_objectCComAutoCriticalSection.Unlock();
		EventSend.SetEvent();
		//global_socket.AsyncSelect(FD_WRITE);
		return 0;



	}
	catch (CMemoryException* e)
	{
		return 30050;
		
	}
	catch (CFileException* e)
	{
		return 30051;
	}
	catch (CException* e)
	{
		return 30052;
	}
	catch(...)
	{
       return 30053;
	}

	// return 0;

	
}
开发者ID:sechacking,项目名称:r3pos,代码行数:81,代码来源:MMC.cpp

示例13: Receive

int Receive(SOCKET s)
{
	////////////////////////////////////
	//static int i=0;

	TRACE("获得一个OnReceive事件");
	//i++;
	/*BYTE * pRightEndTemp;*/

	BYTE buff[65536];
	memset(buff,0x00,65536);
	int nRead;
	nRead = recv(s,(char*)buff, 65536,0); 
	TRACE("已经接收数据 长度%d",nRead);
	switch (nRead)
	{
	case 0:
		//SetSockClose();
		//closesocket(g_socketServer);
		//UnInitSock();   

		TRACE("开始关闭连接");
		//shutdown(g_socketServer,SD_SEND);
		/*EventExit.SetEvent();*/
		THROW(1);

		return WSAGetLastError();
		//case -1:
		//	Close();
		//	break;
	case SOCKET_ERROR:
		if (GetLastError() != WSAEWOULDBLOCK) 
		{
			TRACE("收到WSAEWOULDBLOCK");
			//AfxMessageBox ("Error occurred");
			//SetSockClose();
			//UnInitSock();  
			//shutdown(g_socketServer,SD_SEND);
			/*EventExit.SetEvent();*/
			THROW(1);
			return WSAGetLastError();
		}
		else
		{
			return WSAEWOULDBLOCK;
		}

	default://接收到了数据
		TRACE("接收到了数据");

		if (global_socket->pDataEnd==&(global_socket->pRecvOriginal[0]))//缓冲区为空
		{

			memcpy(global_socket->pDataEnd,buff,nRead);
			global_socket->pDataEnd=global_socket->pDataEnd+nRead-1;
		}
		else
		{//缓冲区有数据
			memcpy(global_socket->pDataEnd+1,buff,nRead);
			global_socket->pDataEnd=global_socket->pDataEnd+1+nRead-1;//    +nRead-1;


		}

	    while(global_socket->pDataEnd-&(global_socket->pRecvOriginal[0]) > 21)
	    
		
	  {
			BYTE * pRightEndTemp;
		
		int i=global_socket->CheckWheaverHaveRightData(&pRightEndTemp);


		TRACE("调用CheckWheaverHaveRightData %d",i);
		if (i==1)//正确包

		{
			TRACE("正确数据包");

			DataReved * pDataReved=new DataReved(global_socket->pHead,pRightEndTemp);
			TRACE("组装接收对象 %d",pDataReved->routeType);
			if (pDataReved->routeType==0||pDataReved->routeType==1)//flex
			{

				/*LC_NSend("LCFlexClient","LCFlexRecvFromNetWork",4,pDataReved->byteDataRecvOrigianl,pDataReved->lengthofbyteDataRecvOrigianl);*/
				
				if (g_LCStatusFlag<=1 )
				{
					LC_NSend("_airToWeb","airToWebHandler",4,pDataReved->byteDataRecvOrigianl,pDataReved->lengthofbyteDataRecvOrigianl);
				}
				//to lC control
			}
			if (pDataReved->routeType==0||pDataReved->routeType==1)//flex
			{
				TRACE("to mm flag %d",pDataReved->flag);
				if (pDataReved->flag==1000)
				{
					TRACE("设置EventConnectFava");
					//::SetEvent(hEvent);
					if (strcmp("yes",((ConnectFava*)pDataReved->p_ToDelphiData)->status)==0)
//.........这里部分代码省略.........
开发者ID:sechacking,项目名称:r3pos,代码行数:101,代码来源:MMC.cpp

示例14: ServiceThread

DWORD WINAPI ServiceThread(LPVOID lpThreadParameter)  
//UINT ServiceThread( LPVOID lpThreadParameter )
//unsigned int WINAPI ServiceThread(void* lpThreadParameter)  
////////////////////////////////////////////////
{   

	::CoInitialize(NULL);
	

	ST_THREAD_PARAM* pThread = (ST_THREAD_PARAM*)lpThreadParameter;   
	SOCKET socketServer = pThread->socket;   
	WSAEVENT wsaEvent = pThread->wsaEvent;   
////////////////////////////
	HANDLE hmultihandle[4];
	hmultihandle[0]=wsaEvent;
	hmultihandle[1]=EventExit.m_hObject;
	hmultihandle[2]=EventSend.m_hObject;
	hmultihandle[3]=EventSendFromFlex.m_hObject;


	TRACE("新线程%d起动/n",GetCurrentThreadId());   

	try
	{

		while(true)   
		{   
			int nRet=::WSAWaitForMultipleEvents(4,hmultihandle,FALSE,10000,FALSE);  
			TRACE("WSAWaitForMultipleEvents %d",nRet);
			if(nRet==WAIT_FAILED) // 失败   
			{   
				 ///////////////////////////////
				TRACE("failed WSAWaitForMultipleEvents/n");   
				THROW(1); 
				break;   
			}   
			else if(nRet==WSA_WAIT_TIMEOUT) // 超时   
			{   
				TRACE(" WSA_WAIT_TIMEOUT ... /n");
				//////////////////////////////////
				/*		int i=0;
				THROW(i);*/
				///////////////////////////////////////////
				continue;   
			}   
			else if (nRet==WSA_WAIT_EVENT_0)

				// 成功 -- 网络事件发生   
			{   
				WSANETWORKEVENTS wsaNetEvent;   
				::WSAEnumNetworkEvents(socketServer,wsaEvent,&wsaNetEvent);   
				TRACE("WSAEnumNetworkEvents",nRet);
				if(wsaNetEvent.lNetworkEvents&FD_READ)   
				{      
					g_objectCComAutoCriticalSection.Lock();
					Receive(g_socketServer);
					g_objectCComAutoCriticalSection.Unlock();
					

				}   
				else if(wsaNetEvent.lNetworkEvents&FD_WRITE)   
				{   

					g_objectCComAutoCriticalSection.Lock();
					SendPackge(g_socketServer);
					g_objectCComAutoCriticalSection.Unlock();
					EventSend.ResetEvent();
					  
				}   
				if(wsaNetEvent.lNetworkEvents&FD_CLOSE)   
				{   
					TRACE("FD_CLOSE event occurs.../n");   
					int nErrorCode = WSAGetLastError();   
					TRACE("Error code is %d/n",nErrorCode);   
					if (nErrorCode == WSAECONNRESET)   
					{   
						TRACE("WSAECONNRESET error./n");   
					}   
					else if (nErrorCode == WSAENETDOWN)   
					{   
						TRACE("WSAENETDOWN error./n");   
					}   
					else if (nErrorCode == WSAENETRESET)   
					{   
						TRACE("WSAENETRESET error./n");   
					}   
					THROW(1);


					



					TRACE("线程%d退出/n",GetCurrentThreadId()); 
					TRACE("线程%d退出/n",GetCurrentThreadId()); 


					return 0; 
					TRACE("无法执行的代码");
				}   
//.........这里部分代码省略.........
开发者ID:sechacking,项目名称:r3pos,代码行数:101,代码来源:MMC.cpp

示例15: main

int main(int argc, char* argv[])
{
	SpewOutputFunc( MySpewFunc );

	// Figure out a random port to use.
	CCycleCount cnt;
	cnt.Sample();
	CUniformRandomStream randomStream;
	randomStream.SetSeed( cnt.GetMicroseconds() );
	int iPort = randomStream.RandomInt( 20000, 30000 );


	g_ClientPacketEvent.Init( false, false );

	
	// Setup the "server".
	CHandlerCreator_Server serverHandler;
	CIPAddr addr( 127, 0, 0, 1, iPort );

	ITCPConnectSocket *pListener = ThreadedTCP_CreateListener( 
		&serverHandler,
		(unsigned short)iPort );

	
	// Setup the "client".
	CHandlerCreator_Client clientCreator;
	ITCPConnectSocket *pConnector = ThreadedTCP_CreateConnector( 
		CIPAddr( 127, 0, 0, 1, iPort ),
		CIPAddr(),
		&clientCreator );


	// Wait for them to connect.
	while ( !g_pClientSocket )
	{
		if ( !pConnector->Update( &g_pClientSocket ) )
		{
			Error( "Error in client connector!\n" );
		}
	}
	pConnector->Release();


	while ( !g_pServerSocket )
	{
		if ( !pListener->Update( &g_pServerSocket ) )
			Error( "Error in server connector!\n" );
	}
	pListener->Release();


	// Send some data.
	__int64 totalBytes = 0;
	CCycleCount startTime;
	int iPacket = 1;

	startTime.Sample();
	CUtlVector<char> buf;

	while ( (GetAsyncKeyState( VK_SHIFT ) & 0x8000) == 0 )
	{
		int size = randomStream.RandomInt( 1024*0, 1024*320 );
		if ( buf.Count() < size )
			buf.SetSize( size );

		if ( g_pClientSocket->Send( buf.Base(), size ) )
		{
			// Server receives the data and echoes it back. Verify that the data is good.
			WaitForSingleObject( g_ClientPacketEvent.GetEventHandle(), INFINITE );
			Assert( memcmp( g_ClientPacket.Base(), buf.Base(), size ) == 0 );

			totalBytes += size;
			CCycleCount curTime, elapsed;
			curTime.Sample();
			CCycleCount::Sub( curTime, startTime, elapsed );
			double flSeconds = elapsed.GetSeconds();
			Msg( "Packet %d, %d bytes, %dk/sec\n", iPacket++, size, (int)(((totalBytes+511)/1024) / flSeconds) );
		}
	}
	
	g_pClientSocket->Release();
	g_pServerSocket->Release();
	return 0;
}
开发者ID:DeadZoneLuna,项目名称:SourceEngine2007,代码行数:84,代码来源:ThreadedTCPSocketTest.cpp


注:本文中的CEvent类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。