add formel 18
[owPython.git] / owRead.py
1 #!/usr/bin/python\r
2 # Copyright (c) 2017, Tobias Mueller tm(at)tm3d.de\r
3 # All rights reserved. \r
4\r
5 # Redistribution and use in source and binary forms, with or without \r
6 # modification, are permitted provided that the following conditions are \r
7 # met: \r
8\r
9 #  * Redistributions of source code must retain the above copyright \r
10 #    notice, this list of conditions and the following disclaimer. \r
11 #  * Redistributions in binary form must reproduce the above copyright \r
12 #    notice, this list of conditions and the following disclaimer in the \r
13 #    documentation and/or other materials provided with the \r
14 #    distribution. \r
15 #  * All advertising materials mentioning features or use of this \r
16 #    software must display the following acknowledgement: This product \r
17 #    includes software developed by tm3d.de and its contributors. \r
18 #  * Neither the name of tm3d.de nor the names of its contributors may \r
19 #    be used to endorse or promote products derived from this software \r
20 #    without specific prior written permission. \r
21\r
22 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \r
23 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT \r
24 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR \r
25 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT \r
26 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, \r
27 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT \r
28 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, \r
29 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY \r
30 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT \r
31 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE \r
32 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \r
33 \r
34 execfile("owlib.py")\r
35 \r
36 devlist=owfind("");\r
37 dc=len(devlist)                                 \r
38 if dc==0:\r
39         print "No 1-Wire Device found"\r
40         exit(0)\r
41 i=1\r
42 #for s in devlist:\r
43 #       print("%i) %s" %(i,s))\r
44 #       i=i+1\r
45 #n=int(raw_input("No. of Device: "))\r
46 #n=n-1\r
47 #if (n>dc-1)or(n<0):\r
48 #               exit(0)\r
49 #s=devlist[n]\r
50 devobj=[];\r
51 for s in devlist:\r
52         if (s[0:2]=="28"):\r
53                 dev=owDS18B20(s)\r
54         elif (s[0:2]=="20"):\r
55                 dev=owDS2450(s)\r
56         elif (s[0:2]=="26"):\r
57                 dev=owDS2438(s)\r
58         elif (s[0:2]=="1d"):\r
59                 dev=owDS2423(s)\r
60         else:\r
61                  continue\r
62         dev.readConfig()\r
63         dev.convertAll()\r
64         devobj.append(dev)\r
65 \r
66 str=""\r
67 for dev in devobj:      \r
68         print dev.getChips()\r
69         print dev.getProperties()\r
70         print dev.getUnits()\r
71 \r
72 while (1):\r
73         for dev in devobj:      \r
74                 dev.convertAll()\r
75                 print dev.owid,dev.values\r
76         print \r
77         time.sleep(3)\r
78 \r
79 \r
80 \r
81 #P0=Press/((1-h/44330)**5.255)\r