Scripts/C/Java for the Raspberry Pi server. Some key files: powermng.cpp Manages power for the RPi based on battery SoC and grid state, eg dumping some excess power to a load moved off-grid at optimal times. ssmppt15l-modbus.cpp Reads some key parameters from the SS-MPPT-15L solar controller. README.txt This file. snapshots/ Code snapshots by date. tests/ Unit tests of key elements of functionality. Pending ideas: * Break out templated core algos and unit test with gtest. * Improve 's' by not preventing dumping at times of day when import likely. * Set temp adjusted margin to reflect coldest forecast temp during next 12--24h to retain adequate margin overnight when temp is falling. Some key updates: 2021-03-26: add A1V raw primary array voltage (mV) to end of logged stats. 2020-12-05: if many days since FULL, eg mid-winter, only dump when red or VFULL. 2020-06-27: -n option now also suppresses adjusing flags and other priv ops. 2020-06-26: folding in support for Expander Pi on RPi3B. 2018-09-11: added extra "significant grid-tie generation" guard to 's'. 2018-09-01: adjusting thresholds to improve use of available capacity. 2018-08-27: prevent dumping while SoC low and grid-tie exporting. 2018-07-08: allowing continuous dumping if battery SoC > 95%. 2018-06-22: removing aggressive dump lockout for day after VLOW (dip). 2018-06-21: adjusting to potentially allow continuous dumping. 2018-06-19: protective reserve for poor forecast now USoC %age. 2018-06-18: allowing very full battery to dump a little, even mid-winter. 2018-06-17: rejigged and unit-tested LA impedance and USoC algos. 2018-06-16: adding Eclipse support (to enable laptop unit test runs). 2018-06-14: adding GTest unit test support. 2018-06-10: adding 'Usable Charge' percentage to log output. 2018-06-10: slightly keener to keep load off grid (by dumping). 2018-06-08: rearranging dump margin calc since currently far too dump averse. 2018-06-06: cap threshold for dumping to 'resting full' V when discharging. 2018-05-23: only avoid dumping to grid when 'deep green', ie no storage draw. 2018-05-23: overnight voltage too high at ~12.8V so thresholds reduced. 2018-02-16: pushing up dump margin from 50mV to 150mV min to avoid wee hours VL. 2018-01-08: pushing up dump margin from 3 to 4 days nominal. 2018-01-08: pushing up extra margin in absence of good forecast / recent VLOW. 2018-01-05: temperature compensation -15mV/C to keep out of VLOW unnecessarily. 2017-12-30: reduced setpoint temperature compensation to -18mV/C. 2017-12-16: fixed direction of temp compensation and it is now always applied. 2017-12-16: prevent dumping ('L') if not long enough since last VLOW. 2017-11-05: added 'S' low SoC branch to prevent dumping. 2017-11-05: added 'long time since FULL' flag, initially gating 'N' status. 2017-10-21: now computing effective SoC from compensated B1 voltage. 2017-10-20: VHIGH now not active until charger reports absorption phase reached. 2017-10-01: tuned LOW/VLOW thresholds to be slightly less conservative. 2017-09-23: ondemand sampling_rate and sampling_down_factor now controlled too. 2017-09-23: ondemand governor threshold adjusted at VLOW boundary not LOW. 2017-09-18: LOW and VLOW thresholds adjusted upwards to avoid sulphation. 2016-11-29: constexpr applied liberally. 2016-11-29: tweaking temperature compensation to battery impedance/sag. 2016-11-12: applying temperature compensation to battery impedance/sag. 2016-10-30: added -E to ssmppt15l-modbus to help gather entropy. 2016-10-01: tweaked looping to ease collection of high-res sample with -nl. 2016-09-25: B1 temperature logging and compensation. 2016-09-24: created BATT1_MINUSAGE_mV_per_day; tiered 'e' dump triggers by days. 2016-09-17: attempt to suppress dump oscillation with tweaked thresholds. 2016-09-11: commented out most of B2 (Li) code. 2016-09-11: dump margin and sag calcs now dynamic with load compensation. 2016-09-10: more cautious after reboot in reliance on last-VHIGH flag timing. 2016-09-10: added live calc of implied supply impedance to RPi. 2016-09-09: made time since VHIGH determinant of less aggressive dumping. 2016-09-07: prioritised dump load triggers further. 2016-09-01: dumping less aggressive if battery not FULL for several days. 2016-09-01: moving locking to mbacess to be shared by the command-line tools. 2016-08-30: encouraging dump is battery > 'medium' and grid not 'green'. 2016-08-28: added FULL state (>=VH and battery in float) and flags. 2016-08-25: split out separate mbaccess.cpp wrapper.