void KbManager::fps(int framerate){ QTimer* timer = eventTimer(); if(!timer) return; if(timer->isActive()) timer->setInterval(1000 / framerate); else timer->start(1000 / framerate); }
static int receive(int sdv[]) { int numfds, ii; fd_set fdset; struct timeval timeout, *tvp = &timeout; struct timeval sched, *svp = &sched, now, *nvp = &now; int count, block; gettimeofday(nvp, (struct timezone *) NULL); svp->tv_usec = nvp->tv_usec + TIMETICK; svp->tv_sec = nvp->tv_sec; while (svp->tv_usec >= ONE_SEC){ svp->tv_usec -= ONE_SEC; svp->tv_sec++; } while (running) { tvp = &timeout; tvp->tv_sec = 0; tvp->tv_usec = TIMETICK; numfds = 0; FD_ZERO(&fdset); for(ii = 0; ii < sdlen; ii++){ if (sdv[ii] + 1 > numfds) numfds = sdv[ii] + 1; FD_SET(sdv[ii], &fdset); } block = 0; snmp_select_info(&numfds, &fdset, tvp, &block); if (block == 1) tvp = NULL; /* block without timeout */ count = select(numfds, &fdset, 0, 0, tvp); if (count > 0){ for(ii = 0; ii < sdlen; ii++){ if(FD_ISSET(sdv[ii], &fdset)){ sd_handlers[ii](sdv[ii]); FD_CLR(sdv[ii], &fdset); } } snmp_read(&fdset); } else switch(count){ case 0: snmp_timeout(); break; case -1: if (errno == EINTR){ continue; } else { perror("select"); } return -1; default: printf("select returned %d\n", count); return -1; } gettimeofday(nvp, (struct timezone *) NULL); if (nvp->tv_sec > svp->tv_sec || (nvp->tv_sec == svp->tv_sec && nvp->tv_usec > svp->tv_usec)){ #ifdef USING_V2PARTY_ALARM_MODULE alarmTimer(nvp); #endif #ifdef USING_V2PARTY_EVENT_MODULE eventTimer(nvp); #endif svp->tv_usec = nvp->tv_usec + TIMETICK; svp->tv_sec = nvp->tv_sec; while (svp->tv_usec >= ONE_SEC){ svp->tv_usec -= ONE_SEC; svp->tv_sec++; } if (log_addresses && lastAddrAge++ > 600){ lastAddrAge = 0; for(count = 0; count < ADDRCACHE; count++){ if (addrCache[count].status == OLD) addrCache[count].status = UNUSED; if (addrCache[count].status == USED) addrCache[count].status = OLD; } } } } return 0; }