ROSBuzz_MISTLab/buzz_scripts/stand_by.bzz

39 lines
660 B
Plaintext
Raw Normal View History

2018-09-06 13:47:38 -03:00
include "act/states.bzz"
include "vstigenv.bzz"
updated="update_ack"
update_no=0
2018-09-06 13:47:38 -03:00
BVMSTATE = "UPDATESTANDBY"
2018-09-06 13:47:38 -03:00
# Executed once at init time.
function init(){
barrier = stigmergy.create(101)
barrier.put(id,1)
barrier_val=0
barrier.onconflict(function (k,l,r) {
if(r. data < l. data or (r. data == l. data )) return l
else return r
})
init_swarm()
# start the swarm command listener
nei_cmd_listen()
}
function stand_by(){
2018-09-06 13:47:38 -03:00
barrier.get(id)
barrier_val = barrier.size()
2018-09-06 13:47:38 -03:00
neighbors.listen(updated,
function(vid, value, rid) {
if(value==update_no) barrier.put(rid,1)
}
)
}
2018-09-06 13:47:38 -03:00
# Executed at each time step.
function step() {
2018-09-06 13:47:38 -03:00
stand_by()
}