Control of both inflow and outflow of tank