Changes between Version 8 and Version 9 of Tutorial


Ignore:
Timestamp:
Aug 22, 2013, 8:11:09 AM (11 years ago)
Author:
Frédéric
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Tutorial

    v8 v9  
    7777
    7878{{{
    79 #!python
    80 # -*- coding: utf-8 -*-
     79"""# -*- coding: utf-8 -*-
    8180
    8281from pknyx.api import Device, FunctionalBlock
     
    8483
    8584
    86 class MyFB(FunctionalBlock):
    87     DP_01 = dict(name="mydp", access="output", dptId="1.001", default="Off")
    88 
    89     GO_01 = dict(dp="mydp", flags="CWT", priority="low")
    90 
    91     DESC = "My FB"
    92 
    93 
    94 class MyDevice(Device):
    95     FB_01 = dict(cls=MyFB, name="myfb", desc="my fb")
    96 
    97     LNK_01 = dict(fb="myfb", dp="mydp", gad="1/1/1")
    98 
    99     DESC = "My device"
    100 
    101 
    102 DEVICE = MyDevice
     85class FB(FunctionalBlock):
     86    DP_01 = dict(name="dp_01", access="output", dptId="1.001", default="Off")
     87
     88    GO_01 = dict(dp="dp_01", flags="CWT", priority="low")
     89
     90    DESC = "FB"
     91
     92
     93class Timer(Device):
     94    FB_01 = dict(cls=FB, name="fb_01", desc="fb 01")
     95
     96    LNK_01 = dict(fb="fb_01", dp="dp_01", gad="1/1/1")
     97
     98    DESC = "Timer"
     99
     100
     101DEVICE = Timer
    103102}}}
    104103
    105104As you see, it already contains a dummy Functional Block, and a dummy Device, in order to show how things work.
    106105
    107 == Timer example ==
    108 
    109 Ok, lets's start to implement as simple example: a timer. This timer monitors the state of a light, and switches it off automatically after a delay.
     106== The Timer example ==
     107
     108Ok, lets's start to implement our simple timer example. This timer monitors the state of a light, and switches it off automatically after a delay.
    110109
    111110Let's modify the {{{device.py}}} according to this: