You can subscribe to this list here.
| 2010 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(1) |
Nov
(121) |
Dec
(58) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2011 |
Jan
(38) |
Feb
(36) |
Mar
(7) |
Apr
(2) |
May
(32) |
Jun
(24) |
Jul
(16) |
Aug
(21) |
Sep
(17) |
Oct
(62) |
Nov
(60) |
Dec
(70) |
| 2012 |
Jan
(54) |
Feb
(41) |
Mar
(21) |
Apr
(38) |
May
(76) |
Jun
(47) |
Jul
(25) |
Aug
(72) |
Sep
(29) |
Oct
(64) |
Nov
(93) |
Dec
(97) |
| 2013 |
Jan
(100) |
Feb
(168) |
Mar
(115) |
Apr
(59) |
May
(37) |
Jun
(32) |
Jul
(45) |
Aug
(42) |
Sep
(24) |
Oct
(73) |
Nov
(64) |
Dec
(4) |
| 2014 |
Jan
(14) |
Feb
(57) |
Mar
(58) |
Apr
(10) |
May
(18) |
Jun
(12) |
Jul
(7) |
Aug
(12) |
Sep
(15) |
Oct
(6) |
Nov
(32) |
Dec
(17) |
| 2015 |
Jan
(50) |
Feb
(5) |
Mar
(1) |
Apr
(26) |
May
(10) |
Jun
(3) |
Jul
(3) |
Aug
(2) |
Sep
(3) |
Oct
(18) |
Nov
(18) |
Dec
(8) |
| 2016 |
Jan
(33) |
Feb
(35) |
Mar
(50) |
Apr
(20) |
May
(25) |
Jun
(17) |
Jul
(8) |
Aug
(73) |
Sep
(64) |
Oct
(51) |
Nov
(20) |
Dec
(14) |
| 2017 |
Jan
(41) |
Feb
(57) |
Mar
(44) |
Apr
(136) |
May
(32) |
Jun
(39) |
Jul
(2) |
Aug
(12) |
Sep
(32) |
Oct
(103) |
Nov
(12) |
Dec
(4) |
| 2018 |
Jan
(9) |
Feb
(1) |
Mar
(60) |
Apr
(24) |
May
(15) |
Jun
(1) |
Jul
(2) |
Aug
(23) |
Sep
(15) |
Oct
(57) |
Nov
(21) |
Dec
(77) |
| 2019 |
Jan
(62) |
Feb
(99) |
Mar
(98) |
Apr
(49) |
May
(6) |
Jun
(3) |
Jul
(6) |
Aug
(18) |
Sep
(9) |
Oct
(15) |
Nov
(30) |
Dec
(6) |
| 2020 |
Jan
(14) |
Feb
(2) |
Mar
(22) |
Apr
(33) |
May
(47) |
Jun
(12) |
Jul
|
Aug
|
Sep
(4) |
Oct
(2) |
Nov
(5) |
Dec
(5) |
| 2021 |
Jan
(4) |
Feb
(101) |
Mar
(13) |
Apr
(32) |
May
(40) |
Jun
|
Jul
(3) |
Aug
|
Sep
|
Oct
(25) |
Nov
(12) |
Dec
|
| 2022 |
Jan
(154) |
Feb
(82) |
Mar
(63) |
Apr
(27) |
May
(26) |
Jun
(5) |
Jul
(12) |
Aug
(23) |
Sep
(17) |
Oct
(37) |
Nov
(13) |
Dec
(21) |
| 2023 |
Jan
(43) |
Feb
(43) |
Mar
(15) |
Apr
(8) |
May
(3) |
Jun
(25) |
Jul
(6) |
Aug
(38) |
Sep
(5) |
Oct
(20) |
Nov
(9) |
Dec
(28) |
| 2024 |
Jan
(15) |
Feb
(2) |
Mar
(12) |
Apr
(2) |
May
(8) |
Jun
(10) |
Jul
(10) |
Aug
(2) |
Sep
(3) |
Oct
(15) |
Nov
(6) |
Dec
(20) |
| 2025 |
Jan
|
Feb
(2) |
Mar
(6) |
Apr
(2) |
May
(2) |
Jun
|
Jul
|
Aug
(1) |
Sep
(1) |
Oct
(11) |
Nov
(2) |
Dec
|
|
From: <ma...@us...> - 2012-03-18 16:01:56
|
Revision: 730
http://openautomation.svn.sourceforge.net/openautomation/?rev=730&view=rev
Author: mayerch
Date: 2012-03-18 16:01:50 +0000 (Sun, 18 Mar 2012)
Log Message:
-----------
Move to room / floor in 3d when clicked.
Modified Paths:
--------------
CometVisu/trunk/visu/designs/structure_pure.js
Modified: CometVisu/trunk/visu/designs/structure_pure.js
===================================================================
--- CometVisu/trunk/visu/designs/structure_pure.js 2012-03-17 23:38:56 UTC (rev 729)
+++ CometVisu/trunk/visu/designs/structure_pure.js 2012-03-18 16:01:50 UTC (rev 730)
@@ -161,9 +161,10 @@
}
var childs = $p.children();
- var container = $( '<div class="clearfix" />' );
+ //var container = $( '<div class="clearfix" />' );
- var $container = $( '<div class="clearfix" path="'+path+'"/>');
+ var subpage = $( '<div class="page" id="' + path + '" style="'+pstyle+';"/>' );
+ var $container = $( '<div class="clearfix" path="'+path+'" style="height:100%;position:relative;" />');
for( var addr in address ) $container.bind( addr, this.update );
var container=$container;
@@ -177,6 +178,12 @@
floorplan.moveToRoom( 'Underground', false, true, false );
container.data( 'JSFloorPlan3D', floorplan );
container.find('canvas').css({position: 'absolute', top: '0px', left: '0px', 'z-index':'-1', width:'100%',height:'100%'});
+ subpage.click( {JSFloorPlan3D:floorplan,callback:function(event){
+ var j = this.JSFloorPlan3D;
+ j.moveToRoom( j.getState('showFloor'), event.room.room, true, true, function(){
+ container.trigger( 'update3d', j );
+ });
+ }}, floorplan.translateMouseEvent );
$(window).bind( 'resize', function(){ floorplan.resize($('.page').width(), $('.page').height(), true);} );
if ($p.attr('azimut')) {
ga_list.push($p.attr('azimut'));
@@ -198,7 +205,6 @@
$( childs ).each( function(i){
container.append( create_pages( childs[i], path + '_' + i, flavour, type ) );
} );
- var subpage = $( '<div class="page" id="' + path + '" style="'+pstyle+';"/>' );
subpage.append(container);
if( flavour ) subpage.addClass( 'flavour_' + flavour );
$('#pages').prepend( subpage );
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ma...@us...> - 2012-03-17 23:39:03
|
Revision: 729
http://openautomation.svn.sourceforge.net/openautomation/?rev=729&view=rev
Author: mayerch
Date: 2012-03-17 23:38:56 +0000 (Sat, 17 Mar 2012)
Log Message:
-----------
Add initial support for widgets in 3d space (currently: only the info widget)
Modified Paths:
--------------
CometVisu/trunk/visu/designs/structure_pure.js
CometVisu/trunk/visu/lib/templateengine.js
CometVisu/trunk/visu/visu_config_2d3d.xml
JSFloorPlan/trunk/src/jsfloorplan.js
Modified: CometVisu/trunk/visu/designs/structure_pure.js
===================================================================
--- CometVisu/trunk/visu/designs/structure_pure.js 2012-03-11 21:52:15 UTC (rev 728)
+++ CometVisu/trunk/visu/designs/structure_pure.js 2012-03-17 23:38:56 UTC (rev 729)
@@ -196,7 +196,7 @@
container.data( 'address', address );
}
$( childs ).each( function(i){
- container.append( create_pages( childs[i], path + '_' + i, flavour ) );
+ container.append( create_pages( childs[i], path + '_' + i, flavour, type ) );
} );
var subpage = $( '<div class="page" id="' + path + '" style="'+pstyle+';"/>' );
subpage.append(container);
@@ -228,14 +228,18 @@
{
case 'azimut':
element.data().JSFloorPlan3D.setState('currentAzimut', value, true);
+ element.trigger( 'update3d', element.data().JSFloorPlan3D );
break;
case 'elevation':
element.data().JSFloorPlan3D.setState('currentElevation', value, true);
+ element.trigger( 'update3d', element.data().JSFloorPlan3D );
break;
case 'floor':
- element.data().JSFloorPlan3D.moveToRoom( value, false, true, true );
+ element.data().JSFloorPlan3D.moveToRoom( value, false, true, true, function(){
+ element.trigger( 'update3d', element.data().JSFloorPlan3D );
+ });
break;
default:
@@ -346,26 +350,30 @@
});
this.addCreator('info', {
- create: function( page, path ) {
- var $p = $(page);
- var layout = $p.find('layout')[0];
+ create: function( element, path, flavour, type ) {
+ var $e = $(element);
+ var layout = $e.find('layout')[0];
var style = layout ? 'style="' + extractLayout( layout ) + '"' : '';
var ret_val = $('<div class="widget clearfix info" ' + style + ' />');
- ret_val.setWidgetLayout($p).makeWidgetLabel($p);
- var address = makeAddressList($p);
+ //type == '3d' && ret_val.data( extractLayout3d( layout ) ).bind( 'update3d', this.update3d );
+ type == '3d' && $(document).bind( 'update3d', {element: ret_val, layout: extractLayout3d( layout )}, this.update3d );
+ ret_val.setWidgetLayout($e).makeWidgetLabel($e);
+ var address = makeAddressList($e);
+
var actor = '<div class="actor"><div class="value">-</div></div>';
var $actor = $(actor).data({
'address' : address,
- 'format' : $p.attr('format'),
- 'mapping' : $p.attr('mapping'),
- 'styling' : $p.attr('styling')
+ 'format' : $e.attr('format'),
+ 'mapping' : $e.attr('mapping'),
+ 'styling' : $e.attr('styling')
});
for( var addr in address ) $actor.bind( addr, this.update );
ret_val.append( $actor );
return ret_val;
},
update: defaultUpdate,
+ update3d: defaultUpdate3d,
attributes: {
format: { type: 'format', required: false },
mapping: { type: 'mapping', required: false },
@@ -1400,6 +1408,16 @@
return value;
}
+function defaultUpdate3d( e, data, passedElement )
+{
+ //var element = passedElement || $(this);
+ var l = e.data.layout;
+ var pos = data.building2screen( new THREE.Vector3( l.x, l.y, l.z ) );
+ e.data.element.css( 'left', pos.x + 'px' );
+ e.data.element.css( 'top' , pos.y + 'px' );
+ //console.log( e, data, e.data, pos.x, pos.y );
+}
+
function extractLayout( layout )
{
var ret_val = 'position:absolute;';
@@ -1409,3 +1427,12 @@
return ret_val;
}
+function extractLayout3d( layout )
+{
+ var ret_val = {};
+ if( layout.getAttribute('x' ) ) ret_val.x = layout.getAttribute('x' );
+ if( layout.getAttribute('y' ) ) ret_val.y = layout.getAttribute('y' );
+ if( layout.getAttribute('z' ) ) ret_val.z = layout.getAttribute('z' );
+ if( layout.getAttribute('floor') ) ret_val.floor = layout.getAttribute('floor');
+ return ret_val;
+}
\ No newline at end of file
Modified: CometVisu/trunk/visu/lib/templateengine.js
===================================================================
--- CometVisu/trunk/visu/lib/templateengine.js 2012-03-11 21:52:15 UTC (rev 728)
+++ CometVisu/trunk/visu/lib/templateengine.js 2012-03-17 23:38:56 UTC (rev 729)
@@ -341,10 +341,10 @@
$("#pages").triggerHandler("done");
}
-function create_pages( page, path, flavour ) {
+function create_pages( page, path, flavour, type ) {
var creator = design.getCreator(page.nodeName);
- var retval = creator.create(page, path, flavour);
+ var retval = creator.create(page, path, flavour, type);
node = $(page).get(0);
var attributes = {};
Modified: CometVisu/trunk/visu/visu_config_2d3d.xml
===================================================================
--- CometVisu/trunk/visu/visu_config_2d3d.xml 2012-03-11 21:52:15 UTC (rev 728)
+++ CometVisu/trunk/visu/visu_config_2d3d.xml 2012-03-17 23:38:56 UTC (rev 729)
@@ -79,6 +79,10 @@
</info>
</page>
<page name="3D Demo" type="3d" backdrop="floorplan_demo.xml" azimut="12/7/53" elevation="12/7/54" floor="12/7/51">
+ <info format="%.2f">
+ <layout x="3.5" y="3.7" z="1.0"/>
+ <address transform="DPT:5.001" type="">12/7/53</address>
+ </info>
<slide min="0" max="6.283185307179586">
<layout x="0px" y="570px" width="600px" />
<label>Azimut</label>
Modified: JSFloorPlan/trunk/src/jsfloorplan.js
===================================================================
--- JSFloorPlan/trunk/src/jsfloorplan.js 2012-03-11 21:52:15 UTC (rev 728)
+++ JSFloorPlan/trunk/src/jsfloorplan.js 2012-03-17 23:38:56 UTC (rev 729)
@@ -1351,7 +1351,7 @@
* @param {Room} room
* @return {THREE.Vector3} Target
*/
- this.moveToRoom = function( floor, room, hideOtherFloors, animate )
+ this.moveToRoom = function( floor, room, hideOtherFloors, animate, callback )
{
var target = new THREE.Vector3();
var dist;
@@ -1391,6 +1391,7 @@
for( ; f >= 0; f-- ) self.hideFloor( f, f == floor );
}
self.render();
+ if( callback !== undefined ) callback();
}, animate );
showStates.showFloor = floor;
return target;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ma...@us...> - 2012-03-11 21:52:26
|
Revision: 728
http://openautomation.svn.sourceforge.net/openautomation/?rev=728&view=rev
Author: mayerch
Date: 2012-03-11 21:52:15 +0000 (Sun, 11 Mar 2012)
Log Message:
-----------
Update of the inline documentation
Modified Paths:
--------------
JSFloorPlan/trunk/src/jsfloorplan.js
Modified: JSFloorPlan/trunk/src/jsfloorplan.js
===================================================================
--- JSFloorPlan/trunk/src/jsfloorplan.js 2012-03-11 20:11:16 UTC (rev 727)
+++ JSFloorPlan/trunk/src/jsfloorplan.js 2012-03-11 21:52:15 UTC (rev 728)
@@ -22,7 +22,7 @@
//////////////////////////////////////////////////////////////////////////////
/**
- * The JSFLOORPLAN3D object is the single global object created by the
+ * The JSFloorPlan3D object is the single global object created by the
* JSFloorPlan 3D library.
* <p/>
* The definition of the config file is:
@@ -136,26 +136,25 @@
* @reqires jQuery, Three.js
*/
-/**
- * @class JSFLOORPLAN3D
- * @constructor FOO
- */
(function( window, undefined ){
////////////////////////////////////////////////////////////////////////////
// private static variables and methods:
- /**
- * Constant representing the ID of an ELEMENT_NODE
- * @property ELEMENT_NODE
- * @private
- * @static
- * @final
- * @type Enum
- */
+ // Constant representing the ID of an ELEMENT_NODE
var ELEMENT_NODE = 1;
////////////////////////////////////////////////////////////////////////////
// the library
+
+ /**
+ * The object JSFloorPlan3D contains the whole API necessary to handle a
+ * 3D floorplan.
+ * @class JSFloorPlan3D
+ * @constructor FOO
+ * @param {DOMElement} container The DOM element where floorplan will be
+ * inserted
+ * @param {URL} floorPlan The URL of the floorplan to show
+ */
var JSFloorPlan3D = function( container, floorPlan ){
// check and fix if the user forgot the "new" keyword
if (!(this instanceof JSFloorPlan3D))
@@ -163,6 +162,11 @@
return new JSFloorPlan3D( container, floorPlan );
}
+ /**
+ * Private pointer to <i>this</i>
+ * @property self
+ * @private
+ */
var self = this;
/*
@@ -172,7 +176,10 @@
}
*/
- // public variables of this object instance
+ /**
+ * public variables of this object instance
+ * @property buildingProperties
+ */
this.buildingProperties = { floor: [], Object3D: new THREE.Object3D(), floorNames:{} };
// private variables of this object instance will follow
@@ -196,6 +203,8 @@
/**
* Set states that define how the floor plan is drawn
+ * @property showStates
+ * @private
*/
var showStates = {
currentAzimut: 1, // North up
@@ -273,6 +282,7 @@
* @private
* @param {Point} start
* @param {Point} end
+ * @return {Number}
*/
function calcLength2D( start, end )
{
@@ -756,10 +766,7 @@
$.ajax({
url: url,
context: self,
- success: function( xmlDoc ){
- parseXMLFloorPlan( xmlDoc );
-
- },
+ success: function( xmlDoc ){ parseXMLFloorPlan( xmlDoc ); },
dataType: 'xml',
async: false
});
@@ -826,7 +833,7 @@
/**
* Contain all informations known about a wall.
* @class wall
- * @for JSFLOORPLAN3D
+ * @for JSFloorPlan3D
*/
var wall = new Object;
/**
@@ -898,7 +905,7 @@
* Fill the <code>rooms</code> array with the room elements from the
* config file.
* @method parseFloorRooms
- * @for JSFLOORPLAN3D
+ * @for JSFloorPlan3D
* @private
* @param {XMLDom} nodeGroup
* @param {Integer} floor The floor number.
@@ -956,7 +963,6 @@
}
}
- //var textures = new Object();
/**
* Dummy routine to handle textures.
* @method parseTextures
@@ -965,7 +971,7 @@
*/
var parseTextures = function( nodes )
{
- return;
+ return; // FIXME - this is currently a dummy...
for( var i=0; i < nodes.childNodes.length; i++ )
{
node = nodes.childNodes[i];
@@ -1055,6 +1061,15 @@
$container.append(renderer.domElement);
}
+ /**
+ * Set up the camera.
+ * @method setupCamera
+ * @param {Number} azimut
+ * @param {Number} elevation
+ * @param {Number} distance
+ * @param {THREE.Vector3} target
+ * @private
+ */
function setupCamera( azimut, elevation, distance, target )
{
var cx = Math.sin(azimut) * Math.cos(elevation);
@@ -1066,11 +1081,22 @@
pointLight.position = camera.position;
}
+ /**
+ * Render the scene
+ * @method render
+ */
this.render = function()
{
renderer.render( scene, camera );
}
+ /**
+ * Change an internal state
+ * @method setState
+ * @param {String} property The property to set
+ * @param {String} value The new value for the property
+ * @param {Bool} redraw Redraw the scene if true
+ */
this.setState = function( property, value, redraw )
{
switch( property )
@@ -1094,6 +1120,12 @@
update3D();
}
}
+
+ /**
+ * Get the value of an internal state
+ * @method getState
+ * @return The value of the state
+ */
this.getState = function( property )
{
return showStates[ property ];
@@ -1102,6 +1134,10 @@
/**
* Resize the canvas. This might be done explicit by passing a width and
* height. Or implicit by passing no parameter or just the redraw parameter.
+ * @method resize
+ * @param {Number} width
+ * @param {Number} height
+ * @param {Bool} redraw
*/
this.resize = function( width, height, redraw )
{
@@ -1124,6 +1160,13 @@
}
}
+ /**
+ * Show or hide a floor
+ * @mthod hideFloor
+ * @param {Number} floorNr The number of the floor to change visibility
+ * @param {Bool} doShow <code>true</code> if floor has to be visible,
+ * <code>false</code> if it has to be hidden
+ */
this.hideFloor = function( floorNr, doShow )
{
THREE.SceneUtils.traverseHierarchy( self.buildingProperties.floor[floorNr].wallGroup, function( object ) {
@@ -1154,6 +1197,11 @@
update3D();
}
+ /**
+ * Update internal
+ * @method update3D
+ * @private
+ */
function update3D()
{
// set up camera
@@ -1296,7 +1344,12 @@
}
/**
+ * Move display to the given room on the given floor. If <code>room</code>
+ * is undefined, the whole floor will be shown.
* @method moveToRoom
+ * @param {Number} floor
+ * @param {Room} room
+ * @return {THREE.Vector3} Target
*/
this.moveToRoom = function( floor, room, hideOtherFloors, animate )
{
@@ -1467,7 +1520,6 @@
* http://paulirish.com/2011/requestanimationframe-for-smart-animating/
* @class requestAnimationFrame
*/
-
if ( !window.requestAnimationFrame ) {
window.requestAnimationFrame = ( function() {
return window.webkitRequestAnimationFrame ||
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ma...@us...> - 2012-03-11 20:11:22
|
Revision: 727
http://openautomation.svn.sourceforge.net/openautomation/?rev=727&view=rev
Author: mayerch
Date: 2012-03-11 20:11:16 +0000 (Sun, 11 Mar 2012)
Log Message:
-----------
Better error handling
Modified Paths:
--------------
JSFloorPlan/trunk/src/jsfloorplan.js
Modified: JSFloorPlan/trunk/src/jsfloorplan.js
===================================================================
--- JSFloorPlan/trunk/src/jsfloorplan.js 2012-03-11 19:52:14 UTC (rev 726)
+++ JSFloorPlan/trunk/src/jsfloorplan.js 2012-03-11 20:11:16 UTC (rev 727)
@@ -1306,6 +1306,9 @@
{
floor = this.buildingProperties.floorNames[floor];
}
+ if( !(floor in this.buildingProperties.floor) )
+ return target; // early exit when floor is invalid
+
if( room ) // use room if defined
{
target.x = room.center.x;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <j-...@us...> - 2012-03-11 19:52:20
|
Revision: 726
http://openautomation.svn.sourceforge.net/openautomation/?rev=726&view=rev
Author: j-n-k
Date: 2012-03-11 19:52:14 +0000 (Sun, 11 Mar 2012)
Log Message:
-----------
Restored imagetrigger (accidentally removed in Rev. 695)
Modified Paths:
--------------
CometVisu/trunk/visu/designs/structure_pure.js
Modified: CometVisu/trunk/visu/designs/structure_pure.js
===================================================================
--- CometVisu/trunk/visu/designs/structure_pure.js 2012-03-11 16:34:34 UTC (rev 725)
+++ CometVisu/trunk/visu/designs/structure_pure.js 2012-03-11 19:52:14 UTC (rev 726)
@@ -852,7 +852,108 @@
},
content: false
});
-
+
+ this.addCreator("imagetrigger", {
+ create: function( page, path ) {
+ var $p = $(page);
+ var ret_val = $('<div class="widget clearfix image" />');
+ ret_val.setWidgetLayout($p);
+ ret_val.addClass ('imagetrigger');
+ var value = $p.attr('value') ? $p.attr('value') : 0;
+ var labelElement = $p.find('label')[0];
+ ret_val.append( labelElement ? '<div class="label">' + labelElement.textContent + '</div>' : '' );
+ var address = {};
+ $p.find('address').each( function(){
+ var src = this.textContent;
+ ga_list.push( src )
+ address[ '_' + src ] = [
+ this.getAttribute('transform'), {
+ 'readonly' : this.getAttribute('readonly'),
+ 'writeonly' : this.getAttribute('writeonly')
+ }
+ ];
+ });
+ var style = ' style=" ';
+ style += $p.attr('width' ) ? 'width:' + $p.attr('width' ) + ';' : 'width: 100%;';
+ style += $p.attr('height' ) ? 'height:' + $p.attr('height' ) + ';"' : '"';
+
+ var actor = '<div class="actor">';
+ if ( $p.attr('type')=='show' )
+ actor += '<img src="' + $p.attr('src') + '.' + $p.attr('suffix') + '" ' + style + ' />';
+ else
+ actor += '<img src="" ' + style + ' />';
+ actor += '</div>';
+
+ actor += '</div>';
+ var refresh = $p.attr('refresh') ? $p.attr('refresh')*1000 : 0;
+ var $actor = $(actor).data( {
+ 'address': address,
+ 'refresh': refresh,
+ 'src': $p.attr('src'),
+ 'suffix': $p.attr('suffix'),
+ 'type': $p.attr('type'),
+ 'mapping': map,
+ 'sendValue': $p.attr('sendValue') || ""
+ } )
+ .each(setupRefreshAction) // abuse "each" to call in context... refresh is broken with select right now
+ .bind( 'click', this.action );
+ for( var addr in address ) {
+ $actor.bind( addr, this.update );
+ }
+ ret_val.append( $actor );
+ return ret_val;
+ },
+ update: function(e,d) {
+ var data = $(this).data();
+ if ( data.address[e.type][1].writeonly == "true")
+ return; // skip writeonly FIXME: writeonly shouldnt bind to update at all
+ var val = transformDecode(data.address[e.type][0], d);
+ if (data.type == "show")
+ if (val == 0)
+ $(this).children().hide();
+ else
+ $(this).children().attr("src", data.src + '.' + data.suffix ).show();
+ else if (data.type == "select")
+ if (val == 0)
+ $(this).children().hide();
+ else
+ $(this).children().attr("src", data.src + val + '.' + data.suffix ).show();
+
+ //FIXME: add value if mapping exists
+ //FIXME: get image name from mapping
+ //FIXME: add bitmask for multiple images
+ //FIXME: add SVG-magics
+ },
+ action: function() {
+ var data = $(this).data();
+ sendValue = data.sendValue;
+ for( var addr in data.address ) {
+ if( data.address[addr][1].readonly == "true" )
+ continue; // skip read only
+ if( data.sendValue == "" )
+ continue; // skip empty
+ visu.write( addr.substr(1), transformEncode( data.address[addr][0], sendValue ) );
+ }
+ },
+ attributes: {
+ src: { type: 'uri' , required: true },
+ width: { type: 'string' , required: false },
+ height: { type: 'string' , required: false },
+ refresh: { type: 'numeric', required: false },
+ colspan: { type: 'numeric', required: false },
+ rowspan: { type: 'numeric', required: false },
+ sendValue: { type: 'numeric', required: false },
+ type: { type: 'list' , required: true, list: {'show': 'show', 'select': 'select' /* , 'bitmask': 'bitmask' */ } },
+ mapping: { type: 'mapping', required: false },
+ suffix: { type: 'list' , required: false, list: {'png': '.png', 'jpg': '.jpg', 'gif': '.gif', 'svg': '.svg', 'bmp': '.bmp'} }
+ },
+ elements: {
+ label: { type: 'string', required: false, multi: false },
+ address: { type: 'address', required: true, multi: true }
+ },
+ content: false
+ });
+
this.addCreator('video', {
create: function( page, path ) {
var $p = $(page);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ma...@us...> - 2012-03-11 16:34:40
|
Revision: 725
http://openautomation.svn.sourceforge.net/openautomation/?rev=725&view=rev
Author: mayerch
Date: 2012-03-11 16:34:34 +0000 (Sun, 11 Mar 2012)
Log Message:
-----------
CometVisu:
- Added <layout> to trigger
- made 3D use full space
- added GA to switch floors (also temporary as well as azimut and elevation)
- removed a few timeouts that seemed unnecessary
JSFloorPlan3D:
- added ability to resize canvas
- improved moveToRoom
Modified Paths:
--------------
CometVisu/trunk/visu/designs/structure_pure.js
CometVisu/trunk/visu/lib/templateengine.js
CometVisu/trunk/visu/visu_config_2d3d.xml
JSFloorPlan/trunk/src/jsfloorplan.js
Modified: CometVisu/trunk/visu/designs/structure_pure.js
===================================================================
--- CometVisu/trunk/visu/designs/structure_pure.js 2012-03-07 22:55:34 UTC (rev 724)
+++ CometVisu/trunk/visu/designs/structure_pure.js 2012-03-11 16:34:34 UTC (rev 725)
@@ -173,7 +173,11 @@
container.append( '<embed src="' + backdrop + '" style="position: absolute; top: 0px; left: 0px;z-index:-1;width:100%;height:100%;"/>' );
} else if( '3d' == type )
{
- container.data( 'JSFloorPlan3D', JSFloorPlan3D( container, backdrop ) );
+ var floorplan = JSFloorPlan3D( container, backdrop );
+ floorplan.moveToRoom( 'Underground', false, true, false );
+ container.data( 'JSFloorPlan3D', floorplan );
+ container.find('canvas').css({position: 'absolute', top: '0px', left: '0px', 'z-index':'-1', width:'100%',height:'100%'});
+ $(window).bind( 'resize', function(){ floorplan.resize($('.page').width(), $('.page').height(), true);} );
if ($p.attr('azimut')) {
ga_list.push($p.attr('azimut'));
address[ '_' + $p.attr('azimut') ] = [ 'DPT:5.001', 0, 'azimut' ];
@@ -183,7 +187,13 @@
ga_list.push($p.attr('elevation'));
address[ '_' + $p.attr('elevation') ] = [ 'DPT:5.001', 0, 'elevation' ];
container.bind( '_' + $p.attr('elevation'), this.update );
- }; container.data( 'address', address );
+ };
+ if ($p.attr('floor')) {
+ ga_list.push($p.attr('floor'));
+ address[ '_' + $p.attr('floor') ] = [ 'DPT:5.004', 0, 'floor' ];
+ container.bind( '_' + $p.attr('floor'), this.update );
+ };
+ container.data( 'address', address );
}
$( childs ).each( function(i){
container.append( create_pages( childs[i], path + '_' + i, flavour ) );
@@ -205,13 +215,14 @@
rowspan: { type: 'numeric', required: false },
backdrop: { type: 'string', required: false },
azimut: { type: 'addr', required: false },
- elevation:{ type: 'addr', required: false }
+ elevation:{ type: 'addr', required: false },
+ floor: { type: 'addr', required: false }
},
elements: {
},
update: function(e, data) {
var element = $(this);
- var value = defaultUpdate( e, data, element );
+ var value = defaultValueHandling( e, data, element );
var type = element.data().address[ e.type ][2];
switch( type )
{
@@ -223,6 +234,10 @@
element.data().JSFloorPlan3D.setState('currentElevation', value, true);
break;
+ case 'floor':
+ element.data().JSFloorPlan3D.moveToRoom( value, false, true, true );
+ break;
+
default:
if (data==01) {
scrollToPage(this.attributes.path.nodeValue);
@@ -745,8 +760,10 @@
this.addCreator('trigger', {
create: function( page, path ) {
var $p = $(page);
+ var layout = $p.find('layout')[0];
+ var style = layout ? 'style="' + extractLayout( layout ) + '"' : '';
var value = $p.attr('value') ? $p.attr('value') : 0;
- var ret_val = $('<div class="widget clearfix switch" />');
+ var ret_val = $('<div class="widget clearfix switch" ' + style + ' />');
ret_val.setWidgetLayout($p);
var labelElement = $p.find('label')[0];
var label = labelElement ? '<div class="label">' + labelElement.textContent + '</div>' : '';
@@ -794,7 +811,8 @@
},
elements: {
label: { type: 'string', required: true, multi: false },
- address: { type: 'address', required: true, multi: true }
+ address: { type: 'address', required: true, multi: true },
+ layout: { type: 'layout', required: false, multi: false }
},
content: false
});
@@ -1237,17 +1255,12 @@
return { x: 0, y: 0 }; // sanity return
}
-function defaultUpdate( e, data, passedElement )
+function defaultValueHandling( e, data, passedElement )
{
var element = passedElement || $(this);
var thisTransform = element.data().address[ e.type ][0];
var value = transformDecode( element.data().address[ e.type ][0], data );
-
- element.setWidgetStyling(value);
- if( element.data( 'align' ) )
- element.addClass(element.data( 'align' ) );
-
element.data( 'basicvalue', value );
if( element.data( 'precision' ) )
value = Number( value ).toPrecision( element.data( 'precision' ) );
@@ -1267,6 +1280,20 @@
break;
}
}
+ return value;
+}
+
+function defaultUpdate( e, data, passedElement )
+{
+// var value = defaultValueHandling( e, data, passedElement )
+ var element = passedElement || $(this);
+ var value = defaultValueHandling( e, data, element );
+
+ element.setWidgetStyling( element.data( 'basicvalue' ) );
+
+ if( element.data( 'align' ) )
+ element.addClass(element.data( 'align' ) );
+
element.find('.value').text( value );
return value;
Modified: CometVisu/trunk/visu/lib/templateengine.js
===================================================================
--- CometVisu/trunk/visu/lib/templateengine.js 2012-03-07 22:55:34 UTC (rev 724)
+++ CometVisu/trunk/visu/lib/templateengine.js 2012-03-11 16:34:34 UTC (rev 725)
@@ -74,7 +74,7 @@
$(document).ready(function() {
// get the data once the page was loaded
$.ajaxSetup({cache: !forceReload});
- window.setTimeout("$.get( 'visu_config" + configSuffix + ".xml', parseXML );", 200);
+ $.get( 'visu_config' + configSuffix + '.xml', parseXML );
} );
$(window).unload(function() {
@@ -276,13 +276,9 @@
$('.footer').html( $('.footer').html() + text );
});
- // adapt width for pages to show
- handleResize();
-
if (pluginsToLoad <= 0) {
setup_page(xml);
}
-
}
function setup_page( xml )
@@ -291,7 +287,6 @@
var page = $( 'pages > page', xml )[0]; // only one page element allowed...
$('head').append(($('<div class="colspandefault" id="colspandefault">')));
- setTimeout(function() {
$('head').data('colspanDefault', parseInt($('#colspandefault').css('width')));
$('#colspandefault').remove();
@@ -342,8 +337,8 @@
}
visu.subscribe( ga_list );
+ $(window).trigger('resize');
$("#pages").triggerHandler("done");
- }, 1);
}
function create_pages( page, path, flavour ) {
Modified: CometVisu/trunk/visu/visu_config_2d3d.xml
===================================================================
--- CometVisu/trunk/visu/visu_config_2d3d.xml 2012-03-07 22:55:34 UTC (rev 724)
+++ CometVisu/trunk/visu/visu_config_2d3d.xml 2012-03-11 16:34:34 UTC (rev 725)
@@ -78,7 +78,7 @@
<address transform="DPT:5.001" type="">12/7/52</address>
</info>
</page>
- <page name="3D Demo" type="3d" backdrop="floorplan_demo.xml" azimut="12/7/53" elevation="12/7/54">
+ <page name="3D Demo" type="3d" backdrop="floorplan_demo.xml" azimut="12/7/53" elevation="12/7/54" floor="12/7/51">
<slide min="0" max="6.283185307179586">
<layout x="0px" y="570px" width="600px" />
<label>Azimut</label>
@@ -89,6 +89,16 @@
<label>Elevation</label>
<address transform="DPT:5.001" type="">12/7/54</address>
</slide>
+ <trigger value="0">
+ <layout x="0px" y="150px" width="600px" />
+ <label>Underground</label>
+ <address transform="DPT:5.004" readonly="false" type="">12/7/51</address>
+ </trigger>
+ <trigger value="1">
+ <layout x="0px" y="100px" width="600px" />
+ <label>Ground</label>
+ <address transform="DPT:5.004" readonly="false" type="">12/7/51</address>
+ </trigger>
</page>
<line/>
</page>
Modified: JSFloorPlan/trunk/src/jsfloorplan.js
===================================================================
--- JSFloorPlan/trunk/src/jsfloorplan.js 2012-03-07 22:55:34 UTC (rev 724)
+++ JSFloorPlan/trunk/src/jsfloorplan.js 2012-03-11 16:34:34 UTC (rev 725)
@@ -173,7 +173,7 @@
*/
// public variables of this object instance
- this.buildingProperties = { floor: [], Object3D: new THREE.Object3D() };
+ this.buildingProperties = { floor: [], Object3D: new THREE.Object3D(), floorNames:{} };
// private variables of this object instance will follow
@@ -384,6 +384,7 @@
var floorName = floor.getAttribute('name');
self.buildingProperties.floor[floorCount].name = floorName;
+ self.buildingProperties.floorNames[floorName] = floorCount;
var floorheight = Number( floor.getAttribute('height') );
self.buildingProperties.floor[floorCount].height = floorheight;
@@ -1098,6 +1099,31 @@
return showStates[ property ];
}
+ /**
+ * Resize the canvas. This might be done explicit by passing a width and
+ * height. Or implicit by passing no parameter or just the redraw parameter.
+ */
+ this.resize = function( width, height, redraw )
+ {
+ if( arguments.length === 2 || arguments.length === 3 )
+ {
+ WIDTH = width;
+ HEIGHT = height;
+ } else {
+ WIDTH = container.find('canvas').width();
+ HEIGHT = container.find('canvas').height();
+ redraw = width; // the first and only parameter is now the "redraw"
+ }
+ ASPECT = WIDTH / HEIGHT;
+ renderer.setSize(WIDTH, HEIGHT);
+ camera.aspect = ASPECT;
+
+ if( redraw ) // is set and true
+ {
+ update3D();
+ }
+ }
+
this.hideFloor = function( floorNr, doShow )
{
THREE.SceneUtils.traverseHierarchy( self.buildingProperties.floor[floorNr].wallGroup, function( object ) {
@@ -1178,13 +1204,14 @@
* is taken from the parameter <code>floor</code>
* @param {Function} delayedFn (optional) Function to call after animation is
* finished
+ * @param {Bool} animate Animate unless set to false
*/
- this.moveTo = function( floor, azimut, elevation, distance, target, delayedFn )
+ this.moveTo = function( floor, azimut, elevation, distance, target, delayedFn, animate )
{
if( noSetup ) setup3D( this.buildingProperties.Object3D );
// speed of the changing
- var steps = 100;
+ var steps = (animate == undefined || !animate) ? 1 : 100;
var rate = { azimut: 0.0, elevation: 0.0, distance: 0.0, target: new THREE.Vector3 };
function calcRate()
@@ -1271,10 +1298,14 @@
/**
* @method moveToRoom
*/
- this.moveToRoom = function( floor, room )
+ this.moveToRoom = function( floor, room, hideOtherFloors, animate )
{
var target = new THREE.Vector3();
var dist;
+ if( typeof floor === 'string' )
+ {
+ floor = this.buildingProperties.floorNames[floor];
+ }
if( room ) // use room if defined
{
target.x = room.center.x;
@@ -1287,7 +1318,25 @@
}
target.z = this.buildingProperties.floor[ floor ].heightOfGround +
this.buildingProperties.floor[ floor ].height / 2;
- this.moveTo( floor, showStates.currentAzimut, showStates.currentElevation, dist, target );
+ if( hideOtherFloors )
+ {
+ // show relevant floors
+ var minFloor = floor < showStates.showFloor ? floor : showStates.showFloor;
+ var maxFloor = floor < showStates.showFloor ? showStates.showFloor : floor;
+ var f = self.buildingProperties.floor.length-1;
+ for( ; f >= 0; f-- ) self.hideFloor( f, minFloor <= f && f <= maxFloor );
+ }
+ this.moveTo( floor, showStates.currentAzimut, showStates.currentElevation, dist, target,
+ function(){
+ if( hideOtherFloors )
+ {
+ // hide all except target floors
+ var f = self.buildingProperties.floor.length-1;
+ for( ; f >= 0; f-- ) self.hideFloor( f, f == floor );
+ }
+ self.render();
+ }, animate );
+ showStates.showFloor = floor;
return target;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ma...@us...> - 2012-03-07 22:55:41
|
Revision: 724
http://openautomation.svn.sourceforge.net/openautomation/?rev=724&view=rev
Author: makki1
Date: 2012-03-07 22:55:34 +0000 (Wed, 07 Mar 2012)
Log Message:
-----------
Tool to read electricity-meter easymeter (SML) by NetFritz
Added Paths:
-----------
tools/sml-meter/
tools/sml-meter/easymeter.pl
Added: tools/sml-meter/easymeter.pl
===================================================================
--- tools/sml-meter/easymeter.pl (rev 0)
+++ tools/sml-meter/easymeter.pl 2012-03-07 22:55:34 UTC (rev 724)
@@ -0,0 +1,94 @@
+#!/usr/bin/perl
+#
+# Holt die Daten vom SML-Zaehler Easymeter Q3C
+# es wird die obere optische Schnittstelle ausgelesen
+# dort liefert der Zaehler alle 2sec. einen Datensatz
+# wird von CRON jede Minute aufgerufen
+# http://wiki.volkszaehler.org/software/sml
+# 03.2012 by NetFritz
+#
+use Device::SerialPort;
+use RRDs;
+#
+my $port = Device::SerialPort->new("/dev/usbserial-2-4") || die $!;
+$port->databits(8);
+$port->baudrate(9600);
+$port->parity("none");
+$port->stopbits(1);
+$port->handshake("none");
+$port->write_settings;
+$port->dtr_active(1);
+$port->purge_all();
+$port->read_char_time(0); # don't wait for each character
+$port->read_const_time(1000); # 1 second per unfulfilled "read" call
+#
+# OBIS-Kennzahl und Anzahl der Zeichen von Anfang OBIS bis Messwert, Messwertwertlaenge immer 8 Zeichen
+%obis_len = (
+'01010801FF' => 42, # Aktueller Zählerstand T1 + Bezug
+'02020805FF' => 42, # Aktueller Zählerstand T5 - Abgabe
+'00010700FF' => 24 # Momentane Summe der Leistung +-
+);
+my $pos = 0;
+my $hexval;
+my @hexdec;
+while ($i < 3) { # wenn 540 chars gelesen werden wird mit last abgebrochen, wenn nicht wird Schleife 2 mal widerholt
+ my ($count,$saw)=$port->read(540); # will read 540 chars
+ if ($count == 540) { # wurden 540 chars gelesen ?
+ my $x=uc(unpack('H*',$saw)); # nach hex wandeln
+ # print "$count <> $x\n "; # gibt die empfangenen Daten in Hex aus
+ #
+ foreach $key(keys%obis_len){
+ $pos=index($x,$key); # pos von OBIS holen
+ $value = substr($x,$pos+$obis_len{$key},8); # Messwert
+ $value{$key} = hexstr_to_signed32int($value)/100; # von hex nach 32bit integer
+ }
+ last; # while verlassen
+ }
+ else {
+ $i++;
+ redo; # bei Fehler while nochmal
+ }
+}
+#
+@hexdec = encode_dpt9($value{'00010700FF'});
+$hexval = sprintf("%x", $hexdec[0]) . " " . sprintf("%x", $hexdec[1]);
+system("groupwrite ip:127.0.0.1 5/0/12 $hexval");
+#
+@hexdec = encode_dpt9($value{'01010801FF'});
+$hexval = sprintf("%x", $hexdec[0]) . " " . sprintf("%x", $hexdec[1]);
+system("groupwrite ip:127.0.0.1 5/0/13 $hexval");
+#
+@hexdec = encode_dpt9($value{'02020805FF'});
+$hexval = sprintf("%x", $hexdec[0]) . " " . sprintf("%x", $hexdec[1]);
+system("groupwrite ip:127.0.0.1 5/0/14 $hexval");
+#
+RRDs::update("/var/www/rrd/Zaehler_Leistung.rrd", "N: $value{'00010700FF'}");
+#
+#
+# --- Sub Konvertiert hex string to 32 bit signed integer ----------
+sub hexstr_to_signed32int {
+ my ($hexstr) = @_;
+ die "Invalid hex string: $hexstr"
+ if $hexstr !~ /^[0-9A-Fa-f]{1,8}$/;
+ my $num = hex($hexstr);
+ return $num >> 31 ? $num - 2 ** 32 : $num;
+}
+# --- Sub 2byte signed float --------------------------------------
+sub encode_dpt9 {
+ my $state = shift;
+ my $data;
+
+ my $sign = ($state <0 ? 0x8000 : 0);
+ my $exp = 0;
+ my $mant = 0;
+
+ $mant = int($state * 100.0);
+ while (abs($mant) > 2047) {
+ $mant /= 2;
+ $exp++;
+ }
+ $data = $sign | ($exp << 11) | ($mant & 0x07ff);
+ return $data >> 8, $data & 0xff;
+}
+# Ende
+
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ma...@us...> - 2012-03-05 17:33:25
|
Revision: 723
http://openautomation.svn.sourceforge.net/openautomation/?rev=723&view=rev
Author: mayerch
Date: 2012-03-05 17:33:16 +0000 (Mon, 05 Mar 2012)
Log Message:
-----------
Add missing floorplan_demo.xml - it's very simple to aid debugging. Showing off wasn't a design aim...
Added Paths:
-----------
CometVisu/trunk/visu/floorplan_demo.xml
Added: CometVisu/trunk/visu/floorplan_demo.xml
===================================================================
--- CometVisu/trunk/visu/floorplan_demo.xml (rev 0)
+++ CometVisu/trunk/visu/floorplan_demo.xml 2012-03-05 17:33:16 UTC (rev 723)
@@ -0,0 +1,94 @@
+<?xml version="1.0" encoding="UTF-8"?>
+ <building name="MyBuilding" orientation="45">
+ <floor name="Underground" height="2.44">
+ <nodes>
+ <node id="1" x="0.0" y="0.0" />
+ <node id="2" x="5.0" y="0.0" />
+ <node id="3" x="10.0" y="0.0" />
+ <node id="4" x="10.0" y="10.0" />
+ <node id="5" x="5.0" y="10.0" />
+ <node id="6" x="0.0" y="10.0" />
+ </nodes>
+ <walls>
+ <wall start="1" end="2" thickness=".24" texture="wall" />
+ <wall start="2" end="3" thickness=".24" >
+ <hole id="window01" distance="0.5" width="0.88" paparet="0.6" lintel="0.5" />
+ <hole id="window11" distance="2.5" width="0.88" paparet="0.6" lintel="0.5" />
+ </wall>
+ <wall start="3" end="4" thickness=".24" >
+ <hole id="window02" distance="0.5" width="0.88" paparet="1.6" lintel="0.0" />
+ </wall>
+ <wall start="4" end="5" thickness=".24" />
+ <wall start="5" end="6" thickness=".24" />
+ <wall start="6" end="1" thickness=".24" texture="wall" />
+ <wall start="2" end="5" thickness=".24" >
+ <hole id="door02" distance="0.5" width="0.88" paparet="0.0" lintel="0.2" />
+ </wall>
+ </walls>
+ <rooms>
+ <room name="Room1">
+ <zone name="all" onclick="alert('Bad')">
+ <corner nodeid="1" />
+ <corner nodeid="2" />
+ <corner nodeid="5" />
+ <corner nodeid="6" />
+ </zone>
+ </room>
+ <room name="Room2">
+ <zone name="all" onclick="alert('Kind')">
+ <corner nodeid="2" />
+ <corner nodeid="3" />
+ <corner nodeid="4" />
+ <corner nodeid="5" />
+ </zone>
+ </room>
+ </rooms>
+ </floor>
+ <floor name="Ground" height="2.44">
+ <nodes>
+ <node id="100" x="0" y="0" />
+ <node id="101" x="0" y="5" />
+ <node id="102" x="0" y="10" />
+ <node id="103" x="10" y="10" />
+ <node id="104" x="10" y="5" />
+ <node id="105" x="10" y="0" />
+ </nodes>
+ <walls>
+ <wall start="100" end="101" thickness=".24" texture="wall" >
+ <hole id="window100" distance="0.3" width="1.385" paparet="1.13" lintel="0.3" />
+ </wall>
+ <wall start="101" end="102" thickness=".24" texture="wall" >
+ <hole id="window101" distance="0.05" width="0.76" paparet="1.13" lintel="0.3" />
+ </wall>
+ <wall start="102" end="103" thickness=".24" >
+ <hole id="window102" distance="0.7" width="2.01" paparet="0.485" lintel="0.3" />
+ </wall>
+ <wall start="103" end="104" thickness=".24" >
+ <hole id="door100" distance="4.37" width="1.01" paparet="0.0" lintel="0.3" />
+ </wall>
+ <wall start="104" end="105" thickness=".24" >
+ <hole id="window104" distance="0.5" width="1.26" paparet="0.6" lintel="0.3" />
+ </wall>
+ <wall start="105" end="100" thickness=".24" >
+ <hole id="door101" distance="0.05" width="1.01" paparet="0.0" lintel="0.3" />
+ </wall>
+ <wall start="101" end="104" thickness=".24" >
+ <hole id="door102" distance="0.37" width="2.25" paparet="0.0" lintel="0.3" />
+ </wall>
+ </walls>
+ <rooms>
+ <room name="Bad EG">
+ <zone name="all" onclick="alert('Bad EG')">
+ <corner nodeid="100" />
+ <corner nodeid="101" />
+ <corner nodeid="104" />
+ <corner nodeid="105" />
+ </zone>
+ </room>
+ </rooms>
+ </floor>
+ <textures>
+ <texture id="wall" src="./textures/Wand.jpg" width="1" height="1" />
+ <texture id="ground" src="./textures/BodenGrau_1_3.jpg" width="1" height="1" />
+ </textures>
+ </building>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tho...@us...> - 2012-03-04 22:03:01
|
Revision: 722
http://openautomation.svn.sourceforge.net/openautomation/?rev=722&view=rev
Author: thomas_s
Date: 2012-03-04 22:02:54 +0000 (Sun, 04 Mar 2012)
Log Message:
-----------
implemented dayCondition and timeCondition
implemented unittests for both classes
Modified Paths:
--------------
xPLHAL/branches/thomas_s_dev/src/conditions/dayCondition.cpp
xPLHAL/branches/thomas_s_dev/src/conditions/dayCondition.h
xPLHAL/branches/thomas_s_dev/src/conditions/timeCondition.cpp
xPLHAL/branches/thomas_s_dev/src/conditions/timeCondition.h
xPLHAL/branches/thomas_s_dev/src/determinatoritems.h
xPLHAL/branches/thomas_s_dev/test/test_determinator.cpp
xPLHAL/branches/thomas_s_dev/test/test_determinator_manager.cpp
Modified: xPLHAL/branches/thomas_s_dev/src/conditions/dayCondition.cpp
===================================================================
--- xPLHAL/branches/thomas_s_dev/src/conditions/dayCondition.cpp 2012-03-04 21:45:41 UTC (rev 721)
+++ xPLHAL/branches/thomas_s_dev/src/conditions/dayCondition.cpp 2012-03-04 22:02:54 UTC (rev 722)
@@ -1,10 +1,34 @@
#include "dayCondition.h"
+#include <ctime>
+#include <chrono>
+#include <iostream>
using std::string;
+using std::chrono::time_point;
+using std::chrono::system_clock;
+using std::shared_ptr;
+using boost::regex;
+using std::cout;
+dayCondition::dayCondition(const BaseDeterminatorItem::attribute_t& attrlist)
+{
+ attributes = attrlist;
+}
+
dayCondition::dayCondition(const pugi::xml_node& basenode)
{
- attributes["dow"];
+ attributes["dow"] = {shared_ptr<regex>(new regex(R"(^[01]{7}$)"))};
parseFromXml(basenode);
}
+bool dayCondition::match() const
+{
+ std::time_t currentTime = std::time(0);
+ auto tm = std::localtime(¤tTime);
+ string dow_config = getAttribute("dow");
+
+ if (dow_config.length() == 7) {
+ return dow_config[tm->tm_wday] == '1';
+ }
+ return false;
+}
Modified: xPLHAL/branches/thomas_s_dev/src/conditions/dayCondition.h
===================================================================
--- xPLHAL/branches/thomas_s_dev/src/conditions/dayCondition.h 2012-03-04 21:45:41 UTC (rev 721)
+++ xPLHAL/branches/thomas_s_dev/src/conditions/dayCondition.h 2012-03-04 22:02:54 UTC (rev 722)
@@ -5,6 +5,9 @@
{
public:
dayCondition() {}
+ dayCondition(const BaseDeterminatorItem::attribute_t& attrlist);
dayCondition(const pugi::xml_node& basenode);
+
+ bool match() const;
};
Modified: xPLHAL/branches/thomas_s_dev/src/conditions/timeCondition.cpp
===================================================================
--- xPLHAL/branches/thomas_s_dev/src/conditions/timeCondition.cpp 2012-03-04 21:45:41 UTC (rev 721)
+++ xPLHAL/branches/thomas_s_dev/src/conditions/timeCondition.cpp 2012-03-04 22:02:54 UTC (rev 722)
@@ -1,22 +1,73 @@
#include "timeCondition.h"
-#include <boost/regex.hpp>
-#include <memory>
-#include <map>
+#include <chrono>
using std::string;
using std::shared_ptr;
-using std::map;
+using std::chrono::time_point;
+using std::chrono::duration;
+using std::chrono::system_clock;
using boost::regex;
using boost::regex_match;
+using boost::smatch;
+
+timeCondition::timeCondition(const BaseDeterminatorItem::attribute_t& attrlist, std::time_t fixTime)
+:mTestTime(fixTime)
+{
+ attributes["operator"] = {shared_ptr<regex>(new regex(R"(^(=|!=|<|>|<=|>=)$)"))};
+ attributes["value"] = {shared_ptr<regex>(new regex(R"(^(\d{1,2}):(\d{1,2})$)"))};
+
+ for (auto a : attrlist) {
+ attributes[a.first].value = a.second.value;
+ }
+
+ setCompareTime();
+}
+
timeCondition::timeCondition(const pugi::xml_node& basenode)
+:mTestTime(0)
{
attributes["operator"] = {shared_ptr<regex>(new regex(R"(^(=|!=|<|>|<=|>=)$)"))};
- attributes["value"] = {shared_ptr<regex>(new regex(R"(^\d{1,2}:\d{1,2}$)"))};
+ attributes["value"] = {shared_ptr<regex>(new regex(R"(^(\d{1,2}):(\d{1,2})$)"))};
parseFromXml(basenode);
+ setCompareTime();
}
+void timeCondition::setCompareTime()
+{
+ smatch res;
+
+ if (! regex_match(attributes["value"].value, res, *attributes["value"].re)) {
+ string error_text = "While creating timeCondition,";
+ error_text += " error getting value for attribute 'value': regex_match failed";
+ throw DeterminatorParseException(error_text);
+ }
+
+ mCompareHour = atoi(res.str(1).c_str());
+ mCompareMinute = atoi(res.str(2).c_str());
+}
+
bool timeCondition::match() const
{
+ /* for testing use mTestTime if != 0 */
+ std::time_t now = mTestTime ? mTestTime : std::time(0);
+ struct tm tm;
+ localtime_r(&now, &tm);
+
+ tm.tm_hour = mCompareHour;
+ tm.tm_min = mCompareMinute;
+
+ auto tp_now = system_clock::from_time_t(now);
+ auto tp_cmp = system_clock::from_time_t(std::mktime(&tm));
+
+ string op = getAttribute("operator");
+
+ if (op == "=") return tp_now == tp_cmp;
+ else if (op == "!=") return tp_now != tp_cmp;
+ else if (op == "<") return tp_now < tp_cmp;
+ else if (op == ">") return tp_now > tp_cmp;
+ else if (op == "<=") return tp_now <= tp_cmp;
+ else if (op == ">=") return tp_now >= tp_cmp;
+ return false;
}
Modified: xPLHAL/branches/thomas_s_dev/src/conditions/timeCondition.h
===================================================================
--- xPLHAL/branches/thomas_s_dev/src/conditions/timeCondition.h 2012-03-04 21:45:41 UTC (rev 721)
+++ xPLHAL/branches/thomas_s_dev/src/conditions/timeCondition.h 2012-03-04 22:02:54 UTC (rev 722)
@@ -1,12 +1,21 @@
#pragma once
#include "determinatoritems.h"
+#include <ctime>
class timeCondition: public DeterminatorCondition<timeCondition>
{
public:
- timeCondition() {}
+ timeCondition():mTestTime(0) {}
+ timeCondition(const BaseDeterminatorItem::attribute_t& attrlist, std::time_t fixTime);
timeCondition(const pugi::xml_node& basenode);
virtual bool match() const;
+
+ private:
+ void setCompareTime();
+
+ std::time_t mTestTime;
+ int mCompareHour;
+ int mCompareMinute;
};
Modified: xPLHAL/branches/thomas_s_dev/src/determinatoritems.h
===================================================================
--- xPLHAL/branches/thomas_s_dev/src/determinatoritems.h 2012-03-04 21:45:41 UTC (rev 721)
+++ xPLHAL/branches/thomas_s_dev/src/determinatoritems.h 2012-03-04 22:02:54 UTC (rev 722)
@@ -26,6 +26,14 @@
class BaseDeterminatorItem
{
public:
+ struct di_attribute {
+ std::shared_ptr<boost::regex> re;
+ std::string value;
+ };
+
+ typedef std::map<std::string, struct di_attribute> attribute_t;
+
+ public:
BaseDeterminatorItem(const std::string& name);
BaseDeterminatorItem(const pugi::xml_node& basenode, const std::string& name);
@@ -35,20 +43,11 @@
virtual void parseFromXml(const pugi::xml_node& basenode);
virtual bool match() const;
virtual void execute() const;
+ std::string getAttribute(const std::string& attrname) const;
- struct di_attribute {
- std::shared_ptr<boost::regex> re;
- std::string value;
- };
-
std::string item_name;
+ attribute_t attributes;
- std::string getAttribute(const std::string& attrname) const;
-
- std::map<std::string, struct di_attribute> attributes;
-
-
-
//boost::signal2::signal<void ()> sigChanged;
};
Modified: xPLHAL/branches/thomas_s_dev/test/test_determinator.cpp
===================================================================
--- xPLHAL/branches/thomas_s_dev/test/test_determinator.cpp 2012-03-04 21:45:41 UTC (rev 721)
+++ xPLHAL/branches/thomas_s_dev/test/test_determinator.cpp 2012-03-04 22:02:54 UTC (rev 722)
@@ -2,6 +2,8 @@
#define BOOST_TEST_DYN_LINK
#include <boost/test/unit_test.hpp>
#include <mockpp/visiting/CountedVisitableMethod.h>
+#include "../src/conditions/dayCondition.h"
+#include "../src/conditions/timeCondition.h"
using namespace mockpp;
@@ -137,4 +139,73 @@
d.execute();
}
+BOOST_AUTO_TEST_CASE( testdayConditon )
+{
+ dayCondition dc1({{"dow", {0, "1111111"}}});
+ BOOST_CHECK(dc1.match() == true);
+
+ dayCondition dc2({{"dow", {0, "0000000"}}});
+ BOOST_CHECK(dc2.match() == false);
+}
+
+BOOST_AUTO_TEST_CASE( testtimeCondition )
+{
+ // 1330895302 => So 4. Mär 22:08:23 CET 2012
+ {
+ // Equal
+ timeCondition tcEq1({{"operator", {0, "="}}, {"value", {0, "22:08"}}}, 1330895302);
+ BOOST_CHECK(tcEq1.match() == true);
+ timeCondition tcEq2({{"operator", {0, "="}}, {"value", {0, "22:09"}}}, 1330895302);
+ BOOST_CHECK(tcEq2.match() == false);
+ }
+
+ {
+ // Not Equal
+ timeCondition tcNEq1({{"operator", {0, "!="}}, {"value", {0, "22:08"}}}, 1330895302);
+ BOOST_CHECK(tcNEq1.match() == false);
+ timeCondition tcNEq2({{"operator", {0, "!="}}, {"value", {0, "22:09"}}}, 1330895302);
+ BOOST_CHECK(tcNEq2.match() == true);
+ }
+
+ {
+ // Greater
+ timeCondition tcGt1({{"operator", {0, ">"}}, {"value", {0, "20:00"}}}, 1330895302);
+ BOOST_CHECK(tcGt1.match() == true);
+ timeCondition tcGt2({{"operator", {0, ">"}}, {"value", {0, "23:00"}}}, 1330895302);
+ BOOST_CHECK(tcGt2.match() == false);
+ timeCondition tcGt3({{"operator", {0, ">"}}, {"value", {0, "22:08"}}}, 1330895302);
+ BOOST_CHECK(tcGt3.match() == false);
+ }
+
+ {
+ // Less
+ timeCondition tcLt1({{"operator", {0, "<"}}, {"value", {0, "20:00"}}}, 1330895302);
+ BOOST_CHECK(tcLt1.match() == false);
+ timeCondition tcLt2({{"operator", {0, "<"}}, {"value", {0, "23:00"}}}, 1330895302);
+ BOOST_CHECK(tcLt2.match() == true);
+ timeCondition tcLt3({{"operator", {0, "<"}}, {"value", {0, "22:08"}}}, 1330895302);
+ BOOST_CHECK(tcLt3.match() == false);
+ }
+
+ {
+ // Greater or Equal
+ timeCondition tcGoE1({{"operator", {0, ">="}}, {"value", {0, "20:00"}}}, 1330895302);
+ BOOST_CHECK(tcGoE1.match() == true);
+ timeCondition tcGoE2({{"operator", {0, ">="}}, {"value", {0, "23:00"}}}, 1330895302);
+ BOOST_CHECK(tcGoE2.match() == false);
+ timeCondition tcGoE3({{"operator", {0, ">="}}, {"value", {0, "22:08"}}}, 1330895302);
+ BOOST_CHECK(tcGoE3.match() == true);
+ }
+
+ {
+ // Less or Equal
+ timeCondition tcLoE1({{"operator", {0, "<="}}, {"value", {0, "20:00"}}}, 1330895302);
+ BOOST_CHECK(tcLoE1.match() == false);
+ timeCondition tcLoE2({{"operator", {0, "<="}}, {"value", {0, "23:00"}}}, 1330895302);
+ BOOST_CHECK(tcLoE2.match() == true);
+ timeCondition tcLoE3({{"operator", {0, "<="}}, {"value", {0, "22:08"}}}, 1330895302);
+ BOOST_CHECK(tcLoE3.match() == true);
+ }
+}
+
BOOST_AUTO_TEST_SUITE_END();
Modified: xPLHAL/branches/thomas_s_dev/test/test_determinator_manager.cpp
===================================================================
--- xPLHAL/branches/thomas_s_dev/test/test_determinator_manager.cpp 2012-03-04 21:45:41 UTC (rev 721)
+++ xPLHAL/branches/thomas_s_dev/test/test_determinator_manager.cpp 2012-03-04 22:02:54 UTC (rev 722)
@@ -13,7 +13,6 @@
{
DeterminatorManager dm("determinators");
dm.loadDeterminators();
-
}
BOOST_AUTO_TEST_SUITE_END();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ma...@us...> - 2012-03-04 21:45:47
|
Revision: 721
http://openautomation.svn.sourceforge.net/openautomation/?rev=721&view=rev
Author: mayerch
Date: 2012-03-04 21:45:41 +0000 (Sun, 04 Mar 2012)
Log Message:
-----------
New feature: 3d pages!!!
This is still more of a quick hack for a proof of concept than a solid integration - but it'll be the base for it.
Modified Paths:
--------------
CometVisu/trunk/visu/designs/structure_pure.js
CometVisu/trunk/visu/index.html
CometVisu/trunk/visu/visu_config_2d3d.xml
JSFloorPlan/trunk/src/jsfloorplan.js
Property Changed:
----------------
CometVisu/trunk/visu/
Property changes on: CometVisu/trunk/visu
___________________________________________________________________
Added: svn:externals
+ lib/jsfloorplan.js https://openautomation.svn.sourceforge.net/svnroot/openautomation/JSFloorPlan/trunk/src/jsfloorplan.js
lib/Three.js https://openautomation.svn.sourceforge.net/svnroot/openautomation/JSFloorPlan/trunk/lib/Three.js
lib/poly2tri.js https://openautomation.svn.sourceforge.net/svnroot/openautomation/JSFloorPlan/trunk/lib/poly2tri.js
media/demo_texture_512x512.png https://openautomation.svn.sourceforge.net/svnroot/openautomation/JSFloorPlan/trunk/media/demo_texture_512x512.png
Modified: CometVisu/trunk/visu/designs/structure_pure.js
===================================================================
--- CometVisu/trunk/visu/designs/structure_pure.js 2012-03-04 19:55:57 UTC (rev 720)
+++ CometVisu/trunk/visu/designs/structure_pure.js 2012-03-04 21:45:41 UTC (rev 721)
@@ -171,6 +171,19 @@
if( '2d' == type )
{
container.append( '<embed src="' + backdrop + '" style="position: absolute; top: 0px; left: 0px;z-index:-1;width:100%;height:100%;"/>' );
+ } else if( '3d' == type )
+ {
+ container.data( 'JSFloorPlan3D', JSFloorPlan3D( container, backdrop ) );
+ if ($p.attr('azimut')) {
+ ga_list.push($p.attr('azimut'));
+ address[ '_' + $p.attr('azimut') ] = [ 'DPT:5.001', 0, 'azimut' ];
+ container.bind( '_' + $p.attr('azimut'), this.update );
+ }
+ if ($p.attr('elevation')) {
+ ga_list.push($p.attr('elevation'));
+ address[ '_' + $p.attr('elevation') ] = [ 'DPT:5.001', 0, 'elevation' ];
+ container.bind( '_' + $p.attr('elevation'), this.update );
+ }; container.data( 'address', address );
}
$( childs ).each( function(i){
container.append( create_pages( childs[i], path + '_' + i, flavour ) );
@@ -190,14 +203,31 @@
type: { type: 'string', required: false },
colspan: { type: 'numeric', required: false },
rowspan: { type: 'numeric', required: false },
- backdrop: { type: 'string', required: false }
+ backdrop: { type: 'string', required: false },
+ azimut: { type: 'addr', required: false },
+ elevation:{ type: 'addr', required: false }
},
elements: {
},
update: function(e, data) {
- if (data==01) {
- scrollToPage(this.attributes.path.nodeValue);
- visu.write(e.type.substr(1), transformEncode("DPT:1.001", 0));
+ var element = $(this);
+ var value = defaultUpdate( e, data, element );
+ var type = element.data().address[ e.type ][2];
+ switch( type )
+ {
+ case 'azimut':
+ element.data().JSFloorPlan3D.setState('currentAzimut', value, true);
+ break;
+
+ case 'elevation':
+ element.data().JSFloorPlan3D.setState('currentElevation', value, true);
+ break;
+
+ default:
+ if (data==01) {
+ scrollToPage(this.attributes.path.nodeValue);
+ visu.write(e.type.substr(1), transformEncode("DPT:1.001", 0));
+ }
}
},
content: true
Modified: CometVisu/trunk/visu/index.html
===================================================================
--- CometVisu/trunk/visu/index.html 2012-03-04 19:55:57 UTC (rev 720)
+++ CometVisu/trunk/visu/index.html 2012-03-04 21:45:41 UTC (rev 721)
@@ -22,6 +22,9 @@
<script src="lib/templateengine.js" type="text/javascript"></script>
<script src="transforms/transform_default.js" type="text/javascript"></script>
<script src="transforms/transform_knx.js" type="text/javascript"></script>
+ <script src="lib/Three.js" type="text/javascript"></script>
+ <script src="lib/poly2tri.js" type="text/javascript"></script>
+ <script src="lib/jsfloorplan.js" type="text/javascript"></script>
<style type="text/css">
.loading { display: none; }
</style>
Modified: CometVisu/trunk/visu/visu_config_2d3d.xml
===================================================================
--- CometVisu/trunk/visu/visu_config_2d3d.xml 2012-03-04 19:55:57 UTC (rev 720)
+++ CometVisu/trunk/visu/visu_config_2d3d.xml 2012-03-04 21:45:41 UTC (rev 721)
@@ -78,8 +78,17 @@
<address transform="DPT:5.001" type="">12/7/52</address>
</info>
</page>
- <page name="3D Demo" >
- <text>not avialable at the moment...</text>
+ <page name="3D Demo" type="3d" backdrop="floorplan_demo.xml" azimut="12/7/53" elevation="12/7/54">
+ <slide min="0" max="6.283185307179586">
+ <layout x="0px" y="570px" width="600px" />
+ <label>Azimut</label>
+ <address transform="DPT:5.001" type="">12/7/53</address>
+ </slide>
+ <slide min="0" max="1.5707963267948966">
+ <layout x="400px" y="570px" width="600px" />
+ <label>Elevation</label>
+ <address transform="DPT:5.001" type="">12/7/54</address>
+ </slide>
</page>
<line/>
</page>
Modified: JSFloorPlan/trunk/src/jsfloorplan.js
===================================================================
--- JSFloorPlan/trunk/src/jsfloorplan.js 2012-03-04 19:55:57 UTC (rev 720)
+++ JSFloorPlan/trunk/src/jsfloorplan.js 2012-03-04 21:45:41 UTC (rev 721)
@@ -165,10 +165,12 @@
var self = this;
+ /*
if (typeof floorPlan === "string")
{
this.loadFloorPlan( floorPlan );
}
+ */
// public variables of this object instance
this.buildingProperties = { floor: [], Object3D: new THREE.Object3D() };
@@ -205,7 +207,7 @@
lightStrength: 80,
lightDistance: 50,
fillOpacity: 1, // solid
- fillColor: new THREE.Color(0x000000), // black
+ fillColor: new THREE.Color(0xffffff), // white
showNodes: false, // only for debug purposes
showWallLines: false, // only for debug purposes
showWireframe: false, //
@@ -1135,8 +1137,8 @@
var sx = Math.sin(showStates.lightAzimut) * Math.cos(showStates.lightElevation);
var sy = Math.cos(showStates.lightAzimut) * Math.cos(showStates.lightElevation);
var sz = Math.sin(showStates.lightElevation);
- sunLight.target.position = target;
- sunLight.position = new THREE.Vector3( sx * showStates.lightDistance, sy * showStates.lightDistance, sz * showStates.lightDistance + target.z );
+ sunLight.target.position = showStates.currentTarget;
+ sunLight.position = new THREE.Vector3( sx * showStates.lightDistance, sy * showStates.lightDistance, sz * showStates.lightDistance + showStates.currentTarget.z );
sunLight.intensity = showStates.lightStrength / 100.0;
sunLightViewLine.geometry.vertices[0].position = sunLight.position;
sunLightViewLine.geometry.vertices[1].position = sunLight.target.position;
@@ -1397,6 +1399,10 @@
if( event.data.callback ) event.data.callback( event );
}
+ if (typeof floorPlan === "string")
+ {
+ this.loadFloorPlan( floorPlan );
+ }
};
// library local variables
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ma...@us...> - 2012-03-04 19:56:04
|
Revision: 720
http://openautomation.svn.sourceforge.net/openautomation/?rev=720&view=rev
Author: mayerch
Date: 2012-03-04 19:55:57 +0000 (Sun, 04 Mar 2012)
Log Message:
-----------
Clean up the API (i.e. public methods) of the lib as well as general stuff
Modified Paths:
--------------
JSFloorPlan/trunk/index.html
JSFloorPlan/trunk/src/jsfloorplan.js
JSFloorPlan/trunk/src/jsfloorplan_example_helper.js
Modified: JSFloorPlan/trunk/index.html
===================================================================
--- JSFloorPlan/trunk/index.html 2012-03-04 18:48:31 UTC (rev 719)
+++ JSFloorPlan/trunk/index.html 2012-03-04 19:55:57 UTC (rev 720)
@@ -77,30 +77,6 @@
</tr>
<tr>
<td>
- Zeige Wände: <input type="checkbox" name="showWallSides" checked="checked" />
- </td><td>
- Zeige Deckel: <input type="checkbox" name="showWallTop" checked="checked" />
- </td><td>
- Zeige Rückseite: <input type="checkbox" name="showBackside" checked="checked" />
- </td><td>
- Zeige MouseOver: <input type="checkbox" name="wallMouseOver" />
- </td>
- </tr>
- <tr>
- <td>
- Wand-Umrandung: <input type="checkbox" name="showSideLines" checked="checked" />
- </td><td>
- Deckel-Umrandung: <input type="checkbox" name="showTopLines" checked="checked" />
- </td><td>
- Zeige "Löcher": <input type="checkbox" name="showHoles" checked="checked" />
- </td><td>
- Erzeuge Zonen: <input type="checkbox" name="showZones" checked="checked" />
- </td><td>
- Zeige Zonen: <input type="checkbox" name="showVisibleZones" checked="checked" />
- </td>
- </tr>
- <tr>
- <td>
Zeige Nodes: <input type="checkbox" name="showNodes" />
</td><td>
Zeige Walls: <input type="checkbox" name="showWallLines" />
@@ -128,12 +104,12 @@
</select>
</td><td>
Farbe: <select size="1" name="fillColor">
-<option value="black">Schwarz</option>
-<option value="grey" selected="selected">Grau</option>
-<option value="white">Weiß</option>
-<option value="blue">Blau</option>
-<option value="red">Rot</option>
-<option value="green">Grün</option>
+<option value="000000">Schwarz</option>
+<option value="808080" selected="selected">Grau</option>
+<option value="ffffff">Weiß</option>
+<option value="0000a0">Blau</option>
+<option value="a00000">Rot</option>
+<option value="00a000">Grün</option>
</select>
</td><td>
Stockwerk: <select size="1" name="showFloor">
@@ -145,23 +121,6 @@
</table>
</form>
<!-- -->
-<hr />
-<h2>Hinweise:</h2>
-<p>
-Sollte oben kein Plan zu sehen sein, so müssen die Dateinen noch an
-den jeweiligen Browser angepasst werden: beim IE einfach diese Datei von
-<em>index.xhtml</em> in <em>index.html</em> umbenennen - nähere Infos
-gibt es beim <a href="http://wiki.svg.org/Inline_SVG">SVG Wiki</a>.<br />
-Gerade in der Entwicklung ist noch mit solchen Kleinigkeiten zu rechnen,
-bei der finalen Version wird es passende Einstellungen geben.
-</p>
-<p>
-Nutzer des Internet Explorers müssen - da dieser im Gegensatz zu anderen
-modernen Browsern von sich aus noch kein SVG unterstützt - das passende
-PlugIn, den <a href="http://www.adobe.com/svg/viewer/install/main.html">Adobe SVG Viewer</a> installieren.<br />
-Problemlos und ohne PlugIn sollte es ab FireFox 1.5, Opera 9, Safari 3
-und Camino 1.0 funktionieren.
-</p>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
</body>
</html>
Modified: JSFloorPlan/trunk/src/jsfloorplan.js
===================================================================
--- JSFloorPlan/trunk/src/jsfloorplan.js 2012-03-04 18:48:31 UTC (rev 719)
+++ JSFloorPlan/trunk/src/jsfloorplan.js 2012-03-04 19:55:57 UTC (rev 720)
@@ -141,13 +141,30 @@
* @constructor FOO
*/
(function( window, undefined ){
- // the constructor
- var JSFloorPlan3D = function( container, floorPlan ){
+ ////////////////////////////////////////////////////////////////////////////
+ // private static variables and methods:
+
+ /**
+ * Constant representing the ID of an ELEMENT_NODE
+ * @property ELEMENT_NODE
+ * @private
+ * @static
+ * @final
+ * @type Enum
+ */
+ var ELEMENT_NODE = 1;
+
+ ////////////////////////////////////////////////////////////////////////////
+ // the library
+ var JSFloorPlan3D = function( container, floorPlan ){
+ // check and fix if the user forgot the "new" keyword
if (!(this instanceof JSFloorPlan3D))
{
return new JSFloorPlan3D( container, floorPlan );
}
+ var self = this;
+
if (typeof floorPlan === "string")
{
this.loadFloorPlan( floorPlan );
@@ -158,14 +175,13 @@
// private variables of this object instance will follow
- var that = this;
- var thatObject = {that: this};
- this.thisThatObject = {that: this};
- this.thisThat = this;
-
////////////////////////////////////////////////////////////////////////////
// Definition of the private variables
+ var WIDTH = 800,
+ HEIGHT = 400;
+ var VIEW_ANGLE = 45;
+ var projector = new THREE.Projector();
// create the materials - sphere for the nodes, cube for the walls and line for the lines
var sphereMaterial = new THREE.MeshLambertMaterial( { color: 0xCC0000 });
//var cubeMaterial = new THREE.MeshLambertMaterial( { color: 0x0000CC });
@@ -175,13 +191,28 @@
var scene, camera, renderer, pointLight, sunLight, ambientLight, sunLightViewLine;
// set up the sphere vars
-
- //var lightAzimut, lightElevation, lightStrength, lightDistanceŷ;
- this.lightAzimut = {foo:'bar'};
- this.lightElevation;
- this.lightStrength;
- this.lightDistanceŷ;
+ /**
+ * Set states that define how the floor plan is drawn
+ */
+ var showStates = {
+ currentAzimut: 1, // North up
+ currentElevation: Math.PI/2, // top view
+ currentDistance: 10,
+ // currentTarget: new THREE.Vector3, // will be defined later
+ lightAzimut: 3.9,
+ lightElevation: 0.25,
+ lightStrength: 80,
+ lightDistance: 50,
+ fillOpacity: 1, // solid
+ fillColor: new THREE.Color(0x000000), // black
+ showNodes: false, // only for debug purposes
+ showWallLines: false, // only for debug purposes
+ showWireframe: false, //
+ showLightView: false, // only for debug purposes
+ showFloor: undefined
+ };
+
var floor;
// this array will contain all vertices to show in the svg
@@ -230,15 +261,6 @@
*/
JSFloorPlan3D.inAnimation = false;
- /**
- * Constant representing the ID of an ELEMENT_NODE
- * @property ELEMENT_NODE
- * @private
- * @static
- * @final
- * @type Enum
- */
- var ELEMENT_NODE = 1;
////////////////////////////////////////////////////////////////////////////
// Definition of the private methods
@@ -317,27 +339,11 @@
}
/**
- * Get the URL url and set up this object by its content
- * @param {String} url
- */
- JSFloorPlan3D.prototype.loadFloorPlan = function( url )
- {
- var outerThis = this;
- $.ajax({
- url: url,
- context: outerThis,
- success: function( xmlDoc ){ outerThis.parseXMLFloorPlan( xmlDoc ); },
- dataType: 'xml',
- async: false
- });
- }
-
- /**
* Parse and create internal structure for the floor plan.
* @method parseXMLFloorPlan
* @param {XMLDom} xmlDoc
*/
- JSFloorPlan3D.prototype.parseXMLFloorPlan = function( xmlDoc )
+ var parseXMLFloorPlan = function( xmlDoc )
{
noFloorplan = false;
@@ -363,7 +369,7 @@
if( floor.tagName == 'textures' )
{
- this.parseTextures( floor );
+ parseTextures( floor );
continue;
}
@@ -372,14 +378,14 @@
"Expected: 'floor', found '" + floor.tagName + "'" );
floorCount++;
- this.buildingProperties.floor[floorCount] = {};
+ self.buildingProperties.floor[floorCount] = {};
var floorName = floor.getAttribute('name');
- this.buildingProperties.floor[floorCount].name = floorName;
+ self.buildingProperties.floor[floorCount].name = floorName;
var floorheight = Number( floor.getAttribute('height') );
- this.buildingProperties.floor[floorCount].height = floorheight;
- this.buildingProperties.floor[floorCount].heightOfGround = heightOfGround;
+ self.buildingProperties.floor[floorCount].height = floorheight;
+ self.buildingProperties.floor[floorCount].heightOfGround = heightOfGround;
var floorWallsStart = floorWalls.length;
@@ -392,15 +398,15 @@
switch( floorNode.tagName )
{
case 'nodes':
- this.parseFloorNodes( floorNode, floorheight );
+ parseFloorNodes( floorNode, floorheight );
break;
case 'walls':
- this.parseFloorWalls( floorNode );
+ parseFloorWalls( floorNode );
break;
case 'rooms':
- this.parseFloorRooms( floorNode, floorCount );
+ parseFloorRooms( floorNode, floorCount );
break;
}
}
@@ -718,27 +724,45 @@
Object3D.add( lineGroup );
Object3D.add( wallGroup );
- this.buildingProperties.floor[floorCount].Object3D = Object3D;
- this.buildingProperties.floor[floorCount].nodeGroup = nodeGroup;
- this.buildingProperties.floor[floorCount].lineGroup = lineGroup;
- this.buildingProperties.floor[floorCount].wallGroup = wallGroup;
- this.buildingProperties.Object3D.add( Object3D ); // add / link; note: we use that JavaScript is not copying objects but uses ref counting on them here!
+ self.buildingProperties.floor[floorCount].Object3D = Object3D;
+ self.buildingProperties.floor[floorCount].nodeGroup = nodeGroup;
+ self.buildingProperties.floor[floorCount].lineGroup = lineGroup;
+ self.buildingProperties.floor[floorCount].wallGroup = wallGroup;
+ self.buildingProperties.Object3D.add( Object3D ); // add / link; note: we use that JavaScript is not copying objects but uses ref counting on them here!
heightOfGround += floorheight;
} // end floor
- this.buildingProperties.x_center = (this.buildingProperties.x_max - this.buildingProperties.x_min) / 2;
- this.buildingProperties.y_center = (this.buildingProperties.y_max - this.buildingProperties.y_min) / 2;
- this.buildingProperties.size = Math.max( this.buildingProperties.x_center, this.buildingProperties.y_center );
- imageCenter.x = this.buildingProperties.x_center;
- imageCenter.y = this.buildingProperties.y_center;
- imageCenter.z = this.buildingProperties.z_max / 2;
+ self.buildingProperties.x_center = (self.buildingProperties.x_max - self.buildingProperties.x_min) / 2;
+ self.buildingProperties.y_center = (self.buildingProperties.y_max - self.buildingProperties.y_min) / 2;
+ self.buildingProperties.size = Math.max( self.buildingProperties.x_center, self.buildingProperties.y_center );
+ imageCenter.x = self.buildingProperties.x_center;
+ imageCenter.y = self.buildingProperties.y_center;
+ imageCenter.z = self.buildingProperties.z_max / 2;
- this.show3D( 35*Math.PI/180, 30*Math.PI/180, 10, new THREE.Vector3( imageCenter.x, imageCenter.y, imageCenter.z ) );
+ self.show3D( 35*Math.PI/180, 30*Math.PI/180, 10, new THREE.Vector3( imageCenter.x, imageCenter.y, imageCenter.z ) );
//}
};
/**
+ * Get the URL url and set up this object by its content
+ * @param {String} url
+ */
+ this.loadFloorPlan = function( url )
+ {
+ $.ajax({
+ url: url,
+ context: self,
+ success: function( xmlDoc ){
+ parseXMLFloorPlan( xmlDoc );
+
+ },
+ dataType: 'xml',
+ async: false
+ });
+ }
+
+ /**
* Fill the <code>floorNodes</code> structure with the nodes from the
* config file.
* @method parseFloorNodes
@@ -747,7 +771,7 @@
* @param {Float} floorheight The generic height of this floor that might be
* overwritten by individual nodes.
*/
- JSFloorPlan3D.prototype.parseFloorNodes = function( nodes, floorheight )
+ var parseFloorNodes = function( nodes, floorheight )
{
for( var i=0; i < nodes.childNodes.length; i++ )
{
@@ -763,21 +787,21 @@
floorNodes[id] = point;
- if( undefined == this.buildingProperties.x_min )
+ if( undefined == self.buildingProperties.x_min )
{
- this.buildingProperties.x_min = point.x;
- this.buildingProperties.x_max = point.x;
- this.buildingProperties.y_min = point.y;
- this.buildingProperties.y_max = point.y;
- this.buildingProperties.z_min = point.z;
- this.buildingProperties.z_max = point.z;
+ self.buildingProperties.x_min = point.x;
+ self.buildingProperties.x_max = point.x;
+ self.buildingProperties.y_min = point.y;
+ self.buildingProperties.y_max = point.y;
+ self.buildingProperties.z_min = point.z;
+ self.buildingProperties.z_max = point.z;
} else {
- if( this.buildingProperties.x_min > point.x ) this.buildingProperties.x_min = point.x;
- if( this.buildingProperties.x_max < point.x ) this.buildingProperties.x_max = point.x;
- if( this.buildingProperties.y_min > point.y ) this.buildingProperties.y_min = point.y;
- if( this.buildingProperties.y_max < point.y ) this.buildingProperties.y_max = point.y;
- if( this.buildingProperties.z_min > point.z ) this.buildingProperties.z_min = point.z;
- if( this.buildingProperties.z_max < point.z ) this.buildingProperties.z_max = point.z;
+ if( self.buildingProperties.x_min > point.x ) self.buildingProperties.x_min = point.x;
+ if( self.buildingProperties.x_max < point.x ) self.buildingProperties.x_max = point.x;
+ if( self.buildingProperties.y_min > point.y ) self.buildingProperties.y_min = point.y;
+ if( self.buildingProperties.y_max < point.y ) self.buildingProperties.y_max = point.y;
+ if( self.buildingProperties.z_min > point.z ) self.buildingProperties.z_min = point.z;
+ if( self.buildingProperties.z_max < point.z ) self.buildingProperties.z_max = point.z;
}
}
}
@@ -789,7 +813,7 @@
* @private
* @param {XMLDom} nodeGroup
*/
- JSFloorPlan3D.prototype.parseFloorWalls = function( nodes )
+ var parseFloorWalls = function( nodes )
{
for( var i=0; i < nodes.childNodes.length; i++ )
{
@@ -876,7 +900,7 @@
* @param {XMLDom} nodeGroup
* @param {Integer} floor The floor number.
*/
- JSFloorPlan3D.prototype.parseFloorRooms = function( nodes, floor )
+ var parseFloorRooms = function( nodes, floor )
{
rooms[floor] = new Array;
for( var i=0; i < nodes.childNodes.length; i++ )
@@ -936,7 +960,7 @@
* @private
* @param {XMLDom} nodes
*/
- JSFloorPlan3D.prototype.parseTextures = function( nodes )
+ var parseTextures = function( nodes )
{
return;
for( var i=0; i < nodes.childNodes.length; i++ )
@@ -958,12 +982,9 @@
///////////////////////////////////////////////////////////////////////////
// set the scene size
- var WIDTH = 800,
- HEIGHT = 400;
// set some camera attributes
- var VIEW_ANGLE = 45,
- ASPECT = WIDTH / HEIGHT,
+ var ASPECT = WIDTH / HEIGHT,
NEAR = 0.1,
FAR = 10000;
@@ -994,7 +1015,6 @@
renderer.shadowMapHeight = SHADOW_MAP_HEIGHT;
renderer.shadowMapEnabled = true;
//renderer.shadowMapSoft = true;
- var projector = new THREE.Projector();
// create a point light
pointLight = new THREE.PointLight( 0xFFFFFF );
@@ -1008,10 +1028,6 @@
// add to the scene
//scene.add(pointLight);
- currentThis.lightAzimut = 3.9;
- currentThis.lightElevation = 0.25;
- currentThis.lightStrength = 80;
- currentThis.lightDistance = 50;
sunLight = new THREE.SpotLight( 0xffffff );
sunLight.position.set( 0, 1500, 1000 );
sunLight.target.position.set( 0, 0, 0 );
@@ -1025,7 +1041,6 @@
scene.add( thisObject3D );
- var showFloor = showStates.showFloor;
///////////
scene.add(sunLight);
@@ -1048,16 +1063,46 @@
pointLight.position = camera.position;
}
- JSFloorPlan3D.prototype.render = function()
+ this.render = function()
{
renderer.render( scene, camera );
}
- JSFloorPlan3D.prototype.showWireframe = function( doShowWireframe )
+ this.setState = function( property, value, redraw )
{
- cubeMaterial.wireframe = doShowWireframe;
+ switch( property )
+ {
+ case 'showWireframe':
+ cubeMaterial.wireframe = value;
+ break;
+
+ case 'fillColor':
+ cubeMaterial.color.setHex( parseInt( value, 16 ) );
+ break;
+
+ case 'showFloor':
+ value = parseInt( value );
+ }
+
+ showStates[ property ] = value;
+
+ if( redraw ) // is set and true
+ {
+ update3D();
+ }
}
+ this.getState = function( property )
+ {
+ return showStates[ property ];
+ }
+ this.hideFloor = function( floorNr, doShow )
+ {
+ THREE.SceneUtils.traverseHierarchy( self.buildingProperties.floor[floorNr].wallGroup, function( object ) {
+ object.visible = doShow;
+ });
+ }
+
/**
* Show the floor plan by updating the relevant view parameters and calling
* the render() method
@@ -1069,7 +1114,7 @@
* @param {Number} distnce Distance between camera and <code>target</code>
* @param {THREE.Vector3} target The point to look at
*/
- JSFloorPlan3D.prototype.show3D = function( azimut, elevation, distance, target )
+ this.show3D = function( azimut, elevation, distance, target )
{
showStates.currentAzimut = azimut;
showStates.currentElevation = elevation;
@@ -1078,16 +1123,21 @@
if( noSetup ) setup3D( this, this.buildingProperties.Object3D );
+ update3D();
+ }
+
+ function update3D()
+ {
// set up camera
- setupCamera( azimut, elevation, distance, target );
+ setupCamera( showStates.currentAzimut, showStates.currentElevation, showStates.currentDistance, showStates.currentTarget );
// set up sun
- var sx = Math.sin(this.lightAzimut) * Math.cos(this.lightElevation);
- var sy = Math.cos(this.lightAzimut) * Math.cos(this.lightElevation);
- var sz = Math.sin(this.lightElevation);
+ var sx = Math.sin(showStates.lightAzimut) * Math.cos(showStates.lightElevation);
+ var sy = Math.cos(showStates.lightAzimut) * Math.cos(showStates.lightElevation);
+ var sz = Math.sin(showStates.lightElevation);
sunLight.target.position = target;
- sunLight.position = new THREE.Vector3( sx * this.lightDistance, sy * this.lightDistance, sz * this.lightDistance + target.z );
- sunLight.intensity = this.lightStrength / 100.0;
+ sunLight.position = new THREE.Vector3( sx * showStates.lightDistance, sy * showStates.lightDistance, sz * showStates.lightDistance + target.z );
+ sunLight.intensity = showStates.lightStrength / 100.0;
sunLightViewLine.geometry.vertices[0].position = sunLight.position;
sunLightViewLine.geometry.vertices[1].position = sunLight.target.position;
sunLightViewLine.geometry.__dirtyVertices = true;
@@ -1104,36 +1154,12 @@
cubeMaterial.opacity = showStates.fillOpacity;
cubeMaterial.transparent = showStates.fillOpacity < 1.0;
cubeMaterial.depthTest = !cubeMaterial.transparent;
- THREE.SceneUtils.traverseHierarchy( JSFloorPlan3D.buildingProperties.Object3D, function( object ) {
+ THREE.SceneUtils.traverseHierarchy( self.buildingProperties.Object3D, function( object ) {
object.doubleSided = cubeMaterial.transparent;
});
}
- // update color
- switch( showStates.fillColor )
- {
- case 'black':
- cubeMaterial.color.setRGB( 0.1, 0.1, 0.1 );
- break;
- case 'grey':
- cubeMaterial.color.setRGB( 0.5, 0.5, 0.5 );
- break;
- case 'white':
- cubeMaterial.color.setRGB( 1.0, 1.0, 1.0 );
- break;
- case 'blue':
- cubeMaterial.color.setRGB( 0.0, 0.0, 0.8 );
- break;
- case 'red':
- cubeMaterial.color.setRGB( 0.8, 0.0, 0.0 );
- break;
- case 'green':
- cubeMaterial.color.setRGB( 0.0, 0.8, 0.0 );
- break;
- };
-
- //this.render();
- renderer.render( scene, camera );
+ self.render();
}
/**
@@ -1151,7 +1177,7 @@
* @param {Function} delayedFn (optional) Function to call after animation is
* finished
*/
- JSFloorPlan3D.prototype.moveTo = function( floor, azimut, elevation, distance, target, delayedFn )
+ this.moveTo = function( floor, azimut, elevation, distance, target, delayedFn )
{
if( noSetup ) setup3D( this.buildingProperties.Object3D );
@@ -1192,7 +1218,7 @@
showStates.currentElevation += rate.elevation;
done = false;
} else {
- showStates.currenteElevation = elevation;
+ showStates.currentElevation = elevation;
}
if( (showStates.currentDistance + rate.distance) * rate.distance < distance * rate.distance )
{
@@ -1241,6 +1267,29 @@
}
/**
+ * @method moveToRoom
+ */
+ this.moveToRoom = function( floor, room )
+ {
+ var target = new THREE.Vector3();
+ var dist;
+ if( room ) // use room if defined
+ {
+ target.x = room.center.x;
+ target.y = room.center.y;
+ dist = room.size / Math.tan( VIEW_ANGLE * Math.PI/180 / 2 );
+ } else { // use whole floor otherwise
+ target.x = this.buildingProperties.x_center;
+ target.y = this.buildingProperties.y_center;
+ dist = this.buildingProperties.size / Math.tan( VIEW_ANGLE * Math.PI/180 / 2 );
+ }
+ target.z = this.buildingProperties.floor[ floor ].heightOfGround +
+ this.buildingProperties.floor[ floor ].height / 2;
+ this.moveTo( floor, showStates.currentAzimut, showStates.currentElevation, dist, target );
+ return target;
+ }
+
+ /**
* Check if point <code>p</code> is in the zone <code>zone</code>. It's
* basically a point-in-polygon test using a ray casting from left infinity to
* the point <code>p</code>.
@@ -1283,7 +1332,7 @@
* @return {Object} If a zone / room was found a hash with the keys "room" and
* "zone" will be returned otherwise an empty Object.
*/
- JSFloorPlan3D.prototype.selectRoom = function( p, floor )
+ this.selectRoom = function( p, floor )
{
var thisFloor = rooms[floor];
for( var room in thisFloor )
@@ -1308,7 +1357,7 @@
* @param {Number} h Height in building space used for mapping
* @return {THREE.Vector3} Point in building space
*/
- JSFloorPlan3D.prototype.sceen2building = function( x, y, h )
+ this.sceen2building = function( x, y, h )
{
var vector = new THREE.Vector3( (x / WIDTH)*2-1, -(y / HEIGHT)*2+1, 0.5 );
projector.unprojectVector( vector, camera );
@@ -1324,7 +1373,7 @@
* @return {Object} Hash with keys <code>x</code> and <code>y</code> in screen
* coordinates
*/
- JSFloorPlan3D.prototype.building2screen = function( p )
+ this.building2screen = function( p )
{
var screen = p.clone();
projector.projectVector( screen, camera );
@@ -1338,7 +1387,7 @@
* @param {Function} event.data.callback This callback function will be called
* after the mouse event was translated
*/
- JSFloorPlan3D.prototype.translateMouseEvent = function( event )
+ this.translateMouseEvent = function( event )
{
var tJSFloorPlan3D = event.data.JSFloorPlan3D;
var thisFloor = tJSFloorPlan3D.buildingProperties.floor[showStates.showFloor];
@@ -1353,4 +1402,22 @@
//Expose dQuery object to window as dQuery or JSlib
window.JSFloorPlan3D = JSFloorPlan3D;
-})(window);
\ No newline at end of file
+})(window);
+
+/**
+ * Provides requestAnimationFrame in a cross browser way.
+ * http://paulirish.com/2011/requestanimationframe-for-smart-animating/
+ * @class requestAnimationFrame
+ */
+
+if ( !window.requestAnimationFrame ) {
+ window.requestAnimationFrame = ( function() {
+ return window.webkitRequestAnimationFrame ||
+ window.mozRequestAnimationFrame ||
+ window.oRequestAnimationFrame ||
+ window.msRequestAnimationFrame ||
+ function( /* function FrameRequestCallback */ callback, /* DOMElement Element */ element ) {
+ window.setTimeout( callback, 1000 / 60 );
+ };
+ } )();
+}
\ No newline at end of file
Modified: JSFloorPlan/trunk/src/jsfloorplan_example_helper.js
===================================================================
--- JSFloorPlan/trunk/src/jsfloorplan_example_helper.js 2012-03-04 18:48:31 UTC (rev 719)
+++ JSFloorPlan/trunk/src/jsfloorplan_example_helper.js 2012-03-04 19:55:57 UTC (rev 720)
@@ -27,53 +27,15 @@
* @module JS FloorPlan 3D Example
*/
-/**
- * Provides requestAnimationFrame in a cross browser way.
- * http://paulirish.com/2011/requestanimationframe-for-smart-animating/
- * @class requestAnimationFrame
- */
-
-if ( !window.requestAnimationFrame ) {
- window.requestAnimationFrame = ( function() {
- return window.webkitRequestAnimationFrame ||
- window.mozRequestAnimationFrame ||
- window.oRequestAnimationFrame ||
- window.msRequestAnimationFrame ||
- function( /* function FrameRequestCallback */ callback, /* DOMElement Element */ element ) {
- window.setTimeout( callback, 1000 / 60 );
- };
-} )();
-
-}
-function animate() {
- requestAnimationFrame( animate );
- //render();
- j.show3D( roll, tilt, dist, target );
- //stats.update();
-}
-
function handleMouseClickEvent( event )
{
- if( event.room.room )
- {
- var room = event.room.room;
- var zone = event.room.zone;
- target.x = room.center.x;
- target.y = room.center.y;
- dist = room.size / Math.tan( VIEW_ANGLE * Math.PI/180 / 2 );
- } else {
- target.x = j.buildingProperties.x_center;
- target.y = j.buildingProperties.y_center;
- dist = j.buildingProperties.size / Math.tan( VIEW_ANGLE * Math.PI/180 / 2 );
- }
+ target = j.moveToRoom( j.getState('showFloor'), event.room.room );
updateSlider();
- j.moveTo( showStates['showFloor'], roll, tilt, dist, target );
}
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// setup script here:
var sc = 40; // overall scaling
-var showStates = {};
var redrawInterval = 50; // in milliseconds; = 20 fps
var roll = 35*Math.PI/180;
@@ -97,36 +59,37 @@
function init()
{
$('input').change(function(e){
- var old = showStates[ e.target.name ];
- showStates[ e.target.name ] = e.target.checked;
+ var old = j.getState( e.target.name );
+ j.setState( e.target.name, e.target.checked );
if( selectChange( e.target.name, old ) )
{
j.show3D( roll, tilt, dist, target );
}
}).each(function(){
- showStates[ this.name ] = this.checked; // init
+ j.setState( this.name, this.checked ); // init
});
$('select').change(function(e){
- var old = showStates[ e.target.name ];
- showStates[ e.target.name ] = e.target.value;
+ var old = j.getState( e.target.name );
+ j.setState( e.target.name, e.target.value );
if( selectChange( e.target.name, old ) )
{
j.show3D( roll, tilt, dist, target );
}
}).each(function(){
- showStates[ this.name ] = this.value; // init
+ j.setState( this.name, this.value ); // init
});
j.loadFloorPlan('floorplan_demo.xml');
target.x = j.buildingProperties.x_center;
target.y = j.buildingProperties.y_center;
createSlider();
- j.render();
// Init after the scene was set up
selectChange( 'showNodes' , 0, true );
selectChange( 'showWallLines' , 0, true );
selectChange( 'showFloor' , 0, true );
+
+ j.render();
}
function selectChange( name, old, onlyInit )
@@ -136,7 +99,7 @@
case 'showNodes':
$( j.buildingProperties.floor ).each( function(){
THREE.SceneUtils.traverseHierarchy( this.nodeGroup, function( object ) {
- object.visible = showStates['showNodes'];
+ object.visible = j.getState( 'showNodes' );
});
});
break;
@@ -144,47 +107,36 @@
case 'showWallLines':
$( j.buildingProperties.floor ).each( function(){
THREE.SceneUtils.traverseHierarchy( this.lineGroup, function( object ) {
- object.visible = showStates['showWallLines'];
+ object.visible = j.getState( 'showWallLines' );
});
});
break;
case 'showFloor':
- //showStates['showFloor'] = Number( showStates['showFloor'] );
if( onlyInit )
{
$( j.buildingProperties.floor ).each( function( number ){
- THREE.SceneUtils.traverseHierarchy( this.wallGroup, function( object ) {
- object.visible = ( showStates['showFloor'] == number );
- });
+ j.hideFloor( number, j.getState( 'showFloor' ) == number );
});
- target.z = j.buildingProperties.floor[ showStates['showFloor'] ].heightOfGround +
- j.buildingProperties.floor[ showStates['showFloor'] ].height / 2;
+ target.z = j.buildingProperties.floor[ j.getState( 'showFloor' ) ].heightOfGround +
+ j.buildingProperties.floor[ j.getState( 'showFloor' ) ].height / 2;
return false;
}
- var min = old < showStates['showFloor'] ? old : showStates['showFloor'];
- var max = old > showStates['showFloor'] ? old : showStates['showFloor'];
+ var min = old < j.getState( 'showFloor' ) ? old : j.getState( 'showFloor' );
+ var max = old > j.getState( 'showFloor' ) ? old : j.getState( 'showFloor' );
$( j.buildingProperties.floor ).each( function( number ){
- THREE.SceneUtils.traverseHierarchy( this.wallGroup, function( object ) {
- object.visible = ( (min <= number) && (number <= max) );
- });
+ j.hideFloor( number, (min <= number) && (number <= max) );
});
- target.z = j.buildingProperties.floor[ showStates['showFloor'] ].heightOfGround +
- j.buildingProperties.floor[ showStates['showFloor'] ].height / 2;
- j.moveTo( showStates['showFloor'], roll, tilt, dist, target, function(){
+ target.z = j.buildingProperties.floor[ j.getState( 'showFloor' ) ].heightOfGround +
+ j.buildingProperties.floor[ j.getState( 'showFloor' ) ].height / 2;
+ j.moveTo( j.getState( 'showFloor' ), roll, tilt, dist, target, function(){
$( j.buildingProperties.floor ).each( function( number ){
- THREE.SceneUtils.traverseHierarchy( this.wallGroup, function( object ) {
- object.visible = ( showStates['showFloor'] == number );
- });
+ j.hideFloor( number, j.getState( 'showFloor' ) == number );
});
j.show3D( roll, tilt, dist, target );
});
return false;
break;
-
- case 'showWireframe':
- j.showWireframe( showStates['showWireframe'] );
- break;
}
return true;
}
@@ -283,15 +235,15 @@
globalInUpdateSlider = true;
var rollAngle = (roll * 180/Math.PI);
var tiltAngle = (tilt * 180/Math.PI);
- var lightDirectionAngle = (j.lightAzimut * 180/Math.PI);
- var lightHeightAngle = (j.lightElevation * 180/Math.PI);
+ var lightDirectionAngle = (j.getState('lightAzimut') * 180/Math.PI);
+ var lightHeightAngle = (j.getState('lightElevation') * 180/Math.PI);
$( "#rollSlider" ).slider( "option", "value", rollAngle );
$( "#tiltSlider" ).slider( "option", "value", tiltAngle );
$( "#distSlider" ).slider( "option", "value", dist );
$( "#lightDirectionSlider" ).slider( "option", "value", lightDirectionAngle );
$( "#lightHeightSlider" ).slider( "option", "value", lightHeightAngle );
- $( "#lightStrengthSlider" ).slider( "option", "value", j.lightStrength );
- $( "#lightDistanceSlider" ).slider( "option", "value", j.lightDistance );
+ $( "#lightStrengthSlider" ).slider( "option", "value", j.getState('lightStrength') );
+ $( "#lightDistanceSlider" ).slider( "option", "value", j.getState('lightDistance') );
globalInUpdateSlider = false;
}
@@ -319,15 +271,13 @@
function lightDirectionChange( event, ui )
{
if( globalInUpdateSlider ) return true;
- j.lightAzimut = ui.value * Math.PI / 180;
- j.show3D( roll, tilt, dist, target );
+ j.setState( 'lightAzimut', ui.value * Math.PI / 180, true );
}
function lightHeightChange( event, ui )
{
if( globalInUpdateSlider ) return true;
- j.lightElevation = ui.value * Math.PI / 180;
- j.show3D( roll, tilt, dist, target );
+ j.setState( 'lightElevation', ui.value * Math.PI / 180, true );
}
function lightStrengthChange( event, ui )
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tho...@us...> - 2012-03-04 18:48:39
|
Revision: 719
http://openautomation.svn.sourceforge.net/openautomation/?rev=719&view=rev
Author: thomas_s
Date: 2012-03-04 18:48:31 +0000 (Sun, 04 Mar 2012)
Log Message:
-----------
added DeterminatorManager class
moved Determinator-Items to subdirectories
refactored Determinator-Items (parsing and toString)
WIP
Modified Paths:
--------------
xPLHAL/branches/thomas_s_dev/src/CMakeLists.txt
xPLHAL/branches/thomas_s_dev/src/determinator.cpp
xPLHAL/branches/thomas_s_dev/src/determinator.h
xPLHAL/branches/thomas_s_dev/src/determinatoritems.cpp
xPLHAL/branches/thomas_s_dev/src/determinatoritems.h
xPLHAL/branches/thomas_s_dev/src/main.cpp
xPLHAL/branches/thomas_s_dev/src/xplmessage.h
xPLHAL/branches/thomas_s_dev/src/xplmessagequeue.cpp
xPLHAL/branches/thomas_s_dev/src/xplmessagequeue.h
xPLHAL/branches/thomas_s_dev/test/CMakeLists.txt
xPLHAL/branches/thomas_s_dev/test/determinator1.xml
xPLHAL/branches/thomas_s_dev/test/test_determinator.cpp
xPLHAL/branches/thomas_s_dev/test/test_devicemanager.cpp
Added Paths:
-----------
xPLHAL/branches/thomas_s_dev/src/actions/delayAction.cpp
xPLHAL/branches/thomas_s_dev/src/actions/delayAction.h
xPLHAL/branches/thomas_s_dev/src/actions/execRuleAction.cpp
xPLHAL/branches/thomas_s_dev/src/actions/execRuleAction.h
xPLHAL/branches/thomas_s_dev/src/actions/executeAction.cpp
xPLHAL/branches/thomas_s_dev/src/actions/executeAction.h
xPLHAL/branches/thomas_s_dev/src/actions/globalAction.cpp
xPLHAL/branches/thomas_s_dev/src/actions/globalAction.h
xPLHAL/branches/thomas_s_dev/src/actions/logAction.cpp
xPLHAL/branches/thomas_s_dev/src/actions/logAction.h
xPLHAL/branches/thomas_s_dev/src/actions/runScriptAction.cpp
xPLHAL/branches/thomas_s_dev/src/actions/runScriptAction.h
xPLHAL/branches/thomas_s_dev/src/actions/stopAction.cpp
xPLHAL/branches/thomas_s_dev/src/actions/stopAction.h
xPLHAL/branches/thomas_s_dev/src/actions/suspendAction.cpp
xPLHAL/branches/thomas_s_dev/src/actions/suspendAction.h
xPLHAL/branches/thomas_s_dev/src/actions/xplAction.cpp
xPLHAL/branches/thomas_s_dev/src/actions/xplAction.h
xPLHAL/branches/thomas_s_dev/src/conditions/dayCondition.cpp
xPLHAL/branches/thomas_s_dev/src/conditions/dayCondition.h
xPLHAL/branches/thomas_s_dev/src/conditions/globalChanged.cpp
xPLHAL/branches/thomas_s_dev/src/conditions/globalChanged.h
xPLHAL/branches/thomas_s_dev/src/conditions/globalCondition.cpp
xPLHAL/branches/thomas_s_dev/src/conditions/globalCondition.h
xPLHAL/branches/thomas_s_dev/src/conditions/timeCondition.cpp
xPLHAL/branches/thomas_s_dev/src/conditions/timeCondition.h
xPLHAL/branches/thomas_s_dev/src/conditions/xplCondition.cpp
xPLHAL/branches/thomas_s_dev/src/conditions/xplCondition.h
xPLHAL/branches/thomas_s_dev/src/determinator_manager.cpp
xPLHAL/branches/thomas_s_dev/src/determinator_manager.h
xPLHAL/branches/thomas_s_dev/test/determinatorAll.xml
xPLHAL/branches/thomas_s_dev/test/test_determinator_manager.cpp
Modified: xPLHAL/branches/thomas_s_dev/src/CMakeLists.txt
===================================================================
--- xPLHAL/branches/thomas_s_dev/src/CMakeLists.txt 2012-03-03 21:11:49 UTC (rev 718)
+++ xPLHAL/branches/thomas_s_dev/src/CMakeLists.txt 2012-03-04 18:48:31 UTC (rev 719)
@@ -17,13 +17,19 @@
project(xPLHAL)
cmake_minimum_required(VERSION 2.6)
-set(CMAKE_CXX_FLAGS "-g -std=c++0x")
-#set(CMAKE_CXX_FLAGS "-g -Os -std=c++0x")
+file(GLOB_RECURSE Action_sources ./actions/*.cpp)
+file(GLOB_RECURSE Condition_sources ./conditions/*.cpp)
+
+#set(CMAKE_CXX_FLAGS "-g -std=c++0x")
+set(CMAKE_CXX_FLAGS "-g -Os -std=c++0x")
set(xPLHAL_SRCS xplmessagequeue.cpp devicemanager.cpp
xplhandler.cpp xplcache.cpp xhcpthread.cpp log.cpp
xhcp.cpp xplmessage.cpp recurring_timer.cpp main.cpp pugixml.cpp
- determinatoritems.cpp determinator.cpp)
+ determinatoritems.cpp determinator.cpp determinator_manager.cpp
+ ${Action_sources} ${Condition_sources})
+include_directories(${CMAKE_CURRENT_SOURCE_DIR})
+
add_executable(xPLHAL ${xPLHAL_SRCS})
#message(STATUS "Boost_LIBRARIES=${Boost_LIBRARIES}")
#message(STATUS "LIBRARIES=${LIBS}")
Added: xPLHAL/branches/thomas_s_dev/src/actions/delayAction.cpp
===================================================================
--- xPLHAL/branches/thomas_s_dev/src/actions/delayAction.cpp (rev 0)
+++ xPLHAL/branches/thomas_s_dev/src/actions/delayAction.cpp 2012-03-04 18:48:31 UTC (rev 719)
@@ -0,0 +1,17 @@
+#include "delayAction.h"
+
+using std::string;
+using std::vector;
+using std::map;
+
+delayAction::delayAction(const pugi::xml_node& basenode)
+{
+ attributes["delay_seconds"];
+ parseFromXml(basenode);
+}
+
+void delayAction::execute() const
+{
+ sleep(atoi(getAttribute("delaySeconds").c_str()));
+}
+
Added: xPLHAL/branches/thomas_s_dev/src/actions/delayAction.h
===================================================================
--- xPLHAL/branches/thomas_s_dev/src/actions/delayAction.h (rev 0)
+++ xPLHAL/branches/thomas_s_dev/src/actions/delayAction.h 2012-03-04 18:48:31 UTC (rev 719)
@@ -0,0 +1,11 @@
+#pragma once
+#include "determinatoritems.h"
+
+class delayAction: public DeterminatorAction<delayAction>
+{
+ public:
+ delayAction() {}
+ delayAction(const pugi::xml_node& basenode);
+
+ void execute() const;
+};
Added: xPLHAL/branches/thomas_s_dev/src/actions/execRuleAction.cpp
===================================================================
--- xPLHAL/branches/thomas_s_dev/src/actions/execRuleAction.cpp (rev 0)
+++ xPLHAL/branches/thomas_s_dev/src/actions/execRuleAction.cpp 2012-03-04 18:48:31 UTC (rev 719)
@@ -0,0 +1 @@
+#include "execRuleAction.h"
Added: xPLHAL/branches/thomas_s_dev/src/actions/execRuleAction.h
===================================================================
--- xPLHAL/branches/thomas_s_dev/src/actions/execRuleAction.h (rev 0)
+++ xPLHAL/branches/thomas_s_dev/src/actions/execRuleAction.h 2012-03-04 18:48:31 UTC (rev 719)
@@ -0,0 +1,17 @@
+#pragma once
+#include "determinatoritems.h"
+
+class execRuleAction: public DeterminatorAction<execRuleAction>
+{
+ public:
+ execRuleAction() {}
+ execRuleAction(const pugi::xml_node& basenode) {
+ parseFromXml(basenode);
+ }
+ void execute() const;
+
+ void parseFromXml(const pugi::xml_node& basenode);
+ std::string toString() const;
+
+ std::string ruleName;
+};
Added: xPLHAL/branches/thomas_s_dev/src/actions/executeAction.cpp
===================================================================
--- xPLHAL/branches/thomas_s_dev/src/actions/executeAction.cpp (rev 0)
+++ xPLHAL/branches/thomas_s_dev/src/actions/executeAction.cpp 2012-03-04 18:48:31 UTC (rev 719)
@@ -0,0 +1 @@
+#include "executeAction.h"
Added: xPLHAL/branches/thomas_s_dev/src/actions/executeAction.h
===================================================================
--- xPLHAL/branches/thomas_s_dev/src/actions/executeAction.h (rev 0)
+++ xPLHAL/branches/thomas_s_dev/src/actions/executeAction.h 2012-03-04 18:48:31 UTC (rev 719)
@@ -0,0 +1,19 @@
+#pragma once
+#include "determinatoritems.h"
+
+class executeAction: public DeterminatorAction<executeAction>
+{
+ public:
+ executeAction() {}
+ executeAction(const pugi::xml_node& basenode) {
+ parseFromXml(basenode);
+ }
+ void execute() const;
+
+ void parseFromXml(const pugi::xml_node& basenode);
+ std::string toString() const;
+
+ std::string program;
+ std::string parameters;
+ std::string wait;
+};
Added: xPLHAL/branches/thomas_s_dev/src/actions/globalAction.cpp
===================================================================
--- xPLHAL/branches/thomas_s_dev/src/actions/globalAction.cpp (rev 0)
+++ xPLHAL/branches/thomas_s_dev/src/actions/globalAction.cpp 2012-03-04 18:48:31 UTC (rev 719)
@@ -0,0 +1,18 @@
+#include "globalAction.h"
+#include <iostream>
+
+using std::string;
+using std::cerr;
+
+globalAction::globalAction(const pugi::xml_node& basenode)
+{
+ attributes["name"];
+ attributes["value"];
+ parseFromXml(basenode);
+}
+
+void globalAction::execute() const
+{
+ std::cerr << "globalAction set " << getAttribute("name") << " to " << getAttribute("value") << "\n";
+}
+
Added: xPLHAL/branches/thomas_s_dev/src/actions/globalAction.h
===================================================================
--- xPLHAL/branches/thomas_s_dev/src/actions/globalAction.h (rev 0)
+++ xPLHAL/branches/thomas_s_dev/src/actions/globalAction.h 2012-03-04 18:48:31 UTC (rev 719)
@@ -0,0 +1,12 @@
+#pragma once
+#include "determinatoritems.h"
+
+class globalAction: public DeterminatorAction<globalAction>
+{
+ public:
+ globalAction() {}
+ globalAction(const pugi::xml_node& basenode);
+
+ void execute() const;
+};
+
Added: xPLHAL/branches/thomas_s_dev/src/actions/logAction.cpp
===================================================================
--- xPLHAL/branches/thomas_s_dev/src/actions/logAction.cpp (rev 0)
+++ xPLHAL/branches/thomas_s_dev/src/actions/logAction.cpp 2012-03-04 18:48:31 UTC (rev 719)
@@ -0,0 +1,17 @@
+#include "logAction.h"
+#include "log.h"
+
+using std::string;
+
+logAction::logAction(const pugi::xml_node& basenode)
+: DeterminatorAction(basenode)
+{
+ attributes["logText"];
+ parseFromXml(basenode);
+}
+
+void logAction::execute() const
+{
+ writeLog(getAttribute("logText"), logLevel::debug);
+}
+
Added: xPLHAL/branches/thomas_s_dev/src/actions/logAction.h
===================================================================
--- xPLHAL/branches/thomas_s_dev/src/actions/logAction.h (rev 0)
+++ xPLHAL/branches/thomas_s_dev/src/actions/logAction.h 2012-03-04 18:48:31 UTC (rev 719)
@@ -0,0 +1,12 @@
+#pragma once
+#include "determinatoritems.h"
+
+class logAction: public DeterminatorAction<logAction>
+{
+ public:
+ logAction() {}
+ logAction(const pugi::xml_node& basenode);
+
+ void execute() const;
+};
+
Added: xPLHAL/branches/thomas_s_dev/src/actions/runScriptAction.cpp
===================================================================
--- xPLHAL/branches/thomas_s_dev/src/actions/runScriptAction.cpp (rev 0)
+++ xPLHAL/branches/thomas_s_dev/src/actions/runScriptAction.cpp 2012-03-04 18:48:31 UTC (rev 719)
@@ -0,0 +1,6 @@
+#include "runScriptAction.h"
+
+using std::string;
+using std::vector;
+using std::map;
+
Added: xPLHAL/branches/thomas_s_dev/src/actions/runScriptAction.h
===================================================================
--- xPLHAL/branches/thomas_s_dev/src/actions/runScriptAction.h (rev 0)
+++ xPLHAL/branches/thomas_s_dev/src/actions/runScriptAction.h 2012-03-04 18:48:31 UTC (rev 719)
@@ -0,0 +1,19 @@
+#pragma once
+#include "determinatoritems.h"
+
+class runScriptAction: public DeterminatorAction<runScriptAction>
+{
+ public:
+ runScriptAction() {}
+ runScriptAction(const pugi::xml_node& basenode) {
+ parseFromXml(basenode);
+ }
+ void execute() const;
+
+ void parseFromXml(const pugi::xml_node& basenode);
+ std::string toString() const;
+
+ std::string scriptName;
+ std::string parameter;
+};
+
Added: xPLHAL/branches/thomas_s_dev/src/actions/stopAction.cpp
===================================================================
--- xPLHAL/branches/thomas_s_dev/src/actions/stopAction.cpp (rev 0)
+++ xPLHAL/branches/thomas_s_dev/src/actions/stopAction.cpp 2012-03-04 18:48:31 UTC (rev 719)
@@ -0,0 +1,15 @@
+#include "stopAction.h"
+
+using std::string;
+
+stopAction::stopAction(const pugi::xml_node& basenode)
+: DeterminatorAction(basenode)
+{
+ parseFromXml(basenode);
+}
+
+void stopAction::execute() const
+{
+ throw AbortDeterminatorExecutionException();
+}
+
Added: xPLHAL/branches/thomas_s_dev/src/actions/stopAction.h
===================================================================
--- xPLHAL/branches/thomas_s_dev/src/actions/stopAction.h (rev 0)
+++ xPLHAL/branches/thomas_s_dev/src/actions/stopAction.h 2012-03-04 18:48:31 UTC (rev 719)
@@ -0,0 +1,11 @@
+#pragma once
+#include "determinatoritems.h"
+
+class stopAction: public DeterminatorAction<stopAction>
+{
+ public:
+ stopAction() {}
+ stopAction(const pugi::xml_node& basenode);
+ void execute() const;
+};
+
Added: xPLHAL/branches/thomas_s_dev/src/actions/suspendAction.cpp
===================================================================
--- xPLHAL/branches/thomas_s_dev/src/actions/suspendAction.cpp (rev 0)
+++ xPLHAL/branches/thomas_s_dev/src/actions/suspendAction.cpp 2012-03-04 18:48:31 UTC (rev 719)
@@ -0,0 +1,4 @@
+#include "suspendAction.h"
+
+using std::string;
+
Added: xPLHAL/branches/thomas_s_dev/src/actions/suspendAction.h
===================================================================
--- xPLHAL/branches/thomas_s_dev/src/actions/suspendAction.h (rev 0)
+++ xPLHAL/branches/thomas_s_dev/src/actions/suspendAction.h 2012-03-04 18:48:31 UTC (rev 719)
@@ -0,0 +1,19 @@
+#pragma once
+#include "determinatoritems.h"
+
+class suspendAction: public DeterminatorAction<suspendAction>
+{
+ public:
+ suspendAction() {}
+ suspendAction(const pugi::xml_node& basenode) {
+ parseFromXml(basenode);
+ }
+ void execute() const;
+
+ void parseFromXml(const pugi::xml_node& basenode);
+ std::string toString() const;
+
+ std::string suspendMinutes;
+ std::string suspendTime;
+ std::string suspendRandomise;
+};
Added: xPLHAL/branches/thomas_s_dev/src/actions/xplAction.cpp
===================================================================
--- xPLHAL/branches/thomas_s_dev/src/actions/xplAction.cpp (rev 0)
+++ xPLHAL/branches/thomas_s_dev/src/actions/xplAction.cpp 2012-03-04 18:48:31 UTC (rev 719)
@@ -0,0 +1,37 @@
+#include "xplAction.h"
+
+using std::string;
+using std::shared_ptr;
+using boost::regex;
+
+xplAction::xplAction(const pugi::xml_node& basenode)
+: DeterminatorAction(basenode)
+{
+ attributes["msg_type"] = {shared_ptr<regex>(new regex(R"(^(stat|trig|cmnd)$)"))};
+ attributes["msg_target"] = {shared_ptr<regex>(new regex(R"(^(\*|.*-.*\..*)$)"))};
+ attributes["msg_schema"] = {shared_ptr<regex>(new regex(R"(^(.*\..*)$)"))};
+ parseFromXml(basenode);
+}
+
+void xplAction::parseFromXml(const pugi::xml_node& basenode)
+{
+ DeterminatorAction::parseFromXml(basenode);
+ for(const auto node : basenode) {
+ if (node.name() == string("xplActionParam")) {
+ actionParams.push_back(node.attribute("expression").value());
+ }
+ }
+}
+
+std::string xplAction::toString() const
+{
+ string ret = BaseDeterminatorItem::toString();
+ for (auto ap : actionParams) {
+ ret += "\nxplActionParam: " + ap;
+ }
+ return ret;
+}
+
+void xplAction::execute() const
+{
+}
Added: xPLHAL/branches/thomas_s_dev/src/actions/xplAction.h
===================================================================
--- xPLHAL/branches/thomas_s_dev/src/actions/xplAction.h (rev 0)
+++ xPLHAL/branches/thomas_s_dev/src/actions/xplAction.h 2012-03-04 18:48:31 UTC (rev 719)
@@ -0,0 +1,16 @@
+#pragma once
+#include "determinatoritems.h"
+
+class xplAction: public DeterminatorAction<xplAction>
+{
+ public:
+ xplAction() {}
+ xplAction(const pugi::xml_node& basenode);
+
+ void execute() const;
+ void parseFromXml(const pugi::xml_node& basenode);
+ std::string toString() const;
+
+ std::list<std::string> actionParams;
+};
+
Added: xPLHAL/branches/thomas_s_dev/src/conditions/dayCondition.cpp
===================================================================
--- xPLHAL/branches/thomas_s_dev/src/conditions/dayCondition.cpp (rev 0)
+++ xPLHAL/branches/thomas_s_dev/src/conditions/dayCondition.cpp 2012-03-04 18:48:31 UTC (rev 719)
@@ -0,0 +1,10 @@
+#include "dayCondition.h"
+
+using std::string;
+
+dayCondition::dayCondition(const pugi::xml_node& basenode)
+{
+ attributes["dow"];
+ parseFromXml(basenode);
+}
+
Added: xPLHAL/branches/thomas_s_dev/src/conditions/dayCondition.h
===================================================================
--- xPLHAL/branches/thomas_s_dev/src/conditions/dayCondition.h (rev 0)
+++ xPLHAL/branches/thomas_s_dev/src/conditions/dayCondition.h 2012-03-04 18:48:31 UTC (rev 719)
@@ -0,0 +1,10 @@
+#pragma once
+#include "determinatoritems.h"
+
+class dayCondition: public DeterminatorCondition<dayCondition>
+{
+ public:
+ dayCondition() {}
+ dayCondition(const pugi::xml_node& basenode);
+};
+
Added: xPLHAL/branches/thomas_s_dev/src/conditions/globalChanged.cpp
===================================================================
--- xPLHAL/branches/thomas_s_dev/src/conditions/globalChanged.cpp (rev 0)
+++ xPLHAL/branches/thomas_s_dev/src/conditions/globalChanged.cpp 2012-03-04 18:48:31 UTC (rev 719)
@@ -0,0 +1,10 @@
+#include "globalChanged.h"
+
+using std::string;
+
+globalChanged::globalChanged(const pugi::xml_node& basenode)
+{
+ attributes["name"];
+ parseFromXml(basenode);
+}
+
Added: xPLHAL/branches/thomas_s_dev/src/conditions/globalChanged.h
===================================================================
--- xPLHAL/branches/thomas_s_dev/src/conditions/globalChanged.h (rev 0)
+++ xPLHAL/branches/thomas_s_dev/src/conditions/globalChanged.h 2012-03-04 18:48:31 UTC (rev 719)
@@ -0,0 +1,11 @@
+#pragma once
+#include "determinatoritems.h"
+
+class globalChanged: public DeterminatorCondition<globalChanged>
+{
+ public:
+ /* connect to signal of changed global variable */
+ globalChanged() {}
+ globalChanged(const pugi::xml_node& basenode);
+};
+
Added: xPLHAL/branches/thomas_s_dev/src/conditions/globalCondition.cpp
===================================================================
--- xPLHAL/branches/thomas_s_dev/src/conditions/globalCondition.cpp (rev 0)
+++ xPLHAL/branches/thomas_s_dev/src/conditions/globalCondition.cpp 2012-03-04 18:48:31 UTC (rev 719)
@@ -0,0 +1,13 @@
+#include "globalCondition.h"
+
+using std::string;
+using std::shared_ptr;
+using boost::regex;
+
+globalCondition::globalCondition(const pugi::xml_node& basenode)
+{
+ attributes["name"];
+ attributes["operator"] = {shared_ptr<regex>(new regex(R"(^(=|!=|<|>|<=|>=)$)"))};
+ attributes["value"];
+ parseFromXml(basenode);
+}
Added: xPLHAL/branches/thomas_s_dev/src/conditions/globalCondition.h
===================================================================
--- xPLHAL/branches/thomas_s_dev/src/conditions/globalCondition.h (rev 0)
+++ xPLHAL/branches/thomas_s_dev/src/conditions/globalCondition.h 2012-03-04 18:48:31 UTC (rev 719)
@@ -0,0 +1,10 @@
+#pragma once
+#include "determinatoritems.h"
+
+class globalCondition: public DeterminatorCondition<globalCondition>
+{
+ public:
+ globalCondition() {}
+ globalCondition(const pugi::xml_node& basenode);
+};
+
Added: xPLHAL/branches/thomas_s_dev/src/conditions/timeCondition.cpp
===================================================================
--- xPLHAL/branches/thomas_s_dev/src/conditions/timeCondition.cpp (rev 0)
+++ xPLHAL/branches/thomas_s_dev/src/conditions/timeCondition.cpp 2012-03-04 18:48:31 UTC (rev 719)
@@ -0,0 +1,22 @@
+#include "timeCondition.h"
+#include <boost/regex.hpp>
+#include <memory>
+#include <map>
+
+using std::string;
+using std::shared_ptr;
+using std::map;
+using boost::regex;
+using boost::regex_match;
+
+timeCondition::timeCondition(const pugi::xml_node& basenode)
+{
+ attributes["operator"] = {shared_ptr<regex>(new regex(R"(^(=|!=|<|>|<=|>=)$)"))};
+ attributes["value"] = {shared_ptr<regex>(new regex(R"(^\d{1,2}:\d{1,2}$)"))};
+
+ parseFromXml(basenode);
+}
+
+bool timeCondition::match() const
+{
+}
Added: xPLHAL/branches/thomas_s_dev/src/conditions/timeCondition.h
===================================================================
--- xPLHAL/branches/thomas_s_dev/src/conditions/timeCondition.h (rev 0)
+++ xPLHAL/branches/thomas_s_dev/src/conditions/timeCondition.h 2012-03-04 18:48:31 UTC (rev 719)
@@ -0,0 +1,12 @@
+#pragma once
+#include "determinatoritems.h"
+
+class timeCondition: public DeterminatorCondition<timeCondition>
+{
+ public:
+ timeCondition() {}
+ timeCondition(const pugi::xml_node& basenode);
+
+ virtual bool match() const;
+};
+
Added: xPLHAL/branches/thomas_s_dev/src/conditions/xplCondition.cpp
===================================================================
--- xPLHAL/branches/thomas_s_dev/src/conditions/xplCondition.cpp (rev 0)
+++ xPLHAL/branches/thomas_s_dev/src/conditions/xplCondition.cpp 2012-03-04 18:48:31 UTC (rev 719)
@@ -0,0 +1,43 @@
+#include "xplCondition.h"
+#include <iostream>
+
+using std::string;
+using std::cerr;
+
+xplCondition::xplCondition(const pugi::xml_node& basenode)
+{
+ attributes["msg_type"];
+ attributes["source_vendor"];
+ attributes["source_device"];
+ attributes["source_instance"];
+ attributes["target_vendor"];
+ attributes["target_device"];
+ attributes["target_instance"];
+ attributes["schema_class"];
+ attributes["schema_type"];
+ parseFromXml(basenode);
+}
+
+void xplCondition::parseFromXml(const pugi::xml_node& basenode)
+{
+ BaseDeterminatorItem::parseFromXml(basenode);
+ for(const auto node : basenode) {
+ if (node.name() == string("param")) {
+ struct parameter p;
+ p.name = node.attribute("name").value();
+ p.op = node.attribute("operator").value();
+ p.value = node.attribute("value").value();
+ parameter.push_back(p);
+ }
+ }
+}
+
+string xplCondition::toString() const
+{
+ string ret = BaseDeterminatorItem::toString();
+ for (auto p : parameter) {
+ ret +="\nparameter: " + p.name + p.op + p.value;
+ }
+ return ret;
+}
+
Added: xPLHAL/branches/thomas_s_dev/src/conditions/xplCondition.h
===================================================================
--- xPLHAL/branches/thomas_s_dev/src/conditions/xplCondition.h (rev 0)
+++ xPLHAL/branches/thomas_s_dev/src/conditions/xplCondition.h 2012-03-04 18:48:31 UTC (rev 719)
@@ -0,0 +1,22 @@
+#pragma once
+#include "determinatoritems.h"
+
+class xplCondition: public DeterminatorCondition<xplCondition>
+{
+ public:
+ xplCondition() {}
+ xplCondition(const pugi::xml_node& basenode);
+
+ void parseFromXml(const pugi::xml_node& basenode);
+ std::string toString() const;
+ /* connect to signal of new xpl-message */
+
+ struct parameter {
+ std::string name;
+ std::string op;
+ std::string value;
+ };
+
+ std::vector<struct parameter> parameter;
+};
+
Modified: xPLHAL/branches/thomas_s_dev/src/determinator.cpp
===================================================================
--- xPLHAL/branches/thomas_s_dev/src/determinator.cpp 2012-03-03 21:11:49 UTC (rev 718)
+++ xPLHAL/branches/thomas_s_dev/src/determinator.cpp 2012-03-04 18:48:31 UTC (rev 719)
@@ -4,6 +4,19 @@
#include <typeinfo>
#include <memory>
#include <functional>
+#include <algorithm>
+#include <thread>
+#include <future>
+#include "conditions/xplCondition.h"
+#include "conditions/globalCondition.h"
+#include "conditions/globalChanged.h"
+#include "conditions/dayCondition.h"
+#include "conditions/timeCondition.h"
+#include "actions/logAction.h"
+#include "actions/xplAction.h"
+#include "actions/delayAction.h"
+#include "actions/globalAction.h"
+#include "actions/stopAction.h"
using std::string;
using std::vector;
@@ -35,17 +48,20 @@
DeterminatorXmlParser::DeterminatorXmlParser(const string& filename)
{
- registerCondition(BaseDeterminatorItemConstPtr(new XplCondition));
- registerCondition(BaseDeterminatorItemConstPtr(new GlobalCondition));
- registerCondition(BaseDeterminatorItemConstPtr(new GlobalChanged));
- registerCondition(BaseDeterminatorItemConstPtr(new DayCondition));
- registerCondition(BaseDeterminatorItemConstPtr(new TimeCondition));
+ registerCondition(BaseDeterminatorItemConstPtr(new xplCondition));
+ registerCondition(BaseDeterminatorItemConstPtr(new globalCondition));
+ registerCondition(BaseDeterminatorItemConstPtr(new globalChanged));
+ registerCondition(BaseDeterminatorItemConstPtr(new dayCondition));
+ registerCondition(BaseDeterminatorItemConstPtr(new timeCondition));
registerAction(BaseDeterminatorItemConstPtr(new logAction));
registerAction(BaseDeterminatorItemConstPtr(new xplAction));
+ registerAction(BaseDeterminatorItemConstPtr(new delayAction));
+ registerAction(BaseDeterminatorItemConstPtr(new globalAction));
+ registerAction(BaseDeterminatorItemConstPtr(new stopAction));
pugi::xml_parse_result result = m_doc.load_file(filename.c_str());
- cerr << "Load result: " << result.description() << "\n";
+// cerr << "Load result: " << result.description() << "\n";
}
void DeterminatorXmlParser::registerCondition(BaseDeterminatorItemConstPtr condition)
@@ -95,7 +111,7 @@
}
}
- d.printDeterminator();
+ //d.printDeterminator();
return d;
}
@@ -125,8 +141,8 @@
Determinator::~Determinator()
{
- if (mExecuteThread) {
- mExecuteThread->join();
+ if (!mExecFutures.empty()) {
+ mExecFutures[0].wait();
}
}
@@ -142,35 +158,42 @@
return (input_match_type == match_type::ALL);
}
-void Determinator::executeOutputs() const
+bool Determinator::executeOutputs() const
{
std::multimap<string, BaseDeterminatorItemPtr> orderd_outputs;
for (auto output : outputs) {
string execOrder;
auto execOrderIter = output.second->attributes.find("executeOrder");
if (execOrderIter != output.second->attributes.end()) {
- execOrder = execOrderIter->second;
+ execOrder = execOrderIter->second.value;
}
orderd_outputs.insert({execOrder, output.second});
}
- for (auto output : orderd_outputs) {
- cerr << "execute output:" << output.second->display_name << endl;
- output.second->execute();
+ try {
+ for (auto output : orderd_outputs) {
+ cerr << "execute output:" << output.second->getAttribute("display_name") << endl;
+ output.second->execute();
+ }
+ } catch (const AbortDeterminatorExecutionException &e) {
+ return false;
}
+ return true;
}
+
/**
* Check if input conditions are met, then start a thread to execute actions
*/
void Determinator::execute()
{
if (checkInputs()) {
- if (mExecuteThread) {
- mExecuteThread->join();
+ if (mExecFutures.empty() || mExecFutures[0].valid()) {
+ mExecFutures.erase(mExecFutures.begin(), mExecFutures.end());
+ cerr << "determinator start thread" << endl;
+ mExecFutures.push_back(std::async(std::launch::async, std::bind(&Determinator::executeOutputs, this)));
+ cerr << "determinator start thread" << endl;
}
- cerr << "determinator start thread" << endl;
- mExecuteThread.reset(new thread(bind(&Determinator::executeOutputs, this)));
}
}
Modified: xPLHAL/branches/thomas_s_dev/src/determinator.h
===================================================================
--- xPLHAL/branches/thomas_s_dev/src/determinator.h 2012-03-03 21:11:49 UTC (rev 718)
+++ xPLHAL/branches/thomas_s_dev/src/determinator.h 2012-03-04 18:48:31 UTC (rev 719)
@@ -5,6 +5,7 @@
#include <vector>
#include <map>
#include <thread>
+#include <future>
class Determinator
{
@@ -29,11 +30,14 @@
private:
bool checkInputs() const;
- void executeOutputs() const;
-
- std::unique_ptr<std::thread> mExecuteThread;
+ bool executeOutputs() const;
+
+ std::vector<std::future<bool>> mExecFutures;
};
+typedef std::shared_ptr<Determinator> DeterminatorPtr;
+typedef std::shared_ptr<const Determinator> DeterminatorConstPtr;
+
class DeterminatorXmlParser
{
public:
Added: xPLHAL/branches/thomas_s_dev/src/determinator_manager.cpp
===================================================================
--- xPLHAL/branches/thomas_s_dev/src/determinator_manager.cpp (rev 0)
+++ xPLHAL/branches/thomas_s_dev/src/determinator_manager.cpp 2012-03-04 18:48:31 UTC (rev 719)
@@ -0,0 +1,58 @@
+#include "determinator_manager.h"
+#include "determinator.h"
+#include <boost/filesystem.hpp>
+#include <boost/filesystem/fstream.hpp>
+#include <iostream>
+
+using std::cout;
+using boost::filesystem::path;
+using boost::filesystem::exists;
+using boost::filesystem::filesystem_error;
+using boost::filesystem::is_regular_file;
+using boost::filesystem::is_directory;
+using boost::filesystem::directory_iterator;
+using boost::filesystem::ifstream;
+
+DeterminatorManager::DeterminatorManager(const std::string& determinatorDirectory)
+:mDeterminatorDirectory(determinatorDirectory)
+{
+}
+
+void DeterminatorManager::loadDeterminators()
+{
+ path p(mDeterminatorDirectory);
+ try {
+ if (exists(p)) {
+ if (is_regular_file(p)) {
+ cout << p << " is regular file\n";
+ }
+ else if (is_directory(p)) {
+ cout << p << " directory containing:\n";
+
+ for (auto item = directory_iterator(p); item != directory_iterator(); ++item) {
+ ifstream determinatorFile(*item);
+ std::string filename = item->string();
+ //storeXmlDeterminator("guid", determinatorFile.read());
+ cout << "diritem: " << *item << "\n";
+ DeterminatorXmlParser parser(filename);
+ Determinator d = parser.parse();
+ }
+ }
+ else {
+ cout << p << " exists, but is neither a regular file nor a directory\n";
+ }
+ }
+ }
+ catch (const filesystem_error& ex) {
+
+ }
+}
+
+std::string DeterminatorManager::getXmlDeterminator(const std::string& guid) const
+{
+}
+
+void DeterminatorManager::storeXmlDeterminator(const std::string& guid, const std::string& xmlDeterminator)
+{
+}
+
Added: xPLHAL/branches/thomas_s_dev/src/determinator_manager.h
===================================================================
--- xPLHAL/branches/thomas_s_dev/src/determinator_manager.h (rev 0)
+++ xPLHAL/branches/thomas_s_dev/src/determinator_manager.h 2012-03-04 18:48:31 UTC (rev 719)
@@ -0,0 +1,26 @@
+#pragma once
+#include "determinator.h"
+#include <string>
+#include <map>
+#include <boost/signals2/signal.hpp>
+#include "xplhandler.h"
+
+class DeterminatorManager
+{
+ public:
+ DeterminatorManager(const std::string& determinatorDirectory);
+
+ void loadDeterminators();
+
+// DeterminatorConstPtr getDeterminator(const std::string& guid) const;
+ std::string getXmlDeterminator(const std::string& guid) const;
+ void storeXmlDeterminator(const std::string& guid, const std::string& xmlDeterminator);
+
+ public:
+ xPLHandler::signal_t m_sigRceivedXplMessage;
+
+ private:
+ std::string mDeterminatorDirectory;
+ std::map<std::string, DeterminatorPtr> mDeterminators;
+
+};
Modified: xPLHAL/branches/thomas_s_dev/src/determinatoritems.cpp
===================================================================
--- xPLHAL/branches/thomas_s_dev/src/determinatoritems.cpp 2012-03-03 21:11:49 UTC (rev 718)
+++ xPLHAL/branches/thomas_s_dev/src/determinatoritems.cpp 2012-03-04 18:48:31 UTC (rev 719)
@@ -8,6 +8,7 @@
using std::string;
using std::vector;
using std::map;
+using std::cerr;
DeterminatorParseException::DeterminatorParseException(const string& text)
:m_text(text)
@@ -19,286 +20,66 @@
return m_text.c_str();
}
-
-class ScopedXmlAttributeGetter
-{
- public:
- ScopedXmlAttributeGetter(const pugi::xml_node& basenode, map<string, string> &attributemap)
- :m_basenode(basenode),m_attributemap(attributemap) {}
- string get(const string& attribute_name) const {
- pugi::xml_attribute xml_attribute = m_basenode.attribute(attribute_name.c_str());
- if (!xml_attribute) {
- string error_text = string("In node '") + m_basenode.name() + "'";
- error_text += " attribute '" + attribute_name + "' was not found";
- throw DeterminatorParseException(error_text);
- }
- m_attributemap.insert({attribute_name, xml_attribute.value()});
- return xml_attribute.value();
- }
- private:
- const pugi::xml_node& m_basenode;
- map<string, string> &m_attributemap;
-};
-
BaseDeterminatorItem::BaseDeterminatorItem(const string& name)
:item_name(name)
{
+ attributes["display_name"] = {};
}
BaseDeterminatorItem::BaseDeterminatorItem(const pugi::xml_node& basenode, const string& name)
:item_name(name)
{
- ScopedXmlAttributeGetter a(basenode, attributes);
- display_name = a.get("display_name");
+ attributes["display_name"] = {};
}
-bool BaseDeterminatorItem::match() const
+void BaseDeterminatorItem::parseFromXml(const pugi::xml_node& basenode)
{
- return true;
-}
+ for (auto &ai: attributes) {
+ const string attribute_name = ai.first;
+ pugi::xml_attribute xml_attribute = basenode.attribute(attribute_name.c_str());
-void BaseDeterminatorItem::execute() const
-{
-}
+ if (!xml_attribute) {
+ string error_text = string("In node '") + basenode.name() + "'";
+ error_text += " attribute '" + attribute_name + "' was not found";
+ throw DeterminatorParseException(error_text);
+ }
-/*
- * Determinator Conditions
- */
-
-XplCondition::XplCondition()
-:BaseDeterminatorItem("xplCondition")
-{
-}
-
-XplCondition::XplCondition(const pugi::xml_node& basenode)
-:BaseDeterminatorItem(basenode, "xplCondition")
-{
- parseFromXml(basenode);
-}
+ ai.second.value = xml_attribute.value();
-BaseDeterminatorItemPtr XplCondition::createNew(const pugi::xml_node& basenode) const
-{
- return BaseDeterminatorItemPtr(new XplCondition(basenode));
-}
-
-void XplCondition::parseFromXml(const pugi::xml_node& basenode)
-{
- ScopedXmlAttributeGetter helper(basenode, attributes);
- msg_type = helper.get("msg_type");
- source_vendor = helper.get("source_vendor");
- source_device = helper.get("source_device");
- source_instance = helper.get("source_instance");
- target_vendor = helper.get("target_vendor");
- target_device = helper.get("target_device");
- target_instance = helper.get("target_instance");
- schema_class = helper.get("schema_class");
- schema_type = helper.get("schema_type");
-
- for(const auto node : basenode) {
- if (node.name() == string("param")) {
- struct parameter p;
- ScopedXmlAttributeGetter pa(node, attributes);
- p.name = pa.get("name");
- p.op = pa.get("operator");
- p.value = pa.get("value");
- parameter.push_back(p);
+ if (ai.second.re.get() != nullptr) {
+ if (! regex_match(ai.second.value, *ai.second.re)) {
+ string error_text = string("In node '") + basenode.name() + "'";
+ error_text += " invalid value for attribute '" + ai.first + "' value: '" + ai.second.value + "'.";
+ throw DeterminatorParseException(error_text);
+ }
}
}
}
-string XplCondition::toString() const
+bool BaseDeterminatorItem::match() const
{
- string ret = "xplCondition:";
- ret += "\nmsg_type: " + msg_type;
- ret += "\nsource_vendor: " + source_vendor;
- ret += "\nsource_device: " + source_device;
- ret += "\nsource_instance: " + source_instance;
- ret += "\ntarget_vendor: " + target_vendor;
- ret += "\ntarget_device: " + target_device;
- ret += "\ntarget_instance: " + target_instance;
- ret += "\nschema_class: " + schema_class;
- ret += "\nschema_type: " + schema_type;
- for (auto p : parameter) {
- ret +="\nparameter: " + p.name + p.op + p.value;
- }
- return ret;
+ return true;
}
-
-GlobalCondition::GlobalCondition()
-:BaseDeterminatorItem("globalCondition")
-{
-}
-GlobalCondition::GlobalCondition(const pugi::xml_node& basenode)
-:BaseDeterminatorItem(basenode, "globalCondition")
+void BaseDeterminatorItem::execute() const
{
- parseFromXml(basenode);
}
-BaseDeterminatorItemPtr GlobalCondition::createNew(const pugi::xml_node& basenode) const
+std::string BaseDeterminatorItem::getAttribute(const std::string& attrname) const
{
- return BaseDeterminatorItemPtr(new GlobalCondition(basenode));
-}
-
-void GlobalCondition::parseFromXml(const pugi::xml_node& basenode)
-{
- ScopedXmlAttributeGetter helper(basenode, attributes);
- name = helper.get("name");
- op = helper.get("operator");
- value = helper.get("value");
-}
-
-string GlobalCondition::toString() const
-{
- string ret = item_name + ":";
- ret += "\nname: " + name;
- ret += "\noperator: " + op;
- ret += "\nvalue: " + value;
- return ret;
-}
-
-GlobalChanged::GlobalChanged()
-:BaseDeterminatorItem("globalChanged")
-{
-}
-
-GlobalChanged::GlobalChanged(const pugi::xml_node& basenode)
-:BaseDeterminatorItem(basenode, "globalChanged")
-{
- parseFromXml(basenode);
-}
-
-BaseDeterminatorItemPtr GlobalChanged::createNew(const pugi::xml_node& basenode) const
-{
- return BaseDeterminatorItemPtr(new GlobalChanged(basenode));
-}
-
-void GlobalChanged::parseFromXml(const pugi::xml_node& basenode)
-{
- ScopedXmlAttributeGetter helper(basenode, attributes);
- name = helper.get("name");
-}
-
-string GlobalChanged::toString() const
-{
- string ret = item_name + ":";
- ret += "\nname: " + name;
- return ret;
-}
-
-
-DayCondition::DayCondition()
-:BaseDeterminatorItem("dayCondition")
-{
-}
-
-DayCondition::DayCondition(const pugi::xml_node& basenode)
-:BaseDeterminatorItem(basenode, "dayCondition")
-{
- parseFromXml(basenode);
-}
-
-BaseDeterminatorItemPtr DayCondition::createNew(const pugi::xml_node& basenode) const
-{
- return BaseDeterminatorItemPtr(new DayCondition(basenode));
-}
-
-void DayCondition::parseFromXml(const pugi::xml_node& basenode)
-{
- ScopedXmlAttributeGetter helper(basenode, attributes);
- dow = helper.get("dow");
-}
-
-string DayCondition::toString() const
-{
- string ret = item_name + ":";
- ret += "\ndow: " + dow;
- return ret;
-}
-
-TimeCondition::TimeCondition()
-:BaseDeterminatorItem("timeCondition")
-{
-}
-
-TimeCondition::TimeCondition(const pugi::xml_node& basenode)
- :BaseDeterminatorItem(basenode, "timeCondition")
-{
- parseFromXml(basenode);
-}
-
-BaseDeterminatorItemPtr TimeCondition::createNew(const pugi::xml_node& basenode) const
-{
- return BaseDeterminatorItemPtr(new TimeCondition(basenode));
-}
-
-void TimeCondition::parseFromXml(const pugi::xml_node& basenode)
-{
- ScopedXmlAttributeGetter helper(basenode, attributes);
- op = helper.get("operator");
- value = helper.get("value");
-}
-
-string TimeCondition::toString() const
-{
- string ret = item_name + ":";
- ret += "\noperator: " + op;
- ret += "\nvalue...: " + value;
- return ret;
-}
-
-/*
- * Determinator Actions
- */
-
-void logAction::parseFromXml(const pugi::xml_node& basenode)
-{
- ScopedXmlAttributeGetter helper(basenode, attributes);
- logText = helper.get("logText");
- executeOrder = helper.get("executeOrder");
-}
-
-std::string logAction::toString() const
-{
- string ret = item_name + ":";
- ret += "\nlogText.....: " + logText;
- ret += "\nexecuteOrder: " + executeOrder;
- return ret;
-}
-
-void logAction::execute() const
-{
- writeLog(logText, logLevel::debug);
-}
-
-//-----
-
-void xplAction::parseFromXml(const pugi::xml_node& basenode)
-{
- ScopedXmlAttributeGetter helper(basenode, attributes);
- executeOrder = helper.get("executeOrder");
- msgType = helper.get("msgType");
- msgTarget = helper.get("msgTarget");
- msgSchema = helper.get("msgSchema");
-
- for(const auto node : basenode) {
- if (node.name() == string("xplActionParam")) {
- string expression = node.attribute("expression").value();
- }
+ auto iter = attributes.find(attrname);
+ if (iter == attributes.end()) {
+ return "";
}
+ return iter->second.value;
}
-std::string xplAction::toString() const
+string BaseDeterminatorItem::toString() const
{
string ret = item_name + ":";
- ret += "\nexecuteOrder: " + executeOrder;
- ret += "\nmsgType.....: " + msgType;
- ret += "\nmsgTarget...: " + msgTarget;
- ret += "\nmsgSchema...: " + msgSchema;
+ for (auto iter : attributes) {
+ ret += "\n" + iter.first + ": " + iter.second.value;
+ }
return ret;
}
-void xplAction::execute() const
-{
-}
-
Modified: xPLHAL/branches/thomas_s_dev/src/determinatoritems.h
===================================================================
--- xPLHAL/branches/thomas_s_dev/src/determinatoritems.h 2012-03-03 21:11:49 UTC (rev 718)
+++ xPLHAL/branches/thomas_s_dev/src/determinatoritems.h 2012-03-04 18:48:31 UTC (rev 719)
@@ -4,6 +4,8 @@
#include <vector>
#include <memory>
#include <map>
+#include <cxxabi.h>
+#include <boost/regex.hpp>
class DeterminatorParseException: public std::exception
{
@@ -14,6 +16,8 @@
private:
std::string m_text;
};
+
+class AbortDeterminatorExecutionException: public std::exception {};
class BaseDeterminatorItem;
typedef std::shared_ptr<BaseDeterminatorItem> BaseDeterminatorItemPtr;
@@ -24,18 +28,27 @@
public:
BaseDeterminatorItem(const std::string& name);
BaseDeterminatorItem(const pugi::xml_node& basenode, const std::string& name);
-
- virtual void parseFromXml(const pugi::xml_node& basenode) = 0;
+
virtual BaseDeterminatorItemPtr createNew(const pugi::xml_node& basenode) const = 0;
- virtual std::string toString() const = 0;
+
+ virtual std::string toString() const;
+ virtual void parseFromXml(const pugi::xml_node& basenode);
virtual bool match() const;
virtual void execute() const;
+ struct di_attribute {
+ std::shared_ptr<boost::regex> re;
+ std::string value;
+ };
+
std::string item_name;
- std::string display_name;
- std::map<std::string, std::string> attributes;
+ std::string getAttribute(const std::string& attrname) const;
+ std::map<std::string, struct di_attribute> attributes;
+
+
+
//boost::signal2::signal<void ()> sigChanged;
};
@@ -43,237 +56,26 @@
class DeterminatorAction: public BaseDeterminatorItem
{
public:
- DeterminatorAction() :BaseDeterminatorItem(typeid(T).name()) { }
+ DeterminatorAction() :BaseDeterminatorItem(abi::__cxa_demangle(typeid(T).name(), 0, 0, 0)) { }
DeterminatorAction(const pugi::xml_node& basenode)
- :BaseDeterminatorItem(basenode, std::string(typeid(T).name())) {
- executeOrder = basenode.attribute("executeOrder").value();
- attributes["executeOrder"] = executeOrder;
+ :BaseDeterminatorItem(basenode, std::string(abi::__cxa_demangle(typeid(T).name(), 0, 0, 0))) {
+ attributes["executeOrder"];
}
BaseDeterminatorItemPtr createNew(const pugi::xml_node& basenode) const {
return BaseDeterminatorItemPtr(new T(basenode));
}
-
- std::string executeOrder;
};
-
-/*
- * Conditions
- */
-
-class XplCondition: public BaseDeterminatorItem
+template<typename T>
+class DeterminatorCondition: public BaseDeterminatorItem
{
public:
- XplCondition();
- XplCondition(const pugi::xml_node& basenode);
-
- virtual BaseDeterminatorItemPtr createNew(const pugi::xml_node& basenode) const;
+ DeterminatorCondition() :BaseDeterminatorItem(abi::__cxa_demangle(typeid(T).name(), 0, 0, 0)) { }
+ DeterminatorCondition(const pugi::xml_node& basenode)
+ :BaseDeterminatorItem(basenode, std::string(abi::__cxa_demangle(typeid(T).name(), 0, 0, 0))) { }
- void parseFromXml(const pugi::xml_node& basenode);
-
- std::string toString() const;
-
- /* connect to signal of new xpl-message */
- std::string msg_type;
- std::string source_vendor;
- std::string source_device;
- std::string source_instance;
- std::string target_vendor;
- std::string target_device;
- std::string target_instance;
- std::string schema_class;
- std::string schema_type;
-
- struct parameter {
- std::string name;
- std::string op;
- std::string value;
- };
-
- std::vector<struct parameter> parameter;
-};
-
-class GlobalCondition: public BaseDeterminatorItem
-{
- public:
- GlobalCondition();
- GlobalCondition(const pugi::xml_node& basenode);
-
- virtual BaseDeterminatorItemPtr createNew(const pugi::xml_node& basenode) const;
-
- void parseFromXml(const pugi::xml_node& basenode);
-
- std::string toString() const;
-
- std::string name;
- std::string op;
- std::string value;
-};
-
-class GlobalChanged: public BaseDeterminatorItem
-{
- public:
- /* connect to signal of changed global variable */
- GlobalChanged();
- GlobalChanged(const pugi::xml_node& basenode);
-
- virtual BaseDeterminatorItemPtr createNew(const pugi::xml_node& basenode) const;
- void parseFromXml(const pugi::xml_node& basenode);
- std::string toString() const;
-
- std::string name;
-};
-
-class DayCondition: public BaseDeterminatorItem
-{
- public:
- DayCondition();
- DayCondition(const pugi::xml_node& basenode);
-
- virtual BaseDeterminatorItemPtr createNew(const pugi::xml_node& basenode) const;
- void parseFromXml(const pugi::xml_node& basenode);
- std::string toString() const;
-
- std::string dow;
-};
-
-class TimeCondition: public BaseDeterminatorItem
-{
- public:
- TimeCondition();
- TimeCondition(const pugi::xml_node& basenode);
-
- virtual BaseDeterminatorItemPtr createNew(const pugi::xml_node& basenode) const;
- void parseFromXml(const pugi::xml_node& basenode);
- std::string toString() const;
-
- std::string op;
- std::string value;
-};
-
-/*
- * Actions
- */
-
-class logAction: public DeterminatorAction<logAction>
-{
- public:
- logAction() {}
- logAction(const pugi::xml_node& basenode) : DeterminatorAction(basenode) {
- parseFromXml(basenode);
+ BaseDeterminatorItemPtr createNew(const pugi::xml_node& basenode) const {
+ return BaseDeterminatorItemPtr(new T(basenode));
}
-
- void execute() const;
- void parseFromXml(const pugi::xml_node& basenode);
- std::string toString() const;
-
- std::string logText;
- std::string executeOrder;
};
-
-class xplAction: public DeterminatorAction<xplAction>
-{
- public:
- xplAction() {}
- xplAction(const pugi::xml_node& basenode) : DeterminatorAction(basenode) {
- parseFromXml(basenode);
- }
-
- void execute() const;
- void parseFromXml(const pugi::xml_node& basenode);
- std::string toString() const;
-
- std::string msgType;
- std::string msgTarget;
- std::string msgSchema;
- std::multimap<std::string, std::string> actionParams;
-};
-
-class globalAction: public DeterminatorAction<globalAction>
-{
- public:
- globalAction();
- globalAction(const pugi::xml_node& basenode);
- void execute() const;
-
- virtual BaseDeterminatorItemPtr createNew(const pugi::xml_node& basenode) const;
- void parseFromXml(const pugi::xml_node& basenode);
- std::string toString() const;
-
- std::string name;
- std::string value;
-};
-
-class delayAction: public DeterminatorAction<delayAction>
-{
- public:
- delayAction();
- delayAction(const pugi::xml_node& basenode);
- void execute() const;
-
- virtual BaseDeterminatorItemPtr createNew(const pugi::xml_node& basenode) const;
- void parseFromXml(const pugi::xml_node& basenode);
- std::string toString() const;
-
- std::string delaySeconds;
-};
-
-class stopAction: public DeterminatorAction<stopAction>
-{
- public:
- stopAction();
- stopAction(const pugi::xml_node& basenode);
- void execute() const;
-
- virtual BaseDeterminatorItemPtr createNew(const pugi::xml_node& basenode) const;
- void parseFromXml(const pugi::xml_node& basenode);
- std::string toString() const;
-
-};
-
-class suspendAction: public DeterminatorAction<suspendAction>
-{
- public:
- suspendAction();
- suspendAction(const pugi::xml_node& basenode);
- void execute() const;
-
- virtual BaseDeterminatorItemPtr createNew(const pugi::xml_node& basenode) const;
- void parseFromXml(const pugi::xml_node& basenode);
- std::string toString() const;
-
- std::string suspendMinutes;
- std::string suspendTime;
- std::string suspendRandomise;
-};
-
-class execRuleAction: public DeterminatorAction<execRuleAction>
-{
- public:
- execRuleAction();
- execRuleAction(const pugi::xml_node& basenode);
- void execute() const;
-
- virtual BaseDeterminatorItemPtr createNew(const pugi::xml_node& basenode) const;
- void parseFromXml(const pugi::xml_node& basenode);
- std::string toString() const;
-
- std::string ruleName;
-};
-
-class runScriptAction: public DeterminatorAction<runScriptAction>
-{
- public:
- runScriptAction();
- runScriptAction(const pugi::xml_node& basenode);
- void execute() const;
-
- virtual BaseDeterminatorItemPtr createNew(const pugi::xml_node& basenode) const;
- void parseFromXml(const pugi::xml_node& basenode);
- std::string toString() const;
-
- std::string scriptName;
- std::string parameter;
-};
-
Modified: xPLHAL/branches/thomas_s_dev/src/main.cpp
===================================================================
--- xPLHAL/branches/thomas_s_dev/src/main.cpp 2012-03-03 21:11:49 UTC (rev 718)
+++ xPLHAL/branches/thomas_s_dev/src/main.cpp 2012-03-04 18:48:31 UTC (rev 719)
@@ -19,6 +19,7 @@
#include <boost/program_options.hpp>
#include "log.h"
#include "devicemanager.h"
+#include "determinator_manager.h"
#include "xhcp.h"
#include "recurring_timer.h"
#include "xplhandler.h"
@@ -55,11 +56,14 @@
,mDeviceManager(mXplCache)
,mXHCPServer(new XHCPServer(m_ioservice, &mDeviceManager))
,mXpl(new xPLHandler(m_ioservice, boost::asio::ip::host_name() ))
+ ,mDeterminatorManager("data")
,mTimerListAllObjects(m_ioservice, boost::posix_time::seconds(60), true)
,mTimerFlushExpiredEntries(m_ioservice, boost::posix_time::minutes(5), true)
+
{
mDeviceManager.m_sigSendXplMessage.connect(boost::bind(&xPLHandler::sendMessage, mXpl, _1));
mXpl->m_sigRceivedXplMessage.connect(boost::bind(&DeviceManager::processXplMessage, &mDeviceManager, _1));
+ mXpl->m_sigRceivedXplMessage.connect(mDeterminatorManager.m_sigRceivedXplMessage);
installTimer();
/* set global variables */
@@ -123,6 +127,7 @@
DeviceManager mDeviceManager;
XHCPServer *mXHCPServer;
xPLHandler *mXpl;
+ DeterminatorManager mDeterminatorManager;
RecurringTimer mTimerListAllObjects;
RecurringTimer mTimerFlushExpiredEntries;
Modified: xPLHAL/branches/thomas_s_dev/src/xplmessage.h
===================================================================
--- xPLHAL/branches/thomas_s_dev/src/xplmessage.h 2012-03-03 21:11:49 UTC (rev 718)
+++ xPLHAL/branches/thomas_s_dev/src/xplmessage.h 2012-03-04 18:48:31 UTC (rev 719)
@@ -19,7 +19,7 @@
#include <vector>
#include <string>
-#include <boost/shared_ptr.hpp>
+#include <memory>
extern "C" {
#define COMMON_TYPES
@@ -102,6 +102,6 @@
operator std::string() const;
bool operator==(const xPLMessage& right) const;
};
-typedef boost::shared_ptr<xPLMessage> xPLMessagePtr;
+typedef std::shared_ptr<xPLMessage> xPLMessagePtr;
std::ostream& operator<<(std::ostream& os, const xPLMessage& msg);
Modified: xPLHAL/branches/thomas_s_dev/src/xplmessagequeue.cpp
===================================================================
--- xPLHAL/branches/thomas_s_dev/src/xplmessagequeue.cpp 2012-03-03 21:11:49 UTC (rev 718)
+++ xPLHAL/branches/thomas_s_dev/src/xplmessagequeue.cpp 2012-03-04 18:48:31 UTC (rev 719)
@@ -25,7 +25,6 @@
using std::lock_guard;
XplMessageQueue::XplMessageQueue()
-:mPipeFD({0})
{
pipe(mPipeFD);
}
Modified: xPLHAL/branches/thomas_s_dev/src/xplmessagequeue.h
===================================================================
--- xPLHAL/branches/thomas_s_dev/src/xplmessagequeue.h 2012-03-03 21:11:49 UTC (rev 718)
+++ xPLHAL/branches/thomas_s_dev/src/xplmessagequeue.h 2012-03-04 18:48:31 UTC (rev 719)
@@ -21,6 +21,8 @@
#include <queue>
#include <string>
#include <thread>
+#include <mutex>
+#include <memory>
#include "xplmessage.h"
@@ -48,6 +50,6 @@
/** \brief variable to ensure that the queue is thread save... */
mutable std::mutex queueLock;
std::queue<xPLMessagePtr> xPLMessages;
- int mPipeFD[2];
+ int mPipeFD[2];// = {0};
};
Modified: xPLHAL/branches/thomas_s_dev/test/CMakeLists.txt
===================================================================
--- xPLHAL/branches/thomas_s_dev/test/CMakeLists.txt 2012-03-03 21:11:49 UTC (rev 718)
+++ xPLHAL/branches/thomas_s_dev/test/CMakeLists.txt 2012-03-04 18:48:31 UTC (rev 719)
@@ -21,10 +21,13 @@
find_package(Boost COMPONENTS unit_test_framework REQUIRED)
file(GLOB_RECURSE UnitTests_sources *.cpp)
+file(GLOB_RECURSE Action_sources ../src/actions/*.cpp)
+file(GLOB_RECURSE Condition_sources ../src/conditions/*.cpp)
#set(UnitTest_tsrc ../src/devicemanager.cpp ../src/xplcache.cpp ../src/xplhandler.cpp ../src/xplmessagequeue.cpp)
set(UnitTest_tsrc ../src/devicemanager.cpp ../src/xplmessage.cpp ../src/determinator.cpp
- ../src/determinatoritems.cpp ../src/pugixml.cpp)
+ ../src/determinatoritems.cpp ../src/pugixml.cpp ../src/determinator_manager.cpp
+ ${Action_sources} ${Condition_sources})
add_executable(test_runner ${UnitTests_sources} ${UnitTest_tsrc})
@@ -32,7 +35,7 @@
enable_testing()
-set(CMAKE_CXX_FLAGS "-g -std=c++0x -fprofile-arcs -ftest-coverage")
+set(CMAKE_CXX_FLAGS "-g -Os -std=c++0x -fprofile-arcs -ftest-coverage")
#set(xPLHALTest_SRCS test_test.cpp test_xplcache.cpp)
#add_executable(test_runner ${xPLHALTest_SRCS})
#message(STATUS "Boost_LIBRARIES=${Boost_LIBRARIES}")
Modified: xPLHAL/branches/thomas_s_dev/test/determinator1.xml
===================================================================
--- xPLHAL/branches/thomas_s_dev/test/determinator1.xml 2012-03-03 21:11:49 UTC (rev 718)
+++ xPLHAL/branches/thomas_s_dev/test/determinator1.xml 2012-03-04 18:48:31 UTC (rev 719)
@@ -17,6 +17,7 @@
logText="text to log"
executeOrder="nnn"
/>
+ <stopAction display_name="stopAction" executeOrder="Z" />
</output>
</determinator>
</xplDeterminator>
Added: xPLHAL/branches/thomas_s_dev/test/determinatorAll.xml
===================================================================
--- xPLHAL/branches/thomas_s_dev/test/determinatorAll.xml (rev 0)
+++ xPLHAL/branches/thomas_s_dev/test/determinatorAll.xml 2012-03-04 18:48:31 UTC (rev 719)
@@ -0,0 +1,232 @@
+<!--
+***************************************
+* xPL Determinator Specification
+*
+* Revision 0.9
+*
+* Copyright (C) 2004-2006 John Bent
+*
+***************************************
+-->
+<xplDeterminator> <!-- All xPL Determinator files must have <xplDeterminator> as their top-level element -->
+<!-- The <determinator> element is the container element for a determinator rule.
+
+ The guid attribute specifies the GUID that uniquely identifies this determinator.
+ When a client creates a new determinator, it must omit the guid attribute (or specify it as an empty string), and the
+ server will fill it with an appropriate value when the determinator is submitted.
+
+ The name attribute specifies the name of the determinator (see notes below on groups of determinators).
+ The description attribute specifies a more verbose description, and may be empty.
+ The enabled attribute contains either Y or N, and is used to specify whether the
+ determinator should be executed when it's input conditions are true.
+
+ The groupName attribute specifies whether this determinator belongs to a group.
+ If it is an empty string, the determinator is placed at the top of the hierarchy.
+
+ The isGroup attribute specifies whether this is a determinator, or a determinator group.
+ For normal determinators, it should be set to N.
+ For groups, it should be set to Y.
+ When specifying a determinator group, no input or output sections are required.
+ The name attribute should be used to specify the name of the group.
+ Group names can be hierarchical, using a slash (/) as the hierarchy separator.
+
+-->
+<determinator
+ guid="rule-guid"
+ name="rule-name"
+ description="rule-description"
+ enabled="Y"
+ groupName=""
+ isGroup="N">
+
+ <input match="all">
+ <!-- The <input> section describes the conditions which must be true for the output section of this
+ determinator to be executed.
+ -->
+
+ <!-- The <xplCondition> element is used to allow the rule to match specific xPL messages -->
+ <xplCondition
+ display_name="condition-name"
+ msg_type="cmnd"
+ source_vendor="pnxs"
+ source_device="device"
+ source_instance="instance"
+ target_vendor="vendor"
+ target_device="device"
+ target_instance="instance"
+ schema_class="class"
+ schema_type="type">
+ <!-- One or more <param> elements may appear to allow matching on specific parameters within the body of a message -->
+ <param
+ name="parameter-name"
+ operator="<="
+ value="parameter-value"
+ />
+ </xplCondition>
+
+ <!-- The <globalCondition> element allows rules to be executed based on the value of a global -->
+ <globalCondition
+ display_name="condition-name"
+ name="global-name"
+ operator=">="
+ value="global-value"
+ />
+
+ <!-- The <globalChanged> condition causes a determinator to be executed
+ when the value of a global variable changes.
+ -->
+ <globalChanged
+ display_name="rule-name"
+ name="global-name"
+ />
+
+ <!-- The <dayCondition> restricts execution of a determinator to specific days of the week
+ The dow parameter contains a 7-character string, representing the 7 days
+ of the week, with the first character representing Sunday.
+
+ 0 = do not execute on that day, 1 = execute on that day
+ For example, to execute on Monday to Friday, specify dow="0111110"
+
+ -->
+ <dayCondition display_name="rule-name"
+ dow="0000000"
+ />
+
+ <!-- The <timeCondition> element is u...
[truncated message content] |
|
From: <ma...@us...> - 2012-03-03 21:11:55
|
Revision: 718
http://openautomation.svn.sourceforge.net/openautomation/?rev=718&view=rev
Author: mayerch
Date: 2012-03-03 21:11:49 +0000 (Sat, 03 Mar 2012)
Log Message:
-----------
Revert (last commit committed a debug version...)
Modified Paths:
--------------
JSFloorPlan/trunk/index.html
Modified: JSFloorPlan/trunk/index.html
===================================================================
--- JSFloorPlan/trunk/index.html 2012-03-03 20:51:28 UTC (rev 717)
+++ JSFloorPlan/trunk/index.html 2012-03-03 21:11:49 UTC (rev 718)
@@ -10,10 +10,10 @@
-->
<title>JS Floor Plan</title>
<!-- -->
-<script src="lib/jquery-1.7.1.js" type="text/javascript"></script>
+<script src="lib/jquery-1.7.1.min.js" type="text/javascript"></script>
<script src="lib/jquery-ui-1.8.16.custom.min.js" type="text/javascript"></script>
<script src="lib/poly2tri.js" type="text/javascript"></script>
-<script src="lib/Three.max.js" type="text/javascript"></script>
+<script src="lib/Three.js" type="text/javascript"></script>
<script src="src/jsfloorplan.js" type="text/javascript"></script>
<script src="src/jsfloorplan_example_helper.js" type="text/javascript"></script>
<link rel="stylesheet" type="text/css" href="css/ui-lightness/jquery-ui-1.8.16.custom.css" />
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ma...@us...> - 2012-03-03 20:51:36
|
Revision: 717
http://openautomation.svn.sourceforge.net/openautomation/?rev=717&view=rev
Author: mayerch
Date: 2012-03-03 20:51:28 +0000 (Sat, 03 Mar 2012)
Log Message:
-----------
Make lib much more self contained
(Propper sorting, commenting and indentation still missing, though)
Modified Paths:
--------------
JSFloorPlan/trunk/index.html
JSFloorPlan/trunk/src/jsfloorplan.js
JSFloorPlan/trunk/src/jsfloorplan_example_helper.js
Modified: JSFloorPlan/trunk/index.html
===================================================================
--- JSFloorPlan/trunk/index.html 2012-02-29 19:33:36 UTC (rev 716)
+++ JSFloorPlan/trunk/index.html 2012-03-03 20:51:28 UTC (rev 717)
@@ -10,10 +10,10 @@
-->
<title>JS Floor Plan</title>
<!-- -->
-<script src="lib/jquery-1.7.1.min.js" type="text/javascript"></script>
+<script src="lib/jquery-1.7.1.js" type="text/javascript"></script>
<script src="lib/jquery-ui-1.8.16.custom.min.js" type="text/javascript"></script>
<script src="lib/poly2tri.js" type="text/javascript"></script>
-<script src="lib/Three.js" type="text/javascript"></script>
+<script src="lib/Three.max.js" type="text/javascript"></script>
<script src="src/jsfloorplan.js" type="text/javascript"></script>
<script src="src/jsfloorplan_example_helper.js" type="text/javascript"></script>
<link rel="stylesheet" type="text/css" href="css/ui-lightness/jquery-ui-1.8.16.custom.css" />
Modified: JSFloorPlan/trunk/src/jsfloorplan.js
===================================================================
--- JSFloorPlan/trunk/src/jsfloorplan.js 2012-02-29 19:33:36 UTC (rev 716)
+++ JSFloorPlan/trunk/src/jsfloorplan.js 2012-03-03 20:51:28 UTC (rev 717)
@@ -142,10 +142,10 @@
*/
(function( window, undefined ){
// the constructor
- var JSFloorPlan3D = function( floorPlan ){
+ var JSFloorPlan3D = function( container, floorPlan ){
if (!(this instanceof JSFloorPlan3D))
{
- return new JSFloorPlan3D( floorPlan );
+ return new JSFloorPlan3D( container, floorPlan );
}
if (typeof floorPlan === "string")
@@ -159,10 +159,29 @@
// private variables of this object instance will follow
var that = this;
+ var thatObject = {that: this};
+ this.thisThatObject = {that: this};
+ this.thisThat = this;
////////////////////////////////////////////////////////////////////////////
// Definition of the private variables
+ // create the materials - sphere for the nodes, cube for the walls and line for the lines
+ var sphereMaterial = new THREE.MeshLambertMaterial( { color: 0xCC0000 });
+ //var cubeMaterial = new THREE.MeshLambertMaterial( { color: 0x0000CC });
+ var cubeMaterial = new THREE.MeshBasicMaterial({ map: THREE.ImageUtils.loadTexture( 'media/demo_texture_512x512.png' ) });
+ //var cubeMaterial = new THREE.MeshPhongMaterial( { color: 0xff0000, specular: 0xffffff, ambient: 0xaa0000 } );
+ var lineMaterial = new THREE.LineBasicMaterial( { color: 0x0099ff, linewidth: 2 } );
+
+ var scene, camera, renderer, pointLight, sunLight, ambientLight, sunLightViewLine;
+ // set up the sphere vars
+
+ //var lightAzimut, lightElevation, lightStrength, lightDistanceŷ;
+ this.lightAzimut = {foo:'bar'};
+ this.lightElevation;
+ this.lightStrength;
+ this.lightDistanceŷ;
+
var floor;
// this array will contain all vertices to show in the svg
@@ -367,7 +386,7 @@
// iterate over the content of this floor
for( var j=0; j < floor.childNodes.length; j++ )
{
- floorNode = floor.childNodes[j];
+ var floorNode = floor.childNodes[j];
if (floorNode.nodeType != ELEMENT_NODE) continue;
switch( floorNode.tagName )
@@ -451,7 +470,7 @@
if( floorWalls[wjj].endOffset && vectors[jj].id < 0 )
djj += -floorWalls[wjj].endOffset;
- vertex = new Object;
+ var vertex = new Object;
vertex.x = vectors[j].x*djj + vectors[jj].x*dj;
vertex.y = vectors[j].y*djj + vectors[jj].y*dj;
var l = vectors[j].x*vectors[jj].y - vectors[j].y*vectors[jj].x;
@@ -592,8 +611,8 @@
p2tF.push(new THREE.Face3(val.GetPoint(0).id, val.GetPoint(1).id, val.GetPoint(2).id));
});
- Tvertices = swctx.points_;
- Tfaces = p2tF;
+ var Tvertices = swctx.points_;
+ var Tfaces = p2tF;
var wall1vertices = [];
var wall2vertices = [];
var sId, eId;
@@ -732,7 +751,7 @@
{
for( var i=0; i < nodes.childNodes.length; i++ )
{
- node = nodes.childNodes[i];
+ var node = nodes.childNodes[i];
if (node.nodeType != ELEMENT_NODE) continue;
var id = node.getAttribute('id');
@@ -774,7 +793,7 @@
{
for( var i=0; i < nodes.childNodes.length; i++ )
{
- node = nodes.childNodes[i];
+ var node = nodes.childNodes[i];
if (node.nodeType != ELEMENT_NODE) continue;
/**
@@ -932,11 +951,78 @@
* @method setup3D
* @private
*/
- function setup3D( thisObject3D )
- {
+ function setup3D( currentThis, thisObject3D )
+ {
if( noFloorplan ) return;
noSetup = false;
+ ///////////////////////////////////////////////////////////////////////////
+ // set the scene size
+ var WIDTH = 800,
+ HEIGHT = 400;
+
+ // set some camera attributes
+ var VIEW_ANGLE = 45,
+ ASPECT = WIDTH / HEIGHT,
+ NEAR = 0.1,
+ FAR = 10000;
+
+
+ renderer = new THREE.WebGLRenderer({antialias: true});
+ camera = new THREE.PerspectiveCamera(
+ VIEW_ANGLE,
+ ASPECT,
+ NEAR,
+ FAR );
+ scene = new THREE.Scene();
+ scene.add( camera );
+ // the camera starts at 0,0,0 so pull it back
+ camera.position.z = 300;
+
+ // start the renderer
+ renderer.setSize(WIDTH, HEIGHT);
+
+ // enable shadows
+ var SHADOW_MAP_WIDTH = 2048, SHADOW_MAP_HEIGHT = 1024;
+ renderer.shadowCameraNear = 0.1;
+ renderer.shadowCameraFar = 100;
+ renderer.shadowCameraFov = 45;
+
+ renderer.shadowMapBias = 0.0039;
+ renderer.shadowMapDarkness = 0.5;
+ renderer.shadowMapWidth = SHADOW_MAP_WIDTH;
+ renderer.shadowMapHeight = SHADOW_MAP_HEIGHT;
+ renderer.shadowMapEnabled = true;
+ //renderer.shadowMapSoft = true;
+ var projector = new THREE.Projector();
+
+ // create a point light
+ pointLight = new THREE.PointLight( 0xFFFFFF );
+
+ ambientLight = new THREE.AmbientLight( 0xFFFFFF );
+ // set its position
+ pointLight.position.x = 10;
+ pointLight.position.y = 50;
+ pointLight.position.z = 130;
+
+ // add to the scene
+ //scene.add(pointLight);
+
+ currentThis.lightAzimut = 3.9;
+ currentThis.lightElevation = 0.25;
+ currentThis.lightStrength = 80;
+ currentThis.lightDistance = 50;
+ sunLight = new THREE.SpotLight( 0xffffff );
+ sunLight.position.set( 0, 1500, 1000 );
+ sunLight.target.position.set( 0, 0, 0 );
+ sunLight.castShadow = true;
+ var sunLightView = new THREE.Geometry();
+ sunLightView.vertices.push( new THREE.Vertex( sunLight.position ) );
+ sunLightView.vertices.push( new THREE.Vertex( sunLight.target.position ) );
+ sunLightViewLine = new THREE.Line( sunLightView, lineMaterial );
+ scene.add( sunLightViewLine );
+ ///////////////////////////////////////////////////////////////////////////
+
scene.add( thisObject3D );
var showFloor = showStates.showFloor;
@@ -946,14 +1032,9 @@
//scene.add(pointLight);
scene.add(ambientLight);
//scene.add( camera );
- var $container = $('#top_level');
+ var $container = $(container);
// attach the render-supplied DOM element
$container.append(renderer.domElement);
-
- // Init after the scene was set up
- selectChange( 'showNodes' , 0, true );
- selectChange( 'showWallLines' , 0, true );
- selectChange( 'showFloor' , 0, true );
}
function setupCamera( azimut, elevation, distance, target )
@@ -967,6 +1048,16 @@
pointLight.position = camera.position;
}
+ JSFloorPlan3D.prototype.render = function()
+ {
+ renderer.render( scene, camera );
+ }
+
+ JSFloorPlan3D.prototype.showWireframe = function( doShowWireframe )
+ {
+ cubeMaterial.wireframe = doShowWireframe;
+ }
+
/**
* Show the floor plan by updating the relevant view parameters and calling
* the render() method
@@ -985,18 +1076,18 @@
showStates.currentDistance = distance;
showStates.currentTarget = target.clone(); //JSFloorPlan3D.buildingProperties.x_center;
- if( noSetup ) setup3D( this.buildingProperties.Object3D );
+ if( noSetup ) setup3D( this, this.buildingProperties.Object3D );
// set up camera
setupCamera( azimut, elevation, distance, target );
// set up sun
- var sx = Math.sin(lightAzimut) * Math.cos(lightElevation);
- var sy = Math.cos(lightAzimut) * Math.cos(lightElevation);
- var sz = Math.sin(lightElevation);
+ var sx = Math.sin(this.lightAzimut) * Math.cos(this.lightElevation);
+ var sy = Math.cos(this.lightAzimut) * Math.cos(this.lightElevation);
+ var sz = Math.sin(this.lightElevation);
sunLight.target.position = target;
- sunLight.position = new THREE.Vector3( sx * lightDistance, sy * lightDistance, sz * lightDistance + target.z );
- sunLight.intensity = lightStrength / 100.0;
+ sunLight.position = new THREE.Vector3( sx * this.lightDistance, sy * this.lightDistance, sz * this.lightDistance + target.z );
+ sunLight.intensity = this.lightStrength / 100.0;
sunLightViewLine.geometry.vertices[0].position = sunLight.position;
sunLightViewLine.geometry.vertices[1].position = sunLight.target.position;
sunLightViewLine.geometry.__dirtyVertices = true;
@@ -1041,7 +1132,8 @@
break;
};
- render();
+ //this.render();
+ renderer.render( scene, camera );
}
/**
@@ -1132,7 +1224,7 @@
}
setupCamera( showStates.currentAzimut, showStates.currentElevation, showStates.currentDistance, showStates.currentTarget );
- render();
+ renderer.render( scene, camera );
if( !done )
window.requestAnimationFrame( doMove );
Modified: JSFloorPlan/trunk/src/jsfloorplan_example_helper.js
===================================================================
--- JSFloorPlan/trunk/src/jsfloorplan_example_helper.js 2012-02-29 19:33:36 UTC (rev 716)
+++ JSFloorPlan/trunk/src/jsfloorplan_example_helper.js 2012-03-03 20:51:28 UTC (rev 717)
@@ -27,146 +27,6 @@
* @module JS FloorPlan 3D Example
*/
-function three_init()
-{
- return;
- // get the DOM element to attach to
- // - assume we've got jQuery to hand
- //var $container = $('#container');
- var $container = $('#top_level');
- // attach the render-supplied DOM element
- $container.append(renderer.domElement);
- // draw!
- //scene.add( camera );
- //renderer.render(scene, camera);
- //render();
- animate();
-}
-// set the scene size
-var WIDTH = 800,
- HEIGHT = 400;
-
-// set some camera attributes
-var VIEW_ANGLE = 45,
- ASPECT = WIDTH / HEIGHT,
- NEAR = 0.1,
- FAR = 10000;
-
-
-// create a WebGL renderer, camera
-// and a scene
-var renderer = new THREE.WebGLRenderer({antialias: true});
-var camera = new THREE.PerspectiveCamera(
- VIEW_ANGLE,
- ASPECT,
- NEAR,
- FAR );
-/*
-var controls = new THREE.TrackballControls( camera );
-//controls.rotateSpeed = 1.0;
-//controls.zoomSpeed = 1.2;
-//controls.panSpeed = 0.8;
-
-controls.noZoom = false;
-controls.noPan = false;
-
-controls.staticMoving = true;
-controls.dynamicDampingFactor = 0.3;
-
-controls.keys = [ 65, 83, 68 ];
-*/
-var scene = new THREE.Scene();
-scene.add( camera );
-// the camera starts at 0,0,0 so pull it back
-camera.position.z = 300;
-
-// start the renderer
-renderer.setSize(WIDTH, HEIGHT);
-
-// enable shadows
-var SHADOW_MAP_WIDTH = 2048, SHADOW_MAP_HEIGHT = 1024;
-renderer.shadowCameraNear = 0.1;
-renderer.shadowCameraFar = 100;
-renderer.shadowCameraFov = 45;
-
-renderer.shadowMapBias = 0.0039;
-renderer.shadowMapDarkness = 0.5;
-renderer.shadowMapWidth = SHADOW_MAP_WIDTH;
-renderer.shadowMapHeight = SHADOW_MAP_HEIGHT;
-renderer.shadowMapEnabled = true;
-//renderer.shadowMapSoft = true;
-var projector = new THREE.Projector();
-
-// set up the sphere vars
-var radius = 50, segments = 16, rings = 16;
-
-// create the sphere's material
-var sphereMaterial = new THREE.MeshLambertMaterial(
-{
- color: 0xCC0000
-});
-// create a new mesh with sphere geometry -
-// we will cover the sphereMaterial next!
-var sphere = new THREE.Mesh(
- new THREE.SphereGeometry(radius,
- segments,
- rings),
-
- sphereMaterial);
-
-// add the sphere to the scene
-//scene.add(sphere);
-
-var cubeMaterial = new THREE.MeshLambertMaterial(
-{
- color: 0x0000CC
-});
-var cube = new THREE.Mesh(
- new THREE.CubeGeometry(
- 10, 20, 30,
- 2, 2),
- cubeMaterial
-);
-cube.position = new THREE.Vector3(50,50,50);
-//scene.add( cube );
-
-cubeMaterial = new THREE.MeshBasicMaterial({ map: THREE.ImageUtils.loadTexture( 'media/demo_texture_512x512.png' ) });
-//cubeMaterial = new THREE.MeshPhongMaterial( { color: 0xff0000, specular: 0xffffff, ambient: 0xaa0000 } );
-
-var lineMaterial = new THREE.LineBasicMaterial( { color: 0x0099ff, linewidth: 2 } );
-
-// create a point light
-var pointLight = new THREE.PointLight( 0xFFFFFF );
-
-var ambientLight = new THREE.AmbientLight( 0xFFFFFF );
-// set its position
-pointLight.position.x = 10;
-pointLight.position.y = 50;
-pointLight.position.z = 130;
-
-// add to the scene
-//scene.add(pointLight);
-
-var lightAzimut = 3.9;
-var lightElevation = 0.25;
-var lightStrength = 80;
-var lightDistance = 50;
-//var sunLight = new THREE.PointLight( 0xFFFFFF );
-//var sunLight = new THREE.DirectionalLight( 0xFFFFFF );
-var sunLight = new THREE.SpotLight( 0xffffff );
-sunLight.position.set( 0, 1500, 1000 );
-sunLight.target.position.set( 0, 0, 0 );
-sunLight.castShadow = true;
-var sunLightView = new THREE.Geometry();
-sunLightView.vertices.push( new THREE.Vertex( sunLight.position ) );
-sunLightView.vertices.push( new THREE.Vertex( sunLight.target.position ) );
-var sunLightViewLine = new THREE.Line( sunLightView, lineMaterial );
-scene.add( sunLightViewLine );
-//var dlight = new THREE.DirectionalLight( 0xffffff, 0.1 );
-// dlight.position.set( 0.5, -1, 0 ).normalize();
-// scene.add( dlight );
-
-
/**
* Provides requestAnimationFrame in a cross browser way.
* http://paulirish.com/2011/requestanimationframe-for-smart-animating/
@@ -192,13 +52,6 @@
//stats.update();
}
-function render() {
- //controls.update();
- renderer.render( scene, camera );
-}
-
-//}
-
function handleMouseClickEvent( event )
{
if( event.room.room )
@@ -221,20 +74,6 @@
// setup script here:
var sc = 40; // overall scaling
var showStates = {};
-/*
-var showWallSides = true;
-var showWallTop = true;
-var showSideLines = true;
-var showTopLines = true;
-var showBackside = true;
-var showHoles = true;
-var showZones = true;
-var showVisibleZones = false;
-var showFloor = 1;
-var wallMouseOver = true;
-var fillOpacity = 0.5;
-var fillColor = 'black';
-*/
var redrawInterval = 50; // in milliseconds; = 20 fps
var roll = 35*Math.PI/180;
@@ -253,7 +92,7 @@
var t_25d_after_sort;
var t_25d_end;
-j = new JSFloorPlan3D();
+j = new JSFloorPlan3D('#top_level');
function init()
{
@@ -278,12 +117,16 @@
showStates[ this.name ] = this.value; // init
});
- //loadFloorplan();
j.loadFloorPlan('floorplan_demo.xml');
target.x = j.buildingProperties.x_center;
target.y = j.buildingProperties.y_center;
createSlider();
- render();
+ j.render();
+
+ // Init after the scene was set up
+ selectChange( 'showNodes' , 0, true );
+ selectChange( 'showWallLines' , 0, true );
+ selectChange( 'showFloor' , 0, true );
}
function selectChange( name, old, onlyInit )
@@ -340,7 +183,7 @@
break;
case 'showWireframe':
- cubeMaterial.wireframe = showStates['showWireframe'];
+ j.showWireframe( showStates['showWireframe'] );
break;
}
return true;
@@ -420,70 +263,6 @@
document.getElementById('status').firstChild.data = text;
}
-/*
-function set_color( event )
-{
- if( 'blue' != fillColor )
- event.setAttribute( 'fill', 'blue' );
- else
- event.setAttribute( 'fill', 'red' );
-}
-
-function unset_color( event )
-{
- event.setAttribute( 'fill', fillColor );
-}
-*/
-/*
-function check( what, redraw )
-{
- eval( what +' = document.forms[0].elements[what].checked' );
-
- switch( what )
- {
- case 'wallMouseOver':
- if( wallMouseOver )
- {
- wrapper.setAttribute( "onmouseover", 'set_color(this);' );
- wrapper.setAttribute( "onmouseout", 'unset_color(this);' );
- } else {
- wrapper.setAttribute( "onmouseover", '' );
- wrapper.setAttribute( "onmouseout", '' );
- }
- break;
- }
-
- if( redraw )
- {
- j.show3D( roll, tilt, dist, plan );
- }
-}
-*/
-
-/*
-function selectValue( what, redraw )
-{
- var val = document.forms[0].elements[what].options[ document.forms[0].elements[what].selectedIndex ].value;
- eval( what + ' = val' );
-
- switch( what )
- {
- case 'fillOpacity':
- wrapper.setAttribute( "fill-opacity", fillOpacity );
- break;
-
- case 'fillColor':
- wrapper.setAttribute( "fill", fillColor );
- break;
- }
-
- if( redraw )
- {
- j.show3D( roll, tilt, dist, plan );
- }
-}
-*/
-
// Create the little graphics for the roll and the tilt angle
// as well as the buttons to manipulate them
function createSlider()
@@ -504,15 +283,15 @@
globalInUpdateSlider = true;
var rollAngle = (roll * 180/Math.PI);
var tiltAngle = (tilt * 180/Math.PI);
- var lightDirectionAngle = (lightAzimut * 180/Math.PI);
- var lightHeightAngle = (lightElevation * 180/Math.PI);
+ var lightDirectionAngle = (j.lightAzimut * 180/Math.PI);
+ var lightHeightAngle = (j.lightElevation * 180/Math.PI);
$( "#rollSlider" ).slider( "option", "value", rollAngle );
$( "#tiltSlider" ).slider( "option", "value", tiltAngle );
$( "#distSlider" ).slider( "option", "value", dist );
$( "#lightDirectionSlider" ).slider( "option", "value", lightDirectionAngle );
$( "#lightHeightSlider" ).slider( "option", "value", lightHeightAngle );
- $( "#lightStrengthSlider" ).slider( "option", "value", lightStrength );
- $( "#lightDistanceSlider" ).slider( "option", "value", lightDistance );
+ $( "#lightStrengthSlider" ).slider( "option", "value", j.lightStrength );
+ $( "#lightDistanceSlider" ).slider( "option", "value", j.lightDistance );
globalInUpdateSlider = false;
}
@@ -540,28 +319,28 @@
function lightDirectionChange( event, ui )
{
if( globalInUpdateSlider ) return true;
- lightAzimut = ui.value * Math.PI / 180;
+ j.lightAzimut = ui.value * Math.PI / 180;
j.show3D( roll, tilt, dist, target );
}
function lightHeightChange( event, ui )
{
if( globalInUpdateSlider ) return true;
- lightElevation = ui.value * Math.PI / 180;
+ j.lightElevation = ui.value * Math.PI / 180;
j.show3D( roll, tilt, dist, target );
}
function lightStrengthChange( event, ui )
{
if( globalInUpdateSlider ) return true;
- lightStrength = ui.value;
+ j.lightStrength = ui.value;
j.show3D( roll, tilt, dist, target );
}
function lightDistanceChange( event, ui )
{
if( globalInUpdateSlider ) return true;
- lightDistance = ui.value;
+ j.lightDistance = ui.value;
j.show3D( roll, tilt, dist, target );
}
@@ -626,6 +405,5 @@
}
$(function() {
- three_init();
$('#top_level').css('border','1px solid black').click( {callback:handleMouseClickEvent,JSFloorPlan3D:j}, j.translateMouseEvent );
});
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sw...@us...> - 2012-02-29 19:33:42
|
Revision: 716
http://openautomation.svn.sourceforge.net/openautomation/?rev=716&view=rev
Author: swiss1
Date: 2012-02-29 19:33:36 +0000 (Wed, 29 Feb 2012)
Log Message:
-----------
Astro Funktion by ZeitlerW integriert und auf Version 0.6 BETA aktualisiert
Modified Paths:
--------------
wiregate/plugin/generic/schaltuhr.pl
Modified: wiregate/plugin/generic/schaltuhr.pl
===================================================================
--- wiregate/plugin/generic/schaltuhr.pl 2012-02-25 18:43:35 UTC (rev 715)
+++ wiregate/plugin/generic/schaltuhr.pl 2012-02-29 19:33:36 UTC (rev 716)
@@ -1,27 +1,45 @@
-# Plugin zum Zeit abh\xE4ngigem schaten von GA's (Schaltuhr)
-# Version 0.5 BETA 03.07.2011
+# Plugin zum Zeit abh\xE4ngigem schalten von GA's (Schaltuhr)
+# Version 0.6 BETA 29.02.2012
# Copyright: swiss (http://knx-user-forum.de/members/swiss.html)
# License: GPL (v2)
# Aufbau m\xF6glichst so, dass man unterhalb der Einstellungen nichts ver\xE4ndern muss!
+# -Erweitert um Sonnenauf / - untergang von ZeitlerW (http://knx-user-forum.de/members/zeitlerw.html)
+# -Inspiriert von kleinklausi's Rolladen - Plugin
####################
###Einstellungen:###
####################
+
+# Die Standortdaten
+# Die Koordinaten des Hauses. Sehr einfach \xFCber http://www.getlatlon.com/ zu ermitteln.
+my ($lat, $lon) = (
+ 50.27816466477597, # Breitengrad in Grad
+ 11.64325475692749 # L\xE4ngengrad in Grad
+ );
+
+#Winkel f\xFCr Beginn der D\xE4mmerung
+# siehe auch: http://search.cpan.org/~rkhill/Astro-Sunrise-0.91/Sunrise.pm#DESCRIPTION
+my $winkel=-3;
my @Schaltzeiten;
+
#Pro Schaltpunkt einfach den unten stehenden Eintrag kopieren und anpassen.
+#Sollen Schaltzeiten astronomisch geschaltet werden, so mu\xDF bei Astro 'a' f\xFCr Sonnenaufgang
+#und 'u' f\xFCr Sonnenuntergang eingetragen werden. Der Stunden und Minutenwert wird dann ignoriert.
-push @Schaltzeiten, { name => "bew\xE4sserung_ein", montag => 1, dienstag => 1, mittwoch => 1, donnerstag => 1, freitag => 1, samstag => 0, sonntag => 1, Stunden => 21, Minuten => 02, Wert => 1, DPT => 1, ga => '2/0/0', KW => '', Monat => '' };
+push @Schaltzeiten, { name => "weckzeit", montag => 1, dienstag => 1, mittwoch => 1, donnerstag => 1, freitag => 1, samstag => 0, sonntag => 0, Stunden => 05, Minuten => 45, Wert => 1, DPT => 1, ga => '1/5/4', KW => '', Monat => '', Astro => '' };
-push @Schaltzeiten, { name => "bew\xE4sserung_aus", montag => 1, dienstag => 1, mittwoch => 1, donnerstag => 1, freitag => 1, samstag => 0, sonntag => 1, Stunden => 21, Minuten => 03, Wert => 0, DPT => 1, ga => '2/0/0', KW => '', Monat => '' };
+
######################
##ENDE Einstellungen##
######################
use POSIX;
use Time::Local;
+# Wir brauchen auch Sonnenstandsberechnung
+use Astro::Sunrise;
# Eigenen Aufruf-Zyklus auf 20sek. setzen
$plugin_info{$plugname.'_cycle'} = 20;
@@ -47,6 +65,15 @@
foreach my $element (@Schaltzeiten) {
if (knx_read($element->{ga},0,$element->{DPT}) ne $element->{Wert}) {
+ if ($element->{Astro} ne '') {
+ if ($element->{Astro} eq 'a') {
+ $element->{Stunden}=$sunrise[0];
+ $element->{Minuten}=$sunrise[1];
+ } elsif ($element->{Astro} eq 'u') {
+ $element->{Stunden}=$sunset[0];
+ $element->{Minuten}=$sunset[1];
+ }
+ }
if ($element->{$Wochentag[$wday]} == 1 && $element->{Stunden} == $hour && $element->{Minuten} == $min && $element->{KW} ne '') {
if ($element->{KW} == $kw) {
knx_write($element->{ga},$element->{Wert},$element->{DPT});
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <j-...@us...> - 2012-02-25 18:43:41
|
Revision: 715
http://openautomation.svn.sourceforge.net/openautomation/?rev=715&view=rev
Author: j-n-k
Date: 2012-02-25 18:43:35 +0000 (Sat, 25 Feb 2012)
Log Message:
-----------
Changed diagram_popup behaviour to old style (height is approx. one row)
Modified Paths:
--------------
CometVisu/trunk/visu/plugins/diagram/structure_plugin.js
Added Paths:
-----------
CometVisu/trunk/visu/designs/pitchblack/mobile.css
Added: CometVisu/trunk/visu/designs/pitchblack/mobile.css
===================================================================
--- CometVisu/trunk/visu/designs/pitchblack/mobile.css (rev 0)
+++ CometVisu/trunk/visu/designs/pitchblack/mobile.css 2012-02-25 18:43:35 UTC (rev 715)
@@ -0,0 +1,11 @@
+.widget_container {
+ width: 98%;
+}
+
+#bottom {
+ display: none;
+}
+
+.page {
+ overflow: visible;
+}
Property changes on: CometVisu/trunk/visu/designs/pitchblack/mobile.css
___________________________________________________________________
Added: svn:executable
+ *
Modified: CometVisu/trunk/visu/plugins/diagram/structure_plugin.js
===================================================================
--- CometVisu/trunk/visu/plugins/diagram/structure_plugin.js 2012-02-23 18:09:58 UTC (rev 714)
+++ CometVisu/trunk/visu/plugins/diagram/structure_plugin.js 2012-02-25 18:43:35 UTC (rev 715)
@@ -71,6 +71,10 @@
if ($p.attr("width")) {
diagram.css("width", $p.attr("width"));
+ } else {
+ if (oldType=="popup") {
+ diagram.removeClass("diagram_inline").addClass("diagram_preview");
+ }
}
if ($p.attr("height")) {
diagram.css("height", $p.attr("height"));
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <j-...@us...> - 2012-02-23 18:10:05
|
Revision: 714
http://openautomation.svn.sourceforge.net/openautomation/?rev=714&view=rev
Author: j-n-k
Date: 2012-02-23 18:09:58 +0000 (Thu, 23 Feb 2012)
Log Message:
-----------
reworked diagram-code, including diff by netsrac, new widget "diagram",
diagram_popup and diagram_inline still supported but deprecated
added short documentation at file-header
Modified Paths:
--------------
CometVisu/trunk/visu/plugins/diagram/structure_plugin.js
Modified: CometVisu/trunk/visu/plugins/diagram/structure_plugin.js
===================================================================
--- CometVisu/trunk/visu/plugins/diagram/structure_plugin.js 2012-02-22 06:46:10 UTC (rev 713)
+++ CometVisu/trunk/visu/plugins/diagram/structure_plugin.js 2012-02-23 18:09:58 UTC (rev 714)
@@ -19,422 +19,444 @@
* This plugins integrates flot (diagrams in javascript) into the visualization.
* server-side data-storage is rrd
*/
+
+ /**
+ * short documentation
+ *
+ * recommended widgets:
+ * - diagram
+ * - diagram_info
+ *
+ * deprecated widgets:
+ * - diagram_inline (use diagram with option previewlabels="true" instead)
+ * - diagram_popup (use diagram with option popup="true" instead)
+ *
+ * attributes:
+ * - rrd: required, name of RRD
+ * - unit: optional, unit for axis-labels
+ * - series: optional, "hour", "day" (default), "week", "month", "year"
+ * - period: optional, ?
+ * - datasource: optional, RRD-datasource, "MIN", "AVERAGE" (default), "MAX"
+ * - refresh: optional, refresh-rate in seconds, no refresh if missing
+ * - yaxismin, yaxismax: optional, limits for y-axis
+ * - linecolor, gridcolor: optional, color for dataline and grid, HTML-colorcode
+ * - width, height: optional, width and height of "inline"-diagram
+ * - previewlabels: optional, show labels on "inline"-diagram
+ * - popup: optional, make diagram clickable and open popup
+ *
+ * functions:
+ * - createDiagram(page, path, oldType)
+ * - refreshDiagram(diagram, flotoptions, data)
+ *
+*/
+
+
$("body").append("<script type=\"text/javascript\" src=\"plugins/diagram/flot/jquery.flot.js\"></script>");
-VisuDesign_Custom.prototype.addCreator("diagram_inline", {
- create: function( page, path ) {
- var $p = $(page);
+function createDiagram( page, path, oldType ) {
+ var $p = $(page);
- function uniqid() {
- var newDate = new Date;
- return newDate.getTime();
- }
+ function uniqid() {
+ var newDate = new Date;
+ return newDate.getTime();
+ }
- var id = "diagram_" + uniqid();
+ var id = "diagram_" + uniqid();
- var ret_val = $('<div class="widget clearfix diagram" />');
- ret_val.setWidgetLayout($p).makeWidgetLabel($p);
+ var ret_val = $('<div class="widget clearfix diagram" />');
+ ret_val.setWidgetLayout($p).makeWidgetLabel($p);
- var actor = $("<div class=\"actor\"><div class=\"diagram_inline\" id=\"" + id + "\">loading...</div></div>");
- var diagram = $("#" + id, actor);
+ var actor = $("<div class=\"actor\"><div class=\"diagram_inline\" id=\"" + id + "\">loading...</div></div>");
+ var diagram = $("#" + id, actor);
- if ($p.attr("width")) {
- diagram.css("width", $p.attr("width"));
- }
- if ($p.attr("height")) {
- diagram.css("height", $p.attr("height"));
- }
+ if ($p.attr("width")) {
+ diagram.css("width", $p.attr("width"));
+ }
+ if ($p.attr("height")) {
+ diagram.css("height", $p.attr("height"));
+ }
- ret_val.append(actor);
+ ret_val.append(actor);
- diagram.data("id", id);
- diagram.data("rrd", $p.attr("rrd"));
- diagram.data("unit", $p.attr("unit") || "");
- diagram.data("series", $p.attr("series") || "day");
- diagram.data("period", $p.attr("period") || 1);
- diagram.data("datasource", $p.attr("datasource") || "AVERAGE");
- diagram.data("label", $('.label', ret_val).text() || '');
- diagram.data("refresh", $p.attr("refresh"));
- diagram.data("yaxismin", $p.attr("yaxismin"));
- diagram.data("yaxismax", $p.attr("yaxismax"));
- diagram.data("linecolor", $p.attr("linecolor") || "");
- diagram.data("gridcolor", $p.attr("gridcolor") || "");
+ diagram.data("id", id);
+ diagram.data("rrd", $p.attr("rrd"));
+ diagram.data("unit", $p.attr("unit") || "");
+ diagram.data("series", $p.attr("series") || "day");
+ diagram.data("period", $p.attr("period") || 1);
+ diagram.data("datasource", $p.attr("datasource") || "AVERAGE");
+ diagram.data("label", $('.label', ret_val).text() || '');
+ diagram.data("refresh", $p.attr("refresh"));
+ diagram.data("yaxismin", $p.attr("yaxismin"));
+ diagram.data("yaxismax", $p.attr("yaxismax"));
+ diagram.data("linecolor", $p.attr("linecolor") || "");
+ diagram.data("gridcolor", $p.attr("gridcolor") || "");
- refreshDiagram(diagram, {});
-
- return ret_val;
- },
- attributes: {
- rrd: {type: "string", required: true},
- width: {type: "string", required: false},
- height: {type: "string", required: false},
- unit: {type: "string", required: false},
- series: {type: "list", required: false, list: {hour: "hours", day: "days", week: "weeks", month: "months", year: "years"}},
- period: {type: "numeric", required: false},
- datasource: {type: "list", required: false, list: {'MIN': "Min", 'AVERAGE': "Avg", 'MAX': "Max"}},
- refresh: {type: "numeric", required: false},
- yaxismin: {type: "numeric", required: false},
- yaxismax: {type: "numeric", required: false},
- linecolor: {type: "string", required: false},
- colspan: {type: "numeric", required: false},
- rowspan: {type: "numeric", required: false},
- gridcolor: {type: "string", required: false}
- },
- elements: {
- label: { type: 'string', required: false, multi: false }
- },
- content: false
-});
-
-VisuDesign_Custom.prototype.addCreator("diagram_popup", {
- create: function( page, path ) {
- var $p = $(page);
-
- function uniqid() {
- var newDate = new Date;
- return newDate.getTime();
- }
-
- var id = "diagram_" + uniqid();
-
- var ret_val = $('<div class="widget clearfix diagram" />');
- ret_val.setWidgetLayout($p).makeWidgetLabel($p);
+ var bDiagram = $("<div class=\"diagram\" id=\"" + id + "_big\"/>");
- var actor = $("<div class=\"actor\"><div class=\"diagram_preview\" id=\"" + id + "\">loading...</div></div>");
- var diagram = $("#" + id, actor);
+ diagram.addClass("clickable");
+ var data = jQuery.extend({}, diagram.data());
- if ($p.attr("width")) {
- diagram.css("width", $p.attr("width"));
- }
- if ($p.attr("height")) {
- diagram.css("height", $p.attr("height"));
- }
-
- ret_val.append(actor);
-
- diagram.data("id", id);
- diagram.data("rrd", $p.attr("rrd"));
- diagram.data("unit", $p.attr("unit") || "");
- diagram.data("series", $p.attr("series") || "day");
- diagram.data("period", $p.attr("period") || 1);
- diagram.data("datasource", $p.attr("datasource") || "AVERAGE");
- diagram.data("label", $('.label', ret_val).text() || '');
- diagram.data("refresh", $p.attr("refresh"));
- diagram.data("yaxismin", $p.attr("yaxismin"));
- diagram.data("yaxismax", $p.attr("yaxismax"));
- diagram.data("linecolor", $p.attr("linecolor") || "");
- diagram.data("gridcolor", $p.attr("gridcolor") || "");
-
- var bDiagram = $("<div class=\"diagram\" id=\"" + id + "_big\"/>");
-
- diagram.addClass("clickable");
- var data = jQuery.extend({}, diagram.data());
-
- diagram.bind("click", function() {
- bDiagram.data(data);
- bDiagram.css({height: "90%"});
-
- showPopup("unknown", {title: page.textContent, content: bDiagram});
- bDiagram.parent("div").css({height: "100%", width: "90%", margin: "auto"}); // define parent as 100%!
+ if ((oldType=="popup") || ($p.attr("popup")=="true")) {
+ diagram.bind("click", function() {
+ bDiagram.data(data);
+ bDiagram.css({height: "90%"});
+ showPopup("unknown", {title: page.textContent, content: bDiagram});
+ bDiagram.parent("div").css({height: "100%", width: "90%", margin: "auto"}); // define parent as 100%!
- var bDiagramOpts = {yaxis: {labelWidth: null}};
- if ($p.attr("tooltip") == "true") {
- // if we want to display a tooltip, we need to listen to the event
- var previousPoint = null;
- jQuery(bDiagram).bind("plothover", function (event, pos, item) {
- jQuery("#x").text(pos.x.toFixed(2));
- jQuery("#y").text(pos.y.toFixed(2));
+ var bDiagramOpts = {yaxis: {labelWidth: null}};
+ if ($p.attr("tooltip") == "true") {
+ // if we want to display a tooltip, we need to listen to the event
+ var previousPoint = null;
+ jQuery(bDiagram).bind("plothover", function (event, pos, item) {
+ jQuery("#x").text(pos.x.toFixed(2));
+ jQuery("#y").text(pos.y.toFixed(2));
- if (item) {
- if (previousPoint != item.datapoint) {
- previousPoint = item.datapoint;
-
- $("#diagramTooltip").remove();
- var x = item.datapoint[0],
- y = item.datapoint[1].toFixed(2);
-
- //This is a mess but toLocaleString expects UTC again
- var offset = new Date().getTimezoneOffset() * 60 * 1000;
- var dte = new Date(x + offset);
- showDiagramTooltip(item.pageX, item.pageY,
- dte.toLocaleString() + ": " + y + jQuery(this).data("unit"));
- }
- }
- else {
- $("#diagramTooltip").remove();
- previousPoint = null;
- }
-
- })
- .bind("click", function(event) {
- // don't let the popup know about the click, or it will close on touch-displays
- event.stopPropagation();
- });
-
- bDiagramOpts = jQuery.extend(bDiagramOpts, {grid: {hoverable: true, clickable: true} });
+ if (item) {
+ if (previousPoint != item.datapoint) {
+ previousPoint = item.datapoint;
+
+ $("#diagramTooltip").remove();
+ var x = item.datapoint[0],
+ y = item.datapoint[1].toFixed(2);
+
+ //This is a mess but toLocaleString expects UTC again
+ var offset = new Date().getTimezoneOffset() * 60 * 1000;
+ var dte = new Date(x + offset);
+ showDiagramTooltip(item.pageX, item.pageY,
+ dte.toLocaleString() + ": " + y + jQuery(this).data("unit"));
}
-
- refreshDiagram(bDiagram, bDiagramOpts);
- return false;
+ } else {
+ $("#diagramTooltip").remove();
+ previousPoint = null;
+ }
+ })
+ .bind("click", function(event) {
+ // don't let the popup know about the click, or it will close on touch-displays
+ event.stopPropagation();
});
+
+ bDiagramOpts = jQuery.extend(bDiagramOpts, { grid: {hoverable: true, clickable: true} });
+ }
- refreshDiagram(diagram, {xaxes: [{ticks: 0}], yaxes: [{ticks: 0}]});
+ refreshDiagram(bDiagram, bDiagramOpts);
+ return false;
+ });
+ }
+ if ((oldType=="inline") || ($p.attr("previewlabels") == "true")) {
+ refreshDiagram(diagram, {});
+ } else {
+ refreshDiagram(diagram, {xaxes: [{ticks: 0}], yaxes: [{ticks: 0}]});
+ }
- return ret_val;
- },
- attributes: {
- rrd: {type: "string", required: true},
- unit: {type: "string", required: false},
- series: {type: "list", required: false, list: {hour: "hours", day: "days", week: "weeks", month: "months", year: "years"}},
- period: {type: "numeric", required: false},
- datasource: {type: "list", required: false, list: {'MIN': "Min", 'AVERAGE': "Avg", 'MAX': "Max"}},
- refresh: {type: "numeric", required: false},
- yaxismin: {type: "numeric", required: false},
- yaxismax: {type: "numeric", required: false},
- linecolor: {type: "string", required: false},
- gridcolor: {type: "string", required: false},
- tooltip: {type: "list", required: false, list: {'true': "yes", 'false': "no"}},
- },
- elements: {
- label: { type: 'string', required: false, multi: false }
- },
- content: false
+ return ret_val;
+}
+
+
+VisuDesign_Custom.prototype.addCreator("diagram_inline", {
+ create: function( page, path ) {
+ return createDiagram(page, path, "inline");
+ },
+ attributes: {
+ rrd: {type: "string", required: true},
+ width: {type: "string", required: false},
+ height: {type: "string", required: false},
+ unit: {type: "string", required: false},
+ series: {type: "list", required: false, list: {hour: "hours", day: "days", week: "weeks", month: "months", year: "years"}},
+ period: {type: "numeric", required: false},
+ datasource: {type: "list", required: false, list: {'MIN': "Min", 'AVERAGE': "Avg", 'MAX': "Max"}},
+ refresh: {type: "numeric", required: false},
+ yaxismin: {type: "numeric", required: false},
+ yaxismax: {type: "numeric", required: false},
+ linecolor: {type: "string", required: false},
+ colspan: {type: "numeric", required: false},
+ rowspan: {type: "numeric", required: false},
+ gridcolor: {type: "string", required: false}
+ },
+ elements: {
+ label: { type: 'string', required: false, multi: false }
+ },
+ content: false
});
+VisuDesign_Custom.prototype.addCreator("diagram_popup", {
+ create: function(page,path) {
+ return createDiagram(page, path, "popup");
+ },
+ attributes: {
+ rrd: {type: "string", required: true},
+ unit: {type: "string", required: false},
+ series: {type: "list", required: false, list: {hour: "hours", day: "days", week: "weeks", month: "months", year: "years"}},
+ period: {type: "numeric", required: false},
+ datasource: {type: "list", required: false, list: {'MIN': "Min", 'AVERAGE': "Avg", 'MAX': "Max"}},
+ refresh: {type: "numeric", required: false},
+ yaxismin: {type: "numeric", required: false},
+ yaxismax: {type: "numeric", required: false},
+ linecolor: {type: "string", required: false},
+ gridcolor: {type: "string", required: false},
+ tooltip: {type: "list", required: false, list: {'true': "yes", 'false': "no"}},
+ width: {type: "string", required: false},
+ height: {type: "string", required: false},
+ },
+ elements: {
+ label: { type: 'string', required: false, multi: false }
+ },
+ content: false
+});
+
+VisuDesign_Custom.prototype.addCreator("diagram", {
+ create: function(page,path) {
+ return createDiagram(page, path, "none");
+ },
+ attributes: {
+ rrd: {type: "string", required: true},
+ unit: {type: "string", required: false},
+ series: {type: "list", required: false, list: {hour: "hours", day: "days", week: "weeks", month: "months", year: "years"}},
+ period: {type: "numeric", required: false},
+ datasource: {type: "list", required: false, list: {'MIN': "Min", 'AVERAGE': "Avg", 'MAX': "Max"}},
+ refresh: {type: "numeric", required: false},
+ yaxismin: {type: "numeric", required: false},
+ yaxismax: {type: "numeric", required: false},
+ linecolor: {type: "string", required: false},
+ gridcolor: {type: "string", required: false},
+ tooltip: {type: "list", required: false, list: {'true': "yes", 'false': "no"}},
+ width: {type: "string", required: false},
+ height: {type: "string", required: false},
+ previewlabels: {type: "list", required: false, list: {'true': "yes", 'false': "no"}},
+ popup: {type: "list", required: false, list: {'true': "yes", 'false': "no"}},
+ },
+ elements: {
+ label: { type: 'string', required: false, multi: false }
+ },
+ content: false
+});
+
VisuDesign_Custom.prototype.addCreator("diagram_info", {
- create: function( page, path ) {
- var $p = $(page);
+ create: function( page, path ) {
+ var $p = $(page);
- var address = {};
- $p.find('address').each( function(){
- var src = this.textContent;
- ga_list.push( src )
- address[ '_' + src ] = [ this.getAttribute('transform') ];
- });
+ var address = {};
+ $p.find('address').each( function(){
+ var src = this.textContent;
+ ga_list.push( src )
+ address[ '_' + src ] = [ this.getAttribute('transform') ];
+ });
- function uniqid() {
- var newDate = new Date;
- return newDate.getTime();
- }
+ function uniqid() {
+ var newDate = new Date;
+ return newDate.getTime();
+ }
- var id = "diagram_" + uniqid();
+ var id = "diagram_" + uniqid();
- var ret_val = $('<div class="widget clearfix diagram" />');
- ret_val.setWidgetLayout($p).makeWidgetLabel($p);
+ var ret_val = $('<div class="widget clearfix diagram" />');
+ ret_val.setWidgetLayout($p).makeWidgetLabel($p);
- var actor = '<div class="actor switchUnpressed ';
- if ( $p.attr( 'align' ) )
- actor += $p.attr( 'align' );
- actor += '">';
- var map = $p.attr('mapping');
- if( mappings[map] && mappings[map][value] )
- actor += '<div class="value">' + mappings[map][value] + '</div>';
- else
- actor += '<div class="value">-</div>';
- actor += '</div>';
+ var actor = '<div class="actor switchUnpressed ';
+ if ( $p.attr( 'align' ) )
+ actor += $p.attr( 'align' );
+ actor += '">';
+ var map = $p.attr('mapping');
+ if( mappings[map] && mappings[map][value] )
+ actor += '<div class="value">' + mappings[map][value] + '</div>';
+ else
+ actor += '<div class="value">-</div>';
+ actor += '</div>';
- var $actor = $(actor).data({
- 'address' : address,
- 'format' : $p.attr('format'),
- 'mapping' : $p.attr('mapping'),
- 'styling' : $p.attr('styling')
- });
- for( var addr in address ) $actor.bind( addr, this.update );
+ var $actor = $(actor).data({
+ 'address' : address,
+ 'format' : $p.attr('format'),
+ 'mapping' : $p.attr('mapping'),
+ 'styling' : $p.attr('styling')
+ });
+ for( var addr in address ) $actor.bind( addr, this.update );
- ret_val.append($actor);
+ ret_val.append($actor);
- $actor.addClass("clickable");
+ $actor.addClass("clickable");
- var bDiagram = $("<div class=\"diagram\" id=\"" + id + "_big\"/>");
+ var bDiagram = $("<div class=\"diagram\" id=\"" + id + "_big\"/>");
- bDiagram.data("id", id);
- bDiagram.data("rrd", $p.attr("rrd"));
- bDiagram.data("unit", $p.attr("unit") || "");
- bDiagram.data("series", $p.attr("series") || "day");
- bDiagram.data("period", $p.attr("period") || 1);
- bDiagram.data("datasource", $p.attr("datasource") || "AVERAGE");
- bDiagram.data("label", $('.label', ret_val).text() || '');
- bDiagram.data("refresh", $p.attr("refresh"));
- bDiagram.data("yaxismin", $p.attr("yaxismin"));
- bDiagram.data("yaxismax", $p.attr("yaxismax"));
- bDiagram.data("linecolor", $p.attr("linecolor") || "");
- bDiagram.data("gridcolor", $p.attr("gridcolor") || "");
+ bDiagram.data("id", id);
+ bDiagram.data("rrd", $p.attr("rrd"));
+ bDiagram.data("unit", $p.attr("unit") || "");
+ bDiagram.data("series", $p.attr("series") || "day");
+ bDiagram.data("period", $p.attr("period") || 1);
+ bDiagram.data("datasource", $p.attr("datasource") || "AVERAGE");
+ bDiagram.data("label", $('.label', ret_val).text() || '');
+ bDiagram.data("refresh", $p.attr("refresh"));
+ bDiagram.data("yaxismin", $p.attr("yaxismin"));
+ bDiagram.data("yaxismax", $p.attr("yaxismax"));
+ bDiagram.data("linecolor", $p.attr("linecolor") || "");
+ bDiagram.data("gridcolor", $p.attr("gridcolor") || "");
- var data = jQuery.extend({}, bDiagram.data());
+ var data = jQuery.extend({}, bDiagram.data());
- $actor.bind("click", function() {
- bDiagram.data(data);
- bDiagram.css({height: "90%"});
+ $actor.bind("click", function() {
+ bDiagram.data(data);
+ bDiagram.css({height: "90%"});
- showPopup("unknown", {title: bDiagram.data('label'), content: bDiagram});
- bDiagram.parent("div").css({height: "100%", width: "90%", margin: "auto"}); // define parent as 100%!
+ showPopup("unknown", {title: bDiagram.data('label'), content: bDiagram});
+ bDiagram.parent("div").css({height: "100%", width: "90%", margin: "auto"}); // define parent as 100%!
- var bDiagramOpts = {yaxis: {labelWidth: null}};
- if ($p.attr("tooltip") == "true") {
- // if we want to display a tooltip, we need to listen to the event
- var previousPoint = null;
- jQuery(bDiagram).bind("plothover", function (event, pos, item) {
- jQuery("#x").text(pos.x.toFixed(2));
- jQuery("#y").text(pos.y.toFixed(2));
-
- if (item) {
- if (previousPoint != item.datapoint) {
- previousPoint = item.datapoint;
-
- $("#diagramTooltip").remove();
- var x = item.datapoint[0],
- y = item.datapoint[1].toFixed(2);
-
- //This is a mess but toLocaleString expects UTC again
- var offset = new Date().getTimezoneOffset() * 60 * 1000;
- var dte = new Date(x + offset);
- showDiagramTooltip(item.pageX, item.pageY,
- dte.toLocaleString() + ": " + y + jQuery(this).data("unit"));
- }
- }
- else {
- $("#diagramTooltip").remove();
- previousPoint = null;
- }
-
- })
- .bind("click", function(event) {
- // don't let the popup know about the click, or it will close on touch-displays
- event.stopPropagation();
- });
-
- bDiagramOpts = jQuery.extend(bDiagramOpts, {grid: {hoverable: true, clickable: true} });
+ var bDiagramOpts = {yaxis: {labelWidth: null}};
+ if ($p.attr("tooltip") == "true") {
+ // if we want to display a tooltip, we need to listen to the event
+ var previousPoint = null;
+ jQuery(bDiagram).bind("plothover", function (event, pos, item) {
+ jQuery("#x").text(pos.x.toFixed(2));
+ jQuery("#y").text(pos.y.toFixed(2));
+
+ if (item) {
+ if (previousPoint != item.datapoint) {
+ previousPoint = item.datapoint;
+
+ $("#diagramTooltip").remove();
+ var x = item.datapoint[0],
+ y = item.datapoint[1].toFixed(2);
+
+ //This is a mess but toLocaleString expects UTC again
+ var offset = new Date().getTimezoneOffset() * 60 * 1000;
+ var dte = new Date(x + offset);
+ showDiagramTooltip(item.pageX, item.pageY,
+ dte.toLocaleString() + ": " + y + jQuery(this).data("unit"));
}
-
- refreshDiagram(bDiagram, bDiagramOpts);
- return false;
+ } else {
+ $("#diagramTooltip").remove();
+ previousPoint = null;
+ }
+ })
+ .bind("click", function(event) {
+ // don't let the popup know about the click, or it will close on touch-displays
+ event.stopPropagation();
});
+
+ bDiagramOpts = jQuery.extend(bDiagramOpts, { grid: {hoverable: true, clickable: true} });
+ }
- return ret_val;
- },
- update: function(e,d) {
- var element = $(this);
- var value = defaultUpdate( e, d, element );
- element.addClass('switchUnpressed');
- },
- attributes: {
- rrd: {type: "string", required: true},
- unit: {type: "string", required: false},
- series: {type: "list", required: false, list: {hour: "hours", day: "days", week: "weeks", month: "months", year: "years"}},
- period: {type: "numeric", required: false},
- datasource: {type: "list", required: false, list: {'MIN': "Min", 'AVERAGE': "Avg", 'MAX': "Max"}},
- refresh: {type: "numeric", required: false},
- tooltip: {type: "list", required: false, list: {'true': "yes", 'false': "no"}},
- linecolor: {type: "string", required: false},
- gridcolor: {type: "string", required: false},
- yaxismin: {type: "numeric", required: false},
- yaxismax: {type: "numeric", required: false},
- format: { type: 'format', required: false },
- mapping: { type: 'mapping', required: false },
- styling: { type: 'styling', required: false }
- },
- elements: {
- label: { type: 'string', required: true, multi: false },
- address: { type: 'address', required: true, multi: true }
- },
- content: {type: "string", required: true}
+ refreshDiagram(bDiagram, bDiagramOpts);
+ return false;
+ });
+
+ return ret_val;
+ },
+ update: function(e,d) {
+ var element = $(this);
+ var value = defaultUpdate( e, d, element );
+ element.addClass('switchUnpressed');
+ },
+ attributes: {
+ rrd: {type: "string", required: true},
+ unit: {type: "string", required: false},
+ series: {type: "list", required: false, list: {hour: "hours", day: "days", week: "weeks", month: "months", year: "years"}},
+ period: {type: "numeric", required: false},
+ datasource: {type: "list", required: false, list: {'MIN': "Min", 'AVERAGE': "Avg", 'MAX': "Max"}},
+ refresh: {type: "numeric", required: false},
+ tooltip: {type: "list", required: false, list: {'true': "yes", 'false': "no"}},
+ linecolor: {type: "string", required: false},
+ gridcolor: {type: "string", required: false},
+ yaxismin: {type: "numeric", required: false},
+ yaxismax: {type: "numeric", required: false},
+ format: { type: 'format', required: false },
+ mapping: { type: 'mapping', required: false },
+ styling: { type: 'styling', required: false }
+ },
+ elements: {
+ label: { type: 'string', required: true, multi: false },
+ address: { type: 'address', required: true, multi: true }
+ },
+ content: {type: "string", required: true}
});
diagramColors = {
- data: $("<span class='link'><a href='#' /></a>").find("a").css("color")
+ data: $("<span class='link'><a href='#' /></a>").find("a").css("color")
};
function showDiagramTooltip(x, y, contents) {
- $('<div id="diagramTooltip">' + contents + '</div>').css( {
- position: 'absolute',
- display: 'none',
- top: y + 5,
- left: x + 5,
- }).appendTo("body").fadeIn(200);
+ $('<div id="diagramTooltip">' + contents + '</div>').css( {
+ position: 'absolute',
+ display: 'none',
+ top: y + 5,
+ left: x + 5,
+ }).appendTo("body").fadeIn(200);
}
-
function refreshDiagram(diagram, flotoptions, data) {
- var diagram = $(diagram);
- var config = jQuery.extend(true, {series: diagram.data("series")}, data || {});
+ var diagram = $(diagram);
+ var config = jQuery.extend(true, {series: diagram.data("series")}, data || {});
- var unit = diagram.data("unit");
- var rrd = diagram.data("rrd");
- var label = diagram.data("label");
- var refresh = diagram.data("refresh");
- var datasource = diagram.data("datasource") || "AVERAGE";
- var period = diagram.data("period") || 1;
- var linecolor = diagram.data("linecolor") || diagramColors.data;
- var gridcolor = diagram.data("gridcolor") || "#81664B";
- var yaxismin = diagram.data("yaxismin") || null;
- var yaxismax = diagram.data("yaxismax") || null;
+ var unit = diagram.data("unit");
+ var rrd = diagram.data("rrd");
+ var label = diagram.data("label");
+ var refresh = diagram.data("refresh");
+ var datasource = diagram.data("datasource") || "AVERAGE";
+ var period = diagram.data("period") || 1;
+ var linecolor = diagram.data("linecolor") || diagramColors.data;
+ var gridcolor = diagram.data("gridcolor") || "#81664B";
+ var yaxismin = diagram.data("yaxismin") || null;
+ var yaxismax = diagram.data("yaxismax") || null;
- var series = {
- hour: {label: "hour", res: "60", start: "hour", end: "now"},
- day: {label: "day", res: "300", start: "day", end: "now"},
- week: {label: "week", res: "1800", start: "week", end: "now"},
- month: {label: "month", res: "21600", start: "month", end: "now"},
- year: {label: "year", res: "432000", start: "year", end: "now"},
- };
+ var series = {
+ hour: {label: "hour", res: "60", start: "hour", end: "now"},
+ day: {label: "day", res: "300", start: "day", end: "now"},
+ week: {label: "week", res: "1800", start: "week", end: "now"},
+ month: {label: "month", res: "21600", start: "month", end: "now"},
+ year: {label: "year", res: "432000", start: "year", end: "now"},
+ };
- var options = jQuery.extend(true,
- {
- yaxes: [{
- tickFormatter: function (v, axis) { return v.toFixed(axis.tickDecimals) + unit; },
- min: yaxismin,
- max: yaxismax,
- }],
- xaxes: [{
- mode: "time"
- }],
- legend: {
- show: 1,
- backgroundColor: "#101010"
- },
- series: {
- points: { show: false, fill: false }
- },
- grid: {
- show: true,
- aboveData: false,
- color: gridcolor,
- backgroundColor: "black",
- tickColor: gridcolor,
- borderColor: gridcolor
- }
- },
- flotoptions);
+ var options = jQuery.extend(true, {
+ yaxes: [{
+ tickFormatter: function (v, axis) { return v.toFixed(axis.tickDecimals) + unit; },
+ min: yaxismin,
+ max: yaxismax,
+ }],
+ xaxes: [{
+ mode: "time"
+ }],
+ legend: {
+ show: 1,
+ backgroundColor: "#101010"
+ },
+ series: {
+ points: { show: false, fill: false }
+ },
+ grid: {
+ show: true,
+ aboveData: false,
+ color: gridcolor,
+ backgroundColor: "black",
+ tickColor: gridcolor,
+ borderColor: gridcolor
+ }
+ }, flotoptions);
- var s = series[config.series];
+ var s = series[config.series];
- if (s) {
- // init
- $.ajax({
- url: "/cgi-bin/rrdfetch?rrd=" + rrd + ".rrd&ds=" + datasource + "&start=end-" + period + s.start + "&end=" + s.end + "&res=" + s.res,
- dataType: "json",
- type: "GET",
- success: function(data) {
- var color = linecolor || options.grid.color;
- var offset = new Date().getTimezoneOffset() * 60 * 1000;
- //TODO: find a better way
- for (var j = 0; j < data.length; j++) {
- data[j][0] -= offset;
- data[j][1] = parseFloat( data[j][1][0] );
- }
- p = $.plot(diagram, [{color: color, data: data}], options);
- //console.log( p, p.width(), p.height(), p.getPlotOffset() );
- }
- });
+ if (s) {
+ // init
+ $.ajax({
+ url: "/cgi-bin/rrdfetch?rrd=" + rrd + ".rrd&ds=" + datasource + "&start=end-" + period + s.start + "&end=" + s.end + "&res=" + s.res,
+ dataType: "json",
+ type: "GET",
+ success: function(data) {
+ var color = linecolor || options.grid.color;
+ var offset = new Date().getTimezoneOffset() * 60 * 1000;
+ //TODO: find a better way
+ for (var j = 0; j < data.length; j++) {
+ data[j][0] -= offset;
+ data[j][1] = parseFloat( data[j][1][0] );
+ }
+ p = $.plot(diagram, [{color: color, data: data}], options);
+ //console.log( p, p.width(), p.height(), p.getPlotOffset() );
+ }
+ });
- if (typeof (refresh) != "undefined" && refresh) {
- // reload regularly
- window.setTimeout(function(diagram, flotoptions, data) {
- refreshDiagram(diagram, flotoptions, data);
- }, refresh * 1000, diagram, flotoptions, data);
- }
+ if (typeof (refresh) != "undefined" && refresh) {
+ // reload regularly
+ window.setTimeout(function(diagram, flotoptions, data) {
+ refreshDiagram(diagram, flotoptions, data);
+ }, refresh * 1000, diagram, flotoptions, data);
}
+ }
- return false;
-
+ return false;
}
-
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <hu...@us...> - 2012-02-22 06:46:17
|
Revision: 713
http://openautomation.svn.sourceforge.net/openautomation/?rev=713&view=rev
Author: hubermi
Date: 2012-02-22 06:46:10 +0000 (Wed, 22 Feb 2012)
Log Message:
-----------
Initial commit of ETA_PU.pl written by haegar80 and greentux
Added Paths:
-----------
wiregate/plugin/generic/ETA_PU.pl
Added: wiregate/plugin/generic/ETA_PU.pl
===================================================================
--- wiregate/plugin/generic/ETA_PU.pl (rev 0)
+++ wiregate/plugin/generic/ETA_PU.pl 2012-02-22 06:46:10 UTC (rev 713)
@@ -0,0 +1,552 @@
+# Plugin: Schnittstelle zum Pelletskessel ETA-PU
+# Version 1.0
+# License: GPL (v3)
+
+# Dieses Plugin dient als Schnittstelle zwischen KNX und dem ETA Heizkessel PU (Pellets Unit).
+# Verwendet wird hierbei die ETAtouch RESTful Webservices Schnittstelle, die mit der Anbindung
+# des Kessels an www.meineta.at zur Verfügung steht.
+#
+# Eine Beschreibung der Schnittstelle ist unter diesem Link verfügbar:
+# https://www.meineta.at/user/download.action?contentType=application%2Fpdf&file=ETA-RESTful-v1.pdf
+# CAN-BUS-URI können in der XML-Datei für die Menüstruktur entnommen werden:
+# http://ip:port/user/menu
+
+
+# Aktuell werden folgende Features unterstützt:
+# 1. Lesen von festgelegten Kesseldaten in einem festgelegten Intervall (aktuell 1 Minute):
+# - Schreiben der Kesselwerte auf KNX-Gruppenadressen
+# > DPT wird über ein Mapping der Einheiten bestimmt)
+# - Schreiben von Statustexten auf KNX-Gruppenadressen(DPT wird über ein Mapping der Einheiten bestimmt)
+# > DPT wird über Import der Gruppenadressen ins Wiregate bestimmt
+# - Aufzeichnen der Kesselwerte in RRD für Messwerte (GAUGE)
+# > RRD wird mit Standardparametern automatisch angelegt
+# - Aufzeichnen von Tageswerten auf Basis von Zählerständen des Kessel in RRD für Zähler (COUNTER)
+# > RRD wird mit den entsprechenden Parametern automatisch angelegt, falls noch vorhanden
+# 2. Lesen der Meldungen der Kesselsteuerung in einem festgelegten Intervall (aktuell 1 Minute)
+# - Schreiben einer Status Grupenadresse: Meldung Ja/Nein
+# - Schreiben der Anzahl der Meldungen auf eine Gruppenadresse
+# 3. Empfangen von KNX-Schreibtelegrammen von festgelegten KNX-Gruppenadressen
+# und Schreiben in die Steuerung des Kessels.
+# Achtung: Es dürfen nicht die selben Gruppenadressen wie beim Lesen der Kesseldaten verwendet werden!!!
+
+
+# Folgende Features werden aktuell durch das Plugin noch nicht unterstützt:
+# - Empfangen von KNX-Lesetelegrammen von festgelegten KNX-Gruppenadressen,
+# Lesen der entsprechenden Kesseldaten und Schreiben der Kesselwerte auf KNX-Gruppenadressen
+# - Schreiben der Fehlermeldungen in einen RSS-Feed
+#
+# Folgende Features werden aktuell durch die ETAtouch RESTful Webservices Schnittstelle noch nicht unterstützt:
+# - Lesen und Schreiben auf Werte der Schaltuhren
+# - Lesen der aktuellen Pumpenleistung in %
+# - Lesen und Schreiben auf Werte die mit der Service Anmeldung in der Kesselsteuerung zur Verfügung stehen
+# - Ein-/Ausschalten der Schaltuhren
+
+
+# Die Fachliche Diskussion zu dem Plugin findet im knx-user-forum.de statt:
+# http://knx-user-forum.de/knx-eib-forum/16767-plugin-pelletskessel-eta-pu-new-post.html
+#
+# Mitwirkende bei der Entwicklung des Plugins:
+# Matthias Lemke greentux
+# Sascha Bank haegar80
+# Kontaktaufnahme bitte über das knx-user-forum.de
+
+
+
+## Beginn Definitionen ##
+my $IP_PU = "192.168.10.11:8080";
+my $ResVariables = "/user/vars";
+my $ResSingleVariable = "/user/var";
+my $ResErrors = "/user/errors";
+my $set = "basic";
+my $DirRrd = "/var/www/rrd/";
+
+my $GA_Fehler = "10/0/3";
+my $DPT_GA_Fehler = "1.001";
+my $GA_AnzahlFehler = "10/0/4";
+my $DPT_GA_AnzahlFehler = "5.010";
+
+
+# Mapping ETA can-bus-uri zu Gruppenadressen für Werte aus string Rückgaben
+my %string_GA_URI_mapping = (
+ '10/0/0' => '112/10021/0/0/12000', # Kessel - Kesselstatus (Text)
+ '10/0/48' => '112/10021/0/0/12078', # Kessel - UV-Speicher (Text)
+ '10/0/80' => '112/10101/0/0/12090', # Kessel - Entaschung Status (Text)
+ '10/0/90' => '112/10021/0/0/12248', # Kessel - Beginn Ruhezeit
+ '10/0/95' => '112/10021/0/0/12249', # Kessel - Dauer Ruhezeit
+ '10/0/185' => '112/10021/0/0/12152', # Kessel - Pellets Saugzeitpunkt
+ '10/0/200' => '112/10021/0/0/12153', # Kessel - Betriebsstunden (Text)
+
+ '10/2/0' => '112/10101/0/0/12090', # HK - Status (Text)
+ '10/2/2' => '112/10101/0/0/12092', # HK - Betrieb (Text)
+ '10/2/20' => '112/10101/0/0/12232', # HK - Urlaub Beginn
+ '10/2/25' => '112/10101/0/0/12239', # HK - Urlaub Ende
+
+ '10/3/0' => '112/10102/0/0/12090', # FBH - Status (Text)
+ '10/3/2' => '112/10102/0/0/12092', # FBH - Betrieb (Text)
+ '10/3/20' => '112/10102/0/0/12232', # FBH - Urlaub Beginn
+ '10/3/25' => '112/10102/0/0/12239', # FBH - Urlaub Ende
+
+ '10/5/0' => '112/10111/0/0/12129', # WW - Schaltzustand (Text)
+);
+
+# Mapping ETA can-bus-uri zu Gruppenadressen für Werte aus Value Rückgaben
+my %value_GA_URI_mapping = (
+ '10/0/1' => '112/10021/0/0/12000', # Kessel - Kesselstatus (Code)
+ '10/0/2' => '112/10241/0/11149/2001', # Kessel - Störmeldung
+ '10/0/6' => '112/10021/0/0/12080', # Kessel - I/O Taste
+ '10/0/8' => '112/10021/0/0/12115', # Kessel - Emissionsmessung
+ '10/0/10' => '112/10021/0/0/12001', # Kessel - Kessel Solltemperatur
+ '10/0/11' => '112/10021/0/0/12161', # Kessel - Isttemperatur
+ '10/0/12' => '112/10021/0/0/12300', # Kessel - Isttemperatur unten
+ '10/0/21' => '112/10021/0/0/12162', # Kessel - Abgastemperatur
+ '10/0/22' => '112/10021/0/0/12165', # Kessel - Drehzahl Abgasgebläse
+ '10/0/23' => '112/10021/0/0/12164', # Kessel - Restsauerstoff
+ '10/0/40' => '112/10021/0/11121/2120', # Kessel - VL1-Solltemperatur
+ '10/0/41' => '112/10021/0/11121/2121', # Kessel - VL1-Isttemperatur
+ '10/0/45' => '112/10021/0/11123/2001', # Kessel - Kesselpumpe 1
+ '10/0/49' => '112/10021/0/0/12078', # Kessel - UV-Speicher (Code)
+ '10/0/50' => '112/10021/0/11152/2120', # Kessel - VL2-Solltemperatur
+ '10/0/51' => '112/10021/0/11152/2121', # Kessel - VL2-Isttemperatur
+ '10/0/55' => '112/10021/0/11138/2001', # Kessel - Kesselpumpe 2
+ '10/0/81' => '112/10101/0/0/12090', # Kessel - Entaschung Status (Code)
+ '10/0/86' => '112/10021/0/0/12112', # Kessel - Entaschentaste
+ '10/0/100' => '112/10021/0/0/12073', # Kessel - Entaschen nach kg frühestens
+ '10/0/103' => '112/10021/0/0/12074', # Kessel - Entaschen nach kg spätestens
+ '10/0/111' => '112/10021/0/0/12120', # Kessel - Kübel leeren nach
+ '10/0/170' => '112/10201/0/0/12015', # Silo - Vorrat
+ '10/0/175' => '112/10021/0/0/12011', # Kessel - Pellets Behälterinhalt
+ '10/0/181' => '112/10021/0/0/12071', # Kessel - Pellets Füllen
+ '10/0/201' => '112/10021/0/0/12153', # Kessel - Betriebsstunden (Sekunden)
+ '10/0/205' => '112/10021/0/0/12016', # Kessel - Gesamtverbrauch
+ '10/0/210' => '112/10021/0/0/12014', # Kessel - kg seit Wartung
+ '10/0/211' => '112/10021/0/0/12012', # Kessel - kg seit Entaschung
+ '10/0/212' => '112/10021/0/0/12013', # Kessel - kg seit Kübel entleeren
+
+ '10/2/1' => '112/10101/0/0/12090', # HK - Status (Code)
+ '10/2/3' => '112/10101/0/0/12092', # HK - Betrieb (Code)
+ '10/2/6' => '112/10101/0/0/12080', # HK - I/O Taste
+ '10/2/11' => '112/10101/0/0/12126', # HK - Auto Taste
+ '10/2/13' => '112/10101/0/0/12125', # HK - Tag Taste
+ '10/2/15' => '112/10101/0/0/12230', # HK - Nacht Taste
+ '10/2/17' => '112/10101/0/0/12218', # HK - Kommen Taste
+ '10/2/19' => '112/10101/0/0/12231', # HK - Gehen Taste
+ '10/2/30' => '112/10101/0/0/12111', # HK - Solltemperatur
+ '10/2/36' => '112/10101/0/0/12240', # HK - Schieber Position
+ '10/2/41' => '112/10101/0/0/12104', # HK - Vorlauf bei -10°C
+ '10/2/43' => '112/10101/0/0/12103', # HK - Vorlauf bei +10°C
+ '10/2/45' => '112/10101/0/0/12107', # HK - Vorlauf Absenkung
+ '10/2/47' => '112/10101/0/0/12096', # HK - Heizgrenze Tag
+ '10/2/49' => '112/10101/0/0/12097', # HK - Heizgrenze Nacht
+ '10/2/50' => '112/10101/12095/0/1071', # HK - Außen verzögert (Lag x)
+ '10/2/51' => '112/10101/12095/0/1072', # HK - Außen verzögert (Lag Tf)
+ '10/2/53' => '112/10101/12095/0/1073', # HK - Außen verzögert (Lag y)
+
+ '10/3/1' => '112/10102/0/0/12090', # FBH - Status (Code)
+ '10/3/3' => '112/10102/0/0/12092', # FBH - Betrieb (Code)
+ '10/3/6' => '112/10102/0/0/12080', # FBH - I/O Taste
+ '10/3/11' => '112/10102/0/0/12126', # FBH - Auto Taste
+ '10/3/13' => '112/10102/0/0/12125', # FBH - Tag Taste
+ '10/3/15' => '112/10102/0/0/12230', # FBH - Nacht Taste
+ '10/3/17' => '112/10102/0/0/12218', # FBH - Kommen Taste
+ '10/3/19' => '112/10102/0/0/12231', # FBH - Gehen Taste
+ '10/3/30' => '112/10102/0/0/12111', # FBH - Solltemperatur
+ '10/3/36' => '112/10102/0/0/12240', # FBH - Schieber Position
+ '10/3/41' => '112/10102/0/0/12104', # FBH - Vorlauf bei -10°C
+ '10/3/43' => '112/10102/0/0/12103', # FBH - Vorlauf bei +10°C
+ '10/3/45' => '112/10102/0/0/12107', # FBH - Vorlauf Absenkung
+ '10/3/47' => '112/10102/0/0/12096', # FBH - Heizgrenze Tag
+ '10/3/49' => '112/10102/0/0/12097', # FBH - Heizgrenze Nacht
+ '10/3/50' => '112/10102/12095/0/1071', # FBH - Außen verzögert (Lag x)
+ '10/3/51' => '112/10102/12095/0/1072', # FBH - Außen verzögert (Lag Tf)
+ '10/3/53' => '112/10102/12095/0/1073', # FBH - Außen verzögert (Lag y)
+ '10/3/60' => '112/10102/12113/0/1109', # FBH - Zeitautomatik Schaltzustand
+ '10/2/60' => '112/10101/12113/0/1109', # HK - Zeitautomatik Schaltzustand
+
+ '10/5/1' => '112/10111/0/0/12129', # WW - Schaltzustand (Code)
+ '10/5/6' => '112/10111/0/0/12134', # WW - Laden Taste
+ '10/5/10' => '112/10111/0/0/12132', # WW - Solltemperatur
+ '10/5/16' => '112/10111/0/0/12133', # WW - Einschaltdifferenz
+ '10/5/20' => '112/10111/0/0/12271', # WW - Temperatur Speicher oben
+
+ '10/5/60' => '112/10111/12130/0/1109', # WW - Zeitautomatik Schaltzustand
+ '10/5/61' => '112/10111/12130/0/1110', # WW - Zeitautomatik Temperatur
+);
+
+# Mapping ETA can-bus-uri zu Gruppenadressen für Schreibaktionen
+my %write_GA_URI_mapping = (
+ '10/0/5' => '112/10021/0/0/12080', # Kessel - I/O Taste
+ '10/0/7' => '112/10021/0/0/12115', # Kessel - Emissionsmessung
+ '10/0/85' => '112/10021/0/0/12112', # Kessel - Entaschentaste
+ '10/0/101' => '112/10021/0/0/12073', # Kessel - Entaschen nach kg frühestens
+ '10/0/102' => '112/10021/0/0/12074', # Kessel - Entaschen nach kg spätestens
+ '10/0/110' => '112/10021/0/0/12120', # Kessel - Kübel leeren nach
+ '10/0/180' => '112/10021/0/0/12071', # Kessel - Pellets Füllen
+
+ '10/2/5' => '112/10101/0/0/12080', # HK - I/O Taste
+ '10/2/10' => '112/10101/0/0/12126', # HK - Auto Taste
+ '10/2/12' => '112/10101/0/0/12125', # HK - Tag Taste
+ '10/2/14' => '112/10101/0/0/12230', # HK - Nacht Taste
+ '10/2/16' => '112/10101/0/0/12218', # HK - Kommen Taste
+ '10/2/18' => '112/10101/0/0/12231', # HK - Gehen Taste
+ '10/2/35' => '112/10101/0/0/12240', # HK - Schieber Position
+ '10/2/40' => '112/10101/0/0/12104', # HK - Vorlauf bei -10°C
+ '10/2/42' => '112/10101/0/0/12103', # HK - Vorlauf bei +10°C
+ '10/2/44' => '112/10101/0/0/12107', # HK - Vorlauf Absenkung
+ '10/2/46' => '112/10101/0/0/12096', # HK - Heizgrenze Tag
+ '10/2/48' => '112/10101/0/0/12097', # HK - Heizgrenze Nacht
+ '10/2/52' => '112/10101/12095/0/1072', # HK - Außen verzögert (Lag Tf)
+
+ '10/3/5' => '112/10102/0/0/12080', # FBH - I/O Taste
+ '10/3/10' => '112/10102/0/0/12126', # FBH - Auto Taste
+ '10/3/12' => '112/10102/0/0/12125', # FBH - Tag Taste
+ '10/3/14' => '112/10102/0/0/12230', # FBH - Nacht Taste
+ '10/3/16' => '112/10102/0/0/12218', # FBH - Kommen Taste
+ '10/3/18' => '112/10102/0/0/12231', # FBH - Gehen Taste
+ '10/3/35' => '112/10102/0/0/12240', # FBH - Schieber Position
+ '10/3/40' => '112/10102/0/0/12104', # FBH - Vorlauf bei -10°C
+ '10/3/42' => '112/10102/0/0/12103', # FBH - Vorlauf bei +10°C
+ '10/3/44' => '112/10102/0/0/12107', # FBH - Vorlauf Absenkung
+ '10/3/46' => '112/10102/0/0/12096', # FBH - Heizgrenze Tag
+ '10/3/48' => '112/10102/0/0/12097', # FBH - Heizgrenze Nacht
+ '10/3/52' => '112/10102/12095/0/1072', # FBH - Außen verzögert (Lag Tf)
+
+ '10/5/5' => '112/10111/0/0/12134', # WW - Laden Taste
+ '10/5/15' => '112/10111/0/0/12133', # WW - Einschaltdifferenz
+);
+
+# Mapping ETA can-bus-uri zu RRD Graphen (Gauge = Messerte) aus Value Rückgaben
+my %value_URI_RRD_mapping = (
+ '112/10021/0/0/12001' => 'Heizung_KesselSolltemperatur',
+ '112/10021/0/0/12161' => 'Heizung_Kesseltemperatur',
+ '112/10021/0/0/12300' => 'Heizung_KesseltemperaturUnten',
+ '112/10021/0/0/12162' => 'Heizung_Abgastemperatur',
+ '112/10021/0/0/12165' => 'Heizung_DrehzahlAbgasgebläse',
+ '112/10021/0/0/12164' => 'Heizung_Restsauerstoff',
+
+ '112/10021/0/11121/2120' => 'Heizung_VL1_Solltemperatur',
+ '112/10021/0/11121/2121' => 'Heizung_VL1_Isttemperatur',
+ '112/10021/0/11152/2120' => 'Heizung_VL2_Solltemperatur',
+ '112/10021/0/11152/2121' => 'Heizung_VL2_Isttemperatur',
+
+ '112/10101/0/0/12111' => 'Heizung_HK_Solltemperatur',
+ '112/10101/0/0/12240' => 'Heizung_HK_Schieber',
+ '112/10102/0/0/12111' => 'Heizung_FBH_Solltemperatur',
+ '112/10102/0/0/12240' => 'Heizung_FBH_Schieber',
+ '112/10111/0/0/12132' => 'Heizung_WW_Solltemperatur',
+ '112/10111/0/0/12271' => 'Heizung_WW_TemperaturSpeicherOben',
+);
+
+# Mapping ETA can-bus-uri zu RRD Graphen für Tageszähler (aus Zählerstand) aus Value Rückgaben
+my %value_URI_RRDdaycount_mapping = (
+ '112/10021/0/0/12016' => 'Heizung_PelletsverbrauchTag',
+ '112/10021/0/0/12153' => 'Heizung_Betriebssekunden',
+);
+
+# Mapping der ETA Einheiten zu KNX Datenpunkttypen
+my %unit_DPT_mapping = (
+ "%" => '6.001',
+ "U/min" => '7.001',
+ "\N{U+00b0}C" => '9.001',
+ "Sek" => '9.010',
+ 'kg' => '14.051',
+);
+## Ende Definitionen ##
+
+#Module laden
+use strict;
+use warnings;
+use LWP::UserAgent;
+use XML::Parser;
+use IO::File;
+
+
+# Plugin alle 1 Minuten aufrufen
+$plugin_info{$plugname.'_cycle'} = 60*1;
+
+#Letzte Laufzeit protokollieren
+update_rrd("LaufzeitPlugin_".$plugname,"",$plugin_info{$plugname.'_runtime'});
+
+
+# Variablen definieren
+my %value_GA_URI;
+my %write_GA_URI;
+my %string_GA_URI;
+
+# ETA Variablenset anlegen, wenn Plugin durch Speichern aufgerufen
+my $SetVar;
+if ((stat('/etc/wiregate/plugin/generic/' . $plugname))[9] > time()-10) {
+# Code nach PL30
+#if = ($plugin_info{$plugname.'_lastsaved'} > $plugin_info{$plugname.'_last'} or $plugin_info{$plugname.'_lastSetVariable'} == 0) {
+ $SetVar = 1;
+}
+
+# ETA Variablenset anlegen, wenn Variablenset fehlt
+if ($plugin_info{$plugname.'_lastSetVariable'} == 0) {
+ $SetVar = 1;
+}
+
+# ETA Variablenset anlegen
+if ($SetVar) {
+ delete_set("http://".$IP_PU.$ResVariables, $set);
+ create_set("http://".$IP_PU.$ResVariables, $set);
+ plugin_log($plugname,"Variablenset anlegen: ".$set);
+ $plugin_info{$plugname.'_lastSetVariable'} = time();
+}
+
+for my $ga (%string_GA_URI_mapping) {
+ if (exists $string_GA_URI_mapping{$ga}) {
+ #$plugin_subscribe{$ga}{$plugname} = 1; #An Gruppenadresse anmelden
+ $string_GA_URI{$string_GA_URI_mapping{$ga}} = $ga; # Hash URI -> GA aus Hash GA->URI bilden
+ if ($SetVar) {
+ # ETA Uri zu Variablenset hinzufügen
+ add_to_set("http://".$IP_PU.$ResVariables, $set, $string_GA_URI_mapping{$ga});
+ plugin_log($plugname, "Variablenset erweitern: ".$set.
+ " - String URI".$string_GA_URI_mapping{$ga});
+ }
+ }
+}
+
+for my $ga (%value_GA_URI_mapping) {
+ if (exists $value_GA_URI_mapping{$ga}) {
+ #$plugin_subscribe{$ga}{$plugname} = 1; #An Gruppenadresse anmelden
+ $value_GA_URI{$value_GA_URI_mapping{$ga}} = $ga; # Hash URI -> GA aus Hash GA->URI bilden
+ if ($SetVar) {
+ # ETA Uri zu Variablenset hinzufügen
+ add_to_set("http://".$IP_PU.$ResVariables, $set, $value_GA_URI_mapping{$ga});
+ plugin_log($plugname, "Variablenset erweitern: ".$set.
+ " - Value URI".$value_GA_URI_mapping{$ga});
+ }
+ }
+}
+
+for my $ga (%write_GA_URI_mapping) {
+ if (exists $write_GA_URI_mapping{$ga}) {
+ $plugin_subscribe{$ga}{$plugname} = 1; #An Gruppenadresse anmelden
+ $write_GA_URI{$write_GA_URI_mapping{$ga}} = $ga; # Hash URI -> GA aus Hash GA->URI bilden
+ if ($SetVar) {
+ # ETA Uri zu Variablenset hinzufügen
+ add_to_set("http://".$IP_PU.$ResVariables, $set, $write_GA_URI_mapping{$ga});
+ plugin_log($plugname, "Variablenset erweitern: ".$set.
+ " - Write URI".$write_GA_URI_mapping{$ga});
+ }
+
+ }
+}
+
+# Bei Schreibtelegramm Wert mit Faktor und Offset in Kesselsteuerung schreiben
+if ($msg{'apci'} eq "A_GroupValue_Write" and exists $write_GA_URI_mapping{$msg{'dst'}}) {
+ set_value( "http://".$IP_PU.$ResSingleVariable,$write_GA_URI_mapping{$msg{'dst'}},
+ $msg{'value'}
+ * $plugin_info{$plugname.'_'.$write_GA_URI_mapping{$msg{'dst'}}.'_scaleFactor'}
+ + $plugin_info{$plugname.'_'.$write_GA_URI_mapping{$msg{'dst'}}.'_advTextOffset'});
+ plugin_log( $plugname, $write_GA_URI_mapping{$msg{'dst'}}." - GA ".$msg{'dst'}.
+ " - Wert schreiben: ". $msg{'value'}.
+ " / scaleFactor ". $plugin_info{$plugname.'_'.$write_GA_URI_mapping{$msg{'dst'}}.'_scaleFactor'}.
+ " advTextOffset ". $plugin_info{$plugname.'_'.$write_GA_URI_mapping{$msg{'dst'}}.'_advTextOffset'});
+}
+
+
+# Im Intervall oder nach Schreibtelegramm Werte aus der Kesselsteuerung lesen
+if (! %msg or ($msg{'apci'} eq "A_GroupValue_Write" and exists $write_GA_URI_mapping{$msg{'dst'}})) {
+ my @values = query_user_set_variables("http://".$IP_PU.$ResVariables, $set);
+
+ for my $value (@values) {
+ # Werte für String auf GA schreiben
+ if (exists $string_GA_URI{$value->{uri}}) {
+ my $dpt = $eibgaconf{$string_GA_URI{$value->{uri}}}{'DPTSubId'};
+ knx_write($string_GA_URI{$value->{uri}},$value->{strValue},$dpt);
+ plugin_log($plugname, $value->{uri}." - GA ".$string_GA_URI{$value->{uri}}.
+ " - String lesen: ".$value->{strValue});
+ }
+
+ # Werte für Value auf GA schreiben
+ if (exists $value_GA_URI{$value->{uri}}) {
+ my $dpt = $unit_DPT_mapping{$value->{unit}} || $eibgaconf{$value_GA_URI{$value->{uri}}}{'DPTSubId'};
+ knx_write($value_GA_URI{$value->{uri}},($value->{RAW}/$value->{scaleFactor}-$value->{advTextOffset}),$dpt);
+ plugin_log($plugname, $value->{uri}." - GA ".$value_GA_URI{$value->{uri}}.
+ " - Wert lesen: ".($value->{RAW}/$value->{scaleFactor}-$value->{advTextOffset}));
+ }
+
+ #Faktor und Offset für Write URI merken
+ if (exists $write_GA_URI{$value->{uri}} and $SetVar) {
+ $plugin_info{$plugname.'_'.$value->{uri}.'_scaleFactor'} = $value->{scaleFactor};
+ $plugin_info{$plugname.'_'.$value->{uri}.'_advTextOffset'} = $value->{advTextOffset};
+ }
+
+ # Werte für Value auf RRD schreiben
+ if (exists $value_URI_RRD_mapping{$value->{uri}}) {
+ update_rrd($value_URI_RRD_mapping{$value->{uri}},"",($value->{RAW}/$value->{scaleFactor}-$value->{advTextOffset}));
+ plugin_log($plugname, $value->{uri}." - RRD ".$value_URI_RRD_mapping{$value->{uri}}.
+ " - Wert: ".($value->{RAW}/$value->{scaleFactor}-$value->{advTextOffset}));
+ }
+ # Werte für Value auf RRD Tagesverbrauch schreiben
+ if (exists $value_URI_RRDdaycount_mapping{$value->{uri}}) {
+ # Falls RRD noch nicht existiert, so soll er angelegt werden
+ if (! -e $DirRrd.$value_URI_RRDdaycount_mapping{$value->{uri}}.".rrd" ) {
+ RRDs::create( $DirRrd.$value_URI_RRDdaycount_mapping{$value->{uri}}.".rrd",
+ '--step' => 86400,
+ 'DS:value:COUNTER:86500:0:10000000000',
+ 'RRA:AVERAGE:0.5:1:365', 'RRA:AVERAGE:0.5:7:300');
+ plugin_log($plugname,$value->{uri}." - COUNTER-RRD ".$value_URI_RRDdaycount_mapping{$value->{uri}}." neu angelegt");
+ }
+
+ update_rrd( $value_URI_RRDdaycount_mapping{$value->{uri}},"",
+ (86400*$value->{RAW}/$value->{scaleFactor}-$value->{advTextOffset}),"COUNTER");
+ plugin_log($plugname, $value->{uri}." - COUNTER-RRD ".
+ $value_URI_RRDdaycount_mapping{$value->{uri}}.
+ " - Wert: ".(86400*$value->{RAW}/$value->{scaleFactor}-$value->{advTextOffset}));
+ }
+ }
+
+ # Wenn keine Werte zurückgeben werden, beim nächsten Durchlauf Variablenset neu anlegen
+ if (@values eq 0) {
+ $plugin_info{$plugname.'_lastSetVariable'} = 0;
+ }
+
+ # Fehlerprotokoll auslesen
+ my @values = query_errors("http://".$IP_PU.$ResErrors);
+ knx_write($GA_AnzahlFehler,1,$eibgaconf{$GA_AnzahlFehler}{'DPTSubId'} || $DPT_GA_AnzahlFehler);
+ plugin_log($plugname,"Anzahl Fehlermeldungen: ".@values);
+ if (@values > 0) {
+ knx_write($GA_Fehler,1,$eibgaconf{$GA_Fehler}{'DPTSubId'} || $DPT_GA_Fehler);
+ for my $value (@values) {
+
+ # TODO: RSS-Feed schreiben
+ plugin_log($plugname, "Meldung (".$value->{time}."): ".$value->{priority}." - ".
+ $value->{msg}." (".$value->{RAW}.")");
+ }
+ }
+ else {
+ knx_write($GA_Fehler,0,$eibgaconf{$GA_Fehler}{'DPTSubId'} || $DPT_GA_Fehler);
+ }
+
+ $plugin_info{$plugname.'_lastDataUpdate'} = time();
+}
+
+
+
+sub query_user_set_variables {
+ my ($base_url, $set) = @_;
+ my $url = "$base_url/$set";
+ my $response = do_request(GET => $url);
+ return parse_response($response, 'variable');
+}
+
+sub do_request {
+ my ($type, $url) = @_;
+ my $request = HTTP::Request->new($type => $url);
+ my $ua = LWP::UserAgent->new;
+ my $response = $ua->request($request);
+ #unless ($response->is_success) {
+ # die $response->status_line;
+ #}
+ if ($url =~ m|http://localhost:|) {
+ # Sleep to allow testing with nc -l 8080 -w 1
+ sleep 1;
+ }
+ if ($response->content eq undef) {
+ return 'Abfrage '.$type.' - '.$url.' fehlgeschlagen' ;
+ }
+ return $response->content;
+}
+
+
+sub query_errors {
+ my ($url) = @_;
+ my $response = do_request(GET => $url);
+ return parse_response($response, 'error');
+}
+
+
+sub parse_response {
+ my ($response, $want_element) = @_;
+ my @result;
+
+ my $raw_value = '';
+ my $get_characters;
+ my $current_attributes;
+
+ my $start_handler = sub {
+ my ($expat, $element, %attr) = @_;
+
+ return if ($element ne $want_element);
+
+ $current_attributes = \%attr;
+ $get_characters = 1;
+ };
+
+ my $end_handler = sub {
+ my ($expat, $element) = @_;
+
+ return if ($element ne $want_element);
+ $get_characters = 0;
+
+ $current_attributes->{RAW} = $raw_value;
+ push @result, $current_attributes;
+ $raw_value = '';
+ };
+
+ my $char_handler = sub {
+ my ($expat, $value) = @_;
+ if ($get_characters) {
+ $raw_value .= $value;
+ }
+ };
+
+ my $parser = XML::Parser->new(Handlers => {Start => $start_handler,Char => $char_handler,End => $end_handler });
+ $parser->parse($response);
+ return @result;
+}
+
+
+sub set_value {
+ my ($base_url, $uri, $value) = @_;
+ my $url = "$base_url/$uri";
+ return post_request($url, value => $value);
+}
+
+
+sub post_request {
+ my ($url, %form) = @_;
+ my $ua = LWP::UserAgent->new;
+ my $response = $ua->post($url, \%form);
+ #unless ($response->is_success) {
+ # die $response->status_line;
+ #
+ if ($url =~ m|http://localhost:|) {
+ # Sleep to allow testing with nc -l 8080 -w 1
+ sleep 1;
+ }
+ return $response->content;
+}
+
+
+sub create_set {
+ my ($base_url, $set) = @_;
+ my $url = "$base_url/$set";
+ # Ignore errors here, set might already be existing
+ eval {
+ do_request(PUT => $url);
+ };
+}
+
+
+sub delete_set {
+ my ($base_url, $set) = @_;
+ my $url = "$base_url/$set";
+ do_request(DELETE => $url);
+}
+
+
+sub add_to_set {
+ my ($base_url, $set, $uri) = @_;
+ my $url = "$base_url/$set/$uri";
+ do_request(PUT => $url);
+}
+
+
+sub delete_from_set {
+ my ($base_url, $set, $uri) = @_;
+ my $url = "$base_url/$set/$uri";
+ do_request(DELETE => $url);
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <j-...@us...> - 2012-02-21 20:45:41
|
Revision: 712
http://openautomation.svn.sourceforge.net/openautomation/?rev=712&view=rev
Author: j-n-k
Date: 2012-02-21 20:45:34 +0000 (Tue, 21 Feb 2012)
Log Message:
-----------
Complete rework of colspan/rowspan-code, again
removed ".innerrowspanX", replaced with global ".innerrowspan"
removed ".widget_container .widget_container" (not needed anymore)
removed calculation of "colspanX", instead dynamic style-attributes
are added to all widgets
colspan/rowspan should now work correctly within groups
default-colspan is now given by a ".colspandefault" in basic.css,
the "width: X px;" makes a default widget-witdh of X/12th of screen-width
PLEASE: Test extensively, WFM in FF 10, Chrome 17, Safari 5.1.2 and on iOS 5.1
Modified Paths:
--------------
CometVisu/trunk/visu/designs/alaska/basic.css
CometVisu/trunk/visu/designs/alaska_slim/basic.css
CometVisu/trunk/visu/designs/designglobals.css
CometVisu/trunk/visu/designs/discreet/basic.css
CometVisu/trunk/visu/designs/discreet_sand/basic.css
CometVisu/trunk/visu/designs/discreet_slim/basic.css
CometVisu/trunk/visu/designs/pitchblack/basic.css
CometVisu/trunk/visu/designs/pure/basic.css
CometVisu/trunk/visu/designs/structure_pure.js
CometVisu/trunk/visu/lib/templateengine.js
Modified: CometVisu/trunk/visu/designs/alaska/basic.css
===================================================================
--- CometVisu/trunk/visu/designs/alaska/basic.css 2012-02-20 21:43:31 UTC (rev 711)
+++ CometVisu/trunk/visu/designs/alaska/basic.css 2012-02-21 20:45:34 UTC (rev 712)
@@ -87,18 +87,14 @@
text-decoration: none;
}
-.colspan0 { /* multiple of 8.33333% ! */
- width: 49.9998%;
+.colspandefault { /* in units of 1/12 screen width */
+ width: 6px;
}
.widget_container {
float: left;
}
-.widget_container .widget_container {
- width: 100%;
-}
-
.widget
{
margin: 0.2em;
Modified: CometVisu/trunk/visu/designs/alaska_slim/basic.css
===================================================================
--- CometVisu/trunk/visu/designs/alaska_slim/basic.css 2012-02-20 21:43:31 UTC (rev 711)
+++ CometVisu/trunk/visu/designs/alaska_slim/basic.css 2012-02-21 20:45:34 UTC (rev 712)
@@ -82,18 +82,14 @@
text-decoration: none;
}
-.colspan0 { /* multiple of 8.33333% ! */
- width: 33.33332%;
+.colspandefault { /* in units of 1/12 screen width */
+ width: 4px;
}
.widget_container {
float: left;
}
-.widget_container .widget_container {
- width: 100%;
-}
-
.widget
{
margin: 0.2em;
Modified: CometVisu/trunk/visu/designs/designglobals.css
===================================================================
--- CometVisu/trunk/visu/designs/designglobals.css 2012-02-20 21:43:31 UTC (rev 711)
+++ CometVisu/trunk/visu/designs/designglobals.css 2012-02-21 20:45:34 UTC (rev 712)
@@ -7,54 +7,14 @@
* class, this class is the default widget size
*/
-.colspan1 {
- width: 8.33333%;
+.innerrowspan {
+ position:absolute;
+ top:0;
+ bottom:0;
+ left:0;
+ right:0;
}
-.colspan2 {
- width: 16.66666%;
-}
-
-.colspan3 {
- width: 24.99999%;
-}
-
-.colspan4 {
- width: 33.33332%;
-}
-
-.colspan5 {
- width: 41.66665%;
-}
-
-.colspan6 {
- width: 49.99998%;
-}
-
-.colspan7 {
- width: 58.33331%;
-}
-
-.colspan8 {
- width: 66.66664%;
-}
-
-.colspan9 {
- width: 74.99997%;
-}
-
-.colspan10 {
- width: 83.33330%;
-}
-
-.colspan11 {
- width: 91.66663%;
-}
-
-.colspan12 {
- width: 99.99996%;
-}
-
/*
* global color declarations for stylings in all designs
* may be overloaded by designs
Modified: CometVisu/trunk/visu/designs/discreet/basic.css
===================================================================
--- CometVisu/trunk/visu/designs/discreet/basic.css 2012-02-20 21:43:31 UTC (rev 711)
+++ CometVisu/trunk/visu/designs/discreet/basic.css 2012-02-21 20:45:34 UTC (rev 712)
@@ -81,18 +81,14 @@
vertical-align: middle;
}
-.colspan0 { /* multiple of 8.33333% ! */
- width: 49.9998%;
+.colspandefault { /* in units of 1/12 screen width */
+ width: 6px;
}
.widget_container {
float: left;
}
-.widget_container .widget_container {
- width: 100%;
-}
-
.widget
{
margin: .2em;
Modified: CometVisu/trunk/visu/designs/discreet_sand/basic.css
===================================================================
--- CometVisu/trunk/visu/designs/discreet_sand/basic.css 2012-02-20 21:43:31 UTC (rev 711)
+++ CometVisu/trunk/visu/designs/discreet_sand/basic.css 2012-02-21 20:45:34 UTC (rev 712)
@@ -74,18 +74,14 @@
vertical-align: middle;
}
-.colspan0 { /* multiple of 8.33333% ! */
- width: 49.9998%;
+.colspandefault { /* in units of 1/12 screen width */
+ width: 6px;
}
.widget_container {
float: left;
}
-.widget_container .widget_container {
- width: 100%;
-}
-
.widget
{
margin: .2em;
Modified: CometVisu/trunk/visu/designs/discreet_slim/basic.css
===================================================================
--- CometVisu/trunk/visu/designs/discreet_slim/basic.css 2012-02-20 21:43:31 UTC (rev 711)
+++ CometVisu/trunk/visu/designs/discreet_slim/basic.css 2012-02-21 20:45:34 UTC (rev 712)
@@ -74,18 +74,14 @@
vertical-align: middle;
}
-.colspan0 { /* multiple of 8.33333% ! */
- width: 33.33332%;
+.colspandefault { /* in units of 1/12 screen width */
+ width: 4px;
}
.widget_container {
float: left;
}
-.widget_container .widget_container {
- width: 100%;
-}
-
.widget
{
margin: .1em;
Modified: CometVisu/trunk/visu/designs/pitchblack/basic.css
===================================================================
--- CometVisu/trunk/visu/designs/pitchblack/basic.css 2012-02-20 21:43:31 UTC (rev 711)
+++ CometVisu/trunk/visu/designs/pitchblack/basic.css 2012-02-21 20:45:34 UTC (rev 712)
@@ -39,7 +39,7 @@
div#top , .widget, .popup_background {
border-color: /* border */ #202020;
border-style: solid;
- border-width: 0 0.05em 0.05em 0.05em;
+ border-width: 0 1px 1px 1px;
}
#pages hr, body hr {
@@ -64,10 +64,17 @@
margin: 0;
}
-div#top, .widget {
+div#top, .widget, .widget.group {
margin: .2em .1em 0 .1em;
}
+.widget.group .widget {
+ background: #0D0D0D;
+ border: none;
+ margin: 0;
+ padding:0;
+}
+
.nav_path , .widget .actor, .diagram_inline {
margin-left: .2em;
}
@@ -107,10 +114,18 @@
padding: 0.3em;
}
+.widget.group {
+ padding: 0.3em 0 0.3em 0;
+}
+
.text >div, .rsslog .label, .popup >div.head {
padding-left: 0.3em;
}
+.group .text>div, .group .rsslog .label {
+ padding-left: 0.6em;
+}
+
#diagramTooltip {
padding: 2px;
}
@@ -133,8 +148,8 @@
font-size:80%;
}
-.lighton > div, .lightoff > div, .jalup > div, .jaldown > div, /* image-buttons */
- .jalstop > div, .singlewindowopen > div, .singlewindowclosed > div, .doublewindowleftopen > div,
+.lighton > div, .lightoff > div, .jalup, .jaldown, /* image-buttons */
+ .jalstop, .singlewindowopen > div, .singlewindowclosed > div, .doublewindowleftopen > div,
.doublewindowrightopen >div, .doublewindowbothclosed >div, .doublewindowbothopen >div {
font-size:0%;
}
@@ -241,15 +256,15 @@
vertical-align: middle;
}
-.colspan0 { /* multiple of 8.33333% ! */
- width: 8.33333%;
+.widget_container {
}
-.widget_container {
+.colspan0 {
+ width: 8.33333%;
}
-.widget_container .widget_container, .link > div, .link a , .switchPressed,
- .switchUnpressed, * html>body .clearfix, .info > div, .actor .value , .text>div{
+.link > div, .link a , .switchPressed, .switchUnpressed, * html>body .clearfix,
+ .info > div, .actor .value , .text>div {
width: 100%;
}
@@ -291,21 +306,20 @@
position: relative;
}
- .ui-slider { position: relative; text-align: left; }
+.ui-slider { position: relative; text-align: left; }
.ui-slider .ui-slider-handle { position: absolute; z-index: 2; width: .4em; height: 1.2em; cursor: default; }
.ui-slider .ui-slider-range { position: absolute; z-index: 1; font-size: .7em; display: block; border: 0; background-position: 0 0; }
- .ui-slider-horizontal { height: .8em; }
+.ui-slider-horizontal { height: .8em; }
.ui-slider-horizontal .ui-slider-handle { top: -.40em; margin-left: -0.4em;}
.ui-slider-horizontal .ui-slider-range { top: 0; height: 100%; }
.ui-slider-horizontal .ui-slider-range-min { left: 0; }
.ui-slider-horizontal .ui-slider-range-max { right: 0; }
- .ui-widget-content { border: 1px solid #707070; background: #000000 ; color: #000000; }
- .ui-widget-content a { color: #333333; }
- .ui-state-default, .ui-widget-content .ui-state-default, .ui-widget-header .ui-state-default { border: 1px solid #cccccc; background: #000 ; font-weight: bold; color: #1c94c4; }
- .ui-state-default a, .ui-state-default a:link, .ui-state-default a:visited { color: #1c94c4; text-decoration: none; }
-
+.ui-widget-content { border: 1px solid #707070; background: #000000 ; color: #000000; }
+.ui-widget-content a { color: #333333; }
+.ui-state-default, .ui-widget-content .ui-state-default, .ui-widget-header .ui-state-default { border: 1px solid #cccccc; background: #000 ; font-weight: bold; color: #1c94c4; }
+.ui-state-default a, .ui-state-default a:link, .ui-state-default a:visited { color: #1c94c4; text-decoration: none; }
.widget .ui-slider
{
@@ -408,3 +422,6 @@
background-color: #1d1d1d;
}
+.colspandefault {
+ width: 1px;
+}
Modified: CometVisu/trunk/visu/designs/pure/basic.css
===================================================================
--- CometVisu/trunk/visu/designs/pure/basic.css 2012-02-20 21:43:31 UTC (rev 711)
+++ CometVisu/trunk/visu/designs/pure/basic.css 2012-02-21 20:45:34 UTC (rev 712)
@@ -67,12 +67,8 @@
float: left;
}
-/*.widget_container .widget_container {
- width: 100%;
-}*/
-
-.colspan0 { /* multiple of 8.33333% ! */
- width: 49.9998%;
+.colspandefault { /* in units of 1/12 screen width */
+ width: 6px;
}
.widget
Modified: CometVisu/trunk/visu/designs/structure_pure.js
===================================================================
--- CometVisu/trunk/visu/designs/structure_pure.js 2012-02-20 21:43:31 UTC (rev 711)
+++ CometVisu/trunk/visu/designs/structure_pure.js 2012-02-21 20:45:34 UTC (rev 712)
@@ -55,10 +55,10 @@
*/
$.fn.setWidgetLayout = function(page) {
- this.data('colspanClass', 'colspan'+(page.attr('colspan') || '0'));
+ this.data('colspan', page.attr('colspan') || $('head').data('colspanDefault'));
if (page.attr('rowspan')) {
this.data('rowspanClass', rowspanClass(page.attr('rowspan') || 1));
- this.addClass(innerRowspanClass(page.attr('rowspan') || 1));
+ this.addClass('innerrowspan');
}
return this;
}
Modified: CometVisu/trunk/visu/lib/templateengine.js
===================================================================
--- CometVisu/trunk/visu/lib/templateengine.js 2012-02-20 21:43:31 UTC (rev 711)
+++ CometVisu/trunk/visu/lib/templateengine.js 2012-02-21 20:45:34 UTC (rev 712)
@@ -133,10 +133,11 @@
}
$( window ).bind( 'resize', handleResize );
+
function rowspanClass(rowspan) {
var className = 'rowspan'+ rowspan;
- if ( !$('head').data(className) ) {
+ if ( !$('#'+className+'Style').get(0) ) {
var dummyDiv = $('<div class="clearfix" id="calcrowspan"><div id="containerDiv" class="widget_container"><div class="widget clearfix text" id="innerDiv" /></div></div>')
.appendTo(document.body).show();
@@ -146,36 +147,12 @@
// append css style
- $('head').append('<style>.rowspan' + rowspan + ' { height: ' + rowspan*Math.round(singleHeight) + 'px; overflow:hidden;} </style>').data(className, 1);
+ $('head').append('<style id="'+className+'Style">.rowspan' + rowspan + ' { height: ' + rowspan*Math.round(singleHeight) + 'px; overflow:hidden; position:relative;} </style>').data(className, 1);
}
return className;
}
-function innerRowspanClass(rowspan) {
- var className = 'innerrowspan'+ rowspan;
-
- if ( !$('head').data(className)) {
- var dummyDiv = $('<div class="clearfix" id="calcinnerrowspan"><div id="containerDiv" class="widget_container"><div class="widget clearfix text" id="innerDiv" /></div></div>')
- .appendTo(document.body).show();
- $('#containerDiv').addClass(rowspanClass(rowspan));
-
- var outerHeight = parseFloat($('#containerDiv').css('height'));
- var innerDiv=$('#innerDiv');
- var margin=Math.round(parseFloat(innerDiv.css('marginTop')))+Math.round(parseFloat(innerDiv.css('marginBottom')));
- var padding=Math.round(parseFloat(innerDiv.css('paddingTop')))+Math.round(parseFloat(innerDiv.css('paddingBottom')));
- var border=Math.round(parseFloat(innerDiv.css('borderTopWidth')))+Math.round(parseFloat(innerDiv.css('borderBottomWidth')));
- var innerHeight=outerHeight-margin-padding-border;
- $('#calcinnerrowspan').remove();
-
- // append css style
- $('head').append('<style>.innerrowspan' + rowspan + ' { height: ' + innerHeight + 'px;} </style>').data(className, 1);
-
- }
-
- return className;
-}
-
function parseXML(xml) {
// erst mal den Cache für AJAX-Requests wieder aktivieren
$.ajaxSetup({cache: true});
@@ -313,8 +290,32 @@
// and now setup the pages
var page = $( 'pages > page', xml )[0]; // only one page element allowed...
+ $('head').append(($('<div class="colspandefault" id="colspandefault">')));
+ setTimeout(function() {
+ $('head').data('colspanDefault', parseInt($('#colspandefault').css('width')));
+ $('#colspandefault').remove();
+
create_pages(page, '0');
+ // all containers
+ if (!/(android|blackberry|iphone|ipod|series60|symbian|windows ce|palm)/i.test(navigator.userAgent.toLowerCase())) {
+ var allContainer = $('.widget_container');
+ allContainer.each(function(i, e) {
+ var ourColspan = $(e).children('*:first-child').data('colspan');
+ var ourWidth = ourColspan/12*100;
+ $(e).css('width', ourWidth+'%');
+ });
+
+ // and elements inside groups
+ var adjustableElements = $('.group .widget_container');
+ adjustableElements.each(function(i, e) {
+ var groupColspan = $(e).parentsUntil('.widget_container', '.group').data('colspan');
+ var ourColspan = $(e).children('.widget').data('colspan');
+ var ourWidth = ourColspan/groupColspan*100; // in percent
+ $(e).css('width', ourWidth+'%');
+ });
+ };
+
// setup the scrollable
main_scroll = $('#main').scrollable({keyboard: false, touch: false}).data('scrollable');
main_scroll.onSeek( updateTopNavigation );
@@ -342,6 +343,7 @@
visu.subscribe( ga_list );
$("#pages").triggerHandler("done");
+ }, 1);
}
function create_pages( page, path, flavour ) {
@@ -384,7 +386,6 @@
if (jQuery(retval).is(".widget") || (jQuery(retval).is(".group")) ) {
retval = jQuery("<div class='widget_container " +
- (retval.data("colspanClass") ? retval.data("colspanClass") : '') + " " +
(retval.data("rowspanClass") ? retval.data("rowspanClass") : '')+"' />")
.append(retval);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ma...@us...> - 2012-02-20 21:43:38
|
Revision: 711
http://openautomation.svn.sourceforge.net/openautomation/?rev=711&view=rev
Author: mayerch
Date: 2012-02-20 21:43:31 +0000 (Mon, 20 Feb 2012)
Log Message:
-----------
Big step towards a self contained and clean libaray.
Still missing (not in this commit to keep revision to revision comparisions readable):
* sort stuff between the helper and the library
* sort functions and variables inside of the library
* proper indentation
Modified Paths:
--------------
JSFloorPlan/trunk/src/jsfloorplan.js
JSFloorPlan/trunk/src/jsfloorplan_example_helper.js
Modified: JSFloorPlan/trunk/src/jsfloorplan.js
===================================================================
--- JSFloorPlan/trunk/src/jsfloorplan.js 2012-02-19 23:12:54 UTC (rev 710)
+++ JSFloorPlan/trunk/src/jsfloorplan.js 2012-02-20 21:43:31 UTC (rev 711)
@@ -135,31 +135,39 @@
* @title JS FloorPlan 3D
* @reqires jQuery, Three.js
*/
-if (typeof JSFLOORPLAN3D == 'undefined' || !JSFLOORPLAN3D)
-{
- /*
- * The JSFLOORPLAN3D global namespace object. If JSFLOORPLAN3D is already
- * defined, the existing JSFLOORPLAN3D object will not be overwritten so
- * that defined namespaces are preserved.
- */
- var JSFLOORPLAN3D = {};
-}
/**
* @class JSFLOORPLAN3D
* @constructor FOO
*/
-JSFLOORPLAN3D = function () {
+(function( window, undefined ){
+ // the constructor
+ var JSFloorPlan3D = function( floorPlan ){
+ if (!(this instanceof JSFloorPlan3D))
+ {
+ return new JSFloorPlan3D( floorPlan );
+ }
+
+ if (typeof floorPlan === "string")
+ {
+ this.loadFloorPlan( floorPlan );
+ }
+
+ // public variables of this object instance
+ this.buildingProperties = { floor: [], Object3D: new THREE.Object3D() };
+
+ // private variables of this object instance will follow
+
+ var that = this;
+
////////////////////////////////////////////////////////////////////////////
// Definition of the private variables
- var JSFloorPlan3D = this;
var floor;
// this array will contain all vertices to show in the svg
var vertices = Array();
// infos about the building
- JSFloorPlan3D.buildingProperties = { floor: [], Object3D: new THREE.Object3D() };
var imageCenter = new Object;
var noFloorplan = true;
@@ -290,11 +298,27 @@
}
/**
+ * Get the URL url and set up this object by its content
+ * @param {String} url
+ */
+ JSFloorPlan3D.prototype.loadFloorPlan = function( url )
+ {
+ var outerThis = this;
+ $.ajax({
+ url: url,
+ context: outerThis,
+ success: function( xmlDoc ){ outerThis.parseXMLFloorPlan( xmlDoc ); },
+ dataType: 'xml',
+ async: false
+ });
+ }
+
+ /**
* Parse and create internal structure for the floor plan.
* @method parseXMLFloorPlan
* @param {XMLDom} xmlDoc
*/
- JSFloorPlan3D.parseXMLFloorPlan = function( xmlDoc )
+ JSFloorPlan3D.prototype.parseXMLFloorPlan = function( xmlDoc )
{
noFloorplan = false;
@@ -320,7 +344,7 @@
if( floor.tagName == 'textures' )
{
- parseTextures( floor );
+ this.parseTextures( floor );
continue;
}
@@ -329,14 +353,14 @@
"Expected: 'floor', found '" + floor.tagName + "'" );
floorCount++;
- JSFloorPlan3D.buildingProperties.floor[floorCount] = {};
+ this.buildingProperties.floor[floorCount] = {};
var floorName = floor.getAttribute('name');
- JSFloorPlan3D.buildingProperties.floor[floorCount].name = floorName;
+ this.buildingProperties.floor[floorCount].name = floorName;
var floorheight = Number( floor.getAttribute('height') );
- JSFloorPlan3D.buildingProperties.floor[floorCount].height = floorheight;
- JSFloorPlan3D.buildingProperties.floor[floorCount].heightOfGround = heightOfGround;
+ this.buildingProperties.floor[floorCount].height = floorheight;
+ this.buildingProperties.floor[floorCount].heightOfGround = heightOfGround;
var floorWallsStart = floorWalls.length;
@@ -349,15 +373,15 @@
switch( floorNode.tagName )
{
case 'nodes':
- parseFloorNodes( floorNode, floorheight );
+ this.parseFloorNodes( floorNode, floorheight );
break;
case 'walls':
- parseFloorWalls( floorNode );
+ this.parseFloorWalls( floorNode );
break;
case 'rooms':
- parseFloorRooms( floorNode, floorCount );
+ this.parseFloorRooms( floorNode, floorCount );
break;
}
}
@@ -544,7 +568,6 @@
sourrounding.splice( 0, 0, new poly2tri.Point(fRight,0), new poly2tri.Point(fRight,lintel), new poly2tri.Point(fLeft,lintel), new poly2tri.Point(fLeft,0) );
continue;
}
-
holesToAdd.push( [new poly2tri.Point(fLeft,paparet), new poly2tri.Point(fRight,paparet), new poly2tri.Point(fRight,lintel), new poly2tri.Point(fLeft,lintel)] );
}
} // if( floorWalls[j].holes.length )
@@ -555,7 +578,9 @@
// Do the triangulation - FIXME: handle exceptions, don't ignore them...
try {
poly2tri.sweep.Triangulate(swctx);
- }catch(err){}
+ }catch(err){
+ console.log(err);
+ }
// mark all points to make sure that we don't need to double vertices
for( var tp = 0; tp < swctx.point_count(); tp++ )
@@ -674,23 +699,23 @@
Object3D.add( lineGroup );
Object3D.add( wallGroup );
- JSFloorPlan3D.buildingProperties.floor[floorCount].Object3D = Object3D;
- JSFloorPlan3D.buildingProperties.floor[floorCount].nodeGroup = nodeGroup;
- JSFloorPlan3D.buildingProperties.floor[floorCount].lineGroup = lineGroup;
- JSFloorPlan3D.buildingProperties.floor[floorCount].wallGroup = wallGroup;
- JSFloorPlan3D.buildingProperties.Object3D.add( Object3D ); // add / link; note: we use that JavaScript is not copying objects but uses ref counting on them here!
+ this.buildingProperties.floor[floorCount].Object3D = Object3D;
+ this.buildingProperties.floor[floorCount].nodeGroup = nodeGroup;
+ this.buildingProperties.floor[floorCount].lineGroup = lineGroup;
+ this.buildingProperties.floor[floorCount].wallGroup = wallGroup;
+ this.buildingProperties.Object3D.add( Object3D ); // add / link; note: we use that JavaScript is not copying objects but uses ref counting on them here!
heightOfGround += floorheight;
} // end floor
- JSFloorPlan3D.buildingProperties.x_center = (JSFloorPlan3D.buildingProperties.x_max - JSFloorPlan3D.buildingProperties.x_min) / 2;
- JSFloorPlan3D.buildingProperties.y_center = (JSFloorPlan3D.buildingProperties.y_max - JSFloorPlan3D.buildingProperties.y_min) / 2;
- JSFloorPlan3D.buildingProperties.size = Math.max( JSFloorPlan3D.buildingProperties.x_center, JSFloorPlan3D.buildingProperties.y_center );
- imageCenter.x = JSFloorPlan3D.buildingProperties.x_center;
- imageCenter.y = JSFloorPlan3D.buildingProperties.y_center;
- imageCenter.z = JSFloorPlan3D.buildingProperties.z_max / 2;
+ this.buildingProperties.x_center = (this.buildingProperties.x_max - this.buildingProperties.x_min) / 2;
+ this.buildingProperties.y_center = (this.buildingProperties.y_max - this.buildingProperties.y_min) / 2;
+ this.buildingProperties.size = Math.max( this.buildingProperties.x_center, this.buildingProperties.y_center );
+ imageCenter.x = this.buildingProperties.x_center;
+ imageCenter.y = this.buildingProperties.y_center;
+ imageCenter.z = this.buildingProperties.z_max / 2;
- JSFloorPlan3D.show3D( 35*Math.PI/180, 30*Math.PI/180, 10, new THREE.Vector3( imageCenter.x, imageCenter.y, imageCenter.z ) );
+ this.show3D( 35*Math.PI/180, 30*Math.PI/180, 10, new THREE.Vector3( imageCenter.x, imageCenter.y, imageCenter.z ) );
//}
};
@@ -703,7 +728,7 @@
* @param {Float} floorheight The generic height of this floor that might be
* overwritten by individual nodes.
*/
- function parseFloorNodes( nodes, floorheight )
+ JSFloorPlan3D.prototype.parseFloorNodes = function( nodes, floorheight )
{
for( var i=0; i < nodes.childNodes.length; i++ )
{
@@ -719,21 +744,21 @@
floorNodes[id] = point;
- if( undefined == JSFloorPlan3D.buildingProperties.x_min )
+ if( undefined == this.buildingProperties.x_min )
{
- JSFloorPlan3D.buildingProperties.x_min = point.x;
- JSFloorPlan3D.buildingProperties.x_max = point.x;
- JSFloorPlan3D.buildingProperties.y_min = point.y;
- JSFloorPlan3D.buildingProperties.y_max = point.y;
- JSFloorPlan3D.buildingProperties.z_min = point.z;
- JSFloorPlan3D.buildingProperties.z_max = point.z;
+ this.buildingProperties.x_min = point.x;
+ this.buildingProperties.x_max = point.x;
+ this.buildingProperties.y_min = point.y;
+ this.buildingProperties.y_max = point.y;
+ this.buildingProperties.z_min = point.z;
+ this.buildingProperties.z_max = point.z;
} else {
- if( JSFloorPlan3D.buildingProperties.x_min > point.x ) JSFloorPlan3D.buildingProperties.x_min = point.x;
- if( JSFloorPlan3D.buildingProperties.x_max < point.x ) JSFloorPlan3D.buildingProperties.x_max = point.x;
- if( JSFloorPlan3D.buildingProperties.y_min > point.y ) JSFloorPlan3D.buildingProperties.y_min = point.y;
- if( JSFloorPlan3D.buildingProperties.y_max < point.y ) JSFloorPlan3D.buildingProperties.y_max = point.y;
- if( JSFloorPlan3D.buildingProperties.z_min > point.z ) JSFloorPlan3D.buildingProperties.z_min = point.z;
- if( JSFloorPlan3D.buildingProperties.z_max < point.z ) JSFloorPlan3D.buildingProperties.z_max = point.z;
+ if( this.buildingProperties.x_min > point.x ) this.buildingProperties.x_min = point.x;
+ if( this.buildingProperties.x_max < point.x ) this.buildingProperties.x_max = point.x;
+ if( this.buildingProperties.y_min > point.y ) this.buildingProperties.y_min = point.y;
+ if( this.buildingProperties.y_max < point.y ) this.buildingProperties.y_max = point.y;
+ if( this.buildingProperties.z_min > point.z ) this.buildingProperties.z_min = point.z;
+ if( this.buildingProperties.z_max < point.z ) this.buildingProperties.z_max = point.z;
}
}
}
@@ -745,7 +770,7 @@
* @private
* @param {XMLDom} nodeGroup
*/
- function parseFloorWalls( nodes )
+ JSFloorPlan3D.prototype.parseFloorWalls = function( nodes )
{
for( var i=0; i < nodes.childNodes.length; i++ )
{
@@ -832,7 +857,7 @@
* @param {XMLDom} nodeGroup
* @param {Integer} floor The floor number.
*/
- function parseFloorRooms( nodes, floor )
+ JSFloorPlan3D.prototype.parseFloorRooms = function( nodes, floor )
{
rooms[floor] = new Array;
for( var i=0; i < nodes.childNodes.length; i++ )
@@ -892,7 +917,7 @@
* @private
* @param {XMLDom} nodes
*/
- function parseTextures( nodes )
+ JSFloorPlan3D.prototype.parseTextures = function( nodes )
{
return;
for( var i=0; i < nodes.childNodes.length; i++ )
@@ -907,12 +932,12 @@
* @method setup3D
* @private
*/
- function setup3D()
+ function setup3D( thisObject3D )
{
if( noFloorplan ) return;
noSetup = false;
- scene.add( JSFloorPlan3D.buildingProperties.Object3D );
+ scene.add( thisObject3D );
var showFloor = showStates.showFloor;
@@ -953,14 +978,14 @@
* @param {Number} distnce Distance between camera and <code>target</code>
* @param {THREE.Vector3} target The point to look at
*/
- JSFloorPlan3D.show3D = function( azimut, elevation, distance, target )
+ JSFloorPlan3D.prototype.show3D = function( azimut, elevation, distance, target )
{
showStates.currentAzimut = azimut;
showStates.currentElevation = elevation;
showStates.currentDistance = distance;
showStates.currentTarget = target.clone(); //JSFloorPlan3D.buildingProperties.x_center;
- if( noSetup ) setup3D();
+ if( noSetup ) setup3D( this.buildingProperties.Object3D );
// set up camera
setupCamera( azimut, elevation, distance, target );
@@ -1034,9 +1059,9 @@
* @param {Function} delayedFn (optional) Function to call after animation is
* finished
*/
- JSFloorPlan3D.moveTo = function( floor, azimut, elevation, distance, target, delayedFn )
+ JSFloorPlan3D.prototype.moveTo = function( floor, azimut, elevation, distance, target, delayedFn )
{
- if( noSetup ) setup3D();
+ if( noSetup ) setup3D( this.buildingProperties.Object3D );
// speed of the changing
var steps = 100;
@@ -1166,7 +1191,7 @@
* @return {Object} If a zone / room was found a hash with the keys "room" and
* "zone" will be returned otherwise an empty Object.
*/
- JSFloorPlan3D.selectRoom = function( p, floor )
+ JSFloorPlan3D.prototype.selectRoom = function( p, floor )
{
var thisFloor = rooms[floor];
for( var room in thisFloor )
@@ -1191,7 +1216,7 @@
* @param {Number} h Height in building space used for mapping
* @return {THREE.Vector3} Point in building space
*/
- JSFloorPlan3D.sceen2building = function( x, y, h )
+ JSFloorPlan3D.prototype.sceen2building = function( x, y, h )
{
var vector = new THREE.Vector3( (x / WIDTH)*2-1, -(y / HEIGHT)*2+1, 0.5 );
projector.unprojectVector( vector, camera );
@@ -1207,7 +1232,7 @@
* @return {Object} Hash with keys <code>x</code> and <code>y</code> in screen
* coordinates
*/
- JSFloorPlan3D.building2screen = function( p )
+ JSFloorPlan3D.prototype.building2screen = function( p )
{
var screen = p.clone();
projector.projectVector( screen, camera );
@@ -1221,12 +1246,19 @@
* @param {Function} event.data.callback This callback function will be called
* after the mouse event was translated
*/
- JSFloorPlan3D.translateMouseEvent = function( event )
+ JSFloorPlan3D.prototype.translateMouseEvent = function( event )
{
- var thisFloor = JSFloorPlan3D.buildingProperties.floor[showStates.showFloor];
+ var tJSFloorPlan3D = event.data.JSFloorPlan3D;
+ var thisFloor = tJSFloorPlan3D.buildingProperties.floor[showStates.showFloor];
var height = thisFloor.heightOfGround + thisFloor.height;
- var intersec = JSFloorPlan3D.sceen2building( event.offsetX, event.offsetY, height );
- event.room = JSFloorPlan3D.selectRoom( intersec, showStates.showFloor );
+ var intersec = tJSFloorPlan3D.sceen2building( event.offsetX, event.offsetY, height );
+ event.room = tJSFloorPlan3D.selectRoom( intersec, showStates.showFloor );
if( event.data.callback ) event.data.callback( event );
}
-};//());
\ No newline at end of file
+
+ };
+ // library local variables
+
+ //Expose dQuery object to window as dQuery or JSlib
+ window.JSFloorPlan3D = JSFloorPlan3D;
+})(window);
\ No newline at end of file
Modified: JSFloorPlan/trunk/src/jsfloorplan_example_helper.js
===================================================================
--- JSFloorPlan/trunk/src/jsfloorplan_example_helper.js 2012-02-19 23:12:54 UTC (rev 710)
+++ JSFloorPlan/trunk/src/jsfloorplan_example_helper.js 2012-02-20 21:43:31 UTC (rev 711)
@@ -27,18 +27,6 @@
* @module JS FloorPlan 3D Example
*/
-j = new JSFLOORPLAN3D();
-function loadFloorplan()
-{
- $.ajax({
- url: 'floorplan01.xml',
- success: j.parseXMLFloorPlan,
- dataType: 'xml',
- async: false
- });
-}
-
-
function three_init()
{
return;
@@ -229,10 +217,6 @@
j.moveTo( showStates['showFloor'], roll, tilt, dist, target );
}
/////////////////////////////////////////////////////////////////////////////
-$(function() {
- three_init();
- $('#top_level').css('border','1px solid black').click( {callback:handleMouseClickEvent}, j.translateMouseEvent );
-});
/////////////////////////////////////////////////////////////////////////////
// setup script here:
var sc = 40; // overall scaling
@@ -269,6 +253,8 @@
var t_25d_after_sort;
var t_25d_end;
+j = new JSFloorPlan3D();
+
function init()
{
$('input').change(function(e){
@@ -292,7 +278,8 @@
showStates[ this.name ] = this.value; // init
});
- loadFloorplan();
+ //loadFloorplan();
+ j.loadFloorPlan('floorplan_demo.xml');
target.x = j.buildingProperties.x_center;
target.y = j.buildingProperties.y_center;
createSlider();
@@ -636,4 +623,9 @@
azimuth: azimuth * 180/Math.PI,
altitude: Math.atan2( sin_a, azimuth ) * 180/Math.PI
};
-}
\ No newline at end of file
+}
+
+$(function() {
+ three_init();
+ $('#top_level').css('border','1px solid black').click( {callback:handleMouseClickEvent,JSFloorPlan3D:j}, j.translateMouseEvent );
+});
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tho...@us...> - 2012-02-19 23:13:02
|
Revision: 710
http://openautomation.svn.sourceforge.net/openautomation/?rev=710&view=rev
Author: thomas_s
Date: 2012-02-19 23:12:54 +0000 (Sun, 19 Feb 2012)
Log Message:
-----------
- refactored determinatoritems
- added determinator actions (not fully implemented)
- refactored xplhandler to use asio for calling xPL_process_messages
WIP!
Modified Paths:
--------------
xPLHAL/branches/thomas_s_dev/CMakeLists.txt
xPLHAL/branches/thomas_s_dev/src/determinator.cpp
xPLHAL/branches/thomas_s_dev/src/determinator.h
xPLHAL/branches/thomas_s_dev/src/determinatoritems.cpp
xPLHAL/branches/thomas_s_dev/src/determinatoritems.h
xPLHAL/branches/thomas_s_dev/src/globals.h
xPLHAL/branches/thomas_s_dev/src/main.cpp
xPLHAL/branches/thomas_s_dev/src/xplhandler.cpp
xPLHAL/branches/thomas_s_dev/src/xplhandler.h
xPLHAL/branches/thomas_s_dev/src/xplmessagequeue.cpp
xPLHAL/branches/thomas_s_dev/src/xplmessagequeue.h
xPLHAL/branches/thomas_s_dev/test/determinator1.xml
xPLHAL/branches/thomas_s_dev/test/test_determinator.cpp
Added Paths:
-----------
xPLHAL/branches/thomas_s_dev/src/actions/
xPLHAL/branches/thomas_s_dev/src/conditions/
xPLHAL/branches/thomas_s_dev/test/pugi.h
Modified: xPLHAL/branches/thomas_s_dev/CMakeLists.txt
===================================================================
--- xPLHAL/branches/thomas_s_dev/CMakeLists.txt 2012-02-19 12:22:04 UTC (rev 709)
+++ xPLHAL/branches/thomas_s_dev/CMakeLists.txt 2012-02-19 23:12:54 UTC (rev 710)
@@ -37,7 +37,7 @@
#set(Boost_USE_STATIC_LIBS ON)
set(Boost_USE_MULTITHREADED ON)
-find_package(Boost 1.38 COMPONENTS thread system filesystem date_time regex unit_test_framework)
+find_package(Boost 1.38 COMPONENTS thread system filesystem date_time regex unit_test_framework program_options)
find_package(xPL REQUIRED)
set(LIBS ${LIBS} ${Boost_LIBRARIES} ${xPL_LIBRARIES} pthread)
Modified: xPLHAL/branches/thomas_s_dev/src/determinator.cpp
===================================================================
--- xPLHAL/branches/thomas_s_dev/src/determinator.cpp 2012-02-19 12:22:04 UTC (rev 709)
+++ xPLHAL/branches/thomas_s_dev/src/determinator.cpp 2012-02-19 23:12:54 UTC (rev 710)
@@ -3,11 +3,14 @@
#include <cxxabi.h>
#include <typeinfo>
#include <memory>
+#include <functional>
using std::string;
using std::vector;
using std::cerr;
using std::endl;
+using std::thread;
+using std::bind;
void Determinator::printDeterminator() const
{
@@ -38,7 +41,8 @@
registerCondition(BaseDeterminatorItemConstPtr(new DayCondition));
registerCondition(BaseDeterminatorItemConstPtr(new TimeCondition));
- registerAction(BaseDeterminatorItemConstPtr(new LogAction));
+ registerAction(BaseDeterminatorItemConstPtr(new logAction));
+ registerAction(BaseDeterminatorItemConstPtr(new xplAction));
pugi::xml_parse_result result = m_doc.load_file(filename.c_str());
cerr << "Load result: " << result.description() << "\n";
@@ -70,6 +74,11 @@
d.enabled = base_d.attribute("guid").value() == "Y";
pugi::xml_node input = base_d.child("input");
+ d.input_match_type = Determinator::match_type::ALL;
+ if (input.attribute("match").value() == "any") {
+ d.input_match_type = Determinator::match_type::ANY;
+ }
+
pugi::xml_node output = base_d.child("output");
for(auto condition : m_conditionmap) {
@@ -81,7 +90,8 @@
for(auto action : m_actionmap) {
pugi::xml_node action_node = output.child(action.first.c_str());
if (action_node) {
- d.outputs.insert({action.first, BaseDeterminatorItemPtr(action.second->createNew(action_node))} );
+ BaseDeterminatorItemPtr actionObject(action.second->createNew(action_node));
+ d.outputs.insert({action.first, actionObject});
}
}
@@ -108,4 +118,59 @@
}
return node;
}
+
+Determinator::Determinator()
+{
+}
+Determinator::~Determinator()
+{
+ if (mExecuteThread) {
+ mExecuteThread->join();
+ }
+}
+
+bool Determinator::checkInputs() const
+{
+ for (auto input : inputs) {
+ bool match = input.second->match();
+ switch(input_match_type) {
+ case match_type::ALL: if (!match) return false;
+ case match_type::ANY: if (match) return true;
+ }
+ }
+ return (input_match_type == match_type::ALL);
+}
+
+void Determinator::executeOutputs() const
+{
+ std::multimap<string, BaseDeterminatorItemPtr> orderd_outputs;
+ for (auto output : outputs) {
+ string execOrder;
+ auto execOrderIter = output.second->attributes.find("executeOrder");
+ if (execOrderIter != output.second->attributes.end()) {
+ execOrder = execOrderIter->second;
+ }
+ orderd_outputs.insert({execOrder, output.second});
+ }
+
+ for (auto output : orderd_outputs) {
+ cerr << "execute output:" << output.second->display_name << endl;
+ output.second->execute();
+ }
+}
+
+/**
+ * Check if input conditions are met, then start a thread to execute actions
+ */
+void Determinator::execute()
+{
+ if (checkInputs()) {
+ if (mExecuteThread) {
+ mExecuteThread->join();
+ }
+ cerr << "determinator start thread" << endl;
+ mExecuteThread.reset(new thread(bind(&Determinator::executeOutputs, this)));
+ }
+}
+
Modified: xPLHAL/branches/thomas_s_dev/src/determinator.h
===================================================================
--- xPLHAL/branches/thomas_s_dev/src/determinator.h 2012-02-19 12:22:04 UTC (rev 709)
+++ xPLHAL/branches/thomas_s_dev/src/determinator.h 2012-02-19 23:12:54 UTC (rev 710)
@@ -4,14 +4,20 @@
#include <string>
#include <vector>
#include <map>
+#include <thread>
class Determinator
{
public:
+ explicit Determinator();
+ virtual ~Determinator();
+
enum class match_type { ALL, ANY };
void printDeterminator() const;
+ void execute();
+
std::string guid;
std::string name;
std::string description;
@@ -20,6 +26,12 @@
std::multimap<std::string, BaseDeterminatorItemPtr> inputs;
std::multimap<std::string, BaseDeterminatorItemPtr> outputs;
+
+ private:
+ bool checkInputs() const;
+ void executeOutputs() const;
+
+ std::unique_ptr<std::thread> mExecuteThread;
};
class DeterminatorXmlParser
Modified: xPLHAL/branches/thomas_s_dev/src/determinatoritems.cpp
===================================================================
--- xPLHAL/branches/thomas_s_dev/src/determinatoritems.cpp 2012-02-19 12:22:04 UTC (rev 709)
+++ xPLHAL/branches/thomas_s_dev/src/determinatoritems.cpp 2012-02-19 23:12:54 UTC (rev 710)
@@ -3,21 +3,12 @@
#include <iostream>
#include <typeinfo>
#include <iostream>
+#include "log.h"
using std::string;
using std::vector;
+using std::map;
-ConditionParseException::ConditionParseException(const string& text)
-:m_text(text)
-{
-}
-
-const char* ConditionParseException::what() const throw()
-{
- return m_text.c_str();
-
-}
-
DeterminatorParseException::DeterminatorParseException(const string& text)
:m_text(text)
{
@@ -32,18 +23,21 @@
class ScopedXmlAttributeGetter
{
public:
- ScopedXmlAttributeGetter(const pugi::xml_node& basenode) :m_basenode(basenode) {}
+ ScopedXmlAttributeGetter(const pugi::xml_node& basenode, map<string, string> &attributemap)
+ :m_basenode(basenode),m_attributemap(attributemap) {}
string get(const string& attribute_name) const {
pugi::xml_attribute xml_attribute = m_basenode.attribute(attribute_name.c_str());
if (!xml_attribute) {
string error_text = string("In node '") + m_basenode.name() + "'";
error_text += " attribute '" + attribute_name + "' was not found";
- throw ConditionParseException(error_text);
+ throw DeterminatorParseException(error_text);
}
+ m_attributemap.insert({attribute_name, xml_attribute.value()});
return xml_attribute.value();
}
private:
const pugi::xml_node& m_basenode;
+ map<string, string> &m_attributemap;
};
BaseDeterminatorItem::BaseDeterminatorItem(const string& name)
@@ -54,10 +48,19 @@
BaseDeterminatorItem::BaseDeterminatorItem(const pugi::xml_node& basenode, const string& name)
:item_name(name)
{
- ScopedXmlAttributeGetter a(basenode);
+ ScopedXmlAttributeGetter a(basenode, attributes);
display_name = a.get("display_name");
}
+
+bool BaseDeterminatorItem::match() const
+{
+ return true;
+}
+void BaseDeterminatorItem::execute() const
+{
+}
+
/*
* Determinator Conditions
*/
@@ -80,7 +83,7 @@
void XplCondition::parseFromXml(const pugi::xml_node& basenode)
{
- ScopedXmlAttributeGetter helper(basenode);
+ ScopedXmlAttributeGetter helper(basenode, attributes);
msg_type = helper.get("msg_type");
source_vendor = helper.get("source_vendor");
source_device = helper.get("source_device");
@@ -94,7 +97,7 @@
for(const auto node : basenode) {
if (node.name() == string("param")) {
struct parameter p;
- ScopedXmlAttributeGetter pa(node);
+ ScopedXmlAttributeGetter pa(node, attributes);
p.name = pa.get("name");
p.op = pa.get("operator");
p.value = pa.get("value");
@@ -120,8 +123,7 @@
}
return ret;
}
-
-
+
GlobalCondition::GlobalCondition()
:BaseDeterminatorItem("globalCondition")
{
@@ -140,9 +142,10 @@
void GlobalCondition::parseFromXml(const pugi::xml_node& basenode)
{
- name = basenode.attribute("name").value();
- op = basenode.attribute("operator").value();
- value = basenode.attribute("value").value();
+ ScopedXmlAttributeGetter helper(basenode, attributes);
+ name = helper.get("name");
+ op = helper.get("operator");
+ value = helper.get("value");
}
string GlobalCondition::toString() const
@@ -172,7 +175,8 @@
void GlobalChanged::parseFromXml(const pugi::xml_node& basenode)
{
- name = basenode.attribute("name").value();
+ ScopedXmlAttributeGetter helper(basenode, attributes);
+ name = helper.get("name");
}
string GlobalChanged::toString() const
@@ -201,7 +205,8 @@
void DayCondition::parseFromXml(const pugi::xml_node& basenode)
{
- dow = basenode.attribute("dow").value();
+ ScopedXmlAttributeGetter helper(basenode, attributes);
+ dow = helper.get("dow");
}
string DayCondition::toString() const
@@ -229,8 +234,9 @@
void TimeCondition::parseFromXml(const pugi::xml_node& basenode)
{
- op = basenode.attribute("operator").value();
- value = basenode.attribute("value").value();
+ ScopedXmlAttributeGetter helper(basenode, attributes);
+ op = helper.get("operator");
+ value = helper.get("value");
}
string TimeCondition::toString() const
@@ -245,33 +251,54 @@
* Determinator Actions
*/
-LogAction::LogAction()
-:BaseDeterminatorItem("logAction")
+void logAction::parseFromXml(const pugi::xml_node& basenode)
{
+ ScopedXmlAttributeGetter helper(basenode, attributes);
+ logText = helper.get("logText");
+ executeOrder = helper.get("executeOrder");
}
-LogAction::LogAction(const pugi::xml_node& basenode)
-:BaseDeterminatorItem(basenode, "logAction")
+std::string logAction::toString() const
{
- parseFromXml(basenode);
+ string ret = item_name + ":";
+ ret += "\nlogText.....: " + logText;
+ ret += "\nexecuteOrder: " + executeOrder;
+ return ret;
}
-BaseDeterminatorItemPtr LogAction::createNew(const pugi::xml_node& basenode) const
+void logAction::execute() const
{
- return BaseDeterminatorItemPtr(new LogAction(basenode));
+ writeLog(logText, logLevel::debug);
}
-void LogAction::parseFromXml(const pugi::xml_node& basenode)
+//-----
+
+void xplAction::parseFromXml(const pugi::xml_node& basenode)
{
- logText = basenode.attribute("logText").value();
- executeOrder = basenode.attribute("executeOrder").value();
+ ScopedXmlAttributeGetter helper(basenode, attributes);
+ executeOrder = helper.get("executeOrder");
+ msgType = helper.get("msgType");
+ msgTarget = helper.get("msgTarget");
+ msgSchema = helper.get("msgSchema");
+
+ for(const auto node : basenode) {
+ if (node.name() == string("xplActionParam")) {
+ string expression = node.attribute("expression").value();
+ }
+ }
}
-std::string LogAction::toString() const
+std::string xplAction::toString() const
{
string ret = item_name + ":";
- ret += "\nlogText.....: " + logText;
ret += "\nexecuteOrder: " + executeOrder;
+ ret += "\nmsgType.....: " + msgType;
+ ret += "\nmsgTarget...: " + msgTarget;
+ ret += "\nmsgSchema...: " + msgSchema;
return ret;
}
+void xplAction::execute() const
+{
+}
+
Modified: xPLHAL/branches/thomas_s_dev/src/determinatoritems.h
===================================================================
--- xPLHAL/branches/thomas_s_dev/src/determinatoritems.h 2012-02-19 12:22:04 UTC (rev 709)
+++ xPLHAL/branches/thomas_s_dev/src/determinatoritems.h 2012-02-19 23:12:54 UTC (rev 710)
@@ -3,17 +3,8 @@
#include <string>
#include <vector>
#include <memory>
+#include <map>
-class ConditionParseException: public std::exception
-{
- public:
- ConditionParseException(const std::string& text);
- virtual ~ConditionParseException() throw() {}
- const char* what() const throw();
- private:
- std::string m_text;
-};
-
class DeterminatorParseException: public std::exception
{
public:
@@ -37,13 +28,40 @@
virtual void parseFromXml(const pugi::xml_node& basenode) = 0;
virtual BaseDeterminatorItemPtr createNew(const pugi::xml_node& basenode) const = 0;
virtual std::string toString() const = 0;
+ virtual bool match() const;
+ virtual void execute() const;
std::string item_name;
std::string display_name;
+ std::map<std::string, std::string> attributes;
+
//boost::signal2::signal<void ()> sigChanged;
};
+template<typename T>
+class DeterminatorAction: public BaseDeterminatorItem
+{
+ public:
+ DeterminatorAction() :BaseDeterminatorItem(typeid(T).name()) { }
+ DeterminatorAction(const pugi::xml_node& basenode)
+ :BaseDeterminatorItem(basenode, std::string(typeid(T).name())) {
+ executeOrder = basenode.attribute("executeOrder").value();
+ attributes["executeOrder"] = executeOrder;
+ }
+
+ BaseDeterminatorItemPtr createNew(const pugi::xml_node& basenode) const {
+ return BaseDeterminatorItemPtr(new T(basenode));
+ }
+
+ std::string executeOrder;
+};
+
+
+/*
+ * Conditions
+ */
+
class XplCondition: public BaseDeterminatorItem
{
public:
@@ -134,16 +152,128 @@
std::string value;
};
-class LogAction: public BaseDeterminatorItem
+/*
+ * Actions
+ */
+
+class logAction: public DeterminatorAction<logAction>
{
public:
- LogAction();
- LogAction(const pugi::xml_node& basenode);
+ logAction() {}
+ logAction(const pugi::xml_node& basenode) : DeterminatorAction(basenode) {
+ parseFromXml(basenode);
+ }
- virtual BaseDeterminatorItemPtr createNew(const pugi::xml_node& basenode) const;
+ void execute() const;
void parseFromXml(const pugi::xml_node& basenode);
std::string toString() const;
std::string logText;
std::string executeOrder;
};
+
+class xplAction: public DeterminatorAction<xplAction>
+{
+ public:
+ xplAction() {}
+ xplAction(const pugi::xml_node& basenode) : DeterminatorAction(basenode) {
+ parseFromXml(basenode);
+ }
+
+ void execute() const;
+ void parseFromXml(const pugi::xml_node& basenode);
+ std::string toString() const;
+
+ std::string msgType;
+ std::string msgTarget;
+ std::string msgSchema;
+ std::multimap<std::string, std::string> actionParams;
+};
+
+class globalAction: public DeterminatorAction<globalAction>
+{
+ public:
+ globalAction();
+ globalAction(const pugi::xml_node& basenode);
+ void execute() const;
+
+ virtual BaseDeterminatorItemPtr createNew(const pugi::xml_node& basenode) const;
+ void parseFromXml(const pugi::xml_node& basenode);
+ std::string toString() const;
+
+ std::string name;
+ std::string value;
+};
+
+class delayAction: public DeterminatorAction<delayAction>
+{
+ public:
+ delayAction();
+ delayAction(const pugi::xml_node& basenode);
+ void execute() const;
+
+ virtual BaseDeterminatorItemPtr createNew(const pugi::xml_node& basenode) const;
+ void parseFromXml(const pugi::xml_node& basenode);
+ std::string toString() const;
+
+ std::string delaySeconds;
+};
+
+class stopAction: public DeterminatorAction<stopAction>
+{
+ public:
+ stopAction();
+ stopAction(const pugi::xml_node& basenode);
+ void execute() const;
+
+ virtual BaseDeterminatorItemPtr createNew(const pugi::xml_node& basenode) const;
+ void parseFromXml(const pugi::xml_node& basenode);
+ std::string toString() const;
+
+};
+
+class suspendAction: public DeterminatorAction<suspendAction>
+{
+ public:
+ suspendAction();
+ suspendAction(const pugi::xml_node& basenode);
+ void execute() const;
+
+ virtual BaseDeterminatorItemPtr createNew(const pugi::xml_node& basenode) const;
+ void parseFromXml(const pugi::xml_node& basenode);
+ std::string toString() const;
+
+ std::string suspendMinutes;
+ std::string suspendTime;
+ std::string suspendRandomise;
+};
+
+class execRuleAction: public DeterminatorAction<execRuleAction>
+{
+ public:
+ execRuleAction();
+ execRuleAction(const pugi::xml_node& basenode);
+ void execute() const;
+
+ virtual BaseDeterminatorItemPtr createNew(const pugi::xml_node& basenode) const;
+ void parseFromXml(const pugi::xml_node& basenode);
+ std::string toString() const;
+
+ std::string ruleName;
+};
+
+class runScriptAction: public DeterminatorAction<runScriptAction>
+{
+ public:
+ runScriptAction();
+ runScriptAction(const pugi::xml_node& basenode);
+ void execute() const;
+
+ virtual BaseDeterminatorItemPtr createNew(const pugi::xml_node& basenode) const;
+ void parseFromXml(const pugi::xml_node& basenode);
+ std::string toString() const;
+
+ std::string scriptName;
+ std::string parameter;
+};
+
Modified: xPLHAL/branches/thomas_s_dev/src/globals.h
===================================================================
--- xPLHAL/branches/thomas_s_dev/src/globals.h 2012-02-19 12:22:04 UTC (rev 709)
+++ xPLHAL/branches/thomas_s_dev/src/globals.h 2012-02-19 23:12:54 UTC (rev 710)
@@ -31,9 +31,6 @@
class xPLHandler;
extern xPLHandler *xPL;
-class xPLMessageQueueClass;
-extern xPLMessageQueueClass *xPLMessageQueue;
-
/** The working directories */
extern boost::filesystem::path xPLHalRootFolder;
extern boost::filesystem::path DataFileFolder;
Modified: xPLHAL/branches/thomas_s_dev/src/main.cpp
===================================================================
--- xPLHAL/branches/thomas_s_dev/src/main.cpp 2012-02-19 12:22:04 UTC (rev 709)
+++ xPLHAL/branches/thomas_s_dev/src/main.cpp 2012-02-19 23:12:54 UTC (rev 710)
@@ -16,17 +16,26 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <signal.h>
+#include <boost/program_options.hpp>
#include "log.h"
-#include "xplcache.h"
#include "devicemanager.h"
#include "xhcp.h"
#include "recurring_timer.h"
+#include "xplhandler.h"
+#include "xplcache.h"
// load globas and give them their space to live
#include "globals.h"
using boost::filesystem::path;
using boost::filesystem::initial_path;
+using boost::program_options::options_description;
+using boost::program_options::variables_map;
+using boost::program_options::store;
+using boost::program_options::parse_command_line;
+using boost::program_options::notify;
+using std::cout;
+using std::endl;
path xPLHalRootFolder;
path DataFileFolder;
@@ -35,7 +44,6 @@
xPLCacheClass *xPLCache;
xPLHandler *xPL;
-xPLMessageQueueClass *xPLMessageQueue;
static boost::asio::io_service* g_ioservice = nullptr;
@@ -43,22 +51,20 @@
{
public:
XplHalApplication()
- :mXplMessageQueue(new xPLMessageQueueClass)
- ,mXplCache(new xPLCacheClass)
+ :mXplCache(new xPLCacheClass)
,mDeviceManager(mXplCache)
,mXHCPServer(new XHCPServer(m_ioservice, &mDeviceManager))
- ,mXpl(new xPLHandler( boost::asio::ip::host_name() ))
+ ,mXpl(new xPLHandler(m_ioservice, boost::asio::ip::host_name() ))
,mTimerListAllObjects(m_ioservice, boost::posix_time::seconds(60), true)
,mTimerFlushExpiredEntries(m_ioservice, boost::posix_time::minutes(5), true)
{
- mDeviceManager.m_sigSendXplMessage.connect(boost::bind(&xPLMessageQueueClass::add, mXplMessageQueue, _1));
+ mDeviceManager.m_sigSendXplMessage.connect(boost::bind(&xPLHandler::sendMessage, mXpl, _1));
mXpl->m_sigRceivedXplMessage.connect(boost::bind(&DeviceManager::processXplMessage, &mDeviceManager, _1));
installTimer();
/* set global variables */
xPLCache = mXplCache;
xPL = mXpl;
- xPLMessageQueue = mXplMessageQueue;
writeLog( "initialized", logLevel::all );
}
@@ -97,7 +103,7 @@
int exec()
{
// force everyone to send their configuration so that we start up to date...
- xPLMessageQueue->add(xPLMessagePtr( new xPLMessage(xPL_MESSAGE_COMMAND, "*", "config", "current", {{"command", "request"}}) ));
+ mXpl->sendMessage(xPLMessagePtr( new xPLMessage(xPL_MESSAGE_COMMAND, "*", "config", "current", {{"command", "request"}}) ));
writeLog( "started, run mainloop", logLevel::all );
m_ioservice.run();
@@ -113,7 +119,6 @@
private:
static boost::asio::io_service m_ioservice;
- xPLMessageQueueClass *mXplMessageQueue;
xPLCacheClass *mXplCache;
DeviceManager mDeviceManager;
XHCPServer *mXHCPServer;
@@ -146,6 +151,20 @@
//vendorFileFolder = DataFileFolder / "vendors";
//ConfigFileFolder = DataFileFolder / "configs";
+ options_description desc("Allowed options");
+ desc.add_options()
+ ("help", "help message")
+ ("datadir","location of data directory");
+
+ variables_map vm;
+ store(parse_command_line(argc, argv, desc), vm);
+ notify(vm);
+
+ if (vm.count("help")) {
+ cout << desc << endl;
+ return 1;
+ }
+
signal(SIGINT, handle_signal);
signal(SIGTERM, handle_signal);
Modified: xPLHAL/branches/thomas_s_dev/src/xplhandler.cpp
===================================================================
--- xPLHAL/branches/thomas_s_dev/src/xplhandler.cpp 2012-02-19 12:22:04 UTC (rev 709)
+++ xPLHAL/branches/thomas_s_dev/src/xplhandler.cpp 2012-02-19 23:12:54 UTC (rev 710)
@@ -16,14 +16,15 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#include "xplhandler.h"
+#include "xplmessagequeue.h"
+
#include <boost/algorithm/string/replace.hpp>
using std::string;
#include "log.h"
-#include "xplhandler.h"
-#include "globals.h"
/** Handle a change to the logger service configuration */
/* static void configChangedHandler(xPL_ServicePtr theService, xPL_ObjectPtr userData) {
@@ -31,12 +32,14 @@
int xPLHandler::m_refcount = 0;
-xPLHandler::xPLHandler( const string& host_name)
+xPLHandler::xPLHandler(boost::asio::io_service& ioservice, const std::string& host_name)
: xPLService(0)
-, m_exit_thread(false)
, vendor( "CHRISM" )
, deviceID( "xplhalqt" )
, instanceID( host_name )
+, m_xplSocket(ioservice)
+, m_xplWriteSocket(ioservice)
+, mXplMessageQueue(new XplMessageQueue)
{
writeLog( "xPLHandler::xPLHandler( "+host_name+" )", logLevel::debug );
//xPL_setDebugging(TRUE);
@@ -54,7 +57,7 @@
writeLog("Unable to start xPL", logLevel::debug);
}
}
-
+
/* And a listener for all xPL messages */
xPL_addMessageListener( xpl_message_callback, this );
@@ -82,16 +85,17 @@
xPL_addServiceConfigChangedListener(loggerService, configChangedHandler, NULL);*/
//xPL_setServiceEnabled(loggerService, TRUE);
xPL_setServiceEnabled(xPLService, TRUE);
-
- m_thread = new boost::thread(boost::bind(&xPLHandler::run, this));
+
+ m_xplSocket.assign(boost::asio::ip::tcp::v4(), xPL_getFD());
+ m_xplWriteSocket.assign(boost::asio::ip::tcp::v4(), mXplMessageQueue->getFD());
+ startAsyncRead();
+ startAsyncWrite();
}
xPLHandler::~xPLHandler()
{
writeLog( "xPLHandler::~xPLHandler()", logLevel::debug );
- m_exit_thread = true;
- m_thread->join();
- delete m_thread;
+ m_xplSocket.close();
if (xPLService) {
xPL_releaseService(xPLService);
}
@@ -100,56 +104,30 @@
}
}
-void xPLHandler::run()
+void xPLHandler::sendBroadcastMessage( const string& msgClass, const string& msgType, const xPLMessage::namedValueList& namedValues )
{
- writeLog( "xPLHandler::run()", logLevel::debug );
- // writeLog( "xPLHandler::run() - ready", logLevel::debug );
-
- // Hand control over to xPLLib
- while( ! m_exit_thread )
- {
- // get exclusive access to xPLib
- //lock_guard locker( xPLLock );
-
- // send waiting messages
- while( xPL_MessagePtr theMessage = xPLMessageQueue->consume( xPLService ) )
- {
- writeLog("Found xPL message at " + lexical_cast<string>(theMessage)+ " to send...", logLevel::debug);
- if ( !xPL_sendMessage( theMessage ) )
- writeLog("Unable to send xPL message", logLevel::debug);
- else
- writeLog( "xPL Message sent...", logLevel::debug );
- }
-
- // handle messages - and return after 100 ms
- xPL_processMessages(100);
- }
-}
-
-void xPLHandler::sendBroadcastMessage( const string& msgClass, const string& msgType, const xPLMessage::namedValueList& namedValues ) const
-{
writeLog( "xPLHandler::sendBroadcastMessage( "+msgClass+", "+msgType+" )", logLevel::debug );
- xPLMessageQueue->add( xPLMessagePtr( new xPLMessage( xPL_MESSAGE_COMMAND, "*", "", "", msgClass, msgType, namedValues ) ) );
+ sendMessage( xPLMessagePtr( new xPLMessage( xPL_MESSAGE_COMMAND, "*", "", "", msgClass, msgType, namedValues ) ) );
}
void xPLHandler::sendMessage( const xPL_MessageType type, const string& tgtVendor, const string& tgtDeviceID,
const string& tgtInstanceID, const string& msgClass, const string& msgType,
- const xPLMessage::namedValueList& namedValues ) const
+ const xPLMessage::namedValueList& namedValues )
{
writeLog( "xPLHandler::sendMessage( "+lexical_cast<string>(type)+", "+tgtVendor+", "+tgtDeviceID+", "+tgtInstanceID+", "+msgClass+", "+msgType+" )", logLevel::debug );
- xPLMessageQueue->add( xPLMessagePtr( new xPLMessage( type, tgtVendor, tgtDeviceID, tgtInstanceID, msgClass, msgType, namedValues ) ) );
+ sendMessage( xPLMessagePtr( new xPLMessage( type, tgtVendor, tgtDeviceID, tgtInstanceID, msgClass, msgType, namedValues ) ) );
}
void xPLHandler::sendMessage( const xPL_MessageType type, const string& VDI,
const string& msgClass, const string& msgType,
- const xPLMessage::namedValueList& namedValues ) const
+ const xPLMessage::namedValueList& namedValues )
{
size_t marker1 = VDI.find( "-" );
size_t marker2 = VDI.find( "." );
string vendor = VDI.substr( 0, marker1 );
string device = VDI.substr( marker1+1, marker2 - (marker1+1) );
string instance = VDI.substr( marker2+1 );
- xPLMessageQueue->add( xPLMessagePtr( new xPLMessage( type, vendor, device, instance, msgClass, msgType, namedValues ) ) );
+ sendMessage( xPLMessagePtr( new xPLMessage( type, vendor, device, instance, msgClass, msgType, namedValues ) ) );
}
void xPLHandler::xpl_message_callback( xPL_MessagePtr theMessage, void *userValue )
@@ -196,3 +174,43 @@
m_sigRceivedXplMessage(msg);
}
+
+void xPLHandler::startAsyncRead()
+{
+ m_xplSocket.async_read_some(boost::asio::null_buffers(), boost::bind(&xPLHandler::handleReadableXplSocket, this, _1));
+}
+
+void xPLHandler::startAsyncWrite()
+{
+ m_xplWriteSocket.async_read_some(boost::asio::null_buffers(), boost::bind(&xPLHandler::handleReadableXplMessagequeue, this, _1));
+}
+
+void xPLHandler::handleReadableXplMessagequeue(boost::system::error_code ec)
+{
+ if (!ec) {
+ // send waiting messages
+ while( xPL_MessagePtr theMessage = mXplMessageQueue->consume( xPLService ) )
+ {
+ writeLog("Found xPL message at " + lexical_cast<string>(theMessage)+ " to send...", logLevel::debug);
+ if ( !xPL_sendMessage( theMessage ) )
+ writeLog("Unable to send xPL message", logLevel::debug);
+ else
+ writeLog( "xPL Message sent...", logLevel::debug );
+ }
+ startAsyncWrite();
+ }
+}
+
+void xPLHandler::handleReadableXplSocket(boost::system::error_code ec)
+{
+ if (!ec) {
+ // handle messages - and return
+ xPL_processMessages(0);
+ startAsyncRead();
+ }
+}
+
+void xPLHandler::sendMessage( const xPLMessagePtr& message )
+{
+ mXplMessageQueue->add(message);
+}
Modified: xPLHAL/branches/thomas_s_dev/src/xplhandler.h
===================================================================
--- xPLHAL/branches/thomas_s_dev/src/xplhandler.h 2012-02-19 12:22:04 UTC (rev 709)
+++ xPLHAL/branches/thomas_s_dev/src/xplhandler.h 2012-02-19 23:12:54 UTC (rev 710)
@@ -20,57 +20,61 @@
#include <vector>
#include <string>
-#include <boost/thread.hpp>
-#include <boost/thread/locks.hpp>
#include <boost/signals2/signal.hpp>
+#include <boost/asio.hpp>
+#include "xplmessage.h"
-// this is also including the xPL.h
-#include "xplmessagequeue.h"
+class XplMessageQueue;
/**
* \brief Handle all xPL communication.
*/
class xPLHandler
{
- /** \brief variable to ensure that the xPL library is only called at the same time... */
- //mutable boost::mutex xPLLock;
- //typedef boost::lock_guard<boost::mutex> lock_guard;
public:
typedef boost::signals2::signal<void (xPLMessagePtr)> signal_t;
public:
- xPLHandler( const std::string& host_name);
+ xPLHandler(boost::asio::io_service& ioservice, const std::string& host_name);
~xPLHandler();
void run();
+
+ void sendMessage( const xPLMessagePtr& message );
/** \brief Broadcast one message to the xPL network. */
- void sendBroadcastMessage( const std::string& msgClass, const std::string& msgType, const xPLMessage::namedValueList& namedValues ) const;
+ void sendBroadcastMessage( const std::string& msgClass, const std::string& msgType, const xPLMessage::namedValueList& namedValues );
/** \brief Send a directed message to the xPL network. */
void sendMessage( const xPL_MessageType type, const std::string& tgtVendor, const std::string& tgtDeviceID,
const std::string& tgtInstanceID, const std::string& msgClass, const std::string& msgType,
- const xPLMessage::namedValueList& namedValues ) const;
+ const xPLMessage::namedValueList& namedValues );
/** \brief Send a directed message to the xPL network. */
void sendMessage( const xPL_MessageType type, const std::string& VDI,
- const std::string& msgClass, const std::string& msgType, const xPLMessage::namedValueList& namedValues ) const;
+ const std::string& msgClass, const std::string& msgType, const xPLMessage::namedValueList& namedValues );
public:
signal_t m_sigRceivedXplMessage;
private:
+ void startAsyncRead();
+ void handleReadableXplSocket(boost::system::error_code ec);
+ void startAsyncWrite();
+ void handleReadableXplMessagequeue(boost::system::error_code ec);
+
/** \brief Handle an incomming xPL message. */
void handleXPLMessage( xPL_MessagePtr theMessage);
/** \brief Handle an incomming xPL message. */
static void xpl_message_callback( xPL_MessagePtr theMessage, xPL_ObjectPtr userValue );
- xPL_ServicePtr xPLService;
- std::string vendor;
- std::string deviceID;
- std::string instanceID;
- boost::thread* m_thread;
- static int m_refcount;
- bool m_exit_thread;
+ xPL_ServicePtr xPLService;
+ std::string vendor;
+ std::string deviceID;
+ std::string instanceID;
+ static int m_refcount;
+ boost::asio::ip::tcp::socket m_xplSocket;
+ boost::asio::ip::tcp::socket m_xplWriteSocket;
+ std::shared_ptr<XplMessageQueue> mXplMessageQueue;
};
Modified: xPLHAL/branches/thomas_s_dev/src/xplmessagequeue.cpp
===================================================================
--- xPLHAL/branches/thomas_s_dev/src/xplmessagequeue.cpp 2012-02-19 12:22:04 UTC (rev 709)
+++ xPLHAL/branches/thomas_s_dev/src/xplmessagequeue.cpp 2012-02-19 23:12:54 UTC (rev 710)
@@ -16,20 +16,40 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#include "xplmessagequeue.h"
#include "log.h"
-#include "xplmessagequeue.h"
+#include <unistd.h>
+
using std::mutex;
using std::lock_guard;
+
+XplMessageQueue::XplMessageQueue()
+:mPipeFD({0})
+{
+ pipe(mPipeFD);
+}
-void xPLMessageQueueClass::add( const xPLMessagePtr& message )
+XplMessageQueue::~XplMessageQueue()
{
- writeLog("xPLMessageQueueClass::add", logLevel::debug);
+ close(mPipeFD[0]);
+ close(mPipeFD[1]);
+}
+
+int XplMessageQueue::getFD() const
+{
+ return mPipeFD[0];
+}
+
+void XplMessageQueue::add( const xPLMessagePtr& message )
+{
+ writeLog("XplMessageQueue::add", logLevel::debug);
lock_guard<mutex> locker( queueLock ); // get exclusive access to the queue
xPLMessages.push( message );
+ write(mPipeFD[1], "1", 1);
}
-xPL_MessagePtr xPLMessageQueueClass::consume( const xPL_ServicePtr& service )
+xPL_MessagePtr XplMessageQueue::consume( const xPL_ServicePtr& service )
{
xPLMessagePtr message;
{
@@ -38,8 +58,10 @@
return 0;
message = xPLMessages.front(); // and release is as soon as possible
xPLMessages.pop();
+ char dummy[1];
+ read(mPipeFD[0], dummy, 1);
}
- writeLog("xPLMessageQueueClass::consume", logLevel::debug);
+ writeLog("XplMessageQueue::consume", logLevel::debug);
xPL_MessagePtr theMessage = 0;
if( "*" == message->vendor )
Modified: xPLHAL/branches/thomas_s_dev/src/xplmessagequeue.h
===================================================================
--- xPLHAL/branches/thomas_s_dev/src/xplmessagequeue.h 2012-02-19 12:22:04 UTC (rev 709)
+++ xPLHAL/branches/thomas_s_dev/src/xplmessagequeue.h 2012-02-19 23:12:54 UTC (rev 710)
@@ -27,20 +27,27 @@
/**
* Thread save store for xPL messages to send
*/
-class xPLMessageQueueClass
+class XplMessageQueue
{
- /** \brief variable to ensure that the queue is thread save... */
- mutable std::mutex queueLock;
- std::queue<xPLMessagePtr> xPLMessages;
+ public:
+ XplMessageQueue();
+ ~XplMessageQueue();
- public:
- /** \brief Add an message to the queue that'll be send on the next
- occasion and return a reference to fill it. */
- void add( const xPLMessagePtr& message );
+ int getFD() const;
- /** \brief Convert the next message to an xPL message and delete
- it from the queue. The caller has to ensure that the
- xPLLib is currently not called elsewhere, i.e. locked!
- \returns Returns 0 if no message available or the message. */
- xPL_MessagePtr consume( const xPL_ServicePtr& service );
+ /** \brief Add an message to the queue that'll be send on the next
+ occasion and return a reference to fill it. */
+ void add( const xPLMessagePtr& message );
+
+ /** \brief Convert the next message to an xPL message and delete
+ it from the queue. The caller has to ensure that the
+ xPLLib is currently not called elsewhere, i.e. locked!
+ \returns Returns 0 if no message available or the message. */
+ xPL_MessagePtr consume( const xPL_ServicePtr& service );
+ private:
+ /** \brief variable to ensure that the queue is thread save... */
+ mutable std::mutex queueLock;
+ std::queue<xPLMessagePtr> xPLMessages;
+ int mPipeFD[2];
};
+
Modified: xPLHAL/branches/thomas_s_dev/test/determinator1.xml
===================================================================
--- xPLHAL/branches/thomas_s_dev/test/determinator1.xml 2012-02-19 12:22:04 UTC (rev 709)
+++ xPLHAL/branches/thomas_s_dev/test/determinator1.xml 2012-02-19 23:12:54 UTC (rev 710)
@@ -13,6 +13,10 @@
<xplActionParam expression="level=30" />
<xplActionParam expression="fade-rate=30" />
</xplAction>
+ <logAction display_name="logAction"
+ logText="text to log"
+ executeOrder="nnn"
+ />
</output>
</determinator>
</xplDeterminator>
Added: xPLHAL/branches/thomas_s_dev/test/pugi.h
===================================================================
--- xPLHAL/branches/thomas_s_dev/test/pugi.h (rev 0)
+++ xPLHAL/branches/thomas_s_dev/test/pugi.h 2012-02-19 23:12:54 UTC (rev 710)
@@ -0,0 +1,183 @@
+#include <iostream>
+#include <pugixml.hpp>
+#include <string>
+#include <vector>
+//#include <boost/shared_ptr.hpp>
+#include <cxxabi.h>
+#include <typeinfo>
+#include <memory>
+#include <map>
+
+using std::string;
+using std::vector;
+
+
+class Determinator
+{
+ public:
+ enum class match_type { ALL, ANY };
+
+ string guid;
+ string name;
+ string description;
+ bool enabled;
+ match_type input_match_type;
+
+ vector<BaseConditionPtr> inputs;
+};
+
+
+void printDeterminator(const Determinator& d)
+{
+ std::cout << "Determinator '" << d.name << "'";
+ std::cout << "\n guid: " << d.guid;
+ std::cout << "\n name: " << d.name;
+ std::cout << "\n description: " << d.description;
+ std::cout << "\n enabled: " << d.enabled;
+
+ std::cout << "\n Inputs:\n";
+ for (auto input : d.inputs) {
+ std::cout << " " << input->toString() << std::endl;
+ }
+
+ std::cout << std::endl;
+}
+
+class DeterminatorXmlParser
+{
+ public:
+ DeterminatorXmlParser(const string& filename)
+ {
+ registerCondition(BaseConditionConstPtr(new XplCondition));
+ registerCondition(BaseConditionConstPtr(new GlobalCondition));
+ registerCondition(BaseConditionConstPtr(new GlobalChanged));
+ registerCondition(BaseConditionConstPtr(new DayCondition));
+ registerCondition(BaseConditionConstPtr(new TimeCondition));
+
+ pugi::xml_parse_result result = m_doc.load_file(filename.c_str());
+ std::cout << "Load result: " << result.description() << "\n";
+ }
+
+ void registerCondition(BaseConditionConstPtr condition) {
+ m_conditionmap[condition->condition_name] = condition;
+ }
+
+ void parse() {
+ try {
+ pugi::xml_node base = getNode(m_doc, "xplDeterminator");
+ pugi::xml_node base_d = getNode(base, "determinator");
+
+ bool isGroup = base_d.attribute("isGroup").value() == "Y";
+
+ if (isGroup == false) {
+ Determinator d;
+ d.guid = base_d.attribute("guid").value();
+ d.name = base_d.attribute("name").value();
+ d.description = base_d.attribute("description").value();
+ d.enabled = base_d.attribute("guid").value() == "Y";
+
+ pugi::xml_node input = base_d.child("input");
+
+ for(auto condition : m_conditionmap) {
+ pugi::xml_node action_node = input.child(condition.first.c_str());
+ if (action_node) {
+ d.inputs.push_back( BaseConditionPtr(condition.second->createNew(action_node)) );
+ }
+ }
+
+ printDeterminator(d);
+ }
+
+ }
+ catch(const std::exception& e) {
+ int status;
+ char* realname = abi::__cxa_demangle(typeid(e).name(), 0, 0, &status);
+ std::cout << "Exception: " << realname << " => " << e.what() << std::endl;
+ throw;
+ }
+
+ }
+
+
+ private:
+ pugi::xml_node getNode(const pugi::xml_node& base, const string& childname) {
+ pugi::xml_node node = base.child(childname.c_str());
+ if (!node) {
+ throw DeterminatorParseException("node '" + childname +"' not found");
+ }
+ return node;
+ }
+
+ pugi::xml_document m_doc;
+ std::map<string, std::shared_ptr<const BaseCondition>> m_conditionmap;
+};
+
+int main()
+{
+ DeterminatorXmlParser parser("determinatorDesc.xml");
+ parser.parse();
+
+ /*
+ try {
+ pugi::xml_document doc;
+ pugi::xml_parse_result result = doc.load_file("determinatorDesc.xml");
+
+ std::cout << "Load result: " << result.description() << "\n";
+
+ pugi::xml_node base = doc.child("xplDeterminator");
+ pugi::xml_node base_d = base.child("determinator");
+
+ bool isGroup = base_d.attribute("isGroup").value() == "Y";
+
+ if (isGroup == false) {
+ vector<string> actions = {"xplCondition", "globalCondition", "globalChanged", "dayCondition", "timeCondition"};
+
+ Determinator d;
+ d.guid = base_d.attribute("guid").value();
+ d.name = base_d.attribute("name").value();
+ d.description = base_d.attribute("description").value();
+ d.enabled = base_d.attribute("guid").value() == "Y";
+
+ pugi::xml_node input = base_d.child("input");
+
+ for(auto action : actions) {
+ pugi::xml_node action_node = input.child(action.c_str());
+ if (action_node) {
+ if (action == "globalCondition") {
+ d.inputs.push_back(DCPtr(new DeterminatorConditionGlobal(action_node)));
+ }
+ else if (action == "xplCondition") {
+ XplCondition xplcond(action_node);
+
+ }
+ }
+ }
+
+ printDeterminator(d);
+ }
+
+ }
+ catch(const std::exception& e) {
+ int status;
+ char* realname = abi::__cxa_demangle(typeid(e).name(), 0, 0, &status);
+ std::cout << "Exception: " << realname << " => " << e.what() << std::endl;
+ }
+ */
+
+
+}
+
+/*
+
+ <output>
+ <logAction display_name="display-name"
+ <xplAction display_name="action-name"
+ <globalAction
+ <delayAction
+ <stopAction
+ <suspendAction
+ <executeAction
+ <execRuleAction
+ <runScriptAction
+ </output>
+*/
Modified: xPLHAL/branches/thomas_s_dev/test/test_determinator.cpp
===================================================================
--- xPLHAL/branches/thomas_s_dev/test/test_determinator.cpp 2012-02-19 12:22:04 UTC (rev 709)
+++ xPLHAL/branches/thomas_s_dev/test/test_determinator.cpp 2012-02-19 23:12:54 UTC (rev 710)
@@ -121,4 +121,13 @@
}
}
+
+BOOST_AUTO_TEST_CASE( execute1 )
+{
+ DeterminatorXmlParser parser("determinator1.xml");
+ Determinator d(parser.parse());
+
+ d.execute();
+}
+
BOOST_AUTO_TEST_SUITE_END();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ma...@us...> - 2012-02-19 12:22:11
|
Revision: 709
http://openautomation.svn.sourceforge.net/openautomation/?rev=709&view=rev
Author: mayerch
Date: 2012-02-19 12:22:04 +0000 (Sun, 19 Feb 2012)
Log Message:
-----------
Added fix as described in http://code.google.com/p/poly2tri/issues/detail?id=44 that caused some walls to be "lost"
Modified Paths:
--------------
JSFloorPlan/trunk/lib/poly2tri.js
Modified: JSFloorPlan/trunk/lib/poly2tri.js
===================================================================
--- JSFloorPlan/trunk/lib/poly2tri.js 2012-02-18 15:33:02 UTC (rev 708)
+++ JSFloorPlan/trunk/lib/poly2tri.js 2012-02-19 12:22:04 UTC (rev 709)
@@ -798,9 +798,9 @@
if (px == nx) {
// We might have two nodes with same x value for a short time
- if (point.equals(node.prev.point)) {
+ if (node.prev && point.equals(node.prev.point)) {
node = node.prev;
- } else if (point.equals(node.next.point)) {
+ } else if (node.next && point.equals(node.next.point)) {
node = node.next;
} else if (point.equals(node.point)) {
// do nothing
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <j-...@us...> - 2012-02-18 15:33:10
|
Revision: 708
http://openautomation.svn.sourceforge.net/openautomation/?rev=708&view=rev
Author: j-n-k
Date: 2012-02-18 15:33:02 +0000 (Sat, 18 Feb 2012)
Log Message:
-----------
Fix spaces/tab in templateengine.js
Groups: Added "nowidget"-attribute. If nowidget="true" widget-stylings
are not applied to the group (necessary for grouping without border,
padding, margin, backgroudn etc.)
Modified Paths:
--------------
CometVisu/trunk/visu/designs/structure_pure.js
CometVisu/trunk/visu/lib/templateengine.js
Modified: CometVisu/trunk/visu/designs/structure_pure.js
===================================================================
--- CometVisu/trunk/visu/designs/structure_pure.js 2012-02-16 20:13:02 UTC (rev 707)
+++ CometVisu/trunk/visu/designs/structure_pure.js 2012-02-18 15:33:02 UTC (rev 708)
@@ -233,6 +233,9 @@
if( $p.attr('align') ) hstyle += 'text-align:' + $p.attr('align') + ';';
if( hstyle != '' ) hstyle = 'style="' + hstyle + '"';
ret_val.setWidgetLayout($p);
+ if ($p.attr('nowidget')=='true') {
+ ret_val.removeClass('widget');
+ }
var childs = $p.children();
var container = $( '<div class="clearfix"/>' );
if( $p.attr('name') ) container.append( '<h2 ' + hstyle + '>' + $p.attr('name') + '</h2>' );
@@ -244,11 +247,12 @@
return ret_val;
},
attributes: {
- align: { type: 'string', required: false },
- flavour:{ type: 'string', required: false },
- colspan: { type: 'numeric', required: false },
- rowspan: { type: 'numeric', required: false },
- name: { type: 'string', required: true }
+ align: { type: 'string', required: false },
+ flavour: { type: 'string', required: false },
+ colspan: { type: 'numeric', required: false },
+ rowspan: { type: 'numeric', required: false },
+ nowidget: {type: 'string', required: false },
+ name: { type: 'string', required: true }
},
elements: {
},
Modified: CometVisu/trunk/visu/lib/templateengine.js
===================================================================
--- CometVisu/trunk/visu/lib/templateengine.js 2012-02-16 20:13:02 UTC (rev 707)
+++ CometVisu/trunk/visu/lib/templateengine.js 2012-02-18 15:33:02 UTC (rev 708)
@@ -25,11 +25,9 @@
var main_scroll;
var old_scroll = '';
-visu = new CometVisu('/cgi-bin/');//{};
-visu.update = function( json ) // overload the handler
-{
- for( key in json )
- {
+visu = new CometVisu('/cgi-bin/');
+visu.update = function( json ) { // overload the handler
+ for( key in json ) {
$.event.trigger( '_' + key, json[key] );
}
}
@@ -45,6 +43,7 @@
if (typeof forceReload == "undefined") {
var forceReload = false;
}
+
if( $.getUrlVar('forceReload') ) {
forceReload = $.getUrlVar('forceReload') != 'false'; // true unless set to false
}
@@ -89,25 +88,21 @@
(basetrans in Transform ? Transform[ basetrans ].encode( value ) : value);
}
-function transformDecode( transformation, value )
-{
+function transformDecode( transformation, value ) {
var basetrans = transformation.split('.')[0];
return transformation in Transform ?
Transform[ transformation ].decode( value ) :
(basetrans in Transform ? Transform[ basetrans ].decode( value ) : value);
}
-function map( value, element )
-{
+function map( value, element ) {
var map = element.data('mapping');
- if( map && mappings[map] && (mappings[map][value] || mappings[map]['range']) )
- {
+ if( map && mappings[map] && (mappings[map][value] || mappings[map]['range']) ) {
if( mappings[map]['range'] ) value = parseFloat( value );
if( mappings[map][value] ) return mappings[map][value];
var range = mappings[map]['range'];
- for( var min in range )
- {
+ for( var min in range ) {
if( min > value ) continue;
if( range[min][0] < value ) continue; // check max
return range[min][1];
@@ -120,20 +115,19 @@
* Make sure everything looks right when the window gets resized.
* This is necessary as the scroll effect requires a fixed element size
*/
-function handleResize()
-{
+function handleResize() {
var uagent = navigator.userAgent.toLowerCase();
if (/(android|blackberry|iphone|ipod|series60|symbian|windows ce|palm)/i.test(uagent)) {
- var width = $( window ).width();
- $( '#main' ).css( 'width', width );
- $( 'head' ).append( '<style type="text/css">.page{width:' + (width-0) + 'px;}</style>' );
- // do nothing
+ var width = $( window ).width();
+ $( '#main' ).css( 'width', width );
+ $( 'head' ).append( '<style type="text/css">.page{width:' + (width-0) + 'px;}</style>' );
+ // do nothing
} else {
- var width = $( window ).width();
- var height = $( window ).height() - $( '#top' ).outerHeight(true) - $( '#bottom' ).outerHeight(true) - 2;
- $( '#main' ).css( 'width', width ).css( 'height', height );
- $( 'head' ).append( '<style type="text/css">.page{width:' + (width-0) + 'px;height:' + height + 'px;}</style>' );
+ var width = $( window ).width();
+ var height = $( window ).height() - $( '#top' ).outerHeight(true) - $( '#bottom' ).outerHeight(true) - 2;
+ $( '#main' ).css( 'width', width ).css( 'height', height );
+ $( 'head' ).append( '<style type="text/css">.page{width:' + (width-0) + 'px;height:' + height + 'px;}</style>' );
}
main_scroll != undefined && main_scroll.seekTo( main_scroll.getIndex(), 0 ); // fix scroll
}
@@ -197,15 +191,15 @@
// design by url
if ($.getUrlVar("design")) {
- clientDesign = $.getUrlVar("design");
+ clientDesign = $.getUrlVar("design");
}
// design by config file
else if (predefinedDesign){
- clientDesign = predefinedDesign;
+ clientDesign = predefinedDesign;
}
// selection dialog
else {
- selectDesign();
+ selectDesign();
}
$( 'head' ).append( '<link rel="stylesheet" type="text/css" href="designs/designglobals.css" />' );
@@ -227,19 +221,19 @@
html_doc.appendChild(js);
js.onreadystatechange = function () {
- if (js.readyState == 'complete') {
- pluginsToLoad -= 1;
- if (pluginsToLoad <= 0) {
- setup_page(xml);
- }
+ if (js.readyState == 'complete') {
+ pluginsToLoad -= 1;
+ if (pluginsToLoad <= 0) {
+ setup_page(xml);
}
+ }
}
js.onload = function () {
- pluginsToLoad -= 1;
- if (pluginsToLoad <= 0) {
- setup_page(xml);
- }
+ pluginsToLoad -= 1;
+ if (pluginsToLoad <= 0) {
+ setup_page(xml);
+ }
}
} );
@@ -308,11 +302,10 @@
// adapt width for pages to show
handleResize();
- if (pluginsToLoad <= 0) {
- setup_page(xml);
- }
+ if (pluginsToLoad <= 0) {
+ setup_page(xml);
+ }
-
}
function setup_page( xml )
@@ -339,15 +332,13 @@
// reaction on browser back button
window.onpopstate = function(e) {
-
- // where do we come frome?
- lastpage = $('body').data("lastpage")
- if (lastpage) {
- // browser back button takes us one level higher
- scrollToPage(lastpage);
- }
+ // where do we come frome?
+ lastpage = $('body').data("lastpage")
+ if (lastpage) {
+ // browser back button takes us one level higher
+ scrollToPage(lastpage);
+ }
}
-
visu.subscribe( ga_list );
$("#pages").triggerHandler("done");
@@ -355,90 +346,87 @@
function create_pages( page, path, flavour ) {
- var creator = design.getCreator(page.nodeName);
- var retval = creator.create(page, path, flavour);
+ var creator = design.getCreator(page.nodeName);
+ var retval = creator.create(page, path, flavour);
- node = $(page).get(0);
- var attributes = {};
- if (typeof node.attributes != "undefined") {
- for(var i=0; i<node.attributes.length; i++) {
- if(node.attributes.item(i).specified) {
- attributes[node.attributes.item(i).nodeName]=node.attributes.item(i).nodeValue
- }
- }
- } else {
- $.extend(attributes, node);
+ node = $(page).get(0);
+ var attributes = {};
+ if (typeof node.attributes != "undefined") {
+ for(var i=0; i<node.attributes.length; i++) {
+ if(node.attributes.item(i).specified) {
+ attributes[node.attributes.item(i).nodeName]=node.attributes.item(i).nodeValue
+ }
}
+ } else {
+ $.extend(attributes, node);
+ }
- var configData = {attributes: {}, elements: {}}
- if (typeof creator.attributes != "undefined") {
- $.each(creator.attributes, function (index, e) {
- if ($(page).attr(index)) {
- configData.attributes[index] = $(page).attr(index);
- }
- });
- }
+ var configData = {attributes: {}, elements: {}}
+ if (typeof creator.attributes != "undefined") {
+ $.each(creator.attributes, function (index, e) {
+ if ($(page).attr(index)) {
+ configData.attributes[index] = $(page).attr(index);
+ }
+ });
+ }
- if (typeof creator.elements != "undefined") {
- $.each(creator.elements, function (index, e) {
- var elements = $(page).find(index);
- configData.elements[index] = elements;
- });
- }
+ if (typeof creator.elements != "undefined") {
+ $.each(creator.elements, function (index, e) {
+ var elements = $(page).find(index);
+ configData.elements[index] = elements;
+ });
+ }
- retval.data("configData", configData)
- .data("path", path)
- .data("nodeName", page.nodeName)
- .data("textContent", page.textContent);
+ retval.data("configData", configData)
+ .data("path", path)
+ .data("nodeName", page.nodeName)
+ .data("textContent", page.textContent);
- if (jQuery(retval).is(".widget")) {
- retval = jQuery("<div class='widget_container "+(retval.data("colspanClass") ? retval.data("colspanClass") : '')+" "+(retval.data("rowspanClass") ? retval.data("rowspanClass") : '')+"' />").append(retval);
- }
+ if (jQuery(retval).is(".widget") || (jQuery(retval).is(".group")) ) {
+ retval = jQuery("<div class='widget_container " +
+ (retval.data("colspanClass") ? retval.data("colspanClass") : '') + " " +
+ (retval.data("rowspanClass") ? retval.data("rowspanClass") : '')+"' />")
+ .append(retval);
+ }
- return retval;
+ return retval;
}
-function scrollToPage( page_id, speed )
-{
+function scrollToPage( page_id, speed ) {
$('#'+page_id).css( 'display', '' ); // show new page
// which is the parent of target page_id?
// => set this id as lastpage in url for window.onpopstate handling
var path = page_id.split( '_' );
- if (path.length > 1){
- // above top level
- // everything besides the last number is the parent id
- path.pop();
- // store lastpage in body.data
- $('body').data("lastpage", path.join("_"));
+ if (path.length > 1) {
+ // above top level
+ // everything besides the last number is the parent id
+ path.pop();
+ // store lastpage in body.data
+ $('body').data("lastpage", path.join("_"));
}
else {
- // top level
- $('body').data("lastpage", page_id);
+ // top level
+ $('body').data("lastpage", page_id);
}
// push new state to history
window.history.pushState(page_id, page_id, window.location.href);
-
-
+
main_scroll.seekTo( $('.page').index( $('#'+page_id)[0] ), speed ); // scroll to it
var pagedivs=$('div', '#'+page_id);
- for( var i = 0; i<pagedivs.length; i++) //check for inline diagrams & refresh
- {
- if( pagedivs[i].className == 'diagram_inline')
- {
+ for( var i = 0; i<pagedivs.length; i++) { //check for inline diagrams & refresh
+ if( pagedivs[i].className == 'diagram_inline') {
refreshDiagram(pagedivs[i]);
}
}
}
-function updateTopNavigation()
-{
+function updateTopNavigation() {
var path = $('.page').eq( this.getIndex() ).attr('id').split( '_' );
var id = ''; //path[0];
var nav = '';
- for( var i = 0; i < path.length; i++ )
- {
+ for( var i = 0; i < path.length; i++ ) {
id += path[i];
nav += (0==i ? '' : ' ► ')
+ '<a href="javascript:scrollToPage(\'' +id+ '\')">'
@@ -450,8 +438,7 @@
var old_array = old_scroll;
old_scroll = path;
path = path.join('_');
- for( var i = new_array.length; i < old_array.length; i++ )
- {
+ for( var i = new_array.length; i < old_array.length; i++ ) {
path += '_' + old_array[i]; // reuse of path...
$('#'+path).css('display','none');
}
@@ -463,8 +450,7 @@
* This function returnes a jQuery object that points to the whole popup,
* so it's content can be easily extended
*/
-function showPopup( type, attributes )
-{
+function showPopup( type, attributes ) {
//var retval = design.popups[ type ].create( attributes ); //page, path );
//return retval;
if( !design.popups[ type ] ) type = 'unknown';
@@ -476,8 +462,7 @@
* Remove the popup.
* The parameter is the jQuery object returned by the showPopup function
*/
-function removePopup( jQuery_object )
-{
+function removePopup( jQuery_object ) {
jQuery_object.remove();
}
@@ -485,15 +470,12 @@
/* FIXME - Question: should this belong to the VisuDesign object so that it */
/* is possible to overload?!? */
/****************************************************************************/
-function refreshAction( target, src )
-{
+function refreshAction( target, src ) {
target.src = src + '&' + new Date().getTime();
}
-function setupRefreshAction()
-{
+function setupRefreshAction() {
var refresh = $(this).data('refresh');
- if( refresh && refresh > 0 )
- {
+ if( refresh && refresh > 0 ) {
var target = $('img', $(this) )[0] || $('iframe', $(this) )[0];
var src = target.src;
if( src.indexOf('?') < 0 ) src += '?';
@@ -503,58 +485,57 @@
function selectDesign() {
+ $body = $("body");
- $body = $("body");
-
- $("body > *").hide();
- $body.css({backgroundColor: "black"});
+ $("body > *").hide();
+ $body.css({backgroundColor: "black"});
- $div = $("<div id=\"designSelector\" />");
- $div.css({background: "#808080", width: "400px", color: "white", margin: "auto", padding: "0.5em"});
- $div.html("Loading ...");
+ $div = $("<div id=\"designSelector\" />");
+ $div.css({background: "#808080", width: "400px", color: "white", margin: "auto", padding: "0.5em"});
+ $div.html("Loading ...");
- $body.append($div);
+ $body.append($div);
- $.getJSON("edit/get_designs.php", function(data) {
- $div.empty();
+ $.getJSON("edit/get_designs.php", function(data) {
+ $div.empty();
- $div.append("<h1>Please select design</h1>");
- $div.append("<p>The Location/URL will change after you have chosen your design. Please bookmark the new URL if you do not want to select the design every time.</p>");
+ $div.append("<h1>Please select design</h1>");
+ $div.append("<p>The Location/URL will change after you have chosen your design. Please bookmark the new URL if you do not want to select the design every time.</p>");
- $.each(data, function(i, element) {
- var $myDiv = $("<div />");
+ $.each(data, function(i, element) {
+ var $myDiv = $("<div />");
- $myDiv.css({cursor: "pointer", padding: "0.5em 1em", borderBottom: "1px solid black", margin: "auto", width: "262px", position: "relative"});
+ $myDiv.css({cursor: "pointer", padding: "0.5em 1em", borderBottom: "1px solid black", margin: "auto", width: "262px", position: "relative"});
- $myDiv.append("<div style=\"font-weight: bold; margin: 1em 0 .5em;\">Design: " + element + "</div>");
- $myDiv.append("<iframe src=\"designs/design_preview.html?design=" + element + "\" width=\"160\" height=\"90\" border=\"0\" scrolling=\"auto\" frameborder=\"0\" style=\"z-index: 1;\"></iframe>");
- $myDiv.append("<img width=\"60\" height=\"30\" src=\"media/arrow.png\" alt=\"select\" border=\"0\" style=\"margin: 60px 10px 10px 30px;\"/>");
+ $myDiv.append("<div style=\"font-weight: bold; margin: 1em 0 .5em;\">Design: " + element + "</div>");
+ $myDiv.append("<iframe src=\"designs/design_preview.html?design=" + element + "\" width=\"160\" height=\"90\" border=\"0\" scrolling=\"auto\" frameborder=\"0\" style=\"z-index: 1;\"></iframe>");
+ $myDiv.append("<img width=\"60\" height=\"30\" src=\"media/arrow.png\" alt=\"select\" border=\"0\" style=\"margin: 60px 10px 10px 30px;\"/>");
- $div.append($myDiv);
+ $div.append($myDiv);
- var $tDiv = $("<div />");
- $tDiv.css({background: "transparent", position: "absolute", height: "90px", width: "160px", zIndex: 2})
- var pos = $myDiv.find("iframe").position();
- $tDiv.css({left: pos.left + "px", top: pos.top + "px"});
- $myDiv.append($tDiv);
+ var $tDiv = $("<div />");
+ $tDiv.css({background: "transparent", position: "absolute", height: "90px", width: "160px", zIndex: 2})
+ var pos = $myDiv.find("iframe").position();
+ $tDiv.css({left: pos.left + "px", top: pos.top + "px"});
+ $myDiv.append($tDiv);
- $myDiv.hover(function() {
- // over
- $myDiv.css({background: "#bbbbbb"});
- },
- function() {
- // out
- $myDiv.css({background: "transparent"});
- });
+ $myDiv.hover(function() {
+ // over
+ $myDiv.css({background: "#bbbbbb"});
+ },
+ function() {
+ // out
+ $myDiv.css({background: "transparent"});
+ });
- $myDiv.click(function() {
- if (document.location.search == "") {
- document.location.href = document.location.href + "?design=" + element;
- } else {
- document.location.href = document.location.href + "&design=" + element;
- }
- })
+ $myDiv.click(function() {
+ if (document.location.search == "") {
+ document.location.href = document.location.href + "?design=" + element;
+ } else {
+ document.location.href = document.location.href + "&design=" + element;
+ }
+ })
- })
})
+ })
}
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <j-...@us...> - 2012-02-16 20:13:12
|
Revision: 707
http://openautomation.svn.sourceforge.net/openautomation/?rev=707&view=rev
Author: j-n-k
Date: 2012-02-16 20:13:02 +0000 (Thu, 16 Feb 2012)
Log Message:
-----------
Added support for multiple filters: separate filter-tags by commas
Added additional <span> around content in cv-plugin, tag-classes are added to this
(supports coloring of content-only)
Added separation line after each day, grays out older days (thanks netsrac)
Modified Paths:
--------------
CometVisu/trunk/visu/plugins/rsslog/rsslog.css
CometVisu/trunk/visu/plugins/rsslog/structure_plugin.js
tools/rsslog/rsslog.php
Modified: CometVisu/trunk/visu/plugins/rsslog/rsslog.css
===================================================================
--- CometVisu/trunk/visu/plugins/rsslog/rsslog.css 2012-02-15 18:11:56 UTC (rev 706)
+++ CometVisu/trunk/visu/plugins/rsslog/rsslog.css 2012-02-16 20:13:02 UTC (rev 707)
@@ -38,4 +38,14 @@
.rsslog_ack {
text-decoration: line-through;
+}
+
+.rsslog_separator {
+ border-top-style: dotted;
+ border-color: #DDDDDD;
+}
+
+.rsslog_prevday {
+ opacity: .5;
+ filter: alpha(opacity=50);
}
\ No newline at end of file
Modified: CometVisu/trunk/visu/plugins/rsslog/structure_plugin.js
===================================================================
--- CometVisu/trunk/visu/plugins/rsslog/structure_plugin.js 2012-02-15 18:11:56 UTC (rev 706)
+++ CometVisu/trunk/visu/plugins/rsslog/structure_plugin.js 2012-02-16 20:13:02 UTC (rev 707)
@@ -46,6 +46,7 @@
rss.data("id", id);
rss.data("src", $p.attr("src"));
+ rss.data("filter", $p.attr("filter"));
rss.data("refresh", $p.attr("refresh"));
rss.data("content", $p.attr("content")) || true;
rss.data("datetime", $p.attr("datetime")) || true;
@@ -77,6 +78,7 @@
},
attributes: {
src: {type: "string", required: true},
+ filter: {type: "string", required: false},
width: {type: "string", required: false},
height: {type: "string", required: false},
refresh: {type: "numeric", required: false},
@@ -92,6 +94,14 @@
var rss = $(rss);
var src = rss.data("src");
+ var filter = rss.data("filter");
+ if (filter) {
+ if (src.match(/\?/)) {
+ src += '&f=' + filter;
+ } else {
+ src += '?f=' + filter;
+ }
+ }
var refresh = rss.data("refresh");
var limit = rss.data("limit");
@@ -123,7 +133,7 @@
var defaults = {
src: '',
- html: '{text}',
+ html: '<span>{text}</span>',
wrapper: 'li',
dataType: 'xml',
datetime: true
@@ -183,6 +193,10 @@
var last = itemoffset+displayrows;
last = (last>itemnum) ? itemnum : last;
+ var separatordate = new Date().strftime('%d');
+ var separatoradd = false;
+ var separatorprevday = false;
+
for (var i=itemoffset; i<last; i++) {
var idx = i;
idx = (i>=itemnum) ? (idx = idx - itemnum) : idx;
@@ -196,19 +210,29 @@
itemHtml = (o.timeformat) ?
(itemHtml.replace(/{date}/, entryDate.strftime(o.timeformat) + ' ')) :
(itemHtml.replace(/{date}/, entryDate.toLocaleDateString() + ' ' + entryDate.toLocaleTimeString() + ' '));
+ var thisday = entryDate.strftime('%d');
+ separatoradd = ((separatordate > 0) && (separatordate != thisday));
+ separatordate = thisday;
} else {
itemHtml = itemHtml.replace(/{date}/, '');
}
var $row = $('<' + o.wrapper + ' class="rsslogRow ' + row + '">').append(itemHtml);
-
+ if (separatoradd) {
+ $row.addClass('rsslog_separator'); separatorprevday = true;
+ }
+ if (separatorprevday == true) {
+ $row.addClass(' rsslog_prevday');
+ }
+
var title = item.find('title').text();
var itemClasses = title.substring(title.search(/\[/)+1,title.search(/\]/)).replace(/\,/g, ' ');
if (itemClasses) {
- $row.addClass(itemClasses);
+ $('span', $row).addClass(itemClasses);
var id = itemClasses.match(/id=[0-9]*/)[0].split('=')[1];
$row.data('id', id);
}
+
if (o.itemack) {
$row.bind("click", function() {
var item = $(this);
Modified: tools/rsslog/rsslog.php
===================================================================
--- tools/rsslog/rsslog.php 2012-02-15 18:11:56 UTC (rev 706)
+++ tools/rsslog/rsslog.php 2012-02-16 20:13:02 UTC (rev 707)
@@ -216,9 +216,13 @@
// return a handle to all the data
function retrieve( $db, $filter, $state )
{
-// $q = "SELECT content, strftime('%s', t, 'localtime') AS t FROM Logs";
- $q = "SELECT id, title, content, tags, state, strftime('%s', t) AS t FROM Logs " .
- "WHERE tags LIKE '%" . sqlite_escape_string($filter) . "%' ";
+ $filters = explode(',', $filter); // accept filters by separated by ,
+ foreach ($filters as $i => $val) {
+ $filters[$i] = " (tags LIKE '%" . sqlite_escape_string($val) . "%') ";
+ }
+
+ $q = "SELECT id, title, content, tags, state, strftime('%s', t) AS t FROM Logs WHERE" . implode('OR', $filters);;
+
if (isset($state))
$q .= " AND state=" . $state . " ";
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <j-...@us...> - 2012-02-15 18:12:05
|
Revision: 706
http://openautomation.svn.sourceforge.net/openautomation/?rev=706&view=rev
Author: j-n-k
Date: 2012-02-15 18:11:56 +0000 (Wed, 15 Feb 2012)
Log Message:
-----------
Test fix for reported problem with colspan and groups in 2-column designs
Groups can handle more than 1 column inside the border
Modified Paths:
--------------
CometVisu/trunk/visu/designs/pure/basic.css
CometVisu/trunk/visu/designs/structure_pure.js
Modified: CometVisu/trunk/visu/designs/pure/basic.css
===================================================================
--- CometVisu/trunk/visu/designs/pure/basic.css 2012-02-13 22:13:43 UTC (rev 705)
+++ CometVisu/trunk/visu/designs/pure/basic.css 2012-02-15 18:11:56 UTC (rev 706)
@@ -62,16 +62,17 @@
vertical-align: middle;
}
-.colspan0 { /* multiple of 8.33333% ! */
- width: 49.9998%;
-}
.widget_container {
float: left;
}
-.widget_container .widget_container {
+/*.widget_container .widget_container {
width: 100%;
+}*/
+
+.colspan0 { /* multiple of 8.33333% ! */
+ width: 49.9998%;
}
.widget
Modified: CometVisu/trunk/visu/designs/structure_pure.js
===================================================================
--- CometVisu/trunk/visu/designs/structure_pure.js 2012-02-13 22:13:43 UTC (rev 705)
+++ CometVisu/trunk/visu/designs/structure_pure.js 2012-02-15 18:11:56 UTC (rev 706)
@@ -155,7 +155,9 @@
} else { // default is visible
ret_val = $('<div class="widget clearfix link pagelink"/>');
ret_val.setWidgetLayout($p);
- ret_val.append( '<div ' + wstyle + '><a href="javascript:scrollToPage(\''+path+'\')">' + name + '</a></div>' );
+ var tst = $('<div ' + wstyle + '><a href="javascript:scrollToPage(\''+path+'\')">' + name + '</a></div>');
+
+ ret_val.append(tst );
}
var childs = $p.children();
@@ -230,6 +232,7 @@
var hstyle = ''; // heading style
if( $p.attr('align') ) hstyle += 'text-align:' + $p.attr('align') + ';';
if( hstyle != '' ) hstyle = 'style="' + hstyle + '"';
+ ret_val.setWidgetLayout($p);
var childs = $p.children();
var container = $( '<div class="clearfix"/>' );
if( $p.attr('name') ) container.append( '<h2 ' + hstyle + '>' + $p.attr('name') + '</h2>' );
@@ -243,6 +246,8 @@
attributes: {
align: { type: 'string', required: false },
flavour:{ type: 'string', required: false },
+ colspan: { type: 'numeric', required: false },
+ rowspan: { type: 'numeric', required: false },
name: { type: 'string', required: true }
},
elements: {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|