Beispiel #1
0
void TestProtocol::checkGPS() {
    addState(GPSWaiting);
    checkGPSTimer->setSingleShot(true);
    connect(checkGPSTimer, &QTimer::timeout, [=]() {
        addState(GPSReady);
        addState(GPSHasTime);
        addState(GPSHasPos);
        removeState(GPSWaiting);
        emit positionAvailable(DEFAULT_LATITUDE, DEFAULT_LONGITUDE, DEFAULT_ALTITUDE);
        emit checkedGPS(true);
    });
    checkGPSTimer->start(2000);
}
	void CBitThemAllApp::startGame(){

		addState("juego", new CGameState(this, _game));
		addState("menu",	new CMenuState(this, _game));

		addState("stress",	new CStressTest(this));
		//addState("button",	new CButtonTest(this));
		addState("video",	new CVideoTest(this));
		addState("camera",	new CCameraTest(this));

		setState("menu");

	}
Beispiel #3
0
void DFA::addTransition(int stateI, int stateD, int symbol, bool rangeCheck) {
	if (rangeCheck) {
		if (!isValid(symbol))
			throw Exception("Invalid transition symbol");
	}
	addState(stateI);
	addState(stateD);

	// ensure there's no transition on this symbol already
	int existDest = getTransitionState(stateI, symbol);
	if (existDest >= 0 && existDest != stateD)
		throw Exception("State already has transition symbol");
	DFAState &s = getState(stateI);
	s.addTransition(stateD, symbol);
}
Beispiel #4
0
///
/// \brief UpdateSnakePos Offsets the snake, sets up the state of the head
/// and moves the rest of the body
/// \param _head
/// \param io_tail
/// \param _dir The direction the head should move
///
void updateSnakePos(Node * _head,
                    Node ** io_tail,
                    Move _dir)
{
  if(_head != NULL && *io_tail!=NULL)
  {
    if(_dir != NOTMOVING)
    {
      const int segmentRadius = _head->pos.h;
      const int moveOffset = segmentRadius/4;
      Node newNeck = *_head; // Keep track of the head's old position

      addState(_head, MOVING);

      moveSprite(_dir, &_head->pos, moveOffset);

      // Store the last move direction so the head
      // points in the right direction when there is no input
      _head->idleDirection = _dir;

      shiftSnakeBody(_head, io_tail, &newNeck.pos);
    }
    else
    {
      removeState(_head, MOVING);
    }
  }
}
Beispiel #5
0
void BaseCar::initFSM()
{
    FSMState line;
    line.setName(CarState::Line);
    line.enterCallback = CC_CALLBACK_0(BaseCar::enterLineCallBack, this);
    line.updateCallback = CC_CALLBACK_1(BaseCar::lineUpdate, this);
    addState(line);

    FSMState circle;
    circle.setName(CarState::Circle);
    circle.enterCallback = CC_CALLBACK_0(BaseCar::enterCircleCallBack, this);
    circle.updateCallback = CC_CALLBACK_1(BaseCar::circleUpdate, this);
    addState(circle);

    setNextState(CarState::Line);
}
/** Saves a state using the GameProtocol function to combine several
 *  independent rewinders to write one state.
 */
