示例#1
0
void checkStream(void)
{

	//sprawdzenie na to czy mamy event roz³¹czenia
	if(strstr((const char *)copiedData, "+RDII") != NULL)
	{
		turnOnRightDiode();

		//zastopowanie odbioru i transmisji danych
		removeTimer(&receiveStatus, &receiveID);
		removeTimer(&transmitStatus, &transmitID);
		//zastopowanie odbioru i transmisji danych

		//wlaczenie ponownej inicjalizacji
		makeTimer(500, SYSTM001_PERIODIC, timerHandler, NULL, &Status, &TimerId);

		stageOfInitializationBt = INITIAL_STATE;
		//wy³¹czenie mozliwosci wysy³u odbioru
		turnOnSendingReceiving = TURN_OFF;
		//wy³¹czenie mozliwosci wysy³u odbioru

		initStatus = 0;
		//wyresetowanie bufora danych
		for(int h = 0; h < MAX_READ_DATA; h++)
		{
			copiedData[h] = '\0';
		}
		//wyresetowanie bufora danych
	}

}
示例#2
0
void BSpit::ytramTrapTimer() {
	// Remove this timer
	removeTimer();

	// Check if we've caught a Ytram
	checkYtramCatch(true);
}
//------------------------------------------------------------------------------
tOplkError timeru_delInstance(void)
{
    ULONG               msg;
    tTimeruData*        pTimer;

    /* send message to timer task to signal shutdown */
    msg = 0;
    msgQSend(timeruInstance_l.msgQueue, (char*)&msg, sizeof(ULONG),
             NO_WAIT, MSG_PRI_NORMAL);

    /* wait for timer task to end */
    while (taskIdVerify(timeruInstance_l.taskId) == OK)
        taskDelay(sysClkRateGet());

    /* free up timer list */
    resetTimerList();
    while ((pTimer = getNextTimer()) != NULL)
    {
        hrtimer_delete (pTimer->timer);
        removeTimer(pTimer);
        OPLK_FREE(pTimer);
    }

    /* cleanup resources */
    semDelete(timeruInstance_l.mutex);
    msgQDelete(timeruInstance_l.msgQueue);

    timeruInstance_l.pFirstTimer = NULL;
    timeruInstance_l.pLastTimer = NULL;

    return kErrorOk;
}
示例#4
0
CClientProxyUnknown::~CClientProxyUnknown()
{
	removeHandlers();
	removeTimer();
	delete m_stream;
	delete m_proxy;
}
//------------------------------------------------------------------------------
tOplkError timeru_exit(void)
{
    tTimeruData*     pTimer;

    /* cancel thread */
    pthread_cancel(timeruInstance_g.processThread);
    DEBUG_LVL_TIMERU_TRACE("%s() Waiting for thread to exit...\n", __func__);

    /* wait for thread to terminate */
    pthread_join(timeruInstance_g.processThread, NULL);
    DEBUG_LVL_TIMERU_TRACE("%s()Thread exited\n", __func__);

    /* free up timer list */
    resetTimerList();
    while ((pTimer = getNextTimer()) != NULL)
    {
        removeTimer(pTimer);
        OPLK_FREE(pTimer);
    }

    pthread_mutex_destroy(&timeruInstance_g.mutex);

    timeruInstance_g.pFirstTimer = NULL;
    timeruInstance_g.pLastTimer = NULL;

    return kErrorOk;
}
示例#6
0
uint8_t I2CreadByte(uint8_t address, uint8_t subAddress)
{
	//I2C001_DataType data1,data2,data3,data4,data5, data6, data7;

	uint16_t DataReceive1 = 0x0000;
	addressTimer = address;
	subAddressTimer = subAddress;

	makeTimer(200, SYSTM001_PERIODIC, timerHandlerI2CreadByte, NULL, &Status, &TimerId);
	while(1)
	{
		if(6 == indexI2CreadByte)
		{
			removeTimer(&Status, &TimerId);
			DataReceive1 = DataReceive2;
			indexI2CreadByte = 0;
			addressTimer = 0;
			subAddressTimer = 0;
			DataReceive2 = 0x0000;

			Status = SYSTM001_ERROR;
			TimerId = 0;
			break;
		}
	}

	return (uint8_t)DataReceive1;
}
示例#7
0
    void callTimers()
    {
        const LockType::ScopedLockType sl (lock);

        while (firstTimer != nullptr && firstTimer->countdownMs <= 0)
        {
            Timer* const t = firstTimer;
            t->countdownMs = t->periodMs;

            removeTimer (t);
            addTimer (t);

            const LockType::ScopedUnlockType ul (lock);

            JUCE_TRY
            {
                t->timerCallback();
            }
            JUCE_CATCH_EXCEPTION
        }

        /* This is needed as a memory barrier to make sure all processing of current timers is done
           before the boolean is set. This set should never fail since if it was false in the first place,
           we wouldn't get a message (so it can't be changed from false to true from under us), and if we
           get a message then the value is true and the other thread can only set it to true again and
           we will get another callback to set it to false.
        */
        callbackNeeded.set (0);
    }
