| Author |
Message |
|
| dmitry.volosnykh |
Posted: Wed Jan 06, 2010 7:55 pm |
|
|
|
Joined: 06 Jan 2010
Posts: 4
Location: RUSSIA
|
(see subject) instead of default in-state-on-event actions?
As far as I understand, gen_fsm, beeing in some state, is just waiting for the next event. I would like to make it do some actions first before entering receive statement.
Thanks in advance. |
|
|
| Back to top |
|
| hao |
Posted: Fri Jan 08, 2010 3:59 pm |
|
|
|
User
Joined: 20 Aug 2007
Posts: 18
Location: Uppsala, Sweden
|
As far as I know, you can do some actions in init/1 function. It is called whenever a gen_fsm is started and before it enters initial/first state.
http://www.erlang.org/doc/man/gen_fsm.html#Module:init-1
After init/1 function is called, you can do actions in one state and enter next state which is supposed to receive specific event. |
|
|
| Back to top |
|
| dmitry.volosnykh |
Posted: Sat Jan 09, 2010 3:27 am |
|
|
|
Joined: 06 Jan 2010
Posts: 4
Location: RUSSIA
|
hao wrote: As far as I know, you can do some actions in init/1 function. It is called whenever a gen_fsm is started and before it enters initial/first state.
http://www.erlang.org/doc/man/gen_fsm.html#Module:init-1
After init/1 function is called, you can do actions in one state and enter next state which is supposed to receive specific event.
I want to associate some actions with each state of FSM. Every time FSM enters specific state, it should perform associated actions. |
|
|
| Back to top |
|
| rvirding |
Posted: Sun Jan 10, 2010 12:19 am |
|
|
|
User
Joined: 30 Aug 2006
Posts: 452
Location: Stockholm, Sweden
|
For each state in your FSM you define a function which has the same name as the state. You tell the gen_fsm server which state you are in or to change to the return values of your state functions. When an event occurs (i.e. an event message is received) your state function for that state will be called. It in in your state functions where you do actions depending on the event and state. It is also in these state functions where you determine if there is to be a state transition or not.
This is the basics, there are more functions and alternatives available for other situations. |
|
|
| Back to top |
|
| dmitry.volosnykh |
Posted: Sun Jan 10, 2010 3:59 am |
|
|
|
Joined: 06 Jan 2010
Posts: 4
Location: RUSSIA
|
rvirding wrote: ...state functions where you do actions depending on the event and state.
I need actions not "on the event and state", but only "in state" what ever event has occured. More over, I'd like them to be triggered every time the state entered. But in standard behaviour of gen_fsm, when it enters some state, it does nothing except for waiting for the next event. And only then actions are carried out. That's not what I want. |
|
|
| Back to top |
|
| rvirding |
Posted: Mon Jan 18, 2010 12:53 am |
|
|
|
User
Joined: 30 Aug 2006
Posts: 452
Location: Stockholm, Sweden
|
dmitry.volosnykh wrote: I need actions not "on the event and state", but only "in state" what ever event has occured. More over, I'd like them to be triggered every time the state entered. But in standard behaviour of gen_fsm, when it enters some state, it does nothing except for waiting for the next event. And only then actions are carried out. That's not what I want.
This is easy.
The gen_fsm sits and waits for an event (a message) and when an event occurs the user defined state function for the state it is in is called. It is here that the FSM can decide what to do and which state it should be in. It is also here that when it changes state then any actions which must be done when leaving the old state and entering the new state can be done. |
|
|
| Back to top |
|
| dmitry.volosnykh |
Posted: Wed Jan 20, 2010 7:13 pm |
|
|
|
Joined: 06 Jan 2010
Posts: 4
Location: RUSSIA
|
rvirding wrote: This is easy.
The gen_fsm sits and waits for an event (a message) and when an event occurs the user defined state function for the state it is in is called. It is here that the FSM can decide what to do and which state it should be in. It is also here that when it changes state then any actions which must be done when leaving the old state and entering the new state can be done.
Thanks. That's really what I was searchin for. |
|
|
| Back to top |
|
| babyjing |
Posted: Thu Jan 12, 2012 2:44 am |
|
|
|
Guest
|
| Popular nfl jerseys cheap are going to be scarce over the next three months.Then they're going to be more expensive.The most popular teams will experience the worst shortages, and the James Jones Jersey are breaking all sorts of popularity records this year, from on-field performance to stock sales to merchandise sales.To lure the customer towards their service, providers are leaving no stone unturned in order to provide several plans to make Josh Sitton Jersey.Thats why your website's critics are so vital, and ofcourse why companies must be alerted at all times.With the sport's new passing-crazed style of play challenging the traditional notion that Buffalo Sabres jerseys is a fundamental ingredient for postseason success, these Nick Collins Jersey will provide an intriguing look at the way to win in the NFL when the stakes are highest. |
|
|
| Back to top |
|
| wuji |
Posted: Thu Aug 23, 2012 6:39 am |
|
|
|
User
Joined: 10 Aug 2012
Posts: 654
|
couple so she could give them the photographs, but many many replica Christian Louboutin many YouTube visitors have criticized her for invading the privacy
strangers and seeking personal gain."I'm sure they will just just cheap designer *beep* just be thrilled for your intrusion on their private moment,
of it online without their permission, and the usage of of [h3]cheap designer *beep*[/h3] of it to undoubtedly get yourself noticed," said user CaseRed0605.In
response to the critical comments, Golik wrote that she believed believed replica designer bags for sale believed she was doing the couple a service by trying
give them the photos. She would have loved to see see cheap Ralph Lauren see photos of her husband's proposal to her, she said.Before
to the Internet, she said she'd tried contacting Andrews Air Air discount designer *beep* Air Force Base to see whether the photos could be |
|
|
| Back to top |
|
|
|