state-machine

State machines and UI: Rendering based on 'node-level' states instead of 'leaf' states

馋奶兔 提交于 2019-12-05 00:08:07
Before proceeding, I'd like to point out that the title of this question was rather difficult to phrase. If a more suitable title should be used, please let me know so that I may change it and make this question more useful to others. OK, on to the problem… I am currently working on a React/Redux project. A design decision I made was to manage app state and UI almost entirely with (hierarchical) state machines, for a number of reasons (which I won't delve into). I have taken advantage of Redux to store my state tree in a substate called store.machine . The rest of the Redux substates are then

Finite State Machine In C

心已入冬 提交于 2019-12-04 21:36:33
I am trying to create a simple finite state machine in C and I'm quite confused on how to get started. I tried looking online but nothing has really cleared this up for me. My goal is to check if a string is octal, hex or a decimal. To be octal the string must start with a 0, followed by digits 0-7. To be hex the string must start with 0x or OX, followed by (a-f, A-F, 0-9) My attempt at creating the states would be: typedef enum { ERROR, OCTAL, HEX, DECIMAL } stringStates; Now, I would then use a switch statement to go through the entirety of the string and switch between the different states

Workflow design advice for ASP.Net web application?

只谈情不闲聊 提交于 2019-12-04 17:27:32
My team has been tasked with designing a web application that is workflow driven. I need some advice regarding the design. The workflows need to be dynamic. Meaning, users can define the workflows through some interface and apply those workflows to a given scenario (The definitions will live in a SQL 2008 Database). The scenarios are defined by the business and will never change. So there may be only 2 types of scenarios a workflow can be defined for. The workflows are not necessarily linear. Some sort of state will drive the workflow. States will also be dynamic, but only exist in a workflow.

state transition with different guard condition

寵の児 提交于 2019-12-04 16:50:43
In the state pattern how is this modeled ? state A to state B on trigger X and conditon C1 when current state is A state A to state C on trigger X and condition C2 when current state is A how is this usually accomplished ? I have a lot of guard conditions that I may need to implement. That's pretty standard see e.g. this example . [Edited on basis it's not homework!] Assuming I understand right: You have one event ( X ) which can trigger one of two possible transitions Selecting which transition to fire is made according to which condition holds true ( C1 or C2 ) If so that's a standard case

Emitting signals from class, if transition in QStateMachine was successful

北城余情 提交于 2019-12-04 16:43:00
My problem is the following: I need to create class, which contains QStateMachine instance. This class should have slots through which you could "ask" state machine to make transition to another state. And if transition was successful, my class should emit signal about it. How would I implement this? Class should have ability to emit certain signals according to certain slot invoke. Here is a small example of class: class MyClass : public QObject { Q_OBJECT public: explicit MyClass(QObject *parent = 0) { mStateMachine = new QStateMachine(this); QState *s1 = new QState(mStateMachine); QState

3-state phone model in Hidden Markov Model (HMM)

99封情书 提交于 2019-12-04 15:18:29
I want to ask regarding the meaning of 3-state phone model in HMM. This case is based on the theory of HMM in speech recognition system. So the example is based on the acoustic modeling of the speech sounds in HMM. I get this example picture from a journal paper: http://www.intechopen.com/source/html/41188/media/image8_w.jpg Figure 1: 3-State HMM for the sound /s/ So, my question is: what is it mean by 3 state? what actually S1, S2 & S3 mean? (I know it is state but it represent what?) How to represent the /s/ sound in this HMM state? Why is it 3? what happen if we have 4, 5 or more state? If

How to define a variant<x,y,z> extracting subtypes of a template parameter

笑着哭i 提交于 2019-12-04 13:21:16
I am building a state-machine where state transitions are described as a variant, i.e.: using table = std::variant< /* state event followup-state */ transition<start, success<sock>, connecting>, transition<start, exception, failed>, transition<connecting, success<>, connected>, transition<connecting, exception, failed>, transition<connected, exception, failed> >; and transition being a simple type: template <typename ENTRY_STATE, typename EVENT, typename NEXT_STATE> struct transition { using entry_state = ENTRY_STATE; using event = EVENT; using next_state = NEXT_STATE; }; The state classes are

How to design a state machine in face of non-blocking I/O?

别等时光非礼了梦想. 提交于 2019-12-04 13:16:27
I'm using Qt framework which has by default non-blocking I/O to develop an application navigating through several web pages (online stores) and carrying out different actions on these pages. I'm "mapping" specific web page to a state machine which I use to navigate through this page. This state machine has these transitions; Connect, LogIn, Query, LogOut, Disconnect and these states; Start, Connecting, Connected, LoggingIn, LoggedIn, Querying, QueryDone, LoggingOut, LoggedOut, Disconnecting, Disconnected Transitions from *ing to *ed states ( Connecting->Connected ), are due to LoadFinished

How to define a state_machine in a Concern?

老子叫甜甜 提交于 2019-12-04 10:40:08
I am trying to factor out some duplicated logic into a concern . Part of the duplicated logic is a state_machine . Simplified, the Database , Site , SftpUser and more contain, amongst others, this: class Database < ActiveRecord::Base # ... state_machine :deploy_state, initial: :halted do state :pending end end I'm attempting to refactor this into a concern: module Deployable extend ActiveSupport::Concern included do state_machine :deploy_state, initial: :halted do state :pending end end end # Tested with: class DeployableDouble < ActiveRecord::Base extend Deployable end describe

Best Practice for Transitioning From Nested State to Nested State (see diagram)

别等时光非礼了梦想. 提交于 2019-12-04 08:01:05
问题 I am trying to wrap my mind around the best way to implement nested state transitions in a single threaded programming language (Actionscript). Say I have a structure like this behavior tree: Now imagine that each leaf node is a destination point on a website, like an image in a gallery, or a comment nested in a post view nested in a page view... And the goal is to be able to run animated transitions from leaf node to leaf node, by animating out the previous tree (from bottom to top), and