void
CClientProxyUnknown::sendSuccess()
{
	m_ready = true;
	removeTimer();
	m_events->addEvent(CEvent(m_events->forCClientProxyUnknown().success(), this));
}
示例#9
0
文件: timer.c 项目: leafo/adapbdap
void clearTimers() {
	int i;
	for (i = 0; i < timerCount; i++) {
		if (timers[i].dead) continue;
		removeTimer(i);
	}
}
示例#10
0
文件: MuTimer.cpp 项目: eriser/mural
  void MuTimer::update() {
    TimeEvent::Time now = std::chrono::system_clock::now();

    auto &timerQueue = usingQueueA ? timerQueueA : timerQueueB;
    auto &timerQueue2 = usingQueueA ? timerQueueB : timerQueueA;

    usingQueueA = !usingQueueA;

    while (!timerQueue.empty() && (timerQueue.top()->when < now)) {
      auto t = timerQueue.top();
      timerQueue.pop();

      if (!t->finished) {
        t->callback();

        if (t->loop) {
          t->setDuration(t->duration);
          timerQueue2.push(t);
          continue;
        }
      }

      removeTimer(t->id);
    }
  }
示例#11
0
void
CClientProxyUnknown::sendSuccess()
{
	m_ready = true;
	removeTimer();
	EVENTQUEUE->addEvent(CEvent(getSuccessEvent(), this));
}
示例#12
0
MohawkEngine_Riven::MohawkEngine_Riven(OSystem *syst, const MohawkGameDescription *gamedesc) : MohawkEngine(syst, gamedesc) {
	_showHotspots = false;
	_cardData.hasData = false;
	_gameOver = false;
	_activatedSLST = false;
	_ignoreNextMouseUp = false;
	_extrasFile = 0;
	_curStack = kStackUnknown;
	_hotspots = 0;
	removeTimer();

	// NOTE: We can never really support CD swapping. All of the music files
	// (*_Sounds.mhk) are stored on disc 1. They are copied to the hard drive
	// during install and used from there. The same goes for the extras.mhk
	// file. The following directories allow Riven to be played directly
	// from the DVD.

	const Common::FSNode gameDataDir(ConfMan.get("path"));
	SearchMan.addSubDirectoryMatching(gameDataDir, "all");
	SearchMan.addSubDirectoryMatching(gameDataDir, "data");
	SearchMan.addSubDirectoryMatching(gameDataDir, "exe");
	SearchMan.addSubDirectoryMatching(gameDataDir, "assets1");

	g_atrusJournalRect1 = new Common::Rect(295, 402, 313, 426);
	g_atrusJournalRect2 = new Common::Rect(259, 402, 278, 426);
	g_cathJournalRect2 = new Common::Rect(328, 408, 348, 419);
	g_atrusJournalRect3 = new Common::Rect(222, 402, 240, 426);
	g_cathJournalRect3 = new Common::Rect(291, 408, 311, 419);
	g_trapBookRect3 = new Common::Rect(363, 396, 386, 432);
	g_demoExitRect = new Common::Rect(291, 408, 317, 419);
}
示例#13
0
文件: events.c 项目: robotiko/rules
unsigned int assertTimers(void *handle) {
    unsigned short commandCount = 2;
    redisReply *reply;
    void *rulesBinding;
    unsigned int result = peekTimers(handle, &rulesBinding, &reply);
    if (result != RULES_OK) {
        return result;
    }

    result = prepareCommands(rulesBinding);
    if (result != RULES_OK) {
        freeReplyObject(reply);
        return result;
    }

    for (unsigned long i = 0; i < reply->elements; ++i) {
        result = removeTimer(rulesBinding, reply->element[i]->str);
        if (result != RULES_OK) {
            freeReplyObject(reply);
            return result;
        }

        ++commandCount;
        result = handleEvent(handle, reply->element[i]->str, &rulesBinding, ACTION_ASSERT_TIMER, &commandCount);
        if (result != RULES_OK && result != ERR_EVENT_NOT_HANDLED) {
            freeReplyObject(reply);
            return result;
        }
    }

    result = executeCommands(rulesBinding, commandCount);
    freeReplyObject(reply);
    return result;
}
示例#14
0
void MohawkEngine_Riven::refreshCard() {
	// Clear any timer still floating around
	removeTimer();

	loadHotspots(_curCard);

	_gfx->_updatesEnabled = true;
	_gfx->clearWaterEffects();
	_gfx->_activatedPLSTs.clear();
	_video->stopVideos();
	_gfx->drawPLST(1);
	_activatedSLST = false;

	runCardScript(kCardLoadScript);
	_gfx->updateScreen();
	runCardScript(kCardOpenScript);

	// Activate the first sound list if none have been activated
	if (!_activatedSLST)
		_sound->playSLST(1, _curCard);

	if (_showHotspots)
		for (uint16 i = 0; i < _hotspotCount; i++)
			_gfx->drawRect(_hotspots[i].rect, _hotspots[i].enabled);

	// Now we need to redraw the cursor if necessary and handle mouse over scripts
	updateCurrentHotspot();

	// Finally, install any hardcoded timer
	installCardTimer();
}
示例#15
0
void Server::action(Event event)
{
	if (event == BALLOUT)
	{
		std::cout << "********************************************" << std::endl;
		/* Mr. Wand isn't as good in serving as he is in bouncing the ball
		   So as long the game is not running yet, it's always the user who serves
		*/
		if ((state == RUNNING)&&((int)floor(round / 5.0) % 2 == 0))
		{
			Buffer sbuf(SERVE_BALL);
			for (std::map<grapple_user, Peer>::iterator i = peer.begin(); i != peer.end(); ++i)
			{
				if ((*i).second.player->getSide() == BACK)
				{
					sbuf.pushId((*i).first);
					(*i).second.player->attachBall(&ball[0]);
					break;
				}
			}
			sendPacket(sbuf, true);
		} else {
			output.addMessage(Interface::YOU_SERVE);
			peer[localid].player->attachBall(&ball[0]);
			if (state == RUNNING) {
				Buffer sbuf(SERVE_BALL);
				sbuf.pushId(localid);
				sendPacket(sbuf, true);
			}
		}
		removeTimer(ballouttimer);
		ballouttimer = -1;
	}
}
示例#16
0
/**
 * 时间循环监听定时器事件,并执行定时器回调
 */
