What is the primary function of a Programmable Logic Controller (PLC) in an industrial automation system?