While significant research has been done on applying equation-oriented object languages; such as Modelica; to the simulation of complex systems; much research remains to use such languages for generating application-specific embedded code. We describe a method for using a hybrid system language (as a reference model); from which we generate reduced-order models suitable for creating embedded code for tasks such as control and diagnostics. We apply our approach to the generation of embedded diagnostics code for the operation of heating; ventilation and air-conditioning (HVAC) for complex buildings.