Modeling, Simulation, and Automatic Code Generation Framework for Sensor Network Applications