add charge state function and demo