コード例 #1
0
void AVL_tree::RemoveTimer(Node node, const byte& timerid){
  if(node == NULL){
    return;
  }
  if(node->timerid == timerid){
    node->timerid = 255;
  }
  RemoveTimer(node->left, timerid);
  RemoveTimer(node->right, timerid);
}
コード例 #2
0
ファイル: tmaster-client.cpp プロジェクト: 10fish/heron
void TMasterClient::Die() {
  LOG(INFO) << "Tmaster client is being destroyed " << std::endl;
  to_die_ = true;
  Stop();
  // Unregister the timers
  if (reconnect_timer_id > 0) {
    RemoveTimer(reconnect_timer_id);
  }

  if (heartbeat_timer_id > 0) {
    RemoveTimer(heartbeat_timer_id);
  }
}
コード例 #3
0
ファイル: timer.c プロジェクト: HBelusca/NasuTek-Odyssey
BOOL FASTCALL
DestroyTimersForWindow(PTHREADINFO pti, PWND Window)
{
   PLIST_ENTRY pLE;
   PTIMER pTmr;
   BOOL TimersRemoved = FALSE;

   if ((Window == NULL))
      return FALSE;

   TimerEnterExclusive();
   pLE = TimersListHead.Flink;
   while(pLE != &TimersListHead)
   {
      pTmr = CONTAINING_RECORD(pLE, TIMER, ptmrList);
      pLE = pLE->Flink; /* get next timer list entry before current timer is removed */
      if ((pTmr) && (pTmr->pti == pti) && (pTmr->pWnd == Window))
      {
         TimersRemoved = RemoveTimer(pTmr);
      }
   }

   TimerLeave();

   return TimersRemoved;
}
コード例 #4
0
ファイル: atik_ccd.cpp プロジェクト: azwing/indi
bool ATIKCCD::Disconnect()
{
    ImageState  tState;
    LOGF_DEBUG("Closing %s...", name);

    stopTimerNS();
    stopTimerWE();
    RemoveTimer(genTimerID);
    genTimerID = -1;

    pthread_mutex_lock(&condMutex);
    tState = threadState;
    threadRequest = StateTerminate;
    pthread_cond_signal(&cv);
    pthread_mutex_unlock(&condMutex);
    pthread_join(imagingThread, nullptr);
    tState = StateNone;
    if (isSimulation() == false)
    {
        if (tState == StateExposure)
            ArtemisStopExposure(hCam);
        ArtemisDisconnect(hCam);
    }

    LOG_INFO("Camera is offline.");

    return true;
}
コード例 #5
0
ファイル: gpusb.cpp プロジェクト: rrogge/indi
IPState GPUSB::GuideSouth(float ms)
{
    RemoveTimer(NStimerID);

    driver->startPulse(GPUSB_SOUTH);

    DEBUG(INDI::Logger::DBG_DEBUG, "Starting SOUTH guide");

    NSDir = GPUSB_SOUTH;

    if (ms <= POLLMS)
    {
        usleep(ms * 1000);

        driver->stopPulse(GPUSB_SOUTH);
        return IPS_OK;
    }

    NSPulseRequest = ms / 1000.0;
    gettimeofday(&NSPulseStart, nullptr);
    InNSPulse = true;

    NStimerID = SetTimer(ms - 50);

    return IPS_BUSY;
}
コード例 #6
0
	void addSummon()
	{
		for(uint32 i = 0; i < 5; ++i)
			SpawnCreature( KELESETH_SKELETON_ADD, 163.376f + i + 4, 252.901f - i + 5, 42.868f, 0, true);

		RemoveTimer(mSkeletonTimer);
	};
