|
From: <ni...@us...> - 2010-11-11 14:46:00
|
Revision: 106
http://openautomation.svn.sourceforge.net/openautomation/?rev=106&view=rev
Author: nilss1
Date: 2010-11-11 14:45:53 +0000 (Thu, 11 Nov 2010)
Log Message:
-----------
Fixed time and date for val 0 send current
Modified Paths:
--------------
PyWireGate/trunk/knx_connector/DPT_Types.py
Modified: PyWireGate/trunk/knx_connector/DPT_Types.py
===================================================================
--- PyWireGate/trunk/knx_connector/DPT_Types.py 2010-11-11 14:37:02 UTC (rev 105)
+++ PyWireGate/trunk/knx_connector/DPT_Types.py 2010-11-11 14:45:53 UTC (rev 106)
@@ -21,6 +21,7 @@
### sondern als LIST mit den dezimalen Werten ist das decode hier ein bischen angepasst
import struct
+import time
class dpt_type:
def __init__(self,parent):
@@ -325,7 +326,11 @@
if len(timeval) == 3:
sec = int(timeval[2])
elif type(val) in [float, int]:
- now = time.localtime(val)
+ if val == 0:
+ ## current Time
+ now = time.localtime()
+ else:
+ now = time.localtime(val)
weekday = now[6]
hour = now[3]
min = now[4]
@@ -355,12 +360,12 @@
return u"%02d.%02d.%04d" % (day,mon,year)
def encodeDPT11(self,val):
+ ## make time struct accesible
if type(val) in [float, int]:
- tval = val
+ utime = [v for v in time.localtime(tval)]
else:
- tval =0
- ## make time struct accesible
- utime = [v for v in time.localtime(tval)]
+ utime = [v for v in time.localtime()]
+
if type(val) == str:
datestr = val.split(".")
if len(datestr) == 2:
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ni...@us...> - 2010-11-15 21:20:42
|
Revision: 131
http://openautomation.svn.sourceforge.net/openautomation/?rev=131&view=rev
Author: nilss1
Date: 2010-11-15 21:20:31 +0000 (Mon, 15 Nov 2010)
Log Message:
-----------
Fixed weekday
Modified Paths:
--------------
PyWireGate/trunk/knx_connector/DPT_Types.py
Modified: PyWireGate/trunk/knx_connector/DPT_Types.py
===================================================================
--- PyWireGate/trunk/knx_connector/DPT_Types.py 2010-11-15 19:58:41 UTC (rev 130)
+++ PyWireGate/trunk/knx_connector/DPT_Types.py 2010-11-15 21:20:31 UTC (rev 131)
@@ -331,7 +331,7 @@
now = time.localtime()
else:
now = time.localtime(val)
- weekday = now[6]
+ weekday = now[6]+1
hour = now[3]
min = now[4]
sec = now[5]
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ni...@us...> - 2010-11-17 12:08:03
|
Revision: 135
http://openautomation.svn.sourceforge.net/openautomation/?rev=135&view=rev
Author: nilss1
Date: 2010-11-17 12:07:57 +0000 (Wed, 17 Nov 2010)
Log Message:
-----------
Fixed DPT14 as IEEE754 is pythons internal float
Modified Paths:
--------------
PyWireGate/trunk/knx_connector/DPT_Types.py
Modified: PyWireGate/trunk/knx_connector/DPT_Types.py
===================================================================
--- PyWireGate/trunk/knx_connector/DPT_Types.py 2010-11-15 23:09:17 UTC (rev 134)
+++ PyWireGate/trunk/knx_connector/DPT_Types.py 2010-11-17 12:07:57 UTC (rev 135)
@@ -143,6 +143,8 @@
instance = "dpt-types"
if self._parent:
self._parent.log(msg,severity,instance)
+ else:
+ print msg
def toByteArray(self,val,length):
## Set ByteArray
@@ -413,28 +415,16 @@
## S (Sign) = {0,1}
## Exponent = [0 ... 255]
## Fraction = [0 .. 8 388 607]
- val = self.toBigInt(raw)
- sign = (val & 0x80000000) >> 31
- exp = (val & 0x7f8000) >> 23
- mant = val & 0x7fffff
- if sign <> 0:
- mant = -(~(mant - 1) & 0x7fffff)
- self.debug("DPT14: value: %d sign: %d exp: %d mant: %f" % (val, sign,exp,mant))
- return (1 << exp) * 0.01 * mant
+ ##use struct as internal the same
+ if len(raw)==4:
+ ret = struct.unpack(">f","".join([chr(i) for i in raw]))
+ if type(ret) == tuple:
+ ret = ret[0]
+ return ret
def encodeDPT14(self,val):
- sign = 0
- exp = 0
- if val < 0:
- sign = 0x80000000
- mant = val * 100
- while mant > 0x7fffff:
- mant = mant >> 1
- exp +=1
- data = sign | (exp << 23) | (int(mant) & 0x07ff)
- self.debug("DPT14: value: %d sign: %d exp: %d mant: %r" % (val, sign,exp,mant))
- ## change to 4Byte bytearray
- return self.toByteArray(data,4)
+ ## internal the same
+ return [ord(i) for i in struct.pack(">f",float(val))]
def decodeDPT16(self,raw):
res = ""
@@ -507,7 +497,9 @@
if __name__ == "__main__":
dpttypes = dpt_type(False)
- print dpttypes.decode([24,88],dptid=9)
- print dpttypes.decode([1],dptid=1)
- print dpttypes.decode([35,76,58],dptid=16)
- print dpttypes.encode("Das ist",dptid=16)
\ No newline at end of file
+ #print dpttypes.decode([24,88],dptid=9)
+ #print dpttypes.decode([1],dptid=1)
+ #print dpttypes.decode([35,76,58],dptid=16)
+ print dpttypes.encode(15.5,dptid=14)
+ print dpttypes.decode([0, 0, 6, 14],dptid=14)
+ print dpttypes.decode([65, 120, 0, 0],dptid=14)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ni...@us...> - 2010-11-22 14:57:39
|
Revision: 149
http://openautomation.svn.sourceforge.net/openautomation/?rev=149&view=rev
Author: nilss1
Date: 2010-11-22 14:57:33 +0000 (Mon, 22 Nov 2010)
Log Message:
-----------
if something not int is send to DPT1 send its length == 1
Modified Paths:
--------------
PyWireGate/trunk/knx_connector/DPT_Types.py
Modified: PyWireGate/trunk/knx_connector/DPT_Types.py
===================================================================
--- PyWireGate/trunk/knx_connector/DPT_Types.py 2010-11-22 14:56:25 UTC (rev 148)
+++ PyWireGate/trunk/knx_connector/DPT_Types.py 2010-11-22 14:57:33 UTC (rev 149)
@@ -172,7 +172,10 @@
return int(raw[0]) & 0x1
def encodeDPT1(self,val):
- return int(val) & 0x1
+ ## if wrong Type send length of the element so that an empty string or list is 0
+ if type(val) in [str,unicode,list]:
+ val = len(val)
+ return int(val <> 0) & 0x1
def decodeDPT2(self,raw):
## 2 Bit Control
@@ -497,9 +500,6 @@
if __name__ == "__main__":
dpttypes = dpt_type(False)
- #print dpttypes.decode([24,88],dptid=9)
- #print dpttypes.decode([1],dptid=1)
- #print dpttypes.decode([35,76,58],dptid=16)
print dpttypes.encode(15.5,dptid=14)
print dpttypes.decode([0, 0, 6, 14],dptid=14)
print dpttypes.decode([65, 120, 0, 0],dptid=14)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ma...@us...> - 2010-12-09 22:27:19
|
Revision: 189
http://openautomation.svn.sourceforge.net/openautomation/?rev=189&view=rev
Author: makki1
Date: 2010-12-09 22:27:13 +0000 (Thu, 09 Dec 2010)
Log Message:
-----------
Fix DPT9/EIS5 encode-routine in pywiregate
Modified Paths:
--------------
PyWireGate/trunk/knx_connector/DPT_Types.py
Modified: PyWireGate/trunk/knx_connector/DPT_Types.py
===================================================================
--- PyWireGate/trunk/knx_connector/DPT_Types.py 2010-12-09 20:37:27 UTC (rev 188)
+++ PyWireGate/trunk/knx_connector/DPT_Types.py 2010-12-09 22:27:13 UTC (rev 189)
@@ -280,7 +280,7 @@
if val < 0:
sign = 0x8000
mant = val * 100
- while mant > 0x07ff:
+ while (mant > 2047) or (mant < -2048):
mant = mant >> 1
exp +=1
data = sign | (exp << 11) | (int(mant) & 0x07ff)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|