Page 1 of 4
Run External Programs based on Sunrise/Sunset webtags
Posted: Mon 19 May 2014 10:57 pm
by captzero
Hi all,
Here's a brain rattler....
I stream a live image during daylight hours only (no action at night) and use Windows Task Scheduler to run the program at around dawn and kill it around dusk. I change the on/kill times each week. As far as I know, Windows Task Scheduler doesn’t have the ability to do this based on the actual dawn/dusk times. Does anyone know of a way to do this using the external program feature in Cumulus (or Toolbox) or perhaps some other way?
Thanks
Re: Run External Programs based on Sunrise/Sunset webtags
Posted: Tue 20 May 2014 1:48 am
by ace2
would be nice to have an application that could do that!!!
I too use a form of task scheduler to run 25 scripts a day, 4 would benefit using dust and dawn times.
Anyone then.....
Re: Run External Programs based on Sunrise/Sunset webtags
Posted: Tue 20 May 2014 6:13 am
by BCJKiwi
You could create a batch file as C:\cumulus\web\batchT.txt and have Cumulus save it (not send it) as batch.cmd - obviously name something that make sense to you rather than batch.cmd!
In it place a variable for say <#isSunUp> (Tag generates 0 or 1).
This batch file could be run in the Program slot of external files which runs every time the tag files are updated e.g. every 10 mins or whatever you have set. The batch file can test this value and take action accordingly.
How you would use that to interact with whatever is controlling the streaming / 25 scripts is for you to determine.
Re: Run External Programs based on Sunrise/Sunset webtags
Posted: Tue 20 May 2014 11:36 am
by ace2
Very interesting idea, use cumulus to change a variable with in a txt created into a cmd.
Now how to use this...mm
I convert all bat files into a silent exe so it does interfere with my media center playback/other apps.
My idea would be use cumulus to write a webtag into a simple text as sun up or sun down(0 or 1) then use a script to read that value as a variable to record or not to record and run this as a schedule every hour or what ever....
Now how to write that script...
*looks for thinking hat*
Lol
Re: Run External Programs based on Sunrise/Sunset webtags
Posted: Tue 20 May 2014 12:33 pm
by ace2
Only problem I see if using my weather station dawn/dusk or sunset/sunrise times, the recording would start too late and finish too soon.
Example data from station yesterday
Dawn: 06:40 Sunrise: 07:08
Dusk: 17:45 Sunset: 17:18
But I would like to start recording at 06:00 as sky starts to show light and finish at 18:30 as the light fades.
Know of any solution?
Chris
Re: Run External Programs based on Sunrise/Sunset webtags
Posted: Tue 20 May 2014 2:40 pm
by mcrossley
Use <#isdaylight> which is based on dawn/dusk twilight times?
Edit: oops ignore that, I didn't read your question properly.
Re: Run External Programs based on Sunrise/Sunset webtags
Posted: Tue 20 May 2014 9:15 pm
by BCJKiwi
Its all down to how complicated you want to make it.
You could use any of the tags available and do the work from there.
There are separate tags for;
current hour <#hour>
current minute <#minute>
sunrise <#sunrise>
sunset <#sunset>
dawn <#dawn> (start of civil twilight - Sun's centre 6deg below horizon)
dusk <#dusk> (end of civil twilight - Sun's centre 6deg below horizon)
daylength <#daylength>
sun above the horizon <#isSunUp> (officially "daylight" is defined as when the sun's upper edge is at the horizon but of course it get light before then.
So there are a lot of variables to play with:-
compare the current time to dawn or dusk
or
deduct an hour from sunrise and when current time is > than that, switch on (and add an hour to sunset to switch off).
Re: Run External Programs based on Sunrise/Sunset webtags
Posted: Wed 21 May 2014 12:51 am
by ace2
How is it possible to deduct minutes from <webtag> as to return a variable of 1 or 2???
As I understand, using either <#isdaylight> or <#IsSunUp> will return a 1 for yes and a 0 for no, this could be easily be used in a switch script, but for either of them to Work it, it would require to minus X minutes from them.
Is that at all possible???
Re: Run External Programs based on Sunrise/Sunset webtags
Posted: Wed 21 May 2014 1:55 am
by captzero
BCJKiwi wrote:place a variable for say <#isSunUp> (Tag generates 0 or 1).
I think this is probably the least complicated and easiest way to go.
Re: Run External Programs based on Sunrise/Sunset webtags
Posted: Wed 21 May 2014 2:12 am
by ace2
captzero wrote:BCJKiwi wrote:place a variable for say <#isSunUp> (Tag generates 0 or 1).
I thinK is probably the least complicated and easiest way to go.
I would agree, but first light is about half an hour before and after <#issunup> times.
I like to capture the sun coming up as the colours are amazing and as the light fades in the evening..
PS. I've really highjacked this thread, sorry captzero.
Re: Run External Programs based on Sunrise/Sunset webtags
Posted: Wed 21 May 2014 2:20 am
by tumutbound
I spent a bit of time looking into this recently but ended up writing a python program to do it.
This program updates the configuration file for my webcamera program, also python, to decide when to start/stop taking images.
The main reason for not using webtags was I need it to happen in my Raspberry Pi based web camera and getting the webtag data from cumulus (running in an XP virtual machine on a Linux server ) via a Samba share was a hassle and a bit unreliable.
It's only in use on a test camera but I plan to have it running on the main camera soon.
Re: Run External Programs based on Sunrise/Sunset webtags
Posted: Wed 21 May 2014 2:36 am
by ace2
I'm stuck with a windows machine which is a TV media center. So it's much harder trying to keep resources to a minimum.
I have no stream monitoring software at all, the web cam takes care of the snapshot saving them to a nas drive on the network.
Wish I knew how to program!!
Re: Run External Programs based on Sunrise/Sunset webtags
Posted: Wed 21 May 2014 5:58 am
by BCJKiwi
@ace2
Doing math on dates is absolutely do-able in a batch file.
Construct the batch file with sample data in the format that Cumulus will deliver it to test the match.
Then save the working batch file as batchT.txt
edit it to replace the test data with the webtag.
Cumulus will process the text file and save as batch.cmd
You then run batch.cmd in the program time slot of Cumulus' external programs.
The batch file can do any number of different things in the one file if you need more routines, or, you could have a separate batch file for each routine (from Cumulus or not) and chain them together in another batch file.
Time to study the many features of the batch file language
All manner of things can be carried out in batch files - some complicated some less so.
There are also programs designed to extend and/or simplify these processes.
e.g. Math;
http://www.robvanderwoude.com/battech_math.php
Date and time
http://www.robvanderwoude.com/datetime.php
Also on that site many other commands are described;
http://www.robvanderwoude.com/batchfiles.php
I have also used the Kixtart program extensively over many years for login scripts and for routines similar to some php code.
While these references may appear old, nothing much has changed and these still work in all current versions of Windows AFAIK.
Re: Run External Programs based on Sunrise/Sunset webtags
Posted: Wed 21 May 2014 7:12 am
by steve
Just to clarify - <#IsSunUp> indicates whether the sun is UP, i.e. between sunrise and sunset, so yes, it is light before and after those. <#isdaylight> indicates whether it is between dawn and dusk, i.e. it includes Civil Twilight -
http://en.wikipedia.org/wiki/Twilight#Civil_twilight
If neither of those are suitable for a particular purpose, you'll have to do the maths yourself. It's possible that a future version of Cumulus might include web tags for nautical and astronomical twilight.
Re: Run External Programs based on Sunrise/Sunset webtags
Posted: Wed 21 May 2014 9:24 am
by ace2
steve wrote:It's possible that a future version of Cumulus might include web tags for nautical and astronomical twilight.
That would be great if that could be done one day.
Until then, I'll think I'll just stick to changing the times manually.....
Too hard to nut it out......