void PowerStatus::run()
{
    for(;;)
    {
        bool ok = false;
        unsigned int percent, charging, running;
        bool isRunning, isCharging;

        percent    = getStat(PowerStatus::PERCENT).toInt(&ok);
        charging   = getStat(PowerStatus::CHARGING).toInt(&ok);
        isCharging = ok;
        running    = getStat(PowerStatus::RUNNING).toInt(&ok);
        isRunning  = ok;

        {
            QMutexLocker locker(&m_mutex);
            m_percent    = percent;
            m_charging   = charging;
            m_running    = running;
            m_isCharging = isCharging;
            m_isRunning  = isRunning;
        }

        if(m_percent <= m_treshold && !m_isCharging && m_listener)
        {
            emit lowBatteryLevel();
        }
        emit newBatterLevel();

        msleep( 10 * 1000);
    }
}
Example #2
0
void LLViewerStats::updateFrameStats(const F64 time_diff)
{
	if (mPacketsLostPercentStat.getCurrent() > 5.0)
	{
		incStat(LLViewerStats::ST_LOSS_05_SECONDS, time_diff);
	}
	
	if (mSimFPS.getCurrent() < 20.f && mSimFPS.getCurrent() > 0.f)
	{
		incStat(LLViewerStats::ST_SIM_FPS_20_SECONDS, time_diff);
	}
	
	if (mSimPhysicsFPS.getCurrent() < 20.f && mSimPhysicsFPS.getCurrent() > 0.f)
	{
		incStat(LLViewerStats::ST_PHYS_FPS_20_SECONDS, time_diff);
	}
		
	if (time_diff >= 0.5)
	{
		incStat(LLViewerStats::ST_FPS_2_SECONDS, time_diff);
	}
	if (time_diff >= 0.125)
	{
		incStat(LLViewerStats::ST_FPS_8_SECONDS, time_diff);
	}
	if (time_diff >= 0.1)
	{
		incStat(LLViewerStats::ST_FPS_10_SECONDS, time_diff);
	}

	if (gFrameCount && mLastTimeDiff > 0.0)
	{
		// new "stutter" meter
		setStat(LLViewerStats::ST_FPS_DROP_50_RATIO,
				(getStat(LLViewerStats::ST_FPS_DROP_50_RATIO) * (F64)(gFrameCount - 1) + 
				 (time_diff >= 2.0 * mLastTimeDiff ? 1.0 : 0.0)) / gFrameCount);
			

		// old stats that were never really used
		setStat(LLViewerStats::ST_FRAMETIME_JITTER,
				(getStat(LLViewerStats::ST_FRAMETIME_JITTER) * (gFrameCount - 1) + 
				 fabs(mLastTimeDiff - time_diff) / mLastTimeDiff) / gFrameCount);
			
		F32 average_frametime = gRenderStartTime.getElapsedTimeF32() / (F32)gFrameCount;
		setStat(LLViewerStats::ST_FRAMETIME_SLEW,
				(getStat(LLViewerStats::ST_FRAMETIME_SLEW) * (gFrameCount - 1) + 
				 fabs(average_frametime - time_diff) / average_frametime) / gFrameCount);

		F32 max_bandwidth = gViewerThrottle.getMaxBandwidth();
		F32 delta_bandwidth = gViewerThrottle.getCurrentBandwidth() - max_bandwidth;
		setStat(LLViewerStats::ST_DELTA_BANDWIDTH, delta_bandwidth / 1024.f);

		setStat(LLViewerStats::ST_MAX_BANDWIDTH, max_bandwidth / 1024.f);
		
	}
	
	mLastTimeDiff = time_diff;

}
Example #3
0
    float getKDR(qint32 gameid)
    {
        if(games>0)
        {
            QVector<qint32> K = getStat("K");
            QVector<qint32> D = getStat("D");

            return (float)K.at(gameid-1) / (float)D.at(gameid-1);
        }
        else
            return 0.f;
    }
