void Fire::Update()
{
	if (GetEnabled() && (millis() - GetLastUpdate()) > 1000 / GetSpeed())
	{
		if (GetLastUpdate() != 0)
			GetCanvas()->InvalidateRect(GetX(), GetY());

		SetY(GetY() + GetVDir());
		
		if ((GetY() + GetHeight() - 1) > GetCanvas()->GetScreenHeight() - 1)
		{
			SetEnabled(false);
			SetLastUpdate(0);
		}
		else if (GetY() < 0)
		{
			SetEnabled(false);
			SetLastUpdate(0);
		}

		if (GetEnabled())
		{
			/*
			Serial.print(GetX());
			Serial.print(",");
			Serial.print(GetY());
			*/
			GetCanvas()->Paint(GetX(), GetY());
			SetLastUpdate(millis());
		}
	}

}
void
MacroCellUrbanAreaChannelRealization::UpdateModels ()
{

#ifdef TEST_PROPAGATION_LOSS_MODEL
  std::cout << "\t --> UpdateModels" << std::endl;
#endif


  //update shadowing
  m_shadowing = 0;
  double probability = GetRandomVariable (101) / 100.0;
  for (int i = 0; i < 201; i++)
    {
	  if (probability <= shadowing_probability[i])
	    {
		  m_shadowing = shadowing_value[i];
          break;
	    }
    }

#ifdef TEST_PROPAGATION_LOSS_MODEL
  std::cout << "\t\t new shadowing" <<  m_shadowing << std::endl;
#endif

  UpdateFastFading ();

  SetLastUpdate ();
}
void Fire::Initialize(byte* screenPtr, byte screenWidth, byte screenHeight)
{
	// fire properties
	SetX(0);
	SetY(0);
	
	SetHDir(0);
	SetVDir(1);
	SetSpeed(8);
	SetLastUpdate(0);
	SetEnabled(false);
	
	Canvas *canvas = GetCanvas();
	canvas->SetWidth(1);
	canvas->SetHeight(1);
	canvas->SetImage(fire);
	canvas->SetScreenWidth(screenWidth);
	canvas->SetScreenHeight(screenHeight);
	canvas->SetScreen(screenPtr);

	/*
	if ((canvas->GetScreen()) != screenPtr)
	{
		Serial.println(" test 1 - pointers diferentes");
	}
	if (*(canvas->GetScreen()) != *screenPtr)
	{
		Serial.println(" test 2 - valores de pointers diferentes");
	}
	Serial.println("fim fire init");
	*/
}
Example #4
0
float UnixMetric::GetCPUUsageUnix(){
  uint32 lastupdate = GetLastUpdate();
  uint32 lastsecusage = GetLastSecUsage();
  uint32 lastusecusage = GetLastUSecUsage();
  float usage = 0.0f;
  uint32 secusage = 0;
  uint32 usecusage = 0;
  struct rusage susage;
  uint32 nocpus = GetCPUCount();
  uint32 unixtime = time( NULL );

  if(getrusage(RUSAGE_SELF, &susage) == 0){
    secusage = susage.ru_utime.tv_sec + susage.ru_stime.tv_sec;
    usecusage = susage.ru_utime.tv_usec + susage.ru_stime.tv_usec;

    if(usecusage / 1000000 >= 1){
      secusage = secusage + (usecusage / 1000000);
      usecusage = usecusage - ( usecusage / 1000000 ) * 1000000;
    }
  }

     uint32 difft = (unixtime - lastupdate);

     if(difft != 0){
          // when we sample the cpu usage below 10 minutes we can be more precise, since the usecs will be representable even in 32bit values!
          if( difft <= 3600 ){
            usage = ( static_cast<float>( (secusage * 1000000 + usecusage) - (lastsecusage * 1000000 + lastusecusage) ) / ( difft * 1000000 ) ); 

          }else
            usage = ( static_cast<float>( secusage - lastsecusage) / difft);
     }else{
          // this case means we are polling the cpu usage data in realtime, which shouldn't ever happen, except on startup
          // since we can't divide by 0
          // We don't care about the cpu usage of the starting time anyway so we can just report 0%
          usage = 0.0f;
     }

  usage *= 100.0f;

  /* I will leave this here for now, so next time if I tinker I don't have to rewrite it heh
  printf("secusage: %lu\n", secusage);
  printf("lastsecusage: %lu\n", lastsecusage);
  printf("usecusage: %lu\n", usecusage);
  printf("lastusecusage: %lu\n", lastusecusage);
  printf("difft: %lu\n", difft);
  printf("usec difference: %lu\n", ( (secusage * 1000000 + usecusage) - (lastsecusage * 1000000 + lastusecusage) ) );
  printf("usage%%: %lf\n", usage);
  */

  SetLastUpdate( unixtime );
  SetLastSecUsage( secusage );
  SetLastUSecUsage( usecusage );

  return usage / nocpus;
}
Example #5
0
void VideoVisualSpectrum::Draw(const QRect &area, MythPainter *painter,
                               QPaintDevice* device)
{
    if (m_disabled)
        return;

    mutex()->lock();
    VisualNode *node = GetNode();

    if (area.isEmpty() || !painter)
    {
        mutex()->unlock();
        return;
    }

    if (!Initialise(area))
    {
        mutex()->unlock();
        return;
    }

    uint i = 0;
    if (node)
    {
        i = node->length;
        fast_real_set_from_short(lin, node->left, node->length);
        if (node->right)
            fast_real_set_from_short(rin, node->right, node->length);
    }
    mutex()->unlock();

    fast_reals_set(lin + i, rin + i, 0, FFTW_N - i);
    fftw_execute(lplan);
    fftw_execute(rplan);

    double magL, magR, tmp;
    double falloff = (((double)SetLastUpdate()) / 40.0) * m_falloff;
    if (falloff < 0.0)
        falloff = 0.0;
    if (falloff > 2048.0)
        falloff = 2048.0;
    for (int l = 0, r = m_scale.range(); l < m_scale.range(); l++, r++)
    {
        int index = m_scale[l];
        magL = (log(sq(real(lout[index])) + sq(real(lout[FFTW_N - index]))) - 22.0) *
               m_scaleFactor;
        magR = (log(sq(real(rout[index])) + sq(real(rout[FFTW_N - index]))) - 22.0) *
               m_scaleFactor;

        if (magL > m_range)
            magL = 1.0;

        if (magL < m_magnitudes[l])
        {
            tmp = m_magnitudes[l] - falloff;
            if (tmp < magL)
                tmp = magL;
            magL = tmp;
        }

        if (magL < 1.0)
            magL = 1.0;

        if (magR > m_range)
            magR = 1.0;

        if (magR < m_magnitudes[r])
        {
            tmp = m_magnitudes[r] - falloff;
            if (tmp < magR)
                tmp = magR;
            magR = tmp;
        }

        if (magR < 1.0)
            magR = 1.0;

        m_magnitudes[l] = magL;
        m_magnitudes[r] = magR;
    }

    DrawPriv(painter, device);
}
Example #6
0
void LoanAssumption::SetMezzLastUpdate(const QDate& a)
{
    SetLastUpdate(Mezz, a);
}
Example #7
0
void LoanAssumption::SetSeniorLastUpdate(const QDate& a)
{
    SetLastUpdate(Senior, a);
}
Example #8
0
void
RadioBearer::ResetTransmittedBytes (void)
{
  m_transmittedBytes = 0;
  SetLastUpdate ();
}