-
Notifications
You must be signed in to change notification settings - Fork 0
Data Model
Aim: allow to conveniently specify who should be allowed to open which door at what times.
This page is out of date and speaks of irrelevant stuff. See Controller Behavior if you have nothing better to do.
Assumption: People are lazy => there will not be many distinct time intervals set up.
Idea: Imagine the time intervals look e.g. like this:
Allow: |=================| |===========|
Allow: |====| |========|
Deny : |------|
Project all start and end times:
|...|....|.|..|...|....|....|...|.......|
Store one bit for each of these new intervals: should we allow entry during this time interval?
| 1 | 0 |0| 1| 1 | 0 | 1 | 1 | 1 |
Compile the allowList
and denyList
into three separate bitmasks like this (one for week days, one for weekends, one for holidays) according to the above algorithm. Also store the corresponding times. When querying whether a door should be opened, a simple binary search tells you which bit to look at; open the door iff it is set.