statemachine

State machines in C

What is the best way to write a state machine in C? I usually write a big switch-case statement in a for(;;), with callbacks to re-enter the state machine when an external operation is finished. Do you know a more efficient way? ...

before_filter not working in state_machine :(

Hi all, I have a model that relies on state_machine to manage its different states. One particular event requires a before_transition as it needs to build a join table fore doing the transition. Unfortunately it doesn't work. class DocumentSet < ActiveRecord::Base state_machine :state, :initial => :draft do # Callbacks befor...

Is there a Java equivalent to libevent?

I've written a high-throughput server that handles each request in its own thread. For requests coming in it is occasionally necessary to do RPCs to one or more back-ends. These back-end RPCs are handled by a separate queue and thread-pool, which provides some bounding on the number of threads created and the maximum number of connection...

Why is this an invalid Turing machine?

Whilst doing exam revision I am having trouble answering the following question from the book, "An Introduction to the Theory of Computation" by Sipser. Unfortunately there's no solution to this question in the book. Explain why the following is not a legitimate Turing machine. M = { The input is a polynomial p over variables x1, ...,...

WCF Callback Faulted - what happens to the session?

Just trying to get my head around what can happen when things go wrong with WCF. I have an implementation of my service contract declared with an InstanceContextMode of PerSession... [ServiceBehavior(InstanceContextMode = InstanceContextMode.PerSession, ConcurrencyMode = ConcurrencyMode.Multiple)] The calls happen as follows: My cli...

Dynamic State Machine in Ruby? Do State Machines Have to be Classes?

Question is, are state machines always defined statically (on classes)? Or is there a way for me to have it so each instance of the class with has it's own set of states? I'm checking out Stonepath for implementing a Task Engine. I don't really see the distinction between "states" and "tasks" in there, so I'm thinking I could just map...

Can LINQ expression classes implement the observer pattern instead of deferred execution?

Hi. We have issues within an application using a state machine. The application is implemented as a windows service and is iteration based (it "foreaches" itself through everything) and there are myriads of instances being processed by the state machine. As I'm reading the MEAP version of Jon Skeets book "C# in Depth, 2nd ed", I'm won...

QT EventTransition implementation

I am trying to build an QT State Maschine. I have some States, and for those States i need Transition that alter the Graphics on my gui. The Problem i having and the only reason i am asking, i am Stuck and Point 1. The compiler cant identifie the QTEventTransition. I have QT 4.6 wroking with QT Creator on Windows. The compiler does n...

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 as Error Occured. All I want to do here is create multiple tasks (no of tasks depends on ...

statemachine, conditional transitions

I'm currently using Workflow. class Link < ActiveRecord::Base include Workflow workflow do state :new do event :process, :transitions_to => :checking #checking http_response_code & content_type end state :checking do event :process, :transitions_to => :fetching_links # fetching all links end state :f...

IVR-style dialog system / workflow / menu

I need to build a dialog system similar to IVR used in call centers. My system is not phone-based, but the dialog is similar. Something like System: "Main menu: Enter [1] for menu1, [2] for menu2" User: [1] System: "menu1: enter [1] for apples, [2] for oranges, [3] for main menu" User: [7] System: "What??" System: "menu1: enter [1] for ...

Rails: How to test state_machine?

Please, help me. I'm confused. I know how to write state-driven behavior of model, but I don't know what should I write in specs... My model.rb file look class Ratification < ActiveRecord::Base belongs_to :user attr_protected :status_events state_machine :status, :initial => :boss do state :boss state :owner state ...

How would you code a washing machine?

Imagine I have a class that represents a simple washing machine. It can perform following operations in the following order: turn on -> wash -> centrifuge -> turn off. I see two basic alternatives: A) I can have a class WashingMachine with methods turnOn(), wash(int minutes), centrifuge(int revs), turnOff(). The problem with this is th...

QT : Using State Machine for UI interactions ?

Greetings, We are developing a scientific QT Application which detect the border of a cell.Please refer to following prototype snapshots. http://i27.tinypic.com/25tub9v.png http://i26.tinypic.com/9l8kcj.jpg Now ,we are going to develop this as a opensource product with a good design and architecture.We reconed that it has many comple...

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 = web.Lists["NewHireFormsLibrary"].Items[workflowProperties.ItemId - 1]; item["Fi...

Passing variables to Rails StateMachine gem transitions

Is it possible to send variables in the the transition? i.e. @car.crash!(:crashed_by => current_user) I have callbacks in my model but I need to send them the user who instigated the transition after_crash do |car, transition| # Log the car crashers name end I can't access current_user because I'm in the Model and not the Control...

QStatemachine and parallel states

Dear All, I'm going crazy with QStateMachine wth ParallelState. I've a main state (sequential) which contain a first state, a second state which contains a group of parallel states, and another state that is again sequential. The first state represent a process which create N input files, the second represents N threads which works over ...

Which State Machine execution frameworks for C++ implement UML semantics?

I'm looking for a framework that provides execution of hierarchical state machines (HSMs). These are the requirements for the framework: Conforms to UML state machine semantics (as much as possible) Supports at least run-to-completion semantics hierarchical states entry and exit actions transition actions guards events with custom pa...

What is the difference between SCXML statecharts and UML statecharts?

I know that the user defines them in different ways (XML compared to UML Tool), but what is the difference in semantics between the two? Or does a statechart in SCXML mean the same thing as a comparable statechart in UML? ...

Solid resources for an amateur to learn about writing parsing and state machines?

Books, articles, anything. The language doesn't matter too much as I can probably figure it out. I just want something that is fairly deep, very practical and, most importantly, easy to understand. Thanks guys :) ...