Closed subodhcjoshi82 closed 10 years ago
The graph is a rendering a little weird, but is the main question whether Node4 can be a part of 2 different branches?
Yes Node4 is a child of Node3 and Node2 i want this type of graph or workflow
This is indeed possible. Looks like a flattened finite state machine:
var myflow = _.extend({
initialState: "Root",
states: {
'Root': {
'evt1': { target: 'Start' }
},
'Start': {
'evt2': { target: 'Node0' },
'evt3': { target: 'Node1' }
},
'Node0': {
'evt4': { target: 'Node2' }
},
'Node1': {
'evt5': { target: 'Node3' }
},
'Node2': {
'evt6': { target: 'Node4' }
},
'Node3': {
'evt7': { target: 'Node4' }
},
'Node4': { },
}
}, Statechart);
// Initialize the state machine and make the initial transition (to the `Root` state).
myflow.run();
// Dispatch the `evt1` event to the machine which causes it to transit to the `Start` state. Similarly, one can transit through the whole flow by dispatching appropriate events.
myflow.dispatch('evt1');
Can we edit name of any Node at run time and in my case all information come from DB i mean Node Names? ANd i am using Java in my webapplication.
Not sure if I understand your question properly. Dynamically changing the structure of the state machine is not possible at this time. But if it's only the naming, then one can have a mapping of the actual state names to whatever he wants and dynamically change the mapping only.
I updated my last question
Same thing. No need to change the actual state names, just keep a mapping and change the mapping if needed e.g. for display.
I will try to use your API tomorrow from office and let you know if i got any issue
@subodhcjoshi82 the graph violates the philosophy of https://github.com/gregwebs/StateTree
But from the perspective of StateTree you can also flatten things by instead doing is creating a new branch in the state hierarchy just for Node4 and then restricting access so that it can only be entered via Node2 or Node3.
@gregwebs Why does the graph violate StateTree philosophy? This is just a classical finite state machine not even using nested states or any other advanced StateChart specific features.
Actually, you are right, I added a signals feature that can be used to create state machines like this.
It is impossible to say whether it is better to use that approach or leverage the tree in StateTree. In a graph like this you can't leverage the tree. One advantage of being a tree is that you can ask for the active ancestors (the branch that must be walked from the root to get to the current state). Another advantage of the Tree is that events become unnecessary for many use cases,.
@gregwebs Right, I see. I think I have to study StateTree a little more to get a better understanding of it.
I was trying to run the test example given in your API
but i saw this test example not worked you mentioned node_modules but i did not get any such folder in your downloaded code Can you please guide me what i am doing wrong and how to run test example so that i can integrate it with my Java web application. Thanks
Any update on my last question ?
You need to install NodeJS (http://nodejs.org) first and then run npm install
in the root directory of this repo. The package.json
file lists all the dependencies.
Sorry David can you please add this in document please .Second thing i have to ask if i have to give me product to another company i have to tell them to install this nodejs in their respective machine? Otherwise this workflow will not work?
I Just install Nodejs.org but these file not there expect.js,mocha.js,underscorejs
The NodeJS is only needed for development of the statechart library, more specifically, for running the tests. The statechart library itself runs in browsers and NodeJS. There is no need to install anything if you just want to use the library.
Sorry but i run your test example in Firefox it show me blank page What i am doing wrong?
What is the error?
Failed to load resource file:///C:/Users/sjoshi/Desktop/statechart-master/node_modules/mocha/mocha.css
Failed to load resource file:///C:/Users/sjoshi/Desktop/statechart-master/node_modules/expect.js/expect.js
Failed to load resource file:///C:/Users/sjoshi/Desktop/statechart-master/node_modules/mocha/mocha.js
Uncaught TypeError: Object #
This i found in the Chrome browser
That's what I mentioned. If you want to run the tests, you need to have NodeJS installed and then run npm install
. This will create the node_modules
directory with the test dependencies (mocha, expect and underscore).
Ok it worked but it is not showing any Flowchart it I thought it should display some work flow kind of thing but its showing Samek test machine and other thing
That's correct. This library is a statechart engine, not visualization. If you'd like to visualize your workflow, you might want to take a look at JointJS diagramming library: http://jointjs.com.
So you mean with the help of your API i can not create the Workflow i showed to you?
"Create a workflow" has a broad meaning. The way I perceive it is having an engine that interprets the defined workflow and, potentially, a visualizer that displays the workflow on the screen. This library is an engine. JointJS is a visualizer. Both can be combined together in order to create an application for designing and interpreting workflows.
Ok thanks i will try i am new so its hard to imagine
I will want to create a work flow something like this
Is this possible with this API. If yes how can thanks