c# - Using the StateMachineCompiler(SMC) in own code -


hello want use state machine compiler (smc) c# http://smc.sourceforge.net/

i have created sm-file describe state machine , generated c# code it.

then created own class myclass,add generated class generated smc , implement methods.

my problem how can run statemachine? while-loop, async call or task library ? elegant way?

the statemachine behaivior sending data throught serialport. user can call myclass.send(data) , statemachine should work behind curtains.

can give me example how use statemachine in own code?

regards rubiktubik

i've used smc in many application , satisfied it. hit same problem you. smc generates code c# synchronous , linear. means if issue transaction calling fsm.yourtransaction() , chance somewhere in middle of transaction issue transaction, directly called. dangerous, because breaks base principle of state machine - transactions atomic , system guaranteed in single state, or single transition time.
when realized hidden problem implemented asynchronous layer above state machine code generated smc. unfortunately cannot provide code, because licensed, can describe principle here.
replaced direct method calls asynchronous event processing: there queue awaiting transactions. transactions represented strings, must same transaction methods in fsm. removed queue 1 one in independent thread. transaction string transformed fsm method call. concept proved work in many critical applications. rather simple implement , easy extend new features. final form of asynchronous layer had these additional features:

  1. perfect logging: transactions , arguments, time of arrival, time of processing ...etc.
  2. possibility replace independent thread external thread - better process things in thread provided outside (windows gui sensitive external thread calls...)
  3. preprocessing of transactions - system expected change state if sequence of transaction occured. rather clumsy achieve directly smc. implemented called "transaction transformations" - possible declare how set of transactions transformed single transaction.

Comments

Popular posts from this blog

ios - UICollectionView Self Sizing Cells with Auto Layout -

node.js - ldapjs - write after end error -

DOM Manipulation in Wordpress (and elsewhere) using php -