Example #1
0
void SAnimateImgWnd::OnDestroy()
{
    Stop();
}
Example #2
0
/*
=====================
idCameraAnim::GetViewParms
=====================
*/
void idCameraAnim::GetViewParms( renderView_t* view )
{
	int				realFrame;
	int				frame;
	int				frameTime;
	float			lerp;
	float			invlerp;
	cameraFrame_t*	camFrame;
	int				i;
	int				cut;
	idQuat			q1, q2, q3;
	
	assert( view );
	if( !view )
	{
		return;
	}
	
	if( camera.Num() == 0 )
	{
		// we most likely are in the middle of a restore
		// FIXME: it would be better to fix it so this doesn't get called during a restore
		return;
	}
	
	SetTimeState ts( timeGroup );
	
	frameTime	= ( gameLocal.time - starttime ) * frameRate;
	frame		= frameTime / 1000;
	lerp		= ( frameTime % 1000 ) * 0.001f;
	
	// skip any frames where camera cuts occur
	realFrame = frame;
	cut = 0;
	for( i = 0; i < cameraCuts.Num(); i++ )
	{
		if( frame < cameraCuts[ i ] )
		{
			break;
		}
		frame++;
		cut++;
	}
	
	if( g_debugCinematic.GetBool() )
	{
		int prevFrameTime	= ( gameLocal.previousTime - starttime ) * frameRate;
		int prevFrame		= prevFrameTime / 1000;
		int prevCut;
		
		prevCut = 0;
		for( i = 0; i < cameraCuts.Num(); i++ )
		{
			if( prevFrame < cameraCuts[ i ] )
			{
				break;
			}
			prevFrame++;
			prevCut++;
		}
		
		if( prevCut != cut )
		{
			gameLocal.Printf( "%d: '%s' cut %d\n", gameLocal.framenum, GetName(), cut );
		}
	}
	
	// clamp to the first frame.  also check if this is a one frame anim.  one frame anims would end immediately,
	// but since they're mainly used for static cams anyway, just stay on it infinitely.
	if( ( frame < 0 ) || ( camera.Num() < 2 ) )
	{
		view->viewaxis = camera[ 0 ].q.ToQuat().ToMat3();
		view->vieworg = camera[ 0 ].t + offset;
		view->fov_x = camera[ 0 ].fov;
	}
	else if( frame > camera.Num() - 2 )
	{
		if( cycle > 0 )
		{
			cycle--;
		}
		
		if( cycle != 0 )
		{
			// advance start time so that we loop
			starttime += ( ( camera.Num() - cameraCuts.Num() ) * 1000 ) / frameRate;
			GetViewParms( view );
			return;
		}
		
		Stop();
		if( gameLocal.GetCamera() != NULL )
		{
			// we activated another camera when we stopped, so get it's viewparms instead
			gameLocal.GetCamera()->GetViewParms( view );
			return;
		}
		else
		{
			// just use our last frame
			camFrame = &camera[ camera.Num() - 1 ];
			view->viewaxis = camFrame->q.ToQuat().ToMat3();
			view->vieworg = camFrame->t + offset;
			view->fov_x = camFrame->fov;
		}
	}
	else if( lerp == 0.0f )
	{
		camFrame = &camera[ frame ];
		view->viewaxis = camFrame[ 0 ].q.ToMat3();
		view->vieworg = camFrame[ 0 ].t + offset;
		view->fov_x = camFrame[ 0 ].fov;
	}
	else
	{
		camFrame = &camera[ frame ];
		invlerp = 1.0f - lerp;
		q1 = camFrame[ 0 ].q.ToQuat();
		q2 = camFrame[ 1 ].q.ToQuat();
		q3.Slerp( q1, q2, lerp );
		view->viewaxis = q3.ToMat3();
		view->vieworg = camFrame[ 0 ].t * invlerp + camFrame[ 1 ].t * lerp + offset;
		view->fov_x = camFrame[ 0 ].fov * invlerp + camFrame[ 1 ].fov * lerp;
	}
	
	gameLocal.CalcFov( view->fov_x, view->fov_x, view->fov_y );
	
	// setup the pvs for this frame
	UpdatePVSAreas( view->vieworg );
	
#if 0
	static int lastFrame = 0;
	static idVec3 lastFrameVec( 0.0f, 0.0f, 0.0f );
	if( gameLocal.time != lastFrame )
	{
		gameRenderWorld->DebugBounds( colorCyan, idBounds( view->vieworg ).Expand( 16.0f ), vec3_origin, 1 );
		gameRenderWorld->DebugLine( colorRed, view->vieworg, view->vieworg + idVec3( 0.0f, 0.0f, 2.0f ), 10000, false );
		gameRenderWorld->DebugLine( colorCyan, lastFrameVec, view->vieworg, 10000, false );
		gameRenderWorld->DebugLine( colorYellow, view->vieworg + view->viewaxis[ 0 ] * 64.0f, view->vieworg + view->viewaxis[ 0 ] * 66.0f, 10000, false );
		gameRenderWorld->DebugLine( colorOrange, view->vieworg + view->viewaxis[ 0 ] * 64.0f, view->vieworg + view->viewaxis[ 0 ] * 64.0f + idVec3( 0.0f, 0.0f, 2.0f ), 10000, false );
		lastFrameVec = view->vieworg;
		lastFrame = gameLocal.time;
	}
#endif
	
	if( g_showcamerainfo.GetBool() )
	{
		gameLocal.Printf( "^5Frame: ^7%d/%d\n\n\n", realFrame + 1, camera.Num() - cameraCuts.Num() );
	}
}
Example #3
0
CFolderCrawler::~CFolderCrawler(void)
{
	Stop();
}
Example #4
0
 GateWayFinder::~GateWayFinder()
 {
     Stop();
 }
