Resilient and safe control of cyber-physical systems under uncertainties and adversaries