https://openstack.pythonprogramminghelp.com/how-to-build-bang-bang-control-and-switching-functions/