Skip to content

Control Strategies

Paolo Grasso edited this page Jul 25, 2020 · 1 revision

General info

A control strategy script relies on:

  • JSON file with contains catalog IP, catalog port, devID and plantID to which it is associated
  • A script functions.py which contains generic functions in common with all strategies

Execution

When launched, a control strategy should:

  1. Start a thread which continuously checks if the current time of the machine corresponds to one entry of the hour timetable TIME_LIST. If it corresponds, it calls the get_results() functions and delete the entry from the timetable.
  2. Loop on a function which asks the catalog the hours of irrigation of the plant and appends them to the hour timetable. This happens once a day (sleep 86400 seconds). Except for the irrigation strategy, all hours appended in the hour timetable get anticipated by 5 minutes with respect to the ones present in the catalog.

get_results()

This is a generic function which can be adapted according to the sensor and the plant for which the strategy is designed. It should:

  1. Ask the ThingSpeak Adaptor the past environmental data for a specific interval (e.g. 4 hours).
  2. Compute a variation of the irrigation parameters (e.g. too dry -> add 1000 seconds to the irrigation)
  3. Use the post_mod() function to publish modifications on dynamic catalog via REST.
Clone this wiki locally