Changes between Version 40 and Version 41 of Proposal


Ignore:
Timestamp:
Jul 8, 2013, 1:31:51 PM (11 years ago)
Author:
Frédéric
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Proposal

    v40 v41  
    9999
    100100The {{{Stack}}} object is used to communicate over the bus (real bus, of course, but also on virtual bus). We can give it an Individual Address, to mimic real devices behaviour.
    101 The {{{ETS}}} object is a tool which works like the reall ETS application.
    102 
    103 The {{{Stack}}} object is used to weave (bind, link...) our Group Objects to Group Addresses:
     101
     102The {{{ETS}}} object is a tool which works like the reall ETS application, and used to weave (bind, link...) our Group Objects to Group Addresses:
    104103
    105104{{{
     
    116115}}}
    117116
    118 This call is blocking. We now have a process (Device) running, listening to the bus. The Datapoints, through their respective Group Objects, will react to requests on the Group Addresses their are weaved to ("1/1/1" and "1/1/2"). According to the flags, they will transmit their internal value on a Read request, or if this value changes.
     117This call is blocking, and launch the framework main loop.
     118
     119We now have a process (Device) running, listening to the bus. The Datapoints, through their respective Group Objects, will react to requests on the Group Addresses their are weaved to ("1/1/1" and "1/1/2"). According to the flags, they will transmit their internal value on a Read request, or if this value changes.
    119120
    120121Ok, but our Functional Block is not really usefull yet, as it does not refresh its Datapoints! Let's see how it can be done:
     
    137138    GO_02 = dict(dp="humidity", flags="CRT", priority="low")
    138139
    139     schedule.every(minute=5)
     140    @schedule.every(minute=5)
    140141    def updateTemperaturHumidity(self, event):
    141142
     
    146147        self.dp["humidity"] = humidity
    147148
     149
    148150weatherTempBlock = WeatherTemperatureBlock(name="weather_tempertature", desc="A simple weather block example")
    149151
     
    157159}}}
    158160
    159 All we do, here, is adding a method periodically called by the framework (every 5 minutes in the above example). In this method, we retreive the temperature and humidity values (not explained here), and give the value to the respective Datapoints. If the value has changed from the previous call, the Datapoint will automagically transmit it to the bus (according to the flags, of course).
     161We have just imported and instanciated an additionnal object:
     162
     163{{{
     164#!python
     165from pknyx.api import Scheduler
     166
     167
     168schedule = Scheduler()
     169}}}
     170
     171We have also defined a method which role is to update the temperature and humidity Datapoints values:
     172
     173{{{
     174#!python
     175    @schedule.every(minute=5)
     176    def updateTemperaturHumidity(self, event):
     177
     178        # How we retreive the temperature/humidity is out of the scope of this proposal
     179        # temperature = xxx
     180        # humidity = xxx
     181        self.dp["temperature"] = temperature
     182        self.dp["humidity"] = humidity
     183}}}
     184
     185Note how this method is periodically called, using the {{{schedule.every()}}} method as python decorator. This decorator will automatically register our method and call it every 5 minutes.
     186
     187In our method, we retreive the temperature and humidity values (not explained here), and give the value to the respective Datapoints. If the value has changed from the previous call, the Datapoint will automagically transmit it to the bus (according to the flags, of course).
    160188
    161189That's it for now. This is only a draft version; final implementation may change, according to feedback/suggestions I will get. But the core is all there. Again, the goal of the framework is to provide very high level tools to build complete and powerfull applications and KNX extensions.