A Framework for Modeling, Simulation and Automatic Code Generation of Sensor Network Application