|
From: <ma...@us...> - 2010-11-28 22:15:39
|
Revision: 174
http://openautomation.svn.sourceforge.net/openautomation/?rev=174&view=rev
Author: mayerch
Date: 2010-11-28 22:15:33 +0000 (Sun, 28 Nov 2010)
Log Message:
-----------
Change camelCase to lowercase to conform to XML spec
Modified Paths:
--------------
CometVisu/trunk/visu/plugins/colorchooser/structure_plugin.js
Modified: CometVisu/trunk/visu/plugins/colorchooser/structure_plugin.js
===================================================================
--- CometVisu/trunk/visu/plugins/colorchooser/structure_plugin.js 2010-11-28 22:02:46 UTC (rev 173)
+++ CometVisu/trunk/visu/plugins/colorchooser/structure_plugin.js 2010-11-28 22:15:33 UTC (rev 174)
@@ -20,7 +20,7 @@
* It's purpose is to change the design of the visu during runtime
* to demonstrate all available
*/
-VisuDesign_Custom.prototype.addCreator("colorChooser", {
+VisuDesign_Custom.prototype.addCreator("colorchooser", {
create: function( page, path ) {
var ret_val = $('<div class="widget" />');
ret_val.addClass( 'colorChooser' );
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ma...@us...> - 2010-11-29 20:46:48
|
Revision: 175
http://openautomation.svn.sourceforge.net/openautomation/?rev=175&view=rev
Author: mayerch
Date: 2010-11-29 20:46:42 +0000 (Mon, 29 Nov 2010)
Log Message:
-----------
Change forgotten camelCase to lowercase to conform to XML spec
Modified Paths:
--------------
CometVisu/trunk/visu/plugins/colorchooser/structure_plugin.js
Modified: CometVisu/trunk/visu/plugins/colorchooser/structure_plugin.js
===================================================================
--- CometVisu/trunk/visu/plugins/colorchooser/structure_plugin.js 2010-11-28 22:15:33 UTC (rev 174)
+++ CometVisu/trunk/visu/plugins/colorchooser/structure_plugin.js 2010-11-29 20:46:42 UTC (rev 175)
@@ -60,6 +60,6 @@
/**
* Include the needed stuff
*/
-$( 'head' ).append( '<script type="text/javascript" src="plugins/colorChooser/farbtastic/farbtastic.js"></script>' );
-$( 'head' ).append( '<link rel="stylesheet" href="plugins/colorChooser/farbtastic/farbtastic.css" type="text/css" />' );
+$( 'head' ).append( '<script type="text/javascript" src="plugins/colorchooser/farbtastic/farbtastic.js"></script>' );
+$( 'head' ).append( '<link rel="stylesheet" href="plugins/colorchooser/farbtastic/farbtastic.css" type="text/css" />' );
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ma...@us...> - 2010-12-11 23:58:28
|
Revision: 202
http://openautomation.svn.sourceforge.net/openautomation/?rev=202&view=rev
Author: mayerch
Date: 2010-12-11 23:58:22 +0000 (Sat, 11 Dec 2010)
Log Message:
-----------
Updated to the new message passing / event infrastructure. This allows the colorChooser to be remote controlled - and correctly initialized.
Note: do to rounding problems the colors might drift to a stable value.
This is a known problem and will be fixed by the move to transfer functions instad of datatypes.
Modified Paths:
--------------
CometVisu/trunk/visu/plugins/colorchooser/structure_plugin.js
Modified: CometVisu/trunk/visu/plugins/colorchooser/structure_plugin.js
===================================================================
--- CometVisu/trunk/visu/plugins/colorchooser/structure_plugin.js 2010-12-11 23:03:44 UTC (rev 201)
+++ CometVisu/trunk/visu/plugins/colorchooser/structure_plugin.js 2010-12-11 23:58:22 UTC (rev 202)
@@ -27,27 +27,64 @@
var label = '<div class="label">' + page.textContent + '</div>';
var actor = '<div class="actor">';
actor += '</div>';
+ var a_r = $(page).attr('address_r');
+ var a_g = $(page).attr('address_g');
+ var a_b = $(page).attr('address_b');
+ var datatype = $(page).attr('datatype');
ret_val.append(label)
.append($(actor)
.data({
- 'mapping' : $(page).attr('mapping'),
- 'styling' : $(page).attr('styling'),
- 'type' : 'toggle'
+ //'mapping' : $(page).attr('mapping'),
+ //'styling' : $(page).attr('styling'),
+ 'datatype': datatype, //jQuery(page).attr('datatype'), // use jQuery as '$' dosn't work here?!?
+ 'value_r' : 0,
+ 'value_g' : 0,
+ 'value_b' : 0,
+ 'type' : 'colorChooser'
})
.farbtastic( function(color){
var r = parseInt(color.substring(1, 3), 16) * 100 / 255;
var g = parseInt(color.substring(3, 5), 16) * 100 / 255;
var b = parseInt(color.substring(5, 7), 16) * 100 / 255;
- var a_r = $(page).attr('address_r');
- var a_g = $(page).attr('address_g');
- var a_b = $(page).attr('address_b');
- var datatype = $(page).attr('datatype');
visu.write( a_r, r, datatype );
visu.write( a_g, g, datatype );
visu.write( a_b, b, datatype );
- })) ;
+ })
+ .bind('_'+$(page).attr('address_r'), this.update_r )
+ .bind('_'+$(page).attr('address_g'), this.update_g )
+ .bind('_'+$(page).attr('address_b'), this.update_b ) );
return ret_val;
},
+ update_r: function(e,d) {
+ var element = $(this);
+ var value = decodeDPT( d, element.data('datatype') );
+ element.data( 'value_r', value );
+ function toHex( x ) { var r = parseInt( x ).toString(16); return r.length == 1 ? '0'+r : r; }
+ var color = toHex( element.data( 'value_r' )*255/100 )
+ + toHex( element.data( 'value_g' )*255/100 )
+ + toHex( element.data( 'value_b' )*255/100 );
+ jQuery.farbtastic( element ).setColor( '#' + color );
+ },
+ update_g: function(e,d) {
+ var element = $(this);
+ var value = decodeDPT( d, element.data('datatype') );
+ element.data( 'value_g', value );
+ function toHex( x ) { var r = parseInt( x ).toString(16); return r.length == 1 ? '0'+r : r; }
+ var color = toHex( element.data( 'value_r' )*255/100 )
+ + toHex( element.data( 'value_g' )*255/100 )
+ + toHex( element.data( 'value_b' )*255/100 );
+ jQuery.farbtastic( element ).setColor( '#' + color );
+ },
+ update_b: function(e,d) {
+ var element = $(this);
+ var value = decodeDPT( d, element.data('datatype') );
+ element.data( 'value_b', value );
+ function toHex( x ) { var r = parseInt( x ).toString(16); return r.length == 1 ? '0'+r : r; }
+ var color = toHex( element.data( 'value_r' )*255/100 )
+ + toHex( element.data( 'value_g' )*255/100 )
+ + toHex( element.data( 'value_b' )*255/100 );
+ jQuery.farbtastic( element ).setColor( '#' + color );
+ },
attributes: {
address_r: {type: "address", required: true},
address_g: {type: "address", required: true},
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ma...@us...> - 2010-12-28 22:08:04
|
Revision: 236
http://openautomation.svn.sourceforge.net/openautomation/?rev=236&view=rev
Author: mayerch
Date: 2010-12-28 22:07:57 +0000 (Tue, 28 Dec 2010)
Log Message:
-----------
Make colorChooser much more smooth (and avoid sending of lots of (outdated) values)
Modified Paths:
--------------
CometVisu/trunk/visu/plugins/colorchooser/structure_plugin.js
Modified: CometVisu/trunk/visu/plugins/colorchooser/structure_plugin.js
===================================================================
--- CometVisu/trunk/visu/plugins/colorchooser/structure_plugin.js 2010-12-28 20:10:44 UTC (rev 235)
+++ CometVisu/trunk/visu/plugins/colorchooser/structure_plugin.js 2010-12-28 22:07:57 UTC (rev 236)
@@ -48,27 +48,36 @@
'value_g' : 0,
'value_b' : 0,
'type' : 'colorChooser'
- })
- .farbtastic( function(color){
+ });
+ $actor.farbtastic( function(color){
var r = parseInt(color.substring(1, 3), 16) * 100 / 255.0;
var g = parseInt(color.substring(3, 5), 16) * 100 / 255.0;
var b = parseInt(color.substring(5, 7), 16) * 100 / 255.0;
+ var vr = $actor.data('value_r');
+ var vg = $actor.data('value_g');
+ var vb = $actor.data('value_b');
+ $actor.data( 'value_r', vr );
+ $actor.data( 'value_g', vg );
+ $actor.data( 'value_b', vb );
for( var addr in address )
{
if( address[addr][2] == true ) continue; // skip read only
switch( address[addr][1] )
{
case 'r':
- //visu.write( addr.substr(1), r, address[addr][0].substr(4) );
- visu.write( addr.substr(1), Transform[address[addr][0]].encode( r ) );
+ var v = Transform[address[addr][0]].encode( r );
+ if( v != Transform[address[addr][0]].encode( vr ) )
+ visu.write( addr.substr(1), v );
break;
case 'g':
- //visu.write( addr.substr(1), g, address[addr][0].substr(4) );
- visu.write( addr.substr(1), Transform[address[addr][0]].encode( g ) );
+ var v = Transform[address[addr][0]].encode( g );
+ if( v != Transform[address[addr][0]].encode( vg ) )
+ visu.write( addr.substr(1), v );
break;
case 'b':
- //visu.write( addr.substr(1), b, address[addr][0].substr(4) );
- visu.write( addr.substr(1), Transform[address[addr][0]].encode( b ) );
+ var v = Transform[address[addr][0]].encode( b );
+ if( v != Transform[address[addr][0]].encode( vb ) )
+ visu.write( addr.substr(1), v );
break;
}
}
@@ -95,30 +104,33 @@
var value = transform( data, element.data().address[ e.type ][0] );
element.data( 'value_r', value );
function toHex( x ) { var r = parseInt( x ).toString(16); return r.length == 1 ? '0'+r : r; }
- var color = toHex( element.data( 'value_r' )*255/100 )
- + toHex( element.data( 'value_g' )*255/100 )
- + toHex( element.data( 'value_b' )*255/100 );
- jQuery.farbtastic( element ).setColor( '#' + color );
+ var color = jQuery.farbtastic( element ).color || '#000000';
+ color = color.substring(0,1) +
+ toHex( value*255/100 )+
+ color.substring(3);
+ jQuery.farbtastic( element ).setColor( color );
},
update_g: function( e, data ) {
var element = $(this);
var value = transform( data, element.data().address[ e.type ][0] );
element.data( 'value_g', value );
function toHex( x ) { var r = parseInt( x ).toString(16); return r.length == 1 ? '0'+r : r; }
- var color = toHex( element.data( 'value_r' )*255/100 )
- + toHex( element.data( 'value_g' )*255/100 )
- + toHex( element.data( 'value_b' )*255/100 );
- jQuery.farbtastic( element ).setColor( '#' + color );
+ var color = jQuery.farbtastic( element ).color || '#000000';
+ color = color.substring(0,3) +
+ toHex( value*255/100 )+
+ color.substring(5);
+ jQuery.farbtastic( element ).setColor( color );
},
update_b: function( e, data ) {
var element = $(this);
var value = transform( data, element.data().address[ e.type ][0] );
element.data( 'value_b', value );
function toHex( x ) { var r = parseInt( x ).toString(16); return r.length == 1 ? '0'+r : r; }
- var color = toHex( element.data( 'value_r' )*255/100 )
- + toHex( element.data( 'value_g' )*255/100 )
- + toHex( element.data( 'value_b' )*255/100 );
- jQuery.farbtastic( element ).setColor( '#' + color );
+ var color = jQuery.farbtastic( element ).color || '#000000';
+ color = color.substring(0,5) +
+ toHex( value*255/100 )+
+ color.substring(7);
+ jQuery.farbtastic( element ).setColor( color );
},
attributes: {
address_r: { type: 'address' , required: true },
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ma...@us...> - 2011-01-01 16:21:47
|
Revision: 240
http://openautomation.svn.sourceforge.net/openautomation/?rev=240&view=rev
Author: mayerch
Date: 2011-01-01 16:21:41 +0000 (Sat, 01 Jan 2011)
Log Message:
-----------
Added rate limiter (set to 250 ms) to the colorChooser
Modified Paths:
--------------
CometVisu/trunk/visu/plugins/colorchooser/structure_plugin.js
Modified: CometVisu/trunk/visu/plugins/colorchooser/structure_plugin.js
===================================================================
--- CometVisu/trunk/visu/plugins/colorchooser/structure_plugin.js 2011-01-01 15:20:35 UTC (rev 239)
+++ CometVisu/trunk/visu/plugins/colorchooser/structure_plugin.js 2011-01-01 16:21:41 UTC (rev 240)
@@ -44,43 +44,73 @@
var $actor = $(actor)
.data({
'address' : address,
- 'value_r' : 0,
- 'value_g' : 0,
- 'value_b' : 0,
+ 'value_r' : 0, // The currenty displayed value
+ 'value_g' : 0, // The currenty displayed value
+ 'value_b' : 0, // The currenty displayed value
+ 'bus_r' : 0, // The current value on the bus
+ 'bus_g' : 0, // The current value on the bus
+ 'bus_b' : 0, // The current value on the bus
+ 'rateLimiter' : false, // is the rate limiter active?
'type' : 'colorChooser'
});
$actor.farbtastic( function(color){
- var r = parseInt(color.substring(1, 3), 16) * 100 / 255.0;
- var g = parseInt(color.substring(3, 5), 16) * 100 / 255.0;
- var b = parseInt(color.substring(5, 7), 16) * 100 / 255.0;
- var vr = $actor.data('value_r');
- var vg = $actor.data('value_g');
- var vb = $actor.data('value_b');
- $actor.data( 'value_r', vr );
- $actor.data( 'value_g', vg );
- $actor.data( 'value_b', vb );
- for( var addr in address )
- {
- if( address[addr][2] == true ) continue; // skip read only
- switch( address[addr][1] )
+ $actor.data( 'value_r', parseInt(color.substring(1, 3), 16) * 100 / 255.0 );
+ $actor.data( 'value_g', parseInt(color.substring(3, 5), 16) * 100 / 255.0 );
+ $actor.data( 'value_b', parseInt(color.substring(5, 7), 16) * 100 / 255.0 );
+ function rateLimitedSend( a ) {
+ var modified = false;
+ var address = a.data( 'address' );
+ var r = a.data( 'value_r' );
+ var g = a.data( 'value_g' );
+ var b = a.data( 'value_b' );
+ var br = a.data( 'bus_r' );
+ var bg = a.data( 'bus_g' );
+ var bb = a.data( 'bus_b' );
+ for( var addr in address )
{
- case 'r':
- var v = Transform[address[addr][0]].encode( r );
- if( v != Transform[address[addr][0]].encode( vr ) )
- visu.write( addr.substr(1), v );
- break;
- case 'g':
- var v = Transform[address[addr][0]].encode( g );
- if( v != Transform[address[addr][0]].encode( vg ) )
- visu.write( addr.substr(1), v );
- break;
- case 'b':
- var v = Transform[address[addr][0]].encode( b );
- if( v != Transform[address[addr][0]].encode( vb ) )
- visu.write( addr.substr(1), v );
- break;
+ if( address[addr][2] == true ) continue; // skip read only
+ switch( address[addr][1] )
+ {
+ case 'r':
+ var v = Transform[address[addr][0]].encode( r );
+ if( v != Transform[address[addr][0]].encode( br ) )
+ {
+ visu.write( addr.substr(1), v );
+ modified = true;
+ }
+ break;
+ case 'g':
+ var v = Transform[address[addr][0]].encode( g );
+ if( v != Transform[address[addr][0]].encode( bg ) )
+ {
+ visu.write( addr.substr(1), v );
+ modified = true;
+ }
+ break;
+ case 'b':
+ var v = Transform[address[addr][0]].encode( b );
+ if( v != Transform[address[addr][0]].encode( bb ) )
+ {
+ visu.write( addr.substr(1), v );
+ modified = true;
+ }
+ break;
+ }
}
+
+ if( modified )
+ {
+ a.data( 'bus_r', a.data( 'value_r' ) );
+ a.data( 'bus_g', a.data( 'value_g' ) );
+ a.data( 'bus_b', a.data( 'value_b' ) );
+ a.data( 'rateLimiter', true );
+ setTimeout( function(){rateLimitedSend( a );}, 250 ); // next call in 250ms
+ } else {
+ a.data( 'rateLimiter', false );
+ }
}
+ if( $actor.data( 'rateLimiter' ) == false ) // already requests going?
+ rateLimitedSend( $actor );
});
for( var addr in address ) {
switch( address[addr][1] ) {
@@ -102,7 +132,7 @@
update_r: function( e, data ) {
var element = $(this);
var value = Transform[ element.data().address[ e.type ][0] ].decode( data );
- element.data( 'value_r', value );
+ element.data( 'bus_r', value );
function toHex( x ) { var r = parseInt( x ).toString(16); return r.length == 1 ? '0'+r : r; }
var color = jQuery.farbtastic( element ).color || '#000000';
color = color.substring(0,1) +
@@ -113,7 +143,7 @@
update_g: function( e, data ) {
var element = $(this);
var value = Transform[ element.data().address[ e.type ][0] ].decode( data );
- element.data( 'value_g', value );
+ element.data( 'bus_g', value );
function toHex( x ) { var r = parseInt( x ).toString(16); return r.length == 1 ? '0'+r : r; }
var color = jQuery.farbtastic( element ).color || '#000000';
color = color.substring(0,3) +
@@ -124,7 +154,7 @@
update_b: function( e, data ) {
var element = $(this);
var value = Transform[ element.data().address[ e.type ][0] ].decode( data );
- element.data( 'value_b', value );
+ element.data( 'bus_b', value );
function toHex( x ) { var r = parseInt( x ).toString(16); return r.length == 1 ? '0'+r : r; }
var color = jQuery.farbtastic( element ).color || '#000000';
color = color.substring(0,5) +
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ma...@us...> - 2011-06-05 16:50:28
|
Revision: 355
http://openautomation.svn.sourceforge.net/openautomation/?rev=355&view=rev
Author: mayerch
Date: 2011-06-05 16:50:22 +0000 (Sun, 05 Jun 2011)
Log Message:
-----------
Styling...
Modified Paths:
--------------
CometVisu/trunk/visu/plugins/colorchooser/structure_plugin.js
Modified: CometVisu/trunk/visu/plugins/colorchooser/structure_plugin.js
===================================================================
--- CometVisu/trunk/visu/plugins/colorchooser/structure_plugin.js 2011-06-05 16:48:00 UTC (rev 354)
+++ CometVisu/trunk/visu/plugins/colorchooser/structure_plugin.js 2011-06-05 16:50:22 UTC (rev 355)
@@ -32,7 +32,7 @@
$p.find('address').each( function(){
var src = this.textContent;
var transform = this.getAttribute('transform');
- var color = this.getAttribute('variant' );
+ var color = this.getAttribute('variant' );
var readonly = this.getAttribute('readonly' );
ga_list.push( src );
address[ '_' + src ] = [ transform, color, readonly=='true' ];
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|