An energy router for structural monitoring of framed buildings and real-time shutdown of power and gas supply during earthquakes