Example #1
0
int ShaderEditor::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QMainWindow::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: frameStarted(); break;
        case 1: Tick(); break;
        default: ;
        }
        _id -= 2;
    }
    return _id;
}
Example #2
0
void dgWorld::Update (dgFloat32 timestep)
{
	m_concurrentUpdate = false;
	m_savetimestep = timestep;
	#ifdef DG_USE_THREAD_EMULATION
		dgFloatExceptions exception;
		dgSetPrecisionDouble precision;
		RunStep ();
	#else 
		// runs the update in a separate thread and wait until the update is completed before it returns.
		// this will run well on single core systems, since the two thread are mutually exclusive 
		Tick();
		SuspendExecution(dgWorld::m_mutex);
	#endif
}
Example #3
0
CPlasma::CPlasma(CGameWorld *pGameWorld, vec2 Pos, vec2 Direction, float StartEnergy, int Owner)
	: CEntity(pGameWorld, CGameWorld::ENTTYPE_LASER)
{
	m_Pos = Pos;
	m_Owner = Owner;
	m_Energy = StartEnergy;
	m_Dir = Direction;
	m_Bounces = 0;
	m_Vel = 3;
	m_Limit = GameServer()->m_pEventsGame->IsActualEvent(WEAPON_SLOW) ? true : false;
	GameWorld()->InsertEntity(this);
	Tick();
	if (GameServer()->m_apPlayers[m_Owner] && m_Limit)
		GameServer()->m_apPlayers[m_Owner]->m_Mine++;
}
Example #4
0
TEST_F(TeeHistorian, ExtraMessage)
{
	const unsigned char EXPECTED[] = {
		0x41, 0x00, // TICK_SKIP dt=0
		// EX uuid=6bb8ba88-0f0b-382e-8dae-dbf4052b8b7d data_len=0
		0x4a,
		0x6b, 0xb8, 0xba, 0x88, 0x0f, 0x0b, 0x38, 0x2e,
		0x8d, 0xae, 0xdb, 0xf4, 0x05, 0x2b, 0x8b, 0x7d,
		0x00,
		0x40, // FINISH
	};
	Tick(1); Inputs(); m_TH.RecordTestExtra();
	Finish();
	Expect(EXPECTED, sizeof(EXPECTED));
}
Example #5
0
uint32 FAsyncIOSystemBase::Run()
{
	// IsRunning gets decremented by Stop.
	while( IsRunning.GetValue() > 0 )
	{
		// Sit and spin if requested, unless we are shutting down, in which case make sure we don't deadlock.
		while( !GIsRequestingExit && SuspendCount.GetValue() > 0 )
		{
			FPlatformProcess::Sleep(0.005);
		}

		Tick();
	}

	return 0;
}
void CKarplusStrongController::TestTickSpeed()
{
    m_SerialComm.printf("Test Tick speed\r\n");
    Timer l_Timer;
    l_Timer.reset();
    l_Timer.start();
    int NumRepeats = m_SamplingFrequency;
    for(int Repeat = 0; Repeat<NumRepeats; ++Repeat)
    {
        Tick();
    }
    l_Timer.stop();

    m_SerialComm.printf("The time taken for %d repeats was %d microseconds \r\n", NumRepeats, l_Timer.read_us());
    m_SerialComm.printf("---------------\r\n");
}
Example #7
0
GLWidget::GLWidget()
{    
    setAutoFillBackground(false);
    setMouseTracking(true);    
    setCursor(Qt::BlankCursor);
    resize(_size,_size);

    random = new Random(85533);    

    QTimer *timer = new QTimer(this);
    connect(timer, SIGNAL(timeout()), this, SLOT(Tick()));
    timer->start(1000);

    thread = new MyThread(this,this);
    connect(thread, SIGNAL(ShowOnUI()),this,SLOT(update()));
    thread->start();    
}
int main(void) {
	DDRB = 0xFF; PORTB = 0x00;
	DDRA = 0xFF; PORTA = 0x00;
	DDRD = 0xFF; PORTD = 0x00;
	DDRC = 0xF0; PORTC = 0x0F; // PC7..4 outputs init 0s, PC3..0 inputs init 1s
	
	TimerSet(200);
	TimerOn();
	LCD_init();
	LCD_DisplayString(1,"Congratulations!");
	state = start;
	while(1) {
		while (!TimerFlag);
		TimerFlag = 0;
		Tick();
	}
}
Example #9
0
void csv2ticks(std::string fname, std::string splitter, vector<Tick>& ticks) {
  ifstream fin;
  string buf;
  vector<string> splitbuf;
  typedef vector< boost::iterator_range<string::iterator> > find_vector_type;
  fin.open(fname.c_str());

  if(!fin.is_open()) {
    return;
  }

  while(getline(fin, buf)) {
    boost::split(splitbuf, buf, boost::is_any_of(splitter));
    ticks.push_back(Tick(splitbuf[1],toposixct(splitbuf[0]),splitbuf[2],splitbuf[3]));
  }
  fin.close();
}
Example #10
0
void
WorkerThread::Run()
{
  PeriodClock clock;

  while (true) {
    /* wait for work */
    event_trigger.Wait();

    /* got the "stop" trigger? */
    if (delay > 0
        ? WaitForStopped(delay)
        : CheckStoppedOrSuspended())
      break;

    /* reset the trigger here, because our client might have called
       Trigger() a few more times while we were suspended in
       CheckStoppedOrSuspended() */
    event_trigger.Reset();

    if (IsCommandPending()) {
      /* just in case we got another suspend/stop command after
         CheckStoppedOrSuspended() returned and before the trigger got
         reset: restore the trigger and skip this iteration, to fix
         the race condition */
      event_trigger.Signal();
      continue;
    }

    /* do the actual work */
    if (period_min > 0)
      clock.Update();

    Tick();

    unsigned idle = idle_min;
    if (period_min > 0) {
      unsigned elapsed = clock.Elapsed();
      if (elapsed + idle < period_min)
        idle = period_min - elapsed;
    }

    if (idle > 0 && WaitForStopped(idle))
      break;
  }
}
void UploadManagerImpl::ActionTokenRetry(
        const boost::system::error_code & err
    )
{
    mf::utils::unique_lock<mf::utils::mutex> lock(mutex_);

    if (!err && action_token_state_ == ActionTokenState::Error)
    {
        action_token_.clear();
        action_token_state_ = ActionTokenState::Invalid;

        // Unlock before calling external
        lock.unlock();

        Tick();
    }
}
void CSimpleOscillatorController::TestTickSpeed(int Operator)
{
    m_SerialComm.printf("Test Tick speed\r\n");
    m_SerialComm.printf("Operator = %s \r\n", CSelectableOperatorFactory::SelectionList()[Operator].c_str());
    m_Oscillator.SelectWaveform(Operator);
    Timer l_Timer;
    l_Timer.reset();
    l_Timer.start();
    int NumRepeats = m_SamplingFrequency;
    for(int Repeat = 0; Repeat<NumRepeats; ++Repeat)
    {
        Tick();
    }
    l_Timer.stop();

    m_SerialComm.printf("The time taken for %d repeats was %d microseconds \r\n", NumRepeats, l_Timer.read_us());
    m_SerialComm.printf("---------------\r\n");
}
Example #13
0
bool UIProgressDialog::Progress(const char* package, int index, int total)
{
	// do not update UI too often
	int tick = appMilliseconds();
	if (tick - lastTick < 50)
		return true;
	lastTick = tick;

	char buffer[512];
	appSprintf(ARRAY_ARG(buffer), "%s %d/%d", DescriptionText, index+1, total);
	DescriptionLabel->SetText(buffer);

	PackageLabel->SetText(package);

	ProgressBar->SetValue((float)(index+1) / total);

	return Tick();
}
Example #14
0
void GameEngine::Run()
{
	m_runner->Start();

	while (Is_Running())
	{
		m_frame_time.New_Tick();

		m_frame_time.Begin_Update();
		Tick(m_frame_time);
		m_frame_time.Finish_Update();
	
		m_frame_time.Begin_Draw();
		m_render_pipeline->Draw(m_frame_time);
		m_frame_time.Finish_Draw();
	}	

	m_runner->End();
}
int Application::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QObject::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: update((*reinterpret_cast< QString(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2]))); break;
        case 1: setToZero(); break;
        case 2: onExit(); break;
        case 3: Tick(); break;
        case 4: Screen(); break;
        case 5: Hide(); break;
        default: ;
        }
        _id -= 6;
    }
    return _id;
}
int main(void)
{
    DDRA = 0x00; PORTA = 0xFF;	// set PORTA to inputs and initialize
    DDRC = 0xFF; PORTC = 0x00;  // data lines
    DDRD = 0xFF; PORTD = 0x00;  // LCD control lines

    LCD_init();

    TimerSet(125);             // set Timer period
    TimerOn();                  // enable Timer

    state = START;              // initialize state
    
	while(1)
	{
		Tick();                 // step through states
        while (!TimerFlag);     // Wait for a period
        TimerFlag = 0;          // reset the timer flag
	}
}
Example #17
0
    Tick
    Tick::FromMicroseconds(
        uint64 luTime)                          // Time, in microseconds
    {
        //
        // Ensure we can convert losslessly.
        //

#if DBG
        const uint64 luMaxTick = _UI64_MAX / s_luFreq;
        AssertMsg(luTime <= luMaxTick, "Ensure time can be converted losslessly");
#endif // DBG


        //
        // Create the Tick
        //

        uint64 luTick = luTime * s_luFreq / ((uint64) 1000000);
        return Tick(luTick);
    }
