bool Flow::idle() { /* If this flow is idle for at least MAX_TCP_FLOW_IDLE */ if((protocol == IPPROTO_TCP) && ((tcp_flags & TH_FIN) || (tcp_flags & TH_RST)) && isIdle(MAX_TCP_FLOW_IDLE /* sec */)) { /* ntop->getTrace()->traceEvent(TRACE_NORMAL, "[TCP] Early flow expire"); */ return(true); } return(isIdle(ntop->getPrefs()->get_host_max_idle())); };
// ----------------------------------------------------------------- // Name : checkConditions // ----------------------------------------------------------------- bool AI::checkConditions(JoS_Element& listConditions) { bool bMatchConditions = true; for (int j = 0; j < listConditions.size(); j++) { string condition = listConditions[j].toString(); // "bang" will be xored with the state function // example: // For condition "idle", match = bang XOR isIdle = 0 ^ isIdle = isIdle // For condition "!idle", match = bang XOR isIdle = 1 ^ isIdle = !isIdle bool bang = false; if (condition[0] == '!') { bang = true; condition = condition.substr(1); } if (condition == DIALOG_CONDITION_IDLE) { bMatchConditions &= (bang^isIdle()); } else if (condition == DIALOG_CONDITION_STARVING) { bMatchConditions &= (bang^isStarving()); } else if (condition == DIALOG_CONDITION_HUNGRY) { bMatchConditions &= (bang^isHungry()); } else if (condition == DIALOG_CONDITION_TIRED) { bMatchConditions &= (bang^isTired()); } } return bMatchConditions; }
void afLib::loop(void) { if (isIdle() && (queueGet(&_request.messageType, &_request.requestId, &_request.attrId, &_request.valueLen, &_request.p_value) == afSUCCESS)) { switch (_request.messageType) { case MSG_TYPE_GET: doGetAttribute(_request.requestId, _request.attrId); break; case MSG_TYPE_SET: doSetAttribute(_request.requestId, _request.attrId, _request.valueLen, _request.p_value); break; case MSG_TYPE_UPDATE: doUpdateAttribute(_request.requestId, _request.attrId, 0, _request.valueLen, _request.p_value); break; default: _theLog->println("loop: request type!"); } } if (_request.p_value != NULL) { delete (_request.p_value); _request.p_value = NULL; } checkInterrupt(); }
int Fpc1020Sensor::getEnrolledIds(android::Vector<uint32_t>& ids) { if (!isIdle()) { return -EINVAL; } ALOGV("getEnrolledIds()"); int ret = activate(false); if (ret) { return ret; } ret = sendCommand(CLIENT_CMD_GET_IDS_LIST); if (ret == 0) { fingerprint_get_ids_list_rsp_t *resp = (fingerprint_get_ids_list_rsp_t *) mQseecom.getReceiveBuffer(); ALOGD("getEnrolledIds(): result %d, count %d", resp->result, resp->count); if (resp->result == 0) { for (uint32_t i = 0; i < resp->count; i++) { ids.push_back(resp->ids[i]); } } } deactivate(); return ret; }
void NPC::update (uint32_t deltaTime) { IEntity::update(deltaTime); if (isDying()) return; if (_dazedTime > 0 && _time - _dazedTime > _dazedTimeout) { if (_lastDirectionRight) setAnimationType(Animations::ANIMATION_WAKEUP_RIGHT); else setAnimationType(Animations::ANIMATION_WAKEUP_LEFT); const int length = SpriteDefinition::get().getAnimationLength(_type, getAnimationType()); if (length > 0) { TimeManager& t = _map.getTimeManager(); _idleTimer = t.setTimeout(length, this, &NPC::setIdle); } _dazedTime = 0; } if (isMoving()) { const float xPos = getPos().x; static const float gap = 0.1f; if (Between(xPos, _targetPos.x - gap, _targetPos.x + gap)) { // target reached setIdle(); } } else if (isDazed() || isIdle()) { setLinearVelocity(b2Vec2_zero); } }
void NPCPackage::update (uint32_t deltaTime) { INPCCave::update(deltaTime); if (isIdle() && !returnToInitialPosition()) leavePackage(); if (getCave()->moveBackIntoCave()) { Log::info(LOG_SERVER, "npc %i moved back into cave, remove from world", getID()); _remove = true; } }
// // Detach an attachment. // This is the polite way to detach from the plugin. It may be refused safely // (though perhaps not meaningfully). // THREADS: mLock is locked on entry IFF isLocked, and will be unlocked on exit. // void Attachment::detach(bool isLocked) { StLock<Mutex> locker(*this, isLocked); // pre-state locker locker.lock(); // make sure it's locked if (mIsActive) { if (!isIdle()) CssmError::throwMe(CSSM_ERRCODE_FUNCTION_FAILED); //@#attachment busy if (CSSM_RETURN error = module.plugin->detach(handle())) CssmError::throwMe(error); // I'm sorry Dave, ... secdebug("cssm", "%p detach module %p(%s)", this, &module, module.name().c_str()); mIsActive = false; module.detach(this); } }
int Fpc1020Sensor::startAuthentication(bool inWakeupMode) { if (!isIdle()) { return -EINVAL; } ALOGV("startAuthentication(%d)", inWakeupMode); int ret = activate(true); if (ret) { return ret; } mThread = new AuthenticationThread(this); mWaitingForWakeup = inWakeupMode; mThread->run("FingerprintAuthentication"); ALOGD("State machine now in authentication state"); return 0; }
int Fpc1020Sensor::removeId(uint32_t id) { if (!isIdle()) { return -EINVAL; } ALOGV("removeId(%d)", id); int ret = activate(false); if (ret) { return ret; } fingerprint_delete_cmd_t *req = (fingerprint_delete_cmd_t *) mQseecom.getSendBuffer(); req->id = id; ret = sendCommand(CLIENT_CMD_REMOVE_ID); deactivate(); return ret; }
bool CastCommandState::startCast() { if( ! isIdle() ) return false; m_state = CCS_CASTING; m_timeStart = CastCommandTime::get(); m_channelTicks = 0; if( m_pModel->castTime == 0 ) { //handle instant cast onSchedulerTick(0.0f); }else { //TODO: should we set castTime as delay instead of interval? CastCommandScheduler::get()->scheduleSelector( schedule_selector(CastCommandState::onSchedulerTick), this, m_pModel->castTime, 0, 0.0f, false); } return true; }
int Fpc1020Sensor::startEnrollment(unsigned int timeout) { if (!isIdle()) { return -EINVAL; } ALOGV("startEnrollment(%d)", timeout); int ret = activate(true); if (ret) { return ret; } if (timeout) { mTimeoutWatchdog = new TimeoutWatchdogThread(this, timeout); mTimeoutWatchdog->run("FingerprintTimeout"); } mThread = new EnrollmentThread(this); mThread->run("FingerprintEnrollment"); ALOGD("State machine now in enrollment state"); return 0; }
bool Npc::getNextStep(Direction& dir) { if(Creature::getNextStep(dir)){ return true; } if(walkTicks <= 0){ return false; } if (hasWalkDelay()) { return false; } if(!isIdle() || focusCreature != 0){ return false; } if(getTimeSinceLastMove() < walkTicks){ return false; } return getRandomStep(dir); }
bool StringHost::idle() { return(isIdle(ntop->getPrefs()->get_host_max_idle())); };
bool RUser::isInactive() { return isIdle() && (elapsed - last_action) > 10.0; }
bool RUser::isFading() { return isIdle() && (elapsed - last_action) > gGourceSettings.user_idle_time; }
bool PlayerTaskWin::run() { if (!isIdle()) { CCLOG("PlayerTaskWin::run() - task is not idle"); return false; } //BOOL WINAPI CreateProcess( // _In_opt_ LPCTSTR lpApplicationName, // _Inout_opt_ LPTSTR lpCommandLine, // _In_opt_ LPSECURITY_ATTRIBUTES lpProcessAttributes, // _In_opt_ LPSECURITY_ATTRIBUTES lpThreadAttributes, // _In_ BOOL bInheritHandles, // _In_ DWORD dwCreationFlags, // _In_opt_ LPVOID lpEnvironment, // _In_opt_ LPCTSTR lpCurrentDirectory, // _In_ LPSTARTUPINFO lpStartupInfo, // _Out_ LPPROCESS_INFORMATION lpProcessInformation //); // http://msdn.microsoft.com/en-us/library/windows/desktop/ms682499(v=vs.85).aspx SECURITY_ATTRIBUTES sa = {0}; sa.nLength = sizeof(sa); sa.bInheritHandle = TRUE; // Create a pipe for the child process's STDOUT. if (!CreatePipe(&_childStdOutRead, &_childStdOutWrite, &sa, 0) || !SetHandleInformation(_childStdOutRead, HANDLE_FLAG_INHERIT, 0)) { CCLOG("PlayerTaskWin::run() - create stdout handle failed, for execute %s", _executePath.c_str()); cleanup(); return false; } // Create a pipe for the child process's STDIN. if (!CreatePipe(&_childStdInRead, &_childStdInWrite, &sa, 0) || !SetHandleInformation(_childStdInWrite, HANDLE_FLAG_INHERIT, 0)) { CCLOG("PlayerTaskWin::run() - create stdout handle failed, for execute %s", _executePath.c_str()); cleanup(); return false; } ZeroMemory(&_pi, sizeof(_pi)); STARTUPINFO si = {0}; si.cb = sizeof(STARTUPINFO); si.hStdError = _childStdOutWrite; si.hStdOutput = _childStdOutWrite; si.hStdInput = _childStdInRead; si.dwFlags = STARTF_USESHOWWINDOW | STARTF_USESTDHANDLES; si.wShowWindow = SW_HIDE; #define MAX_COMMAND 4096 //MAX_PATH const std::u16string u16command = makeCommandLine(); WCHAR command[MAX_COMMAND]; wcscpy_s(command, MAX_COMMAND, (WCHAR*)u16command.c_str()); BOOL success = CreateProcess(NULL, command, // command line NULL, // process security attributes NULL, // primary thread security attributes TRUE, // handles are inherited 0, // creation flags NULL, // use parent's environment NULL, // use parent's current directory &si, // STARTUPINFO pointer &_pi); // receives PROCESS_INFORMATION if (!success) { CCLOG("PlayerTaskWin::run() - create process failed, for execute %s", _executePath.c_str()); cleanup(); return false; } _outputBuff = new CHAR[BUFF_SIZE + 1]; _outputBuffWide = new WCHAR[BUFF_SIZE]; _state = STATE_RUNNING; cocos2d::Director::getInstance()->getScheduler()->scheduleUpdate(this, 0, false); return true; }