Foam::automatic::automatic ( const dictionary& cellSizeCalcTypeDict, const triSurfaceMesh& surface, const scalar& defaultCellSize ) : cellSizeCalculationType ( typeName, cellSizeCalcTypeDict, surface, defaultCellSize ), coeffsDict_(cellSizeCalcTypeDict.subDict(typeName + "Coeffs")), surfaceName_(surface.searchableSurface::name()), readCurvature_(Switch(coeffsDict_.lookup("curvature"))), curvatureFile_(coeffsDict_.lookup("curvatureFile")), readFeatureProximity_(Switch(coeffsDict_.lookup("featureProximity"))), featureProximityFile_(coeffsDict_.lookup("featureProximityFile")), readInternalCloseness_(Switch(coeffsDict_.lookup("internalCloseness"))), internalClosenessFile_(coeffsDict_.lookup("internalClosenessFile")), curvatureCellSizeCoeff_ ( readScalar(coeffsDict_.lookup("curvatureCellSizeCoeff")) ), maximumCellSize_ ( readScalar(coeffsDict_.lookup("maximumCellSizeCoeff"))*defaultCellSize ) {}
int Partition(int a[], int low, int high) { int pk = a[low]; while (low < high) { while (low<high && (a[high]>pk))high--; Switch(&a[low], &a[high]); while (low < high && (a[low] < pk))low++; Switch(&a[low], &a[high]); } return low; }
//------------------------------------------------------------------------------------------------ bool Person::PickUp(GunObject* gunobject) { if (gunobject->mGun->mType == PRIMARY) { if (mGuns[PRIMARY] == NULL) { mGuns[PRIMARY] = gunobject; gunobject->mOnGround = false; /*if (mState == RELOADING) { SetState(NORMAL); if (mSoundId != -1) { mSoundSystem->StopSample(mSoundId); mSoundId = -1; } } mGunIndex = PRIMARY;*/ Switch(PRIMARY); gSfxManager->PlaySample(gPickUpSound, mX, mY); return true; } } else if (gunobject->mGun->mType == SECONDARY) { if (mGuns[SECONDARY] == NULL) { mGuns[SECONDARY] = gunobject; gunobject->mOnGround = false; if (mGuns[PRIMARY] == NULL) { //mGunIndex = SECONDARY; Switch(SECONDARY); } gSfxManager->PlaySample(gPickUpSound, mX, mY); return true; } } else if (gunobject->mGun->mType == KNIFE) { if (mGuns[KNIFE] == NULL) { mGuns[KNIFE] = gunobject; gunobject->mOnGround = false; return true; } } else if (gunobject->mGun->mType == GRENADE) { if (mGuns[GRENADE] == NULL) { mGuns[GRENADE] = gunobject; gunobject->mOnGround = false; if (mGuns[PRIMARY] == NULL && mGuns[SECONDARY] == NULL) { //mGunIndex = GRENADE; Switch(GRENADE); } gSfxManager->PlaySample(gPickUpSound, mX, mY); return true; } } return false; }
void simnet() { Signal a, b, c, d, F; // Switch and output objects Switch ( SD("1a"), a, 'a' ); // Switch a controlled by 'a' key Switch ( SD("2a"), b, 'b' ); // Switch b controlled by 'b' key Switch ( SD("3a"), c, 'c' ); // Switch c controlled by 'c' key Switch ( SD("4a"), d, 'd' ); // Switch d controlled by 'd' key circuit( SD("1c-4c"), a, b, c, d, F ); Probe ( (SD("2e"), "F"), F ); // Probe }
// Construct from components writeLiggghts::writeLiggghts ( const dictionary& dict, cfdemCloud& sm, int i ) : liggghtsCommandModel(dict,sm,i), propsDict_(dict), command_("write_restart"), path_(word("..")/word("DEM")), writeName_("liggghts.restartCFDEM"), writeLast_(true), overwrite_(true) { if (dict.found(typeName + "Props")) { propsDict_=dictionary(dict.subDict(typeName + "Props")); // check if verbose if (propsDict_.found("verbose")) verbose_=true; if(propsDict_.found("writeLast")) { writeLast_=Switch(propsDict_.lookup("writeLast")); } if (!writeLast_ && propsDict_.found("overwrite")) { overwrite_=Switch(propsDict_.lookup("overwrite")); } } if(writeLast_) runLast_=true; else { //Warning << "Using invalid options of writeLiggghts, please use 'writeLast' option." << endl; runEveryWriteStep_=true; } command_ += " " + path_ + "/" + writeName_; if(overwrite_) strCommand_=string(command_); else command_ += "_"; Info << "writeLiggghts: A restart file writeName_"<< command_ <<" is written." << endl; checkTimeSettings(dict_); }
//------------------------------------------------------------------------------------------------ bool Person::Drop(int index, float speed) { if (index >= 5) return false; if (index == KNIFE) return false; GunObject* gunobject = mGuns[index]; if (gunobject == NULL) return false; /*if (mState == RELOADING) { SetState(NORMAL); if (mSoundId != -1) { mSoundSystem->StopSample(mSoundId); mSoundId = -1; } }*/ gunobject->mX = mX; gunobject->mY = mY; gunobject->mOldX = mX; gunobject->mOldY = mY; gunobject->mRotation = mRotation; gunobject->mAngle = mFacingAngle; gunobject->mSpeed = speed; gunobject->mOnGround = false; mGunObjects->push_back(gunobject); mGuns[index] = NULL; if (mGuns[PRIMARY] != NULL) { //mGunIndex = PRIMARY; Switch(PRIMARY); } else if (mGuns[SECONDARY] != NULL) { //mGunIndex = SECONDARY; Switch(SECONDARY); } else if (mGuns[GRENADE] != NULL) { //mGunIndex = GRENADE; Switch(GRENADE); } else if (mGuns[KNIFE] != NULL) { //mGunIndex = KNIFE; Switch(KNIFE); } //mRecoilAngle = 0.0f; //mNumDryFire = 0; return true; }
// Construct from components polyStateController::polyStateController ( Time& t, polyMoleculeCloud& molCloud, const dictionary& dict ) : mesh_(refCast<const fvMesh>(molCloud.mesh())), molCloud_(molCloud), // controllerDict_(dict.subDict("controllerProperties")), time_(t), regionName_(dict.lookup("zoneName")), regionId_(-1), control_(true), controlInterForces_(false), writeInTimeDir_(true), writeInCase_(true) { const cellZoneMesh& cellZones = mesh_.cellZones(); regionId_ = cellZones.findZoneID(regionName_); if(regionId_ == -1) { FatalErrorIn("polyStateController::polyStateController()") << "Cannot find region: " << regionName_ << nl << "in: " << time_.time().system()/"controllersDict" << exit(FatalError); } if(dict.found("control")) { control_ = Switch(dict.lookup("control")); } // readStateFromFile_ = Switch(dict.lookup("readStateFromFile")); }
int main (void) { uint8_t no = 0; // wait(10); setMU2PutFunc(uart0Put); setMU2GetFunc(uart0Get); initUART( UART0, StopBitIs1Bit|NonParity, ReceiverEnable|TransmiterEnable|ReceiveCompleteInteruptEnable, UARTBAUD(19200) ); initLED(); initSwitch(); initRCRx(); no = Switch() & 0x03; mu2Command("EI",EI[no]); mu2Command("DI",DI[no]); mu2Command("GI",GI[no]); mu2Command("CH",CH[no]); sei(); userMain(); return 0; }
bool CTabBarClass::OnKeyboard(UINT messg, WPARAM wParam, LPARAM lParam) { //if (!IsShown()) return FALSE; -- всегда. Табы теперь есть в памяти BOOL lbAltPressed = isPressed(VK_MENU); if (messg == WM_KEYDOWN && wParam == VK_TAB) { if (!isPressed(VK_SHIFT)) SwitchNext(lbAltPressed); else SwitchPrev(lbAltPressed); return true; } else if (mb_InKeySwitching && messg == WM_KEYDOWN && !lbAltPressed && (wParam == VK_UP || wParam == VK_DOWN || wParam == VK_LEFT || wParam == VK_RIGHT)) { bool bRecent = gpSet->isTabRecent; gpSet->isTabRecent = false; BOOL bForward = (wParam == VK_RIGHT || wParam == VK_DOWN); Switch(bForward); gpSet->isTabRecent = bRecent; return true; } return false; }
eOSState cMenuAnnounceList::ProcessKey(eKeys Key) { eOSState state = cMenuSearchResultsForList::ProcessKey(Key); if (state == osUnknown) { switch (Key) { case kBlue: { cMenuSearchResultsItem *item = (cMenuSearchResultsItem *)Get(Current()); if (item) { if (!HasSubMenu()) return AddSubMenu(new cMenuAnnounceDetails(item->event, item->search)); else if (!showsDetails) return Switch(); else return osContinue; } } break; default: break; } } return state; }
CString CCommandLineParameters::GetSwitchStr(const char *sz, const char *szDefault, /* = "" */ const BOOL bCase /* = FALSE */ ) { int idx = Switch(sz,bCase); if (idx > 0) { CString s = ParamStr(idx); int n = s.Find(':'); if (n > -1) { CString ts = s.Mid(n + 1); ts.Replace("\"", ""); return ts; // return s.Mid(n+1); } // else { // if ((idx+1) < paramcount) { // if (!IsSwitch(parms[idx+1])) { // return parms[idx+1]; // } // } // } //return szDefault; } return szDefault; }
Foam::LambertWall<CloudType>::LambertWall ( const dictionary& dict, CloudType& cloud, const scalar& surfaceTension, const scalar& contactAngle, const scalar& liqFrac, const scalar& viscosity, const scalar& minSep ) : PendularWallModel<CloudType> ( dict, cloud, typeName, surfaceTension, contactAngle, liqFrac, viscosity, minSep ), useEquivalentSize_(Switch(this->coeffDict().lookup("useEquivalentSize"))) { if (useEquivalentSize_) { volumeFactor_ = readScalar(this->coeffDict().lookup("volumeFactor")); } }
virtual ResultExpr ClonePolicy() const { // Allow use for simple thread creation (pthread_create) only. // WARNING: s390 and cris pass the flags in the second arg -- see // CLONE_BACKWARDS2 in arch/Kconfig in the kernel source -- but we // don't support seccomp-bpf on those archs yet. Arg<int> flags(0); // The glibc source hasn't changed the thread creation clone flags // since 2004, so this *should* be safe to hard-code. Bionic's // value has changed a few times, and has converged on the same one // as glibc; allow any of them. static const int flags_common = CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_SIGHAND | CLONE_THREAD | CLONE_SYSVSEM; static const int flags_modern = flags_common | CLONE_SETTLS | CLONE_PARENT_SETTID | CLONE_CHILD_CLEARTID; // Can't use CASES here because its decltype magic infers const // int instead of regular int and bizarre voluminous errors issue // forth from the depths of the standard library implementation. return Switch(flags) #ifdef ANDROID .Case(flags_common | CLONE_DETACHED, Allow()) // <= JB 4.2 .Case(flags_common, Allow()) // JB 4.3 or KK 4.4 #endif .Case(flags_modern, Allow()) // Android L or glibc .Default(InvalidSyscall()); }
// updated current script bool Scripts::Update(Controller& ctrl, float elapsedTime) { // if script is done, switch script if (! _scripts[_current]->Update(ctrl, elapsedTime)) return Switch(); return true; }
eOSState cMenuSearchResultsForBlacklist::ProcessKey(eKeys Key) { eOSState state = cMenuSearchResults::ProcessKey(Key); if (state == osUnknown) { switch (Key) { case k1...k9: state = HasSubMenu()?osContinue:Commands(Key); break; case kRecord: case kRed: state = OnRed(); break; case kBlue: if (HasSubMenu()) state = Switch(); else state = osContinue; break; default: break; } } return state; }
initialPointsMethod::initialPointsMethod ( const word& type, const dictionary& initialPointsDict, const Time& runTime, Random& rndGen, const conformationSurfaces& geometryToConformTo, const cellShapeControl& cellShapeControls, const autoPtr<backgroundMeshDecomposition>& decomposition ) : dictionary(initialPointsDict), runTime_(runTime), rndGen_(rndGen), geometryToConformTo_(geometryToConformTo), cellShapeControls_(cellShapeControls), decomposition_(decomposition), detailsDict_(subDict(type + "Coeffs")), minimumSurfaceDistanceCoeffSqr_ ( sqr ( readScalar ( initialPointsDict.lookup("minimumSurfaceDistanceCoeff") ) ) ), fixInitialPoints_(Switch(initialPointsDict.lookup("fixInitialPoints"))) {}
short AwaitEvent(int EventClass) { Pause(); CurrentTask->Value.RegisteredEvents|=EventClass; Resume(); Switch(); return CurrentTask->Value.EventId; }
void GameTile::Update() { if(oldStatus != Status) Switch(); if(Front->Rotation->z > 0.001f || Front->Rotation->z < -0.001f || rotVec > 0.001f || rotVec < -0.001f || PositionOld != Position) { rotVec += -Front->Rotation->z * 0.007f; rotVec *= 0.9f; Front->Rotation->z += rotVec; *Front->Position = vec3(Position.x*2.0f,0.0f,Position.y*2.0f); Front->Update(); Back->Rotation->z = Front->Rotation->z + 0.5f; *Back->Position = *Front->Position; Back->Update(); PositionOld = Position; } }
void serialCallBack(Stream& stream, char arrivedChar, unsigned short availableCharsCount) { if (arrivedChar == '\n') { char str[availableCharsCount]; for (int i = 0; i < availableCharsCount; i++) { str[i] = stream.read(); if (str[i] == '\r' || str[i] == '\n') { str[i] = '\0'; } } if (!strcmp(str, "connect")) { // connect to wifi WifiStation.config(WIFI_SSID, WIFI_PWD); WifiStation.enable(true); } else if (!strcmp(str, "ip")) { Serial.printf("ip: %s mac: %s\r\n", WifiStation.getIP().toString().c_str(), WifiStation.getMAC().c_str()); } else if (!strcmp(str, "ota")) { OtaUpdate(); } else if (!strcmp(str, "switch")) { Switch(); } else if (!strcmp(str, "restart")) { System.restart(); } else if (!strcmp(str, "ls")) { Vector<String> files = fileList(); Serial.printf("filecount %d\r\n", files.count()); for (unsigned int i = 0; i < files.count(); i++) { Serial.println(files[i]); } } else if (!strcmp(str, "cat")) { Vector<String> files = fileList(); if (files.count() > 0) { Serial.printf("dumping file %s:\r\n", files[0].c_str()); Serial.println(fileGetContent(files[0])); } else { Serial.println("Empty spiffs!"); } } else if (!strcmp(str, "info")) { ShowInfo(); } else if (!strcmp(str, "help")) { Serial.println(); Serial.println("available commands:"); Serial.println(" help - display this message"); Serial.println(" ip - show current ip address"); Serial.println(" connect - connect to wifi"); Serial.println(" restart - restart the esp8266"); Serial.println(" switch - switch to the other rom and reboot"); Serial.println(" ota - perform ota update, switch rom and reboot"); Serial.println(" info - show esp8266 info"); #ifndef DISABLE_SPIFFS Serial.println(" ls - list files in spiffs"); Serial.println(" cat - show first file in spiffs"); #endif Serial.println(); } else { Serial.println("unknown command"); } } }
Foam::pairPotential::pairPotential ( const word& name, const reducedUnits& rU, const dictionary& pairPotentialProperties ) : name_(name), pairPotentialProperties_(pairPotentialProperties), rCut_(readScalar(pairPotentialProperties_.lookup("rCut"))), rCutSqr_(rCut_*rCut_), rMin_(readScalar(pairPotentialProperties_.lookup("rMin"))), dr_(readScalar(pairPotentialProperties_.lookup("dr"))), forceLookup_(0), energyLookup_(0), esfPtr_(NULL), writeTables_(Switch(pairPotentialProperties_.lookup("writeTables"))) { if(rU.runReducedUnits()) { rCut_ /= rU.refLength(); rMin_ /= rU.refLength(); dr_ /= rU.refLength(); rCutSqr_ = rCut_*rCut_; } }
void Menu::Render() { if (!GetIsAvaible())return; PlayMusic(Scene::m_Sound->GetPointerToMusic("ambient")); if (System::CheckPosition(m_MenuInfo["NEW_GAME"])) DrawFont(GetFont("pacman"), m_MenuInfo["NEW_GAME"].x, m_MenuInfo["NEW_GAME"].y, "New Game", Font::shaded, color1, color2, 0.0, SDL_FLIP_NONE, true); else DrawFont(GetFont("pacman"), m_MenuInfo["NEW_GAME"].x, m_MenuInfo["NEW_GAME"].y, "New Game", Font::blended, color1, color2, 0.0, SDL_FLIP_NONE, true); if (System::CheckPosition(m_MenuInfo["CONTINUE"])) { DrawFont(GetFont("pacman"), m_MenuInfo["CONTINUE"].x, m_MenuInfo["CONTINUE"].y, "Continue", Font::shaded, color1, color2, 0.0, SDL_FLIP_NONE, true); if (m_Mouse->operator[]("left")) Switch(nextScene); } else DrawFont(GetFont("pacman"), m_MenuInfo["CONTINUE"].x, m_MenuInfo["CONTINUE"].y, "Continue", Font::blended, color1, color2, 0.0, SDL_FLIP_NONE, true); if (System::CheckPosition(m_MenuInfo["QUIT"])) { DrawFont(GetFont("pacman"), m_MenuInfo["QUIT"].x, m_MenuInfo["QUIT"].y, "Quit", Font::shaded, color1, color2, 0.0, SDL_FLIP_NONE, true); if (m_Mouse->operator[]("left")) *Scene::m_Running = false; } else DrawFont(GetFont("pacman"), m_MenuInfo["QUIT"].x, m_MenuInfo["QUIT"].y, "Quit", Font::blended, color1, color2, 0.0, SDL_FLIP_NONE, true); }
bool UiBacklight::Trigger() { KillTimer( TimerSwitchOff ); if( _backlightTimeout )RequestTimer( _backlightTimeout * 1000, TimerSwitchOff ); bool wasOn = _isOn; if( !_isOn )Switch( true ); _lastTriggerTime = time(NULL); return wasOn; }
void FIR_Chan_Switch(void* inputFIFOs[], void* outputFIFOs[], Param inParams[], Param outParams[]){ Switch( /* NbS */ (Param) inParams[0], /* sel */ (char*) inputFIFOs[0], /* i0 */ (float*) inputFIFOs[1], /* i1 */ (float*) inputFIFOs[2], /* out */ (float*) outputFIFOs[0] ); }
CGBLGuard::CGBLGuard(TLMutex &lm,const char *loc) // assume orig=eNone, switch to e.Main in constructor : m_Locks(&lm), m_Loc(loc), m_orig(eNone), m_current(eNone), m_select(-1) { Switch(eMain); }
// Construct from dictionary Foam::setUpdater::setUpdater ( const word& name, const dictionary& dict, const label index, const polyTopoChanger& mme ) : polyMeshModifier(name, index, mme, Switch(dict.lookup("active"))) {}
void simnet() { // input to ROM Signal address(4, "address"); Switch("1a", address[3], '3'); Switch("1a", address[2], '2'); Switch("1a", address[1], '1'); Switch("1a", address[0], '0'); // output from ROM Signal bits(8, "ROM Output"); // burn the rom loadRom(romContents, NUM_WORDS, "romfile.txt"); // instantiate the rom Rom("1b", address, bits, ROMSIZE, WORDSIZE, romContents); Probe("1c", bits); }
bool Writer::Call(bool status) { // Problems encountered, probably timed out if (status != OK) return Switch(callback, Error("Writer: timed out\n")); // If we got bad write, let the callback know. ssize_t actual; if (conn->Write(buf, size, actual) != OK || actual == -1) return Switch(callback, Error("Writer: can't write\n")); // Make note of the new data buf += actual; size -= actual; // Write more data if need be if (size > 0) return WaitForWrite(conn.get(), timeout); // We are done. Invoke the callback return Switch(callback, OK); }
virtual ResultExpr PrctlPolicy() const { // Note: this will probably need PR_SET_VMA if/when it's used on // Android without being overridden by an allow-all policy, and // the constant will need to be defined locally. Arg<int> op(0); return Switch(op) .CASES((PR_GET_SECCOMP, // BroadcastSetThreadSandbox, etc. PR_SET_NAME, // Thread creation PR_SET_DUMPABLE), // Crash reporting Allow()) .Default(InvalidSyscall()); }
void dsmcField::updateBasicFieldProperties ( const dictionary& newDict ) { timeDict_ = newDict.subDict("timeProperties"); if (timeDict_.found("resetAtOutput")) { time_.resetFieldsAtOutput() = Switch(timeDict_.lookup("resetAtOutput")); } }
void simnet() { Signal muxIn(4); Signal muxOut(1, "muxOut"); Signal select(2); Space(SD("1b", "Note input/select line order: Incorrect order is a common mistake!")); // Input lines Switch("1a", muxIn[3], '3'); Space(SD("1a", "input[3]")); Switch("1a", muxIn[2], '2'); Space(SD("1a", "input[2]")); Switch("1a", muxIn[1], '1'); Space(SD("1a", "input[1]")); Switch("1a", muxIn[0], '0'); Space(SD("1a", "input[0]")); // Select lines Switch("2b.1a", select[1], 'a'); Space(SD("2b.2a", "select[1]")); Switch("2b.1b", select[0], 'b'); Space(SD("2b.2b", "select[0]")); // select and muxIn are specified in MSB down to LSB order Mux("1b", select, muxIn, muxOut); Probe("1c", muxOut); }