Automatic chemical dosing system