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 RadioBearer::UpdateAverageTransmissionRate () { /* * Update Transmission Data Rate with * a Moving Average * R'(t+1) = (0.8 * R'(t)) + (0.2 * r(t)) */ double rate = (GetTransmittedBytes () * 8)/(Simulator::Init()->Now() - GetLastUpdate()); double beta = 0.2; m_averageTransmissionRate = ((1 - beta) * m_averageTransmissionRate) + (beta * rate); if (m_averageTransmissionRate < 1) { m_averageTransmissionRate = 1; } /* #ifdef SCHEDULER_DEBUG std::cout << "UPDATE AVG RATE, bearer " << GetApplication ()->GetApplicationID () << "\n\t tx byte " << GetTransmittedBytes () << "\n\t interval " << Simulator::Init()->Now() - GetLastUpdate() << "\n\t old rate " << m_averageTransmissionRate << "\n\t new rate " << rate << "\n\t new estimated rate " << m_averageTransmissionRate << std::endl; #endif */ ResetTransmittedBytes(); }
double RadioBearer::GetNowTransmissionRate () //new added~ { double rate = (GetTransmittedBytes () * 8)/(Simulator::Init()->Now() - GetLastUpdate()); return rate; }
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; }
std::vector<double> WinnerDownlinkChannelRealization::GetLoss () { #ifdef TEST_PROPAGATION_LOSS_MODEL std::cout << "\t --> compute loss between " << GetSourceNode ()->GetIDNetworkNode () << " and " << GetDestinationNode ()->GetIDNetworkNode () << std::endl; #endif if (NeedForUpdate ()) { UpdateModels (); } std::vector<double> loss; int now_ms = Simulator::Init()->Now () * 1000; int lastUpdate_ms = GetLastUpdate () * 1000; int index = now_ms - lastUpdate_ms; int nbOfSubChannels = GetSourceNode ()->GetPhy ()->GetBandwidthManager ()->GetDlSubChannels ().size (); for (int i = 0; i < nbOfSubChannels; i++) { //ATTENZIONE double l = GetFastFading ()->at (i).at (index) - GetPathLoss () - GetPenetrationLoss () - GetShadowing (); double l = - GetPathLoss (); loss.push_back (l); #ifdef TEST_PROPAGATION_LOSS_MODEL std::cout << "\t\t mlp = " << GetFastFading ()->at (i).at (index) << " pl = " << GetPathLoss () << " pnl = " << GetPenetrationLoss() << " sh = " << GetShadowing() << " LOSS = " << l << std::endl; #endif } return loss; }
const QDate& LoanAssumption::GetMezzLastUpdate() const { return GetLastUpdate(Mezz); }
const QDate& LoanAssumption::GetSeniorLastUpdate() const { return GetLastUpdate(Senior); }