void Z_DC_Spread_Policy::OnNewFutureMD(MarketDataField* pMD)
{
	if(IsCallAuction(pMD)){
		return;
	}
	UpdateMD(pMD);
	if(m_bStopOnClose && m_MyTradeA.m_nLongPos<1 && m_MyTradeA.m_nShortPos<1 && m_MyTradeB.m_nLongPos<1 && m_MyTradeB.m_nShortPos<1){
		m_nCurrentStage = 0;
		m_nPositiveAddedFlag = 0;
		m_nPositiveAddEnableFlag = 0;
		m_nNegativeAddedFlag = 0;
		m_nNegativeAddEnableFlag = 0;
		m_MyTradeA.m_fBasePrice = 0;
		m_MyTradeB.m_fBasePrice = 0;
		m_nTotalAddTimes = 0;
		m_nTotalSubTimes = 0;
		SetAttr("totalAddtimes",m_nTotalAddTimes);
		SetAttr("totalSubTimes",m_nTotalSubTimes);
		SetAttr("current_stage",m_nCurrentStage);
		SetAttr("Padded_flag",m_nPositiveAddedFlag);
		SetAttr("Nadded_flag",m_nNegativeAddedFlag);
		SetAttr("Paddenable_flag",m_nPositiveAddEnableFlag);
		SetAttr("Naddenable_flag",m_nNegativeAddEnableFlag);
		SetAttr("base_price_a",0);
		SetAttr("base_price_b",0);
		Stop();
		ShowInfo(&m_MyTradeA,"Close stop.",0);
		return;
	}
	//if(m_MyTradeA.m_pLastMD != NULL && m_MyTradeB.m_pLastMD !=NULL){
		//m_fCurrentPriceDisparity = abs( m_MyTradeA.m_pLastMD->LastPrice - m_MyTradeB.m_pLastMD->LastPrice);
	//}
	if(!m_bStopOnClose && m_MyTradeA.m_pLastMD != NULL && m_MyTradeB.m_pLastMD !=NULL){
	/*	if(strcmp(pMD->InstrumentID, m_MyTradeA.m_InstrumentID)==0){	//For Test
			cout<<m_MyTradeA.m_pLastMD->UpdateTime<<" "<<m_MyTradeB.m_pLastMD->UpdateTime<<endl;
		}*/
		//cout<<(strcmp(pMD->InstrumentID, m_MyTradeA.m_InstrumentID) == 0)<<" "<<GetTimeInterval(m_MyTradeA.m_pLastMD->UpdateTime,m_MyTradeB.m_pLastMD->UpdateTime)<<" "<<m_nCurrentStage<<" "<<m_MyTradeA.m_nLongPos<<" "<<m_MyTradeB.m_nShortPos<<endl;
		if(strcmp(pMD->InstrumentID, m_MyTradeA.m_InstrumentID)==0 && GetTimeInterval(m_MyTradeA.m_pLastMD->UpdateTime,m_MyTradeB.m_pLastMD->UpdateTime)){
			if(m_nCurrentStage == 0 && m_MyTradeA.m_nLongPos==0 && m_MyTradeB.m_nShortPos == 0 && !IsTradeLimit(true)){//m_nCurrentStage == 0 &&
				ShowInfo(&m_MyTradeA,"Set Up Base Pos!",0);
				OpenLong(&m_MyTradeA);
				OpenShort(&m_MyTradeB);
				m_MyTradeA.m_fBasePrice = m_MyTradeA.m_pLastMD->LastPrice;
				m_MyTradeB.m_fBasePrice = m_MyTradeB.m_pLastMD->LastPrice;
				m_nCurrentStage = 1;

				SetBaseFlag(&m_MyTradeA);
				SetAttr("base_price_a",m_MyTradeA.m_fBasePrice);
				SetAttr("base_price_b",m_MyTradeB.m_fBasePrice);
				SetAttr("current_stage",m_nCurrentStage);
			}

			//判断当前盈利状况
			if(!this->GetBarCloseFlag(m_MyTradeA.m_pSeries,pMD,5)){//收盘前五秒没有买卖信号判断
				ManageRateSingal();
			}
			//if(m_MyTradeA.m_pLastMD!=NULL && m_MyTradeB.m_pLastMD!=NULL){
			CalProfit();
			//}
		}
	}

}
Example #6
0
TaskQueue::~TaskQueue()
{
	Stop();
}
COggStream::~COggStream()
{
	Stop();
}
Example #8
0
Timer::~Timer()
{
    Stop();
}
Example #9
0
CHttpServer::~CHttpServer()
{
	Stop();
	delete m_TaskManager;
}
int _tmain(int argc, _TCHAR* argv[])
{
	EventLog::SetSourceName(_T("EasyDynamicDNS"));

	if (argc >= 2) {
		TCHAR cmd[20];
		_tcsncpy(cmd, argv[1], 19);
		cmd[19] = 0;
		_tcslwr(cmd);
		if (_tcscmp(cmd, "/install") == 0) {
			if (Install() != TRUE)
				_tprintf(_T("Installation error.\n"));
			return 0;
		}
		else if (_tcscmp(cmd, "/uninstall") == 0) {
			if (Uninstall() != TRUE)
				_tprintf(_T("Remove error.\n"));
			return 0;
		}
		else if (_tcscmp(cmd, "/start") == 0) {
			if (Start() != TRUE)
				_tprintf(_T("Start error.\n"));
			return 0;
		}
		else if (_tcscmp(cmd, "/stop") == 0) {
			if (Stop() != TRUE)
				_tprintf(_T("Stop error.\n"));
			return 0;
		}
		else if (_tcscmp(cmd, "/config") == 0) {
			if (Config(argc - 2, &argv[2]) != TRUE)
				_tprintf(_T("Config error\n"));
			return 0;
		}
		else if (_tcscmp(cmd, "/run") == 0) {
			if (Run() != TRUE)
				_tprintf(_T("Run error\n"));
			return 0;
		}
		else if (_tcscmp(cmd, "/help") == 0) {
			Usage();
			return 0;
		}
		else {
			_tprintf ("Syntax error\n");
			Usage();
			return 1;
		}
	}

	// run service

	SERVICE_TABLE_ENTRY DispatchTable[] = 
	{
		{ _T("EasyDynamicDNS"), (LPSERVICE_MAIN_FUNCTION) EasyDynamicDNSStart },
		{ NULL, NULL }
	};

	if (!StartServiceCtrlDispatcher(DispatchTable)) {
		EventLog log;
		log.LogLastError("Service run error");
	}

	return 0;
}
Example #11
0
bool TcpServer::Start()
{
    if (m_bStart){
        return true;
    }

    Stop();

    //create server object
    m_c2s = (c2s_t) malloc(sizeof(struct c2s_st));
    memset(m_c2s, 0, sizeof(struct c2s_st));
    m_c2s->server_fd = 0;
    m_c2s->local_ip = strdup(g_SysConf.m_BaseConf.m_strBindAdd.c_str());
    m_c2s->local_port = g_SysConf.m_BaseConf.m_usPort;
    m_c2s->io_max_fds = g_SysConf.m_BaseConf.m_uiMaxConnect;
    m_c2s->pvoid = (void*)this;
    /*
    m_c2s->mio = mio_new(m_c2s->io_max_fds);
    if (!m_c2s->mio) {
    */
    m_c2s->mio2 = mio2_new(m_c2s->io_max_fds);
    if (!m_c2s->mio2) {
        gvLog(LOG_ERR_SYS, "(TcpServer::Start) Version Server Create Failed while creating mio!");
        return false;
    }

    //create DB pool
    m_pDBSpool = new DBSpool();
    if (m_pDBSpool == NULL) {
        gvLog(LOG_ERR_SYS, "(TcpServer::Start) Version Server Create Failed while creating DB spool!");
        return false;
    }
    if (!m_pDBSpool->SetConnection(g_SysConf.m_DBConf.m_usThreadPool)) {
        gvLog(LOG_ERR_SYS, "(TcpServer::Start) Version Server Create Failed while setting DB spool connection!");
        return false;
    }
    m_pDBSpool->SetDBparm(g_SysConf.m_DBConf.m_strServer, g_SysConf.m_DBConf.m_usPort, g_SysConf.m_DBConf.m_strDbName,
                            g_SysConf.m_DBConf.m_strUserName, g_SysConf.m_DBConf.m_strPass);
    if (!m_pDBSpool->Connect()) {
        gvLog(LOG_ERR_SYS, "(TcpServer::Start) Core Server Create Failed while connecting to database!");
        return false;
    }
    gvLog(LOG_OFF, "(TcpServer::Start) Init DB(ip=%s, port=%d) done.", g_SysConf.m_DBConf.m_strServer.c_str(), g_SysConf.m_DBConf.m_usPort);

    //init DBMapping
    {
//        CAutoLock lock(&m_tMutex);
//        if (m_VerDBMapping.InitByDBSpool(m_pDBSpool) == -1){
//            gvLog(LOG_ERR_SYS, "(TcpServer::Start) Core Server Create Failed while create DB mapping!");
//            return false;
//        }
    }
    gvLog(LOG_OFF, "(TcpServer::Start) Init mapping done.");

    //create server
    /*
    m_c2s->server_fd = mio_listen(m_c2s->mio, m_c2s->local_port, m_c2s->local_ip, _c2s_client_mio_callback, (void*)m_c2s);
    */
    m_c2s->server_fd = mio2_listen(m_c2s->mio2, m_c2s->local_port, m_c2s->local_ip, _c2s_client_mio2_callback, (void*)m_c2s);
    if (m_c2s->server_fd < 0) {
        gvLog(LOG_ERR_SYS, "(TcpServer::Start) Version Server Create Failed while creating socket server!");
        return false;
    }

    m_bStart = true;
    m_bReStart = false;
    ReSetConnect();
    //create proc pool
    m_pProcThread = new pthread_t[g_SysConf.m_BaseConf.m_usProcPool];
    for (int i = 0; i < g_SysConf.m_BaseConf.m_usProcPool; i++) {
        pthread_create(&(m_pProcThread[i]), NULL, &DataParse, (void*)m_c2s);
    }

    //create send pool
    m_pSndThread = new pthread_t[g_SysConf.m_BaseConf.m_usSndPool];
    for (int i = 0; i < g_SysConf.m_BaseConf.m_usSndPool; i++) {
        pthread_create(&(m_pSndThread[i]), NULL, &RspParse, (void*)m_c2s);
    }

    //create receive pool
    m_pRecvThread = new pthread_t[g_SysConf.m_BaseConf.m_usRecvPool];
    for (int i = 0; i < g_SysConf.m_BaseConf.m_usRecvPool; i++) {
        pthread_create(&(m_pRecvThread[i]), NULL, &RecvParse, (void*)m_c2s);
    }

    m_pMainThread = new pthread_t;
    pthread_create(m_pMainThread, NULL, &MioRun, (void*)m_c2s);

    m_pWaitThread = new pthread_t[g_SysConf.m_BaseConf.m_usWaitSndPool];
    for (int i = 0; i < g_SysConf.m_BaseConf.m_usRecvPool; i++) {
        pthread_create(&(m_pWaitThread[i]), NULL, &WaitHandle, (void*)m_c2s);
    }

    gvLog(LOG_OFF, "(TcpServer::Start) Version Server runing (ip=%s, port=%d)...", m_c2s->local_ip, m_c2s->local_port);

    return true;
}
Example #12
0
 Deferred AllDoneDeferred(void) override {
   Stop();
   return Deferred(this);
 }