コード例 #7
0
//-----------------------------------------------------------------------------
// Purpose: Check & fire any timers that should fire based on their duration.
//-----------------------------------------------------------------------------
void CHintMessageTimers::Update()
{
	if ( !m_pHintSystem )
		return;

	for ( int i = 0; i < m_Timers.Count(); i++ )
	{
		if ( m_Timers[i]->timer.Expired() )
		{
			if ( m_pHintSystem->TimerShouldFire( m_Timers[i]->iHintID ) )
			{
				//Warning("TIMER FIRED: %s\n", m_pszHintMessages[m_Timers[i]->iHintID] );

				m_pHintSystem->HintMessage( m_Timers[i]->iHintID );

				// Remove and return. No reason to bring up multiple hints.
				RemoveTimer( m_Timers[i]->iHintID );
				return;
			}
			else
			{
				// Push the timer out again
				m_Timers[i]->timer.Start();
			}
		}
	}
}
コード例 #8
0
ファイル: NTimer.cpp プロジェクト: refnum/nano
//============================================================================
//		NTimer::~NTimer : Destructor.
//----------------------------------------------------------------------------
NTimer::~NTimer(void)
{


	// Clean up
	RemoveTimer();
}
コード例 #9
0
ファイル: indigps.cpp プロジェクト: rumengb/indi
bool INDI::GPS::ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n)
{
    if (dev != nullptr && strcmp(dev, getDeviceName()) == 0)
    {
        if (strcmp(name, PeriodNP.name) == 0)
        {
            double prevPeriod = PeriodN[0].value;
            IUUpdateNumber(&PeriodNP, values, names, n);
            // Do not remove timer if GPS update is still in progress
            if (timerID > 0 && RefreshSP.s != IPS_BUSY)
            {
                RemoveTimer(timerID);
                timerID = -1;
            }

            if (PeriodN[0].value == 0)
            {
                DEBUG(INDI::Logger::DBG_SESSION, "GPS Update Timer disabled.");
            }
            else
            {
                timerID = SetTimer(PeriodN[0].value*1000);
                if (prevPeriod == 0)
                    DEBUG(INDI::Logger::DBG_SESSION, "GPS Update Timer enabled.");
            }

            PeriodNP.s = IPS_OK;
            IDSetNumber(&PeriodNP, nullptr);

            return true;
        }
    }

    return DefaultDevice::ISNewNumber(dev, name, values, names, n);
}
コード例 #10
0
ファイル: gpusb.cpp プロジェクト: rrogge/indi
IPState GPUSB::GuideWest(float ms)
{
    RemoveTimer(WEtimerID);

    driver->startPulse(GPUSB_WEST);

    DEBUG(INDI::Logger::DBG_DEBUG, "Starting WEST guide");

    WEDir = GPUSB_WEST;

    if (ms <= POLLMS)
    {
        usleep(ms * 1000);

        driver->stopPulse(GPUSB_WEST);
        return IPS_OK;
    }

    WEPulseRequest = ms / 1000.0;
    gettimeofday(&WEPulseStart, nullptr);
    InWEPulse = true;

    WEtimerID = SetTimer(ms - 50);

    return IPS_BUSY;
}
コード例 #11
0
void CLuaTimerManager::DoPulse ( CLuaMain* pLuaMain )
{
    assert ( m_ProcessQueue.empty () );
    assert ( !m_pPendingDelete );
    assert ( !m_pProcessingTimer );

    CTickCount llCurrentTime = CTickCount::Now ();

    // Use a separate queue to avoid trouble
    // What kind of problems are we trying to avoid? Doing a copy each frame isn't quite efficient
    for ( CFastList < CLuaTimer* > ::const_iterator iter = m_TimerList.begin () ; iter != m_TimerList.end () ; ++iter )
        m_ProcessQueue.push_back ( *iter );

    while ( !m_ProcessQueue.empty () )
    {
        m_pProcessingTimer = m_ProcessQueue.front ();
        m_ProcessQueue.pop_front ();

        CTickCount llStartTime = m_pProcessingTimer->GetStartTime ();
        CTickCount llDelay = m_pProcessingTimer->GetDelay ();
        unsigned int uiRepeats = m_pProcessingTimer->GetRepeats ();

        // Is the time up and is not being deleted
        if ( llCurrentTime >= ( llStartTime + llDelay ) )
        {
            // Set our debug info
            g_pGame->GetScriptDebugging()->SaveLuaDebugInfo ( m_pProcessingTimer->GetLuaDebugInfo ( ) );
            
            m_pProcessingTimer->ExecuteTimer ( pLuaMain );
            // Reset
            g_pGame->GetScriptDebugging()->SaveLuaDebugInfo ( SLuaDebugInfo() );

            // If this is the last repeat, remove
            if ( uiRepeats == 1 )
            {
                RemoveTimer ( m_pProcessingTimer );
            }
            else
            {
                // Decrease repeats if not infinite
                if ( uiRepeats != 0 )
                    m_pProcessingTimer->SetRepeats ( uiRepeats - 1 );

                m_pProcessingTimer->SetStartTime ( llCurrentTime );
            }
        }

        // Finally cleanup timer if it was removed during processing
        if ( m_pPendingDelete )
        {
            assert ( m_pPendingDelete == m_pProcessingTimer );
            m_pProcessingTimer = NULL;
            delete m_pPendingDelete;
            m_pPendingDelete = NULL;
        }
        else
            m_pProcessingTimer = NULL;
    }
}
コード例 #12
0
ファイル: Script.c プロジェクト: sarah-russell12/openclonk
func Death()
{
	RemoveTimer(this.UpdateSwim);
	RemoveTimer(this.Activity);
	this.MeshTransformation = Trans_Rotate(160 + Random(41), 1, 0, 0);
	if (base_transform) this.MeshTransformation = Trans_Mul(base_transform, this.MeshTransformation);
	StopAnimation(swim_animation);
	AddTimer(this.Decaying, 500);
	this.Collectible = true;
	
	// maybe respawn a new fish if roe is near
	var roe = FindObject(Find_Distance(200), Find_ID(FishRoe));
	if (roe)
		roe->Hatch(GetID());
	
	return _inherited(...);
}
コード例 #13
0
ファイル: Base.cpp プロジェクト: Refuge89/Hearthstone
void MoonScriptBossAI::AIUpdate(MapManagerScript* MMSCript, uint32 p_time)
{
	if( mEnrageSpell && mEnrageTimerDuration > 0 && IsTimerFinished(mEnrageTimer) )
	{
		CastSpell(mEnrageSpell);
		RemoveTimer(mEnrageTimer);
	}
	MoonScriptCreatureAI::AIUpdate(MMSCript, p_time);
}
コード例 #14
0
ファイル: Base.cpp プロジェクト: AegisEmu/AegisEmu
void ArcScriptBossAI::AIUpdate()
{
	if( mEnrageSpell && mEnrageTimerDuration > 0 && IsTimerFinished(mEnrageTimer) )
	{
		CastSpell(mEnrageSpell);
		RemoveTimer(mEnrageTimer);
	}
	ArcScriptCreatureAI::AIUpdate();
}
コード例 #15
0
        void AIUpdate()
        {
            if (IsTimerFinished(mReplyTimer) && pDalronn != NULL)
            {
                pDalronn->Emote("By all means, don't assess the situation, you halfwit! Just jump into the fray!", Text_Yell, 13199);
                RemoveTimer(mReplyTimer);
            };

            ParentClass::AIUpdate();
        };
