waggle-sensor / wagman

The Waggle Manager (Wagman), a custom circuit board and control system for Wild Waggle Nodes
1 stars 3 forks source link

Move towards more scheduler / event driven code #18

Open seanshahkarami opened 7 years ago

seanshahkarami commented 7 years ago

At the moment, the system has a lot of timers keeping tabs on when events should occur. Now, those are all kind of laid out in an ad-hoc way through different pieces of the system. It would be nice to write a central scheduler in charge of managing these things.

Some possible benefits I can think of off hand are:

seanshahkarami commented 7 years ago

I started prototyping a couple different approaches to this as part of a generally purpose scheduler: https://github.com/seanshahkarami/scheduler

This kind of design could be very helpful as it allows you to "step" timing and other events. This opens up the possibility of unit testing sequences of events to ensure correctness.

For example, you could simulate having a device in a particular state, then advance time until just before a transition to check if it's still in the same state, then advance time by one unit and check that a transition happened and that we're in the correct state. You can also unit test things like heartbeat / watchdog behavior with this.