Optimal Control Methods for On-Off Sampling Systems