Questions tagged [state-machine]

A State Machine is a computation model used to design both computer programs and sequential logic circuits. It determines that an entity in a program can be in one of a finite number of states. The state it is in at any given time is called the current state. It can change from one state to another when initiated by a triggering event or condition; this is called a transition.

A state machine is an abstract machine, which possesses

  • State a condition that when tested will be either true or false
  • Transitions the result of true/false decision to another State
  • Entry actions (what happens when a state is entered)
  • Exit actions (analogous to entry actions)

As a result, a system can dynamically change its behavior based upon what it is currently doing and what input it receives - this allows state machines to model many types of systems. (An familiar example is Regex - Perl, Python, Tcl, .NET, and most other implementations use a state machine internally).

For example, consider a printer, which can be either waiting for a job, or printing it (states), and can start printing when a job is received and start waiting when it is done with the current job (transitions). Send notification is an exit action for the "Printing" state, to notify the print queue that it is done.

SDL description of a printer

(The above diagram is in the SDL format - UML is also popular for representing state diagrams).

#Related tags - The Coyote open source asynchronous programming framework

1708 questions
0
votes
1 answer

Should states in an FSM be friends with the context type?

I've built a class-based Push-down Automaton Finite State Machine. The context class (the class whose internal state is being modified) has some methods that only the states should access (incrementing/decrementing some iterators, pushing/popping…
Casey
  • 10,297
  • 11
  • 59
  • 88
0
votes
1 answer

Lift FSM Design

Hello guys I want to design a Finite state machine for lift controller and I have no idea what can be the states and the transitions between them. The lift has three levels and can move up and down, and can open and close its doors. The lift has…
0
votes
1 answer

Appccelerate state machine state with timer

Ok I am sure I am not using the state machine correctly but here is subset of sample code. This is the Appccelerate.StateMachine which used to be bbvcommon.StateMachine. fsm.In(State.Idle) .ExecuteOnEntry(() => { // wake up and check if…
rukiman
  • 597
  • 10
  • 32
0
votes
1 answer

regular expression python that accepts everything

I want to write a re that accepts everything that is between parenthesis. My re is: r''\'([^&]+'\')' (ingnore the '' in the backslash) I had to put that random character so it will accept everything except that. How can I write it so it accepts…
Kevjumba94
  • 19
  • 2
0
votes
2 answers

Deterministic Finite State Automata for Modulo Comparison

I'm working on creating a deterministic finite state automata for the following problem: You can create strings made of x's and y's. How do you create a diagram that only accepts the language when the number of (x's mod 4) is greater than the number…
sc1892353
  • 85
  • 1
  • 10
0
votes
0 answers

How do I implement a dynamic kind of single state system?

I am trying to design a game which needs to do the following: Have a lobby period, move players into a pre-game setup, start the game, end the game, repeat. My current setup is as follows: A MatchManager creates and destroys Match objects and sets…
njny
  • 559
  • 2
  • 15
0
votes
2 answers

Is there a correct way of composing moore machines?

A mealy machine is just a stateful function. Hence, two mealy machines can be composed using simple function composition. A moore machine is a restricted mealy machine with an initial output value. Is there a way to compose two moore machines? This…
0
votes
1 answer

c++11 template metaprogramming construct a std::unorderer_map at compile time

i trying to develop a Finite State Machine with template meta programming techniques, but i getting stuck with a map that it has to be fill at compile time, this the code(gcc 4.8 c++11): #include #include
Ricardo_arg
  • 520
  • 11
  • 28
0
votes
1 answer

Independent subtates in a state machine

I need some suggestions. I am trying to implement an online order process through Spring state machine and am trying to construct a state diagram before I get to work. Now say my order can be canceled by three different admin users…
0
votes
1 answer

Spring Statemachine StateMachineBuilder builds a state machine with null state

Since I must support concurrent access to the state machine, I can't use the usual Autowired singleton approach. Instead, I am trying to build the state machine as described in the docs,…
Marc
  • 1,812
  • 4
  • 23
  • 36
0
votes
3 answers

How to save the values if the app when its closed

i am new to iPhone programming.. my app is just like a quiz.. it has different type of quizs and many question in each quiz type i want to save the values like strings(quiz name) and integers(question number) when an application is closed so when…
rockey
  • 638
  • 4
  • 16
  • 34
0
votes
1 answer

State machine transition timing calculation using c++

I was written state machine implementation using C++ code , Now i need calculate the transition timing between one system state to another system state ? Please help any API is there in C++ to calculate timing between the states ? Please suggest…
P Kumarasamy
  • 126
  • 1
  • 5
0
votes
1 answer

Best way to log the time of the moment when an attribute was changed on a record in Rails?

I'm using a state-machine in Rails, and I'd like to log time of the last time the state was changed. What would be the best way to accomplish this? Thanks!
alejorivera
  • 935
  • 1
  • 10
  • 25
0
votes
1 answer

verilog, FSM, finite state machine ,error

When I simulate the below module in Modelsim, I did not see any output wave for cikis, please let me know what went wrong with this FSM and test-bench. I have 3 input and 1 output for the module. module sayici_fsm( clock, reset,cikis, out); …
0
votes
2 answers

Re using a State Machine in CAPL

I have made a very simple state machine in CAPL that tells me when a signal went high and for how long it stayed ON before turning OFF. Now I have around 70 more signals where I need to know when the signal started and how long it stayed ON before…
rohit.ranjan
  • 19
  • 2
  • 7