annotate test.py @ 1:7251d615ca5a default tip

Added tag 0.0.1a for changeset 2d587ea676bf
author Ben Croston <ben@croston.org>
date Mon, 03 Sep 2012 17:18:55 +0100
parents 2d587ea676bf
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
2d587ea676bf Initial version
Ben Croston <ben@croston.org>
parents:
diff changeset
1 # Copyright (c) 2012 Ben Croston
2d587ea676bf Initial version
Ben Croston <ben@croston.org>
parents:
diff changeset
2 #
2d587ea676bf Initial version
Ben Croston <ben@croston.org>
parents:
diff changeset
3 # Permission is hereby granted, free of charge, to any person obtaining a copy of
2d587ea676bf Initial version
Ben Croston <ben@croston.org>
parents:
diff changeset
4 # this software and associated documentation files (the "Software"), to deal in
2d587ea676bf Initial version
Ben Croston <ben@croston.org>
parents:
diff changeset
5 # the Software without restriction, including without limitation the rights to
2d587ea676bf Initial version
Ben Croston <ben@croston.org>
parents:
diff changeset
6 # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
2d587ea676bf Initial version
Ben Croston <ben@croston.org>
parents:
diff changeset
7 # of the Software, and to permit persons to whom the Software is furnished to do
2d587ea676bf Initial version
Ben Croston <ben@croston.org>
parents:
diff changeset
8 # so, subject to the following conditions:
2d587ea676bf Initial version
Ben Croston <ben@croston.org>
parents:
diff changeset
9 #
2d587ea676bf Initial version
Ben Croston <ben@croston.org>
parents:
diff changeset
10 # The above copyright notice and this permission notice shall be included in all
2d587ea676bf Initial version
Ben Croston <ben@croston.org>
parents:
diff changeset
11 # copies or substantial portions of the Software.
2d587ea676bf Initial version
Ben Croston <ben@croston.org>
parents:
diff changeset
12 #
2d587ea676bf Initial version
Ben Croston <ben@croston.org>
parents:
diff changeset
13 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
2d587ea676bf Initial version
Ben Croston <ben@croston.org>
parents:
diff changeset
14 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
2d587ea676bf Initial version
Ben Croston <ben@croston.org>
parents:
diff changeset
15 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
2d587ea676bf Initial version
Ben Croston <ben@croston.org>
parents:
diff changeset
16 # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
2d587ea676bf Initial version
Ben Croston <ben@croston.org>
parents:
diff changeset
17 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2d587ea676bf Initial version
Ben Croston <ben@croston.org>
parents:
diff changeset
18 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2d587ea676bf Initial version
Ben Croston <ben@croston.org>
parents:
diff changeset
19 # SOFTWARE.
2d587ea676bf Initial version
Ben Croston <ben@croston.org>
parents:
diff changeset
20
2d587ea676bf Initial version
Ben Croston <ben@croston.org>
parents:
diff changeset
21 import scratch
2d587ea676bf Initial version
Ben Croston <ben@croston.org>
parents:
diff changeset
22 import time
2d587ea676bf Initial version
Ben Croston <ben@croston.org>
parents:
diff changeset
23
2d587ea676bf Initial version
Ben Croston <ben@croston.org>
parents:
diff changeset
24 s = scratch.Scratch()
2d587ea676bf Initial version
Ben Croston <ben@croston.org>
parents:
diff changeset
25
2d587ea676bf Initial version
Ben Croston <ben@croston.org>
parents:
diff changeset
26 # sensorupdate() test
2d587ea676bf Initial version
Ben Croston <ben@croston.org>
parents:
diff changeset
27 data = {}
2d587ea676bf Initial version
Ben Croston <ben@croston.org>
parents:
diff changeset
28 data['one'] = 1
2d587ea676bf Initial version
Ben Croston <ben@croston.org>
parents:
diff changeset
29 data['devil'] = 666
2d587ea676bf Initial version
Ben Croston <ben@croston.org>
parents:
diff changeset
30 for data['counter'] in range(60):
2d587ea676bf Initial version
Ben Croston <ben@croston.org>
parents:
diff changeset
31 s.sensorupdate(data)
2d587ea676bf Initial version
Ben Croston <ben@croston.org>
parents:
diff changeset
32 time.sleep(1.0)
2d587ea676bf Initial version
Ben Croston <ben@croston.org>
parents:
diff changeset
33
2d587ea676bf Initial version
Ben Croston <ben@croston.org>
parents:
diff changeset
34 # broadcast() test
2d587ea676bf Initial version
Ben Croston <ben@croston.org>
parents:
diff changeset
35 s.broadcast("py_1")
2d587ea676bf Initial version
Ben Croston <ben@croston.org>
parents:
diff changeset
36
2d587ea676bf Initial version
Ben Croston <ben@croston.org>
parents:
diff changeset
37 # receive() test
2d587ea676bf Initial version
Ben Croston <ben@croston.org>
parents:
diff changeset
38 while 1:
2d587ea676bf Initial version
Ben Croston <ben@croston.org>
parents:
diff changeset
39 print(s.receive())