rejetto forum

scripts and events in hfs

Mars · 22 · 15387

0 Members and 1 Guest are viewing this topic.

Offline Mars

  • Operator
  • Tireless poster
  • *****
    • Posts: 2059
    • View Profile
Since some build, everybody heard about the file hfs.events.

Every event of hfs.events is predetermined with regard to certain sections of the main template hfs.tpl.

For more variety, I crossed quite a lot of time to study the subject and some small additions stood out from my imagination, and for reasons of compatibility with the sources of rejetto, I had to use names predefined for sections added in hfs.events.

The new type of section is [sym-event xxxxxxxxx] and is characterized by two versions:

[sym-event every xx]   and  [sym-event at xx]

It is obvious that these features will be completely operational in the next French version of silentpliz ;)

The used code is the following one:
Quote

.......
  end; // calculateETA

  procedure runTimeEvent(timer:integer);      //add by mars
  var
    sym_events:TStringDynArray;
    i:integer;
    sym_eventname:string;
    hourTime, everyTime:integer;
    AtTime:TDateTime;
  begin
  sym_events:=eventScripts.getSyms();
  if not Length(sym_events)>0 then exit;

  for i:= 0 to Length(sym_events)- 1 do
    begin
    sym_eventname:=sym_events[ i ];
    chop('sym-event',sym_eventname);
    sym_eventname:=lowercase(trim(sym_eventname));
   // [sym-event every 1:04] or [sym-event every 64] = event every 64 minutes
    if ansiStartsStr('every',sym_eventname) then
      begin
      chop('every',sym_eventname);
      trim(sym_eventname);
      hourtime:=0;
      try
        if pos(':',sym_eventname) >0 then
          hourTime:=strtoint(chop(':',sym_eventname));
        everyTime:=strtoint(sym_eventname);
      except continue; end;
      everyTime:= hourTime*60+everyTime;
      if (everyTime > 0) and ((timer mod everyTime)= 0) then
        runEventScript(sym_events[ i ]);
      continue;
      end;
   // [sym-event at 3PM] or [sym-event at 15:00] or [sym-event at 15]   = event  at 15h00
    if ansiStartsStr('at',sym_eventname) then
      begin
      chop('at',sym_eventname);
      try atTime:=strtotime(trim(sym_eventname))
      except continue; end;
      if (AnsiLeftStr(TimeToStr(atTime),5) = AnsiLeftStr(TimeToStr(Time),5)) then
        runEventScript(sym_events[ i ]);
      continue;
      end;
    end; //next i
  end; //RunTimeEvent


  procedure updateEventScripts();
...........

..........
  procedure everyMinute();
  begin
  if quitting then exit;
  runTimeEvent(clock div (60*10));    //add by mars : time events
  if updateDailyChk.Checked then
    autoCheckUpdates();
  // purge icons older than 5 minutes, because sometimes icons change
  iconsCache.purge(now_-(5*60)/SECONDS);
  end; // everyMinute

 :o I was going to forget to join the part adding to the file hfs.events in example.

Quote
[sym-event every 1]
{.add to log|this section is called every 1 minutes.}

[sym-event every 3]
{.add to log|this section is called every 3 minutes.}

[sym-event every 5]
{.add to log|this section is called every 5 minutes.}

[sym-event every 1:4]
{.add to log|this section is called every 64 minutes.}

[sym-event every 2]
{.add to log|this section is called every 2 minutes.}

[sym-event every 25]
{.add to log|this section is called every 25 minutes.}

[sym-event every 60]
{.add to log|this section is called every 1 hour.}

[sym-event every 1440]
{.add to log|this section is called every 1 day.}

[sym-event at 23:18]
{.add to log|this section is called at 23:18.}

[sym-event at 23:16]
{.add to log|this section is called at 23:16.}

[sym-event at 11PM]
{.add to log|this section is called at 23h00.}

topic locked, because to be continue...
« Last Edit: January 28, 2009, 02:45:55 PM by mars »


Offline rejetto

  • Administrator
  • Tireless poster
  • *****
    • Posts: 13510
    • View Profile
yes, i like it, i was thinking something like that the other day.

1. i don't think sym-event is a good name. Is borrowed from the old user %symbols% thing. It has actually nothing to do with symbols and is very obscure for the users. I guess [every XXX] should be enough, we'd check for "every " (with space), and it will hardly clash with anything else. OK?

2. I think seconds should be allowed for the 'every'. We may have a default unit and let the user specify other, like [every 3 hours] or [every 3 h], and [every 4 minutes] or [every 4 m].
what you think would it be the best default unit? minutes or seconds?
« Last Edit: February 01, 2009, 12:58:59 PM by rejetto »


Offline SilentPliz

  • Operator
  • Tireless poster
  • *****
    • Posts: 1298
  • ....... chut ! shh!
    • View Profile
what you think would it be the best default unit? minutes or seconds?

   
Inasmuch as we have seen (mars and me), a gap between the call and run the macro (between 5 seconds and 30 seconds), perhaps the unit defaults in seconds would be an best solution.
« Last Edit: February 01, 2009, 02:26:52 PM by SilentPliz »


Offline Mars

  • Operator
  • Tireless poster
  • *****
    • Posts: 2059
    • View Profile
