|
|
| Author |
Message |
|
| Dinesh Rajpoot |
Posted: Thu Oct 07, 2010 7:35 am |
|
|
|
Joined: 11 Jun 2010
Posts: 5
Location: mumbai
|
hi all,
I am using gen_fsm to create centralized autonomous parking system.The name sounds big but actually what I am doing is just parking the bots in the free slots available.
The gen_fsm has 3 states i.e. receive, find, and update.
Initial state is receive where it waits for Data sent by bot.
if Data is 'r'(parking request) then fsm should go to find state and call function find_slot or if Data is '1'(bot has parked in slot 1) then update the status of slot '1' to occupied.
Code: receive({check, Data}, State) ->
case Data of
'r' ->
{next_state, find, State}, find_slot();
%%This is wrong but I need such behaviour....
'1' ->
{next_state, update. State}, update_slot(1);
.....
find({find_slot}, State) ->
....code for finding slot...
update({update_slot, Slot}, State) ->
.....code for updating slot.....
find_slot() ->
gen_fsm:send_event(?SERVER, {find_slot}).
update_slot(Slot) ->
gen_fsm:send_event(?SERVER, {update_slot, Slot}).
Can Someone tell me how to achieve such behaviour.
"change state to next_state and call a function in next_state"
Thanks and Regards |
|
|
| Back to top |
|
| jwatte |
Posted: Sat Oct 09, 2010 4:41 am |
|
|
|
User
Joined: 10 Feb 2010
Posts: 34
|
Is this homework?
Anyway, if you want to model a FSM, then your model is wrong, or at least wrong-ish.
I suggest modeling each parking spot as a FSM that has two states (empty/taken), and each bot as a FSM that has N+1 states (in parking slot 1..N, or in the open).
An alternative is to model your FSM with (N+1)*N*(N-1) ... states, corresponding to the occupancy or not of each parking slot. (I e, slot 1 can be open, have bot 1, have bot 1, ...; slot 2 can be open or have any bot that's not in slot 1, ...) |
|
|
| Back to top |
|
| nike air max |
Posted: Thu Jan 05, 2012 1:50 am |
|
|
|
Guest
|
| ugg canada advancement movement image color contacts certainly they are a assortment that will not genuinely customize the colors from the eyes. |
|
|
| 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 can attach files in this forum You can download files in this forum
|
|
|