コード例 #16
0
ファイル: TimerEvent.cpp プロジェクト: angel0sl/FServer
bool ResetTimer(std::shared_ptr<TimerEvent> te, int milliSecs /* = 0 */)
{
	RemoveTimer(te);
	if (milliSecs > 0)
	{
		te->m_timeval.tv_sec = milliSecs / 1000;
		te->m_timeval.tv_usec = (milliSecs % 1000) * 1000;
	}
	return AddTimer(te);
}
コード例 #17
0
ファイル: DlgPyrit.c プロジェクト: 772/openclonk
// called every 10 frames after plane+oil task has been given
func CheckOilAtPlane()
{
	var barrel;
	for (var plane in FindObjects(Find_ID(Plane)))
		if (barrel = plane->FindObject(plane->Find_AtRect(-30,-10,60,20), Find_ID(MetalBarrel)))
		{
			RemoveTimer(Scenario.CheckOilAtPlane);
			ScheduleCall(nil, Global.GameCall, 1,1, "OnPlaneLoaded", plane, barrel);
		}
	return true;
}
コード例 #18
0
ファイル: Raid_MoltenCore.cpp プロジェクト: wow4all/wowtbc
	void AIUpdate()
	{
		if(!Elite1->isAlive() && !Elite2->isAlive() && !Elite3->isAlive() && !Elite4->isAlive() &&
		!Healer1->isAlive() && !Healer2->isAlive() && !Healer3->isAlive() && !Healer4->isAlive() && GetPhase() == 1)
		{
			SetCanEnterCombat(false);
			SetAllowMelee(false);
			SetAllowRanged(false);
			SetAllowSpell(false);
			SetAllowTargeting(false);
			SetCanMove(false);
			RemoveAllAuras();
			_unit->SetUInt64Value(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_ATTACKABLE_9);		
			Emote("Impossible! Stay your attack, mortal... I submit! I submit!", Text_Yell, 8045);
			SetPhase(2);
			DomoSayTimer1 = AddTimer(7000);
			DomoSayTimer2 = AddTimer(16000);
			DomoTeleportTimer3 = AddTimer(34000);
		}
		
		if(GetPhase() == 2 && IsTimerFinished(DomoSayTimer1))
		{
			Emote("Brashly, you have come to rest the secrets of the Living Flame! You will soon regret the recklessness of your quest", Text_Yell, NULL);
			RemoveTimer(DomoSayTimer1);
		}
		
		if(GetPhase() == 2 && IsTimerFinished(DomoSayTimer2))
		{
			Emote("I go now to summon the lord whose house this is. Should you seek an audience with him, your paltry lives will surely be forfeit! Nevertheless, seek out his lair, if you dare!", Text_Yell, NULL);
			RemoveTimer(DomoSayTimer2);
		}
		
		if(GetPhase() == 2 && IsTimerFinished(DomoTeleportTimer3))
		{
			_unit->SetPosition(838.719971f, -830.810974f, -232.095001f, 2.870590f);
			RemoveTimer(DomoTeleportTimer3);
		}
		
			
		ParentClass::AIUpdate();
	}
