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

How to make a generic callback for any "event" in AASM

I have a State Machine, in a Rails app (with ActiveRecord), defined with AASM and it has a lot of callbacks. Some of these callbacks contain repeated code. E.g, on every state change, we need to build and save a record and send a mail. event…
berkes
  • 26,996
  • 27
  • 115
  • 206
0
votes
2 answers

How can I create a List of classes with a generic type parameter in c#?

I'm trying to create my own state machine but ran into some trouble regarding lists of classes with generic type. My code is as below. State.cs: using UnityEngine; using System.Collections; public abstract class State where T:StateMachine { …
0
votes
1 answer

Trigger an event whenever the state machine enters a certain state

I have a state_machine with three possible states state1, state2, state3. Whenever an object enter to state_3 I want to trigger an event event1. in my state_machine, I have after_transition :on => :state_3, :do => :event1. But what happens is…
Suganya
  • 701
  • 1
  • 9
  • 27
0
votes
1 answer

Rails state machine error when executing gem (Errno::EINVAL)

An error occurs when I execute this command: c:\gem install state_machines ERROR: While executing gem ... (Errno::EINVAL) Invalid argument -…
0
votes
2 answers

Limiting the alphabet for finite state automata string matching

Hi I have programmed my finite state automata string matching algorithm. However I am struggling to limit the alphabet to only two characters. My implementation looks similar to…
jonn
  • 103
  • 2
  • 2
  • 11
0
votes
1 answer

Cannot install state_machines gem in Windows environment

I am new to Rails and would like to check how Spree ecommerce solution looks like before the customization. That's why I installed Ruby from RubyInstaller, DevKit, Rails, Spree etc. During installation of state_machines gem, below error appears and…
Maciej S
  • 1
  • 1
0
votes
0 answers

RegEx alternative to state machine to get functions called in sscript

Imagine you have code that looks like console.log(functioncall('Bang goes the' + ' Olufsen (At least I think it does)')); or var_dump(functioncall("Please, for me")); Without having to write a state machine and without running the script, is…
Luke Madhanga
  • 6,871
  • 2
  • 43
  • 47
0
votes
1 answer

Windows Workflows - While Activity for creating multiple tasks not working

I am using a while activity for creating multiple tasks for a workflow. The code is executed fine and the task is created when the loop runs only once. But when the loop runs twice or more, only one task is getting created. Also the WF status shows…
0
votes
1 answer

Getconnection() not working for state machine

I am using jsPlumb statemachine. I would like to save and load my chart later. I googled and found that I would have to do it using json Object. I tried few examples stackoverflow. I am able to get the positions of each of the box but I cannot get…
Arti
  • 2,993
  • 11
  • 68
  • 121
0
votes
1 answer

Verilog FSM and module instantiation

This finite state machine is to act as a controller for a datapath that contains the operators necessary to calculate the GCD of two 4 bit numbers. I am fairly new to this language and I am aware the issue is a probably a missing semi colon or maybe…
KoolaidLips
  • 247
  • 1
  • 8
  • 20
0
votes
0 answers

Malfunctioning concurrent tick functions in my state machine

The purpose of the code I'm writing is that when my 0th bit of PINA is 1, the number displayed on PORTB is incremented. Likewise, if the 1st bit of PINA is 1, the number is decremented. If the button is held down, it will increment/decrement at a…
Jonathan Chiou
  • 349
  • 6
  • 15
0
votes
1 answer

How would you solve this finite-state-machine (Moore)?

I am trying to solve an exercise using Moore's machine, but I am a bit confused. I don't know how many states are needed. Inputs: A (switch): change between auto and manual mode. P (push-button): give high level while is pressed. D (motion…
user2528167
0
votes
1 answer

Switching the status of a state machine from inside a loop

I have an array (nchar[12]) and I wrote this code to print it as vertical columns composed of "X"'s. I first wrote a version with an accumulator and a while-loop and it worked fine, but it only could print colums as long as a given limit. Then I…
maja
  • 697
  • 5
  • 18
0
votes
1 answer

email validation using enums in java or state machine

I want to validate an email address using a state machine. I know there are other ways to do it like using regular expression, but I want to know can it be done using a state machine. Any sample example or a good pointer in right direction will be…
unknown
  • 13
  • 4
0
votes
1 answer

Angular-UI state transition problems

I am using Angular-UI stateProvider to route between different places in my app. In some places, when I call $state.go('newLocation'), the browser will navigate to the newLocation, but immediately return to where I called it from. So I will…
1 2 3
99
100