Example #18
0
void Clock::InitClockData()
{
	if (appStartTime == 0)
		appStartTime = Tick();

#ifdef WIN32
	if (!QueryPerformanceFrequency(reinterpret_cast<LARGE_INTEGER*>(&ddwTimerFrequency)))
	{
		LOGE("The system doesn't support high-resolution timers!");
		ddwTimerFrequency = (u64)-1;
	}

	if (appStartTime == 0)
	{
#if WINVER >= 0x0600 /* Vista or newer */ && !defined(MATH_ENABLE_WINXP_SUPPORT)
		appStartTime = (tick_t)GetTickCount64();
#else
// We are explicitly building with XP support, so GetTickCount() instead of GetTickCount64 is desired.
#if _MSC_VER >= 1700 // VS2012
#pragma warning(push)
#pragma warning(disable:28159) // warning C28159: Consider using 'GetTickCount64' instead of 'GetTickCount'. Reason: GetTickCount overflows roughly every 49 days.  Code that does not take that into account can loop indefinitely.  GetTickCount64 operates on 64 bit values and does not have that problem
#endif
		appStartTime = (tick_t)GetTickCount();
#if _MSC_VER >= 1700 // VS2012
#pragma warning(pop)
#endif

#endif
	}
#endif

#ifdef __APPLE__
	mach_timebase_info_data_t timeBaseInfo;
	mach_timebase_info(&timeBaseInfo);
	ticksPerSecond = 1000000000ULL * (uint64_t)timeBaseInfo.denom / (uint64_t)timeBaseInfo.numer;
	ASSERT(ticksPerSecond > (uint64_t)timeBaseInfo.denom/timeBaseInfo.numer);
	// Guard against overflow if OSX numer/denom change or similar.
#endif
}
Example #19
0
void Clock::InitClockData()
{
	if (appStartTime == 0)
		appStartTime = Tick();

#ifdef WIN32
	if (!QueryPerformanceFrequency(&ddwTimerFrequency))
	{
		LOG(LogError, "The system doesn't support high-resolution timers!");
		ddwTimerFrequency.HighPart = (unsigned long)-1;
		ddwTimerFrequency.LowPart = (unsigned long)-1;
	}

	if (ddwTimerFrequency.HighPart > 0)
		LOG(LogError, "Warning: Clock::TicksPerSec will yield invalid timing data!");

	if (appStartTime == 0)
		appStartTime = (tick_t)GetTickCount64();

	///\todo Test here that the return values of QueryPerformanceCounter is nondecreasing.
#endif
}
Example #20
0
void CAppBase::Run()
{
	MSG msg;
	ZeroMemory(&msg, sizeof(MSG));

	// Loop until there is a quit message from the window or the user.
	m_bIsRun = true;
	int result;
	while(m_bIsRun)
	{
		// Handle the windows messages.
		if(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
		{
			TranslateMessage(&msg);
			DispatchMessage(&msg);
		}

		// If windows signals to end the application then exit out.
		if(msg.message == WM_QUIT)
		{
			m_bIsRun = false;
		}
		else
		{
			// Otherwise do the Tick processing.
			result = Tick();
			if(result == E_SHUTDOWN)
			{
				m_bIsRun = false;
			}
		}

	}

	ShutDown();

	return;
}
void LatencyBuffer::add(Tick p_tick,Tick p_ticks,float p_msecs ) {
	if (p_msecs<=0.0)
		return;
	
	float new_pos=fmodf(indexf+p_msecs,(float)MSECS_MAX);
	int new_pos_i=(int)new_pos;
	if (new_pos_i>=MSECS_MAX) { //may happen, it's floats..
		new_pos_i=0;
		new_pos=0.0;
	}

	while (index!=new_pos_i) {
		
		index=(index+1)%MSECS_MAX;
		p_tick+=Tick((float)p_ticks/p_msecs);
		ring_buffer[index]=p_tick;
		if (written<MSECS_MAX)
			written++;
	}
	
	indexf=new_pos;
	
}
Example #22
0
void Game::Run() {
	m_frame_clock.restart();

	long counter = 0;
	float fps_micro_secs = 0.0f;

	while ( m_running && m_window->isOpen() ) {
		float micro_secs = static_cast<float>( m_frame_clock.getElapsedTime().asMicroseconds() );
		m_frame_clock.restart();

		Tick( micro_secs / 1000000.0f );

		counter++;

		fps_micro_secs += micro_secs;

		if( fps_micro_secs > 1000000.0f ) {
			fps_micro_secs = 0.0f;
			m_window->setTitle( "WYRM - " + string_cast( counter ) + " FPS" );
			counter = 0;
		}
	}
}
Example #23
0
int main(void)
{
	// Set port B to output
	// Init port B to 0s
	DDRA = 0x00;
	PORTA = 0xFF;
	DDRB = 0xFF;
	PORTB = 0x00;
	state = Start;
	TimerSet(500);
	TimerOn();
	while(1) {
		// User code (i.e. synchSM calls)
		// Toggle PORTB; Temporary, bad programming style
		Tick();
		
		// Wait 1 sec
		while (!TimerFlag);
		TimerFlag = 0;
		// Note: For the above a better style would use a synchSM with TickSM()
		// This example just illustrates the use of the ISR and flag
	}
}
Example #24
0
	void Game::Run()
	{
		MSG msg;

		int totalTime = 0;

		isRunning = true;

		while (isRunning)
		{
			// Check event loop here.
			if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
			{
				if (msg.message == WM_QUIT)
					isRunning = false;
				else
				{
					TranslateMessage(&msg);
					DispatchMessage(&msg);
				}
			}
			else
			{
				TimeSpan timeInitial = FarSystem::GetSystemTime();

				Tick();
				/*
				TimeSpan timeFinal = FarSystem::GetSystemTime();
				int waitTime = targetElapsedTime - (timeFinal - timeInitial).GetMilliseconds();

				while (waitTime > 0) {
					TimeSpan timeFinal = FarSystem::GetSystemTime();
					waitTime = targetElapsedTime - (timeFinal - timeInitial).GetMilliseconds();
				}*/
			}
		}
	}
int PlayerController::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QObject::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: playing(); break;
        case 1: stopped(); break;
        case 2: paused(); break;
        case 3: playerStarted((*reinterpret_cast< bool(*)>(_a[1]))); break;
        case 4: playerClosed(); break;
        case 5: changeTrackInfo((*reinterpret_cast< QString(*)>(_a[1])),(*reinterpret_cast< QString(*)>(_a[2]))); break;
        case 6: changePos((*reinterpret_cast< int(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2]))); break;
        case 7: passAlbumArt((*reinterpret_cast< CFbsBitmap*(*)>(_a[1]))); break;
        case 8: updateAlbumArt((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 9: CheckPlayerState(); break;
        case 10: Tick(); break;
        case 11: Play(); break;
        case 12: Pause(); break;
        case 13: Next(); break;
        case 14: Previous(); break;
        case 15: SeekForward(); break;
        case 16: SeekBack(); break;
        case 17: StopSeeking(); break;
        case 18: AlbumArtSaved((*reinterpret_cast< CFbsBitmap*(*)>(_a[1]))); break;
        case 19: GoToNowPlaying(); break;
        case 20: ClosePlayer(); break;
        case 21: SeekToPos((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 22: GetState(); break;
        default: ;
        }
        _id -= 23;
    }
    return _id;
}
Example #26
0
int main(int argc, char *argv[])
{
	RN::Initialize(argc, argv);
	
#if RN_PLATFORM_MAC_OS
	RN::FileManager::GetSharedInstance()->AddSearchPath("/usr/local/opt/Rayne/Engine Resources");
#endif
#if RN_PLATFORM_WINDOWS
	char path[MAX_PATH + 1];
	::SHGetFolderPathA(NULL, CSIDL_PROGRAM_FILES, NULL, SHGFP_TYPE_CURRENT, path);

	std::stringstream stream;
	stream << path << "\\Rayne\\Engine Resources";

	RN::FileManager::GetSharedInstance()->AddSearchPath(stream.str());
#endif
	
	try
	{
		auto application = new WH::Application();
		auto kernel = new RN::Kernel(application);
		
		while(kernel->Tick())
		{}
		
		delete kernel;
		delete application;
	}
	catch(RN::Exception e)
	{
		RN::HandleException(e);
		return EXIT_FAILURE;
	}
	
	return EXIT_SUCCESS;
}
Example #27
0
	void Game::Run()
	{
		sassert(!inRun, "Run Method called more than once.");

		inRun = true;
		BeginRun();
			
		graphicsManager = (IGraphicsDeviceManager*)((GraphicsDeviceManager*)services.GetService(IGraphicsDeviceManager::GetType()));

		if (graphicsManager != null)
			graphicsManager->CreateDevice();
#if DEBUG
		else
			debugPrint("graphicsManager is NULL.\n");
#endif

		Initialize();

		while(1)
			Tick();

		EndRun();
		inRun = false;
	}
void SWidget::TickWidgetsRecursively( const FGeometry& AllottedGeometry, const double InCurrentTime, const float InDeltaTime )
{
	INC_DWORD_STAT(STAT_SlateNumTickedWidgets);

	// Execute any pending active timers for this widget, followed by the passive tick
	ExecuteActiveTimers( InCurrentTime, InDeltaTime );
	{
		SLATE_CYCLE_COUNTER_SCOPE_CUSTOM_DETAILED(SLATE_STATS_DETAIL_LEVEL_MED, GSlateWidgetTick, GetType());
		Tick(AllottedGeometry, InCurrentTime, InDeltaTime);
	}

	// Gather all children, whether they're visible or not.  We need to allow invisible widgets to
	// consider whether they should still be invisible in their tick functions, as well as maintain
	// other state when hidden,
	FArrangedChildren ArrangedChildren(TickInvisibleWidgets.GetValueOnGameThread() ? EVisibility::All : EVisibility::Visible);
	ArrangeChildren(AllottedGeometry, ArrangedChildren);

	// Recur!
	for(int32 ChildIndex=0; ChildIndex < ArrangedChildren.Num(); ++ChildIndex)
	{
		FArrangedWidget& SomeChild = ArrangedChildren[ChildIndex];
		SomeChild.Widget->TickWidgetsRecursively( SomeChild.Geometry, InCurrentTime, InDeltaTime );
	}
}
/*virtual*/ void WBCompEldSensor::HandleEvent( const WBEvent& Event )
{
	XTRACE_FUNCTION;

	WBEldritchComponent::HandleEvent( Event );

	STATIC_HASHED_STRING( TickSensors );
	STATIC_HASHED_STRING( PauseSensors );
	STATIC_HASHED_STRING( UnpauseSensors );

	const HashedString EventName = Event.GetEventName();
	if( EventName == sTickSensors )
	{
		Tick( 0.0f );
	}
	else if( EventName == sPauseSensors )
	{
		m_Paused = true;
	}
	else if( EventName == sUnpauseSensors )
	{
		m_Paused = false;
	}
}
Example #30
0
void GameEngine::Go()
{
	// Time FPS and TPS
	if(performanceTimer.GetTimePassed() >= 1000.0) {
		//std::cout << "FPS: " << std::setw(3) << frames << ", TPS: " << std::setw(3) << ticks << '\n';
		frames = 0;
		ticks = 0;
		performanceTimer.Restart();
	}
	
	// Tick
	if(tickTimer.GetTimePassed() >= TICK_TIME) {
		tickDelay = tickTimer.GetTimePassed() - TICK_TIME;
		tickTimer.Restart();
		ticks++;
		Tick();
	}

	// Draw
	if(frameTimer.GetTimePassed() >= FRAME_TIME) {
		frameDelay = frameTimer.GetTimePassed() - FRAME_TIME;
		frameTimer.Restart();
		gfx->BeginFrame();
		frames++;
		Draw();
		gfx->EndFrame();
	}

	double tickDifference = (TICK_TIME - tickDelay) - tickTimer.GetTimePassed();
	double frameDifference = (FRAME_TIME - frameDelay) - frameTimer.GetTimePassed();
	auto min = min(tickDifference, frameDifference);
	if(min > 0)
		Sleep(min);
	//else
		//std::cout << "Halp!" << std::endl;
}