コード例 #19
0
ファイル: watchdog.cpp プロジェクト: azwing/indi
bool WatchDog::Disconnect()
{
    if (watchDogTimer > 0)
    {
        RemoveTimer(watchDogTimer);
        LOG_INFO("Watchdog is disabled.");
    }

    shutdownStage = WATCHDOG_IDLE;

    return true;
}
コード例 #20
0
void CLuaTimerManager::DoPulse ( CLuaMain* pLuaMain )
{
    assert ( m_ProcessQueue.empty () );
    assert ( !m_pPendingDelete );
    assert ( !m_pProcessingTimer );

    CTickCount llCurrentTime = CTickCount::Now ();

    // Use a separate queue to avoid trouble
    for ( CFastList < CLuaTimer* > ::const_iterator iter = m_TimerList.begin () ; iter != m_TimerList.end () ; iter++ )
        m_ProcessQueue.push_back ( *iter );

    while ( !m_ProcessQueue.empty () )
    {
        m_pProcessingTimer = m_ProcessQueue.front ();
        m_ProcessQueue.pop_front ();

        CTickCount llStartTime = m_pProcessingTimer->GetStartTime ();
        CTickCount llDelay = m_pProcessingTimer->GetDelay ();
        unsigned int uiRepeats = m_pProcessingTimer->GetRepeats ();

        // Is the time up and is not being deleted
        if ( llCurrentTime >= ( llStartTime + llDelay ) )
        {
            m_pProcessingTimer->ExecuteTimer ( pLuaMain );

            // If this is the last repeat, remove
            if ( uiRepeats == 1 )
            {
                RemoveTimer ( m_pProcessingTimer );
            }
            else
            {
                // Decrease repeats if not infinite
                if ( uiRepeats != 0 )
                    m_pProcessingTimer->SetRepeats ( uiRepeats - 1 );

                m_pProcessingTimer->SetStartTime ( llCurrentTime );
            }
        }

        // Finally cleanup timer if it was removed during processing
        if ( m_pPendingDelete )
        {
            assert ( m_pPendingDelete == m_pProcessingTimer );
            m_pProcessingTimer = NULL;
            delete m_pPendingDelete;
            m_pPendingDelete = NULL;
        }
        else
            m_pProcessingTimer = NULL;
    }
}
コード例 #21
0
ファイル: Instance_Deadmines.cpp プロジェクト: Nupper/AscEmu
        void OnCombatStop(Unit* pTarget)
        {
            if (GetPhase() == 4)
                RemoveAura(SMITES_HAMMER);
            if (!IsAlive())
                SetWieldWeapon(false);

            SetPhase(1);
            SwitchWeapons();
            RemoveTimer(mWaitAtChest);
            ParentClass::OnCombatStop(pTarget);
        }
