// newTime = millliseconds since game clock start (which was assumed to be midnight)
void TimeManager::SetTime ( DWORD newTime )
{
	ShiAssert( IsReady() );

	// We're in trouble if the clock rolls over (approximatly 49 days after start)
//	ShiAssert(newTime >= lastUpdateTime);

	// Update all our measures of time
	deltaTime = newTime - currentTime;
	currentTime = newTime;
	DWORD day = currentTime / MSEC_PER_DAY;
	timeOfDay = currentTime - day * MSEC_PER_DAY;
	today = day + startDay;
	// TODO:  Deal with leap years???
	if (today >= 365) {
		year += 1;
		today = 0;
	}
	
	// Quit now unless enough time has passed to make it worth while
	// (for now we're set for 60 seconds)
	if (newTime - lastUpdateTime < CALLBACK_TIME_STEP) {
		return;
	}

	// Decide how many steps to take (in case we had a large time step)
	int steps = (newTime - lastUpdateTime) / CALLBACK_TIME_STEP;
	if (steps >= MAX_TOD_CALLBACKS) {
		// Start back at the first callback to make sure things happen in order
		nextCallToMake = 0;
		steps = MAX_TOD_CALLBACKS;
	}
	
	// Note the new time
	lastUpdateTime = newTime;

	// Make the callbacks
	while (steps--) {
		// Make the callback if we have one in this slot
		if (CBlist[nextCallToMake].fn) {
			CBlist[nextCallToMake].fn( CBlist[nextCallToMake].self ); 
		}

		// Advance to the next slot for next time
		nextCallToMake++;
		if (nextCallToMake == MAX_TOD_CALLBACKS) {
			nextCallToMake = 0;
		}
	}
}
Beispiel #2
0
void CProgressThreadDlg::SetTimeLabel()
{
  if (!IsReady()) {
    return;
  }

  CWnd* pWnd = GetDlgItem(IDC_ELAPSED_TIME);
  if (pWnd)
  {
//    ASSERT(pWnd);
    CTimeSpan ts = CTime::GetCurrentTime() - m_timeStart;
    CString sText = ts.Format( "Time elapsed   %H:%M:%S" );
    pWnd->SetWindowText(sText);
  }
}
// This call is used to force a lighting reset (as when switch to/from NVG mode)
void TimeManager::Refresh( void )
{
	ShiAssert( IsReady() );

	for ( int i=0; i<MAX_TOD_CALLBACKS; i++ ) {
		// Make the callback if we have one in this slot
		if (CBlist[i].fn) {
			CBlist[i].fn( CBlist[i].self ); 
		}
	}

	// Reset our callback control variables
	nextCallToMake = 0;
	lastUpdateTime = currentTime;
}
Beispiel #4
0
	SHMemReturnValue::RetValue	SHMemPipe::Write(void* pData, DWORD bytes)
	{

		if(IsReady() == false)
		{

			return SHMemReturnValue::ret_not_ready;


		}
		

		return m_pWriteChannel->Write(pData, bytes);

	}
