## 1 Introduction
In [16], the authors present a battery energy management system for a microgrid, in which PVs and diesel generators (DG) are the primary sources of electricity; the novelty of the proposed battery energy management system lies within the energy management of multiple types of batteries' characteristics and the reduction of the DGs' operating hours simultaneously. However, demand-side management does not consider the characteristics of every load demand and the available power, so it cannot give a good power service for users. Paper [17] presents a mathematical model of smart loads in demand-response schemes that is integrated into centralized unit commitment. The goal is to obtain an optimal power flow coupled with an energy management system for isolated microgrids for optimal generation and peak load dispatch. The smart loads are modeled with a neural network load estimator as a function of the ambient temperature, time of day, time of use price, and the peak demand imposed by the microgrid operator. However, the power management above only considers part of the sources, storage, and load management. Thus, it is imperative to propose a complete power microgrid management system considering the constraints of all the physical components to achieve safe and long-life equipment. The contributions of this paper mainly involve three points: this paper proposes an algorithm for both power control and power management of a full DC microgrid; the constraints of all physical components are considered in the full microgrid; a real-time load shedding optimization method is applied. The three points are described in detail below:  
* This paper proposes an algorithm for both the power control and power management of a full DC microgrid building, integrated under the ruled based decision according to non-linear system modeling. The produced energy is dedicated to the self-consumption of the building's electrical appliances, aiming to reach the maximal usage rate of renewable energy and to reduce the usage of the public grid. A battery storage (BS) system, a single phrase public grid connection, a group of PV panels, a DG-like backup source, an SC, and a load seen like a group of pre-defined controllable appliances are integrated into the full DC microgrid. The BS and the public grid can be the controllable sources to supply power deficiency and to absorb the excess power during the on-grid operation of the full DC microgrid. Furthermore, the BS has a higher priority than the public grid to supply the full DC microgrid, which can reduce the stress on the public grid by making full use of the local BS. The DG can make the microgrid more reliable in cases of a high load demand, insufficient PV power generation, exhausted BS power, and low power limitation or failure of the public grid. * The constraints of PV sources, public grid, BS, DG, and SC are considered and defined according to the mathematical modeling of each component. The PV production capacity is considered according to the maximal load demand, and the PV power constraints can make it work at two operation modes: PV maximum power point tracking (MPPT) mode and the PV power shedding mode. The BS is constrained by its power limitation and state of charge to keep it working normally and safely for a long lifetime. The public grid is constrained by the power limitation received from the public grid distribution system operator to increase the stability and thus to reduce the cost. The DG can be turned on and turned off, respecting the constraints of its rated power and a duty time cycle, aiming to protect its lifetime and to reduce the usage and energy cost. The low dynamic power during the DG start-up can lead to power deficiency in the microgrid and this power is compensated for by the SC. The SC is limited by its state of charge and power to keep its lowest power to compensate for the DG. The SC can operate at power charging mode, power discharging mode, or self-discharging mode. * A real-time load optimization method is applied in this paper.