A Compilation Framework for Macroprogramming Networked Sensors