Active Detection for Resilient Cyber-Physical Systems