-
Notifications
You must be signed in to change notification settings - Fork 21
Theory of Operation
The core of the software is designed so that configuration and customising is done within one config file battery.cfg rather than by having multiple versions of the software.
Interfacing to different hardware is done via software drivers, currently I have written drivers for
Raspberry Pi pi.py
TI ADS1115 Analog to digital converters ads1115.py
Generic Chinese Bluetooth BMS bms.py
PIP4048 and PIP5048 Inverter/ChargeController/Charger pip.py
The software drivers are loaded when the interfaces defined in the config file are parsed when the interfaces are first initialised. Each interface has a class Rawdat associated with it. This class is instantiated as part of the initialisation process. A function getdata within this class is called each time my program gathers data from all the interfaces defined in the config file. getdata returns a dictionary containing a list of all the items this interface reports and the value of the item.
As this software monitors and can provide secondary protection to a battery and equipment that can be damaged or even worse catch fire if something goes wrong it is very important that there are multiple levels of error and exception handling.
!!!WARNING!!! although I have made every effort to make this code failsafe I do not guarantee that it is failsafe or FIT FOR A PARTICULAR PURPOSE as per the GNU General Public License. It is up to you to test that this software works in your particular application and take whatever measures are necessary to make sure that failure of or bugs in this software will not result in damage to the equipment that it monitors or controls.
If an error or exception occurs the software will log the event via the Python "logging facility" which can log to a log file and even send emails or other notifications. Code for the logging is in logger.py.
Usually the local module where the error or exceptions occurred will retry the operation that failed and log the event. If this fails an exception will be passed back up to main run loop in battery.py. The program will then terminate. I would suggest that when the program is deployed it be run from a shell script that on termination of the program will reboot the computer that it is running on or take some other course of action to try to work out why the program has terminated and fix the problem.