A new timetable must be calculated in real-time when train operations are perturbed. Although energy consumption is becoming a central issue both from the environmental and economic perspective, it is usually neglected in the timetable recalculation. In this paper, we formalize the real-time Energy Consumption Minimization Problem (rtECMP). It finds in real-time the driving regime combination for each train that minimizes energy consumption, respecting given routing and precedences between trains. In the possible driving regime combinations, train routes are split in subsections for which one of the regimes resulting from the Pontryagin's Maximum Principle is to be chosen. We model the trade-off between minimizing energy consumption and total delay by considering as objective function their weighted sum. We propose an algorithm to solve the rtECMP, based on the solution of a mixed-integer linear programming model. We test this algorithm on the Pierrefitte-Gonesse control area, which is a critical area in France with dense mixed traffic. The results show that the problem is tractable and an optimal solution of the model tackled can often be found in real-time for most instances.