void RewindManager::saveState()
{
    PROFILER_PUSH_CPU_MARKER("RewindManager - save state", 0x20, 0x7F, 0x20);
    auto gp = GameProtocol::lock();
    if (!gp)
        return;
    gp->startNewState();

    m_overall_state_size = 0;
    std::vector<std::string> rewinder_using;

    for (auto& p : m_all_rewinder)
    {
        // TODO: check if it's worth passing in a sufficiently large buffer from
        // GameProtocol - this would save the copy operation.
        BareNetworkString* buffer = NULL;
        if (auto r = p.second.lock())
            buffer = r->saveState(&rewinder_using);
        if (buffer != NULL)
        {
            m_overall_state_size += buffer->size();
            gp->addState(buffer);
        }
        delete buffer;    // buffer can be freed
    }
    gp->finalizeState(rewinder_using);
    PROFILER_POP_CPU_MARKER();
}   // saveState
void StatesEditorView::createNewState()
{
    if (currentState().isBaseState())
        addState();
    else
        duplicateCurrentState();
}
ImperviousRunoff::ImperviousRunoff() {

    addInPort(ADD_PARAMETERS(rain_in)); //in mm
    addOutPort(ADD_PARAMETERS(out_sw));
    addParameter(ADD_PARAMETERS(area)); // in m2
	addState(ADD_PARAMETERS(run_off));
}
Beispiel #9
0
void MainWindow::showTransistionDiagram() {
    qDebug() << "\n[*] MainWindow::showTransistionDiagram";

    if (mProject == NULL) {
        qCritical() << "[-] Project is not active.";
        return;
    }

    if (mTabWidget->indexOf(mTransistionDiagram) != -1) {
        qDebug() << "[+] Removing Existing Transistion Diagram";
        mTabWidget->removeTab(mTabWidget->indexOf(mTransistionDiagram));
        delete mTransistionDiagram;
    }

    qDebug() << "[+] Opening new Transistion Diagram Tab";
    mTransistionDiagram = new TransistionDiagramWidget(mProject);
    mTabWidget->insertTab(1, mTransistionDiagram, "TransistionDiagram");
    mTabWidget->setCurrentIndex(1);

    qDebug() << "[+] Connecting signals to Transistion Diagram Slots";
    connect(mAddStateAction, SIGNAL(triggered()), mTransistionDiagram, SLOT(addState()));
    connect(mDeleteStateAction, SIGNAL(triggered()), mTransistionDiagram, SLOT(removeSelected()));
    connect(mMakeLinkAction, SIGNAL(triggered()), mTransistionDiagram, SLOT(addLink()));
    connect(mDeleteLinkAction, SIGNAL(triggered()), mTransistionDiagram, SLOT(removeSelected()));
    connect(mZoomInAction, SIGNAL(triggered()), mTransistionDiagram, SLOT(zoomIn()));
    connect(mZoomOutAction, SIGNAL(triggered()), mTransistionDiagram, SLOT(zoomOut()));
}
		void clearState( SLSF::State state ) {
			if (  stateAlreadyRegistered( state )  ) {
				getTransConnectorMap( state ).clear();
			} else {
				addState( state );
			}
		}