int timerManager::run()
{
	int nfds = epoll_wait (m_fd, m_events, MAXEVENTS, -1);
	for (int i = 0; i < nfds; i++)
	{
		if ((m_events[i].events & EPOLLERR) || (m_events[i].events & EPOLLHUP) || (!(m_events[i].events & EPOLLIN)))
		{
			/* An error has occured on this fd, or the socket is not
			   ready for reading (why were we notified then?) */
			printf ( "epoll error\n");
			close (m_events[i].data.fd);
			continue;
		}
		std::map<int, timer*>::iterator it = m_timersMap.find(m_events[i].data.fd);
		if (it != m_timersMap.end())
		{
			char buf[10];
			int ret = 0 ;
			/*定时器超时,需要把数据读出来,否则会出现堵塞,重复定时效果失效。读出的数据只有1个*/
			while (ret = read(m_events[i].data.fd, buf, 10) > 0)
			{
                    		//read all data
				//printf("%d\n",ret);//ret = 1
                	}
			//定时器时间到
			timer* t = it->second;
			t->emit(); //发送超时信号
			removeTimer(t);
		}
	}
	return 0;
}
示例#17
0
void CanvasTimer::handleTimeout()
{
    Q_ASSERT(m_value.isFunction());
    m_value.call();
    if (isSingleShot()) {
        removeTimer(this);
    }
}
示例#18
0
        void cancel(const T& t) {
            boost::lock_guard< boost::mutex > guard(mutex_);

            std::auto_ptr< boost::asio::deadline_timer > pTimer = removeTimer(t);
            if (pTimer.get()) {
                boost::system::error_code ec;
                pTimer->cancel(ec);
            }
        }
