How would you implement a state machine for an automated process with multiple operating modes and recovery states?