Cyber–physical energy system toward safety in smart grids