This paper deals with the energy management of a photovoltaic based power station. This power station includes storage units with batteries for long-term energy supply and ultracapacitors for fast dynamic power regulation. According to the availability of the primary source, the level of the stored energy and the request from the grid operator, we have defined and detailed three main operating modes for this system with a particular modeling tool: Petri nets. For each operating mode, we have designed an energy management algorithm in order to calculate the energy dispatching of an adjustable power margin for the storage units.