void
osc::StateHandler::useSipDictionary()
{
  DEBUG_STACK_FRAME;
  addState(new osc::SipDictionary());
  m_hasSipDictionary = true;
}
Beispiel #12
0
void Regex::step()
{
        next_states.clear();
        current_states_copy.clear();
        for(const auto& s:current_states)
        {
              if(s->out1 != nullptr)
            {
               addNextStates(s->out1);
            }
              if(s->out2 != nullptr)
            {
               addNextStates(s->out2);
            }
        }
        while(!next_states.empty())
        {
            StatePtr s = *next_states.rbegin();
            next_states.pop_back();
             if(s->out1 != nullptr)
            {
               addNextStates(s->out1);
            }
              if(s->out2 != nullptr)
            {
               addNextStates(s->out2);
            }
            if(!s->out1 && !s->out2 && s->finalStatus)
                addState(current_states_copy, s);
        }
        current_states = current_states_copy;
       if(!current_states.empty() && !success)  //success为真,代表刚成功进入一个assert,而assert是非占位符,不能cur+1。避免assert在末尾的情况。
            ++cur;
        success = false;    //和上面success对应
}
/**
  Adds a state to the state map, the creation queue and to a
  Compartment with the given id

  @param state

  @param compartmentId

  @return Returns the amount of state space allocated.

  @warning Once you pass a state pointer into this method, you must
           not use it again. It may be invalid.
*/
size_t
osc::StateHandler::addState(osc::State *state,
                            osc::compartment_id_t const &compartmentId,
                            osc::u16 priority)
{
  DEBUG_STACK_FRAME;
  state->retain();

  osc::Compartment * compartment = getCompartment(compartmentId);
  compartment->writeLock();
  
  // Truncating as defined in RFC 3320 6.2.2
  size_t max_size = compartment->totalStateMemoryAvailable();
  if( (state->getStateSize() + 64) > max_size )
  {
    state->truncate(max_size - 64);
  }

  // Add to the global state map. If this state is a duplicate of
  // a state that is already present, then addState will
  // delete the state that was passed in and return a pointer
  // to its doppelganger.
  state = addState(state);

  compartment->addState(state, priority);
  compartment->unlock();
  compartment->release();

  state->release();
  return 0;
}
Beispiel #14
0
Game::Game(void* handle, int show) {
  this->handle = handle;
  this->show = show;
  apiObjects = new APIObjects(handle, show);
  addState(new Menu(this)); 
  //addState(new World(this, DefaultMap()));
}
Beispiel #15
0
    void undo() const override
    {
        auto& scenar = m_scenarioPath.find();
        auto& globalEvent = scenar.event(m_destinationEventId);

        Deserializer<DataStream> s{m_serializedEvent};
        auto recreatedEvent = new EventModel{s, &scenar};

        auto states_in_event = recreatedEvent->states();
        // we remove and re-add states in recreated event
        // to ensure correct parentship between elements.
        for(auto stateId : states_in_event)
        {
            recreatedEvent->removeState(stateId);
            globalEvent.removeState(stateId);
        }
        for(auto stateId : states_in_event)
        {
            recreatedEvent->addState(stateId);
            scenar.states.at(stateId).setEventId(m_movingEventId);
        }

        scenar.events.add(recreatedEvent);

        if(recreatedEvent->timeNode() != globalEvent.timeNode())
        {
            auto& tn = scenar.timeNode(globalEvent.timeNode());
            tn.addEvent(m_movingEventId);
            m_mergeTimeNodesCommand->undo();
        }

        updateEventExtent(m_destinationEventId, scenar);

    }