Beispiel #5
0
BOOL CSSLSession::WriteSendChannel(const BYTE* pData, int iLength)
{
	ASSERT(IsReady());
	ASSERT(pData && iLength > 0);

	BOOL isOK = TRUE;
	int bytes = SSL_write(m_ssl, pData, iLength);

	if(bytes > 0)
		ASSERT(bytes == iLength);
	else if(IsFatalError(bytes))
		isOK = FALSE;

	return isOK;
}
// Reliquish our exclusive pointer to the memory associated with our back buffer
void ImageBuffer::Unlock()
{
	ShiAssert(IsReady());

	if(m_bBitsLocked)
	{
		HRESULT hr = m_pDDSBack->Unlock(NULL);
		ShiAssert(SUCCEEDED(hr));
		m_bBitsLocked = false;
	}

#ifdef _IMAGEBUFFER_PROTECT_SURF_LOCK
	LeaveCriticalSection(&m_cs);
#endif
}
Beispiel #7
0
MTentry *
MTcursor::Next ()
{
	while (!IsReady()) {
		if (queue.IsEmpty() && results.IsEmpty()) {
			return NULL;
		}
		FetchNode ();
	}
	if (!results.IsEmpty()) {
		return results.RemoveFirst ();
	} else {
		return NULL;
	}
}
void CommandQueue::Create( ID3D12Device* pDevice )
{
	ASSERT( pDevice != nullptr );
	ASSERT( !IsReady() );
	ASSERT( m_AllocatorPool.Size() == 0 );

	HRESULT hr;

	D3D12_COMMAND_QUEUE_DESC QueueDesc = {};
	QueueDesc.Type = m_Type;
	QueueDesc.NodeMask = 1;
	V( pDevice->CreateCommandQueue( &QueueDesc, IID_PPV_ARGS( &m_CommandQueue ) ) );
	m_CommandQueue->SetName( L"m_CommandQueue" );

	V( pDevice->CreateFence( 0, D3D12_FENCE_FLAG_NONE, IID_PPV_ARGS( &m_pFence ) ) );
	m_pFence->SetName( L"m_pFence" );
	m_pFence->Signal( (uint64_t)m_Type << 56 );

	m_FenceEventHandle = CreateEvent( nullptr, false, false, nullptr );
	ASSERT( m_FenceEventHandle != INVALID_HANDLE_VALUE );

	m_AllocatorPool.Create( pDevice );
	ASSERT( IsReady() );
}
void TimeManager::Cleanup()
{
	ShiAssert( IsReady() );

#ifdef _DEBUG	
	for (nextCallToMake = 0; nextCallToMake < MAX_TOD_CALLBACKS; nextCallToMake++) {
		if ( CBlist[nextCallToMake].fn != NULL ) {
			ShiWarning( "TimeManager dieing with callbacks still registered!" );
			break;
		}
	}
#endif

	delete[] CBlist;
	CBlist = NULL;
}
Beispiel #10
0
void CProgressThreadDlg::SetProgressStep(int nStep)
{

  if (!IsReady()) {
    return;
  }

  if (nStep > m_nSteps) // could possibly happen with dynamic TS
    nStep = m_nSteps;

  // update only in the case of change(any) - it would be slow otherwise
  if (nStep > m_nStep) {
    m_ctrlProgress.SetPos(nStep);
    m_nStep = nStep;
  }
}
Beispiel #11
0
	//TODO: Сейчас метод принимает только текстуры с ОДНИМ каналом
	void Texture2D::LoadFromMemory(unsigned char* data, unsigned int w, unsigned int h)	//С разными форматами надо подрочить
	{
		if (texId != 0)
			return;
		glGenBuffers(1, &texId);
		glBindTexture(GL_TEXTURE_2D, texId);
		glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_ALPHA, GL_UNSIGNED_BYTE, data);
		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
		width = w;
		height = h;

		IsReady(true);
	}
