Research Article

An Efficient Renewable Energy Management and Sharing System for Sustainable Embedded Devices

Algorithm 2

Network layer energy sharing protocol.
(1) switch Event do
(2) caseTimer fired
(3)    𝑅 ( 𝑖 ) 𝜙 , 𝑆 ( 𝑖 ) 𝜙 ,  𝑗 𝑁 ( 𝑖 ) , 𝐺 𝑖 , 𝑗 0;
(4)   Measure 𝐸 𝑅 𝑖 and calculates 𝑃 𝐿 𝑖 ;
(5)   Share 𝐸 𝑅 𝑖 and 𝑃 𝐿 𝑖 information with neighbors;
(6)   for 𝑗 𝑁 ( 𝑖 ) do
(7)     Update 𝐺 𝑖 , 𝑗 via Formula 5, 6, and 7;
(8)     if 𝐺 𝑖 , 𝑗 > 0 then   𝑅 ( 𝑖 ) 𝑅 ( 𝑖 ) + { 𝑗 } ;
(9)   Call Receptor Selection method;
(10) case Receive 𝑆 𝐻 𝐴 𝑅 𝐸 _ 𝐷 𝐸 𝑁 𝑌 from node 𝑗
(11)    𝑅 ( 𝑖 ) 𝑅 ( 𝑖 ) { 𝑗 } ;
(12)   Call Receptor Selection Method;
(13) case Receive 𝑆 𝐻 𝐴 𝑅 𝐸 _ 𝐴 𝐶 𝐶 𝐸 𝑃 𝑇 from node 𝑗
(14)   Conduct energy sharing control;
(15) case Receive 𝑆 𝐻 𝐴 𝑅 𝐸 _ 𝑅 𝐸 𝑄 from node 𝑘
(16)    𝑆 ( 𝑖 ) 𝑆 ( 𝑖 ) + { 𝑘 } ;
(17)  Wait until receives all the 𝑆 𝐻 𝐴 𝑅 𝐸 _ 𝑅 𝐸 𝑄 from neighbors;
(18)  From 𝑆 ( 𝑖 ) , select 𝑘 which has the maximum 𝐺 𝑘 , 𝑖 ;
(19)  Send 𝑆 𝐻 𝐴 𝑅 𝐸 _ 𝐴 𝐶 𝐶 𝐸 𝑃 𝑇 to 𝑘 ;
(20)  Conduct energy sharing control;
(21)   𝑆 ( 𝑖 ) 𝑆 ( 𝑖 ) { 𝑘 } ;
(22)  Send 𝑆 𝐻 𝐴 𝑅 𝐸 _ 𝐷 𝐸 𝑁 𝑌 to all the nodes in 𝑆 ( 𝑖 ) ;
(23) Receptor Selection method:
(24) if 𝑅 ( 𝑖 ) 𝜙 then
( 2 5 )  From 𝑅 ( 𝑖 ) , select node 𝑗 which has the maximum 𝐺 𝑖 , 𝑗 ;
( 2 6 )  Send 𝑆 𝐻 𝐴 𝑅 𝐸 _ 𝑅 𝐸 𝑄 to 𝑗 ;