• 10 dec 2017: forum version update. In case of issues use this topic.
  • 30 nov 2017: pilight moved servers. In case of issues use this topic.
Hello There, Guest! Login Register


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Ideas for replacement of datetime protocol
#1
The datetime protocol has to be dropped in it's current existance.

With the new codebase, a timerpool was introduced. A short explanation of it's logic.

Old situation:
- 4 functions = 4 threads
- Interval of functions: 1) 3s 2) 1s 3) 10s 4) 5s
- Send message when timeout arrived.

This logic doesn't scale because each new timed function required a new thread.

New situation:
- 4 functions = 4 tasks in threadpool queue
- All intervals are added to a priority queue like this:
2) 1s
1) 3s
4) 5s
3) 10s
- Execute the first function (through the threadpool) that needs execution, then rearm the timer. The execution logic will be like this (when all functions repeat endlessly and rearm at each execution):
2, 2, [2, 1], 2, [2, 4], [2, 3], 2, 2, [2, 3], [2, 4, 3]

This logic scales fine because all timed functions are handled by a single timer and each timeout will be handled by the threadpool.

So in this light, the current datetime device has to be dropped. That implementation still doesn't use the timerpool logic. As in, don't evaluate execution each second, but trigger the timerpool to wait for the first timeout to arrive.

A few ideas how to achieve this:
- Replace the datetime protocol with a cron like protocol. The new cron protocol will fire based on original cron behaivor:
Code:
"zeit": {
    "protocol": [ "cron" ],
    "id": [{
        "longitude": 8.53031,
        "latitude": 50.15403
    }],
    "year": "*",
    "month": "*",
    "day": "*",
    "weekday": "*",
    "hour": "9, 23",
    "minute": 0,
    "second": 0
}
This should trigger a cron event each day of each month of each year at both 9:00 and 23:00.

- Another idea is to add a cron feature to each rule:
Code:
{
    "rule1": {
        "rule": "...",
        "active": 0,
        "cron": [ "0 9,23 * * *" ]
    }
}
This means we drop the datetime / cron protocol altogether, but attach an timed evaluation to each rule. The rule will then only be evaluation on the specific timeout moments.

- Other ideas???
 
Reply
  


Messages In This Thread
Ideas for replacement of datetime protocol - by curlymo - 03-05-2016, 11:46 PM

Possibly Related Threads...
Thread Author Replies Views Last Post
  program protocol missing in rewrite Niek 1 781 10-07-2017, 08:55 PM
Last Post: curlymo

Forum Jump:


Browsing: 1 Guest(s)