Example #4
0
float CTown::getPoints()
{
	if (type == eTownType::TOWN_CITY)
	{
		return getStat("base_points")*(1 + getStat("upgrade")*0.08);
	}
	else
		if (type == eTownType::TOWN_VILLAGE)
			return getStat("base_points") / 4;
		else
			return  0;
}
Example #5
0
File: file.c Project: digsrc/fossil
/*
** Same as file_isdir(), but takes into account symlinks.
*/
int file_wd_isdir(const char *zFilename){
  int rc;

  if( zFilename ){
    char *zFN = mprintf("%s", zFilename);
    file_simplify_name(zFN, -1, 0);
    rc = getStat(zFN, 1);
    free(zFN);
  }else{
    rc = getStat(0, 1);
  }
  return rc ? 0 : (S_ISDIR(fileStat.st_mode) ? 1 : 2);
}
Example #6
0
bool CUser::ItemEquipAvailable(_ITEM_TABLE *pTable)
{
	return (pTable != NULL
		&& GetLevel() >= pTable->m_bReqLevel 
		&& GetLevel() <= pTable->m_bReqLevelMax
		&& (pTable->m_bRace == 0 || pTable->m_bRace == m_bRace)
		&& m_bRank >= pTable->m_bReqRank // this needs to be verified
		&& m_bTitle >= pTable->m_bReqTitle // this is unused
		&& getStat(STAT_STR) >= pTable->m_bReqStr 
		&& getStat(STAT_STA) >= pTable->m_bReqSta 
		&& getStat(STAT_DEX) >= pTable->m_bReqDex 
		&& getStat(STAT_INT) >= pTable->m_bReqIntel 
		&& getStat(STAT_CHA) >= pTable->m_bReqCha);
}
Example #7
0
void SpeedTrainingMode::startTimerToNextKey(int plusMSecs) {
    if (plusMSecs < 0)
        plusMSecs = 0;

    float avetime, delay;
    if (runningMode() != RUNNING)
        return;

    if (plusMSecs <= 0) {
        qDebug() << "stop here!";
        plusMSecs = QTime::currentTime().msecsTo(m_morse->sequenceTime());
    }
    if (m_lastTimes.count() > 3) {
        // don't let them get *too* far behind
        m_badCount++;
        QTimer::singleShot(1000, this, SLOT(startTimerToNextKey()));  // Try again in a second
        return;
    }
    avetime = getStat(m_lastKey)->getAverageTime();
    qDebug() << "avetime: " << avetime;
    if (avetime == -1) {
        avetime = 1000.0;
        qDebug() << "setting avetime to: " << avetime;
    }
    delay  = plusMSecs + (float(m_badCount + m_countWeight)/float(m_goodCount + m_countWeight)) * avetime * m_speedMultiplier;
    qDebug() << "delaying for: t=" << avetime << " + ex=" << plusMSecs << " = " << delay << " ms (good=" << m_goodCount << ", bad=" << m_badCount
             << ", wt=" << m_countWeight << ")";
    QTimer::singleShot(delay, this, SLOT(startNextSpeedKey()));
}
Example #8
0
Stat::Stat(QWidget *parent) :
    QDialog(parent)
{
    setupUi(this);
    getStat();
    connect(pushButton_2, SIGNAL(clicked()), this, SLOT(clearstat()));
}
void RtpPaddingGeneratorHandler::recalculatePaddingRate() {
  if (!isTimeToCalculateBitrate()) {
    return;
  }

  last_rate_calculation_time_ = clock_->now();

  int64_t total_bitrate = getStat("bitrateCalculated");
  int64_t padding_bitrate = stats_->getNode()["total"]["paddingBitrate"].value();
  int64_t media_bitrate = std::max(total_bitrate - padding_bitrate, int64_t(0));

  uint64_t target_bitrate = getTargetBitrate();

  int64_t target_padding_bitrate = target_bitrate - media_bitrate;
  // TODO(pedro): figure out a burst size that makes sense here
  bucket_.reset(std::max(target_padding_bitrate, int64_t(0)), kPaddingBurstSize);

  if (target_padding_bitrate <= 0) {
    number_of_full_padding_packets_ = 0;
    last_padding_packet_size_ = 0;
    return;
  }

  uint64_t marker_rate = marker_rate_.value(std::chrono::milliseconds(500));
  marker_rate = std::max(marker_rate, kMinMarkerRate);
  uint64_t bytes_per_marker = target_padding_bitrate / (marker_rate * 8);
  number_of_full_padding_packets_ = bytes_per_marker / (kMaxPaddingSize + rtp_header_length_);
  last_padding_packet_size_ = bytes_per_marker % (kMaxPaddingSize + rtp_header_length_) - rtp_header_length_;
}
Example #10
0
    float getKDA(qint32 gameid)
    {
        if(games>0)
        {
            if(gameid > games)
                return 0.f;

            QVector<qint32> K = getStat("K");
            QVector<qint32> D = getStat("D");
            QVector<qint32> A = getStat("A");

            return ((float)K.at(gameid-1) + (float)A.at(gameid-1)) / (float)D.at(gameid-1);
        }

        return 0.f;
    }