RWHT::RWHT() {
	addParameter(ADD_PARAMETERS(storage_volume))
			.setUnit("m^3");

	addInPort(ADD_PARAMETERS(in_sw));
	addInPort(ADD_PARAMETERS(in_np));

	addOutPort(ADD_PARAMETERS(out_sw));
	addOutPort(ADD_PARAMETERS(out_np));

	addState(ADD_PARAMETERS(spills));
	addState(ADD_PARAMETERS(dry));

	addState(ADD_PARAMETERS(storage_behaviour));
	addState(ADD_PARAMETERS(provided_volume));

}
Beispiel #17
0
// create the realted state under this statement
int SMFsm::initialization()
{
    m_mainState = new MainIdle(this);
    m_chargeState = new ChargerState(this);
    QFinalState *finalState =new QFinalState(this);

    addState(m_mainState);
    addState(m_chargeState);
    addState(finalState);

    // add Transaction
    m_mainState->addTransition(m_mainState,SIGNAL(gotoCharge()),m_chargeState);
    m_chargeState->addTransition(m_chargeState,SIGNAL(moveToIdle()),m_mainState);

    setInitialState(m_mainState);
    qDebug() << "SMFsm :: initialization";
}
void StateMachine::init()
{
	// Create and states
    SM_State *state_PowerOn		= new SM_State_PowerOn();			addState(state_PowerOn);
    SM_State *state_PassThrough = new SM_State_PassThrough();		addState(state_PassThrough);
    SM_State *state_Disarmed	= new SM_State_Disarmed();			addState(state_Disarmed);
    SM_State *state_Armed_Acro	= new SM_State_Armed_Acro();		addState(state_Armed_Acro);
	
	// Add connections
	state_PowerOn->addConnection   (state_PassThrough,  static_cast<SMConditionFnc>(&SM_State_PowerOn::conditionPassThrough));
	state_PowerOn->addConnection   (state_Disarmed,	    static_cast<SMConditionFnc>(&SM_State_PowerOn::conditionDisarmed));
	state_Disarmed->addConnection  (state_Armed_Acro,	static_cast<SMConditionFnc>(&SM_State_Disarmed::conditionArmed_Acro));
    state_Armed_Acro->addConnection(state_Disarmed,		static_cast<SMConditionFnc>(&SM_State_Armed_Acro::conditionDisarmed));

	// Set initial state
    current_state_ = state_PowerOn;
}
QtMaterialTextFieldStateMachine::QtMaterialTextFieldStateMachine(QtMaterialTextField *parent)
    : QStateMachine(parent),
      m_textField(parent),
      m_normalState(new QState),
      m_focusedState(new QState),
      m_label(0),
      m_offsetAnimation(0),
      m_colorAnimation(0),
      m_progress(0.0)
{
    Q_ASSERT(parent);

    addState(m_normalState);
    addState(m_focusedState);

    setInitialState(m_normalState);

    QEventTransition *transition;
    QPropertyAnimation *animation;

    transition = new QEventTransition(parent, QEvent::FocusIn);
    transition->setTargetState(m_focusedState);
    m_normalState->addTransition(transition);

    animation = new QPropertyAnimation(this, "progress", this);
    animation->setEasingCurve(QEasingCurve::InCubic);
    animation->setDuration(310);
    transition->addAnimation(animation);

    transition = new QEventTransition(parent, QEvent::FocusOut);
    transition->setTargetState(m_normalState);
    m_focusedState->addTransition(transition);

    animation = new QPropertyAnimation(this, "progress", this);
    animation->setEasingCurve(QEasingCurve::OutCubic);
    animation->setDuration(310);
    transition->addAnimation(animation);

    m_normalState->assignProperty(this, "progress", 0);
    m_focusedState->assignProperty(this, "progress", 1);

    setupProperties();

    connect(m_textField, SIGNAL(textChanged(QString)), this, SLOT(setupProperties()));
}
Beispiel #20
0
std::list<Successor>
ReducedModel::transition(State* s, Action* a)
{
    ReducedState* rs = static_cast<ReducedState*>(s);
    std::vector<bool> primaryIndicators;
    if (!useFullTransition_)
        reducedTransition_->
            setPrimary(rs->originalState(), a, primaryIndicators);

    std::list<Successor> successors;
    std::list<Successor> originalSuccessors =
        originalProblem_->transition(rs->originalState(), a);
    double totalProbability = 0.0;
    int i = 0;
    for (Successor const & origSucc : originalSuccessors) {
        State* next = nullptr;
        bool isPrimaryOutcome = useFullTransition_ || primaryIndicators[i];
        if (useContPlanEvaluationTransition_) {
            int add = isPrimaryOutcome && rs->exceptionCount() != k_ ? 0 : 1;
            next = addState(
                new ReducedState(origSucc.su_state,
                                 (rs->exceptionCount() + add) % (k_ + 1),
                                 this));
        } else {
            if (isPrimaryOutcome) {
                next = addState(new ReducedState(origSucc.su_state,
                                                 rs->exceptionCount(),
                                                 this));
            } else if (rs->exceptionCount() < k_) {
                next = addState(new ReducedState(origSucc.su_state,
                                                 rs->exceptionCount() + 1,
                                                 this));
            }
        }
        if (next != nullptr) {
            successors.push_back(Successor(next, origSucc.su_prob));
            totalProbability += origSucc.su_prob;
        }
        i++;
    }
    for (Successor & successor : successors) {
        successor.su_prob /= totalProbability;
    }
    return successors;
}
Beispiel #21
0
void AddCharacterDialog::addNewState()
{
    QString state = mUi.stateEdit->text();
    QString filepath = mUi.browseImageButton->filePath();
    addState(state, filepath);
    mUi.stateEdit->setText("");
    mUi.browseImageButton->setFilePath("");
    mUi.addStateButton->setDisabled(true);
}
Beispiel #22
0
 void StateStorage::setClientInfo( State state, const ClientInfoRefPtr c )
 {
   //Check to make sure this is a valid state.
   if(! isState(state) )
   {
     addState(state);
   }
   //Update the state's info.
   stateInfos[state] = c;
 }
