当前位置: 首页>>代码示例>>C++>>正文


C++ FSM类代码示例

本文整理汇总了C++中FSM的典型用法代码示例。如果您正苦于以下问题:C++ FSM类的具体用法?C++ FSM怎么用?C++ FSM使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了FSM类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

int main (int argc, char **argv)
{
	std::string input;
	std::string file = "./10021.response";
	char buf[1024];

	if (argc > 1)
		file = argv[1];

	FSM fsm;
	fsm.init(file);

	// XXX: integrating into deceptiond framework
	// timeouts can be set via the InputStream obj
	// '>>' tokenizes using \s ;( this should be different using
	// the InputStream
	while(1) {
		std::cin.getline(buf, 1023, '\n');
		if (buf[0] == 0)
			break;
		input = buf;
		fsm.parse(input);
	}

	return 0;
}
开发者ID:roidrage,项目名称:deception_toolkit,代码行数:26,代码来源:fsmmain.cpp

示例2: HandlePollCompleteResponse

void HandlePollCompleteResponse(
        FSM & fsm,
        const mf::api::upload::poll_upload::Response & response
    )
{
    if (response.quickkey)
    {
        if (response.filename)
        {
            // Filename was changed
            fsm.ProcessEvent(event::PollComplete{
                *response.quickkey,
                *response.filename
                });
        }
        else
        {
            fsm.ProcessEvent(event::PollComplete{
                *response.quickkey,
                fsm.filename()
                });
        }
    }
    else
    {
        fsm.ProcessEvent(event::Error{
            make_error_code(api::api_code::ContentInvalidData),
            "Successful response missing quickkey"
            });
    }
}
开发者ID:dazw666,项目名称:mediafire-cpp-sdk,代码行数:31,代码来源:transition_poll_upload.hpp

示例3: create_test_file

/* Create random input file with i states and MAX_EVENTS events */
void create_test_file(const string& filename, int states, int events) {
	FSM fsm = create_initial_FSM(states, events);
	make_accessible(fsm);
	ofstream file_out(filename);
	if (EXTENSION == ".txt") fsm.print_txt(file_out);
	else if (EXTENSION == ".fsm") fsm.print_fsm(file_out);
	file_out.close();
}
开发者ID:morrimax,项目名称:DES_Supervisor,代码行数:9,代码来源:scalability_test.cpp

示例4: BEHAVIAC_UNUSED_VAR

	bool FSMTask::onenter(Agent* pAgent)
	{
		BEHAVIAC_UNUSED_VAR(pAgent);
		FSM* fsm = (FSM*)this->m_node;
		this->m_activeChildIndex = 0;

		this->m_currentNodeId = fsm->GetInitialId();

		return true;
	}
开发者ID:dengyangli,项目名称:behaviac,代码行数:10,代码来源:fsm.cpp

示例5: top

top (sc_module_name name) : sc_module (name), clk("Clk", period){
	fsm = new FSM("Statemachine", 100, 30); //Creating a new state machine with limit = 100.
	fsm->tick(clk);
	fsm->portA(Aout);
	fsm->X(Xin);

	Xcount = 0;
	Acount = 0;
	Xinput = false;

	SC_HAS_PROCESS(top);
	SC_CTHREAD(testbed, clk);
}
开发者ID:strandvik,项目名称:EnbrikkeGIT,代码行数:13,代码来源:top.cpp

示例6: FSMA

bool TestCase3::onInit()
{
    FSM *fsm = new FSMA();
    fsm->create("fsm3").start();
    fsm->subscribeBcEvent("TestEvt1");


    EvtStream data;
    std::string input = "000 hello world! 300 abc123";
    data << 23 << input;
    fsm->sendBcEvent("TestEvt1", data);

    return true;
}
开发者ID:stefangao,项目名称:llfsm,代码行数:14,代码来源:test3.cpp

示例7: FSM

FSM * FSM::create(std::string state, std::function<void()> onEnter)
{
	FSM* fsm = new FSM(state, onEnter);
	if ( fsm && fsm->init())
	{
		fsm->autorelease();
		return fsm;
	}
	else
	{
		CC_SAFE_DELETE(fsm);
		return nullptr;
	}
}
开发者ID:shvanceinfo,项目名称:GameResource,代码行数:14,代码来源:Fsm.cpp

示例8: FSM

/* This function rerturns the fsm to be equivalent to (fsm1|fsm2) 
 * XXX : Use with caution. This modifies fsm1, but the return value must be 
 * stored back in fsm1 for this to be effective.
 *
 * DO NOT try something like "fsm1 | fsm1", this will ave 
 */
FSM * FSM::operator | (FSM& rhs)
{
	/* Create a new (empty) start and end FSM */
	FSM *startFSM = new FSM();
	FSM *endFSM   = new FSM();

	/* Concatenate one of the two fsm-s with the start and end */
	this->concatenate (*endFSM);
	startFSM->concatenate (*this);

	/* Create a transition to the start state of other fsm */
	rhs.concatenate (*endFSM);

	/* Create a transition from the end state of other fsm */
	startFSM->startState.createTransition ('e', EPSILON, &(rhs.startState));
	return startFSM;
}
开发者ID:KWMalik,项目名称:Compiler,代码行数:23,代码来源:FSM.cpp

示例9: FSM

