|
From: <j-...@us...> - 2011-05-23 07:05:55
|
Revision: 344
http://openautomation.svn.sourceforge.net/openautomation/?rev=344&view=rev
Author: j-n-k
Date: 2011-05-23 07:05:49 +0000 (Mon, 23 May 2011)
Log Message:
-----------
Added widget "infotrigger"
Modified Paths:
--------------
CometVisu/trunk/visu/designs/pure/basic.css
CometVisu/trunk/visu/designs/structure_pure.js
CometVisu/trunk/visu/visu_config.xsd
CometVisu/trunk/visu/visu_config_demo.xml
Modified: CometVisu/trunk/visu/designs/pure/basic.css
===================================================================
--- CometVisu/trunk/visu/designs/pure/basic.css 2011-05-22 20:06:21 UTC (rev 343)
+++ CometVisu/trunk/visu/designs/pure/basic.css 2011-05-23 07:05:49 UTC (rev 344)
@@ -214,7 +214,30 @@
border-radius: 5px;
}
+.switchInvisible
+{
+ border-style: solid;
+ border-width: 1px;
+ border-color: #000 #000 #000 #000;
+ -moz-border-radius: 7px;
+ -webkit-border-radius: 7px;
+ border-radius: 7px;
+ padding: 1px;
+}
+.switchInvisible div
+{
+ border-style: solid;
+ border-width: 1px;
+ border-color: #000 #000 #000 #000;
+ padding: 5px;
+ width: 5em;
+ float: left;
+ -moz-border-radius: 5px;
+ -webkit-border-radius: 5px;
+ border-radius: 5px;
+}
+
.ui-slider { position: relative; text-align: left; }
.ui-slider .ui-slider-handle { position: absolute; z-index: 2; width: 1.6em; height: 1.6em; cursor: default; }
.ui-slider .ui-slider-range { position: absolute; z-index: 1; font-size: .7em; display: block; border: 0; background-position: 0 0; }
Modified: CometVisu/trunk/visu/designs/structure_pure.js
===================================================================
--- CometVisu/trunk/visu/designs/structure_pure.js 2011-05-22 20:06:21 UTC (rev 343)
+++ CometVisu/trunk/visu/designs/structure_pure.js 2011-05-23 07:05:49 UTC (rev 344)
@@ -623,6 +623,110 @@
content: false
});
+ this.addCreator('infotrigger', {
+ create: function( page, path ) {
+ var $p = $(page);
+ var ret_val = $('<div class="widget switch" />');
+
+ // handle label
+ var labelElement = $p.find('label')[0];
+ var label = labelElement ? '<div class="label">' + labelElement.textContent + '</div>' : '';
+ ret_val.append( label );
+
+ // handle addresses
+ var address = {};
+ var addrread = {};
+ $p.find('address').each( function(){
+ var src = this.textContent;
+ var transform = this.getAttribute('transform');
+ var readonly = this.getAttribute('readonly');
+ ga_list.push( src )
+ if (readonly=='true') {
+ addrread[ '_' + src ] = [ transform, readonly=='true' ];
+ } else {
+ address[ '_' + src ] = [ transform, readonly=='true' ];
+ };
+ });
+
+ // create buttons + info
+ var buttons = $('<div style="float:left;"/>');
+ var buttonCount = 2;
+
+ var actor = '<div class="actor switchUnpressed '
+ if ( $p.attr( 'align' ) )
+ actor += $p.attr( 'align' );
+ actor += '">';
+ actor += '<div class="value">' + ($p.attr('downlabel') ? $p.attr('downlabel') : '-') + '</div>';
+ actor += '</div>';
+ var $actor = $(actor).data( {
+ 'address' : address,
+ 'mapping' : $p.attr('mapping'),
+ 'styling' : $p.attr('styling'),
+ 'value' : $p.attr('downvalue') || 0,
+ 'align' : $p.attr('align'),
+ 'type' : 'switch'
+ } ).bind( 'click', this.action );
+ buttons.append( $actor );
+
+ var actor = '<div class="actor switchUnpressed '
+ if ( $p.attr( 'align' ) )
+ actor += $p.attr( 'align' );
+ actor += '">';
+ actor += '<div class="value">' + ($p.attr('uplabel') ? $p.attr('uplabel') : '+') + '</div>';
+ actor += '</div>';
+ var $actor = $(actor).data( {
+ 'address' : address,
+ 'mapping' : $p.attr('mapping'),
+ 'styling' : $p.attr('styling'),
+ 'value' : $p.attr('upvalue') || 1,
+ 'align' : $p.attr('align'),
+ 'type' : 'switch'
+ } ).bind( 'click', this.action );
+ buttons.append( $actor );
+
+ var actor = '<div class="actor switchInvisible "><div class="value">-</div></div>';
+ var $actor = $(actor).data({
+ 'address' : addrread,
+ 'format' : $p.attr('format'),
+ 'mapping' : $p.attr('mapping'),
+ 'styling' : $p.attr('styling'),
+ });
+ for( var addr in addrread ) $actor.bind( addr, this.update );
+ buttons.append( $actor );
+
+ ret_val.append( buttons );
+ return ret_val;
+ },
+
+ update: function(e,d) {
+ var element = $(this);
+ var value = defaultUpdate( e, d, element );
+ element.addClass('switchInvisible');
+ },
+ action: function() {
+ var data = $(this).data();
+ for( var addr in data.address )
+ {
+ if( data.address[addr][1] == true ) continue; // skip read only
+ visu.write( addr.substr(1), transformEncode( data.address[addr][0], data.value ) );
+ }
+ },
+ attributes: {
+ uplabel: { type: 'string' , required: false },
+ upvalue: { type: 'string' , required: false },
+ downlabel: { type: 'string' , required: false },
+ downvalue: { type: 'string' , required: false },
+ mapping: { type: 'mapping' , required: false },
+ styling: { type: 'styling' , required: false },
+ align: { type: 'string' , required: false }
+ },
+ elements: {
+ label: { type: 'string', required: false, multi: false },
+ address: { type: 'address', required: true, multi: true }
+ },
+ content: false
+ });
+
this.addCreator('unknown', {
create: function( page, path ) {
var ret_val = $('<div class="widget" />');
Modified: CometVisu/trunk/visu/visu_config.xsd
===================================================================
--- CometVisu/trunk/visu/visu_config.xsd 2011-05-22 20:06:21 UTC (rev 343)
+++ CometVisu/trunk/visu/visu_config.xsd 2011-05-23 07:05:49 UTC (rev 344)
@@ -47,9 +47,6 @@
<!-- simple elements -->
<!-- attributes -->
-<xsd:attribute name="pre" type="xsd:string" />
-<xsd:attribute name="post" type="xsd:string" />
-
<xsd:attribute name="min" type="xsd:decimal" />
<xsd:attribute name="max" type="xsd:decimal" />
<xsd:attribute name="step" type="xsd:decimal" />
@@ -169,7 +166,8 @@
<xsd:element name="switch" type="switch" />
<xsd:element name="toggle" type="switch" />
<xsd:element name="trigger" type="trigger" />
- <xsd:element name="multitrigger" type="multitrigger" />
+ <xsd:element name="multitrigger" type="multitrigger" />
+ <xsd:element name="infotrigger" type="infotrigger" />
<xsd:element name="designtoggle" type="designtoggle" />
<xsd:element name="slide" type="slide" />
<xsd:element name="info" type="info" />
@@ -215,9 +213,7 @@
<xsd:attribute ref="mapping" use="optional" />
<xsd:attribute name="on_value" type="xsd:string" use="optional" />
<xsd:attribute name="off_value" type="xsd:string" use="optional" />
- <xsd:attribute ref="pre" use="optional" />
- <xsd:attribute ref="post" use="optional" />
-
+ <xsd:attribute ref="align" use="optional" />
</xsd:complexType>
<xsd:complexType name="trigger">
@@ -228,10 +224,23 @@
<xsd:attribute ref="value" use="required" />
<xsd:attribute ref="mapping" use="optional"/>
<xsd:attribute ref="styling" use="optional"/>
- <xsd:attribute ref="pre" use="optional" />
- <xsd:attribute ref="post" use="optional" />
</xsd:complexType>
+<xsd:complexType name="infotrigger">
+ <xsd:choice maxOccurs="unbounded" minOccurs="1">
+ <xsd:element name="label" type="xsd:string" />
+ <xsd:element name="address" type="address" minOccurs="2" maxOccurs="unbounded"/>
+ </xsd:choice>
+ <xsd:attribute name="upvalue" type="xsd:string" use="optional"/>
+ <xsd:attribute name="downvalue" type="xsd:string" use="optional"/>
+ <xsd:attribute name="uplabel" type="xsd:string" use="optional"/>
+ <xsd:attribute name="downlabel" type="xsd:string" use="optional"/>
+ <xsd:attribute ref="mapping" use="optional"/>
+ <xsd:attribute ref="styling" use="optional"/>
+ <xsd:attribute ref="align" use="optional" />
+ <xsd:attribute ref="format" use="optional" />
+</xsd:complexType>
+
<xsd:complexType name="multitrigger">
<xsd:choice maxOccurs="unbounded" minOccurs="1">
<xsd:element name="label" type="xsd:string" />
@@ -266,8 +275,6 @@
<xsd:element name="label" type="xsd:string" maxOccurs="1" />
<xsd:element name="address" type="address" minOccurs="1"/>
</xsd:choice>
- <xsd:attribute ref="pre" use="optional" />
- <xsd:attribute ref="post" use="optional" />
<xsd:attribute ref="format" use="optional" />
<xsd:attribute ref="styling" use="optional" />
<xsd:attribute ref="mapping" use="optional" />
Modified: CometVisu/trunk/visu/visu_config_demo.xml
===================================================================
--- CometVisu/trunk/visu/visu_config_demo.xml 2011-05-22 20:06:21 UTC (rev 343)
+++ CometVisu/trunk/visu/visu_config_demo.xml 2011-05-23 07:05:49 UTC (rev 344)
@@ -270,5 +270,10 @@
</slide>
<diagram_popup rrd="200_DALI_Linie_1_Strom" unit="mA" series="day" refresh="300">DALI Strom L1</diagram_popup>
<diagram_inline rrd="200_DALI_Linie_1_Strom" width="600" height="400"/>
+ <infotrigger uplabel="wärmer" downlabel="kälter" upvalue="1" downvalue="0" align="center" format="%.1f °C">
+ <label>Temperatur Sollwert</label>
+ <address transform="DPT:1.001">4/1/3</address>
+ <address transform="DPT:9" readonly="true">4/2/3</address>
+ </infotrigger>
</page>
</pages>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|