本文整理汇总了C++中Transition类的典型用法代码示例。如果您正苦于以下问题:C++ Transition类的具体用法?C++ Transition怎么用?C++ Transition使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Transition类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: Q_ASSERT
void PropertyEditor::Private::setTargetState(const QString &label)
{
Transition* transition = current<Transition>();
Q_ASSERT(transition);
if (transition) {
State *targetState = ElementUtil::findState(transition->sourceState()->machine(), label);
if (transition->targetState() != targetState) {
ModifyTransitionCommand *command = new ModifyTransitionCommand(transition);
command->setTargetState(targetState);
m_commandController->undoStack()->push(command);
}
}
}
开发者ID:hermixy,项目名称:KDStateMachineEditor,代码行数:13,代码来源:propertyeditor.cpp
示例2: getTransitionLocally
Transition* TransitionBase::getTransitionLocally(string transitionId) {
vector<Transition*>::iterator i;
Transition* transition;
i = transitionSet->begin();
while (i != transitionSet->end()) {
transition = *i;
if (transition->getId() == transitionId) {
return transition;
}
++i;
}
return NULL;
}
开发者ID:Gingar,项目名称:port,代码行数:14,代码来源:TransitionBase.cpp
示例3: process_messages
void Thread::run_one_step()
{
process_messages();
Net *net = process->get_net();
if (net == NULL) {
return;
}
Transition *tr = net->pick_active_transition();
if (tr == NULL) {
return;
}
tr->set_active(false);
tr->full_fire(this, net);
}
开发者ID:DiPi22,项目名称:kaira,代码行数:14,代码来源:thread.cpp
示例4: time
void Simulation::PrintStatistics()
{
Log->Write("\nRooms Egress Time:");
Log->Write("==================");
Log->Write("id\tcaption\tegress time (s)");
for (const auto& it:_building->GetAllRooms()) {
auto&& room = it.second;
if (room->GetCaption()!="outside")
Log->Write("%d\t%s\t%.2f", room->GetID(), room->GetCaption().c_str(), room->GetEgressTime());
}
Log->Write("\nUsage of Exits");
Log->Write("==========");
for (const auto& itr : _building->GetAllTransitions()) {
Transition* goal = itr.second;
if (goal->GetDoorUsage()) {
Log->Write(
"\nExit ID [%d] used by [%d] pedestrians. Last passing time [%0.2f] s",
goal->GetID(), goal->GetDoorUsage(),
goal->GetLastPassingTime());
string statsfile = _config->GetTrajectoriesFile()+"_flow_exit_id_"+to_string(goal->GetID())+".dat";
Log->Write("More Information in the file: %s", statsfile.c_str());
auto output = new FileHandler(statsfile.c_str());
output->Write("#Flow at exit "+goal->GetCaption()+"( ID "+to_string(goal->GetID())+" )");
output->Write("#Time (s) cummulative number of agents \n");
output->Write(goal->GetFlowCurve());
}
}
Log->Write("\n");
}
开发者ID:JuPedSim,项目名称:jpscore,代码行数:32,代码来源:Simulation.cpp
示例5: transit
// Consider merging this funciton with nullInputTransit()
int Fsm::transit(MessageTuple* inMsg, vector<MessageTuple*>& outMsgs, bool& high_prob, int startIdx )
{
State* cs = _states[_current];
outMsgs.clear();
// Go through the possible transitions, find that matches the message
for( int tid = startIdx ; tid < cs->getNumTrans(); ++tid ) {
Transition tr = cs->getTrans((int)tid);
if( tr.getFromMachineId() == inMsg->subjectId() && tr.getInputMessageId() == inMsg->destMsgId() ) {
// Matching found. Get all the outLabels
for( size_t oid = 0 ; oid < tr.getNumOutLabels() ; ++oid ) {
OutLabel lbl = tr.getOutLabel(oid);
MessageTuple* out = new FsmMessage(tr.getFromMachineId(), lbl.first,
tr.getInputMessageId(), lbl.second, _macLookup->toInt(this->_name)) ;
outMsgs.push_back(out);
}
// Change state
State* next = cs->getNextState((int)tid);
_current = next->getID();
if( tr.isHigh() )
high_prob = true;
else
high_prob = false;
return tid+1;
}
}
// The function will get to this line when no more matching transition is found
return -1;
}
开发者ID:skiegyt,项目名称:prob_verify,代码行数:35,代码来源:fsm.cpp
示例6: loop
//Transit from current state
int StateMachine::loop() {
int current_state = this->current_state();
for(int i=0; i < stored_transitions; i++) {
Transition transition = this->transitions[i];
if(transition.origin == current_state && transition.transition_function()) {
this->set_current_state(transition.dest);
current_state = transition.dest;
return transition.dest;
}
}
if (state_functions[current_state] != 0) {
state_functions[current_state]();
}
return current_state;
}
开发者ID:hithwen,项目名称:statemachine,代码行数:16,代码来源:statemachine.cpp
示例7: addTransition
returnValue ShootingMethod::addTransition( const Transition& transition_ ){
if( transition_.getNXA() != 0 ) return ACADOERROR( RET_TRANSITION_DEPENDS_ON_ALGEBRAIC_STATES );
integrator[N-1]->setTransition( transition_ );
return SUCCESSFUL_RETURN;
}
开发者ID:rtkg,项目名称:acado,代码行数:7,代码来源:shooting_method.cpp
示例8: Transition
void State::add_epsilon(State* dest)
{
for (size_t i = 0; i < this->transitions.size(); i++) {
if (this->transitions[i]->get_dest() == dest) {
return;
}
}
Transition* t = new Transition(this->location, '\0', this, dest);
t->set_epsilon(true);
transitions.push_back(t);
dest->add_incoming(t);
return;
}
开发者ID:bemk,项目名称:Automaton,代码行数:16,代码来源:State.cpp
示例9: writeClip
void XMLizer::writeClip( QDomDocument &document, QDomNode &parent, Clip *clip )
{
QDomElement n1 = document.createElement( "Clip" );
parent.appendChild( n1 );
if ( clip->getSpeed() != 1.0 )
n1.setAttribute( "speed", QString::number( clip->getSpeed(), 'e', 17 ) );
XMLizer::createText( document, n1, "Name", clip->sourcePath() );
XMLizer::createDouble( document, n1, "PosInTrack", clip->position() );
XMLizer::createDouble( document, n1, "StartTime", clip->start() );
XMLizer::createDouble( document, n1, "Length", clip->length() );
for ( int i = 0; i < clip->videoFilters.count(); ++i )
XMLizer::writeFilter( document, n1, false, clip->videoFilters.at( i ) );
for ( int i = 0; i < clip->audioFilters.count(); ++i )
XMLizer::writeFilter( document, n1, true, clip->audioFilters.at( i ) );
Transition *trans = clip->getTransition();
if ( trans ) {
QDomElement t = document.createElement( "Transition" );
n1.appendChild( t );
XMLizer::createDouble( document, t, "PosInTrack", trans->position() );
XMLizer::createDouble( document, t, "Length", trans->length() );
if ( !trans->getVideoFilter().isNull() )
XMLizer::writeFilter( document, t, false, trans->getVideoFilter() );
if ( !trans->getAudioFilter().isNull() )
XMLizer::writeFilter( document, t, true, trans->getAudioFilter() );
}
}
开发者ID:hftom,项目名称:MachinTruc,代码行数:31,代码来源:xmlizer.cpp
示例10: transitionIsCompatible
bool SimulatedState::transitionIsCompatible(const Transition& transition) const
{
if (_currentState != transition.sourceStateIndex()) {
return false;
}
if (tapes.size() != transition.numberOfTapes()) {
return false;
}
for (int i = 0; i < transition.numberOfTapes(); ++i) {
if (!transition.isCurrentTapeSymbolForTape(i, characterAtTapehead(i)) && (!_tm->anySymbolSymbolSet() || transition.currentTapeSymbolForTape(i) != _tm->anySymbolSymbol())) {
return false;
}
}
return true;
}
开发者ID:arminnh,项目名称:universal-turing-machine-simulator,代码行数:18,代码来源:TMSimulatedState.cpp
示例11: start_transition
/**
* @brief Starts a transition effect on this object.
*
* The transition will be automatically deleted when finished or stopped.
* Any previous transition is stopped.
*
* @param transition The transition to start.
* @param callback_ref A Lua registry ref to the function to call when
* the transition finishes, or LUA_REFNIL.
* @param lua_context The Lua world for the callback (or NULL).
*/
void Drawable::start_transition(Transition& transition,
int callback_ref, LuaContext* lua_context) {
stop_transition();
this->transition = &transition;
this->transition_callback_ref = callback_ref;
this->lua_context = lua_context;
transition.start();
}
开发者ID:xor-mind,项目名称:solarus,代码行数:21,代码来源:Drawable.cpp
示例12: IF_DEBUG
void StateMachineViewerWidgetNG::transitionAdded(const TransitionId transitionId, const StateId sourceId, const StateId targetId, const QString& label)
{
if (m_idToTransitionMap.contains(transitionId))
return;
IF_DEBUG(qDebug() << "transitionAdded" << transitionId << label << sourceId << targetId);
State* source = m_idToStateMap.value(sourceId);
State* target = m_idToStateMap.value(targetId);
if (!source || !target) {
qDebug() << "Null source or target for transition:" << transitionId;
return;
}
Transition* transition = new Transition(source);
transition->setTargetState(target);
transition->setLabel(label);
m_idToTransitionMap[transitionId] = transition;
}
开发者ID:dfries,项目名称:GammaRay,代码行数:19,代码来源:statemachineviewerwidgetng.cpp
示例13: updateStateId
void State::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *mouseEvent) {
if(mouseEvent->button() == Qt::LeftButton && dynamic_cast<GraphGraphicsScene* >(this->scene())->mode() == MODE::DELETE) {
for(Transition *t : m_transitions) {
t->removeSelf();
}
updateStateId(this->m_id);
delete this;
}
else if(mouseEvent->button() == Qt::LeftButton && dynamic_cast<GraphGraphicsScene* >(this->scene())->mode() == MODE::TRANSITION) {
Transition *transition = new Transition();
transition->setFrom(this);
transition->setTo(this);
transition->setDrawMode(DRAW_SHAPE::NORMAL);
transition->setFlag(true);
this->scene()->addItem(transition);
this->addTransiton(transition);
instructionLab->addToInstructionlab(transition);
}
}
开发者ID:Gandalph,项目名称:rs15-15,代码行数:20,代码来源:state.cpp
示例14:
//
// Notification
//
void Script::State::Notify(U32 message, U32 data)
{
// Ask the action to translate this notification
if (action)
{
U32 translation = action->Notify(message, data);
// Was the notification ignored ?
if (translation != Status::Ignored)
{
// Find the transition
Transition *transition = transitions.Find(translation);
if (transition)
{
// Perform the transition
transition->Perform(GetScript());
}
}
}
}
开发者ID:grasmanek94,项目名称:darkreign2,代码行数:24,代码来源:strategic_script_state.cpp
示例15: view
/* Name: view
* Purpose: Prints out all of the transitions.
* Operation: This method is used to print out the value of the transition.
This is used by class Show_Command though the class Turing_Machine.
*/
void Transition_Function::view() const{
// Display a empty set if it is empty.
if (transitions.size() == 0){
cout << "Delta = {}\n\n";
return;
}
for (unsigned int i = 0; i < transitions.size(); i++){
Transition Temp = transitions[i];
cout << "Delta("
<< Temp.Source_State()
<< ", "
<< Temp.Read_Character()
<< ") = ("
<< Temp.Destination_State()
<< ", "
<< Temp.Write_Character()
<< ", "
<< Temp.Move_Direction()
<< ")\n";
}
cout << "\n";
}
开发者ID:SkullCrusher,项目名称:Rex-The-Biplane,代码行数:32,代码来源:Transition_Function.cpp
示例16: getNbOfTokens
void Place::produceTokens(unsigned int nbOfTokens, unsigned int colorLabel, int tokensTime)
{
unsigned int oldNumberOfTokens = getNbOfTokens(colorLabel);
for (unsigned int i = 0; i < nbOfTokens; ++i) {
Token token(tokensTime);
m_tokenByColor[colorLabel - 1].push_back(token);
}
// if(tokensTime < 0){tokensTime = 0;} // CB incompatible with deactivation (tokenTime = -1)
if ((oldNumberOfTokens < NB_OF_TOKEN_TO_ACTIVE_ARC) && (getNbOfTokens(colorLabel) >= NB_OF_TOKEN_TO_ACTIVE_ARC)) { // CB WTF : Si un token et deux arcs sortant, bug ?
arcList outGoingArcs = outGoingArcsOf(colorLabel);
for (unsigned int i = 0 ; i < outGoingArcs.size() ; ++i) {
PetriNetArc* arc = outGoingArcs[i];
// if (!arc->getCondition()) { // CB check if the arc can be activated
// continue;
// }
Transition* transitionTo = dynamic_cast<Transition*>(arc->getTo());
if (!transitionTo) {
throw IncoherentStateException();
}
transitionTo->setArcAsActive(arc, tokensTime, true);
if (transitionTo->isStatic()) {
if(arc->getRelativeMinValue().getValue() < (int) tokensTime) {
getPetriNet()->pushTransitionToCrossWhenAcceleration(transitionTo);
}
} else {
if(arc->getRelativeMaxValue().getValue() < (int) tokensTime) {
getPetriNet()->pushTransitionToCrossWhenAcceleration(transitionTo);
}
}
}
}
}
开发者ID:imclab,项目名称:Score,代码行数:40,代码来源:Place.cpp
示例17: door
void Simulation::UpdateFlowAtDoors(const Pedestrian& ped) const
{
if (_config->ShowStatistics()) {
Transition* trans = _building->GetTransitionByUID(ped.GetExitIndex());
if (trans) {
//check if the pedestrian left the door correctly
if (trans->DistTo(ped.GetPos())>0.5) {
Log->Write("WARNING:\t pedestrian [%d] left room/subroom [%d/%d] in an unusual way. Please check",
ped.GetID(), ped.GetRoomID(), ped.GetSubRoomID());
Log->Write(" :\t distance to last door (%d | %d) is %f. That should be smaller.",
trans->GetUniqueID(), ped.GetExitIndex(),
trans->DistTo(ped.GetPos()));
Log->Write(" :\t correcting the door statistics");
//ped.Dump(ped.GetID());
//checking the history and picking the nearest previous destination
double biggest = 0.3;
bool success = false;
for (const auto& dest:ped.GetLastDestinations()) {
if (dest!=-1) {
Transition* trans_tmp = _building->GetTransitionByUID(dest);
if (trans_tmp && trans_tmp->DistTo(ped.GetPos())<biggest) {
biggest = trans_tmp->DistTo(ped.GetPos());
trans = trans_tmp;
Log->Write(" :\t Best match found at door %d", dest);
success = true;//at least one door was found
}
}
}
if (!success) {
Log->Write("WARNING :\t correcting the door statistics");
return; //todo we need to check if the ped is in a subroom neighboring the target. If so, no problems!
}
}
//#pragma omp critical
trans->IncreaseDoorUsage(1, ped.GetGlobalTime());
}
}
}
开发者ID:JuPedSim,项目名称:jpscore,代码行数:40,代码来源:Simulation.cpp
示例18: step
bool Automaton::step()
{
//cout << this->name << " state: " << this->cur->id << " ";
for (int i=0; i < cur->transitions.size(); i++) {
Transition * t = cur->transitions[i];
if (t->guard() && t->next->inv()) { // если выполнено условие
if (t->needSync() ) {// если есть действия по синхронизации
bool sync = t->synchronize();
//cout << " channel " << t->channelParticipant->channel->id << " ";
if (sync) {
t->action(); //выполняем действия перехода
cerr << "time = " << net->timeForInternalUse << " " << name << ": " << cur->name << " -> " << t->next->name << endl;
cur = t->next; //изменяем текущее состояние
//cout << this->cur->id << "\n";
return true; //был совершен переход
}
}
else { // синхронизации нет, условие выполнено
t->action(); //выполняем действия перехода
cerr << "time = " << net->timeForInternalUse << " " << name << ": " << cur->name << " -> " << t->next->name << endl;
cur = t->next; //изменяем текущее состояние
//cout << this->cur->id << "\n";
return true; //был совершен переход
}
}
}
//cout << "no trans\n";
return false; //перехода не было
}
开发者ID:AlevtinaGlonina,项目名称:IMASimulator,代码行数:29,代码来源:automaton.cpp
示例19: getNbOfTokens
void Place::produceTokens(unsigned int nbOfTokens, unsigned int colorLabel, unsigned int tokensTime) {
unsigned int oldNumberOfTokens = getNbOfTokens(colorLabel);
for (unsigned int i = 0; i < nbOfTokens; ++i) {
Token token;
token.setRemainingTime(tokensTime);
m_tokenByColor[colorLabel - 1].push_back(token);
}
if ((oldNumberOfTokens < NB_OF_TOKEN_TO_ACTIVE_ARC) && (getNbOfTokens(colorLabel) >= NB_OF_TOKEN_TO_ACTIVE_ARC)) {
arcList outGoingArcs = outGoingArcsOf(colorLabel);
for (unsigned int i = 0 ; i < outGoingArcs.size() ; ++i) {
Arc* arc = outGoingArcs[i];
if (!(dynamic_cast<Transition*>(arc->getTo()))) {
throw IncoherentStateException();
}
Transition* transitionTo = ((Transition*) arc->getTo());
transitionTo->setArcAsActive(arc, tokensTime, true);
if (transitionTo->isStatic()) {
if(arc->getRelativeMinValue().getValue() < (int) tokensTime) {
getPetriNet()->pushTransitionToCrossWhenAcceleration(transitionTo);
}
} else {
if(arc->getRelativeMaxValue().getValue() < (int) tokensTime) {
getPetriNet()->pushTransitionToCrossWhenAcceleration(transitionTo);
}
}
}
}
}
开发者ID:raphaelmarczak,项目名称:libIscore,代码行数:38,代码来源:Place.cpp
示例20: assert
void Simulation::oneStep() {
//Search for possible transitions by source state
vector<Transition*> filteredTransitions;
//std::cout << curState << " ==> ";
auto ret = transitions.equal_range(curState);
for (auto it=ret.first;it!=ret.second;++it) {
filteredTransitions.push_back((*it).second);
}
if (filteredTransitions.empty()) {
curState = "reject";
return;
}
//Search for possible transitions by read character
vector<Transition*> possibleTransitions;
char readValue = tape->getChar();
for (Transition* tr : filteredTransitions ) {
if (tr->getRead() == readValue) {
possibleTransitions.push_back(tr);
}
}
if (possibleTransitions.empty()) {
curState = "reject";
return;
}
// transition
assert(possibleTransitions.size() == 1); // cannot copy with multi transitions
Transition* select = possibleTransitions[0];
char wt = select->getWrite();
char mv = select->getMove();
std::string nextState = select->getNextState();
tape->setChar(wt);
tape->move(mv);
curState = nextState;
//std::cout << nextState << std::endl;
}
开发者ID:Lonesome-George,项目名称:turingmachine,代码行数:38,代码来源:Simulation.cpp
注:本文中的Transition类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论