Real-Time Control of Water Quality and Quantity