A closed loop stability condition of switched systems applied to NCSs with packet loss