Beispiel #12
0
void MeshBase::Update()
{
	// Periodic sends
	if (millis() - last_broadcast_time > PEER_DISCOVERY_TIME)
	{
    		if (!IsReady())
			ChooseAddress();
		SendPeerDiscovery();
	}

	// Recieve
	uint8_t pipe_num;
	if (radio.available(&pipe_num))
	{
		bool done = false;
		do {
			uint8_t len = radio.getDynamicPayloadSize();
			uint8_t buff[40];
			done = radio.read(buff, min(len, sizeof(buff)));
			if (pipe_num == 0)
			{
				HandleMessage(0, buff, len);
			} else if (pipe_num == 1) {
				HandlePeerDiscovery(buff, len);
			}
		} while (!done);
	}
	
	// Update peers
	if (millis() - last_peer_check_time > PEER_CHECK_TIME)
	{
		LinkedList<Peer>::Node* current = peers.first;
		while(current != NULL)
		{
			current->item->time += 1;
			if (current->item->time >= PEER_TIMEOUT)
			{
				Serial.print("Lost Peer: ");
				Serial.println(current->item->address, DEC);
				current = peers.Remove(current);
			} else {
				current = current->next;
			}
		}
		last_peer_check_time = millis();
	}
}
Beispiel #13
0
bool Weapon::Shoot()
{
  MSG_DEBUG("weapon.shoot", "Enough ammo ? %d", EnoughAmmo());
  MSG_DEBUG("weapon.shoot", "Enough ammo unit ? %d", EnoughAmmoUnit());
  MSG_DEBUG("weapon.shoot", "Use unit on 1st shoot ? %d", use_unit_on_first_shoot);

  if (!IsReady())
    return false;

  MSG_DEBUG("weapon.shoot", "Enough ammo");

  #ifdef DEBUG
  Point2i hand;
  ActiveCharacter().GetHandPosition(hand);
  MSG_DEBUG("weapon.shoot", "%s Shooting at position:%d,%d (hand: %d,%d)",
            ActiveCharacter().GetName().c_str(),
            ActiveCharacter().GetX(),
            ActiveCharacter().GetY(),
            hand.GetX(),
            hand.GetY());
  ActiveCharacter().body->DebugState();
  #endif
  if (!p_Shoot()) {
    MSG_DEBUG("weapon.shoot", "shoot has failed!!");
    return false;
  }
  m_last_fire_time = Time::GetInstance()->Read();

  MSG_DEBUG("weapon.shoot", "shoot!");

  // Is this the first shoot for this ammo use ?
  if (ActiveTeam().ReadNbUnits() == m_initial_nb_unit_per_ammo) {
    UseAmmo();
  }

  if (use_unit_on_first_shoot){
    UseAmmoUnit();
  }

  if (max_strength.IsNotZero())
    ActiveCharacter().previous_strength = m_strength;

  Game::GetInstance()->SetCharacterChosen(true);

  return true;
}
BOOL Profile::GetString ( char *ItemName, char *Item, int MaxSize ) {

   if ( !IsReady() ) 
      return ( FALSE ) ;

   #ifdef __OS2__

      ULONG TrueSize ;
      if ( !PrfQueryProfileSize ( Handle, PSZ(Name), PSZ(ItemName), &TrueSize ) ) 
         return ( FALSE ) ;

      ULONG HowBig = min ( TrueSize+1, MaxSize ) ;
      if ( !PrfQueryProfileData ( Handle, PSZ(Name), PSZ(ItemName), Item, &HowBig ) ) {
         char Message [512] ;
         Log ( "Profile::GetString: Could not get INI item.  App %s, Item %s, TrueSize %i, MaxSize %i.  %s", Name, ItemName, TrueSize, MaxSize, InterpretWinError(0,Message) ) ;
         return ( FALSE ) ;
      } /* endif */

      Item[HowBig] = 0 ;

   #else // __NT__

      char *Buffer = new char [MaxSize+1] ;
      int Returned ( 0 ) ;
      if ( ProfileName[0] ) {
         Returned = GetPrivateProfileString ( Name, ItemName, "", Buffer, MaxSize+1, ProfileName ) ;
      } else {
         Returned = GetProfileString ( Name, ItemName, "", Buffer, MaxSize+1 ) ;
      } /* endif */

      if ( Returned >= MaxSize ) {
         delete [] Buffer ;
         Log ( "Profile::GetString: Could not get INI item.  App %s, Item %s.  Too large.", Name, ItemName ) ;
         return ( FALSE ) ;
      } /* endif */

      strcpy ( Item, Buffer ) ;

      delete [] Buffer ;

   #endif // __OS2__ vs __NT__

   return ( TRUE ) ;

} /* endmethod */
// Remove a previously added callback from the list of those which are
// periodically called
void TimeManager::ReleaseTimeUpdateCB( void(*fn)(void*), void *self )
{
	ShiAssert( IsReady() );
	ShiAssert( fn );

	for (int i=0; i<MAX_TOD_CALLBACKS; i++) {
		if (CBlist[i].fn == fn) {
			if (CBlist[i].self == self) {
				CBlist[i].fn	= NULL;
				CBlist[i].self	= NULL;
				break;
			}
		}
	}

	// Squawk if someone tried to remove a callback that wasn't in the list
	ShiAssert( i<MAX_TOD_CALLBACKS );
}
	VML::Vector3 Vec3CubicSpline::Interpolate(float t) const
	{
		assert(IsReady());

		processTime(t);
		size_t segm = findSegment(t); 
		size_t n_ctrl = mKeyframes.size();

		const SKeyframeVec3& p0 = mKeyframes[segm];
		const SKeyframeVec3& p1 = mKeyframes[segm + 1];
		const VML::Vector3& t0 = mTangents[segm];
		const VML::Vector3& t1 = mTangents[segm+1];

		float u = (t - p0.time) / (p1.time - p0.time), u2 = u*u, u3 = u2*u;
		VML::Vector3 pos = p0.data*(2.0f*u3 - 3.0f*u2 + 1.0f) + p1.data*(-2.0f*u3 + 3.0f*u2) + t0*(u3 - 2.0f*u2 + u) + t1*(u3 - u2);

		return pos;
	}
