Hi,
thank you all for your tips and I also appologize because I probably didnt explain it really well. I will try again.
So basically with regards to getting data from station, there will be two stages in my template.
Stage 1: Loading history data into the database so that the user doesnt have to start from scratch (database etc. is created also automatically, I made scripts for that too)
- I have this part finished, I made 3 scripts, one is able to read, process and upload data from WU site directly, one does the same thing and is built to reflect the structure of WD log files and the last one again does the same thing, but with the monthly logs from Cumulus. This part is fine.
Stage 2: Continuous upload of current conditions
- so once stage 1 (which is optional, it is of course possible to start with a blank database) is finished, the goal is then to continuously add new data as they are measured and add them to the database.
The overall process can be summarized like this:
PWS -> software -> PHP script -> MySQL
PWS -> software - this is not an issue and can be done by various ways depending on which software the user uses
PHP script -> MySQL - again this is not a problem now, I have already made a script that is able to write the data into the db including data verification
The problematic part is the software ->PHP path.
The exact way of how to do this again depends on the particular software. For now I wanted to concentrate on three different: Meteobridge and similar, Cumulus and Weather display.
Meteobridge: this is probably the easiest. Meteobridge is capable of making an HTTP request, which means you put in the address of your script and it adds the current conditions into the address and can be then used by the script:
Example:
You set your meteobridge to send an HTTP request every 5 minutes to
www.abcd.com/update.php?t="tag for temperature"&h="tag for humidity".....
Meteobridge then every five minutes sends request to for example
www.abcd.com/update.php?t=55&h=23..... and the PHP script gets the data via the GET method.
And now we finally come to the problematic part. Cumulus and WD probably cannot do HTTP request like this, or maybe WD can in the newest version, but I will have to further look into it.
I therefore made a different script for these two softwares, which instead of getting the current data through the GET method and URL, gets the data from the txt file - i.e. realtime.txt or clientraw.txt. This again is not so difficult and I already have the code for this which works.
The final issue now is that obviously for the PHP script to load the text files and save the values to MySQL, I need the script to be executed at regular intervals - and this is what I am having the difficulty with.
CRON job - probably the easiest, but also problematic. First of all I can imagine lot of people dont know what it is and how to set it up. Second, not all webhostings have this feature and third, the interval offered by most webhostings is only very rarely as short as 5 minutes in the cheaper plans. I would therefore like to try to avoid CRON.
My question in this thread was therefore if anyone has an idea what would work the best and also what would be the most user-friendly option.
UPDATE:
As I said previously, I am not a PC programmer, I only know languages like PHP, Ajax, Javascript etc. but not C, Java or others. Still, I tried to look at some examples and I put together a Visual Basic VBS script, which at a user defined interval executes the PHP script. This seems as an ideal option, because it is not dependent on any weather software and can be run on any Windows computer.
My idea right now is therefore following (but again Im not sure to what extent it is feasible or if I maybe overlooked something)
Set the built-in windows task-scheduler to open and run this VBS script automatically upon opening whatever weather software you use. So for example set task scheduler to run this script everytime Cumulus is active. This script that contains the command to execute the php script (without the need to open the browser and performed in the background). This command is inside a loop so it is repeated over and over until the VBS script is running (which would be basically all the time if you have your weather software and data sent 24/7.) Also, between each loop there is a command for pausing (sleep), so you set this to for example 5 mintues and what you get is the PHP script then being executed every 5 minutes. I checked also the processes in windows and the resources and memory used by the VBS are negligible (about 3MB). So my idea right now is to use this VBS script because as I said, it can be used on any Windows machine irrespective of the weather software used and Im sure it will not be a problem to make something similar for iOS if necessary. And this would then be used by those who do not have a software that could make HTTP request directly.
Do you think this would work?