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
2 answers

(state_machine gem) How can I use instance variables within a state machine?

I'm trying to follow along with a lecture by implementing a gumball machine as a state machine. The intent is that it's initialized with 0 coins and 10 gumballs. By default, it's ready; you insert a coin, and from there either request_refund or…
GreenTriangle
  • 2,382
  • 2
  • 21
  • 35
0
votes
1 answer

How to assign a state after a delay

Is it possible to assign a change in state after a delay? I am doing a traffic light controller and I want to transition from the yellow state after 4 sec always @(next_state, EW, Count) begin case (next_state) s0: if (EW&Count) next_state =…
Rocky Q
  • 1
  • 1
0
votes
1 answer

Synthesised Synthesis/Implementation

I'm attempting to create an I2C Bus, however I've stumbled into a very awkward problem - during the mapping part of implementation I get the warning that MapLib:701 - Signal SDA connected to top level port SDA has been removed. After digging back…
davidhood2
  • 1,367
  • 17
  • 47
0
votes
1 answer

How to keep last created state when there is recursive state change in state machine?

I have a state machine like code, which has state A,B and C, and a function changeState(char i) which can change the state of a system, and each state can call changeState(char i) to switch the system to another state: struct State{ State(char…
ggrr
  • 7,737
  • 5
  • 31
  • 53
0
votes
2 answers

Finite-state automation that accepts sum of digits divisible by n

Finite state machine that accepts if sum of digits divisible by 3 . I am trying to construct a finite state machine the accepts if the sum of digits is divisible by n. So far I was able to do for n=2 and n=3 but dint find any generalized steps that…
0
votes
1 answer

Prove that a DFA over binary alphabet with k states can recognise a maximum of k^(2k +1) * 2^k languages

I was given this question in a test and I couldn't do it. After trying on it a little I am still unable to do it. I think I am missing something but not sure what. Can anybody help me?
Vipul Rajan
  • 494
  • 1
  • 5
  • 16
0
votes
1 answer

In what situation should we adopt state pattern?

In what situation should we adopt state pattern? I've been assigned to maintain a project, the project state machine was implemented by switch-case that are 2000+ lines long. It will be hard to expand function, so I would like to refactor it. I'm…
0
votes
1 answer

UnityScript, Static Methods using Coroutines in FSM's

this is my first big game project for Unity, and im trying to achieve using static methods calling coroutines to change game state and load levels with update calls in between. from what i have read something like this would work? public class Game…
ninjagear
  • 1
  • 3
0
votes
2 answers

Spring statemachine Persist recipe with two state machine configurations

I am trying to extend the Persist sample of spring statemachine to two different state machine configurations. http://docs.spring.io/spring-statemachine/docs/1.0.0.RELEASE/reference/htmlsingle/#statemachine-examples-persist Therefor I added a new…
user5545707
0
votes
1 answer

Unable to update a list item from a workflow task in C#

I am not getting any exceptions, but the code below is simply not working. Any ideas? SPSecurity.RunWithElevatedPrivileges(delegate() { using (SPWeb web = this.workflowProperties.Web) { try { SPListItem item =…
billsecond
  • 612
  • 3
  • 21
  • 50
0
votes
1 answer

My UserFriendship create action does not save user_id and friend_id

I am using the 'state_machine' gem. Once I create a new UserFriendship, the user_id and friend_id do not get saved. I even tried creating manually the friendship in the console by passing the user_id and friend_id directly but still these two…
codigomonstruo
  • 1,081
  • 1
  • 11
  • 45
0
votes
2 answers

Synchronously Counting Debounced Button Presses in VHDL

The following code is a VDHL module in Xilinx ISE 14.7 that counts debounced button presses (iXXX), tests to see if they have reached a max, and outputs a "value" for each accumulated input to a std_logic_vector (oXXX) that will be displayed on a…
0
votes
1 answer

state_machine in rails 4 not proper initialize state column value

I am learning Rails and try to use state machine but i am not able to initialize value for state variable..can anyone help me class Primer < ActiveRecord::Base extend StateMachine::MacroMethods state_machine :initial => :data do event…
0
votes
1 answer

Communication between two state machines in Java

I've been using a simple eclipse plugin to create visual state machines, called statecharts, that also uses Java code to work. My overall goal is to make two state machines communicate with each other through sockets and exchange data and make…
Tina J
  • 4,983
  • 13
  • 59
  • 125
0
votes
0 answers

VHDL button debouncing in state machine application

I'm programming an FPGA board w/ Lattice XP2-5E chip. On board are also 4 rows and 2 columns of LED lights which I'm trying to control with 4 directional push-buttons and one reset push-button. For instance, if (1st row/1st column) LED is turned on…
kreso
  • 11
  • 1
  • 4