From: Constantin Berhard Date: Fri, 25 Oct 2013 15:18:25 +0000 (+0200) Subject: concept space api X-Git-Url: https://git.ralfj.de/saartuer.git/commitdiff_plain/960dd08b9c20e339762ba9dab8977f29b05ac522?hp=--cc concept space api --- 960dd08b9c20e339762ba9dab8977f29b05ac522 diff --git a/concept_spaceapi.py b/concept_spaceapi.py new file mode 100644 index 0000000..e991463 --- /dev/null +++ b/concept_spaceapi.py @@ -0,0 +1,24 @@ + + +class SpaceApi: + __init__ (self): + self.state_to_set = None # public write, TODO: getters, setters? + self.state_last_set = None # public read + self._running = True + self._t = threading.Thread(target=self.loop) + _t.start() + + def stop (self): + self._running = False + + def loop (self): + while self._running: + if (self.state_to_set is not None): + if self.state_to_set != self.state_last_set: + stts = self.state_to_set # cache for parallelism + error = do_request(stts) # TODO + #TODO logging + if not error: + self.state_last_set = stts + #TODO logging + time.sleep(SPACE_API_LOOP_DELAY) \ No newline at end of file