[Tinyos-contrib-commits] CVS: tinyos-1.x/contrib/wustl/apps/AgillaAgents/GroupComm/3-join-group-msg Leader.ma, NONE, 1.1 Member.ma, NONE, 1.1 MemberSend.ma, NONE, 1.1 README, NONE, 1.1

Chien-Liang Fok chien-liang at users.sourceforge.net
Wed May 24 19:37:59 PDT 2006


Update of /cvsroot/tinyos/tinyos-1.x/contrib/wustl/apps/AgillaAgents/GroupComm/3-join-group-msg
In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv14752/contrib/wustl/apps/AgillaAgents/GroupComm/3-join-group-msg

Added Files:
	Leader.ma Member.ma MemberSend.ma README 
Log Message:
Added group communication agents.

--- NEW FILE: Leader.ma ---
		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 value
		pushn mbm
		pushc 2			// template = <"mbm", value>
		pushc RXN_GROUP_SEND
		regrxn			// register a reaction for member broadcast messages
		wait

// The group send reaction
// Assumes heap[0] = number of agents and heap[1...n] are the agent's addresses
RXN_GROUP_SEND	remove
		pop
		pop
		esetvar 19
		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 19		
		swap
		pushn lbm
		swap
		pushc 2
		swap			// tuple = <"lbm", 31>
		rout
		pushc RGS_LOOP
		jumps			// go back to STG_LOOP		
DONE		pop			// pop the counter
		endrxn			// end the reaction

// The group join reaction
// 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 ---
// register with the leader
		loc
		pushn jng
		pushc 2
		pushloc 1 1
		rout

// register reaction for leader broadcast messages
		pusht value
		pushn lbm
		pushc 2
		pushc RXN_FIRED
		regrxn
		wait

RXN_FIRED	remove			// remove the tuple
		pop			// pop field count
		pop			// pop "lbm"
		putled
		endrxn
--- NEW FILE: MemberSend.ma ---
// register with the leader
		loc
		pushn jng
		pushc 2
		pushloc 1 1
		rout

// register reaction for leader broadcast message		
		pusht value
		pushn lbm
		pushc 2
		pushc RXN_FIRED
		regrxn		

// send a member broadcast message every second
LOOP		pushc 31
		pushn mbm
		pushc 2
		pushloc 1 1
		rout			// insert tuple <"mbm", 31> on leader's mote
		pushc 8
		sleep
		rjump LOOP		

RXN_FIRED	remove			// remove the tuple
		pop			// pop field count
		pop			// pop "lbm"
		putled
		endrxn
--- NEW FILE: README ---
AGENT GROUP COMMUNICATION
-------------------------------------------------------------------------------
The group is *not* hard coded in the leader.  Members send a "join" message to 
the leader, who is assumed to be at (1,1).  The leader has a reaction 
sensitive to member broadcast messages.  When this reaction fires, the leader 
sends the value stored within the message to each member.

The members react to the group broadcast message, extract the value and display 
it on the LEDs.

The MemberSend periodically sends the leader a member broadcast message that 
triggers the sending of the group message.

The leader must be at (1,1).
Members must be at (1,1), (2,1), (3,1) and (4,1).
One of the members must be MemberSend.ma.
Inject the leader first to ensure successful join operation.

MESSAGE FORMATS
-------------------------------------------------------------------------------
Member Broadcast Message:
 
 <"mbm", value>
 
 This message is sent from the member to the leader for broadcasting to the 
 group.

Leader Broadcast Message:
  <"lbm", value>
 
  This message is sent from the group leader to each member in the group.
  


More information about the Tinyos-contrib-commits mailing list