state-machine

Design Pattern problem involving N states and transitions between them

只愿长相守 提交于 2019-11-28 16:15:10
I have a problem at hand and I am not getting which design pattern to use. The problem goes as such: I have to build a system which has 'N' states and my system has to do a transition from any state to any other state depending on some conditions. Ex: On condition 1, movement from State 1 to 3 and on condition 2 from state 1 to 4. Even the transition from one state to other state can be done on 2 or more different conditions. For example, transition from State 1 to state 3 can be done when: condition 1 : "Its a Sunday" condition 2: "Its Raining" condition 3: "Its Raining and Sunday" In each

Java enum-based state machine (FSM): Passing in events

拥有回忆 提交于 2019-11-28 15:59:41
问题 I'm using several enum-based state machines in my Android application. While these work very well, what I am looking for is a suggestion for how to elegantly receive events, typically from registered callbacks or from eventbus messages, into the currently active state. Of the many blogs and tutorials concerning enum-based FSMs, most of them give examples of state machines that consume data (e.g. parsers) rather than show how these FSMs may be driven from events. A typical state machine I'm

Workflow engine in Javascript [closed]

做~自己de王妃 提交于 2019-11-28 15:21:26
Does anybody know a workflow engine (such as Spring WebFlow) for Javascript? We have a home-made framework that allows us to guide site navigation using JSON, but its quality is far from good. Edit based on given answers: the engine must run on the browser and reduce to minimum the number of requests to the server. eabait As suggested by katspaugh I'm posting the libraries I found as the answer. List of workflow libraries that I've found until now: XState - https://github.com/davidkpiano/xstate Workflow.js for Backbone.js https://github.com/kendagriff/workflow.js Sprout Workflow Engine https:/

get list of state_machine states

青春壹個敷衍的年華 提交于 2019-11-28 07:08:54
We are using state_machine ( https://github.com/pluginaweek/state_machine ) in a project and would like to offer a form with a select that lets us choose a state. (this is for searching, not for setting). I can't seem to find a way to list out all the possible states? Surely there should be an automatic way of doing this, not having to hard-code a list of text somewhere. Thanks! Something like: User.state_machine.states.map &:name Just to add to this (because I'm constantly searching for this answer, and I always come back to this page), if you are trying to list the states for a giving state

VHDL state machine differences (for synthesization)

核能气质少年 提交于 2019-11-28 05:09:08
问题 I am taking a class on embedded system design and one of my class mates, that has taken another course, claims that the lecturer of the other course would not let them implement state machines like this: architecture behavioral of sm is type state_t is (s1, s2, s3); signal state : state_t; begin oneproc: process(Rst, Clk) begin if (Rst = '1') then -- Reset elsif (rising_edge(Clk)) then case state is when s1 => if (input = '1') then state <= s2; else state <= s1; end if; ... ... ... end case;

How to Make a Basic Finite State Machine in Objective-C

拥有回忆 提交于 2019-11-28 03:50:05
I am attempting to build an FSM to control a timer in (iphone sdk) objective c. I felt it was a necessary step, because I was otherwise ending up with nasty spaghetti code containing pages of if-then statements. The complexity, non-readability, and difficulty of adding/changing features lead me to attempt a more formal solution like this. In the context of the application, the state of the timer determines some complex interactions with NSManagedObjects, Core Data, and so forth. I have left all that functionality out for now, in an attempt to get a clear view of the FSM code. The trouble is, I

Use cases of the Workflow Engine

早过忘川 提交于 2019-11-28 02:37:16
I'd like to know about specific problems you - the SO reader - have solved using Workflow Engines and what libraries/frameworks you used if you didn't roll your own. I'd also like to know when a Workflow Engine wasn't the best choice and if/how you chose something simpler, like a TaskList/WorkList/Task-Management type application using state machines. Questions: What problems have you used workflow engines to solve? What libraries/frameworks did you use? When did a simpler State Machine/Task Management like system suffice? Bonus: How did/do you make the distinction between Task Management and

Can UML state machine diagram be used to show the screen navigation?

落爺英雄遲暮 提交于 2019-11-27 22:53:12
问题 Can UML state machine diagram be used to show the screen navigation? 回答1: Sure you can create a UML model of the UI as a state machine, for example: Screens are states State transitions i.e. screen changes occur on specific inputs or other triggers Did you actually have some more specific question? 回答2: You can use state machines but it is also possible to use sequence diagrams for that. If you don't need to stick to the pure UML, there are plenty of approaches devoted to the specification of

Why does this take so long to match? Is it a bug?

守給你的承諾、 提交于 2019-11-27 11:26:05
I need to match certain URLs in web application, i.e. /123,456,789 , and wrote this regex to match the pattern: r'(\d+(,)?)+/$' I noticed that it does not seem to evaluate, even after several minutes when testing the pattern: re.findall(r'(\d+(,)?)+/$', '12345121,223456,123123,3234,4523,523523') The expected result would be that there were no matches. This expression, however, executes almost immediately (note the trailing slash): re.findall(r'(\d+(,)?)+/$', '12345121,223456,123123,3234,4523,523523/') Is this a bug? There is some catastrophic backtracking going on that will cause an

uses for state machines [closed]

不打扰是莪最后的温柔 提交于 2019-11-27 10:16:08
In what areas of programming would I use state machines ? Why ? How could I implement one ? EDIT: please provide a practical example , if it's not too much to ask . In what areas of programming would I use a state machine? Use a state machine to represent a (real or logical) object that can exist in a limited number of conditions (" states ") and progresses from one state to the next according to a fixed set of rules. Why would I use a state machine? A state machine is often a very compact way to represent a set of complex rules and conditions, and to process various inputs. You'll see state