Beispiel #23
0
 bool StateStorage::addInitialState( State initialState )
 {
   bool inserted = initialStates.insert(initialState).second;
   if (inserted) {
     // It wasn't a initial state, so we might not have seen it
     addState(initialState);
   }
   
   return inserted;
 }    
Beispiel #24
0
 bool StateStorage::addFinalState( State finalState )
 {
   bool inserted = finalStates.insert(finalState).second;
   if (inserted) {
     // It wasn't a final state, so we might not have seen it
     addState(finalState);
   }
   
   return inserted;
 }
Beispiel #25
0
void ViewMachine::setup(LayoutUpdater *updater)
{
    if (not updater) {
        qCritical() << __PRETTY_FUNCTION__
                    << "No updater specified. Aborting setup.";
        return;
    }

    setChildMode(QState::ExclusiveStates);

    QState *main = 0;
    QState *symbols0 = 0;
    QState *symbols1 = 0;

    // addState makes state machine to be a parent of passed state,
    // so we don't have to care about deleting states explicitly.
    addState(main = new QState);
    addState(symbols0 = new QState);
    addState(symbols1 = new QState);
    setInitialState(main);

    main->setObjectName(main_state);
    symbols0->setObjectName(symbols0_state);
    symbols1->setObjectName(symbols1_state);

    main->addTransition(updater, SIGNAL(symKeyReleased()), symbols0);
    connect(main,    SIGNAL(entered()),
            updater, SLOT(switchToMainView()));

    symbols0->addTransition(updater, SIGNAL(symKeyReleased()), main);
    symbols0->addTransition(updater, SIGNAL(symSwitcherReleased()), symbols1);
    connect(symbols0, SIGNAL(entered()),
            updater,  SLOT(switchToPrimarySymView()));

    symbols1->addTransition(updater, SIGNAL(symKeyReleased()), main);
    symbols1->addTransition(updater, SIGNAL(symSwitcherReleased()), symbols0);
    connect(symbols1, SIGNAL(entered()),
            updater,  SLOT(switchToSecondarySymView()));

    // Defer to first main loop iteration:
    QTimer::singleShot(0, this, SLOT(start()));
}
Beispiel #26
0
void StateMachine::loadStateMachineVariables(GameObjectData* dataObj)
{
	for(auto kv : dataObj->getObjectMap("states"))
	{
		addState(new State(_owner, kv.second), kv.first);
	}


	_defaultState = dataObj->getString("defaultState");
	setCurrentState(_defaultState);
}
Beispiel #27
0
void Grammar::computeSuccessors(LR1State &state) {
//dump(state); pause();
  BitSet itemsDone(state.m_items.size()); // this is correct!
  for(UINT i = 0; i < state.m_items.size(); i++) {
    if(itemsDone.contains(i)) {
      continue;
    }
    const LR1Item &origItem = state.m_items[i];
    if(isAcceptItem(origItem)) {
      continue; // No successor, but accept
    }
    const Production &origProduction = getProduction(origItem);
    if(origItem.m_dot < origProduction.getLength()) { // origItem is A -> alfa . X beta [la]
      CompactIntArray successorItems;
      successorItems.add(i);
      int symbolNr = origProduction.m_rightSide[origItem.m_dot];
      LR1State newState(getStateCount());
      const LR1Item newItem(true, origItem.m_prod, origItem.m_dot+1, origItem.m_la); // newItem is A -> alfa X . beta [la] (kernelItem)
      newState.addItem(newItem);
      itemsDone += i;
      for(UINT k = i+1; k < state.m_items.size(); k++) {
        if(itemsDone.contains(k)) {
          continue;
        }
        const LR1Item    &sameSymbolItem = state.m_items[k];
        const Production &sameSymbolProd = getProduction(sameSymbolItem);
        if(sameSymbolItem.m_dot < sameSymbolProd.getLength()
          && sameSymbolProd.m_rightSide[sameSymbolItem.m_dot] == symbolNr) { // sameSymbolItem is C -> gamma . X zeta [la1]
          const LR1Item newItem1(true, sameSymbolItem.m_prod, sameSymbolItem.m_dot+1, sameSymbolItem.m_la); // newItem1 is C -> gamma X . zeta [la1] (kernelItem)
          newState.addItem(newItem1);
          itemsDone += k;
          successorItems.add(k);
        }
      }
      newState.sortItems();
      int succStateIndex = findState(newState);
      if(succStateIndex < 0) {
        computeClosure(newState, true);
        succStateIndex = addState(newState);
      } else {
        if(mergeLookahead(m_states[succStateIndex], newState)) {
          m_unfinishedSet.add(succStateIndex);
//          printf(_T(")%d ", succStateIndex);
        }
      }

      assert(succStateIndex >= 0);

      for(size_t j = 0; j < successorItems.size(); j++) {
        state.m_items[successorItems[j]].m_succ = succStateIndex;
      }
    }
  }
}
void DRDirectionalLight::enableDebugShape( bool enable )
{
   if ( enable )
   {
      addState( *m_material );
   }
   else
   {
      removeState( *m_material );
   }
}
Beispiel #29
0
void ShiftMachine::setup(LayoutUpdater *updater)
{
    if (not updater) {
        qCritical() << __PRETTY_FUNCTION__
                    << "No updater specified. Aborting setup.";
        return;
    }

    setChildMode(QState::ExclusiveStates);

    QState *no_shift = 0;
    QState *latched_shift = 0;
    QState *caps_lock = 0;

    // addState makes state machine to be a parent of passed state,
    // so we don't have to care about deleting states explicitly.
    addState(no_shift = new QState);
    addState(latched_shift = new QState);
    addState(caps_lock = new QState);
    setInitialState(no_shift);

    no_shift->setObjectName(no_shift_state);
    latched_shift->setObjectName(latched_shift_state);
    caps_lock->setObjectName(caps_lock_state);

    connect(no_shift, SIGNAL(entered()),
            updater,  SLOT(syncLayoutToView()));
    connect(latched_shift, SIGNAL(entered()),
            updater,       SLOT(syncLayoutToView()));
    connect(caps_lock, SIGNAL(entered()),
            updater,   SLOT(syncLayoutToView()));

    no_shift->addTransition(updater, SIGNAL(shiftPressed()), latched_shift);
    no_shift->addTransition(updater, SIGNAL(autoCapsActivated()), latched_shift);
    latched_shift->addTransition(updater, SIGNAL(shiftCancelled()), no_shift);
    latched_shift->addTransition(updater, SIGNAL(shiftReleased()), caps_lock);
    caps_lock->addTransition(updater, SIGNAL(shiftReleased()), no_shift);

    // Defer to first main loop iteration:
    QTimer::singleShot(0, this, SLOT(start()));
}
DRDirectionalLight::DRDirectionalLight( DirectionalLight& light )
   : DebugGeometry( &light )
   , m_light( light )
   , m_mesh( NULL )
{
   Vector endPos;
   endPos.setMul( Quad_0010, Float_2 );
   m_mesh = DebugGeometryBuilder::createArrow( 0.2f, Quad_0, endPos );
   m_material = new SingleColorDebugMat( Color( 255, 242, 61 ) );

   setMesh( *m_mesh );
   addState( *m_material );
}