Quote
1. i don't think sym-event is a good name.

Sym-event is the only possibility that I was able to use without modifying one so much is little the sources of hfs, indeed if you look of the highly-rated of the type Ttpl, several elements are missing:
Ttpl = class
....
public
function getsections():TStringDynArray;   //as getsyms()
function getSectionByID(id:integer):string;
var count:integer


OK for the renunciation of the part 'sym-', but it is necessary to keep the 'event' word in the name of section.

For me it will be this syntax, there will be no bargaining ;D ;D

[event every xx:xx]

[event at xx:xx]

Quote
what you think would it be the best default unit? minutes or seconds?
Concerning the unit of measure, it is possible to shorten the imposed delai of 1 minute, but it is necessary to think that too much of moved closer events could create an overload of hfs, and thus damage the system, as for the used syntax xx:xx, it is in compliance with the type Ttime

To use a timming below 30 seconds would be absurd, because we can already notice a delay of approximately 37 seconds between the passage of the clock system in the next minute and the beginning of the concerned event

It is in noted that the event [event every xx:yy] runs quite xx hours+ yy minutes which follow the starting up of hfs, the event [event at yy:yy] runs at the indicated hour incremented of at least 30 seconds.
I am going to work on a version of 'event at' which will begin in the chosen minute and about is the hour, by example xx:35, every new hour + 35 minutes (+30 seconds :D)


Offline rejetto

  • Administrator
  • Tireless poster
  • *****
    • Posts: 13510
    • View Profile
OK for the renunciation of the part 'sym-', but it is necessary to keep the 'event' word in the name of section.

For me it will be this syntax, there will be no bargaining ;D ;D
[event every xx:xx]
[event at xx:xx]

mmmm, i meant to remove also "event" because in the events file, anything in [square brackets] is an event.

it would be like naming a variable to keep the age of a person "variableAge". :)

Quote
To use a timming below 30 seconds would be absurd, because we can already notice a delay of approximately 37 seconds between the passage of the clock system in the next minute and the beginning of the concerned event

it's because you put the handling inside everyMinute()

Quote
I am going to work on a version of 'event at' which will begin in the chosen minute and about is the hour, by example xx:35, every new hour + 35 minutes (+30 seconds :D)

like "cron" :)
did you do it then?
i'm not sure this is the good way to go.
maybe something similar to javascript setTimer() will give us more power with less coding.


Offline rejetto

  • Administrator
  • Tireless poster
  • *****
    • Posts: 13510
    • View Profile
aaaaaaaaaaaaaaaah
finally i found why you insisted on the "sym" thing.
there was a legacy handling for sections with that name. (the getSyms)
that function is not used anymore, since the new macro system can work without it.
and since the name "sym" is very ugly, i think i will shortly remove it.
i think it is better that we just make "sections" array to be public.
like...
Code: [Select]
  for i:=0 to length(eventScripts.sections)-1 do
    with eventScripts.sections[i] do
      if ansiStartsText('every ', name) then


Offline Mars

  • Operator
  • Tireless poster
  • *****
    • Posts: 2059
    • View Profile

Offline rejetto

  • Administrator
  • Tireless poster
  • *****
    • Posts: 13510
    • View Profile
i think it is better that we just make "sections" array to be public.
like...
Code: [Select]
  for i:=0 to length(eventScripts.sections)-1 do
    with eventScripts.sections[i] do
      if ansiStartsText('every ', name) then

i'm trying this solution, but i fear it is not good.
it is not compatible with the "diff template" technology (the "over" thing).
i know we are not using this for event scripts yet, but i suspect we may in the future.
so, my new suggestion is to have a getSections() that will return all section' names.


Offline rejetto

  • Administrator
  • Tireless poster
  • *****
    • Posts: 13510
    • View Profile
ok, i finally found my way through this.

next build will have [every XXX] and [at HH:MM]
XXX is in seconds, but you can use minutes or hours. examples
[every 5]   (that is 5 seconds)
[every 3 hours]
[every 4h]
[every 15 minutes]
[every 1.5m]   (that is 90 seconds)
[every 1:15 min]  (that is 75 minutes)

HH:MM is instead in standard 24 hours format, but you can do things like

[at 0:00=at 6:00=at 12:00=at 18:00]
this will trigger every six hours, but at specific times.
while [every 6 hours] would trigger at same intervals but differently placed in time.


Offline Kremlin

  • Tireless poster
  • ****
    • Posts: 137
    • View Profile
So in the matter of the schedule set ini I can simply create a section called [at 18:00] and the command under it? If so this is very nice.



Offline Kremlin

  • Tireless poster
  • ****
    • Posts: 137
    • View Profile

Offline Mars

  • Operator
  • Tireless poster
  • *****
    • Posts: 2059
    • View Profile
build 232

 hfs.events

[every 10]
{.add to log|KREMLIN.}


Offline Kremlin

  • Tireless poster
  • ****
    • Posts: 137
    • View Profile
I'm refering to the [at 18:00]

Tryed it with the set ini command and it didn't trigger even with a download start. This must be a set ini macro problem because other commands seem to work with these macros


Offline Mars

  • Operator
  • Tireless poster
  • *****
    • Posts: 2059
    • View Profile
can you give us your hfs.events to see where is the pb (MP if you prefer)