void Rover::move(float distance) { //Convert from metres into millimetres. distance *= 1000; //Work out how many pulses are required to go that many millimetres. distance *= PULSES_PER_MM; //Make sure we scale the number of pulses according to our encoding method. distance /= ENCODING; positionSetPoint_ = distance; //Moving forward. if (distance > 0) { enterState(STATE_MOVING_FORWARD); } //Moving backward. else if (distance < 0) { enterState(STATE_MOVING_BACKWARD); } //If distance == 0, then do nothing, i.e. stay stationary. }
void FalseColorDock::processApplyClicked() { if(coloringState[selectedColoring()] == FalseColoringState::CALCULATING) { GGDBGM("enterState():"<<endl); enterState(selectedColoring(), FalseColoringState::ABORTING); if (lastShown == selectedColoring()) { // Cancel after re-calc enterState(selectedColoring(), FalseColoringState::UNKNOWN); emit unsubscribeFalseColoring(this, selectedColoring()); updateProgressBar(); updateTheButton(); } else { emit unsubscribeFalseColoring(this, selectedColoring()); // go back to last shown coloring if(coloringUpToDate[lastShown]) { uisel->sourceBox->setCurrentIndex(int(lastShown)); requestColoring(lastShown); } else { // or fall back to CMF, e.g. after ROI change uisel->sourceBox->setCurrentIndex(FalseColoring::CMF); requestColoring(FalseColoring::CMF); } } } else if( coloringState[selectedColoring()] == FalseColoringState::FINISHED || coloringState[selectedColoring()] == FalseColoringState::UNKNOWN ) { requestColoring(selectedColoring(), /* recalc */ true); } }
void Rover::turn(int degrees) { //Correct the amount to turn based on deviation during last segment. headingSetPoint_ = abs(degrees) + (endHeading_ - startHeading_); //In case the rover tries to [pointlessly] turn >360 degrees. if (headingSetPoint_ > 359.8){ headingSetPoint_ -= 359.8; } //Rotating clockwise. if (degrees > 0) { enterState(STATE_ROTATING_CLOCKWISE); } //Rotating counter-clockwise. else if (degrees < 0) { enterState(STATE_ROTATING_COUNTER_CLOCKWISE); } //If degrees == 0, then do nothing, i.e. stay stationary. }
void XtgScanner::defAtRate() { enterState(nameMode); sfcName = getToken(); if (sfcName == "@$:") { if (doc->paragraphStyles().contains(m_item->itemName() + "_Normal")) { ParagraphStyle newStyle; newStyle.setParent(m_item->itemName() + "_Normal"); currentParagraphStyle = newStyle; currentCharStyle = newStyle.charStyle(); } else if (doc->paragraphStyles().contains("Normal")) { ParagraphStyle newStyle; newStyle.setParent("Normal"); currentParagraphStyle = newStyle; currentCharStyle = newStyle.charStyle(); } enterState(previousState()); } else if (sfcName == "@:") { QString pStyle = CommonStrings::DefaultParagraphStyle; ParagraphStyle newStyle; newStyle.setParent(pStyle); newStyle.setLineSpacingMode(ParagraphStyle::AutomaticLineSpacing); currentParagraphStyle = newStyle; currentCharStyle = newStyle.charStyle(); currentCharStyle.setFontSize(120.0); styleEffects = ScStyle_None; currentCharStyle.setFeatures(styleEffects.featureList()); enterState(textMode); } else if (doc->paragraphStyles().contains(m_item->itemName() + "_" + sfcName)) { ParagraphStyle newStyle; newStyle.setParent(m_item->itemName() + "_" + sfcName); currentParagraphStyle = newStyle; currentCharStyle = newStyle.charStyle(); if (lookAhead() == ':') top++; enterState(textMode); } else if (doc->paragraphStyles().contains(sfcName)) { ParagraphStyle newStyle; newStyle.setParent(sfcName); currentParagraphStyle = newStyle; currentCharStyle = newStyle.charStyle(); if (lookAhead() == ':') top++; enterState(textMode); } }
/*----------------------------------- CompressorSystem::heartbeat----------------------------------- * This is called from the heartbeat() in the main page * 1. Reads the reservoir pressure * 2. Fills tank when it is too low, enters starting state * 3. Waits for one loop through, then enters the on state * 4. Once tank is filled to correct pressure, enter stopping state * 5. Waits for on loop through, then enters the off state */ void CompressorSystem::heartbeat(void){ //Serial.print("Compressor System Heartbeat Started, State: "); Serial.println(comp.state); int reservoirPressure = analogRead(aiReservoirPin); if(reservoirPressure < pvTankPressMin-100) reservoirPressure = pvTankPressMin; switch(state){ case CSS_OFF: if (reservoirPressure <= pvTankPressMin) { //if the compressor is off, and the tank is to low, turn it on inverter.neededByCompressor(true); // Serial.print(" reservoirPressure: "); Serial.println(reservoirPressure); digitalWrite(oUnloaderPin, HIGH); //dump pressure for 2 heart beats before compressor is truned on pvUnloaderTimeout = 2; // number of heartbeat intervals to wait for unloader enterState(CSS_STARTING); //compressor system is now starting } else digitalWrite(oCompressorPin, LOW); //turn off compressor break; case CSS_STARTING: if (pvUnloaderTimeout > 1) { pvUnloaderTimeout--; // keep waiting This works allongs as } else if (digitalRead(iInverterOnPin)) { digitalWrite(oUnloaderPin, LOW); // unloader has timed out so close it digitalWrite(oCompressorPin, HIGH); //start compressor //Serial.print("oCompressorPin: "); Serial.print(oCompressorPin); enterState(CSS_ON); //the compressor is now on } // end else if break; case CSS_ON: if (reservoirPressure > pvTankPressMax) { digitalWrite(oCompressorPin, LOW); //turn off if tank is pressurized inverter.neededByCompressor(false); //compressor is no longer needed by inverter pvUnloaderTimeout = 2; // number of heartbeat intervals to wait for unloader enterState(CSS_STOPPING); //enter the stopping state } else digitalWrite(oCompressorPin, HIGH); //if tank pressure is not achieved, keep compressor on break; case CSS_STOPPING: if (pvUnloaderTimeout > 1) { pvUnloaderTimeout--; // keep waiting } else { // unloader has timed out so close it digitalWrite(oUnloaderPin, LOW); enterState(CSS_OFF); //compressor is now off } break; } //end switch (state) } //end CompressorSystem::heartbeat
void FalseColorDock::processComputationCancelled(FalseColoring::Type coloringType) { if(coloringState[coloringType] == FalseColoringState::ABORTING) { coloringProgress[coloringType] = 0; GGDBGM("enterState():"<<endl); enterState(coloringType, FalseColoringState::UNKNOWN); updateTheButton(); updateProgressBar(); } else if(coloringState[coloringType] == FalseColoringState::CALCULATING) { enterState(coloringType, FalseColoringState::UNKNOWN); GGDBGM("restarting cancelled computation"<<endl); requestColoring(coloringType); } }
void XtgScanner::defColor() { bool isSpot = false; ScColor tmp; enterState(stringMode); token = getToken(); while (lookAhead() != '>' ) { token = getToken(); if ((token == "CMJN") || (token == "CMYK")) { enterState(tagMode); token = getToken(); if (token == "S") { token = getToken(); isSpot = true; } double c = getToken().toDouble(); double m = getToken().toDouble(); double y = getToken().toDouble(); double k = getToken().toDouble(); tmp.setColor(qRound(c * 2.55), qRound(m * 255), qRound(y * 255), qRound(k * 255)); tmp.setSpotColor(isSpot); tmp.setRegistrationColor(false); doc->PageColors.tryAddColor(sfcName, tmp); } else if (token == "RGB") { enterState(tagMode); token = getToken(); if (token == "S") { token = getToken(); isSpot = true; } double r = getToken().toDouble(); double g = getToken().toDouble(); double b = getToken().toDouble(); tmp.setColorRGB(qRound(r * 2.55), qRound(g * 255), qRound(b * 255)); tmp.setSpotColor(isSpot); tmp.setRegistrationColor(false); doc->PageColors.tryAddColor(sfcName, tmp); } } top++; enterState(textMode); }
void ComponentGate::handleMessageClientUsesObject(Message &message) { switch(state) { case STATE_A: enterState(STATE_TRANSITION_AB); break; case STATE_B: enterState(STATE_TRANSITION_BA); break; case STATE_TRANSITION_AB: /* do nothing */ break; case STATE_TRANSITION_BA: /* do nothing */ break; } }
void FenwarBoss::dealDamage(float damage, bool makesFlash) { //Fenwar is invincible until you kill his orbs!!! if (orbManager->numOrbsAlive() > 0) { smh->soundManager->playSound("snd_HitInvulnerable"); return; } if (!flashing) { health -= damage; if (makesFlash) { flashing = true; timeStartedFlashing = smh->getGameTime(); } } if (health <= 0.0) { if (state != FenwarStates::NEAR_DEATH && state != FenwarStates::RETURN_TO_ARENA) { //Initial "death" health = 0.0; fadeWhiteAlpha = 0; flashing = false; smh->screenEffectsManager->stopEffect(); orbManager->killOrbs(); bulletManager->killBullets(); enterState(FenwarStates::RETURN_TO_ARENA); smh->windowManager->openDialogueTextBox(-1, FENWAR_NEAR_DEFEAT_TEXT); hasBegunFadeToWhite=false; } } }
void FenwarBoss::doReturnToArenaState(float dt) { //After the player closes the near death text box, fade the screen to white if (!relocatedYet && !smh->windowManager->isTextBoxOpen() && !hasBegunFadeToWhite) { hasBegunFadeToWhite=true; smh->beginFadeScreenToColor(Colors::WHITE, 255.0); } //Move smiley to the copy of the original arena that wasn't terraformed if (!relocatedYet && smh->getScreenColorAlpha() >= 255.0) { timeRelocated = smh->getGameTime(); relocatedYet = true; smh->player->reset(); smh->player->dontUpdate = true; smh->player->moveTo(FENWAR_DEATH_STAGE_X, FENWAR_DEATH_STAGE_Y + 2); smh->player->facing = UP; x = FENWAR_DEATH_STAGE_X * 64.0 + 32.0; y = FENWAR_DEATH_STAGE_Y * 64.0 + 32.0; floatingYOffset = 0.0; } //Now fade out from white if (smh->timePassedSince(timeRelocated) > 2.0) { smh->fadeScreenToNormal(); if (smh->getScreenColorAlpha() <= 0.0) { smh->setScreenColor(Colors::WHITE, 0.0); smh->windowManager->openDialogueTextBox(-1, FENWAR_DEFEAT_TEXT); enterState(FenwarStates::NEAR_DEATH); } } }
FenwarBoss::FenwarBoss(int _gridX, int _gridY, int _groupID) { x = _gridX * 64 + 32; y = _gridY * 64 + 32; startGridX = _gridX; startGridY = _gridY; groupID = _groupID; health = maxHealth = FenwarAttributes::HEALTH; startedIntroDialogue = false; terraformedYet = false; startedShakingYet = false; flashing = false; floatingYOffset = 0.0; collisionBox = new hgeRect(); collisionBox->SetRadius(x, y, 1); timeRelocated = 999999999.0; relocatedYet = false; hasBegunFadeToWhite=false; orbManager = new FenwarOrbs(this); bulletManager = new FenwarBullets(this); bombManager = new FenwarBombs(this); smh->resources->GetAnimation("fenwar")->Play(); smh->resources->GetAnimation("fenwar")->SetColor(ARGB(255,255,255,255)); initPlatformPoints(); tauntedAboutOrbs = false; enterState(FenwarStates::INACTIVE); }
void gui_mode::documentChanged(){ // qDebug("gui_mode::documentChanged()"); if(!mainWindow()->hasModePlugin()) return; ModePlugin* iMode = mainWindow()->getModePlugin(); switch(state){ /// But there was no active plugin case DEFAULT: return; /// And there was an active plugin case MODE: /// Give the plugin a chance to react to the selection change /// If plugin didn't specify how to perform the update, simply /// destroy it and re-create it from scratch. if(!iMode->documentChanged()){ iMode->__internal_destroy(); iMode->__internal_create(); } return; /// There was a suspended plugin case SUSPENDED: /// On the other hand, when plugin is suspended, change in document just /// results in the plugin termination if(!iMode->documentChanged()) iMode->__internal_destroy(); mainWindow()->removeModePlugin(); lastActiveModeAction = NULL; enterState(DEFAULT); return; } }
void Label::resetState() { m_occludedLastFrame = false; m_occlusionSolved = false; m_updateMeshVisibility = true; m_dirty = true; enterState(State::wait_occ, 0.0); }
void StateIdle::MouseLeftDrag(int dx, int dy) { if (Controller::bMoveCenterMode) { mCamera->setCamCenter(mCamera->getCamCenter() + calcMoveCenterVector(dx, dy, Plane())); return; } if (INTERNAL_STATE_MOUSE_DOWN == internalState) { std::vector<Vector3> selectedPoints; Vector3 planeVec = Vector3(0, 1, 0); selectedPoints.push_back(selectedPoint); Plane::buildPlane(selectedPoints, Controller::currPlane, planeVec); if (Controller::currPlane.N.dot(mCamera->getDirection()) > 0) { Controller::currPlane = -Controller::currPlane; } dynamic_cast<StateDraw*>(State::statePool[STATE_DRAW])->selectedPoints = selectedPoints; dynamic_cast<StateDraw*>(State::statePool[STATE_DRAW])->startPoint = selectedPoint; dynamic_cast<StateDraw*>(State::statePool[STATE_DRAW])->endPoint = selectedPoint; dynamic_cast<StateDraw*>(State::statePool[STATE_DRAW])->internalState = StateDraw::STATE_DRAW_START_POINT_SELECTED; enterState(State::statePool[STATE_DRAW]); internalState = INTERNAL_STATE_IDLE; } }
INLINE_CHAINS void ElevatorDoor_Actor::chain1_Initial( void ) { // transition ':TOP:Initial:Initial' rtgChainBegin( 1, "Initial" ); rtgTransitionBegin(); rtgTransitionEnd(); enterState( 2 ); }
void StateBasedGame::enterState(unsigned int id) { for (unsigned int i = 0; i < m_states.size(); i++) { if (m_states.at(i)->id() == id) { enterState(m_states.at(i)); break; } } }
INLINE_CHAINS void serialTranslateCapsule_Actor::chain1_Initial( void ) { // transition ':TOP:Initial:Initial' rtgChainBegin( 1, "Initial" ); rtgTransitionBegin(); rtgTransitionEnd(); enterState( 2 ); }
void FalseColorDock::setCalculationInProgress(FalseColoring::Type coloringType) { if (selectedColoring() == coloringType) { enterState(selectedColoring(), FalseColoringState::CALCULATING); updateTheButton(); updateProgressBar(); } }
INLINE_CHAINS void roombaProgram_Actor::chain5_Initial( void ) { // transition ':TOP:Initial:Initial' rtgChainBegin( 1, "Initial" ); rtgTransitionBegin(); rtgTransitionEnd(); enterState( 2 ); }
INLINE_CHAINS void serialCommunicationCapsule_Actor::chain2_False( void ) { // transition ':TOP:openPort:False' rtgChainBegin( 6, "False" ); rtgTransitionBegin(); transition2_False( msg->data, msg->sap() ); rtgTransitionEnd(); enterState( 3 ); }
INLINE_CHAINS void Local_Controller_Actor::chain1_Initial( void ) { // transition ':TOP:Initial:Initial' rtgChainBegin( 1, "Initial" ); rtgTransitionBegin(); transition1_Initial( msg->data, msg->sap() ); rtgTransitionEnd(); enterState( 2 ); }
void Label::resetState() { if (m_state == State::dead) { return; } m_occludedLastFrame = false; m_occluded = false; m_anchorIndex = 0; enterState(State::none, 0.0); }
INLINE_CHAINS void ElevatorDoor_Actor::chain7_ignore( void ) { // transition ':TOP:Opening:J56FBEFD60316:ignore' rtgChainBegin( 5, "ignore" ); exitState( rtg_parent_state ); rtgTransitionBegin(); rtgTransitionEnd(); enterState( 5 ); }
INLINE_CHAINS void ElevatorDoor_Actor::chain10_ignore( void ) { // transition ':TOP:Opened:J56FBF2A10398:ignore' rtgChainBegin( 3, "ignore" ); exitState( rtg_parent_state ); rtgTransitionBegin(); rtgTransitionEnd(); enterState( 3 ); }
INLINE_CHAINS void ElevatorDoor_Actor::chain5_ignore( void ) { // transition ':TOP:Closed:J56FBEDAA03E9:ignore' rtgChainBegin( 2, "ignore" ); exitState( rtg_parent_state ); rtgTransitionBegin(); rtgTransitionEnd(); enterState( 2 ); }
INLINE_CHAINS void ElevatorDoor_Actor::chain12_ignoreClose( void ) { // transition ':TOP:Closing:J56FC59C80360:ignoreClose' rtgChainBegin( 4, "ignoreClose" ); exitState( rtg_parent_state ); rtgTransitionBegin(); rtgTransitionEnd(); enterState( 4 ); }
void StateIdle::UIEvent(int event) { if (event == Controller::BTN_ID_STANDARD_VIEW) { Quaternion q = Quaternion::fromEuler(Vector3(-90, 0, 0)); mCamera->setCamCenterTo(Vector3(0, 0, 0)); mCamera->rotateCamTo(q); } else if (event == Controller::BTN_ID_DELETE_LINE) { enterState(State::statePool[STATE_DELETE]); } }
INLINE_CHAINS void roombaProgram_Actor::chain2_batteryTooLow( void ) { // transition ':TOP:checkBatteryLevel:batteryTooLow' rtgChainBegin( 6, "batteryTooLow" ); rtgTransitionBegin(); transition2_batteryTooLow( (const int *)msg->data, (programProtocol::Base *)msg->sap() ); rtgTransitionEnd(); enterState( 2 ); }
INLINE_CHAINS void roombaProgram_Actor::chain9_bumperTriggered( void ) { // transition ':TOP:rotating:J51ADCE6F0025:bumperTriggered' rtgChainBegin( 4, "bumperTriggered" ); exitState( rtg_parent_state ); rtgTransitionBegin(); rtgTransitionEnd(); enterState( 4 ); }
void XtgScanner::defColon() { flushText(); if ((sfcName == "@") || (sfcName == "@$:") || (sfcName == "@:")) { QString pStyle = CommonStrings::DefaultParagraphStyle; ParagraphStyle newStyle; newStyle.setParent(pStyle); newStyle.setLineSpacingMode(ParagraphStyle::AutomaticLineSpacing); currentParagraphStyle = newStyle; currentCharStyle = newStyle.charStyle(); currentCharStyle.setFontSize(120.0); styleEffects = ScStyle_None; currentCharStyle.setFeatures(styleEffects.featureList()); } else if (doc->paragraphStyles().contains(m_item->itemName() + "_" + sfcName)) { ParagraphStyle newStyle; newStyle.setParent(m_item->itemName() + "_" + sfcName); currentParagraphStyle = newStyle; currentCharStyle = newStyle.charStyle(); } else if (doc->paragraphStyles().contains(sfcName)) { ParagraphStyle newStyle; newStyle.setParent(sfcName); currentParagraphStyle = newStyle; currentCharStyle = newStyle.charStyle(); } else { QString pStyle = CommonStrings::DefaultParagraphStyle; ParagraphStyle newStyle; newStyle.setParent(pStyle); newStyle.setLineSpacingMode(ParagraphStyle::AutomaticLineSpacing); currentParagraphStyle = newStyle; currentCharStyle = newStyle.charStyle(); currentCharStyle.setFontSize(120.0); styleEffects = ScStyle_None; currentCharStyle.setFeatures(styleEffects.featureList()); } if (newlineFlag) { int posT = m_item->itemText.length(); if (posT > 0) { m_item->itemText.insertChars(posT, SpecialChars::PARSEP); m_item->itemText.applyStyle(posT, currentParagraphStyle); } } newlineFlag = false; enterState(textMode); define = 0; if (!((lookAhead() == '\r') || (lookAhead() == '\n'))) inDef = false; }