|
|
| Author |
Message |
< Erlang ~ [still newbie] FSM, timeouts and ignoring events |
| sv75 |
Posted: Mon Oct 22, 2007 3:06 pm |
|
|
|
User
Joined: 19 Oct 2007
Posts: 10
|
I'm studying FSM sample from http://www.erlang.org/doc/design_principles/fsm.html
I wonder how to ignore any buttons pressed when door is open without using additional timers. Sample above just terminates its execution in this case because there is no open({button, Digit}, State) function. I can add
Code: open({button, Digit}, State) ->
io:format("button ignored~n", []),
{next_state, open, State};
but it breaks timeout that was set before. And I cannot get remaining time to set it again.
Any advices, please? Functions start_timer/cancel_timer are marked as internal. Should I just get over it and use timer module? |
|
|
| Back to top |
|
| francesco |
Posted: Tue Oct 23, 2007 2:15 pm |
|
|
|
User
Joined: 07 Jul 2006
Posts: 249
Location: London
|
|
| Back to top |
|
| sv75 |
Posted: Wed Oct 24, 2007 10:22 am |
|
|
|
User
Joined: 19 Oct 2007
Posts: 10
|
francesco wrote: Try
Code: open(_, State) ->
{next_state, open, State};
Timeout still never happens. Ok, I can live with timer:apply_after... |
|
|
| Back to top |
|
| francesco |
Posted: Wed Oct 24, 2007 1:09 pm |
|
|
|
User
Joined: 07 Jul 2006
Posts: 249
Location: London
|
When you receive a message, you reset the timeout. The only way to avoid it is to use, as you suggest, the timer module.
Francesco
--
http://www.erlang-consulting.com |
|
|
| Back to top |
|
|
|
All times are GMT
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You cannot download files in this forum
|
|
|