Real-Time Control of Power Exchange at Primary Substations: An OPF-Based Solution