示例#19
0
//
// a simple timier
void *amt_timer(void *_p)
{
#ifdef P32BITS
    u32 period = (long)_p;
#else
    u32 period = (long long)_p;
#endif

    AMT_TRACE(AMT_LEVEL_9,"timer thread created with periodic time:%u \n", period);
 
    timerState = AMT_TIMER_RUN;
    period = (period > 10000 || period < 10)?100:period;
    
    // setup the periodic timer  
    // if ((res = setupTimer(period))!=0) return ((void *)res);
    
    // we need not an accurate clock. Let us just use msleep
    while(timerQuitReq!=AMT_TIMER_QUIT_REQ) {
	amt_timer_t *p;
	u32 now =  getCurrentTime();
	pthread_mutex_lock(&amt_timer_mutex);
	p = pTimerRoot ;
	while (p) {
	    if (p->expiredTime <= now) {
		amt_timer_callback_f sinkFunc = p->sinkFunc;
		void *param = p->param;
		amt_timer_handle timerID= p->timerID;

		if (p->timerType==AMT_TIMER_ONESHOT) {
		    p=removeTimer(p);
		} else {
		    p->expiredTime += p->period;
		}
		
		if (sinkFunc) {
		    pthread_mutex_unlock(&amt_timer_mutex);
		    sinkFunc(timerID, param);
		    pthread_mutex_lock(&amt_timer_mutex);
		    p = pTimerRoot ;
		    now =  getCurrentTime();
		    continue;
		}
	    }
	    p=p->next;
	}
	pthread_mutex_unlock(&amt_timer_mutex);
	msleep(0, period); 
    }
    timerState = AMT_TIMER_IDLE;
    pthread_mutex_unlock(&amt_timer_mutex);
    timerQuitReq = AMT_TIMER_IDLE;
    pthread_mutex_unlock(&amt_timer_mutex);

    AMT_TRACE(AMT_LEVEL_9,"timer thread exited\n");
    
    return NULL;
}
void
CClientProxyUnknown::sendFailure()
{
	delete m_proxy;
	m_proxy = NULL;
	m_ready = false;
	removeHandlers();
	removeTimer();
	m_events->addEvent(CEvent(m_events->forCClientProxyUnknown().failure(), this));
}
示例#21
0
        void handleTimeout(const boost::system::error_code& ec, T t, boost::function< void () > timeoutHandler) {
            {
                boost::lock_guard< boost::mutex > guard(mutex_);
                removeTimer(t);
            }

            if (!ec) {
                timeoutHandler();
            }
        }
示例#22
0
文件: MuTimer.cpp 项目: eriser/mural
 void MuTimer::cancelAnimationFrame(unsigned int id) {
   /*
   auto e = rafCallbackHash.find(id);
   if (e != rafCallbackHash.end()) {
     e->second->second = true;
     rafCallbackHash.erase(e);
   }
   */
   removeTimer(id);
 }
