Another top10 approach

An example for this top10 approach you will find on the weather site.

As a variation to existing top10 lists, I wrote a small program (in C) which reads dayfile.txt from Cumulus once per day just after midnight and for selected measurements it creates a sorted top10-list. From that list it creates a HTML-table and writes that to a text-file. That file can be included by the user on a website wherever he wants simply by a PHP-include (which is the easy way to include I think).

Recently I saw some Top10 pages on different sites and I discussed it with a meteo enthusiast close by, who pointed me to a site top10 page and PHP/SQL function serving it, made by Mark Crossley. I appreciate the result but while studying the PHP and SQL code, I could not help noticing that the query’s are fetched every time the page is loaded (apart maybe for some caching advantage). Beside that, this type of PHP/SQL combination brings a complexity to displaying of data which I increasingly see on websites, but which I personally do not really like. As Cumulus itself has a very clean text database and as such the handling of the data is not complex and straightforward, I took another approach, described below. PHP/SQL, I think, is a bit of overkill.

You will find attached, the program compiled for the Raspberry 3B+ in a zip-archive. For other environments, it needs to be recompiled (which I think can be done without modifications). I submitted the code to github in a private repository. As this is my first github project, I will have to find out how that works. Let me know if you are interested, have a problem or have question.

How to use (for a daily new version of the table):

  1. Copy the executable to the CumulusMX executable directory, the data-directory is assumed one directory below. If not, it fails.;
  2. In “CumulusMX->InternetSettings->External programs->Daily program” fill in: “./top10”;
  3. In Daily Program Parameters use values for the commandline parameters “-NrOfColumns 2 -bgcHdr Red -bgcTbl yellow -txtHdr purple -accTbl “;
  4. In “Extra webfiles” create two new entries for “top10TableStyle.txt” and “top10Table.txt”; Set these for FTP, if you want to debug and have quick result: set realtime and rund the program by hand, otherwise just FTP is enough.
  5. Make a page for your website to display the table.This is done by including the txt.files in respectively the <HEAD> and the <BODY> section. A likely method could be e.g. PHP: “<?php include(‘top10TableStyle.txt’);?>”

Commandline parameters are:

* 1) -NrOfColumns – number of columns
* 2) -bgcHdr – background color header
* 3) -bgcTbl – background color table (the data)
* 4) -txtHdr – text color for the header
* 5) -accTbl – accent color for the table (dates and values)
* if younger than 30 days
* e.g. -NrOfColumns 2 -bgcHdr Red -bgcTbl yellow -txtHdr purple -accTbl #d0d0d0
* for obvious purposes as everybody’s site has different styles.
* Any number of arguments can be used or skipped in any order.

Defaults are:

Number of columns = 3;
background color header = “#d0d0d0”;
background color table = “#f0f0f0”;
text color for the header = “Green”;
accent color for the table (dates and values) = “DarkOrange”;

(Crossposted in the Cumulus support forum)

Geef een reactie