From 981e0bd299624ec20538e60cb923f15e7a7d39ec Mon Sep 17 00:00:00 2001 From: Arjen Baart Date: Tue, 18 Feb 2020 09:38:27 +0100 Subject: [PATCH] Started on events and actions --- doc/design.xml | 22 +++++- doc/wakeup-classes.svg | 171 +++++++++++++++++++++++++++-------------- src/action.h | 16 ++++ src/event.h | 19 +++++ 4 files changed, 169 insertions(+), 59 deletions(-) create mode 100644 src/action.h create mode 100644 src/event.h diff --git a/doc/design.xml b/doc/design.xml index 0426b40..9aef045 100644 --- a/doc/design.xml +++ b/doc/design.xml @@ -145,6 +145,9 @@ Set the date to dec 21, 23:00. Set a wakeup event at dec 22, 06:00 + Start wakeup daemon + Verify lights on at 06:00 + Verify lights off at sunrise @@ -338,10 +341,10 @@ depending on the times of sunrise and sunset. The wakeup times are specified like calendar events, possibly with a recurrence pattern and an end date. -Elements in a wakeup event are: +Elements in an event are: Label - Light parameters + Action Start time Recurrence pattern Number of recurrences @@ -349,8 +352,23 @@ Elements in a wakeup event are: A recurrence pattern can be specified with a number of days, weeks or months as well as a set of weekdays. A set of weekdays implies the recurrence will be weekly. +The action for an event can be a light sequence or a curtain control. + +An event is read from an XML element or created dynamically, for example calculated from the time of sunrise. +From any event, the next occurance is calculated, which is an event that happens after a certain time. +When the next event does happen, meaning the time of the occurance is the current time, the sequence of actions is executed. +Each action can for example be a change in lights or the opening or closing of curtains. +Event methods: + +FromXML +ToXML +add_recurrance +next_occurance +add_action +execute_actions + diff --git a/doc/wakeup-classes.svg b/doc/wakeup-classes.svg index ee1ae88..950d04b 100644 --- a/doc/wakeup-classes.svg +++ b/doc/wakeup-classes.svg @@ -25,17 +25,17 @@ borderopacity="1.0" inkscape:pageopacity="0.0" inkscape:pageshadow="2" - inkscape:zoom="2" - inkscape:cx="286.177" - inkscape:cy="871.65698" + inkscape:zoom="0.86772068" + inkscape:cx="255.00379" + inkscape:cy="579.0815" inkscape:document-units="mm" inkscape:current-layer="layer1" showgrid="false" - inkscape:window-width="1920" - inkscape:window-height="1163" - inkscape:window-x="0" - inkscape:window-y="0" - inkscape:window-maximized="1" /> + inkscape:window-width="1711" + inkscape:window-height="1023" + inkscape:window-x="51" + inkscape:window-y="42" + inkscape:window-maximized="0" /> @@ -44,7 +44,7 @@ image/svg+xml - + @@ -53,119 +53,119 @@ inkscape:groupmode="layer" id="layer1"> Event label lights + style="stroke-width:0.26458332px">action start_time recurrence Lightsequence + y="204.42358" + x="100.58395" + sodipodi:role="line" + id="tspan4510">Lightstep lightlevel fadetime + x="131.0829" + y="25.459591" /> + x="131.0829" + y="25.459591" /> Event_Recurrence number end_time + pattern + + + Action + + + diff --git a/src/action.h b/src/action.h new file mode 100644 index 0000000..8f29894 --- /dev/null +++ b/src/action.h @@ -0,0 +1,16 @@ +#include +#include +#include + +class Action +{ +public: + +virtual void execute() = 0; + +} + +class Lightstep : Action +{ +} + diff --git a/src/event.h b/src/event.h new file mode 100644 index 0000000..ab1214e --- /dev/null +++ b/src/event.h @@ -0,0 +1,19 @@ + + +#include "action.h" + +class Event +{ + String label; + date start_time; + std::list sequence; + +public: + + Event(String lbl) + { + label = lbl; + } + + void FromXML(xmlnode x); +} -- 2.20.1