You are here: Homepage > Forum
Register now
SYMPL Modular Range
Lighting Control Engine 2
Priscilla Queen of the Desert – New York, USA
East Pacific International Center
Mission Space – Neede, The Netherlands

User login

Enter your username and password here in order to log in on the website:

Forgot your password?

Topic with no new replies

Offset for the sunrise and sunset in macro


Author Message
Written on:
Alex_F
Topic creator
registered since: 04.03.2016
Posts: 9
Hello everyone,

Does anyone know the solution?

How can I apply an offset : +15' for the sunrise and -30' for the sunset in macro?

Sincerely yours,
Alex.
Written on:
bkruse
registered since: 13.07.2010
Posts: 1438
Hi,

if you call the macro via a Trigger Rule, then you can simply put the offset into the Trigger Rule itself.

If you call the macro repeatedly and check for the astro event yourself, you use NiceTime() command for it.
With NiceTime() you can get todays astro times and also the current time. You need to compare it manually then.
See also escript help for NiceTime()

Does that help?
If not, please specify your question in more details.

Bests, Björn
Written on:
Alex_F
Topic creator
registered since: 04.03.2016
Posts: 9
Hello Bjorn,
I am using macro only.
Yes, I can get todays astro times and also the current time using NiceTime().

But it`s not clear for me how can I get for example 30 minutes before sunset.

Ideally, I would like to use the construction:

if (IsAfter(surise+15minutes) && IsBefore(suset-30minutes))


Sincerely yours,
Alex.
Written on:
bkruse
registered since: 13.07.2010
Posts: 1438
Hi,

IsAfter() and IsBefore() require the hour, minute and second to be entered separately.
Use TimeAdd() command to add or substract your offset.

Then you're pretty close to your mentioned if-statement.

Hope that helps,
Björn

Written on:
Alex_F
Topic creator
registered since: 04.03.2016
Posts: 9
As I understand it,
TimeAdd() command requires the hour, minute and second to be entered separately too.

Using TimeAdd() for "surise+15minutes" is not clear.

Ok. Another way:

string Sunrise; // It works using NiceTime
string Offset; // It works using MilliSecondsToTimeStr

Show me the way please, how I can do: "Sunrise+Offset" ???
Written on:
bkruse
registered since: 13.07.2010
Posts: 1438
Hi,

adding or other math operations only work on int (integer variables), not on string.

It can be done like this:

TYPOSCRIPT
// astroTimeWithOffset script comment
int sunriseH = val(NiceTime("$H1"));
int sunriseM = val(NiceTime("$M1"));
int sunsetH = val(NiceTime("$H3"));
int sunsetM = val(NiceTime("$M3"));
int currentH = val(NiceTime("%H"));
int currentM = val(NiceTime("%M"));
int sec = 0;
 
// add 15 min to sunrise
int add15 = 15*60;
TimeAdd(sunriseH, sunriseM, sec, add15);
 
//substract 30 min from sunset
int subs30 = -30*60;
TimeAdd(sunsetH, sunsetM, sec, subs30);
 
if (IsAfter(sunriseH, sunriseM, 0) && IsBefore(sunsetH, sunsetM, 0))
{
	printf("condition met! %d %d\n", add15, subs30);
}


Hope that helps,
Björn
Attachment

astroTimeWithOffset.cpp (File type: text/plain, Size: 594 bytes) — 100 downloads
Written on:
Alex_F
Topic creator
registered since: 04.03.2016
Posts: 9
Thank you so much Björn!
It works very well!!!

I tried make the same, but your macro is more better.

Sincerely yours,
Alex



Quick guide for the search
X


  • Wildcard-Search
    With the help of a so-called wildcard you can look for several search words, which have the same word beginning. If you search e.g. for "Typo*", the search will find everything that begins with "Typo" : Typo3, Typoscript, Typocode, Typo3user... etc.
  • Negative search
    If you do not want to find certain expressions in your search result, you can cause this with placing a hyphen in front. Terms containing this phrase are excluded from the search result.
  • Search for user
    It is possible to limit the search result on answers of certain users. In addition to the retrieval query attach still another "user:username" and find the results, which were written by this certain user. If the username could not be found this will be ignored.
Quick guide for Indexing
X


  • ###LABEL_START_INDEX###
    ###START_INDEX_CONTENT###
Search
Search string
Advanced Search place
Sort by
Show only solved topics
Only show one post per topic
Quick guide

Portal information:

At the moment there are 0 users online, thereof 0 registered users and 0 guests.
Today 0 registered users and 0 guests were already online.

Now online


www.ecue.com has 10932 registered user, 3029 topics and 9227 answers. On average 2.42 posts are written per day.

Please also find more articles regarding e:cue products here www.ecuetips.com (C) www.ruby-lighting.com