a more complete state machine has a number of stimuli and has transitions from any state to any other state. what you have is more of a sequencer.
a sequencer can easily be maintained with a switch statement. each state waits for some stimuli, your opto-coupler sensors, performs some action and then advances the state.
an action may also involve a delay or possibly waiting for a sensor before returning and advancing state
it's hard (for me) to tell what your code is doing because it's not obvious whether LOW/HIGH activates a relay and what exactly the relay is doing.
you don't describe what the sensors are. i also assume you need a start button (and very likely a STOP! button if not the start)
some more detail would be helpful