This software is an example of reading information from a Morningstar TriStar PWM and then displaying the information on a web page.  This example requires the libmodbus library as well as gd2 (on Debian: apt-get install libgd2-noxpm-dev).

PLEASE NOTE: I do not have a TriStar PWM, so this software is untested.  It is my best guess of what should work.  The MODBUS documentation is very similar to that of the SunSaver MPPT which I do have.  In particular, I don't know if I have the bitwise operators in "dailylog.c" correct for Logger_flags, alarm_daily, Tb_min_daily, or Tb_max_daily.  I can't test it so I don't know.  The software compiles on my system with no errors.

To use this example, you will need to edit "powersystem.h" in the "src" directory with the appropriate path to your serial port and the appropriate file paths to where you want to store the log files and the web pages (also read FILELOCATIONS).  Once you have edited "powersystem.h", type "make" in the "src" directory to compile the three executables: powersystemstatus, dailygraphs, and dailylog.  These are stored in the "bin" directory.

The web page is generated by running "powersystemstatus" every 5 minutes using the included cron file (src/cron.d/powersystem).  Edit it appropriately and copy it to /etc/cron.d  The cron file also runs "dailygraphs" and "dailylog" once a day.

"dailygraphs" updates the daily graphs web page with all the daily graph image files in the current year's directory.

"dailylog" reads the current day's information from a TriStar PWM and adds the information to a table on a web page.

The software doesn't make the file directory structures or do any setup.  A basic setup with empty folders is included in this distribution.  You will need to make all the right directories for your setup before running the software.  Toward the end of each year I have to add directories for the next year in the log directory and the powersystem directory (see FILELOCATIONS).  I also have to edit "powersystemstatus.c" to add links for the next year's daily graphs and daily logs (see comments in powersystemstatus.c).