FSM* IRParser::parseFSM(llvm::MDNode* node){
    FSM* fsm = new FSM();

    //Parse initial state
    MDString* initialState = cast<MDString>(node->getOperand(0));

    //Parse all fsm state
    MDNode* stateArray = cast<MDNode>(node->getOperand(1));

    for (unsigned i = 0, e = stateArray->getNumOperands(); i != e; ++i){
        MDString* stateMD = cast<MDString>(stateArray->getOperand(i));
        fsm->addState(stateMD->getString());
    }

    // set the initial state after initializing the states
    fsm->setInitialState(initialState->getString());


    //Parse transition
    MDNode* transitionsArray = cast<MDNode>(node->getOperand(2));

    for (unsigned i = 0, e = transitionsArray->getNumOperands(); i != e; ++i){
        MDNode* transitionArray = cast<MDNode>(transitionsArray->getOperand(i));
        MDString* source = cast<MDString>(transitionArray->getOperand(0));


        Value* targetValue = transitionArray->getOperand(1);

        //In case of "undefined" state, no target are given
        if (targetValue != NULL){
            MDNode* targetsArray = cast<MDNode>(targetValue);
            for (unsigned j = 0, f = targetsArray->getNumOperands() ; j != f; ++j){
                MDNode* targetArray = cast<MDNode>(targetsArray->getOperand(j));

                Action* action = getAction(cast<MDNode>(targetArray->getOperand(0)));
                MDString* target = cast<MDString>(targetArray->getOperand(1));


                fsm->addTransition(source->getString(), target->getString(), action);
            }
        }
    }

    return fsm;
}
开发者ID:orcc,项目名称:jade,代码行数:45,代码来源:IRParser.cpp

示例10: main

int main()
{
    enum Message { on, off, ack };
    Message messageArray[10] = { on,off,off,ack,ack,ack,ack,on,off,off };
    FSM* context = new FSM(B::getInstance());
    for (int index=0; index < 10; index++)
    {
        if(messageArray[index] == on)
            context->on();
        else if(messageArray[index] == off)
            context->off();
        else if(messageArray[index] == ack)
            context->ack();
        cout<<endl;
    }

    return 1;
}
开发者ID:zengxy,项目名称:design_pattern,代码行数:18,代码来源:state.cpp

示例11: fsm_simple

FSM fsm_simple() {
    FSM fsm;
    int even = fsm.addState("Even", true);
    int odd = fsm.addState("Odd");
    fsm.addTransition(even, even, 1, "1");
    fsm.addTransition(even, odd, 0, "0");
    fsm.addTransition(odd, odd, 1, "1");
    fsm.addTransition(odd, even, 0, "0");
    return fsm;
}
开发者ID:JuanVM2,项目名称:cs2270,代码行数:10,代码来源:fsm_driver.cpp

示例12: StartPoll

void StartPoll(const std::string & upload_key, FSM & fsm)
{
    if (upload_key.empty())
    {
        assert(!"Reached poll upload without upload key");
        fsm.ProcessEvent(
                event::Error{make_error_code(uploader::errc::LogicError),
                             "Filsize unavailable."});
        return;
    }

    auto fsmp = fsm.AsFrontShared();

    fsm.GetSessionMaintainer()->Call(
            mf::api::upload::poll_upload::Request(upload_key),
            [fsmp, upload_key](
                    const mf::api::upload::poll_upload::Response & response)
            {
                HandlePollResponse(upload_key, *fsmp, response);
            });
}
开发者ID:MediaFire,项目名称:mediafire-cpp-sdk,代码行数:21,代码来源:transition_poll_upload.hpp

示例13: make_accessible

void make_accessible(FSM& fsm) {
	vector<int> current_access(fsm.nstates);
	int current = 0; //Initial state
	queue<int> BFS; //Breadth First Search
	BFS.push(current); 
	do_BFS(BFS, current, current_access, fsm);
	/* While there exists an inaccessible state */
	int inaccessible_state = fsm.find_inaccessible(current_access);
	while(inaccessible_state != -1) {
		int event_out = rand() % fsm.nevents;
		int state_out = rand() % fsm.nstates;
		while (transition_is_invalid(fsm, current_access, state_out, event_out)) {
			state_out = rand() % fsm.nstates;
			event_out = rand() % fsm.nevents;
		}
		/* Add transition from accessible state to inaccessible state */
		fsm.transitions[state_out][event_out] = inaccessible_state;
		BFS.push(inaccessible_state);
		do_BFS(BFS, inaccessible_state, current_access, fsm);
		inaccessible_state = fsm.find_inaccessible(current_access);
	}
}
开发者ID:morrimax,项目名称:DES_Supervisor,代码行数:22,代码来源:scalability_test.cpp

示例14: disconnectedUpdate

void disconnectedUpdate() {
  if(Particle.connected()) {
    connectionFsm.transitionTo(Online);
  } else if(connectionFsm.timeInCurrentState() > DISCONNECTED_TIMEOUT) {
    connectionFsm.transitionTo(Offline);
  }
}
开发者ID:monkbroc,项目名称:internet_light,代码行数:7,代码来源:application.cpp

示例15: error

void error(String message) {
  if(self.isInState(Start)) {
    sd.initErrorPrint(&terminal);
  } else {
    sd.errorPrint(&terminal);
  }
  terminal.flush();

  errorMessage = message;
  self.transitionTo(Error);
}
开发者ID:tjpeden,项目名称:mane-avis,代码行数:11,代码来源:ManeAvis.cpp


注:本文中的FSM类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。