Reducing the energy consumption is a major concern in industrial production systems. One approach is recuperating the braking energy of robot axes. Ideally, their acceleration and deceleration phases should be synchronized so that the braking energy of one axis can be reused directly to accelerate another. This requires a detailed alignment of the axes' trajectories, but also a careful design of the overall discrete control. Finding an optimal control strategy manually, however, is difficult, as also many functional and safety requirements must be considered. We therefore propose an automated methodology that consists of three parts: (1) A scenario-based language to flexibly specify the discrete production system behavior, (2) an automated procedure to synthesize optimal control strategies from such specifications, including PLC code generation, and (3) a procedure for the detailed trajectory optimization. We describe the methodology, focusing on parts (1) and (2) in this paper, and present tool support and evaluation results.