Comments (4)
Not sure I follow... Can you explain what you're trying to do? A code sample might help as well.
from transitions.
I have this:
transitions = [
{ 'trigger': 'pulse', 'source': 'input', 'dest': 'input', 'conditions': 'IsConditionMet'},
{ 'trigger': 'pulse', 'source': 'input', 'dest': 'log', 'conditions': 'IsConditionMet'},
{ 'trigger': 'pulse', 'source': 'input', 'dest': 'display', 'conditions': 'IsConditionMet'},
{ 'trigger': 'reset', 'source': '*', 'dest': 'input'}
]
As you can see all the conditions are the same i.e. IsConditionMet
Then I have:
def IsConditionMet(self):
if self.State == 'input' and dest == 'input':
return False
.....
return False
The idea is I don't want to populate my class with each condition in transition.
I just want to have 1 method.
Please let me know if that make sense. I may be having paralysis analysis =)
from transitions.
Oh, I see. It should actually work exactly the way you want it to, I believe. In your example, 'IsConditionMet' is just a pointer to the function. It's fine if all conditions point to the same function. All you're missing is catching the EventData instance. I.e., this should work:
def IsConditionMet(self, event_data):
# trans is a Transition instance that has .source and .dest properties you can access.
trans = event_data.transition
...
return False
Closing this unless there are any other issues.
from transitions.
Wow! You are absolutely correct! Thank you for your prompt reply and solution! Awesome module!!!!!
from transitions.
Related Issues (20)
- State transition during on_exception callback causes RecursionError
- "on_exception" is not invoked for "KeyboardInterrupt"
- Explicitly reexport package names
- GraphMachine: set proportional font or allow caller control HOT 3
- AttributeError: 'state' does not exist HOT 3
- prepare func raises Exception altough on_exception is defined
- GraphMachine seems not working for parallel states HOT 1
- AsyncMachine transitions fail when a list of `State` objects are passed in to the FSM. HOT 2
- get_triggers does not work HOT 3
- Cannot use Pydantic `BaseModel` class for models HOT 2
- All possible transitions are initialized, instead of those provided as an argument. HOT 2
- Machine get into wrong state. HOT 1
- after_state_change not triggered by set_state HOT 2
- AsyncMachine with queued transitions breaks when transition is cancelled
- AsyncMachine transitions aren't atomic
- The Event and Machine have cyclic dependency. HOT 3
- Update COPR packages
- get_triggers does not get child states in HierarchicalAsyncMachine HOT 1
- may_ function in parallel state does not report correct value
- 3.12 Performance HOT 9
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from transitions.