bool cdxCDynamicControlsManager::SetMinMaxSize(const CSize & szMin, const CSize & szMax, bool bResizeIfNecessary)
{
	ASSERT(IsReady());			// DoInitWindow() not called ?

	if((szMax.cx && (szMin.cx > szMax.cx)) ||
		(szMax.cy && (szMin.cy > szMax.cy)))
	{
		return false;
	}

	m_szMin	=	szMin;
	m_szMax	=	szMax;

	if(bResizeIfNecessary)
		FixWindowSize();

	return true;
}
BOOL Profile::PutItem ( char *ItemName, void *Item, int Size ) {

   if ( !IsReady() ) 
      return ( FALSE ) ;

   #ifdef __OS2__

      if ( !PrfWriteProfileData ( Handle, PSZ(Name), PSZ(ItemName), Item, Size ) ) {
         char Message [512] ;
         Log ( "Profile::PutItem: Could not put INI item.  App %s, Item %s, size %i.  %s", Name, ItemName, Size, InterpretWinError(0,Message) ) ;
         return ( FALSE ) ;
      } /* endif */

   #else // __NT__

      char *Buffer = new char [Size*2+1] ;
      if ( Buffer ) {
         for ( int i=0; i<Size; i++ ) 
            sprintf ( &Buffer[i*2], "%02X", ((unsigned char*)Item)[i] ) ;
         if ( ProfileName[0] ) {
            if ( !WritePrivateProfileString ( Name, ItemName, Buffer, ProfileName ) ) {
               char Message [512] ;
               Log ( "Profile::PutString: Could not put INI item.  App %s, Item %s, Value %s.  %s", Name, ItemName, Buffer, InterpretWinError(0,Message) ) ;
               return ( FALSE ) ;
            } /* endif */
         } else {
            if ( !WriteProfileString ( Name, ItemName, Buffer ) ) {
               char Message [512] ;
               Log ( "Profile::PutString: Could not put INI item.  App %s, Item %s, Value %s.  %s", Name, ItemName, Buffer, InterpretWinError(0,Message) ) ;
               return ( FALSE ) ;
            } /* endif */
         } /* endif */
         delete [] Buffer ;
      } else {
         Log ( "Profile::PutItem: Could not put INI item.  App %s, Item %s, size %i.  Insufficient memory.", Name, ItemName, Size ) ;
         return ( FALSE ) ;
      } /* endif */

   #endif // __OS2__ vs __NT__

   return ( TRUE ) ;

} /* endmethod */
void SProfilerThreadView::Tick( const FGeometry& AllottedGeometry, const double InCurrentTime, const float InDeltaTime )
{
	if( AllottedGeometry.Size.X > 0.0f )
	{
		if( ThisGeometry.Size.X != AllottedGeometry.Size.X )
		{
			// Refresh.
			ThisGeometry = AllottedGeometry;
			bUpdateData = true;
		}

		if( ShouldUpdateData() && IsReady() )
		{
			UpdateInternalConstants();
			ProcessData();
			bUpdateData = false;
		}
	}
}
bool FGatherTextSCC::RevertFile( const FString& InFile, FString& OutError )
{
	if( InFile.IsEmpty() )
	{
		OutError = TEXT("Could not revert file.");
		return false;
	}

	FString SCCError;
	if( !IsReady( SCCError ) )
	{
		OutError = SCCError;
		return false;
	}

	FString AbsoluteFilename = FPaths::ConvertRelativePathToFull(InFile);
	ISourceControlProvider& SourceControlProvider = ISourceControlModule::Get().GetProvider();
	FSourceControlStatePtr SourceControlState = SourceControlProvider.GetState( AbsoluteFilename, EStateCacheUsage::ForceUpdate );

	bool bSuccessfullyReverted = false;

	TArray<FString> FilesToRevert;
	FilesToRevert.Add(AbsoluteFilename);

	if( SourceControlState.IsValid() && !SourceControlState->IsCheckedOut() && !SourceControlState->IsAdded() )
	{
		bSuccessfullyReverted = true;
	}
	else
	{
		bSuccessfullyReverted = (SourceControlProvider.Execute(ISourceControlOperation::Create<FRevert>(), FilesToRevert) == ECommandResult::Succeeded);
	}
	
	if(!bSuccessfullyReverted)
	{
		OutError = TEXT("Could not revert file.");
	}
	else
	{
		CheckedOutFiles.Remove( AbsoluteFilename );
	}
	return bSuccessfullyReverted;
}
Beispiel #21
0
void Console::AddLine(std::string line)
{
	EnterCriticalSection(&Vars.cConsoleSection);

	if(!IsReady())
		Initialize();
	// add the new line to the list
	lines.push_back(line);

	// update all of the screenhooks to use the new lines
	std::deque<std::string>::reverse_iterator it = lines.rbegin();
	for(int i = lineCount-1; i >= 0 && it != lines.rend(); i--, it++)
		lineBuffers[i]->SetText(it->c_str());

	// clear out old lines
	while(lines.size() > lineCount)
		lines.pop_front();

	LeaveCriticalSection(&Vars.cConsoleSection);
}
// Add a callback function to the list of those to be periodically called
// as time advances
void TimeManager::RegisterTimeUpdateCB( void(*fn)(void*), void *self )
{
	ShiAssert( IsReady() );
	ShiAssert( fn );

	if (CBlist)
	{
		for (int i=0; i<MAX_TOD_CALLBACKS; i++)
		{
			if (CBlist[i].fn == NULL)
			{
				CBlist[i].self	= self;
				CBlist[i].fn	= fn;
				break;
			}
		}
		// If we fell out the bottom, we ran out of room.
		ShiAssert( i<MAX_TOD_CALLBACKS );
	}
}
void DriftModel::Record(double next_angle, double angle, double previous_angle, double velocity, double radius, double direction) {
  // If next_angle is so small, we probably just started and we are not
  // drifting any more. Doesn't make sense to record such entries.
  if (fabs(next_angle) < 1e-5) return;

  if (direction != 0) {
    raw_points_turn_.push_back({angle, previous_angle, velocity, radius, direction, next_angle});
  } else {
    raw_points_straight_.push_back({angle, previous_angle, velocity, radius, direction, next_angle});
  }

  if (!very_ready_) {
    Train();
  }

  double predicted = 0;
  if (IsReady()) {
    predicted = Predict(angle, previous_angle, velocity, radius, direction);
    error_tracker_.Add(predicted, next_angle);
  }
}
Beispiel #24
0
bool CUPnPImplMiniLib::CheckAndRefresh()
{
	// on a CheckAndRefresh we don't do any new time consuming discovery tries, we expect to find the same router like the first time
	// and of course we also don't delete old ports (this was done on Discovery) but only check that our current mappings still exist
	// and refresh them if not
	if (m_bAbortDiscovery || !m_bSucceededOnce|| !IsReady() || m_pURLs == NULL || m_pIGDData == NULL 
		|| m_pURLs->controlURL == NULL || m_nTCPPort == 0)
	{
		DebugLog(_T("Not refreshing UPnP ports because they don't seem to be forwarded in the first place"));
		return false;
	}
	else
		DebugLog(_T("Checking and refreshing UPnP ports"));

	m_bCheckAndRefresh = true;
	CStartDiscoveryThread* pStartDiscoveryThread = (CStartDiscoveryThread*) AfxBeginThread(RUNTIME_CLASS(CStartDiscoveryThread), THREAD_PRIORITY_NORMAL,0, CREATE_SUSPENDED);
	m_hThreadHandle = pStartDiscoveryThread->m_hThread;
	pStartDiscoveryThread->SetValues(this);
	pStartDiscoveryThread->ResumeThread();
	return true;
}
// Fix in memory and return and pointer to the memory associated with our back buffer
void *ImageBuffer::Lock(bool bLockMutexOnly, bool bWriteOnly)
{
#ifdef _IMAGEBUFFER_PROTECT_SURF_LOCK
	EnterCriticalSection(&m_cs);
	if(bLockMutexOnly)
		return NULL;
#endif

	ShiAssert(IsReady());

	HRESULT hr;

	DDSURFACEDESC2 ddsd;
	ZeroMemory(&ddsd, sizeof(ddsd));
	ddsd.dwSize = sizeof(ddsd);

//	DWORD dwFlags = DDLOCK_NOSYSLOCK | DDLOCK_WAIT | DDLOCK_SURFACEMEMORYPTR;
	DWORD dwFlags = DDLOCK_WAIT | DDLOCK_SURFACEMEMORYPTR;
	if(bWriteOnly) dwFlags |= DDLOCK_WRITEONLY;

	int nRetries = 1;

	Retry:
	hr = m_pDDSBack->Lock(NULL, &ddsd, dwFlags, NULL);
	m_bBitsLocked = SUCCEEDED(hr);

	if(FAILED(hr))
	{
		MonoPrint("ImageBuffer::Lock - Lock failed with 0x%X\n", hr);

		if(hr == DDERR_SURFACELOST && nRetries)
		{
			RestoreAll();
			nRetries--;
			goto Retry;
		}
	}

	return ddsd.lpSurface;
}
bool FGatherTextSCC::CheckinFiles( const FString& InChangeDescription, FString& OutError )
{
	if( CheckedOutFiles.Num() == 0 )
	{
		return true;
	}

	FString SCCError;
	if( !IsReady( SCCError ) )
	{
		OutError = SCCError;
		return false;
	}

	ISourceControlProvider& SourceControlProvider = ISourceControlModule::Get().GetProvider();
	SourceControlHelpers::RevertUnchangedFiles(SourceControlProvider, CheckedOutFiles);

	// remove unchanged files
	for (int32 VerifyIndex = CheckedOutFiles.Num()-1; VerifyIndex >= 0; --VerifyIndex)
	{
		FSourceControlStatePtr SourceControlState = SourceControlProvider.GetState( CheckedOutFiles[VerifyIndex], EStateCacheUsage::ForceUpdate );
		if (SourceControlState.IsValid() && !SourceControlState->IsCheckedOut() && !SourceControlState->IsAdded())
		{
			CheckedOutFiles.RemoveAt(VerifyIndex);
		}
	}

	if (CheckedOutFiles.Num() > 0)
	{
		TSharedRef<FCheckIn, ESPMode::ThreadSafe> CheckInOperation = ISourceControlOperation::Create<FCheckIn>();
		CheckInOperation->SetDescription(InChangeDescription);
		if (!SourceControlProvider.Execute( CheckInOperation, CheckedOutFiles ))
		{
			OutError = TEXT("The checked out localization files could not be checked in.");
			return false;
		}
		CheckedOutFiles.Empty();
	}
	return true;
}
Beispiel #27
0
    void GUI::Render(Window* window, std::function<void(void)> callback)
    {
        if (!window || !IsReady())
            return;
        Setup();
        ImGui::SetInternalState(state_);
        window_ = window;
        window->BeginImguiRender();
        ImGuiIO& io = ImGui::GetIO();
        auto width = (float)window->GetWidth();
        auto height = (float)window->GetHeight();

        if (area_ != Rect(0))
            io.DisplaySize = ImVec2{ Clamp(area_.z, 0.f, width), Clamp(area_.w, 0.f, height) };
        else
            io.DisplaySize = ImVec2{ width, height };

        io.DeltaTime = Engine::GetPtr()->GetDeltaTime();
        ImGui::NewFrame();
        callback();
        ImGui::Render();
    }