示例#23
0
void
CClientProxyUnknown::sendFailure()
{
	delete m_proxy;
	m_proxy = NULL;
	m_ready = false;
	removeHandlers();
	removeTimer();
	EVENTQUEUE->addEvent(CEvent(getFailureEvent(), this));
}
示例#24
0
uint8_t I2CreadBytes1(uint8_t address, uint8_t subAddress, uint8_t * dest, uint8_t count)
{
	addressTimerI2CReadBytes = address;
	subAddressTimerI2CReadBytes = subAddress;
	makeTimer(200, SYSTM001_PERIODIC, timerHandlerI2CreadBytes1, NULL, &StatusReadBytes, &TimerIdReadBytes);

	while(1)
	{
		if(8 == indexI2CreadBytes)
		{
			removeTimer(&StatusReadBytes, &TimerIdReadBytes);

			indexI2CreadBytes = 0;
			addressTimerI2CReadBytes = 0;
			subAddressTimerI2CReadBytes = 0;

			StatusReadBytes = SYSTM001_ERROR;
			TimerIdReadBytes = 0;

			addressTimerI2CReadBytes = address;
			subAddressTimerI2CReadBytes = subAddress;

			//indexAccel = indexAccel + 1;
			subAddressTimerI2CReadBytes = subAddressTimerI2CReadBytes + indexAccel;

			if(indexAccel == count)
			{
				/*dest[0] = (uint8_t)accelerationXYZ[0];
				dest[1] = (uint8_t)accelerationXYZ[1];
				dest[2] = (uint8_t)accelerationXYZ[2];
				dest[3] = (uint8_t)accelerationXYZ[3];
				dest[4] = (uint8_t)accelerationXYZ[4];
				dest[5] = (uint8_t)accelerationXYZ[5];*/
				int k = 0;
				for(k = 0; k < count; k++)
				{
					dest[k] = (uint8_t)accelerationXYZ[k];
				}

				/*for(k = 0; k < 6; k++)
				{
					accelerationXYZ[k] = 0;
				}*/
				indexAccel = 0;

				break;
			}
			else
			{
				makeTimer(100, SYSTM001_PERIODIC, timerHandlerI2CreadBytes1, NULL, &StatusReadBytes, &TimerIdReadBytes);
			}
		}
	}
}
示例#25
0
void FileUtils::remove(int64_t id) {
  Timer removeTimer(true);
  boost::system::error_code ec;
  boost::filesystem::path path = filePath(id);
  boost::filesystem::remove(path, ec);
  if (ec) {
    LOG(ERROR) << "Unlink " << path << " failed: " << ec;
  }
  GorillaStatsManager::addStatValue(
      kMsPerFileRemove, removeTimer.get() / kGorillaUsecPerMs);
}
示例#26
0
文件: timer.c 项目: leafo/adapbdap
// update all the living timers
void updateTimers(float dt) {
	int i;
	for (i = 0; i < timerCount; i++) {
		if (timers[i].dead) continue;
		timers[i].passed += dt;
		if (timers[i].passed > timers[i].interval) {
			timers[i].passed -= timers[i].interval;
			int finished = timers[i].action(&timers[i]);
			if (finished) removeTimer(i);
		}
	}
}
示例#27
0
void TimerManager::removeTimer(TimerHandle &handle) {
	Common::StackLock lock(_mutex);

	if (handle._empty)
		return;

	removeTimer(*handle._iterator);

	_timers.erase(handle._iterator);

	handle._iterator = _timers.end();
	handle._empty    = true;
}
示例#28
0
void CanvasTimer::removeTimer(const QScriptValue &val)
{
    if (!val.isFunction())
        return;

    for (int i = 0 ; i < activeTimers()->count() ; ++i) {
        CanvasTimer *timer = activeTimers()->at(i);
        if (timer->equals(val)) {
            removeTimer(timer);
            return;
        }
    }
}
示例#29
0
        void add(const T& t, int timeoutMillis, boost::function< void () > timeoutHandler) {
            boost::lock_guard< boost::mutex > guard(mutex_);

            std::auto_ptr< boost::asio::deadline_timer > pTimer = removeTimer(t);

            if ( pTimer.get() ) {
                boost::system::error_code ec;
                pTimer->cancel(ec);
            }

            pTimer.reset(new boost::asio::deadline_timer(io_service_intializer_.get_io_service(), boost::posix_time::milliseconds(timeoutMillis)));
            pTimer->async_wait(boost::bind(&Timer::handleTimeout, this, _1, t, timeoutHandler));

            timers_.insert(t, pTimer);
        }
/**
 * read_timer_cmd
 * read message received on the IPC from the client
 * the only messages are timer commands {add, remove}
 *
 * @return CPR_SUCCESS or CPR_FAILURE
 */
static cprRC_t read_timer_cmd ()
{
    static const char fname[] = "read_timer_cmd";
    int  rcvlen;
    timer_ipc_t tmr_cmd ={0};
    cprRC_t ret = CPR_FAILURE;



    rcvlen =recvfrom(serv_sock, &tmr_cmd, sizeof(timer_ipc_t), 0,
                     NULL, NULL);

    if (rcvlen > 0) {
        //CPR_INFO("got message type=%d\n", tmr_cmd.msg_type);
        switch(tmr_cmd.msg_type) {
	case TMR_CMD_ADD:
            //CPR_INFO("request to add timer ptr=%x duration=%d datptr=%x\n",
            //       tmr_cmd.u.cmd.timer_ptr, tmr_cmd.u.cmd.duration, tmr_cmd.u.cmd.user_data_ptr);

            ret = addTimer(tmr_cmd.u.cmd.timer_ptr,tmr_cmd.u.cmd.duration,
                     (void *)tmr_cmd.u.cmd.user_data_ptr);

            break;

	case TMR_CMD_REMOVE:
            //CPR_INFO("request to remove timer ptr=%x\n", tmr_cmd.u.cmd.timer_ptr);
            ret = removeTimer(tmr_cmd.u.cmd.timer_ptr);
            break;

        default:
            CPR_ERROR("%s:invalid ipc command = %d\n", tmr_cmd.msg_type);
            ret = CPR_FAILURE;
            break;
        }
    } else {
        CPR_ERROR("%s:while reading serv_sock err =%s: Closing Socket..Timers not operational !!! \n",
                  fname, strerror(errno));
        (void) close(serv_sock);
        serv_sock = INVALID_SOCKET;
        ret = CPR_FAILURE;
    }

    /* send the result back */
    send_api_result(ret, &tmr_client_addr, sizeof(tmr_client_addr));

    return (ret);

}