コード例 #22
0
CPhysicalLinkHelper::~CPhysicalLinkHelper()
	{
	LOG_FUNC
	
	RemoveTimer();
	delete iBTProxySAP;
	
	if (iEventReceivedCallBack)
		{
		iEventReceivedCallBack->Cancel();
		delete iEventReceivedCallBack;
		}
	}
コード例 #23
0
ファイル: indiweather.cpp プロジェクト: geehalel/indi
bool Weather::ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n)
{
    //  first check if it's for our device
    if (dev != nullptr && strcmp(dev, getDeviceName()) == 0)
    {
        if (strcmp(name, "GEOGRAPHIC_COORD") == 0)
        {
            int latindex       = IUFindIndex("LAT", names, n);
            int longindex      = IUFindIndex("LONG", names, n);
            int elevationindex = IUFindIndex("ELEV", names, n);

            if (latindex == -1 || longindex == -1 || elevationindex == -1)
            {
                LocationNP.s = IPS_ALERT;
                IDSetNumber(&LocationNP, "Location data missing or corrupted.");
            }

            double targetLat  = values[latindex];
            double targetLong = values[longindex];
            double targetElev = values[elevationindex];

            return processLocationInfo(targetLat, targetLong, targetElev);
        }

        // Update period
        if (strcmp(name, "WEATHER_UPDATE") == 0)
        {
            IUUpdateNumber(&UpdatePeriodNP, values, names, n);

            UpdatePeriodNP.s = IPS_OK;
            IDSetNumber(&UpdatePeriodNP, nullptr);

            if (UpdatePeriodN[0].value == 0)
                DEBUG(Logger::DBG_SESSION, "Periodic updates are disabled.");
            else
            {
                if (updateTimerID > 0)
                    RemoveTimer(updateTimerID);

                updateTimerID = SetTimer(UpdatePeriodN[0].value * 1000);
            }
            return true;
        }

        // Pass to weather interface
        if (processNumber(dev, name, values, names, n))
            return true;
    }

    return DefaultDevice::ISNewNumber(dev, name, values, names, n);
}
コード例 #24
0
		void AIUpdate()
		{
			if(IsTimerFinished(mNovaTimer))
			{
				switch(RandomUInt(2))
				{
					case 0:
						Emote("You cannot hide from fate!",			Text_Yell,	14163);
						break;
					case 1:
						Emote("Come closer. I will make it quick.",	Text_Yell,	14164);
						break;
					case 2:
						Emote("Your flesh cannot hold out for long.",	Text_Yell,	14165);
						break;
				};

				Announce("Loken begins to cast Lightning Nova!");
				CastSpellNowNoScheduling(mNova);
				ResetTimer(mNovaTimer, TIMER_NOVA + (RandomUInt(8) * 1000));
			};

			if(mSpeech == 4)
				return;

			if(GetHealthPercent() <= (100 - (25 * mSpeech)))
			{
				switch(mSpeech)
				{
					case 1:
						Emote("You stare blindly into the abyss!",	                                    Text_Yell, 14169);
						break;
					case 2:
						Emote("Your ignorance is profound. Can you not see where this path leads?",    Text_Yell, 14170);
						break;
					case 3:
						Emote("You cross the precipice of oblivion!",                                  Text_Yell, 14171);
						break;
						++mSpeech;
				};
			};

			if(IsTimerFinished(mRespondTimer))
			{
				Emote("My master has shown me the future, and you have no place in it. Azeroth will be reborn in darkness. Yogg-Saron shall be released! The Pantheon shall fall!", Text_Yell, 14161);
				RemoveTimer(mRespondTimer);
				RemoveAIUpdateEvent();
			};

			ParentClass::AIUpdate();
		};