Beispiel #28
0
void Shooter::Log()
{
#if 0
    static int logCount = 0;

    if (IsRunning()) {
	if (++logCount >= 20) {
	    SmartDashboard::Log(m_speed, "set speed");
	    SmartDashboard::Log(speed_bottom, "b set");
	    SmartDashboard::Log(pid_bottom.GetInput(), "b spd");
	    SmartDashboard::Log(pid_bottom.GetError(), "b err");
	    SmartDashboard::Log(speed_top, "t set");
	    SmartDashboard::Log(pid_top.GetInput(), "t spd");
	    SmartDashboard::Log(pid_top.GetError(), "t err");
	    SmartDashboard::Log(IsReady(), "shooter");
	    logCount = 0;
	}
    } else {
	logCount = 0;
    }
#endif

    DriverStationLCD *lcd = DriverStationLCD::GetInstance();
    if (IsRunning()) {
	lcd->PrintfLine(DriverStationLCD::kUser_Line3,
	    "t %6.0f %6.0f",
	    speed_top, pid_top.GetInput());
	lcd->PrintfLine(DriverStationLCD::kUser_Line4,
	    "b %6.0f %6.0f",
	    speed_bottom, pid_bottom.GetInput());
    } else {
	lcd->PrintfLine(DriverStationLCD::kUser_Line3,
	    "t stopped");
	lcd->PrintfLine(DriverStationLCD::kUser_Line4,
	    "b stopped");
    }
    lcd->UpdateLCD();
}
Beispiel #29
0
void
CacheFileChunk::WaitForUpdate(CacheFileChunkListener *aCallback)
{
  mFile->AssertOwnsLock();

  LOG(("CacheFileChunk::WaitForUpdate() [this=%p, listener=%p]",
       this, aCallback));

  MOZ_ASSERT(mFile->mOutput);
  MOZ_ASSERT(IsReady());

#ifdef DEBUG
  for (uint32_t i = 0 ; i < mUpdateListeners.Length() ; i++) {
    MOZ_ASSERT(mUpdateListeners[i]->mCallback != aCallback);
  }
#endif

  ChunkListenerItem *item = new ChunkListenerItem();
  item->mTarget = NS_GetCurrentThread();
  item->mCallback = aCallback;

  mUpdateListeners.AppendElement(item);
}
Beispiel #30
0
ERRCODE CRenderer::Startup(bool startNewThread)
{
	ERRCODE er = ERR_OK;
	separateThread = startNewThread;
	if(startNewThread)
	{
		if(!(hThread = (HANDLE)_beginthreadex(NULL, 1024*10, RendererStartup, (void*)this, 0, 0)))
			er = ERR_NEWTHREADFAIL;
	}
	else
	{
		er = this->Initialize();
	}

	running = true;

	while(!IsReady())
		Sleep(10);

	

	return er;
}