Example #11
0
frl::Bool copy( const frl::String &fileNameSrc, const frl::String &fileNameDst, frl::Bool overwrite )
{
	struct DescriptorManager
	{
		Descriptor fileSrc;
		Descriptor fileDst;
		DescriptorManager( void )
			:	fileSrc( InvalidDescriptor ),
				fileDst( InvalidDescriptor )
		{
		}

		~DescriptorManager( void )
		{
			close( fileSrc );
			close( fileDst );
		}
	}; // struct DescriptorManger


	if( ! isExist( fileNameSrc ) )
		return frl::False;

	if( isExist( fileNameDst ) && ( ! overwrite ) )
		return frl::False;

	Stat stat_;
	if( ! getStat( fileNameSrc, stat_ ) )
		return False;

	if( stat_.permissionMode & permDirectory )
		return False; // FIXME mrdir implement!

	DescriptorManager dm;
	dm.fileSrc = open( fileNameSrc, openReadOnly );
	if( dm.fileSrc == InvalidDescriptor )
		return frl::False;

	dm.fileDst = open( fileNameDst, openCreate | openTruncate | openWriteOnly, stat_.permissionMode );
	if( dm.fileDst == InvalidDescriptor )
		return frl::False;

	frl::UChar buffer[4096];
	RWCount readCount = InvalidRWCount;
	RWCount writeCount = InvalidRWCount;
	while( 1 )
	{
		readCount = read( dm.fileSrc, buffer, sizeof(buffer) );
		if( readCount < 0 )
			return frl::False;

		if( readCount == 0 )
			break;
		writeCount = write( dm.fileDst, buffer, readCount );
		if( writeCount < 0)
			return frl::False;
	}
	return frl::True;
}
Example #12
0
 foreach(QChar theLetter, m_trainingSequence) {
     m_progressBars[theLetter]->setRange(0,fastestWPM);
     m_progressBars[theLetter]->setGoalBarLevel(goalWPM);
     float aveTime = getStat(theLetter)->getAverageTime();
     if (aveTime < 0)
         m_progressBars[theLetter]->setValue(0);
     else
         m_progressBars[theLetter]->setValue(msToPauseWPM(aveTime / MULTFACTOR));
 }
