Observer-based Anomaly Diagnosis and Mitigation for Cyber-Physical Systems