Example #13
0
 // Trivial shutdown override
 void AllDone(void) override {
   Stop();
 }
Example #14
0
STDMETHODIMP CBaseGraph::StopWhenReady()
{
    return Stop();
}
Example #15
0
bool EMMediaMetronome::MessageReceived(EMListenerRepository* p_opWho, uint32 p_vMessage)
{
	switch(p_vMessage)
	{
		case EM_MESSAGE_BEGIN_PLAYORRECORD:
		{
//			m_opProtectionSemaphore -> Acquire();
			m_vLastTickTime = -1;
//			m_opProtectionSemaphore -> Release();
			return true;
		}
		case EM_MESSAGE_BEGIN_BUFFER_UP:
		{
//			m_opProtectionSemaphore -> Acquire();
			m_vLastTickTime = -1;
//			m_opProtectionSemaphore -> Release();
			this -> Start();
			return true;
		}
		case EM_MESSAGE_TIME_WAS_SEEKED:
		{
			ReleaseSemaphore(m_uSleepSemaphore, 1, NULL);
			m_opProtectionSemaphore -> Acquire();
			m_vLastTickTime = -1;
			m_vSystemTimeWhenStarted = EMMediaTimer::Instance() -> GetSystemTimeWhenStarted();
			m_vSongTimeWhenStarted = EMMediaTimer::Instance() -> MetronomeNowTime();
			m_vClickNumber = 0;
			m_opProtectionSemaphore -> Release();
			return true;
		}
		case EM_MESSAGE_STOP_PLAYORRECORD:
		{
			Stop();
			//BEGIN TEST - COPIED FROM EM_MESSAGE_TIME_WAS_SEEKED
			m_opProtectionSemaphore -> Acquire();
			m_vLastTickTime = -1;
			m_vSystemTimeWhenStarted = EMMediaTimer::Instance() -> GetSystemTimeWhenStarted();
			m_vSongTimeWhenStarted = EMMediaTimer::Instance() -> MetronomeNowTime();
			m_vClickNumber = 0;
			m_opProtectionSemaphore -> Release();
			//END TEST - COPIED FROM EM_MESSAGE_TIME_WAS_SEEKED
			return true;
		}
		case EM_SETTING_UPDATED:
		{
			float vBPM = *static_cast<float*>(EMMediaEngine::Instance() -> GetSettingsRepository() -> GetSetting(SETTING_TEMPO));
			bool vEnabled = *static_cast<bool*>(EMMediaEngine::Instance() -> GetSettingsRepository() -> GetSetting(SETTING_MIDI_METRONOME_ENABLED));
			string oSignature = *static_cast<string*>(EMMediaEngine::Instance() -> GetSettingsRepository() -> GetSetting(SETTING_SIGNATURE));
			bool vUsePCSpeaker = *static_cast<bool*>(EMMediaEngine::Instance() -> GetSettingsRepository() -> GetSetting(SETTING_MIDI_METRONOME_USE_PC_SPEAKER));
			bool vUseMIDINote = *static_cast<bool*>(EMMediaEngine::Instance() -> GetSettingsRepository() -> GetSetting(SETTING_MIDI_METRONOME_USE_MIDI_NOTE));
			bool vDuringPlayback = *static_cast<bool*>(EMMediaEngine::Instance() -> GetSettingsRepository() -> GetSetting(SETTING_MIDI_METRONOME_DURING_PLAYBACK));
			bool vDuringRecording = *static_cast<bool*>(EMMediaEngine::Instance() -> GetSettingsRepository() -> GetSetting(SETTING_MIDI_METRONOME_DURING_RECORDING));
			string oDevice = string(static_cast<string*>(EMMediaEngine::Instance() -> GetSettingsRepository() -> GetSetting(SETTING_MIDI_METRONOME_MIDI_DEVICE)) -> c_str());
			uint32 vMIDIChannel = static_cast<uint32>(*static_cast<int32*>(EMMediaEngine::Instance() -> GetSettingsRepository() -> GetSetting(SETTING_MIDI_METRONOME_MIDI_CHANNEL)));
			uint8 vHighKey = static_cast<uint8>(*static_cast<int*>(EMMediaEngine::Instance() -> GetSettingsRepository() -> GetSetting(SETTING_MIDI_METRONOME_MIDI_NOTE_HIGH_KEY)));
			uint8 vHighVelocity = static_cast<uint8>(*static_cast<int*>(EMMediaEngine::Instance() -> GetSettingsRepository() -> GetSetting(SETTING_MIDI_METRONOME_MIDI_NOTE_HIGH_VELOCITY)));
			int64 vHighDuration = *static_cast<int64*>(EMMediaEngine::Instance() -> GetSettingsRepository() -> GetSetting(SETTING_MIDI_METRONOME_MIDI_NOTE_HIGH_DURATION));
			uint8 vLowKey = static_cast<uint8>(*static_cast<int*>(EMMediaEngine::Instance() -> GetSettingsRepository() -> GetSetting(SETTING_MIDI_METRONOME_MIDI_NOTE_LOW_KEY)));
			uint8 vLowVelocity = static_cast<uint8>(*static_cast<int*>(EMMediaEngine::Instance() -> GetSettingsRepository() -> GetSetting(SETTING_MIDI_METRONOME_MIDI_NOTE_LOW_VELOCITY)));
			int64 vLowDuration = *static_cast<int64*>(EMMediaEngine::Instance() -> GetSettingsRepository() -> GetSetting(SETTING_MIDI_METRONOME_MIDI_NOTE_LOW_DURATION));
			int32 vCountIn = *static_cast<int32*>(EMMediaEngine::Instance() -> GetSettingsRepository() -> GetSetting(SETTING_MIDI_METRONOME_COUNT_IN));
			
			int32 vSignatureMajor = 1;
			int32 vSignatureMinor = 1;
			sscanf(oSignature.c_str(), "%d/%d", &vSignatureMajor, &vSignatureMinor);
			if(vBPM != m_vBPM || 
				vEnabled != m_vIsEnabled || 
				vSignatureMajor != m_vSignatureMajor || 
				vSignatureMinor != m_vSignatureMinor ||
				m_vUsePCSpeaker != vUsePCSpeaker ||
				m_vUseMIDINote != vUseMIDINote ||
				m_vDuringPlayback != vDuringPlayback ||
				m_vDuringRecording != vDuringRecording ||
				m_oDevice != oDevice ||
				m_vMIDIChannel != vMIDIChannel ||
				m_vHighKey != vHighKey ||
				m_vHighVelocity != vHighVelocity ||
				m_vHighDuration != vHighDuration ||
				m_vLowKey != vLowKey ||
				m_vLowVelocity != vLowVelocity ||
				m_vLowDuration != vLowDuration ||
				m_vCountIn != vCountIn)
			{
				m_opProtectionSemaphore -> Acquire();
				m_vLastTickTime = -1;
				m_vBPM = vBPM;
				m_vIsEnabled = vEnabled;
				m_vSignatureMajor = vSignatureMajor;
				m_vSignatureMinor = vSignatureMinor;
				m_vUsePCSpeaker = vUsePCSpeaker;
				m_vUseMIDINote = vUseMIDINote;
				m_vDuringPlayback = vDuringPlayback;
				m_vDuringRecording = vDuringRecording;
				m_oDevice = oDevice.c_str();
				m_vMIDIChannel = vMIDIChannel;
				m_vHighKey = vHighKey;
				m_vHighVelocity = vHighVelocity;
				m_vHighDuration = vHighDuration;
				m_vLowKey = vLowKey;
				m_vLowVelocity = vLowVelocity;
				m_vLowDuration = vLowDuration;
				m_vCountIn = vCountIn;
				m_opProtectionSemaphore -> Release();

				EMRealtimeMIDIOutputDescriptor* opMIDIOut = static_cast<EMRealtimeMIDIOutputDescriptor*>(EMOutputRepository::Instance() -> SearchForName(m_oDevice));
				if(opMIDIOut == NULL)
					opMIDIOut = static_cast<EMRealtimeMIDIOutputDescriptor*>(EMOutputRepository::Instance() -> First(EM_TYPE_MIDI));

				if(opMIDIOut != NULL)
				{
					m_opProtectionSemaphore -> Acquire();
					m_opMetronomeMIDIDevice = opMIDIOut;
					m_opProtectionSemaphore -> Release();
				}
			}
			return true;
		}
		case EM_QUIT_PHASE_ONE:
			return false;
		case EM_QUIT_PHASE_TWO:
			break;
		case EM_QUIT_PHASE_THREE:
		{
			Stop();
			m_opThread -> RemoveListener(this);
			m_opThread -> Kill();
			delete m_opThread;
			m_opThread = NULL;
			return true;
		}
		case EM_QUIT_PHASE_FOUR:
			break;
		case EM_QUIT_PHASE_FIVE:
			break;
		case EM_QUIT_PHASE_SIX:
			break;
		case EM_QUIT_ABORTED:
			break;
		default:
			break;
	};
	return false;
}
Example #16
0
RakNetTransport2::~RakNetTransport2()
{
	Stop();
}
Example #17
0
 void GameCore::ContextRequestStop() { Stop(); }
