state-machine

How to implement a FSM - Finite State Machine in Java

守給你的承諾、 提交于 2019-11-26 21:39:37
I have something to do for work and I need your help. We want to implement a FSM - Finite State Machine , to identify char sequence(like: A, B, C, A, C), and tell if it accepted. We think to implement three classes: State , Event and Machine . The state class presents a node in the FSM , we thought to implement it with State design pattern , every node will extend from the abstract class state and every class would handle different types of events and indicate transitions to a new state. Is it good idea in your opinion? Second thing, we don't know how to save all the transitions. Again we

state machines tutorials [closed]

喜你入骨 提交于 2019-11-26 18:03:17
I am just wondering if anyone know of some good tutorials on the Internet for developing state machines. Or ebooks? I am starting working on state machines and just need something general to get me started. qrdl State machines are very simple in C if you use function pointers. Basically you need 2 arrays - one for state function pointers and one for state transition rules. Every state function returns the code, you lookup state transition table by state and return code to find the next state and then just execute it. int entry_state(void); int foo_state(void); int bar_state(void); int exit

implementing a state machine using the “yield” keyword

泪湿孤枕 提交于 2019-11-26 17:38:37
问题 Is it feasible to use the yield keyword to implement a simple state machine as shown here. To me it looks like the C# compiler has done the hard work for you as it internally implements a state machine to make the yield statement work. Can you piggy-back on top of the work the compiler is already doing and get it to implement most of the state machine for you? Has anyone done this, is it technically possible? 回答1: It's feasible but it is a bad idea. Iterator blocks were created to help you

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

北战南征 提交于 2019-11-26 15:34:31
问题 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

Python state-machine design

十年热恋 提交于 2019-11-26 15:03:59
问题 Related to this Stack Overflow question (C state-machine design) , could you Stack Overflow folks share your Python state-machine design techniques with me (and the community)? At the moment, I am going for an engine based on the following: class TrackInfoHandler(object): def __init__(self): self._state="begin" self._acc="" ## ================================== Event callbacks def startElement(self, name, attrs): self._dispatch(("startElement", name, attrs)) def characters(self, ch): self.

Simple state machine example in C#?

ε祈祈猫儿з 提交于 2019-11-26 13:54:56
Update: Again thanks for the examples, they have been very helpful and with the following I don't mean to take anything away from them. Aren't the currently given examples, as far as I understand them & state-machines, only half of what we usually understand by a state-machine? In the sense that the examples do change state but that's only represented by changing the value of a variable (and allowing different value- changes in different states), while usually a state machine should also change it's behavior, and behavior not (only) in the sense of allowing different value changes for a

How to implement a FSM - Finite State Machine in Java

有些话、适合烂在心里 提交于 2019-11-26 08:00:02
问题 I have something to do for work and I need your help. We want to implement a FSM - Finite State Machine , to identify char sequence(like: A, B, C, A, C), and tell if it accepted. We think to implement three classes: State , Event and Machine . The state class presents a node in the FSM , we thought to implement it with State design pattern , every node will extend from the abstract class state and every class would handle different types of events and indicate transitions to a new state. Is

Simple state machine example in C#?

佐手、 提交于 2019-11-26 05:56:57
问题 Update: Again thanks for the examples, they have been very helpful and with the following I don\'t mean to take anything away from them. Aren\'t the currently given examples, as far as I understand them & state-machines, only half of what we usually understand by a state-machine? In the sense that the examples do change state but that\'s only represented by changing the value of a variable (and allowing different value- changes in different states), while usually a state machine should also

C state-machine design

╄→гoц情女王★ 提交于 2019-11-26 05:42:26
问题 I am crafting a small project in mixed C and C++. I am building one small-ish state-machine at the heart of one of my worker thread. I was wondering if you gurus on SO would share your state-machine design techniques. NOTE: I am primarily after tried & tested implementation techniques. UPDATED: Based on all the great input gathered on SO, I\'ve settled on this architecture: 回答1: State machines that I've designed before (C, not C++) have all come down to a struct array and a loop. The