cotestatnt / ya_fsm Goto Github PK
View Code? Open in Web Editor NEWSimple state machine. Implements a "Petri net" (GRAFCET/SFC) inspired state machine with states, transitions and actions
License: Apache License 2.0
Simple state machine. Implements a "Petri net" (GRAFCET/SFC) inspired state machine with states, transitions and actions
License: Apache License 2.0
Hi: I love your library and have a project that needs to instantiate multiple, independent state machines. For code cleanliness and to avoid global variables, I tried to subclass YA_FSM to encapsulate the shared settings, a la
class PulsarStateMachine : public YA_FSM {public: int pulsarTimeout = 100; ...}
and then I have a PulsarStateMachine::Setup()
function that defines the states, actions, and transitions.
However, I'm getting stuck following your timed transition pattern from within that Setup() function, because the lambda doesn't know how to find the CurrentState()->timeout
. Your recommended pattern is:
this->AddTransition(ON_STATE, OFF_STATE, [](){return stateMachine.CurrentState()->timeout;} );
...but I'm wondering whether we could simplify by adding something to YA_FSM::Update() that directly checks _currentState->timeout;
Is there a reason you implemented with lambdas that I'm overlooking or could we add an AddTimedTransition(FROM_STATE, TO_STATE)
function and skip the complexity of lambdas and function pointers?
Thank you for humoring me, and apologies if I'm missing something subtle for why you designed it this way. I'm not super familiar with lambda syntax and after a day of fighting with various captures and compiler warnings, wondered if this might be a simpler solution.
Hello,
Is it intentional for the OnState callback to be called once for each transition defined? I was expecting OnState callback to be called once for each Update.
Thanks.
YA_FSM::GetTimeout returns _currentState-YmaxTime as bool
Timout handling not working
Should be:
// Return true if timeout
bool YA_FSM::GetTimeout(uint8_t index){
FSM_State* state = GetStateAt(index);
if(state != nullptr ){
return _currentState->timeout;
}
return false;
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.