Hello,
while implementing with DSM (which is fun), I saw myself often doing
this type of construct:
transition "play that weird mesage" somestate - keyPress(1) / {
playFile(this_message_e_g_from_db.wav);
repost();
} -> PLAY_SOMETHING_PREPARE;
state PLAY_SOMETHING_PREPARE:
transition "error occured" PLAY_SOMETHING_PREPARE - test(errno!="") /
play(sorry.wav); -> some_further_state;
transition "ok, playing" PLAY_SOMETHING_PREPARE --> PLAY_SOMETHING;
state PLAY_SOMETHING;
transition "played that one" PLAY_SOMETHING - noAudioTest -> andsoon;
This is ugly, but error checking is indispensable, especially if one
depends on the event that is fired when that particular message ends for
continuation of the flow, or some event that finally results from the
failed action. And playing file of course most of the time works, but
for some external component there may be multiple failure reasons. So I
was wondering whether it makes sense to introduce exceptions, that would
break out of the current actions block, and fire an 'exception' event.
then this would make it much simpler:
state PLAY_SOMETHING
enter {
playFile(file1.wav);
playFile($file2);
mysql.execute(insert into xyz values ("playing stuf");
someOtherAction();
};
transition "error playing file1" PLAY_SOMETHING - exception(#type=file);
exception(#name=file1) -> HANDLE_FILE1_ERR;
transition "error playing file1" PLAY_SOMETHING - exception(#type=file);
exception(#name=file2) -> HANDLE_FILE2_ERR;
transition "error on db" PLAY_SOMETHING - exception(#type=db) ->
HANDLE_DB_ERR;
and so on. One question with this is what parameters the exception
should contain - e.g. the index of the action? name/type of the action?
action parameter?
Thinking about it a little further, I was wondering about repost(). DSM
is a state machine, and the 'clock' is the events that come in - what
repost does is actually to double the clock for the current event. From
a systematical perspective, this is probably nonsense, just that it is
really useful. At the beginning, the plan was that everything which
would require an 'if' or a 'while' should be implemented as (atomic)
action in c++, also for the reason that the whole application state
would be defined by state+vars (and so is possible to replicate for
failover). But now I realize that DSM language itself can actually be
useful to also implement a whole lot of real app logic. So, would it
make sense to add "if" in action blocks? or is that now really overdoing
it? would it make much more sense to use a readily available language
like lua or python?
Curious for your comments
Stefan
--
Stefan Sayer
VoIP Services
[email protected]
www.iptego.com
IPTEGO GmbH
Wittenbergplatz 1
10789 Berlin
Germany
Amtsgericht Charlottenburg, HRB 101010
Geschaeftsfuehrer: Alexander Hoffmann
_______________________________________________
Semsdev mailing list
[email protected]
http://lists.iptel.org/mailman/listinfo/semsdev