Real-time controller executing logical sequences and interlocks for electrical and mechanical systems