[Tinyos-contrib-commits] CVS: tinyos-1.x/contrib/wustl/apps/AgillaAgents/GroupComm/chat Leader.ma, NONE, 1.1 Member.ma, NONE, 1.1 README.txt, NONE, 1.1

Chien-Liang Fok chien-liang at users.sourceforge.net
Wed Sep 20 01:00:42 PDT 2006


Update of /cvsroot/tinyos/tinyos-1.x/contrib/wustl/apps/AgillaAgents/GroupComm/chat
In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv26294

Added Files:
	Leader.ma Member.ma README.txt 
Log Message:
initial commit

--- 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
		pushn jng
		pushc 2
		pushc RXN_GROUP_JOIN
		regrxn
	
// register a reaction sensitive to member broadcast messages		
		pusht string
		pusht string
		pushn mbm
		pushc 3			// template = <"mbm", string, string>
		pushc RXN_GROUP_SEND
		regrxn			// register a reaction for member broadcast messages
		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
		esetvar 19		// heap[19] = name
		esetvar 18		// heap[18] = message
		pushc 0
RGS_LOOP	inc
		copy
		getvar 0
		cgt			// check whether the counter is > number of members
		rjumpc DONE
		copy
		getvars			// get the neighbor's address
		egetvar 18		
		swap
		egetvar 19
		swap
		pushn lbm
		swap
		pushc 3
		swap			// tuple = <"lbm", name, message>
		rout
		pushc RGS_LOOP
		jumps			// go back to STG_LOOP		
DONE		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]++
		setvars			// save the location of the member on the heap
		endrxn
		
--- NEW FILE: Member.ma ---
// set the leader location to be (1,1)
		pushloc 1 1
		setvar 0	// heap[0] = leader location
		
// register with the leader
		loc
		pushn jng
		pushc 2
		getvar 0
		rout

// register reaction for leader broadcast messages
		pusht string
		pusht string
		pushn lbm
		pushc 3
		pushc RXN_FIRED
		regrxn

// register reaction for messages to send		
		pusht string
		pusht string
		pushn snd
		pushc 3
		pushc SND_MSG
		regrxn
		wait

RXN_FIRED	remove			// remove the tuple
		pushc uart_x uart_y
		rout			// send tuple to base station
		endrxn

SND_MSG		remove
		pop
		pop
		pushn mbm
		pushc 3			// <"mbm", String:name, String:msg>
		getvar 0
		rout			// send to leader
		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>





More information about the Tinyos-contrib-commits mailing list