Questions tagged [finite-state-machine]

130 questions
27
votes
10 answers

Examples of Finite State Machines

I'm looking for good examples of finite state machines; language isn't particularly important, just good examples. Code implementations are useful (generalized pseudo-code), but it's also very useful to gather the various uses of FSM's. Examples…
ocodo
  • 2,947
7
votes
4 answers

Is a finite state machine an appropriate solution for this situation?

I was writing some test code as an example where I had a washing machine class. It has a door state that should be open or closed, and also a running state, either on or off. I want to prevent the running state from changing from 'off' to 'on' when…
user1936
  • 652
  • 5
  • 17
6
votes
1 answer

State machine with additional variable

When implementing a state machine and it comes to the fact that a transition depends on an external boolean a, or an enum value b which can be one out of three (which are set somewhere else in the control flow), like // ... more states ... L : { //…
5
votes
2 answers

Language to describe Finite State Machine

I'm doing a lot of code analysis using lexer and finite state machine. For time being I'm using table to describe FSM: | token | current state | target state | +-------+---------------+--------------+ | . | start | dot | | trace…
aisbaa
  • 159
  • 1
  • 5
3
votes
2 answers

Is there a well defined notion of 'before' and 'after' in finite state machines?

When working with finite state machines, is there or can there be a well defined concept of 'before' and 'after'. The ordering would, for example, tell me that one state is always considered to be 'before' another state, in the sense that any…
3
votes
0 answers

Finite State Machine user input tree

I'm drawing a Finite State Machine (which I'll have to implement later on) which is semi-automatic, i.e. some transitions require user input, some are decided on internal value. The problem is that some transitions are decision trees with several…
friendzis
  • 131
2
votes
2 answers

Hierarchical State Machine (HSM) superstate and substate sharing event

I am learning HSMs and I can see a problem that I don’t know how to address. The problem is shown in the image bellow. Inside S1, substates S11 and S12 are continuously changing in reaction to TIMERTICK event. At the same time the superstate S1…
JHG
  • 21
  • 1
2
votes
1 answer

State machine with database records

I was re-learning about state diagrams this weekend, and realized that I may have been using them for years without realizing it. Suppose i have an order record, with a bunch of fields including status, start date, end date, customer name, address,…
PartOfTheOhana
  • 173
  • 1
  • 6
1
vote
2 answers

Modelling an A to B movement controller, split or merge position and movement as state machines

I am currently creating a software model for controlling a simple (two-way) pneumatic cylinder. In essence, this controls just a movement from point A to point B. The controller has two outputs (OnMovingToA, OnMovingToB), which can be linked to a…
1
vote
1 answer

State Diagram: How to Represent a Parent/Child Object's States Properly?

I made a state diagram for the Purchase object (parent) and for the Item object (child), as you can see below. One of my doubts is how to represent the integration between parent/child objects in the state diagram. The system flow is the following:…
1
vote
4 answers

So what exactly is a final state of a finite state machine?

I am playing around the state machine concept trying to better understand the best areas of their application. The formal definition of an FSM contains the following elements: finite non-empty set of allowed states; an initial state; an alphabet…
Igor Soloydenko
  • 422
  • 6
  • 15
0
votes
1 answer

Is it OK for Finite State Machine entry actions to trigger events?

We're using some FSM library that allows you to define entry and exit actions. For some reason, somebody needed to do this fsm.Configure(State.A) .Permit(Trigger.A, State.B) .OnEntry(() => { IsAuto…
SuperJMN
  • 443
0
votes
2 answers

Why are these options correct for this state machine diagram question?

Considering the following state machine diagram, it is CORRECT to state that: Select one or more: a. the Restart event will always be executed in the Halted state. b. After a Halt and Restart event and assuming no previous history is available the…
0
votes
2 answers

FSM diagrams - Modern device with battery / charger

I'm studying state machines diagrams and was asked to come up with a diagram for a device that turns on and off when a button is pressed... but as with other modern devices nowadays, it can operate either when the battery has charge in it, or when…
h0tfus3
  • 121
0
votes
2 answers

Will FSM be a good solution?

At work, we are creating an android app. We have a business logic module for talking to an API for CRUD operations. The app I'm working on, the UI module, speaks to the business logic module to create, update, delete and get entities. These entities…
1
2