Real-time fault diagnosis and fault-tolerant control