[Tinyos-contrib-commits]
CVS: tinyos-1.x/contrib/wustl/apps/AgillaAgents/GroupComm/mobile-chat
AutoMember.ma, NONE, 1.1 Leader.ma, NONE, 1.1 Member.ma, NONE,
1.1 Proxy.ma, NONE, 1.1 README.txt, NONE,
1.1 simple_sleep_test.ma, NONE, 1.1 test_sleep.ma, NONE,
1.1 test_sleep_fire.ma, NONE, 1.1
Chien-Liang Fok
chien-liang at users.sourceforge.net
Tue Nov 14 17:11:35 PST 2006
Update of /cvsroot/tinyos/tinyos-1.x/contrib/wustl/apps/AgillaAgents/GroupComm/mobile-chat
In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv13819
Added Files:
AutoMember.ma Leader.ma Member.ma Proxy.ma README.txt
simple_sleep_test.ma test_sleep.ma test_sleep_fire.ma
Log Message:
Initial Commit
--- NEW FILE: AutoMember.ma ---
// get use rname from cmd line
// store user name in heap[0]
// pushn fei
// setvar 0
// Send a string to the base station to create GUI
// 'msc', agentID, screen name
getvar 0
aid
pushn msc
pushc 3
pushloc force_uart_x force_uart_y
rout
pushc 8
sleep
// discover the leader location
loc
pushn abc // group name = "abc"
pushn req
pushc 3
pushloc uart_x uart_y
rout // send request message: <"req", "abc", loc>
pushc 8 // sleep for 1 second to allow BS to generate reponse
sleep
pusht location
pushn grl
pushc 2
in // wait for response
pop
pop
setvar 1 // heap[1] = leader location
// register with the leader
loc
aid
pushn jng
pushc 3
getvar 1
rout
// register reaction for leader broadcast messages
pusht string
pusht string
aid
pushn lbm
pushc 4
pushcl RXN_FIRED
regrxn
// register reaction for messages to send
pusht string
getvar 0
aid
pushn snd
pushc 4
pushcl SND_MSG
regrxn
// register reaction to move to a different node
//pushn mov
//pushc 1
//pushcl MOVE
//regrxn
WAIT pushc 48
sleep
aid
pushn msc
pushc 2
pushloc force_uart_x force_uart_y
rout // tell current base station to kill GUI
pushloc 2 1
aid
pushn upd
pushc 3
getvar 1
rout // send update location message to leader
pushloc 2 1
smove // strong move to (2,1)
getvar 0
aid
pushn msc
pushc 3
pushloc force_uart_x force_uart_y
rout // send message to base station to create GUI
wait
RXN_FIRED remove // remove the tuple
pushloc force_uart_x force_uart_y
rout // send tuple to base station
endrxn
SND_MSG remove
pop
pop
pushn mbm
pushc 4 // <"mbm", AgentID, String:name, String:msg>
getvar 1
rout // send to leader
pushc 26
putled // toggle green when message is sent to leader
//clear
//pushcl WAIT
endrxn
--- NEW FILE: Leader.ma ---
//-------------------------------------------------------------------------------------------------
// Group Communication Leader
//
// Heap Structure:
// [0] = number of members
// [1..n] = member locations
//
// Number of reactions: 2
// (1) Distributes a group message.
// Tuple format: <"mbm", value>
// (2) Adds a member to the group.
// Tuple format: <"jng", location>
//-------------------------------------------------------------------------------------------------
pushc 0 // store the group member information on the heap
setvar 0 // heap[0] = initial number of members (0)
// register a reaction sensitive to join messages
pusht location
pusht agentid
pushn jng
pushc 3
pushcl RXN_GROUP_JOIN
regrxn
// register a reaction sensitive to member broadcast messages
pusht string
pusht string
pusht agentid
pushn mbm
pushc 4 // template = <"mbm", agentID, string, string>
pushc RXN_GROUP_SEND
regrxn // register a reaction for member broadcast messages
// register a reaction sensitive to member update messages
pusht location
pusht agentid
pushn upd
pushc 3
pushcl RXN_UPDATE_LOC
regrxn
WAIT wait
// The group send reaction sensitive to <"mbm", string, string>
// Assumes heap[0] = number of agents and heap[1...n] are the agent's addresses
RXN_GROUP_SEND remove
pop
pop
pop
esetvar 19 // heap[19] = name
esetvar 18 // heap[18] = message
pushc 28
putled // toggle yellow
pushc 0
esetvar 17
RGS_LOOP egetvar 17
inc
copy // Stack: cntr, cntr
esetvar 17 // heap[17] = cntr
getvar 0 // Stack: # of members, cntr
cgt // check whether the counter is > number of members
pushcl DONE
jumpc
egetvar 18 // message
egetvar 19 // member's name
egetvar 17
pushc 2
mul
dec // 2*idx - 1
getvars // each member's agent ID
//copy
//pushn rcv
//pushc 2
//pushloc uart_x uart_y
//rout
pushn lbm
pushc 4 // tuple = <"lbm", member ID, name, message>
egetvar 17
pushc 2
mul // 2*idx
getvars // get the member's address
//pushloc uart_x uart_y
//copy
//pushn rcv
//pushc 2
//pushloc uart_x uart_y
//rout
rout
pushc RGS_LOOP
jumps // go back to STG_LOOP
DONE pushc 25
putled // toggle red
//pop // pop the counter
endrxn // end the reaction
// The group join reaction sensitive to <"jng", location>
// Assumes heap[0] = number of agents and heap[1...n] are the agent's addresses
RXN_GROUP_JOIN remove
pop // pop number of fields
pop // pop the string "jng"
getvar 0
inc
copy
setvar 0 // heap[0]++
pushc 2
mul
dec
setvars // heap[index*2-1] = agent id
getvar 0
pushc 2
mul
setvars // heap[index*2] = location
pushc 28
putled // toggle yellow when member joins group
//getvar 0
//pushc 2
//mul
//getvars
//pushn mem // tell BS that a member has joined
//pushc 2
//pushloc uart_x uart_y
//rout
endrxn
RXN_UPDATE_LOC remove
pushc 25
putled // toggle red LED when member moves
pop // pop number of fields
pop // pop the string "upd"
findMatch // find the index of the agent id on the heap
inc // the location is in the next index position
setvars // save the new location
endrxn
--- NEW FILE: Member.ma ---
// get use rname from cmd line
// store user name in heap[0]
// pushn fei
// setvar 0
// Send a string to the base station to create GUI
// 'msc', agentID, screen name
getvar 0
aid
pushn msc
pushc 3
pushloc force_uart_x force_uart_y
rout
pushc 8
sleep
// discover the leader location
loc
pushn abc // group name = "abc"
pushn req
pushc 3
pushloc uart_x uart_y
rout // send request message: <"req", "abc", loc>
pushc 8 // sleep for 1 second to allow BS to generate reponse
sleep
pusht location
pushn grl
pushc 2
in // wait for response
pop
pop
setvar 1 // heap[1] = leader location
// register with the leader
loc
aid
pushn jng
pushc 3
getvar 1
rout
// register reaction for leader broadcast messages
pusht string
pusht string
aid
pushn lbm
pushc 4
pushcl RXN_FIRED
regrxn
// register reaction for messages to send
pusht string
getvar 0 // name of agent
aid
pushn snd
pushc 4
pushcl SND_MSG
regrxn
// register reaction to move to a different node
pusht location
aid
pushn abc
pushc 3
pushcl MOVE
regrxn
WAIT wait
RXN_FIRED remove // remove the tuple
pushloc force_uart_x force_uart_y
rout // send tuple to base station
endrxn
SND_MSG remove
pop
pop
pushn mbm
pushc 4 // <"mbm", AgentID, String:name, String:msg>
getvar 1
rout // send to leader
pushc 26
putled // toggle green when message is sent to leader
endrxn
MOVE pushc 28
putled
remove // remove the tuple
pop // pop off number of fields
pop // pop off "mov"
pop // pop off agent id
aid
pushn msc
pushc 2
pushloc force_uart_x force_uart_y
rout // tell current base station to kill GUI
pushloc 2 1 // copy destination location
aid
pushn upd
pushc 3 // tuple: <"upd", AgentID, new location>
getvar 1
rout // send update location message to leader
smove // strong move to destination
getvar 0
aid
pushn msc
pushc 3
pushloc force_uart_x force_uart_y
rout // send message to base station to create GUI
endrxn
--- NEW FILE: Proxy.ma ---
// heap[0] = reserved location
// heap[1] = current member agent location
// heap[2] = previous member agent location
pushc 8
sleep
// register reaction: Receive message from PDA, send message to member agent
// <'typ', chat msg> (typ - type)
pusht string
pushn typ
pushc 2
pushcl SND_MSG
regrxn
// register reaction: Receive message from member agent, send message to PDA
// <"dsp", chat msg> (dsp - display)
pusht string
pushn dsp
pushc 2
pushcl RCV_MSG
regrxn
// register reaction to move to a different node
// <"pmv", new location> (pmv - PDA move)
pusht location
pushn pmv
pushc 2
pushcl MOVE
regrxn
WAIT wait
RCV_MSG remove
pushloc force_uart_x force_uart_y
rout // send tuple to base station
endrxn
// reaction fired: Receive message from PDA, send message to member agent
// From PDA: <'typ', chat msg>
// To Member: <'ocm', chat msg> (ocm - out chat msg)
// # Future Optimization: <'ocm', member agentID, chat msg> for multiple member agents on the same node
SND_MSG remove
pop
pop // Stack: chat msg
pushn ocm
pushc 2 // <"ocm", chat msg>
randnbr // get the member agent's addr
// if success, forward msg to member agent
rjumpc FND_MEM
getvar 1 // heap[1] = curr member
rout // send to current member
pushc 26
putled // toggle green when message is sent to leader
endrxn
MOVE pushc 28
putled
remove // remove the tuple
pop // pop off number of fields
pop // pop off "mov"
pop // pop off agent id
aid
pushn msc
pushc 2
pushloc force_uart_x force_uart_y
rout // tell current base station to kill GUI
pushloc 2 1 // copy destination location
aid
pushn upd
pushc 3 // tuple: <"upd", AgentID, new location>
getvar 1
rout // send update location message to leader
smove // strong move to destination
getvar 0
aid
pushn msc
pushc 3
pushloc force_uart_x force_uart_y
rout // send message to base station to create GUI
endrxn
--- NEW FILE: README.txt ---
Inject leader onto Mote 0 (1,1).
Members are on other motes that are base stations.
-------------------------------------------------------------------------------
Join group:
<"jng", location>
Send IM:
<"mbm", String:Name, String:msg>
Message from base station to its member agent:
<"snd", String:Name, String:msg>
--- NEW FILE: simple_sleep_test.ma ---
BEGIN pushc 24
sleep
pushc 26
putled
halt
--- NEW FILE: test_sleep.ma ---
BEGIN pusht STRING
pushc 1
pushc RXN
regrxn
pushcl 480
sleep
pushc 26
putled
halt
RXN remove
pushc 25
putled
endrxn
--- NEW FILE: test_sleep_fire.ma ---
BEGIN pushc 26
putled
pushn fei
pushc 1
out
halt
More information about the Tinyos-contrib-commits
mailing list