QMap<QString, pokemonStruct> accessAllCaughtPokemon(QString trainerName)
{
    QMap<QString, pokemonStruct> data;
    QSqlQuery query(Dynamic);
    QString statement = "SELECT * FROM CaughtPokemon WHERE trainer='" + trainerName + "'";
    if( !query.exec(statement) )
    {
        qDebug() << query.lastError().databaseText();
        return data;
    }
    while( query.next() )
    {        
        pokemonStruct saved;
        saved.PID = query.record().field("PID").value().toInt();
        saved.attEV = query.record().field("AtEV").value().toInt();
        saved.CPID = query.record().field("CPID").value().toInt();
        saved.defEV = query.record().field("DefEV").value().toInt();
        saved.EXP = query.record().field("EXP").value().toInt();
        saved.HPEV = query.record().field("HPEV").value().toInt();
        saved.speedEV = query.record().field("speedEV").value().toInt();
        saved.HP = query.record().field("HP").value().toInt();
        saved.level = getLevel(saved.EXP);
        saved.name = getPokemonName(QString::number(saved.PID));
        saved.attack = getStat(saved.attEV, getBaseAtt(saved.name), saved.level);
        saved.defense = getStat(saved.defEV, getBaseDef(saved.name), saved.level);
        saved.speed = getStat(saved.speedEV, getBaseSpeed(saved.name), saved.level);
        saved.HP = getHP(saved.HPEV, getBaseHP(saved.name), saved.level);
        QString moves = query.record().field("Moves").value().toString();
        QStringList l = moves.split("|");
        for(int i = 0; i < l.size(); i++)
        {
            QStringList m = l[i].split(".");
            moveStruct move;
            move.name = m[0];
            move.pp = m[1].toInt();
            move.accuracy = getAccuracy(move.name);
            move.damage = getDamage(move.name);
            move.type = getMoveType(move.name);
            saved.moves.append(move);
        }
        data.insert(saved.name, saved);
    }
    return data;
}
Example #14
0
void SpeedTrainingMode::updateGraphs()
{
#ifndef SMALL_DEVICE
    int fastestWPM = MULTFACTOR * m_morse->currentWPMGoal();
    int goalWPM = MULTFACTOR * m_morse->currentWPMAccept();
    foreach(QChar theLetter, m_trainingSequence) {
        float aveTime = getStat(theLetter)->getAverageTime();
        if (aveTime > 0) {
            fastestWPM = qMax(msToPauseWPM(aveTime / MULTFACTOR), fastestWPM);
        }
    }
Example #15
0
File: file.c Project: digsrc/fossil
/*
** Return file permissions (normal, executable, or symlink):
**   - PERM_EXE on Unix if file is executable;
**   - PERM_LNK on Unix if file is symlink and allow-symlinks option is on;
**   - PERM_REG for all other cases (regular file, directory, fifo, etc).
*/
int file_wd_perm(const char *zFilename){
#if !defined(_WIN32)
  if( !getStat(zFilename, 1) ){
     if( S_ISREG(fileStat.st_mode) && ((S_IXUSR)&fileStat.st_mode)!=0 )
      return PERM_EXE;
    else if( g.allowSymlinks && S_ISLNK(fileStat.st_mode) )
      return PERM_LNK;
  }
#endif
  return PERM_REG;
}
Example #16
0
FileType getFileType(const char * filePath) {
	struct stat data = {0};
	getStat(filePath, &data);
	if (S_ISREG(data.st_mode)) {
		return FTFile;
	}
	else if (S_ISDIR(data.st_mode)) {
		return FTDir;
	}
	return FTNeither;
}
Example #17
0
void player::use(int index){
	//WEAPON,ARMOR,CONSUMABLE,ETC
	Item tmp = load::getItemData(getItemList()->at(index).getID());
	if(tmp.getItemType() == "WEAPON"){
		getStat()->addAll(0-getWeapon().getiAtk(),0-getWeapon().getiDef(),0-getWeapon().getiMaxHp());
		getItemList()->at(index) = load::getItemData(getWeapon().getID());
		if(getItemList()->at(index).getID() == 1)delItem(index);
		setWeapon(tmp.getID());
		getStat()->addAll(tmp.getiAtk(),tmp.getiDef(),tmp.getiMaxHp());
		cout << "\n\tEquipe "<<tmp.getName()<<endl;
	}else if(tmp.getItemType() == "ARMOR"){
		getStat()->addAll(0-getArmor().getiAtk(),0-getArmor().getiDef(),0-getArmor().getiMaxHp());
		getItemList()->at(index) = load::getItemData(getArmor().getID());
		if(getItemList()->at(index).getID() == 2)delItem(index);
		setArmor(tmp.getID());
		getStat()->addAll(tmp.getiAtk(),tmp.getiDef(),tmp.getiMaxHp());
		cout << "\n\tEquipe "<<tmp.getName()<<endl;
	}else if(tmp.getItemType() == "CONSUMABLE"){
		getStat()->addAll(tmp.getiAtk(),tmp.getiDef(),tmp.getiMaxHp());
		getStat()->addHp(tmp.getiHp());
		delItem(index);
		cout << "\tUse "<<tmp.getName()<<endl;
	}else{
		cout << "\n\tCannot use "<<tmp.getName()<<endl;
	}
	getch();
}
Example #18
0
    float getDF(qint32 gameid)
    {
        if(games>0)
        {
            qint8 KillMultipler = 2;
            qint8 DeathMultipler = -3;
            qint8 AssistMultipler = 1;

            float DF = 0.f;

            QVector<qint32> K = getStat("K");
            QVector<qint32> D = getStat("D");
            QVector<qint32> A = getStat("A");

            if(K.count() > 0)
                DF = K.at(gameid-1) * KillMultipler + D.at(gameid-1) * DeathMultipler + A.at(gameid-1) * AssistMultipler;

            return DF;
        }

        return 0.f;
    }
Example #19
0
void NetworkManagerHandler::processData(const boost::property_tree::ptree &requestPt, boost::property_tree::ptree &responsePt)
{
    if (_interfaceName == "wlan")
    {
        if (qpcrApp.wirelessManager()->interfaceName().empty())
        {
            setStatus(Poco::Net::HTTPResponse::HTTP_METHOD_NOT_ALLOWED);
            setErrorString("No WIFI interface is present");

            JsonHandler::processData(requestPt, responsePt);

            return;
        }

        _interfaceName = qpcrApp.wirelessManager()->interfaceName();
    }

    switch (_type)
    {
    case GetStat:
        getStat(responsePt);
        break;

    case SetSettings:
        setSettings(requestPt);
        JsonHandler::processData(requestPt, responsePt);
        break;

    case WifiScan:
        wifiScan(responsePt);
        break;

    case WifiConnect:
        wifiConnect();
        JsonHandler::processData(requestPt, responsePt);
        break;

    case WifiDisconnect:
        wifiDisconnect();
        JsonHandler::processData(requestPt, responsePt);
        break;

    default:
        setStatus(Poco::Net::HTTPResponse::HTTP_BAD_REQUEST);
        setErrorString("Unknown opeation type");

        JsonHandler::processData(requestPt, responsePt);

        break;
    }
}
Example #20
0
void CTown::draw(Canvas cv)
{
	Colorf c = getMap()->getCountry(owner)->getColor();
	c.a = 0.3;
	if (getStat("got_image") == 1)
		cv.fill_circle(getCenter().x, getCenter().y, position.get_width() / 2 + 2, c);

	if (position.contains(Point(::map->getMouseX(), ::map->getMouseY())) || selected)
		cv.fill_circle(getCenter().x, getCenter().y, position.get_width() / 2 + 6, Colorf(255, 255, 255, 50));


	if (getStat("got_image") == 1)
		GetImage("village").draw(cv, Rect(30 * (int)type, 0, Size(30, 30)), position);


	if (type == TOWN_CITY && selected)
	{
		int w = GetFont("small_font").get_text_size(cv, name).width / 2;
		cv.fill_rect(Rectf(Pointf(getCenter() + Point(-w - 2, 30 - 2 - 8)), Sizef(w * 2 + 4, 14)), Colorf(20, 127, 30, 60));
		GetFont("small_font").draw_text(cv, Point(getCenter() + Point(-w, 30)).x, Point(getCenter() + Point(-w, 30)).y, name, Colorf(185, 130, 14));
	}



	int x = position.left + 12;
	int y = position.top - 5;

	int sx = x + sin(smokeTimer) * 4 + 9;
	int sy = y + sin(smokeTimer) * 2;

	Quadf pos(Point(sx, sy), Point(sx + 20, y), Point(x + 20, y + 20), Point(x, y + 20));
	if (type != TOWN_ROAD)
		GetImage("village").draw(cv, Rectf((int)(smokeTimer / 0.02) % 1 * 20, 30, Sizef(20, 20)), pos);


}
Example #21
0
FightBox MWBotWin::getDuelResult() {
	FightBox res;
	int mylife;
	int enlife;
	QWebElement elm;
	res.enemy = getStat("div.fighter2","td.fighter2-cell");
	clickElement("i.icon.icon-forward");				// forward button
	mylife = frm->findFirstElement("span#fighter1-life").toPlainText().split("/").first().trimmed().toInt();
	enlife = frm->findFirstElement("span#fighter2-life").toPlainText().split("/").first().trimmed().toInt();
	res.result = (mylife > 0) ? 1 : ((enlife > 0) ? 0 : 2);		// duel result (0,1,2 = lose,win,draw)
	res.items = getDuelResultMain();
	elm = frm->findFirstElement("div.backlink div.button div.c");
	if (!elm.isNull()) {
		clickElement(elm);
	}
	res.items.append(getDuelResultExtra());
	return res;
}
Example #22
0
File: file.c Project: oopos/fossil
/*
** Return file permissions (normal, executable, or symlink):
**   - PERM_EXE if file is executable;
**   - PERM_LNK on Unix if file is symlink and allow-symlinks option is on;
**   - PERM_REG for all other cases (regular file, directory, fifo, etc).
*/
int file_wd_perm(const char *zFilename) {
    if( getStat(zFilename, 1) ) return PERM_REG;
#if defined(_WIN32)
#  if defined(__DMC__) || defined(_MSC_VER)
#    define S_IXUSR  _S_IEXEC
#  endif
    if( S_ISREG(fileStat.st_mode) && ((S_IXUSR)&fileStat.st_mode)!=0 )
        return PERM_EXE;
    else
        return PERM_REG;
#else
    if( S_ISREG(fileStat.st_mode) &&
            ((S_IXUSR|S_IXGRP|S_IXOTH)&fileStat.st_mode)!=0 )
        return PERM_EXE;
    else if( g.allowSymlinks && S_ISLNK(fileStat.st_mode) )
        return PERM_LNK;
    else
        return PERM_REG;
#endif
}
Example #23
0
bool UnitVideo::onRender(LPVOID world,FLOAT& x,FLOAT& y,FLOAT& z)
{
	if(isRenderFlag() && m_dataPtr && getStat() == MEDIA_PLAY)
	{
		m_critical.lock();
		if(m_initImage)
		{
			INT width = MediaSampler::getImageWidth();
			INT height = MediaSampler::getImageHeight();
			setSize(width,height);
			m_initImage = false;
		}

		INT width = MediaSampler::getImageWidth();
		INT height = MediaSampler::getImageHeight();
		INT pitch = (width * 24/8 + 3)/4*4;
		Gdiplus::Bitmap bitmap(width,height,pitch,PixelFormat24bppRGB,(LPBYTE)m_dataPtr);
		Gdiplus::Graphics* g = getGraphics();
	
		g->DrawImage(&bitmap,0,height-1,width,-height);
		m_critical.unlock();
	}
	return UnitGdip::onRender(world,x,y,z);
}
Example #24
0
File: file.c Project: digsrc/fossil
/*
** Same as file_isfile(), but takes into account symlinks.
*/
int file_wd_isfile(const char *zFilename){
  return getStat(zFilename, 1) ? 0 : S_ISREG(fileStat.st_mode);
}
Example #25
0
File: file.c Project: digsrc/fossil
/*
** Return TRUE if the named file is an ordinary file or symlink
** and symlinks are allowed.
** Return false for directories, devices, fifos, etc.
*/
int file_wd_isfile_or_link(const char *zFilename){
  return getStat(zFilename, 1) ? 0 : S_ISREG(fileStat.st_mode) ||
                                     S_ISLNK(fileStat.st_mode);
}
Example #26
0
File: file.c Project: digsrc/fossil
/*
** Same as file_mtime(), but takes into account symlinks.
*/
i64 file_wd_mtime(const char *zFilename){
  return getStat(zFilename, 1) ? -1 : fileStat.st_mtime;
}
Example #27
0
File: file.c Project: digsrc/fossil
/*
** Return the size of a file in bytes.  Return -1 if the file does not
** exist.  If zFilename is NULL, return the size of the most recently
** stat-ed file.
*/
i64 file_size(const char *zFilename){
  return getStat(zFilename, 0) ? -1 : fileStat.st_size;
}
Example #28
0
void TestScriptingInterface::waitForProcessingIdle() {
    auto statTracker = DependencyManager::get<StatTracker>();
    waitForCondition(0, [statTracker]()->bool {
        return (0 == statTracker->getStat("Processing").toInt() && 0 == statTracker->getStat("PendingProcessing").toInt());
    });
}
Example #29
0
 qint32 Games()
 {
     QVector<qint32> K = getStat("K");
     return K.count();
 }
Example #30
0
off_t getFileSize(const char * path) {
	struct stat data = {0};
	getStat(path, &data);
	return data.st_size;
}