|
From: <ma...@us...> - 2012-07-13 17:39:55
|
Revision: 918
http://openautomation.svn.sourceforge.net/openautomation/?rev=918&view=rev
Author: makki1
Date: 2012-07-13 17:39:48 +0000 (Fri, 13 Jul 2012)
Log Message:
-----------
Fix encoding of DPT7/8/12/13
Modified Paths:
--------------
CometVisu/trunk/visu/transforms/transform_knx.js
Modified: CometVisu/trunk/visu/transforms/transform_knx.js
===================================================================
--- CometVisu/trunk/visu/transforms/transform_knx.js 2012-07-13 07:54:14 UTC (rev 917)
+++ CometVisu/trunk/visu/transforms/transform_knx.js 2012-07-13 17:39:48 UTC (rev 918)
@@ -142,8 +142,8 @@
'7.001' : {
name : 'DPT_Value_2_Ucount',
encode: function( phy ){
- var val = phy.toString( 16 );
- return (val.length == 1 ? '800' : '80') + val;
+ var val = zeroFillString( parseInt(phy).toString( 16 ), 4);
+ return '80' + val;
},
decode: function( hex ){
return parseInt( hex, 16 );
@@ -156,8 +156,9 @@
'8.001' : {
name : 'DPT_Value_2_Count',
encode: function( phy ){
- var val = phy < 0 ? phy + 65536 : phy;
- return '80' + val.toString( 16 );
+ var val = parseInt ( phy );
+ val = val < 0 ? val + 65536 : val;
+ return '80' + zeroFillString( val.toString( 16 ), 4);
},
decode: function( hex ){
var val = parseInt( hex, 16 );
@@ -254,8 +255,8 @@
'12.001' : {
name : 'DPT_Value_4_Ucount',
encode: function( phy ){
- var val = phy.toString( 16 );
- return (val.length == 1 ? '800' : '80') + val;
+ var val = zeroFillString( parseInt(phy).toString( 16 ), 8);
+ return '80' + val;
},
decode: function( hex ){
return parseInt( hex, 16 );
@@ -268,9 +269,9 @@
'13.001' : {
name : 'DPT_Value_4_Count',
encode: function( phy ){
- var val = phy < 0 ? phy + 4294967296 : phy;
- val = val.toString( 16 );
- return (val.length == 1 ? '800' : '80') + val;
+ var val = parseInt ( phy );
+ val = val < 0 ? val + 4294967296 : val;
+ return '80' + zeroFillString( val.toString( 16 ), 8);
},
decode: function( hex ){
var val = parseInt( hex, 16 );
@@ -284,7 +285,7 @@
'14.001' : {
name : 'DPT_Value_Acceleration_Angular',
encode: function( phy ){
- return '80' + phy;
+ //FIXME: unimplemented (jspack?)
},
decode: function( hex ){
var val = parseInt( hex, 16 );
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|