Task-oriented Communication Design in Cyber-Physical Systems: A Survey on Theory and Applications