Changes between Version 8 and Version 9 of Tutorial
- Timestamp:
- Aug 22, 2013, 8:11:09 AM (11 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Tutorial
v8 v9 77 77 78 78 {{{ 79 #!python 80 # -*- coding: utf-8 -*- 79 """# -*- coding: utf-8 -*- 81 80 82 81 from pknyx.api import Device, FunctionalBlock … … 84 83 85 84 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 = " MyFB"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 = MyDevice85 class 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 93 class 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 101 DEVICE = Timer 103 102 }}} 104 103 105 104 As you see, it already contains a dummy Functional Block, and a dummy Device, in order to show how things work. 106 105 107 == T imer 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 108 Ok, 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. 110 109 111 110 Let's modify the {{{device.py}}} according to this: