Device Scheduling

From aquarium-doc
Jump to navigationJump to search

The following components actuate the relays:

  • Refill Control: refilling of fresh water depending on water level
  • Feeder Control: stopping flow pumps, skimmer and actuating the feeder
  • Water Exchange Control: actuating the external pump for water exchange
  • Balling Control: actuating the pumps for mineral dosing

There are two requirements, which ask for a more sophisticated control of the relays:

  • The dosing of minerals needs to be as precise as possible.
  • The hardware shall be tested before commencing certain operations.
  • The communication with the board needs to be reinitialised or reopened after certain periods of time.

Avoiding conflicting access to the relays

This functionality is implemented in DevSchdlr/DevSchdlr.c.

Mutual exclusion is implemented using a semaphore.

The semaphore is used only by the function DevSchdlr. This function is the central gateway for all other components to initiate usage of the relays. It shall give control of the hardware to a calling component so that the calling component can execute a sequence of commands which shall not be interrupted.

The function uses three callbacks which are provided via argument and a label informing which component is using the relay board:

DevSchdlr (int TestFuncRlyBrd(void), int TestFuncControllino(void), void ExecFunc(void), char *lbl)

The first and second callback functions (TestFunc) allow the calling component to determine specifically which tests needs to be carried out before the sequence can be initiated. For example, the Balling dosing only needs to actuate the low voltage relays while the feeder control only actuates the high voltage relays.

The test functions implement specific recovery strategy.

The callback function (ExecFunc) gives control to the calling component for execution of the sequence. Execution is only triggered if one call of the test function returned with a successful result.