コード例 #25
0
ファイル: Quest_ShadowMoon.cpp プロジェクト: lev1976g/easywow
 void AIUpdate()
 {
     if(IsTimerFinished(mRazuunTimer))
     {
         switch(mRazuunPhase)
         {
             case 0:
                 {
                     _unit->Emote(EMOTE_ONESHOT_TALK);
                     _unit->SendChatMessage(CHAT_MSG_MONSTER_SAY, LANG_UNIVERSAL, "Doom Lord Kazzak will be pleased. You are to increase the pace of your attacks. Destroy the orcish and dwarven strongholds with all haste.");
                     mRazuunPhase = 1;
                     ResetTimer(mRazuunTimer, 9000);
                 }
                 break;
             case 1:
                 {
                     _unit->Emote(EMOTE_ONESHOT_TALK);
                     _unit->SendChatMessage(CHAT_MSG_MONSTER_SAY, LANG_UNIVERSAL, "Don't worry about that. I've increased production at the Deathforge. You'll have all the infernals you need to carry out your orders. Don't fail, Jovaan.");
                     mRazuunPhase = 2;
                     ResetTimer(mRazuunTimer, 15000);
                 }
                 break;
             case 2:
                 {
                     _unit->Emote(EMOTE_ONESHOT_QUESTION);
                     _unit->SendChatMessage(CHAT_MSG_MONSTER_SAY, LANG_UNIVERSAL, "Yes?");
                     mRazuunPhase = 3;
                     ResetTimer(mRazuunTimer, 8000);
                 }
                 break;
             case 3:
                 {
                     _unit->Emote(EMOTE_ONESHOT_QUESTION);
                     _unit->SendChatMessage(CHAT_MSG_MONSTER_SAY, LANG_UNIVERSAL, "Crate? I didn't send you a crate, Jovaan. Don't you have more important things to worry about? Go see to them!");
                     mRazuunPhase = 4;
                     ResetTimer(mRazuunTimer, 5000);
                 }
                 break;
             case 4:
                 {
                     mRazuunPhase = -1;
                     RemoveTimer(mRazuunTimer);
                     Despawn(0, 0);
                     return;
                 }
                 break;
         }
     }
     ParentClass::AIUpdate();
 }