Example #18
0
CRawThread::~CRawThread(void)
{
	Stop();
}
Example #19
0
bool TaskQueue::Process()
{
	boost::recursive_mutex::scoped_lock lock(queueMutex);

	for(list<TaskEntry>::iterator i(activeTasks.begin()); i != activeTasks.end();)
	{
		if(failed == kNoError)
			failed = i->GetTask()->FailureCode();

		if(i->GetTask()->IsDone() == true)
		{
			list<TaskEntry>::iterator e(i);
			i++;
			activeTasks.erase(e);
		}
		else
			i++;
	}

	if(failed != kNoError)
	{
		Stop();
		return false;
	}

	if(queuedTasks.empty() == false)
	{
		switch(queuedTasks.front().GetEntryType())
		{
			case TaskEntry::kTask:
			{
				activeTasks.push_back(queuedTasks.front());
				queuedTasks.front().GetTask()->Start(boost::bind(&TaskQueue::Notify, this));
				queuedTasks.pop();
				break;
			}
			case TaskEntry::kSync:
			{
				if(activeTasks.empty() == true)
					queuedTasks.pop();
				else
					return false;
				break;
			}
			case TaskEntry::kMessage:
			{
				try { POVMS_SendMessage(queuedTasks.front().GetMessage()); } catch(pov_base::Exception&) { }
				queuedTasks.pop();
				break;
			}
			case TaskEntry::kFunction:
			{
				try { queuedTasks.front().GetFunction()(*this); } catch(pov_base::Exception&) { }
				queuedTasks.pop();
				break;
			}
		}
	}

	if(queuedTasks.empty() == true)
		processCondition.wait(lock);

	return (queuedTasks.empty() == false);
}
WheelController::~WheelController()
{
	Stop();
	WaitForStop();
}
Example #21
0
CBufferItem::~CBufferItem()
{
	Stop();
	ReleaseOpenALBuffer();
}
HotspotImpl_TitlebarMenus::~HotspotImpl_TitlebarMenus()
{
	if (myEnabled)
		Stop();
}
Example #23
0
CGuiServer::~CGuiServer()
{
	Stop(true);
}
Example #24
0
AviRecorder::~AviRecorder()
{
	Stop();
}
void Z_DC_Spread_Policy::Init()
{
	//初始化200更接近真实值
	m_nHistoryCount = 90*15;
	//memset(&InsField,0,sizeof(FutureInstrumentField));
	strcpy(m_MyTradeA.InsField.InstrumentID, m_MyTradeA.m_InstrumentID);
	strcpy(m_MyTradeB.InsField.InstrumentID, m_MyTradeB.m_InstrumentID);
	if(!m_pTrader->GetInstrument(&m_MyTradeA.InsField)){
		throw "Invalid instrument_id A, please check.";
		Stop();
	}
	if(!m_pTrader->GetInstrument(&m_MyTradeB.InsField)){
		throw "Invalid instrument_id B, please check.";
		Stop();
	}
	if(strcmp(m_MyTradeA.m_InstrumentID,m_MyTradeB.m_InstrumentID) == 0){
		throw "The Same InstrumentID";
	}

	//ClosePos();
	cout<<"Price Tick: "<<m_MyTradeA.InsField.PriceTick<<" "<<m_MyTradeB.InsField.PriceTick<<" "<<m_MyTradeA.InsField.ExchangeID<<" "<<m_MyTradeB.InsField.ExchangeID<<" "<<strcmp(m_MyTradeB.InsField.ExchangeID,"SHFE")<<endl;
	//sleep(10);
	if(strcmp(m_MyTradeA.InsField.ExchangeID,"SHFE")==0){
		m_pTrader->SetSHFE(true);
		cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl;
	}if(strcmp(m_MyTradeB.InsField.ExchangeID,"SHFE") == 0){
		m_pTrader->SetSHFE(true);
		cout<<"**********************************"<<endl;
	}
	GetStartTime(m_MyTradeA.m_InstrumentID);
	//订阅行情
	SubscribeMarketData(m_MyTradeA.m_InstrumentID);
	SubscribeMarketData(m_MyTradeB.m_InstrumentID);

	m_MyTradeA.m_nMaxAddPosInWin = this->m_fAddPosInWin*m_MyTradeA.m_nMaxPos;
	m_MyTradeA.m_nMaxAddPosInLose = this->m_fAddPosInLose*m_MyTradeA.m_nMaxPos;
	m_MyTradeB.m_nMaxAddPosInWin = this->m_fAddPosInWin*m_MyTradeB.m_nMaxPos;
	m_MyTradeB.m_nMaxAddPosInLose = this->m_fAddPosInLose*m_MyTradeB.m_nMaxPos;

	cout<<"Inited and StartA:"<<m_MyTradeA.m_CountID<<" "<<m_MyTradeA.m_InstrumentID<<" "<<m_MyTradeA.m_nMaxPos<<" "<<m_MyTradeA.m_nMaxAddPosInWin<<" "<<m_MyTradeA.m_nMaxAddPosInLose<<endl;
	cout<<"Inited and StartB:"<<m_MyTradeB.m_CountID<<" "<<m_MyTradeB.m_InstrumentID<<" "<<m_MyTradeB.m_nMaxPos<<" "<<m_MyTradeB.m_nMaxAddPosInWin<<" "<<m_MyTradeB.m_nMaxAddPosInLose<<endl;

	m_MyTradeA.m_pSeries = m_pBarsCollection->CreateSeries(m_MyTradeA.m_InstrumentID,m_MyTradeA.InsField.ExchangeID,Minute,15,m_MyTradeA.InsField.VolumeMultiply,500);
	m_MyTradeA.m_pSeries->ReadHistoryLastN(10);
/*
	m_MyTradeA.m_pSeries_1 = m_pBarsCollection->CreateSeries(m_MyTradeA.m_InstrumentID,m_MyTradeA.InsField.ExchangeID,m_nBarType_1,m_nBarLength_1,10,2048);
	m_MyTradeA.m_pSeries_1->ReadHistoryLastN(1500);
	*/
	//m_pSeries = m_pBarsCollection->CreateSeries(m_InstrumentID, "CFFEX", m_nBarType,  m_nBarLength, 10, 2048);
	//m_pSeries->ReadHistoryLastN(m_nHistoryCount);
	//m_MyPUBU2 = new MyPUBU2(m_pSeries);


/*	m_MyTradeB.m_pSeries = m_pBarsCollection->CreateSeries(m_MyTradeB.m_InstrumentID,m_MyTradeB.InsField.ExchangeID,m_nBarType,m_nBarLength,10,2048);
	m_MyTradeB.m_pSeries->ReadHistoryLastN(1500);

	m_MyTradeB.m_pSeries_1 = m_pBarsCollection->CreateSeries(m_MyTradeB.m_InstrumentID,m_MyTradeB.InsField.ExchangeID,m_nBarType_1,m_nBarLength_1,10,2048);
	m_MyTradeB.m_pSeries_1->ReadHistoryLastN(1500);
	if(m_MyDCM != NULL){
		delete m_MyDCM;
	}
	if(m_MyDCM_1 != NULL){
		delete m_MyDCM_1;
	}
	m_MyDCM = new MyDCM(m_MyTradeA.m_pSeries,m_MyTradeB.m_pSeries,m_nN1,m_nN2,m_nN3);
	int _sizeA = m_MyTradeA.m_pSeries->m_nCount;
	int _sizeB = m_MyTradeB.m_pSeries->m_nCount;
	int _count = min(_sizeA, _sizeB);
	for(int i=_count; i>=2; i--){
		m_MyDCM->Update(_sizeA - i,_sizeB - i);
	}
	if(m_MyTradeA.m_pSeries->GetBar(_sizeA - 1)->m_fHighest != m_MyTradeA.m_pSeries->GetBar(_sizeA - 1)->m_fLowest ||
			m_MyTradeB.m_pSeries->GetBar(_sizeB - 1)->m_fHighest != m_MyTradeB.m_pSeries->GetBar(_sizeB - 1)->m_fLowest)
	{
		m_MyDCM->Update(_sizeA - 1,_sizeB - 1);
	}
	m_MyDCM_1 = new MyDCM(m_MyTradeA.m_pSeries_1,m_MyTradeB.m_pSeries_1,m_nN1,m_nN2,m_nN3);
	int _sizeA_1 = m_MyTradeA.m_pSeries_1->m_nCount;
	int _sizeB_1 = m_MyTradeB.m_pSeries_1->m_nCount;
	int _count_1 = min(_sizeA_1,_sizeB_1);
	for(int i=_count_1; i>=2; i--){
		m_MyDCM_1->Update(_sizeA_1 - i,_sizeB_1 - i);
	}
	if(m_MyTradeA.m_pSeries_1->GetBar(_sizeA_1 - 1)->m_fHighest != m_MyTradeA.m_pSeries_1->GetBar(_sizeA_1 - 1)->m_fLowest ||
			m_MyTradeB.m_pSeries_1->GetBar(_sizeB_1 - 1)->m_fHighest != m_MyTradeB.m_pSeries_1->GetBar(_sizeB_1 - 1)->m_fLowest)
	{
		m_MyDCM_1->Update(_sizeA_1 - 1,_sizeB_1 - 1);
	}


	cout<<m_MyTradeA.m_InstrumentID<<" init: "<<m_MyTradeA.m_pSeries->m_nCount<<" "<<m_MyDCM->m_fMA1<<" "<<m_MyDCM->m_fMA2<<" "<<m_MyDCM_1->m_fMA1<<" "<<m_MyDCM_1->m_fMA2<<endl;
	cout<<m_MyTradeB.m_InstrumentID<<" init: "<<m_MyTradeB.m_pSeries->m_nCount<<" "<<m_MyDCM->m_fMA1<<" "<<m_MyDCM->m_fMA2<<" "<<m_MyDCM_1->m_fMA1<<" "<<m_MyDCM_1->m_fMA2<<endl;
*/

	//初始化


	m_bStopOnClose = false;
	cout<<"Init end"<<endl;

}
void CzPlatformVideo::Release()
{
	Stop();
	Initialised = false;
}
Example #27
0
/*
===============
idCameraAnim::Event_Stop
================
*/
void idCameraAnim::Event_Stop()
{
	Stop();
}
Example #28
0
WasServer::~WasServer()
{
	Stop() ;
}
Example #29
0
CResourceHTMLItem::~CResourceHTMLItem ( void )
{
    Stop();
}
Example #30
0
void AnnDrive::Move(
	double &speed, 
	double &angle, 
	double &rotation,
	bool &stop
)
{
	if (stop)
	{
		Stop();
		return;
	}
	
	/*
		Thoughts and notes
		
		We should calculate an ideal speed and angle for each wheel (ie, 
		our goal), and tell the wheel servos to go there. However, we must
		set the velocities of the wheels based on the current angle of the 
		wheels so that we don't go in weird directions
		
		Question: is this actually true? Should we just sit until the wheels
		turn (this seems like a bad idea)
		
		Currently, neither of those is implemented.
		
	*/
	
	// special case: doing nothing
	if (fabs(speed) < 0.0001 && fabs(angle) < 0.0001 && fabs(rotation) < 0.0001)
	{
		// this forces motors to stop and keeps the wheels pointed in the
		// same direction, much less annoying
		m_chassis->motor_lf.SetSpeed(0);
		m_chassis->motor_lr.SetSpeed(0);
		m_chassis->motor_rf.SetSpeed(0);
		m_chassis->motor_rr.SetSpeed(0);
		
		return;
	}
	
	
	// set limitations on speed
	if (speed < -1.0)
		speed = -1.0;
	else if (speed > 1.0)
		speed = 1.0;
	
	// set limitations on rotation
	if (rotation < -1.0)
		rotation = -1.0;
	else if (rotation > 1.0)
		rotation = 1.0;
 
	
//----------------------------------------------------------------------------------------------
// ANNETTE--added lots of stuff
//----------------------------------------------------------------------------------------------


// I'm assuming this method's parameter, angle (for the basic direction the wwheels are facing), is in radians,
// and that 0 means pointing so that the robot would be driving straight front.

// For this, I'm assuming that twisting the joystick will mean have robot drive in a curve, rotating along the way.

// The "key point" should be roughly the center of mass of the robot-and-trailer combination.
// Since it should be on the mid-line, only its distance back from the front wheels is needed.

// It might be worthwhile experimenting to find the best value to use for that, for the "big_r"
// that affects furthest center of rotation (shallowest curve), for the fudge factor that affects
// the closest center of rotation (shallowest curve, and for the function. 
 


// constants

const double length=18.5, width=29.5, key_d=12;	// robot shape, and key point distance from front

const double big_r=100; 			// longest possible distance between key and center of rotation
						// for shallowest curve (that's not a straight line)
						// maybe make it close to the field size (54')
const double PI = 3.1415926;
const double half_pi = PI/2;
const double to_radians = 180./PI;
const double to_degrees = PI/180.;
const double almost_0 = .01;
const double fudge = 1.0;			// fudge factor for computing small_r
				
const double half_w=width/2;	// half width
const double lf_x=key_d, lr_x=key_d-length,
			rf_x=key_d, rr_x=key_d-length; 	//x coordinates of wheels
const double lf_y=half_w, lr_y=half_w, rf_y=-half_w,
			rr_y=-half_w; 			//y coordinates of wheels


//other variables

double small_r; 		// shortest desired distance between key and center of rotation
				

double r, r_angle, rx, ry;	// length of radius to center of rotation,
				// and its angle and coordinates
						
double r_lf, r_lr, r_rf, r_rr; 	// distances from center of rotation to wheels
double r_max;			// max of the r's

double angle_in_radians;

double angle1, angle2;		//some temporaries for angles

   
    if (fabs(rotation) < almost_0)
    {
        // no rotation
		
		m_chassis->servo_lf.SetAngle(angle);
		m_chassis->servo_rf.SetAngle(angle);
		m_chassis->servo_lr.SetAngle(angle);
		m_chassis->servo_rr.SetAngle(angle);
		
		m_chassis->motor_lf.SetSpeed((float)speed);
		m_chassis->motor_lr.SetSpeed((float)speed);
		m_chassis->motor_rf.SetSpeed((float)speed);
		m_chassis->motor_rr.SetSpeed((float)speed);
		
	}
	else
	{
		// we need some rotation code here... 


// determine smallest r
// it should be at least as big as the length from the key point to any of the wheels

small_r = std::max(key_d, length-key_d);	//just a temp val here, to use in next line
small_r = sqrt( small_r*small_r + width*width/4.) + fudge; // add in the fudge factor


// compute r based on magnitude of twist or "rotation", between 0 and 1
// a previous step already took care of rotation too close to 0

// this is linear, but alternative functions could be tried
// they should be smoothly decreasing as rotation increases, and 
// be approximately =big_r for rotation close to 0,
// and be =small_r for rotation equal 1

r = big_r+(small_r-big_r)*fabs(rotation);

// calc r's coordinates
// positive rotation means clockwise,
// so center of rotation is to the right if you're facing in heading angle direction

angle_in_radians = angle*to_radians;

r_angle = rotation>0 ? angle_in_radians - half_pi : angle_in_radians + half_pi; 
rx = r*cos (r_angle);
ry = r*sin (r_angle);

// calc distance from center of rotation to each wheel
r_lf = sqrt((lf_x-rx)*(lf_x-rx) + (lf_y-ry)*(lf_y-ry));
r_lr = sqrt((lr_x-rx)*(lr_x-rx) + (lr_y-ry)*(lr_y-ry));
r_rf = sqrt((rf_x-rx)*(rf_x-rx) + (rf_y-ry)*(rf_y-ry));
r_rr = sqrt((rr_x-rx)*(rr_x-rx) + (rr_y-ry)*(rr_y-ry));

// find the biggest r, the distance of the wheel furthest away from the center of rotation

r_max = std::max(std::max(r_lf, r_lr), std::max(r_rf,  r_rr));


// set wheel speeds
// the furthest wheel gets the full speed
// the rest are proportionally less

		m_chassis->motor_lf.SetSpeed(speed*r_lf/r_max);
		m_chassis->motor_lr.SetSpeed(speed*r_lr/r_max);
		m_chassis->motor_rf.SetSpeed(speed*r_rf/r_max);
		m_chassis->motor_rr.SetSpeed(speed*r_rr/r_max);


// compute and set angles
// use arctan of slope of line perpendicular
// to the line connecting the center of rotation and the wheel, and
// picking out of the arctan results, which could be + or - 180 degrees,
// the one closest to the input angle

if (fabs(ry-lf_y)<almost_0)
	if (rx-lf_x >=0) m_chassis->servo_lf.SetAngle(0); // angle is along x axis
		else m_chassis->servo_lf.SetAngle(180.) ; // but neg direction

	else { 	angle1 = (atan ((rx-lf_x)/(lf_y-ry)))*to_degrees;
		angle2 = angle1>0 ? angle1-180. :angle1+180.;

		m_chassis->servo_lf.SetAngle(fabs(angle1-angle) < fabs(angle1-angle) ? angle1 : angle2);
		}		

if (fabs(ry-lr_y)<almost_0)
	if (rx-lr_x >=0) m_chassis->servo_lr.SetAngle(0); // angle is along x axis
		else m_chassis->servo_lr.SetAngle(180.) ; // but neg direction

	else { 	angle1 = (atan ((rx-lr_x)/(lr_y-ry)))*to_degrees;
		angle2 = angle1>0 ? angle1-180. :angle1+180.;

		m_chassis->servo_lr.SetAngle(fabs(angle1-angle) < fabs(angle1-angle) ? angle1 : angle2);
		}	

if (fabs(ry-rf_y)<almost_0)
	if (rx-rf_x >=0) m_chassis->servo_rf.SetAngle(0); // angle is along x axis
		else m_chassis->servo_rf.SetAngle(180.);  // but neg direction

	else { 	angle1 = (atan ((rx-rf_x)/(rf_y-ry)))*to_degrees;
		angle2 = angle1>0 ? angle1-180. :angle1+180.;

		m_chassis->servo_rf.SetAngle(fabs(angle1-angle) < fabs(angle1-angle) ? angle1 : angle2);
		}	

if (fabs(ry-rr_y)<almost_0)
	if (rx-rr_x >=0) m_chassis->servo_rr.SetAngle(0); // angle is along x axis
		else m_chassis->servo_rr.SetAngle(180.) ; // but neg direction

	else { 	angle1 = (atan ((rx-rr_x)/(rr_y-ry)))*to_degrees;
		angle2 = angle1>0 ? angle1-180. :angle1+180.;

		m_chassis->servo_rr.SetAngle(fabs(angle1-angle) < fabs(angle1-angle) ? angle1 : angle2);
		}	

    }


	



	
}