1. A method for generating code for a closed-loop controller, comprising: receiving input for a simulation model in a data processing system, the simulation model including a sensor; concurrently executing the simulation model and control code for a simulated physical controller in the data processing system, the control code interacting with the simulation model according to a state of the sensor, the control code including instructions automatically generated by the data processing system at least partially in response to the data processing system receiving a user input of a sensor object being dragged into the control code; generating revised control code, by the data processing system, based on the executed simulation model and control code; generating controller-specific control code based on the revised control code by the data processing system; and executing the simulation model and the controller-specific control code, the controller-specific control code interacting with the simulation model.