コード例 #26
0
FILEMONITOR_PROC( void, EndMonitor )( PMONITOR monitor )
{
	if( !monitor )
		return;
	if( monitor->flags.bDispatched || monitor->flags.bScanning )
	{
		monitor->flags.bEnd = 1;
		return;
	}
	if( monitor->flags.bClosing )
	{
		if( l.flags.bLog ) Log( WIDE("Monitor already closing...") );
		return;
	}
	EnterCriticalSec( &monitor->cs );
	monitor->flags.bClosing = 1;
	monitor->flags.bRemoveFromEvents = 1;

	if( !monitor->flags.bRemovedFromEvents )
	{
		SetEvent( l.hMonitorThreadControlEvent );
		while( !monitor->flags.bRemovedFromEvents )
			Relinquish();
	}
	//Log1( WIDE("Closing the monitor on %s and killing thread...")
	//    , monitor->directory );
	if( monitor->hChange != INVALID_HANDLE_VALUE )
	{
		lprintf( WIDE( "close ntoification (wakes thread?" ) );
		FindCloseChangeNotification( monitor->hChange );
		lprintf( WIDE( "and then we wait..." ) );
	}
	monitor->hChange = INVALID_HANDLE_VALUE;
	{
		uint32_t tick = timeGetTime();
		while( monitor->pThread && ( ( tick+50 ) > timeGetTime() ) )
			Relinquish();
	}
	if( monitor->pThread )
	{
		EndThread( monitor->pThread );
	}
	//else
	//	Log( WIDE("Thread already left...") );
	CloseFileMonitors( monitor );
	RemoveTimer( monitor->timer );
	UnlinkThing( monitor );
	LeaveCriticalSec( &monitor->cs );
	Release( monitor );
}
コード例 #27
0
ファイル: Script.c プロジェクト: TheBlackJokerDevil/openclonk
func StartFloating()
{
	RemoveTimer("Seed");
	SetAction("Idle");
	this.Collectible = 1;
	this.NutritionalValue = this.NutritionalValue_;
	
	for (var attachment in mesh_attachments)
		DetachMesh(attachment);
	for (var obj in FindObjects(Find_Container(this)))
	{
		obj->Exit();
		obj->StartFloating();
	}
}
コード例 #28
0
ファイル: watchdog.cpp プロジェクト: azwing/indi
bool WatchDog::ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n)
{
    if (dev != nullptr && strcmp(dev, getDeviceName()) == 0)
    {
        if (!strcmp(HeartBeatNP.name, name))
        {
            double prevHeartBeat = HeartBeatN[0].value;

            if (watchdogClient->isBusy())
            {
                HeartBeatNP.s = IPS_ALERT;
                IDSetNumber(&HeartBeatNP, nullptr);
                LOG_ERROR("Cannot change heart beat while shutdown is in progress...");
                return true;
            }

            IUUpdateNumber(&HeartBeatNP, values, names, n);
            HeartBeatNP.s = IPS_OK;

            if (HeartBeatN[0].value == 0)
                LOG_INFO("Watchdog is disabled.");
            else
            {
                if (isConnected())
                {
                    if (prevHeartBeat != HeartBeatN[0].value)
                        DEBUGF(INDI::Logger::DBG_SESSION,
                               "Watchdog is enabled. Shutdown is triggered after %g minutes of communication loss with "
                               "the client.",
                               HeartBeatN[0].value);

                    LOG_DEBUG("Received heart beat from client.");

                    RemoveTimer(watchDogTimer);
                    watchDogTimer = SetTimer(HeartBeatN[0].value * 60 * 1000);
                }
                else
                    LOG_INFO("Watchdog is armed. Please connect to enable it.");
            }

            IDSetNumber(&HeartBeatNP, nullptr);

            return true;
        }
    }

    return DefaultDevice::ISNewNumber(dev, name, values, names, n);
}
コード例 #29
0
ファイル: indiweather.cpp プロジェクト: azwing/indi
void Weather::TimerHit()
{
    if (!isConnected())
        return;

    if (updateTimerID > 0)
        RemoveTimer(updateTimerID);

    IPState state = updateWeather();

    // Override weather state if required
    if (OverrideS[0].s == ISS_ON)
        state = IPS_OK;

    switch (state)
    {
        // Ok
        case IPS_OK:

            syncCriticalParameters();

            if (OverrideS[0].s == ISS_ON)
                critialParametersLP.s = IPS_OK;

            ParametersNP.s = state;
            IDSetNumber(&ParametersNP, nullptr);

            // If update period is set, then set up the timer
            if (UpdatePeriodN[0].value > 0)
                updateTimerID = SetTimer(static_cast<int>(UpdatePeriodN[0].value * 1000));

            return;

        // Alert
        // We retry every 5000 ms until we get OK
        case IPS_ALERT:
            ParametersNP.s = state;
            IDSetNumber(&ParametersNP, nullptr);
            break;

        // Weather update is in progress
        default:
            break;
    }

    updateTimerID = SetTimer(5000);
}
コード例 #30
0
	void AIUpdate()
	{
		if(IsTimerFinished(mRessTimer))
		{
			SetPhase(2);
			
			_unit->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
			_unit->SetUInt32Value(UNIT_FIELD_DISPLAYID, 26351);
			_unit->SetUInt32Value(UNIT_FIELD_HEALTH,_unit->GetUInt32Value(UNIT_FIELD_MAXHEALTH));
			_unit->setDeathState(ALIVE);
			_unit->WipeTargetList();
			_unit->WipeHateList();
		
			Emote("I return! A second chance to carve out your skull!", Text_Yell, 13209);
			RemoveTimer(mRessTimer);
		}
	}