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...> - 2011-05-11 16:04:22
|
Revision: 330
http://openautomation.svn.sourceforge.net/openautomation/?rev=330&view=rev
Author: mayerch
Date: 2011-05-11 16:04:16 +0000 (Wed, 11 May 2011)
Log Message:
-----------
Added a scope block the Logic Editor (this was quite hackish and has to be cleaned up later)
NOTE: The performance in the browser (expecially FireFox) can get real bad, there's a big optimisation needed
Modified Paths:
--------------
PyWireGate/trunk/logic_editor/backendCommunication.js
PyWireGate/trunk/logic_editor/gle/gle.block.js
PyWireGate/trunk/logic_editor/logicEditor.js
PyWireGate/trunk/logic_server/LogicLibrary.py
PyWireGate/trunk/logik.json
PyWireGate/trunk/logik2.json
Modified: PyWireGate/trunk/logic_editor/backendCommunication.js
===================================================================
--- PyWireGate/trunk/logic_editor/backendCommunication.js 2011-05-10 21:04:09 UTC (rev 329)
+++ PyWireGate/trunk/logic_editor/backendCommunication.js 2011-05-11 16:04:16 UTC (rev 330)
@@ -282,14 +282,16 @@
// tweak backend communication, should also be done on demand
live = new CometVisu( '/live/' );
liveUpdateCalls = [];
+count = 10;
live.update = function( json )
{
$.each( liveUpdateCalls, function(){
- for( var i = json.length-1; i >= 0; i-- )
+ for( var i = 0; i < json.length; i++ )
{
- if( json[i].block == this[0] )
+ var last = i == json.length-1;
+ if( json[i].block == this[0] && ( last || !this[1] ) )
{
- this[1]( json[i].value );
+ this[2]( json[i].value );
}
}
});
Modified: PyWireGate/trunk/logic_editor/gle/gle.block.js
===================================================================
--- PyWireGate/trunk/logic_editor/gle/gle.block.js 2011-05-10 21:04:09 UTC (rev 329)
+++ PyWireGate/trunk/logic_editor/gle/gle.block.js 2011-05-11 16:04:16 UTC (rev 330)
@@ -50,6 +50,8 @@
var parameters = prototype.parameters || {};
var parameter = prototype.parameter || createParameter( prototype.parameters );
var postParameterUpdateFn = maskOptions.postParameterUpdate;
+ var cElem = false; // if that block has a <canvas> it's cached here
+ var cCtx = false; // as well as it's context
var canvas = svg || $('#editor').svg('get');
var addEvent = interactive !== undefined ? interactive : true;
@@ -85,8 +87,28 @@
// Draw the body
//var body = canvas.group( g, {'transform':'translate(6,1)'} );
var body = canvas.group( g );
- if( mask )
+ if( 'MainLib/scope' == type )
{
+ gB = body;
+ var xhtmlNS = 'http://www.w3.org/1999/xhtml',
+ svgNS = 'http://www.w3.org/2000/svg',
+ xlinkNS = 'http://www.w3.org/1999/xlink';
+ var f = document.createElementNS( svgNS, 'foreignObject' );
+ f.x.baseVal.value = 0;
+ f.y.baseVal.value = 0;
+ f.width.baseVal.value = width;
+ f.height.baseVal.value = height;
+ var c = document.createElementNS( xhtmlNS, 'canvas' );
+ c.width = width;
+ c.height = height;
+ var foObj = body.appendChild(f);
+ cElem = foObj.appendChild(c);
+ cCtx = cElem.getContext( '2d' );
+ cCtx.fillStyle="rgba(0,0,0,255)";
+ cCtx.fillRect(0,0,width,height);
+ }
+ else if( mask )
+ {
var path = canvas.createPath();
for( var i in mask )
{
@@ -223,14 +245,30 @@
}
// private function for live updating of param = {'text-anchor':'start'}a display
+ var scopeLastX = -1;
this._updateValue = function( value )
{
- if( g )
+ if( 'MainLib/scope' == type )
{
- //console.log( '_updateValue', value.toString(), g, 10, height/2 );
- $( g ).find( '.valueString').remove();
- param = {'text-anchor':'start','class':'valueString'};
- canvas.text( g, 10, height/2, value.toString(), param );
+ scopeLastX = ( scopeLastX + 1 ) % width;
+ var thisY = Math.round( (2.0+value)*(height/4.0) );
+ var imgdA = cCtx.getImageData( 0, 0, width-1, height );
+ cCtx.putImageData( imgdA, 1, 0 );
+ var imgdI = cCtx.createImageData( 1, height );
+ var pix = imgdI.data;
+ for( var i = 0; i < height; i++ )
+ pix[ 4 * i + 3 ] = 255; // set alpha
+ pix[ 4 * thisY + 0 ] = 0 ; // red
+ pix[ 4 * thisY + 1 ] = 255; // green
+ pix[ 4 * thisY + 2 ] = 0 ; // blue
+ cCtx.putImageData( imgdI, 0, 0 );
+ } else {
+ if( g )
+ {
+ $( g ).find( '.valueString').remove();
+ param = {'text-anchor':'start','class':'valueString'};
+ canvas.text( g, 10, height/2, value.toString(), param );
+ }
}
}
Modified: PyWireGate/trunk/logic_editor/logicEditor.js
===================================================================
--- PyWireGate/trunk/logic_editor/logicEditor.js 2011-05-10 21:04:09 UTC (rev 329)
+++ PyWireGate/trunk/logic_editor/logicEditor.js 2011-05-11 16:04:16 UTC (rev 330)
@@ -200,10 +200,11 @@
var b = new Block( element, svg, addEvent );
if( addEvent ) blockRegistry[ element.name ] = b;
// FIXME this should become more generalized
- if( 'MainLib/display' == element.type ) // make display interactive
+ if( 'MainLib/display' == element.type || 'MainLib/scope' == element.type ) // make display and scope interactive
{
liveUpdateCalls.push( [
b.getName(),
+ 'MainLib/display' == element.type,
b._updateValue
] );
}
Modified: PyWireGate/trunk/logic_server/LogicLibrary.py
===================================================================
--- PyWireGate/trunk/logic_server/LogicLibrary.py 2011-05-10 21:04:09 UTC (rev 329)
+++ PyWireGate/trunk/logic_server/LogicLibrary.py 2011-05-11 16:04:16 UTC (rev 330)
@@ -37,6 +37,16 @@
#_codingInstructions = lambda s, n, i, o, p: ( None, "print __time,',','\"%%s\"' %% globalVariables['__name'],',','%s',',',%s" % ( n, i[0]) )
_codingInstructions = lambda s, n, i, o, p: ( None, "inspector['%s'] = %s" % ( n, i[0]) )
+class ScopeBlock( LogicModule.LogicModule ):
+ _name = "scope"
+ _inPorts = [ 'in' ]
+ _outPorts = []
+ _parameters = []
+ _drawingInstructions = ""
+ _maskOptions = { 'showLabel': False }
+ _codingInstructions = lambda s, n, i, o, p: ( None, "inspector['%s'] = %s" % ( n, i[0]) )
+
+
class GainBlock( LogicModule.LogicModule ):
_name = "gain"
_inPorts = [ 'in' ]
@@ -80,6 +90,7 @@
def __init__( self ):
self.addBlock( ConstBlock )
self.addBlock( DisplayBlock )
+ self.addBlock( ScopeBlock )
self.addBlock( GainBlock )
self.addBlock( SumBlock )
self.addBlock( MemoryBlock )
Modified: PyWireGate/trunk/logik.json
===================================================================
--- PyWireGate/trunk/logik.json 2011-05-10 21:04:09 UTC (rev 329)
+++ PyWireGate/trunk/logik.json 2011-05-11 16:04:16 UTC (rev 330)
@@ -38,8 +38,13 @@
},
"Display3": {
"type": "MainLib/display",
- "x": 250, "y": 250, "width": 150, "height": 50,
+ "x": 250, "y": 350, "width": 150, "height": 50,
"parameters": {}
+ },
+ "Scope_1": {
+ "type": "MainLib/scope",
+ "x": 500, "y": 125, "width": 600, "height": 300,
+ "parameters": {}
}
},
"signals": [
@@ -49,6 +54,7 @@
[ "Integral1", 0, "Integral2" , 0, {} ],
[ "Integral2", 0, "Gain2" , 0, {} ],
[ "Gain2" , 0, "Integral1" , 0, {} ],
- [ "Integral2", 0, "Display3" , 0, {} ]
+ [ "Integral2", 0, "Display3" , 0, {} ],
+ [ "Integral2", 0, "Scope_1" , 0, {} ]
]
}
\ No newline at end of file
Modified: PyWireGate/trunk/logik2.json
===================================================================
--- PyWireGate/trunk/logik2.json 2011-05-10 21:04:09 UTC (rev 329)
+++ PyWireGate/trunk/logik2.json 2011-05-11 16:04:16 UTC (rev 330)
@@ -18,7 +18,7 @@
},
"Display22": {
"type": "MainLib/display",
- "x": 350, "y": 150, "width": 150, "height": 50,
+ "x": 350, "y": 50, "width": 150, "height": 50,
"parameters": {}
},
"Integral2": {
@@ -31,6 +31,11 @@
"x": 150, "y": 50, "width": 50, "height": 50,
"parameters": { "gain": -1.0 },
"flip" : true
+ },
+ "Scope_2": {
+ "type": "MainLib/scope",
+ "x": 350, "y": 150, "width": 600, "height": 300,
+ "parameters": {}
}
},
"signals": [
@@ -40,6 +45,7 @@
[ "Memory1" , 0, "Sum1" , 1, {} ],
[ "Integral2", 0, "Gain2" , 0, {} ],
[ "Gain2" , 0, "Gain1" , 0, {} ],
- [ "Integral2", 0, "Display22" , 0, {} ]
+ [ "Integral2", 0, "Display22" , 0, {} ],
+ [ "Integral2", 0, "Scope_2" , 0, {} ]
]
}
\ 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: <ma...@us...> - 2011-05-10 21:04:16
|
Revision: 329
http://openautomation.svn.sourceforge.net/openautomation/?rev=329&view=rev
Author: mayerch
Date: 2011-05-10 21:04:09 +0000 (Tue, 10 May 2011)
Log Message:
-----------
Added feature to allow to flip blocks
Modified Paths:
--------------
PyWireGate/trunk/logic_editor/LogicEditor.py
PyWireGate/trunk/logic_editor/gle/gle.block.js
PyWireGate/trunk/logic_server/LogicModule.py
PyWireGate/trunk/logik.json
PyWireGate/trunk/logik2.json
Modified: PyWireGate/trunk/logic_editor/LogicEditor.py
===================================================================
--- PyWireGate/trunk/logic_editor/LogicEditor.py 2011-05-10 17:49:48 UTC (rev 328)
+++ PyWireGate/trunk/logic_editor/LogicEditor.py 2011-05-10 21:04:09 UTC (rev 329)
@@ -112,18 +112,14 @@
prefix = ','
f.write( '],' )
+ f.write( '"flip":%s,' % self._convert2JSON( block.flip() ) )
+
f.write( '"maskOptions":{' )
prefix = ''
maskOptions = block.maskOptions()
for maskOption in maskOptions:
option = maskOptions[maskOption]
- if type(option) in (int, float):
- f.write( '%s"%s":%s' % (prefix, maskOption, option) )
- elif type(option) == bool:
- option = 'true' if option else 'false'
- f.write( '%s"%s":%s' % (prefix, maskOption, option) )
- else:
- f.write( '%s"%s":"%s"' % (prefix, maskOption, option) )
+ f.write( '%s"%s":%s' % (prefix, maskOption, self._convert2JSON( option ) ) )
prefix = ','
f.write( '},' )
@@ -189,4 +185,15 @@
def copyfile(self, source, outputfile):
shutil.copyfileobj(source, outputfile)
-
\ No newline at end of file
+
+ # create a JSON representation out of the Python value
+ def _convert2JSON( self, value ):
+ if type( value ) in ( int, float ):
+ return str( value )
+ elif type( value ) == bool:
+ if value:
+ return 'true'
+ else:
+ return 'false'
+ else:
+ return '"%s"' % value
Modified: PyWireGate/trunk/logic_editor/gle/gle.block.js
===================================================================
--- PyWireGate/trunk/logic_editor/gle/gle.block.js 2011-05-10 17:49:48 UTC (rev 328)
+++ PyWireGate/trunk/logic_editor/gle/gle.block.js 2011-05-10 21:04:09 UTC (rev 329)
@@ -176,7 +176,7 @@
}
if( maskOptions.showLabel )
canvas.text( g, 1.2*p[0].x-0.2*p[1].x, 1.2*p[0].y-0.2*p[1].y, this.name,
- {'dominant-baseline':'middle','text-anchor':'start'} );
+ {'dominant-baseline':'middle','text-anchor': flip?'end':'start'} );
});
// Draw the outports
@@ -198,7 +198,7 @@
}
if( maskOptions.showLabel )
canvas.text( g, 1.2*p[0].x-0.2*p[1].x, 1.2*p[0].y-0.2*p[1].y, this.name,
- {'dominant-baseline':'middle','text-anchor':'end'} );
+ {'dominant-baseline':'middle','text-anchor': flip?'start':'end'} );
});
// Draw the label
@@ -379,15 +379,15 @@
return maskOptions.inPortPos( number, that, maskOptions, parameter );
} else
return [
- { x: x , y: y + height * (0.5 + number) / inPorts.length },
- { x: x - 20, y: y + height * (0.5 + number) / inPorts.length }
+ { x: flip ? x + width : x , y: y + height * (0.5 + number) / inPorts.length },
+ { x: flip ? x + width + 20 : x - 20, y: y + height * (0.5 + number) / inPorts.length }
];
}
this.outPortPos = function( number )
{
return [
- { x: x + width , y: y + height * (0.5 + number) / outPorts.length },
- { x: x + width + 20, y: y + height * (0.5 + number) / outPorts.length }
+ { x: flip ? x : x + width , y: y + height * (0.5 + number) / outPorts.length },
+ { x: flip ? x - 20 : x + width + 20, y: y + height * (0.5 + number) / outPorts.length }
];
}
Modified: PyWireGate/trunk/logic_server/LogicModule.py
===================================================================
--- PyWireGate/trunk/logic_server/LogicModule.py 2011-05-10 17:49:48 UTC (rev 328)
+++ PyWireGate/trunk/logic_server/LogicModule.py 2011-05-10 21:04:09 UTC (rev 329)
@@ -18,6 +18,10 @@
class LogicModule:
"""The base class for a generic logic module"""
+
+ # default values
+ _flip = False
+
def name( self ):
return self._name
@@ -30,6 +34,9 @@
def parameters( self ):
return self._parameters
+ def flip( self ):
+ return self._flip
+
def drawingIntructions( self ):
return self._drawingInstructions
Modified: PyWireGate/trunk/logik.json
===================================================================
--- PyWireGate/trunk/logik.json 2011-05-10 17:49:48 UTC (rev 328)
+++ PyWireGate/trunk/logik.json 2011-05-10 21:04:09 UTC (rev 329)
@@ -33,7 +33,8 @@
"Gain2": {
"type": "MainLib/gain",
"x": 150, "y": 350, "width": 50, "height": 50,
- "parameters": { "gain": -1.0 }
+ "parameters": { "gain": -1.0 },
+ "flip" : true
},
"Display3": {
"type": "MainLib/display",
Modified: PyWireGate/trunk/logik2.json
===================================================================
--- PyWireGate/trunk/logik2.json 2011-05-10 17:49:48 UTC (rev 328)
+++ PyWireGate/trunk/logik2.json 2011-05-10 21:04:09 UTC (rev 329)
@@ -2,8 +2,9 @@
"blocks": {
"Memory1": {
"type": "MainLib/memory",
- "x": 150, "y": 300, "width": 50, "height": 50,
- "parameters": { "initial_value": 1.0 }
+ "x": 150, "y": 250, "width": 50, "height": 50,
+ "parameters": { "initial_value": 1.0 },
+ "flip" : true
},
"Gain1": {
"type": "MainLib/gain",
@@ -12,27 +13,28 @@
},
"Sum1": {
"type": "MainLib/sum",
- "x": 150, "y": 200, "width": 50, "height": 50,
+ "x": 150, "y": 150, "width": 50, "height": 50,
"parameters": {}
},
"Display22": {
"type": "MainLib/display",
- "x": 350, "y": 300, "width": 150, "height": 50,
+ "x": 350, "y": 150, "width": 150, "height": 50,
"parameters": {}
},
"Integral2": {
"type": "MainLib/integral",
- "x": 250, "y": 300, "width": 50, "height": 50,
+ "x": 250, "y": 150, "width": 50, "height": 50,
"parameters": { "inital_value": 0.0 }
},
"Gain2": {
"type": "MainLib/gain",
"x": 150, "y": 50, "width": 50, "height": 50,
- "parameters": { "gain": -1.0 }
+ "parameters": { "gain": -1.0 },
+ "flip" : true
}
},
"signals": [
- [ "Memory1" , 0, "Integral2" , 0, {} ],
+ [ "Sum1" , 0, "Integral2" , 0, {} ],
[ "Gain1" , 0, "Sum1" , 0, {} ],
[ "Sum1" , 0, "Memory1" , 0, {} ],
[ "Memory1" , 0, "Sum1" , 1, {} ],
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ma...@us...> - 2011-05-10 17:49:55
|
Revision: 328
http://openautomation.svn.sourceforge.net/openautomation/?rev=328&view=rev
Author: mayerch
Date: 2011-05-10 17:49:48 +0000 (Tue, 10 May 2011)
Log Message:
-----------
Finish the display the current values of the LogicServer in the current LogicEditor view
(The solution is quite hackish and has to be cleaned up later)
Modified Paths:
--------------
PyWireGate/trunk/logic_editor/LogicEditor.py
PyWireGate/trunk/logic_editor/backendCommunication.js
PyWireGate/trunk/logic_editor/gle/gle.block.js
PyWireGate/trunk/logic_editor/logicEditor.js
PyWireGate/trunk/logic_server/LogicImportJSON.py
PyWireGate/trunk/logic_server/LogicLibrary.py
PyWireGate/trunk/logic_server/LogicModule.py
PyWireGate/trunk/logic_server/LogicServer.py
PyWireGate/trunk/logik.json
PyWireGate/trunk/logik2.json
Modified: PyWireGate/trunk/logic_editor/LogicEditor.py
===================================================================
--- PyWireGate/trunk/logic_editor/LogicEditor.py 2011-05-10 15:13:52 UTC (rev 327)
+++ PyWireGate/trunk/logic_editor/LogicEditor.py 2011-05-10 17:49:48 UTC (rev 328)
@@ -81,11 +81,12 @@
f.write('{ \x22v\x22:\x220.0.1\x22, \x22s\x22:\x22SESSION\x22 }\n\n')
elif self.path.startswith("/logicLib"):
lib = LogicLibrary.LogicLibrary().getLibrary()
- f.write( '{"MainLib":{' )
+ thisLib = 'MainLib' # FIXME iterate over it...
+ f.write( '{"%s":{' % thisLib )
blockPrefix = ''
- for blockName in lib:
+ for blockName in lib[ thisLib ]:
f.write( '%s"%s":{"name":"%s",' % (blockPrefix, blockName, blockName) )
- block = lib[ blockName ]
+ block = lib[ thisLib ][ blockName ]
f.write( '"inPorts":[' )
prefix = ''
@@ -111,6 +112,21 @@
prefix = ','
f.write( '],' )
+ f.write( '"maskOptions":{' )
+ prefix = ''
+ maskOptions = block.maskOptions()
+ for maskOption in maskOptions:
+ option = maskOptions[maskOption]
+ if type(option) in (int, float):
+ f.write( '%s"%s":%s' % (prefix, maskOption, option) )
+ elif type(option) == bool:
+ option = 'true' if option else 'false'
+ f.write( '%s"%s":%s' % (prefix, maskOption, option) )
+ else:
+ f.write( '%s"%s":"%s"' % (prefix, maskOption, option) )
+ prefix = ','
+ f.write( '},' )
+
f.write( '"width":100,"height":50,"rotation":0,"flip":false,"color":[0.0,0.0,0.0],"background":[1.0, 1.0, 1.0]' )
f.write( '}' )
Modified: PyWireGate/trunk/logic_editor/backendCommunication.js
===================================================================
--- PyWireGate/trunk/logic_editor/backendCommunication.js 2011-05-10 15:13:52 UTC (rev 327)
+++ PyWireGate/trunk/logic_editor/backendCommunication.js 2011-05-10 17:49:48 UTC (rev 328)
@@ -280,28 +280,22 @@
});
// tweak backend communication, should also be done on demand
-XXX = new CometVisu( '/live/' );
-XXX.update = function( json )
+live = new CometVisu( '/live/' );
+liveUpdateCalls = [];
+live.update = function( json )
{
- console.log( json );
+ $.each( liveUpdateCalls, function(){
+ for( var i = json.length-1; i >= 0; i-- )
+ {
+ if( json[i].block == this[0] )
+ {
+ this[1]( json[i].value );
+ }
+ }
+ });
}
-XXX.subscribe( ['ALL'] );
+live.subscribe( ['ALL'] );
$(window).unload(function() {
- XXX.stop();
-});
-/*XXX=$.ajax({
- url: '/live',
- cache: false,
- success: function(html){
- console.log('success', html);
- }
-});*/
-/*
- var ws = new websocket("/live");
- ws.onopen = function() {
- ws.send("Hello Mr. Server!");
- };
- ws.onmessage = function (e) { console.log(e.data); };
- ws.onclose = function() { console.log('close'); };
- */
\ No newline at end of file
+ live.stop();
+});
\ No newline at end of file
Modified: PyWireGate/trunk/logic_editor/gle/gle.block.js
===================================================================
--- PyWireGate/trunk/logic_editor/gle/gle.block.js 2011-05-10 15:13:52 UTC (rev 327)
+++ PyWireGate/trunk/logic_editor/gle/gle.block.js 2011-05-10 17:49:48 UTC (rev 328)
@@ -21,11 +21,11 @@
/**
* The block constructor.
- * type: the block (proto)type in JSON notation
+ * prototype: the block (proto)type in JSON notation
* svg: the link to the SVG canvas
* interactive: event handlers will be added, set to false to create picture only
*/
-function Block( type, svg, interactive )
+function Block( prototype, svg, interactive )
{
// setup the private "constants"
var that = this;
@@ -33,21 +33,22 @@
var outset = 3; // how far should the handle stick out
// setup the private variables
- var name = type.name || 'UNKNOWN';
- var x = type.x || 0;
- var y = type.y || 0;
- var width = type.width || 100;
- var height = type.height || 100;
- var rotation = type.rotation || 0;
- var flip = type.flip || false;
- var mask = type.mask || undefined;
- var maskOptions = type.maskOptions || { showLabel: true };
- var color = type.color || [0.0, 0.0, 0.0];
- var background = type.background || [1.0, 1.0, 1.0];
- var inPorts = type.inPorts || [];
- var outPorts = type.outPorts || [];
- var parameters = type.parameters || {};
- var parameter = type.parameter || createParameter( type.parameters );
+ var type = prototype.type || 'UNKNOWN';
+ var name = prototype.name || 'UNKNOWN';
+ var x = prototype.x || 0;
+ var y = prototype.y || 0;
+ var width = prototype.width || 100;
+ var height = prototype.height || 100;
+ var rotation = prototype.rotation || 0;
+ var flip = prototype.flip || false;
+ var mask = prototype.mask || undefined;
+ var maskOptions = prototype.maskOptions || { showLabel: true };
+ var color = prototype.color || [0.0, 0.0, 0.0];
+ var background = prototype.background || [1.0, 1.0, 1.0];
+ var inPorts = prototype.inPorts || [];
+ var outPorts = prototype.outPorts || [];
+ var parameters = prototype.parameters || {};
+ var parameter = prototype.parameter || createParameter( prototype.parameters );
var postParameterUpdateFn = maskOptions.postParameterUpdate;
var canvas = svg || $('#editor').svg('get');
@@ -221,6 +222,18 @@
}
+ // private function for live updating of param = {'text-anchor':'start'}a display
+ this._updateValue = function( value )
+ {
+ if( g )
+ {
+ //console.log( '_updateValue', value.toString(), g, 10, height/2 );
+ $( g ).find( '.valueString').remove();
+ param = {'text-anchor':'start','class':'valueString'};
+ canvas.text( g, 10, height/2, value.toString(), param );
+ }
+ }
+
function createParameter( structure )
{
var retVal = {};
@@ -339,6 +352,8 @@
}
// the public (privileged) methods:
+ this.getType = function() { return type ; }
+ this.getName = function() { return name ; }
this.getWidth = function() { return width ; }
this.setWidth = function( _width ) { width = _width ; draw(); }
this.getHeight = function() { return height; }
Modified: PyWireGate/trunk/logic_editor/logicEditor.js
===================================================================
--- PyWireGate/trunk/logic_editor/logicEditor.js 2011-05-10 15:13:52 UTC (rev 327)
+++ PyWireGate/trunk/logic_editor/logicEditor.js 2011-05-10 17:49:48 UTC (rev 328)
@@ -137,6 +137,7 @@
$.each( this, function( element ){
var entry = $('<div class="libEntry"></div>');
var obj = this;
+ obj.type = libName + '/' + element;
var width = this.width+20;
var height = this.height+35;
entry.prepend(
@@ -165,12 +166,13 @@
{
logic = logics[ logicName ];
- // clean canvas first
- $('#editor g').remove();
+ $('#editor g').remove(); // clean canvas first
+ blockRegistry = {}; // and then the block registry
// draw all the blocks
$.each( logic.blocks, function( name, def ){
- var newBlock = $.extend( true, {}, libJSON['MainLib'][ def.type ], def, {'name':name} );
+ var type = def.type.split('/');
+ var newBlock = $.extend( true, {}, libJSON[ type[0] ][ type[1] ], def, {'name':name} );
drawElement( undefined, newBlock, true );
});
@@ -197,6 +199,14 @@
if( addEvent === undefined ) addEvent = true;
var b = new Block( element, svg, addEvent );
if( addEvent ) blockRegistry[ element.name ] = b;
+ // FIXME this should become more generalized
+ if( 'MainLib/display' == element.type ) // make display interactive
+ {
+ liveUpdateCalls.push( [
+ b.getName(),
+ b._updateValue
+ ] );
+ }
}
function colorByArray( a )
Modified: PyWireGate/trunk/logic_server/LogicImportJSON.py
===================================================================
--- PyWireGate/trunk/logic_server/LogicImportJSON.py 2011-05-10 15:13:52 UTC (rev 327)
+++ PyWireGate/trunk/logic_server/LogicImportJSON.py 2011-05-10 17:49:48 UTC (rev 328)
@@ -36,7 +36,8 @@
stateupdate = '' # the string containing the update of the states
for name, attribute in loaddict['blocks'].iteritems():
- block = lib[ attribute['type'] ]
+ blockType = attribute['type'].split('/')
+ block = lib[ blockType[0] ][ blockType[1] ]
G.add_node( name, attribute )
# Add aditional, virtual node "<name>.state" that is treates as an additional
# input with no dependancy as the state won't change during an update cycle,
@@ -49,7 +50,8 @@
for signal in loaddict['signals']:
b = loaddict['blocks']
- if lib[ loaddict['blocks'][ signal[0] ]['type'] ].outPortNumberHasState( signal[1] ):
+ blockType = loaddict['blocks'][ signal[0] ]['type'].split('/')
+ if lib[ blockType[0] ][ blockType[1] ].outPortNumberHasState( signal[1] ):
G.add_edge( signal[0] + '.state', signal[2], { 'ports': ( signal[1], signal[3] ), 'start': signal[0] } )
else:
G.add_edge( signal[0], signal[2], { 'ports': ( signal[1], signal[3] ), 'start': signal[0] } )
@@ -59,12 +61,14 @@
for instruction in intructionOrder:
if not instruction in loaddict['blocks']:
continue # ignore the virtual state nodes
- libBlock = lib[ loaddict['blocks'][ instruction ]['type'] ]
+ blockType = loaddict['blocks'][ instruction ]['type'].split('/')
+ libBlock = lib[ blockType[0] ][ blockType[1] ]
ins = []
for i in range(len(libBlock.inPorts())):
for e in G.in_edges_iter( instruction, True ):
if e[2]['ports'][1] == i:
- if lib[ loaddict['blocks'][ e[2]['start'] ]['type'] ].outPortNumberHasState( e[2]['ports'][0] ):
+ blockType = loaddict['blocks'][ e[2]['start'] ]['type'].split('/')
+ if lib[ blockType[0] ][ blockType[1] ].outPortNumberHasState( e[2]['ports'][0] ):
ins.append( "self.%s_%s" % ( e[2]['start'], e[2]['ports'][0] ) )
else:
ins.append( "%s_%s" % ( e[2]['start'], e[2]['ports'][0] ) )
Modified: PyWireGate/trunk/logic_server/LogicLibrary.py
===================================================================
--- PyWireGate/trunk/logic_server/LogicLibrary.py 2011-05-10 15:13:52 UTC (rev 327)
+++ PyWireGate/trunk/logic_server/LogicLibrary.py 2011-05-10 17:49:48 UTC (rev 328)
@@ -24,14 +24,16 @@
_outPorts = [ ( 'out', 'const' ) ]
_parameters = [ 'value' ]
_drawingInstructions = ""
+ _maskOptions = { 'showLabel': True }
_codingInstructions = lambda s, n, i, o, p: ( "%s = %s" % ( o[0], p[0] ), "%s_next = %s" % ( o[0], p[0] ) )
-class LogBlock( LogicModule.LogicModule ):
+class DisplayBlock( LogicModule.LogicModule ):
_name = "display"
_inPorts = [ 'in' ]
_outPorts = []
_parameters = []
_drawingInstructions = ""
+ _maskOptions = { 'showLabel': False }
#_codingInstructions = lambda s, n, i, o, p: ( None, "print __time,',','\"%%s\"' %% globalVariables['__name'],',','%s',',',%s" % ( n, i[0]) )
_codingInstructions = lambda s, n, i, o, p: ( None, "inspector['%s'] = %s" % ( n, i[0]) )
@@ -41,6 +43,7 @@
_outPorts = [ ( 'out', 'signal' ) ]
_parameters = [ 'gain' ]
_drawingInstructions = ""
+ _maskOptions = { 'showLabel': True }
_codingInstructions = lambda s, n, i, o, p: ( None, "%s = %s * %s" % ( o[0], p[0], i[0] ) )
class SumBlock( LogicModule.LogicModule ):
@@ -49,6 +52,7 @@
_outPorts = [ ( 'out', 'signal' ) ]
_parameters = []
_drawingInstructions = ""
+ _maskOptions = { 'showLabel': True }
_codingInstructions = lambda s, n, i, o, p: ( None, "%s = %s + %s" % ( o[0], i[0], i[1] ) )
class MemoryBlock( LogicModule.LogicModule ):
@@ -57,6 +61,7 @@
_outPorts = [ ( 'out', 'state' ) ]
_parameters = [ 'inital_value' ]
_drawingInstructions = ""
+ _maskOptions = { 'showLabel': True }
_codingInstructions = lambda s, n, i, o, p: ( "%s = %s" % (o[0], p[0]), "%s_next = %s" % ( o[0], i[0] ) )
class IntegralBlock( LogicModule.LogicModule ):
@@ -65,23 +70,25 @@
_outPorts = [ ( 'out', 'state' ) ]
_parameters = [ 'initial_value' ]
_drawingInstructions = ""
+ _maskOptions = { 'showLabel': True }
_codingInstructions = lambda s, n, i, o, p: ( "%s = %s" % (o[0], p[0]), "%s_next = %s * %s + self.%s" % ( o[0], "__dt", i[0], o[0] ) )
class LogicLibrary:
"""The container for all known library blocks"""
- _db = {}
+ _db = {'MainLib':{}}
def __init__( self ):
self.addBlock( ConstBlock )
- self.addBlock( LogBlock )
+ self.addBlock( DisplayBlock )
self.addBlock( GainBlock )
self.addBlock( SumBlock )
self.addBlock( MemoryBlock )
self.addBlock( IntegralBlock )
def addBlock( self, block ):
+ l = 'MainLib'
b = block()
- self._db[ b.name() ] = b
+ self._db[ l ][ b.name() ] = b
def getLibrary( self ):
return self._db
Modified: PyWireGate/trunk/logic_server/LogicModule.py
===================================================================
--- PyWireGate/trunk/logic_server/LogicModule.py 2011-05-10 15:13:52 UTC (rev 327)
+++ PyWireGate/trunk/logic_server/LogicModule.py 2011-05-10 17:49:48 UTC (rev 328)
@@ -33,6 +33,9 @@
def drawingIntructions( self ):
return self._drawingInstructions
+ def maskOptions( self ):
+ return self._maskOptions
+
def codingIntructions( self, name, ins, outs, params ):
return self._codingInstructions( name, ins, outs, params )
Modified: PyWireGate/trunk/logic_server/LogicServer.py
===================================================================
--- PyWireGate/trunk/logic_server/LogicServer.py 2011-05-10 15:13:52 UTC (rev 327)
+++ PyWireGate/trunk/logic_server/LogicServer.py 2011-05-10 17:49:48 UTC (rev 328)
@@ -79,8 +79,8 @@
self.Logik2 = LogikClass
t = TaskManager.TaskManager(self)
- t.addInterval( 'Interval 1 - 75 ms Task', 0.75 )
- t.addInterval( 'Interval 2 - 10 ms Task', 0.910 )
+ t.addInterval( 'Interval 1 - 75 ms Task', 0.075 )
+ t.addInterval( 'Interval 2 - 10 ms Task', 0.010 )
t.addTask( 'Interval 1 - 75 ms Task', 'Logik1', self.Logik1 )
t.addTask( 'Interval 2 - 10 ms Task', 'Logik2', self.Logik2 )
t.start()
Modified: PyWireGate/trunk/logik.json
===================================================================
--- PyWireGate/trunk/logik.json 2011-05-10 15:13:52 UTC (rev 327)
+++ PyWireGate/trunk/logik.json 2011-05-10 17:49:48 UTC (rev 328)
@@ -1,42 +1,42 @@
{
"blocks": {
"Const1": {
- "type": "const",
+ "type": "MainLib/const",
"x": 50, "y": 50, "width": 50, "height": 50,
"parameters": { "value": 1.0 }
},
"Gain1": {
- "type": "gain",
+ "type": "MainLib/gain",
"x": 150, "y": 50, "width": 50, "height": 50,
"parameters": { "gain": 5.0 }
},
"Display1": {
- "type": "display",
+ "type": "MainLib/display",
"x": 250, "y": 150, "width": 150, "height": 50,
"parameters": {}
},
"Display2": {
- "type": "display",
+ "type": "MainLib/display",
"x": 250, "y": 50, "width": 150, "height": 50,
"parameters": {}
},
"Integral1": {
- "type": "integral",
+ "type": "MainLib/integral",
"x": 50, "y": 250, "width": 50, "height": 50,
"parameters": { "inital_value": 1.0 }
},
"Integral2": {
- "type": "integral",
+ "type": "MainLib/integral",
"x": 150, "y": 250, "width": 50, "height": 50,
"parameters": { "inital_value": 0.0 }
},
"Gain2": {
- "type": "gain",
+ "type": "MainLib/gain",
"x": 150, "y": 350, "width": 50, "height": 50,
"parameters": { "gain": -1.0 }
},
"Display3": {
- "type": "display",
+ "type": "MainLib/display",
"x": 250, "y": 250, "width": 150, "height": 50,
"parameters": {}
}
Modified: PyWireGate/trunk/logik2.json
===================================================================
--- PyWireGate/trunk/logik2.json 2011-05-10 15:13:52 UTC (rev 327)
+++ PyWireGate/trunk/logik2.json 2011-05-10 17:49:48 UTC (rev 328)
@@ -1,32 +1,32 @@
{
"blocks": {
"Memory1": {
- "type": "memory",
+ "type": "MainLib/memory",
"x": 150, "y": 300, "width": 50, "height": 50,
"parameters": { "initial_value": 1.0 }
},
"Gain1": {
- "type": "gain",
+ "type": "MainLib/gain",
"x": 50, "y": 150, "width": 50, "height": 50,
"parameters": { "gain": "__dt" }
},
"Sum1": {
- "type": "sum",
+ "type": "MainLib/sum",
"x": 150, "y": 200, "width": 50, "height": 50,
"parameters": {}
},
"Display22": {
- "type": "display",
+ "type": "MainLib/display",
"x": 350, "y": 300, "width": 150, "height": 50,
"parameters": {}
},
"Integral2": {
- "type": "integral",
+ "type": "MainLib/integral",
"x": 250, "y": 300, "width": 50, "height": 50,
"parameters": { "inital_value": 0.0 }
},
"Gain2": {
- "type": "gain",
+ "type": "MainLib/gain",
"x": 150, "y": 50, "width": 50, "height": 50,
"parameters": { "gain": -1.0 }
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ma...@us...> - 2011-05-10 15:13:59
|
Revision: 327
http://openautomation.svn.sourceforge.net/openautomation/?rev=327&view=rev
Author: mayerch
Date: 2011-05-10 15:13:52 +0000 (Tue, 10 May 2011)
Log Message:
-----------
- [PyWireGate]: Update the logic editor to have a CometVisu Protocol compatible connection between backend and frontend
- [CometVisu client]: add real session handling to the client
Modified Paths:
--------------
CometVisu/trunk/visu/lib/cometvisu-client.js
PyWireGate/trunk/logic_editor/LogicEditor.py
PyWireGate/trunk/logic_editor/backendCommunication.js
PyWireGate/trunk/logic_editor/index.html
PyWireGate/trunk/logic_editor/logicEditor.js
PyWireGate/trunk/logic_server/LogicServer.py
Property Changed:
----------------
PyWireGate/trunk/logic_editor/lib/
Modified: CometVisu/trunk/visu/lib/cometvisu-client.js
===================================================================
--- CometVisu/trunk/visu/lib/cometvisu-client.js 2011-05-09 17:10:59 UTC (rev 326)
+++ CometVisu/trunk/visu/lib/cometvisu-client.js 2011-05-10 15:13:52 UTC (rev 327)
@@ -106,7 +106,7 @@
{
var requestAddresses = (this.addresses.length)?'a=' + this.addresses.join( '&a=' ):'';
var requestFilters = (this.filters.length )?'f=' + this.filters.join( '&f=' ):'';
- return requestAddresses + ( (this.addresses.length&&this.filters.length)?'&':'' ) + requestFilters;
+ return 's=' + this.session + '&' + requestAddresses + ( (this.addresses.length&&this.filters.length)?'&':'' ) + requestFilters;
}
/**
Modified: PyWireGate/trunk/logic_editor/LogicEditor.py
===================================================================
--- PyWireGate/trunk/logic_editor/LogicEditor.py 2011-05-09 17:10:59 UTC (rev 326)
+++ PyWireGate/trunk/logic_editor/LogicEditor.py 2011-05-10 15:13:52 UTC (rev 327)
@@ -25,6 +25,7 @@
import SocketServer
import threading
+import Queue
import re
from logic_server import LogicLibrary
@@ -119,21 +120,40 @@
contentType="text/plain"
self.path = self.path.replace('/logicCode', thisPath + '/..')
return SimpleHTTPServer.SimpleHTTPRequestHandler.do_GET(self)
- elif self.path.startswith('/live'):
- self.send_response(200)
- self.send_header("Content-type", 'text/plain')
- self.send_header("Access-Control-Allow-Origin", "*")
- self.end_headers()
+
+
+ # Create the CometVisu interface for the internal variables
+ elif self.path.startswith('/live/l'):
# FIXME: BIG, Big, big memory and CPU leak! A created Queue must be
# removed later, or the LogicServer will continue to fill it, even if
# no page will be listening anymore!
l = LOGIC.createQueue( None, None, None ) # get everything!
+ contentType="text/plain"
+ f.write('{"v":"0.0.1","s":"live%s"}' % l)
+ elif self.path.startswith('/live/r'):
+ try:
+ l = int( re.findall('s=live(\d*)', self.path )[0] )
+ except IndexError:
+ return # FIXME - return sensible error message
+ self.send_response(200)
+ #self.send_header("Content-type", 'text/plain')
+ self.send_header("Content-type", 'application/json')
+ self.send_header("Access-Control-Allow-Origin", "*")
+ self.end_headers()
+ self.wfile.write( '{"d":[' )
+ sep = ''
+ getWait = True # wait for the first result, but not any longer
while True:
#self.wfile.write( "new line\n" )
- m = l.get()
- self.wfile.write( "|%s|%s|%s|%s|\n" % m )
- self.wfile.flush()
- #time.sleep( 1.0 )
+ try:
+ m = LOGIC.queues[l][3].get( getWait )
+ getWait = False
+ self.wfile.write( sep )
+ self.wfile.write( '{"task":"%s","module":"%s","block":"%s","value":%s}' % m )
+ sep = ','
+ except Queue.Empty:
+ self.wfile.write( '],"i":0}')
+ return # Queue is empty, end connection
else:
self.path = "%s%s" % ( thisPath, self.path )
return SimpleHTTPServer.SimpleHTTPRequestHandler.do_GET(self)
Modified: PyWireGate/trunk/logic_editor/backendCommunication.js
===================================================================
--- PyWireGate/trunk/logic_editor/backendCommunication.js 2011-05-09 17:10:59 UTC (rev 326)
+++ PyWireGate/trunk/logic_editor/backendCommunication.js 2011-05-10 15:13:52 UTC (rev 327)
@@ -278,3 +278,30 @@
logics['logik2'] = data;
updateKnownLogics('logik2');
});
+
+// tweak backend communication, should also be done on demand
+XXX = new CometVisu( '/live/' );
+XXX.update = function( json )
+{
+ console.log( json );
+}
+XXX.subscribe( ['ALL'] );
+
+$(window).unload(function() {
+ XXX.stop();
+});
+/*XXX=$.ajax({
+ url: '/live',
+ cache: false,
+ success: function(html){
+ console.log('success', html);
+ }
+});*/
+/*
+ var ws = new websocket("/live");
+ ws.onopen = function() {
+ ws.send("Hello Mr. Server!");
+ };
+ ws.onmessage = function (e) { console.log(e.data); };
+ ws.onclose = function() { console.log('close'); };
+ */
\ No newline at end of file
Modified: PyWireGate/trunk/logic_editor/index.html
===================================================================
--- PyWireGate/trunk/logic_editor/index.html 2011-05-09 17:10:59 UTC (rev 326)
+++ PyWireGate/trunk/logic_editor/index.html 2011-05-10 15:13:52 UTC (rev 327)
@@ -13,6 +13,7 @@
<script type="text/javascript" src="lib/jquery.layout.js"></script>
<script type="text/javascript" src="lib/jquery.jstree.js"></script>
<script type="text/javascript" src="lib/jquery.hotkeys.js"></script>
+ <script type="text/javascript" src="lib/cometvisu-client.js"></script>
<script type="text/javascript" src="backendCommunication.js"></script>
<script type="text/javascript" src="gle/gle.block.js"></script>
<script type="text/javascript" src="gle/gle.connection.js"></script>
Property changes on: PyWireGate/trunk/logic_editor/lib
___________________________________________________________________
Added: svn:externals
+ ^/CometVisu/trunk/visu/lib/cometvisu-client.js cometvisu-client.js
Modified: PyWireGate/trunk/logic_editor/logicEditor.js
===================================================================
--- PyWireGate/trunk/logic_editor/logicEditor.js 2011-05-09 17:10:59 UTC (rev 326)
+++ PyWireGate/trunk/logic_editor/logicEditor.js 2011-05-10 15:13:52 UTC (rev 327)
@@ -163,16 +163,19 @@
function displayLogic( logicName )
{
- console.log( '"'+logicName+'"' );
logic = logics[ logicName ];
+
+ // clean canvas first
+ $('#editor g').remove();
+
+ // draw all the blocks
$.each( logic.blocks, function( name, def ){
var newBlock = $.extend( true, {}, libJSON['MainLib'][ def.type ], def, {'name':name} );
drawElement( undefined, newBlock, true );
});
- console.log( blockRegistry );
+
+ // and connect them
$.each( logic.signals, function( name, def ){
- console.log( name, def, blockRegistry[ def[0] ] );
-
var startBlock = blockRegistry[ def[0] ];
var endBlock = blockRegistry[ def[2] ];
var pn = def[1];
Modified: PyWireGate/trunk/logic_server/LogicServer.py
===================================================================
--- PyWireGate/trunk/logic_server/LogicServer.py 2011-05-09 17:10:59 UTC (rev 326)
+++ PyWireGate/trunk/logic_server/LogicServer.py 2011-05-10 15:13:52 UTC (rev 327)
@@ -21,6 +21,7 @@
import TaskManager
import Queue
import time
+import threading
## Load logik.json
#exec LogicImportJSON.get( 'logik.json' )
@@ -46,7 +47,10 @@
CONNECTOR_NAME = 'Logic Server'
CONNECTOR_VERSION = 0.1
CONNECTOR_LOGNAME = 'logic_server'
- queues = []
+ queues = {}
+ lastQueueId = -1
+ write_mutex = threading.RLock()
+
def __init__(self,parent, instanceName):
self._parent = parent
self.WG = parent.WG
@@ -75,14 +79,15 @@
self.Logik2 = LogikClass
t = TaskManager.TaskManager(self)
- t.addInterval( 'Interval 1 - 75 ms Task', 0.075 )
- t.addInterval( 'Interval 2 - 10 ms Task', 0.010 )
+ t.addInterval( 'Interval 1 - 75 ms Task', 0.75 )
+ t.addInterval( 'Interval 2 - 10 ms Task', 0.910 )
t.addTask( 'Interval 1 - 75 ms Task', 'Logik1', self.Logik1 )
t.addTask( 'Interval 2 - 10 ms Task', 'Logik2', self.Logik2 )
t.start()
while True:
for m in iter( t.getMessage, None ):
for q in self.queues:
+ q = self.queues[q]
if (q[0] == None or q[0] == m[0]) and (q[1] == None or q[1] == m[1]):
for b in m[2]:
if q[2] == None or q[2] == b:
@@ -90,6 +95,11 @@
time.sleep( 0.1 )
def createQueue(self, taskFilter, logicFilter, blockFilter):
- q = Queue.Queue()
- self.queues.append( (taskFilter, logicFilter, blockFilter, q) )
- return q
\ No newline at end of file
+ try:
+ self.write_mutex.acquire()
+ self.lastQueueId += 1
+ thisQueueId = self.lastQueueId # extra variable to be save when the lock is released
+ self.queues[ thisQueueId ] = (taskFilter, logicFilter, blockFilter, Queue.Queue())
+ finally:
+ self.write_mutex.release()
+ return thisQueueId
\ 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: <ma...@us...> - 2011-05-09 17:11:05
|
Revision: 326
http://openautomation.svn.sourceforge.net/openautomation/?rev=326&view=rev
Author: mayerch
Date: 2011-05-09 17:10:59 +0000 (Mon, 09 May 2011)
Log Message:
-----------
Renamed "log" block to "display" - it'll show the current value in the editor in future and won't log to the screen anymore
Modified Paths:
--------------
PyWireGate/trunk/logic_server/LogicLibrary.py
PyWireGate/trunk/logik.json
PyWireGate/trunk/logik2.json
Modified: PyWireGate/trunk/logic_server/LogicLibrary.py
===================================================================
--- PyWireGate/trunk/logic_server/LogicLibrary.py 2011-05-09 17:09:29 UTC (rev 325)
+++ PyWireGate/trunk/logic_server/LogicLibrary.py 2011-05-09 17:10:59 UTC (rev 326)
@@ -27,7 +27,7 @@
_codingInstructions = lambda s, n, i, o, p: ( "%s = %s" % ( o[0], p[0] ), "%s_next = %s" % ( o[0], p[0] ) )
class LogBlock( LogicModule.LogicModule ):
- _name = "log"
+ _name = "display"
_inPorts = [ 'in' ]
_outPorts = []
_parameters = []
Modified: PyWireGate/trunk/logik.json
===================================================================
--- PyWireGate/trunk/logik.json 2011-05-09 17:09:29 UTC (rev 325)
+++ PyWireGate/trunk/logik.json 2011-05-09 17:10:59 UTC (rev 326)
@@ -10,14 +10,14 @@
"x": 150, "y": 50, "width": 50, "height": 50,
"parameters": { "gain": 5.0 }
},
- "Log1": {
- "type": "log",
- "x": 250, "y": 150, "width": 50, "height": 50,
+ "Display1": {
+ "type": "display",
+ "x": 250, "y": 150, "width": 150, "height": 50,
"parameters": {}
},
- "Log2": {
- "type": "log",
- "x": 250, "y": 50, "width": 50, "height": 50,
+ "Display2": {
+ "type": "display",
+ "x": 250, "y": 50, "width": 150, "height": 50,
"parameters": {}
},
"Integral1": {
@@ -35,19 +35,19 @@
"x": 150, "y": 350, "width": 50, "height": 50,
"parameters": { "gain": -1.0 }
},
- "Log3": {
- "type": "log",
- "x": 250, "y": 250, "width": 50, "height": 50,
+ "Display3": {
+ "type": "display",
+ "x": 250, "y": 250, "width": 150, "height": 50,
"parameters": {}
}
},
"signals": [
- [ "Const1" , 0, "Log1" , 0, {} ],
+ [ "Const1" , 0, "Display1" , 0, {} ],
[ "Const1" , 0, "Gain1" , 0, {} ],
- [ "Gain1" , 0, "Log2" , 0, {} ],
+ [ "Gain1" , 0, "Display2" , 0, {} ],
[ "Integral1", 0, "Integral2" , 0, {} ],
[ "Integral2", 0, "Gain2" , 0, {} ],
[ "Gain2" , 0, "Integral1" , 0, {} ],
- [ "Integral2", 0, "Log3" , 0, {} ]
+ [ "Integral2", 0, "Display3" , 0, {} ]
]
}
\ No newline at end of file
Modified: PyWireGate/trunk/logik2.json
===================================================================
--- PyWireGate/trunk/logik2.json 2011-05-09 17:09:29 UTC (rev 325)
+++ PyWireGate/trunk/logik2.json 2011-05-09 17:10:59 UTC (rev 326)
@@ -15,9 +15,9 @@
"x": 150, "y": 200, "width": 50, "height": 50,
"parameters": {}
},
- "Log22": {
- "type": "log",
- "x": 350, "y": 300, "width": 50, "height": 50,
+ "Display22": {
+ "type": "display",
+ "x": 350, "y": 300, "width": 150, "height": 50,
"parameters": {}
},
"Integral2": {
@@ -38,6 +38,6 @@
[ "Memory1" , 0, "Sum1" , 1, {} ],
[ "Integral2", 0, "Gain2" , 0, {} ],
[ "Gain2" , 0, "Gain1" , 0, {} ],
- [ "Integral2", 0, "Log22" , 0, {} ]
+ [ "Integral2", 0, "Display22" , 0, {} ]
]
}
\ 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: <ma...@us...> - 2011-05-09 17:09:35
|
Revision: 325
http://openautomation.svn.sourceforge.net/openautomation/?rev=325&view=rev
Author: mayerch
Date: 2011-05-09 17:09:29 +0000 (Mon, 09 May 2011)
Log Message:
-----------
Route inspected values from the Logic Server to the Logic Editor
Modified Paths:
--------------
PyWireGate/trunk/logic_editor/LogicEditor.py
PyWireGate/trunk/logic_server/LogicServer.py
Modified: PyWireGate/trunk/logic_editor/LogicEditor.py
===================================================================
--- PyWireGate/trunk/logic_editor/LogicEditor.py 2011-05-09 15:19:30 UTC (rev 324)
+++ PyWireGate/trunk/logic_editor/LogicEditor.py 2011-05-09 17:09:29 UTC (rev 325)
@@ -33,6 +33,7 @@
import time
thisPath = '/'
+LOGIC = None
class logic_editor(ConnectorServer):
CONNECTOR_NAME = 'Logic Editor'
@@ -42,6 +43,8 @@
self._parent = parent
if parent:
self.WG = parent.WG
+ global LOGIC
+ LOGIC = self._parent.connectors['LogicServer']
global thisPath
thisPath = parent.scriptpath + '/logic_editor'
else:
@@ -121,10 +124,16 @@
self.send_header("Content-type", 'text/plain')
self.send_header("Access-Control-Allow-Origin", "*")
self.end_headers()
+ # FIXME: BIG, Big, big memory and CPU leak! A created Queue must be
+ # removed later, or the LogicServer will continue to fill it, even if
+ # no page will be listening anymore!
+ l = LOGIC.createQueue( None, None, None ) # get everything!
while True:
- self.wfile.write( "new line\n" )
+ #self.wfile.write( "new line\n" )
+ m = l.get()
+ self.wfile.write( "|%s|%s|%s|%s|\n" % m )
self.wfile.flush()
- time.sleep( 1.0 )
+ #time.sleep( 1.0 )
else:
self.path = "%s%s" % ( thisPath, self.path )
return SimpleHTTPServer.SimpleHTTPRequestHandler.do_GET(self)
Modified: PyWireGate/trunk/logic_server/LogicServer.py
===================================================================
--- PyWireGate/trunk/logic_server/LogicServer.py 2011-05-09 15:19:30 UTC (rev 324)
+++ PyWireGate/trunk/logic_server/LogicServer.py 2011-05-09 17:09:29 UTC (rev 325)
@@ -19,7 +19,7 @@
from connector import Connector
import LogicImportJSON
import TaskManager
-
+import Queue
import time
## Load logik.json
@@ -46,6 +46,7 @@
CONNECTOR_NAME = 'Logic Server'
CONNECTOR_VERSION = 0.1
CONNECTOR_LOGNAME = 'logic_server'
+ queues = []
def __init__(self,parent, instanceName):
self._parent = parent
self.WG = parent.WG
@@ -81,5 +82,14 @@
t.start()
while True:
for m in iter( t.getMessage, None ):
- print m
- time.sleep( 0.1 )
\ No newline at end of file
+ for q in self.queues:
+ if (q[0] == None or q[0] == m[0]) and (q[1] == None or q[1] == m[1]):
+ for b in m[2]:
+ if q[2] == None or q[2] == b:
+ q[3].put( (m[0], m[1], b, m[2][b]) )
+ time.sleep( 0.1 )
+
+ def createQueue(self, taskFilter, logicFilter, blockFilter):
+ q = Queue.Queue()
+ self.queues.append( (taskFilter, logicFilter, blockFilter, q) )
+ return q
\ 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: <ma...@us...> - 2011-05-09 15:19:36
|
Revision: 324
http://openautomation.svn.sourceforge.net/openautomation/?rev=324&view=rev
Author: makki1
Date: 2011-05-09 15:19:30 +0000 (Mon, 09 May 2011)
Log Message:
-----------
diagrams: Fix Grid timezone and add periods+datasource
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 2011-05-08 20:26:11 UTC (rev 323)
+++ CometVisu/trunk/visu/plugins/diagram/structure_plugin.js 2011-05-09 15:19:30 UTC (rev 324)
@@ -51,6 +51,8 @@
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", page.textContent);
diagram.data("refresh", $p.attr("refresh"));
@@ -63,7 +65,9 @@
width: {type: "string", required: false},
height: {type: "string", required: false},
unit: {type: "string", required: false},
- series: {type: "list", required: false, list: {day: "1 day", week: "1 week", month: "1 month", year: "1 year"}},
+ 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}
},
content: {type: "string", required: true}
@@ -99,6 +103,8 @@
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", page.textContent);
diagram.data("refresh", $p.attr("refresh"));
@@ -130,8 +136,9 @@
var x = item.datapoint[0],
y = item.datapoint[1].toFixed(2);
- var dte = new Date(x);
-
+ //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"));
}
@@ -161,7 +168,9 @@
attributes: {
rrd: {type: "string", required: true},
unit: {type: "string", required: false},
- series: {type: "list", required: false, list: {day: "1 day", week: "1 week", month: "1 month", year: "1 year"}},
+ 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"}},
},
@@ -190,12 +199,15 @@
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 series = {
- day: {label: "day", res: "300", start: "-1day", end: "now"},
- week: {label: "week", res: "1800", start: "-1week", end: "now"},
- month: {label: "month", res: "21600", start: "-1month", end: "now"},
- year: {label: "year", res: "432000", start: "-1year", end: "now"}
+ 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,
@@ -230,11 +242,16 @@
if (s) {
// init
$.ajax({
- url: "/cgi-bin/rrdfetch?rrd=" + rrd + ".rrd&ds=AVERAGE&start=end" + s.start + "&end=" + s.end + "&res=" + s.res,
+ 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 = diagramColors.data || 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;
+ }
$.plot(diagram, [{color: color, data: data}], options);
}
});
@@ -252,4 +269,5 @@
return false;
-}
\ 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: <ma...@us...> - 2011-05-08 20:26:17
|
Revision: 323
http://openautomation.svn.sourceforge.net/openautomation/?rev=323&view=rev
Author: mayerch
Date: 2011-05-08 20:26:11 +0000 (Sun, 08 May 2011)
Log Message:
-----------
Updated Logic Server to run the two sample snippets.
The output ("log") is currently still written to stdout, the routing to a live display in the Logic Editor is still missing
Modified Paths:
--------------
PyWireGate/trunk/logic_server/LogicImportJSON.py
PyWireGate/trunk/logic_server/LogicLibrary.py
PyWireGate/trunk/logic_server/LogicServer.py
PyWireGate/trunk/logic_server/TaskManager.py
Modified: PyWireGate/trunk/logic_server/LogicImportJSON.py
===================================================================
--- PyWireGate/trunk/logic_server/LogicImportJSON.py 2011-05-07 19:39:44 UTC (rev 322)
+++ PyWireGate/trunk/logic_server/LogicImportJSON.py 2011-05-08 20:26:11 UTC (rev 323)
@@ -43,34 +43,34 @@
# only afterwards
if block.hasState():
G.add_node( name + '.state' )
- for p in block.outPorts():
- if block.outPortNameHasState( p[0] ):
- stateupdate += " self.%s_%s = %s_%s_next\n" % ( name, p[0], name, p[0] )
+ for p in range(len(block.outPorts())):
+ if block.outPortNumberHasState( p ):
+ stateupdate += " self.%s_%s = %s_%s_next\n" % ( name, p, name, p )
for signal in loaddict['signals']:
b = loaddict['blocks']
- if lib[ loaddict['blocks'][ signal[0] ]['type'] ].outPortNameHasState( signal[1] ):
+ if lib[ loaddict['blocks'][ signal[0] ]['type'] ].outPortNumberHasState( signal[1] ):
G.add_edge( signal[0] + '.state', signal[2], { 'ports': ( signal[1], signal[3] ), 'start': signal[0] } )
else:
G.add_edge( signal[0], signal[2], { 'ports': ( signal[1], signal[3] ), 'start': signal[0] } )
-
+
intructionOrder = nx.topological_sort(G)
-
+
for instruction in intructionOrder:
if not instruction in loaddict['blocks']:
continue # ignore the virtual state nodes
libBlock = lib[ loaddict['blocks'][ instruction ]['type'] ]
ins = []
- for i in libBlock.inPorts():
+ for i in range(len(libBlock.inPorts())):
for e in G.in_edges_iter( instruction, True ):
if e[2]['ports'][1] == i:
- if lib[ loaddict['blocks'][ e[2]['start'] ]['type'] ].outPortNameHasState( e[2]['ports'][0] ):
+ if lib[ loaddict['blocks'][ e[2]['start'] ]['type'] ].outPortNumberHasState( e[2]['ports'][0] ):
ins.append( "self.%s_%s" % ( e[2]['start'], e[2]['ports'][0] ) )
else:
ins.append( "%s_%s" % ( e[2]['start'], e[2]['ports'][0] ) )
outs = []
- for o in libBlock.outPorts():
- outs.append( "%s_%s" % (instruction, o[0]) )
+ for o in range(len(libBlock.outPorts())):
+ outs.append( "%s_%s" % (instruction, o) )
params = []
for p in G.node[instruction]['parameters']:
paramName = "%s_%s" % (instruction, p)
@@ -90,10 +90,12 @@
%s
%s
def run( self, globalVariables ):
+ inspector = {}
__dt = globalVariables['__dt']
__time = globalVariables['__elapsedTime']
%s
%s
+ return inspector
""" % ( parameter, init, program, stateupdate )
if printCode:
Modified: PyWireGate/trunk/logic_server/LogicLibrary.py
===================================================================
--- PyWireGate/trunk/logic_server/LogicLibrary.py 2011-05-07 19:39:44 UTC (rev 322)
+++ PyWireGate/trunk/logic_server/LogicLibrary.py 2011-05-08 20:26:11 UTC (rev 323)
@@ -32,7 +32,8 @@
_outPorts = []
_parameters = []
_drawingInstructions = ""
- _codingInstructions = lambda s, n, i, o, p: ( None, "print __time,',','\"%%s\"' %% globalVariables['__name'],',','%s',',',%s" % ( n, i[0]) )
+ #_codingInstructions = lambda s, n, i, o, p: ( None, "print __time,',','\"%%s\"' %% globalVariables['__name'],',','%s',',',%s" % ( n, i[0]) )
+ _codingInstructions = lambda s, n, i, o, p: ( None, "inspector['%s'] = %s" % ( n, i[0]) )
class GainBlock( LogicModule.LogicModule ):
_name = "gain"
Modified: PyWireGate/trunk/logic_server/LogicServer.py
===================================================================
--- PyWireGate/trunk/logic_server/LogicServer.py 2011-05-07 19:39:44 UTC (rev 322)
+++ PyWireGate/trunk/logic_server/LogicServer.py 2011-05-08 20:26:11 UTC (rev 323)
@@ -66,17 +66,20 @@
def run(self):
# Load logik.json
- exec LogicImportJSON.get( self._parent.scriptpath + '/logik.json' )
+ exec LogicImportJSON.get( self._parent.scriptpath + '/logik.json', True )
self.Logik1 = LogikClass
# Load logik2.json - and show code and diagram
- exec LogicImportJSON.get( self._parent.scriptpath + '/logik2.json' )
+ exec LogicImportJSON.get( self._parent.scriptpath + '/logik2.json', True )
self.Logik2 = LogikClass
- cnt = 0
- while self.isrunning:
- if cnt == 60 and self.isrunning:
- self.statistics()
- if self.isrunning:
- cnt +=1
- self.idle(5)
+ t = TaskManager.TaskManager(self)
+ t.addInterval( 'Interval 1 - 75 ms Task', 0.075 )
+ t.addInterval( 'Interval 2 - 10 ms Task', 0.010 )
+ t.addTask( 'Interval 1 - 75 ms Task', 'Logik1', self.Logik1 )
+ t.addTask( 'Interval 2 - 10 ms Task', 'Logik2', self.Logik2 )
+ t.start()
+ while True:
+ for m in iter( t.getMessage, None ):
+ print m
+ time.sleep( 0.1 )
\ No newline at end of file
Modified: PyWireGate/trunk/logic_server/TaskManager.py
===================================================================
--- PyWireGate/trunk/logic_server/TaskManager.py 2011-05-07 19:39:44 UTC (rev 322)
+++ PyWireGate/trunk/logic_server/TaskManager.py 2011-05-08 20:26:11 UTC (rev 323)
@@ -17,7 +17,8 @@
## if not, see <http://www.gnu.de/documents/gpl-3.0.de.html>.
# A task manager that runs the little code snippets
-from multiprocessing import Process, Queue as mpQueue
+#from multiprocessing import Process, Queue as mpQueue
+import threading
import Queue
import time
@@ -25,26 +26,38 @@
"""The task manager that called all programs in the defined order at the
specified interval"""
taskList = {}
+ inspection = Queue.Queue()
+ def __init__( self, parent ):
+ self._parent = parent
+
def addInterval( self, name, interval ):
if name in self.taskList:
raise # Name already in interval list!
- q = mpQueue()
+ #q = mpQueue()
+ q = Queue.Queue()
self.taskList[name] = [ None, interval, q, [] ]
def addTask( self, interval, name, code ):
if interval in self.taskList:
- self.taskList[ interval ][3].append( code )
+ self.taskList[ interval ][3].append( [name, code] )
else:
raise # interval doesn't exist
+ def getMessage( self ):
+ try:
+ return self.inspection.get( False )
+ except Queue.Empty:
+ return
+
def start( self ):
# start the task handling
self.startTime = time.time() # only *nix is interesting here
for i in self.taskList:
interval = self.taskList[ i ][1]
q = self.taskList[ i ][2]
- self.taskList[ i ][0] = Process( target = self.aIntervall, args = ( i, interval, q, self.startTime ) )
+ #self.taskList[ i ][0] = Process( target = self.aIntervall, args = ( i, interval, q, self.startTime ) )
+ self.taskList[ i ][0] = threading.Thread( target = self.aIntervall, args = ( i, interval, q, self.inspection, self.startTime ) )
self.taskList[ i ][0].start()
def stop( self ):
@@ -53,7 +66,7 @@
self.taskList[ i ][2].put( 'STOP' )
self.taskList[ i ][0].join()
- def aIntervall( self, name, interval, q, startTime ):
+ def aIntervall( self, name, interval, q, inspection, startTime ):
globalVariables = {
'__name' : name,
'__interval' : interval,
@@ -63,20 +76,21 @@
}
# initialize the classes
for i in range( len( self.taskList[ name ][3] )):
- print i, self.taskList[ name ][3][i]
- self.taskList[ name ][3][i] = self.taskList[ name ][3][i]( globalVariables )
+ self.taskList[ name ][3][i][1] = self.taskList[ name ][3][i][1]( globalVariables )
# main loop
while 1:
__elapsedTime = time.time() - startTime
globalVariables['__dt'] = __elapsedTime - globalVariables['__elapsedTime']
globalVariables['__elapsedTime'] = __elapsedTime
+ #print 'XX', self.taskList[ name ][3]
for i in self.taskList[ name ][3]:
- i.run( globalVariables )
+ inspector = i[1].run( globalVariables )
+ inspection.put( (name, i[0], inspector) )
try:
message = q.get( True, interval )
except Queue.Empty:
continue # just start next iteration immediately
-
+
if 'STOP' == message:
break
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ma...@us...> - 2011-05-07 19:39:53
|
Revision: 322
http://openautomation.svn.sourceforge.net/openautomation/?rev=322&view=rev
Author: mayerch
Date: 2011-05-07 19:39:44 +0000 (Sat, 07 May 2011)
Log Message:
-----------
* Initial import of the logic server
* Update of the logic editor to use informations provided by the logic server
NOTE:
This is just an import of the current development version. It will NOT run (but it will also not affect the currently available other code of the PyWireGate)
Modified Paths:
--------------
PyWireGate/trunk/logic_editor/backendCommunication.js
PyWireGate/trunk/logic_editor/gle/gle.block.js
PyWireGate/trunk/logic_editor/gle/gle.connection.js
PyWireGate/trunk/logic_editor/logicEditor.js
Added Paths:
-----------
PyWireGate/trunk/logic_editor/LogicEditor.py
PyWireGate/trunk/logic_editor/__init__.py
PyWireGate/trunk/logic_server/
PyWireGate/trunk/logic_server/CodeClass.py
PyWireGate/trunk/logic_server/LogicImportJSON.py
PyWireGate/trunk/logic_server/LogicLibrary.py
PyWireGate/trunk/logic_server/LogicModule.py
PyWireGate/trunk/logic_server/LogicServer.py
PyWireGate/trunk/logic_server/TaskManager.py
PyWireGate/trunk/logic_server/__init__.py
PyWireGate/trunk/logic_server/test.py
PyWireGate/trunk/logik.json
PyWireGate/trunk/logik2.json
Added: PyWireGate/trunk/logic_editor/LogicEditor.py
===================================================================
--- PyWireGate/trunk/logic_editor/LogicEditor.py (rev 0)
+++ PyWireGate/trunk/logic_editor/LogicEditor.py 2011-05-07 19:39:44 UTC (rev 322)
@@ -0,0 +1,147 @@
+#!/usr/bin/env python
+# -*- coding: iso8859-1 -*-
+## -----------------------------------------------------
+## LogicEditor.py
+## -----------------------------------------------------
+## Copyright (c) 2011, Christian Mayer, All rights reserved.
+##
+## This program is free software; you can redistribute it and/or modify it under the terms
+## of the GNU General Public License as published by the Free Software Foundation; either
+## version 3 of the License, or (at your option) any later version.
+##
+## This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
+## without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+## See the GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License along with this program;
+## if not, see <http://www.gnu.de/documents/gpl-3.0.de.html>.
+
+
+from connector import ConnectorServer
+from StringIO import StringIO
+import shutil
+import BaseHTTPServer
+import SimpleHTTPServer
+import SocketServer
+import threading
+
+import re
+
+from logic_server import LogicLibrary
+
+# tmp:
+import time
+
+thisPath = '/'
+
+class logic_editor(ConnectorServer):
+ CONNECTOR_NAME = 'Logic Editor'
+ CONNECTOR_VERSION = 0.1
+ CONNECTOR_LOGNAME = 'logic_editor'
+ def __init__(self,parent, instanceName):
+ self._parent = parent
+ if parent:
+ self.WG = parent.WG
+ global thisPath
+ thisPath = parent.scriptpath + '/logic_editor'
+ else:
+ self.WG = False
+ self.instanceName = instanceName
+ defaultconfig = {
+ 'port' : 8080
+ }
+
+ self.WG.checkconfig(self.instanceName,defaultconfig)
+ config = self.WG.config[self.instanceName]
+ ConnectorServer.__init__(self,("0.0.0.0",config['port']),LERequestHandler )
+ self.start()
+
+
+class LERequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
+ def handle2(self):
+ data = self.request.recv(1024)
+ cur_thread = threading.currentThread()
+ response = "%s: %s: %s" % (self.server.WG.getname(),cur_thread.getName(), data)
+ self.request.send(response)
+
+ def log_message(self, format, *args):
+ self.server.log("%s - %s" %
+ (self.address_string(),
+ format%args))
+
+ def do_GET(self):
+ f = StringIO()
+ contentType="application/json"
+ if self.path.startswith("/config"):
+ contentType="text/plain"
+ f.write('{ \x22v\x22:\x220.0.1\x22, \x22s\x22:\x22SESSION\x22 }\n\n')
+ elif self.path.startswith("/logicLib"):
+ lib = LogicLibrary.LogicLibrary().getLibrary()
+ f.write( '{"MainLib":{' )
+ blockPrefix = ''
+ for blockName in lib:
+ f.write( '%s"%s":{"name":"%s",' % (blockPrefix, blockName, blockName) )
+ block = lib[ blockName ]
+
+ f.write( '"inPorts":[' )
+ prefix = ''
+ for inPort in block.inPorts():
+ f.write( '%s{"name":"%s","type":"signal"}' % (prefix, inPort) )
+ prefix = ','
+ f.write( '],' )
+
+ f.write( '"outPorts":[' )
+ prefix = ''
+ for outPort in block.outPorts():
+ portType = 'UNKNOWN'
+ if outPort[1] in ( 'const', 'signal', 'state' ):
+ portType = 'state'
+ f.write( '%s{"name":"%s","type":"%s"}' % (prefix, outPort[0], portType) )
+ prefix = ','
+ f.write( '],' )
+
+ f.write( '"parameters":[' )
+ prefix = ''
+ for parameter in block.parameters():
+ f.write( '%s{"name":"%s","type":"float","default":0.0}' % (prefix, parameter) )
+ prefix = ','
+ f.write( '],' )
+
+ f.write( '"width":100,"height":50,"rotation":0,"flip":false,"color":[0.0,0.0,0.0],"background":[1.0, 1.0, 1.0]' )
+
+ f.write( '}' )
+ blockPrefix = ','
+ f.write( '}}' )
+ elif self.path.startswith("/logicCode"):
+ contentType="text/plain"
+ self.path = self.path.replace('/logicCode', thisPath + '/..')
+ return SimpleHTTPServer.SimpleHTTPRequestHandler.do_GET(self)
+ elif self.path.startswith('/live'):
+ self.send_response(200)
+ self.send_header("Content-type", 'text/plain')
+ self.send_header("Access-Control-Allow-Origin", "*")
+ self.end_headers()
+ while True:
+ self.wfile.write( "new line\n" )
+ self.wfile.flush()
+ time.sleep( 1.0 )
+ else:
+ self.path = "%s%s" % ( thisPath, self.path )
+ return SimpleHTTPServer.SimpleHTTPRequestHandler.do_GET(self)
+
+ length = f.tell()
+ f.seek(0)
+ print "Length: "+str(length)
+ self.send_response(200)
+ self.send_header("Content-type", contentType)
+ self.send_header("Access-Control-Allow-Origin", "*")
+ self.send_header("Content-Length", str(length))
+ self.end_headers()
+ if f:
+ print "send"
+ self.copyfile(f, self.wfile)
+ f.close()
+
+ def copyfile(self, source, outputfile):
+ shutil.copyfileobj(source, outputfile)
+
\ No newline at end of file
Added: PyWireGate/trunk/logic_editor/__init__.py
===================================================================
--- PyWireGate/trunk/logic_editor/__init__.py (rev 0)
+++ PyWireGate/trunk/logic_editor/__init__.py 2011-05-07 19:39:44 UTC (rev 322)
@@ -0,0 +1 @@
+from LogicEditor import logic_editor
\ No newline at end of file
Modified: PyWireGate/trunk/logic_editor/backendCommunication.js
===================================================================
--- PyWireGate/trunk/logic_editor/backendCommunication.js 2011-05-07 09:29:04 UTC (rev 321)
+++ PyWireGate/trunk/logic_editor/backendCommunication.js 2011-05-07 19:39:44 UTC (rev 322)
@@ -1,5 +1,5 @@
// Sollte das Backend dynamisch aus den verfuegbaren Bloecken generieren:
- var libJSON = {
+ /*var libJSON = {
'sourceLib': {
'source1': {
'width': 100,
@@ -260,7 +260,21 @@
]
}
}
-};
+};*/
-// Die Struktur mit der feritgen Logik
-var logicJSON = {};
+var libJSON = {};
+$.getJSON('/logicLib', function(data) {
+ libJSON = data;
+ drawLibrary();
+});
+
+// The array with all known logics (should be filled on demand later)
+var logics = {};
+$.getJSON('/logicCode/logik.json', function(data) {
+ logics['logik'] = data;
+ updateKnownLogics('logik');
+});
+$.getJSON('/logicCode/logik2.json', function(data) {
+ logics['logik2'] = data;
+ updateKnownLogics('logik2');
+});
Modified: PyWireGate/trunk/logic_editor/gle/gle.block.js
===================================================================
--- PyWireGate/trunk/logic_editor/gle/gle.block.js 2011-05-07 09:29:04 UTC (rev 321)
+++ PyWireGate/trunk/logic_editor/gle/gle.block.js 2011-05-07 19:39:44 UTC (rev 322)
@@ -33,6 +33,7 @@
var outset = 3; // how far should the handle stick out
// setup the private variables
+ var name = type.name || 'UNKNOWN';
var x = type.x || 0;
var y = type.y || 0;
var width = type.width || 100;
@@ -199,6 +200,9 @@
{'dominant-baseline':'middle','text-anchor':'end'} );
});
+ // Draw the label
+ canvas.text( body, width/2, height+15, name, {'text-anchor':'middle'} );
+
// shotcut
function editorDrag( obj, handle )
{
Modified: PyWireGate/trunk/logic_editor/gle/gle.connection.js
===================================================================
--- PyWireGate/trunk/logic_editor/gle/gle.connection.js 2011-05-07 09:29:04 UTC (rev 321)
+++ PyWireGate/trunk/logic_editor/gle/gle.connection.js 2011-05-07 19:39:44 UTC (rev 322)
@@ -60,6 +60,7 @@
stroke: colorByArray( origin.getColor() ),
'stroke-width': 1,
'marker-end' : 'url(#ArrowEnd)',
+ 'z-index': 999,
fill: 'none'
};
@@ -318,5 +319,7 @@
paths : paths
};
}
+
+ draw(); // show directly after construction
}
Modified: PyWireGate/trunk/logic_editor/logicEditor.js
===================================================================
--- PyWireGate/trunk/logic_editor/logicEditor.js 2011-05-07 09:29:04 UTC (rev 321)
+++ PyWireGate/trunk/logic_editor/logicEditor.js 2011-05-07 19:39:44 UTC (rev 322)
@@ -37,10 +37,12 @@
south__closable : false,
south__resizable: false
});
- $('#structureTree').jstree({
- plugins : [ 'json_data', 'themes', 'types' ],
+ $('#structureTree').bind("select_node.jstree", function (event, data) {
+ displayLogic( $.trim( $(data.args[0]).text() ) );
+ }).jstree({
+ plugins : [ 'json_data', 'themes', 'types', 'ui' ],
json_data : {
- data : [
+ data : [/*
{
data : 'System 1',
attr : { rel : 'logic' },
@@ -65,7 +67,7 @@
title : 'System 2',
attr : { href : "#" }
}
- }
+ }*/
]
},
themes: {
@@ -77,7 +79,11 @@
types: {
logic : { icon: { image: 'icon/16/code-block.png' } },
subsystem: { icon: { image: 'icon/16/code-block.png' } }
- }
+ },
+ },
+ 'ui' : {
+ 'select_limit' : 1,
+ 'selected_parent_close' : 'select_parent'
}
});
@@ -129,10 +135,10 @@
$.each( libJSON, function( libName ){
var lib = $('<div class="lib"><div class="libName">'+libName+'</div></div>');
$.each( this, function( element ){
- var entry = $('<div class="libEntry"><div class="libEntryName">'+element+'</div></div>');
+ var entry = $('<div class="libEntry"></div>');
var obj = this;
var width = this.width+20;
- var height = this.height+20;
+ var height = this.height+35;
entry.prepend(
$('<div style="width:'+width+'px;height:'+height+'px;" ></div>').
svg({onLoad:function(svg){drawElement(svg,obj,false);},settings:{width:width,height:height,viewBox:'-10 -10 '+width+' '+height}}).
@@ -147,12 +153,47 @@
});
}
-var blockRegistry = [];
+function updateKnownLogics( newLogicName )
+{
+ $('#structureTree').jstree('create_node', -1, 'after', {
+ 'data' : newLogicName,
+ 'attr' : { rel : 'logic'}
+ });
+}
+function displayLogic( logicName )
+{
+ console.log( '"'+logicName+'"' );
+ logic = logics[ logicName ];
+ $.each( logic.blocks, function( name, def ){
+ var newBlock = $.extend( true, {}, libJSON['MainLib'][ def.type ], def, {'name':name} );
+ drawElement( undefined, newBlock, true );
+ });
+ console.log( blockRegistry );
+ $.each( logic.signals, function( name, def ){
+ console.log( name, def, blockRegistry[ def[0] ] );
+
+ var startBlock = blockRegistry[ def[0] ];
+ var endBlock = blockRegistry[ def[2] ];
+ var pn = def[1];
+ var op = startBlock.outPortPos( pn )[0];
+ var ip = endBlock.inPortPos( def[3] )[0];
+ var c = new Connection({
+ origin : startBlock,
+ originPortNumber: pn,
+ paths : [{path:[ [op.x, op.y], [ip.x, ip.y] ],target:endBlock}]
+ });
+ startBlock.setConnection( 'outPort', pn, c );
+ endBlock.setConnection( 'inPort', def[3], c );
+ });
+}
+
+var blockRegistry = {};
+
function drawElement( svg, element, addEvent ){
if( addEvent === undefined ) addEvent = true;
var b = new Block( element, svg, addEvent );
- if( addEvent ) blockRegistry.push( b );
+ if( addEvent ) blockRegistry[ element.name ] = b;
}
function colorByArray( a )
Added: PyWireGate/trunk/logic_server/CodeClass.py
===================================================================
--- PyWireGate/trunk/logic_server/CodeClass.py (rev 0)
+++ PyWireGate/trunk/logic_server/CodeClass.py 2011-05-07 19:39:44 UTC (rev 322)
@@ -0,0 +1,26 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+## -----------------------------------------------------
+## CodeClass.py
+## -----------------------------------------------------
+## Copyright (c) 2011, Christian Mayer, All rights reserved.
+##
+## This program is free software; you can redistribute it and/or modify it under the terms
+## of the GNU General Public License as published by the Free Software Foundation; either
+## version 3 of the License, or (at your option) any later version.
+##
+## This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
+## without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+## See the GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License along with this program;
+## if not, see <http://www.gnu.de/documents/gpl-3.0.de.html>.
+
+class CodeClass:
+ """The object that contains the code to run from the task manager and the
+ definied entry points for that"""
+ def getParameter( self, parameter ):
+ return getattr( self, parameter )
+
+ def setParameter( self, parameter, value ):
+ setattr( self, parameter, value )
\ No newline at end of file
Added: PyWireGate/trunk/logic_server/LogicImportJSON.py
===================================================================
--- PyWireGate/trunk/logic_server/LogicImportJSON.py (rev 0)
+++ PyWireGate/trunk/logic_server/LogicImportJSON.py 2011-05-07 19:39:44 UTC (rev 322)
@@ -0,0 +1,113 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+## -----------------------------------------------------
+## LogicImportJSON.py
+## -----------------------------------------------------
+## Copyright (c) 2011, Christian Mayer, All rights reserved.
+##
+## This program is free software; you can redistribute it and/or modify it under the terms
+## of the GNU General Public License as published by the Free Software Foundation; either
+## version 3 of the License, or (at your option) any later version.
+##
+## This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
+## without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+## See the GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License along with this program;
+## if not, see <http://www.gnu.de/documents/gpl-3.0.de.html>.
+
+import codecs
+import simplejson as json
+import networkx as nx
+import LogicLibrary
+
+def get( file, printCode = False, displayGraph = False ):
+ G=nx.DiGraph()
+ lib = LogicLibrary.LogicLibrary().getLibrary()
+
+ db = codecs.open( file, 'r', encoding = 'UTF-8' )
+ data = db.read()
+ loaddict = json.loads(data)
+ db.close()
+
+ parameter = '' # the string to set up the block parameters
+ init = '' # the string containing the inital setup
+ program = '' # the string containing the concatenated instructions
+ stateupdate = '' # the string containing the update of the states
+
+ for name, attribute in loaddict['blocks'].iteritems():
+ block = lib[ attribute['type'] ]
+ G.add_node( name, attribute )
+ # Add aditional, virtual node "<name>.state" that is treates as an additional
+ # input with no dependancy as the state won't change during an update cycle,
+ # only afterwards
+ if block.hasState():
+ G.add_node( name + '.state' )
+ for p in block.outPorts():
+ if block.outPortNameHasState( p[0] ):
+ stateupdate += " self.%s_%s = %s_%s_next\n" % ( name, p[0], name, p[0] )
+
+ for signal in loaddict['signals']:
+ b = loaddict['blocks']
+ if lib[ loaddict['blocks'][ signal[0] ]['type'] ].outPortNameHasState( signal[1] ):
+ G.add_edge( signal[0] + '.state', signal[2], { 'ports': ( signal[1], signal[3] ), 'start': signal[0] } )
+ else:
+ G.add_edge( signal[0], signal[2], { 'ports': ( signal[1], signal[3] ), 'start': signal[0] } )
+
+ intructionOrder = nx.topological_sort(G)
+
+ for instruction in intructionOrder:
+ if not instruction in loaddict['blocks']:
+ continue # ignore the virtual state nodes
+ libBlock = lib[ loaddict['blocks'][ instruction ]['type'] ]
+ ins = []
+ for i in libBlock.inPorts():
+ for e in G.in_edges_iter( instruction, True ):
+ if e[2]['ports'][1] == i:
+ if lib[ loaddict['blocks'][ e[2]['start'] ]['type'] ].outPortNameHasState( e[2]['ports'][0] ):
+ ins.append( "self.%s_%s" % ( e[2]['start'], e[2]['ports'][0] ) )
+ else:
+ ins.append( "%s_%s" % ( e[2]['start'], e[2]['ports'][0] ) )
+ outs = []
+ for o in libBlock.outPorts():
+ outs.append( "%s_%s" % (instruction, o[0]) )
+ params = []
+ for p in G.node[instruction]['parameters']:
+ paramName = "%s_%s" % (instruction, p)
+ paramValue = G.node[instruction]['parameters'][p]
+ if isinstance( paramValue, basestring):
+ paramValue = "globalVariables['%s']" % paramValue
+ parameter += " self.%s = %s\n" % (paramName, paramValue)
+ params.append( "self." + paramName )
+ i = libBlock.codingIntructions( instruction, ins, outs, params )
+ if None != i[0]:
+ init += " self.%s\n" % i[0]
+ program += " %s\n" % i[1]
+
+ code = """import CodeClass
+class LogikClass( CodeClass.CodeClass ):
+ def __init__( self, globalVariables ):
+%s
+%s
+ def run( self, globalVariables ):
+ __dt = globalVariables['__dt']
+ __time = globalVariables['__elapsedTime']
+%s
+%s
+""" % ( parameter, init, program, stateupdate )
+
+ if printCode:
+ print code
+
+ if displayGraph:
+ # just to show - connect the states
+ for name, attribute in loaddict['blocks'].iteritems():
+ block = lib[ attribute['type'] ]
+ if block.hasState():
+ G.add_edge( name, name + '.state' )
+ import matplotlib.pyplot as plt
+ nx.draw(G)
+ plt.show()
+
+ c = compile( code, '<string>', 'exec' )
+ return c
\ No newline at end of file
Added: PyWireGate/trunk/logic_server/LogicLibrary.py
===================================================================
--- PyWireGate/trunk/logic_server/LogicLibrary.py (rev 0)
+++ PyWireGate/trunk/logic_server/LogicLibrary.py 2011-05-07 19:39:44 UTC (rev 322)
@@ -0,0 +1,87 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+## -----------------------------------------------------
+## LogicLibrary.py
+## -----------------------------------------------------
+## Copyright (c) 2011, Christian Mayer, All rights reserved.
+##
+## This program is free software; you can redistribute it and/or modify it under the terms
+## of the GNU General Public License as published by the Free Software Foundation; either
+## version 3 of the License, or (at your option) any later version.
+##
+## This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
+## without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+## See the GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License along with this program;
+## if not, see <http://www.gnu.de/documents/gpl-3.0.de.html>.
+
+import LogicModule
+
+class ConstBlock( LogicModule.LogicModule ):
+ _name = "const"
+ _inPorts = []
+ _outPorts = [ ( 'out', 'const' ) ]
+ _parameters = [ 'value' ]
+ _drawingInstructions = ""
+ _codingInstructions = lambda s, n, i, o, p: ( "%s = %s" % ( o[0], p[0] ), "%s_next = %s" % ( o[0], p[0] ) )
+
+class LogBlock( LogicModule.LogicModule ):
+ _name = "log"
+ _inPorts = [ 'in' ]
+ _outPorts = []
+ _parameters = []
+ _drawingInstructions = ""
+ _codingInstructions = lambda s, n, i, o, p: ( None, "print __time,',','\"%%s\"' %% globalVariables['__name'],',','%s',',',%s" % ( n, i[0]) )
+
+class GainBlock( LogicModule.LogicModule ):
+ _name = "gain"
+ _inPorts = [ 'in' ]
+ _outPorts = [ ( 'out', 'signal' ) ]
+ _parameters = [ 'gain' ]
+ _drawingInstructions = ""
+ _codingInstructions = lambda s, n, i, o, p: ( None, "%s = %s * %s" % ( o[0], p[0], i[0] ) )
+
+class SumBlock( LogicModule.LogicModule ):
+ _name = "sum"
+ _inPorts = [ 'in1', 'in2' ]
+ _outPorts = [ ( 'out', 'signal' ) ]
+ _parameters = []
+ _drawingInstructions = ""
+ _codingInstructions = lambda s, n, i, o, p: ( None, "%s = %s + %s" % ( o[0], i[0], i[1] ) )
+
+class MemoryBlock( LogicModule.LogicModule ):
+ _name = "memory"
+ _inPorts = [ 'in' ]
+ _outPorts = [ ( 'out', 'state' ) ]
+ _parameters = [ 'inital_value' ]
+ _drawingInstructions = ""
+ _codingInstructions = lambda s, n, i, o, p: ( "%s = %s" % (o[0], p[0]), "%s_next = %s" % ( o[0], i[0] ) )
+
+class IntegralBlock( LogicModule.LogicModule ):
+ _name = "integral"
+ _inPorts = [ 'in' ]
+ _outPorts = [ ( 'out', 'state' ) ]
+ _parameters = [ 'initial_value' ]
+ _drawingInstructions = ""
+ _codingInstructions = lambda s, n, i, o, p: ( "%s = %s" % (o[0], p[0]), "%s_next = %s * %s + self.%s" % ( o[0], "__dt", i[0], o[0] ) )
+
+class LogicLibrary:
+ """The container for all known library blocks"""
+ _db = {}
+
+ def __init__( self ):
+ self.addBlock( ConstBlock )
+ self.addBlock( LogBlock )
+ self.addBlock( GainBlock )
+ self.addBlock( SumBlock )
+ self.addBlock( MemoryBlock )
+ self.addBlock( IntegralBlock )
+
+ def addBlock( self, block ):
+ b = block()
+ self._db[ b.name() ] = b
+
+ def getLibrary( self ):
+ return self._db
+
Added: PyWireGate/trunk/logic_server/LogicModule.py
===================================================================
--- PyWireGate/trunk/logic_server/LogicModule.py (rev 0)
+++ PyWireGate/trunk/logic_server/LogicModule.py 2011-05-07 19:39:44 UTC (rev 322)
@@ -0,0 +1,56 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+## -----------------------------------------------------
+## LogicModule.py
+## -----------------------------------------------------
+## Copyright (c) 2011, Christian Mayer, All rights reserved.
+##
+## This program is free software; you can redistribute it and/or modify it under the terms
+## of the GNU General Public License as published by the Free Software Foundation; either
+## version 3 of the License, or (at your option) any later version.
+##
+## This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
+## without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+## See the GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License along with this program;
+## if not, see <http://www.gnu.de/documents/gpl-3.0.de.html>.
+
+class LogicModule:
+ """The base class for a generic logic module"""
+ def name( self ):
+ return self._name
+
+ def inPorts( self ):
+ return self._inPorts
+
+ def outPorts( self ):
+ return self._outPorts
+
+ def parameters( self ):
+ return self._parameters
+
+ def drawingIntructions( self ):
+ return self._drawingInstructions
+
+ def codingIntructions( self, name, ins, outs, params ):
+ return self._codingInstructions( name, ins, outs, params )
+
+ def hasState( self ):
+ for port in self.outPorts():
+ if ('state' == port[1]) or ('const' == port[1]):
+ return True
+ return False
+
+ def outPortNumberHasState( self, i ):
+ portType = self.outPorts()[ i ][1]
+ if ('state' == portType) or ('const' == portType):
+ return True
+ return False
+
+ def outPortNameHasState( self, n ):
+ for port in self.outPorts():
+ if port[0] == n:
+ if ('state' == port[1]) or ('const' == port[1]):
+ return True
+ return False
Added: PyWireGate/trunk/logic_server/LogicServer.py
===================================================================
--- PyWireGate/trunk/logic_server/LogicServer.py (rev 0)
+++ PyWireGate/trunk/logic_server/LogicServer.py 2011-05-07 19:39:44 UTC (rev 322)
@@ -0,0 +1,82 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+## -----------------------------------------------------
+## LogicServer.py
+## -----------------------------------------------------
+## Copyright (c) 2011, Christian Mayer, All rights reserved.
+##
+## This program is free software; you can redistribute it and/or modify it under the terms
+## of the GNU General Public License as published by the Free Software Foundation; either
+## version 3 of the License, or (at your option) any later version.
+##
+## This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
+## without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+## See the GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License along with this program;
+## if not, see <http://www.gnu.de/documents/gpl-3.0.de.html>.
+
+from connector import Connector
+import LogicImportJSON
+import TaskManager
+
+import time
+
+## Load logik.json
+#exec LogicImportJSON.get( 'logik.json' )
+#Logik1 = LogikClass
+
+## Load logik2.json - and show code and diagram
+#exec LogicImportJSON.get( 'logik2.json' )
+#Logik2 = LogikClass
+
+#t = TaskManager.TaskManager()
+#t.addInterval( 'Interval 1 - 75 ms Task', 0.075 )
+#t.addInterval( 'Interval 2 - 10 ms Task', 0.01 )
+#t.addTask( 'Interval 1 - 75 ms Task', 'Logik1', Logik1 )
+#t.addTask( 'Interval 2 - 10 ms Task', 'Logik2', Logik2 )
+#for i in range(10):
+ #t.addInterval( 'i%s' % i, 6.0 )
+ #t.addTask( 'i%s' % i, 'foo', Logik1 )
+#t.start()
+#time.sleep(6.5)
+#t.stop()
+
+class logic_server(Connector):
+ CONNECTOR_NAME = 'Logic Server'
+ CONNECTOR_VERSION = 0.1
+ CONNECTOR_LOGNAME = 'logic_server'
+ def __init__(self,parent, instanceName):
+ self._parent = parent
+ self.WG = parent.WG
+ self.instanceName = instanceName
+
+ ## Deafaultconfig
+ defaultconfig = {
+ }
+
+ ## check Defaultconfig Options in main configfile
+ self.WG.checkconfig(self.instanceName,defaultconfig)
+
+ ## set local config
+ self.config = self.WG.config[self.instanceName]
+
+ ## Start the Thread
+ self.start()
+
+ def run(self):
+ # Load logik.json
+ exec LogicImportJSON.get( self._parent.scriptpath + '/logik.json' )
+ self.Logik1 = LogikClass
+
+ # Load logik2.json - and show code and diagram
+ exec LogicImportJSON.get( self._parent.scriptpath + '/logik2.json' )
+ self.Logik2 = LogikClass
+
+ cnt = 0
+ while self.isrunning:
+ if cnt == 60 and self.isrunning:
+ self.statistics()
+ if self.isrunning:
+ cnt +=1
+ self.idle(5)
Added: PyWireGate/trunk/logic_server/TaskManager.py
===================================================================
--- PyWireGate/trunk/logic_server/TaskManager.py (rev 0)
+++ PyWireGate/trunk/logic_server/TaskManager.py 2011-05-07 19:39:44 UTC (rev 322)
@@ -0,0 +1,85 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+## -----------------------------------------------------
+## TaskManager.py
+## -----------------------------------------------------
+## Copyright (c) 2011, Christian Mayer, All rights reserved.
+##
+## This program is free software; you can redistribute it and/or modify it under the terms
+## of the GNU General Public License as published by the Free Software Foundation; either
+## version 3 of the License, or (at your option) any later version.
+##
+## This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
+## without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+## See the GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License along with this program;
+## if not, see <http://www.gnu.de/documents/gpl-3.0.de.html>.
+
+# A task manager that runs the little code snippets
+from multiprocessing import Process, Queue as mpQueue
+import Queue
+import time
+
+class TaskManager:
+ """The task manager that called all programs in the defined order at the
+ specified interval"""
+ taskList = {}
+
+ def addInterval( self, name, interval ):
+ if name in self.taskList:
+ raise # Name already in interval list!
+ q = mpQueue()
+ self.taskList[name] = [ None, interval, q, [] ]
+
+ def addTask( self, interval, name, code ):
+ if interval in self.taskList:
+ self.taskList[ interval ][3].append( code )
+ else:
+ raise # interval doesn't exist
+
+ def start( self ):
+ # start the task handling
+ self.startTime = time.time() # only *nix is interesting here
+ for i in self.taskList:
+ interval = self.taskList[ i ][1]
+ q = self.taskList[ i ][2]
+ self.taskList[ i ][0] = Process( target = self.aIntervall, args = ( i, interval, q, self.startTime ) )
+ self.taskList[ i ][0].start()
+
+ def stop( self ):
+ # stop all tasks
+ for i in self.taskList:
+ self.taskList[ i ][2].put( 'STOP' )
+ self.taskList[ i ][0].join()
+
+ def aIntervall( self, name, interval, q, startTime ):
+ globalVariables = {
+ '__name' : name,
+ '__interval' : interval,
+ '__startTime' : startTime,
+ '__elapsedTime': 0.0,
+ '__dt' : interval
+ }
+ # initialize the classes
+ for i in range( len( self.taskList[ name ][3] )):
+ print i, self.taskList[ name ][3][i]
+ self.taskList[ name ][3][i] = self.taskList[ name ][3][i]( globalVariables )
+ # main loop
+ while 1:
+ __elapsedTime = time.time() - startTime
+ globalVariables['__dt'] = __elapsedTime - globalVariables['__elapsedTime']
+ globalVariables['__elapsedTime'] = __elapsedTime
+ for i in self.taskList[ name ][3]:
+ i.run( globalVariables )
+ try:
+ message = q.get( True, interval )
+ except Queue.Empty:
+ continue # just start next iteration immediately
+
+ if 'STOP' == message:
+ break
+
+ def showStatus( self ):
+ print self.taskList
+
\ No newline at end of file
Added: PyWireGate/trunk/logic_server/__init__.py
===================================================================
--- PyWireGate/trunk/logic_server/__init__.py (rev 0)
+++ PyWireGate/trunk/logic_server/__init__.py 2011-05-07 19:39:44 UTC (rev 322)
@@ -0,0 +1 @@
+from LogicServer import logic_server
\ No newline at end of file
Added: PyWireGate/trunk/logic_server/test.py
===================================================================
--- PyWireGate/trunk/logic_server/test.py (rev 0)
+++ PyWireGate/trunk/logic_server/test.py 2011-05-07 19:39:44 UTC (rev 322)
@@ -0,0 +1,26 @@
+#!/usr/bin/python
+import LogicImportJSON
+import TaskManager
+import LogicCommander
+
+import time
+
+# Load logik.json
+exec LogicImportJSON.get( 'logik.json' )
+Logik1 = LogikClass
+
+# Load logik2.json - and show code and diagram
+exec LogicImportJSON.get( 'logik2.json', True, True )
+Logik2 = LogikClass
+
+t = TaskManager.TaskManager()
+t.addInterval( 'Interval 1 - 75 ms Task', 0.075 )
+t.addInterval( 'Interval 2 - 10 ms Task', 0.01 )
+t.addTask( 'Interval 1 - 75 ms Task', 'Logik1', Logik1 )
+t.addTask( 'Interval 2 - 10 ms Task', 'Logik2', Logik2 )
+for i in range(10):
+ t.addInterval( 'i%s' % i, 6.0 )
+ t.addTask( 'i%s' % i, 'foo', Logik1 )
+t.start()
+time.sleep(6.5)
+t.stop()
Property changes on: PyWireGate/trunk/logic_server/test.py
___________________________________________________________________
Added: svn:executable
+ *
Added: PyWireGate/trunk/logik.json
===================================================================
--- PyWireGate/trunk/logik.json (rev 0)
+++ PyWireGate/trunk/logik.json 2011-05-07 19:39:44 UTC (rev 322)
@@ -0,0 +1,53 @@
+{
+ "blocks": {
+ "Const1": {
+ "type": "const",
+ "x": 50, "y": 50, "width": 50, "height": 50,
+ "parameters": { "value": 1.0 }
+ },
+ "Gain1": {
+ "type": "gain",
+ "x": 150, "y": 50, "width": 50, "height": 50,
+ "parameters": { "gain": 5.0 }
+ },
+ "Log1": {
+ "type": "log",
+ "x": 250, "y": 150, "width": 50, "height": 50,
+ "parameters": {}
+ },
+ "Log2": {
+ "type": "log",
+ "x": 250, "y": 50, "width": 50, "height": 50,
+ "parameters": {}
+ },
+ "Integral1": {
+ "type": "integral",
+ "x": 50, "y": 250, "width": 50, "height": 50,
+ "parameters": { "inital_value": 1.0 }
+ },
+ "Integral2": {
+ "type": "integral",
+ "x": 150, "y": 250, "width": 50, "height": 50,
+ "parameters": { "inital_value": 0.0 }
+ },
+ "Gain2": {
+ "type": "gain",
+ "x": 150, "y": 350, "width": 50, "height": 50,
+ "parameters": { "gain": -1.0 }
+ },
+ "Log3": {
+ "type": "log",
+ "x": 250, "y": 250, "width": 50, "height": 50,
+ "parameters": {}
+ }
+ },
+ "signals": [
+ [ "Const1" , 0, "Log1" , 0, {} ],
+ [ "Const1" , 0, "Gain1" , 0, {} ],
+ [ "Gain1" , 0, "Log2" , 0, {} ],
+ [ "Integral1", 0, "Integral2" , 0, {} ],
+ [ "Integral2", 0, "Gain2" , 0, {} ],
+ [ "Gain2" , 0, "Integral1" , 0, {} ],
+ [ "Integral2", 0, "Log3" , 0, {} ]
+ ]
+}
\ No newline at end of file
Added: PyWireGate/trunk/logik2.json
===================================================================
--- PyWireGate/trunk/logik2.json (rev 0)
+++ PyWireGate/trunk/logik2.json 2011-05-07 19:39:44 UTC (rev 322)
@@ -0,0 +1,43 @@
+{
+ "blocks": {
+ "Memory1": {
+ "type": "memory",
+ "x": 150, "y": 300, "width": 50, "height": 50,
+ "parameters": { "initial_value": 1.0 }
+ },
+ "Gain1": {
+ "type": "gain",
+ "x": 50, "y": 150, "width": 50, "height": 50,
+ "parameters": { "gain": "__dt" }
+ },
+ "Sum1": {
+ "type": "sum",
+ "x": 150, "y": 200, "width": 50, "height": 50,
+ "parameters": {}
+ },
+ "Log22": {
+ "type": "log",
+ "x": 350, "y": 300, "width": 50, "height": 50,
+ "parameters": {}
+ },
+ "Integral2": {
+ "type": "integral",
+ "x": 250, "y": 300, "width": 50, "height": 50,
+ "parameters": { "inital_value": 0.0 }
+ },
+ "Gain2": {
+ "type": "gain",
+ "x": 150, "y": 50, "width": 50, "height": 50,
+ "parameters": { "gain": -1.0 }
+ }
+ },
+ "signals": [
+ [ "Memory1" , 0, "Integral2" , 0, {} ],
+ [ "Gain1" , 0, "Sum1" , 0, {} ],
+ [ "Sum1" , 0, "Memory1" , 0, {} ],
+ [ "Memory1" , 0, "Sum1" , 1, {} ],
+ [ "Integral2", 0, "Gain2" , 0, {} ],
+ [ "Gain2" , 0, "Gain1" , 0, {} ],
+ [ "Integral2", 0, "Log22" , 0, {} ]
+ ]
+}
\ 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: <ma...@us...> - 2011-05-07 09:29:11
|
Revision: 321
http://openautomation.svn.sourceforge.net/openautomation/?rev=321&view=rev
Author: mayerch
Date: 2011-05-07 09:29:04 +0000 (Sat, 07 May 2011)
Log Message:
-----------
Fix KeyError exception when intance has no config, e.g. currently common for the scheduler
Modified Paths:
--------------
PyWireGate/trunk/WireGate.py
Modified: PyWireGate/trunk/WireGate.py
===================================================================
--- PyWireGate/trunk/WireGate.py 2011-05-06 21:12:20 UTC (rev 320)
+++ PyWireGate/trunk/WireGate.py 2011-05-07 09:29:04 UTC (rev 321)
@@ -229,8 +229,12 @@
## TODO: Check COnfig for seperate Logfiles and min level for logging
def createLog(self,instance):
- loglevel = self.config[instance].get('loglevel',False)
- filename = self.config[instance].get('logfile',False)
+ if instance in self.config:
+ loglevel = self.config[instance].get('loglevel',False)
+ filename = self.config[instance].get('logfile',False)
+ else:
+ loglevel = self.config['WireGate'].get('loglevel',False)
+ filename = self.config['WireGate'].get('logfile',False)
return self.__createLog(instance,filename=filename,maxlevel=loglevel)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ni...@us...> - 2011-05-06 21:12:26
|
Revision: 320
http://openautomation.svn.sourceforge.net/openautomation/?rev=320&view=rev
Author: nilss1
Date: 2011-05-06 21:12:20 +0000 (Fri, 06 May 2011)
Log Message:
-----------
check if parent is True else dont assign WG
Modified Paths:
--------------
PyWireGate/trunk/datastore.py
Modified: PyWireGate/trunk/datastore.py
===================================================================
--- PyWireGate/trunk/datastore.py 2011-04-27 16:17:31 UTC (rev 319)
+++ PyWireGate/trunk/datastore.py 2011-05-06 21:12:20 UTC (rev 320)
@@ -38,7 +38,8 @@
##
####################################################
self._parent = parent
- self.WG = parent.WG
+ if parent:
+ self.WG = parent.WG
self.log("DATASTORE starting up")
self.DBLOADED = False
self.dataobjects = {}
@@ -191,7 +192,8 @@
class dataObject(object):
def __init__(self,parent,id,name=False):
self._parent = parent
- self.WG = parent.WG
+ if parent:
+ self.WG = parent.WG
## Threadlocking
self.write_mutex = threading.RLock()
self.read_mutex = threading.RLock()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ma...@us...> - 2011-04-27 16:17:37
|
Revision: 319
http://openautomation.svn.sourceforge.net/openautomation/?rev=319&view=rev
Author: mayerch
Date: 2011-04-27 16:17:31 +0000 (Wed, 27 Apr 2011)
Log Message:
-----------
Updated info about the new switch widget feature
Modified Paths:
--------------
CometVisu/trunk/ChangeLog
Modified: CometVisu/trunk/ChangeLog
===================================================================
--- CometVisu/trunk/ChangeLog 2011-04-27 16:15:16 UTC (rev 318)
+++ CometVisu/trunk/ChangeLog 2011-04-27 16:17:31 UTC (rev 319)
@@ -2,6 +2,7 @@
====
- New Feature: Multitrigger widget
+- New Feature: The switch widget can send arbitrary values now
0.5.3
=====
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ma...@us...> - 2011-04-27 16:15:22
|
Revision: 318
http://openautomation.svn.sourceforge.net/openautomation/?rev=318&view=rev
Author: mayerch
Date: 2011-04-27 16:15:16 +0000 (Wed, 27 Apr 2011)
Log Message:
-----------
Created optional parameters for the switch to set the values for on and off
Modified Paths:
--------------
CometVisu/trunk/visu/designs/structure_pure.js
Modified: CometVisu/trunk/visu/designs/structure_pure.js
===================================================================
--- CometVisu/trunk/visu/designs/structure_pure.js 2011-03-08 21:29:06 UTC (rev 317)
+++ CometVisu/trunk/visu/designs/structure_pure.js 2011-04-27 16:15:16 UTC (rev 318)
@@ -296,6 +296,8 @@
'address' : address,
'mapping' : $p.attr('mapping'),
'styling' : $p.attr('styling'),
+ 'on_value' : $p.attr('on_value' ) || 1,
+ 'off_value' : $p.attr('off_value') || 0,
'type' : 'switch'
} ).bind( 'click', this.action );
for( var addr in address ) $actor.bind( addr, this.update );
@@ -305,18 +307,21 @@
update: function(e,d) {
var element = $(this);
var value = defaultUpdate( e, d, element );
- element.removeClass( value == 0 ? 'switchPressed' : 'switchUnpressed' );
- element.addClass( value == 0 ? 'switchUnpressed' : 'switchPressed' );
+ var off = element.data( 'off_value' );
+ element.removeClass( value == off ? 'switchPressed' : 'switchUnpressed' );
+ element.addClass( value == off ? 'switchUnpressed' : 'switchPressed' );
},
action: function() {
var data = $(this).data();
for( var addr in data.address )
{
if( data.address[addr][1] == true ) continue; // skip read only
- visu.write( addr.substr(1), transformEncode( data.address[addr][0], data.value == 0 ) );
+ visu.write( addr.substr(1), transformEncode( data.address[addr][0], data.value == data.off_value ? data.on_value : data.off_value ) );
}
},
attributes: {
+ on_value: { type: 'string' , required: false },
+ off_value: { type: 'string' , required: false },
pre: { type: 'string' , required: false },
post: { type: 'string' , required: false },
mapping: { type: 'mapping' , required: false },
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ma...@us...> - 2011-03-08 21:29:12
|
Revision: 317
http://openautomation.svn.sourceforge.net/openautomation/?rev=317&view=rev
Author: mayerch
Date: 2011-03-08 21:29:06 +0000 (Tue, 08 Mar 2011)
Log Message:
-----------
Fix the demo colorchooser call
Modified Paths:
--------------
CometVisu/trunk/visu/visu_config_demo.xml
Modified: CometVisu/trunk/visu/visu_config_demo.xml
===================================================================
--- CometVisu/trunk/visu/visu_config_demo.xml 2011-03-08 21:13:18 UTC (rev 316)
+++ CometVisu/trunk/visu/visu_config_demo.xml 2011-03-08 21:29:06 UTC (rev 317)
@@ -237,9 +237,9 @@
</page>
<colorchooser>
A colorChooser
- 1/2/59
- 1/2/60
- 1/2/61
+ <address transform="DPT:5.001" color="r">1/2/59</address>
+ <address transform="DPT:5.001" color="g">1/2/60</address>
+ <address transform="DPT:5.001" color="b">1/2/61</address>
</colorchooser>
<break/>
<info format="%.2f">
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ma...@us...> - 2011-03-08 21:13:24
|
Revision: 316
http://openautomation.svn.sourceforge.net/openautomation/?rev=316&view=rev
Author: mayerch
Date: 2011-03-08 21:13:18 +0000 (Tue, 08 Mar 2011)
Log Message:
-----------
Bug fix for the broken styling feature
Modified Paths:
--------------
CometVisu/trunk/visu/designs/structure_pure.js
Modified: CometVisu/trunk/visu/designs/structure_pure.js
===================================================================
--- CometVisu/trunk/visu/designs/structure_pure.js 2011-03-06 20:46:46 UTC (rev 315)
+++ CometVisu/trunk/visu/designs/structure_pure.js 2011-03-08 21:13:18 UTC (rev 316)
@@ -761,25 +761,6 @@
var element = passedElement || $(this);
var thisTransform = element.data().address[ e.type ][0];
var value = transformDecode( element.data().address[ e.type ][0], data );
- if( element.data( 'precision' ) )
- value = Number( value ).toPrecision( element.data( 'precision' ) );
- if( element.data( 'format' ) )
- value = sprintf( element.data( 'format' ), value );
- element.data( 'value', value );
- value = map( value, element );
- if( value.constructor == Date )
- {
- switch( thisTransform ) // special case for KNX
- {
- case 'DPT:10.001':
- value = value.toLocaleTimeString();
- break;
- case 'DPT:11.001':
- value = value.toLocaleDateString();
- break;
- }
- }
- element.find('.value').text( value );
var styling = element.data('styling');
if( styling && stylings[styling] && (stylings[styling][value] || stylings[styling]['range']) )
@@ -803,5 +784,26 @@
if( not_found ) element.addClass( 'actor' );
}
}
+
+ if( element.data( 'precision' ) )
+ value = Number( value ).toPrecision( element.data( 'precision' ) );
+ if( element.data( 'format' ) )
+ value = sprintf( element.data( 'format' ), value );
+ element.data( 'value', value );
+ value = map( value, element );
+ if( value.constructor == Date )
+ {
+ switch( thisTransform ) // special case for KNX
+ {
+ case 'DPT:10.001':
+ value = value.toLocaleTimeString();
+ break;
+ case 'DPT:11.001':
+ value = value.toLocaleDateString();
+ break;
+ }
+ }
+ element.find('.value').text( value );
+
return value;
}
\ 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: <ma...@us...> - 2011-03-06 20:46:52
|
Revision: 315
http://openautomation.svn.sourceforge.net/openautomation/?rev=315&view=rev
Author: mayerch
Date: 2011-03-06 20:46:46 +0000 (Sun, 06 Mar 2011)
Log Message:
-----------
Move diagram a bit to the right to avoid overlaping tick labels (at least till a new Flot version fixes that)
Cf. bug ID 3175343
Modified Paths:
--------------
CometVisu/trunk/visu/designs/discreet/basic.css
CometVisu/trunk/visu/designs/pure/basic.css
Modified: CometVisu/trunk/visu/designs/discreet/basic.css
===================================================================
--- CometVisu/trunk/visu/designs/discreet/basic.css 2011-03-06 12:09:26 UTC (rev 314)
+++ CometVisu/trunk/visu/designs/discreet/basic.css 2011-03-06 20:46:46 UTC (rev 315)
@@ -353,6 +353,7 @@
}
.diagram_inline {
+ margin-left: 1em;
width: 320px;
height: 180px;
}
Modified: CometVisu/trunk/visu/designs/pure/basic.css
===================================================================
--- CometVisu/trunk/visu/designs/pure/basic.css 2011-03-06 12:09:26 UTC (rev 314)
+++ CometVisu/trunk/visu/designs/pure/basic.css 2011-03-06 20:46:46 UTC (rev 315)
@@ -313,6 +313,10 @@
cursor: pointer;
}
+.diagram_inline {
+ margin-left: 1em;
+}
+
#diagramTooltip {
z-index: 1000;
color: black;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ma...@us...> - 2011-03-06 12:09:32
|
Revision: 314
http://openautomation.svn.sourceforge.net/openautomation/?rev=314&view=rev
Author: mayerch
Date: 2011-03-06 12:09:26 +0000 (Sun, 06 Mar 2011)
Log Message:
-----------
New Feature: added a watchdog that makes sure that the connection stays fresh
This handles e.g. a browser on a system that goes to sleep and wakes up later. Or bad networks.
Modified Paths:
--------------
CometVisu/trunk/visu/lib/cometvisu-client.js
Modified: CometVisu/trunk/visu/lib/cometvisu-client.js
===================================================================
--- CometVisu/trunk/visu/lib/cometvisu-client.js 2011-03-05 14:44:58 UTC (rev 313)
+++ CometVisu/trunk/visu/lib/cometvisu-client.js 2011-03-06 12:09:26 UTC (rev 314)
@@ -20,6 +20,7 @@
*/
function CometVisu( urlPrefix )
{
+ var thisCometVisu = this;
this.urlPrefix = (null == urlPrefix) ? '' : urlPrefix; // the address of the service
this.addresses = []; // the subscribed addresses
this.filters = []; // the subscribed filters
@@ -28,6 +29,8 @@
this.device = ''; // the current device ID
this.running = false; // is the communication running at the moment?
this.xhr = false; // the ongoing AJAX request
+ this.watchdogTimer = 5; // in Seconds - the alive check intervall of the watchdog
+ this.maxConnectionAge = 60; // in Seconds - restart if last read is older
/**
* This function gets called once the communication is established and session information is available
@@ -55,6 +58,7 @@
if( this.running )
{ // retry initial request
this.xhr = $.ajax( {url:this.urlPrefix + 'r',dataType: 'json',context:this,data:this.buildRequest()+'&t=0', success:this.handleRead ,error:this.handleError/*,complete:this.handleComplete*/ } );
+ watchdog.ping();
}
return;
}
@@ -66,6 +70,7 @@
if( this.running )
{ // keep the requests going
this.xhr = $.ajax( {url:this.urlPrefix + 'r',dataType: 'json',context:this,data:this.buildRequest()+'&i='+lastIndex, success:this.handleRead ,error:this.handleError/*,complete:this.handleComplete*/ } );
+ watchdog.ping();
}
};
@@ -149,6 +154,34 @@
var request = 'a=' + address + '&v=' + value;
$.ajax( {url:this.urlPrefix + 'w',dataType: 'json',context:this,data:request} );
}
+
+ /**
+ * Restart the read request, e.g. when the watchdog kicks in
+ */
+ this.restart = function()
+ {
+ if( this.xhr.abort ) this.xhr.abort();
+ this.handleRead(); // restart
+ }
+
+ /**
+ * The watchdog to recreate a read request when it stopped somehow
+ */
+ var watchdog = (function(){
+ var last = new Date();
+ var aliveCheckFunction = function(){
+ var now = new Date();
+ if( now - last < thisCometVisu.maxConnectionAge * 1000 ) return;
+ thisCometVisu.restart();
+ last = now;
+ };
+ var aliveHandler = setInterval( aliveCheckFunction, thisCometVisu.watchdogTimer * 1000 );
+ return {
+ ping: function(){
+ last = new Date();
+ }
+ };
+ })();
};
CometVisu.prototype.update = function( json ) {}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ma...@us...> - 2011-03-05 14:45:04
|
Revision: 313
http://openautomation.svn.sourceforge.net/openautomation/?rev=313&view=rev
Author: mayerch
Date: 2011-03-05 14:44:58 +0000 (Sat, 05 Mar 2011)
Log Message:
-----------
New Feature: automatically set the range of a slider to the possible range of it's addresses datatype.
This will e.g. set the slider range for a integer value to 0..255 instead of the default 0..100.
Modified Paths:
--------------
CometVisu/trunk/visu/designs/structure_pure.js
CometVisu/trunk/visu/transforms/transform_knx.js
Modified: CometVisu/trunk/visu/designs/structure_pure.js
===================================================================
--- CometVisu/trunk/visu/designs/structure_pure.js 2011-03-05 11:52:31 UTC (rev 312)
+++ CometVisu/trunk/visu/designs/structure_pure.js 2011-03-05 14:44:58 UTC (rev 313)
@@ -172,16 +172,25 @@
var labelElement = $p.find('label')[0];
var label = labelElement ? '<div class="label">' + labelElement.textContent + '</div>' : '';
var address = {};
+ var datatype_min = undefined;
+ var datatype_max = undefined;
$p.find('address').each( function(){
var src = this.textContent;
var transform = this.getAttribute('transform');
var readonly = this.getAttribute('readonly');
ga_list.push( src )
address[ '_' + src ] = [ transform, readonly=='true' ];
+ if( Transform[ transform ] && Transform[ transform ].range )
+ {
+ if( !( datatype_min > Transform[ transform ].range.min ) )
+ datatype_min = Transform[ transform ].range.min;
+ if( !( datatype_max < Transform[ transform ].range.max ) )
+ datatype_max = Transform[ transform ].range.max;
+ }
});
var actor = $('<div class="actor">');
- var min = parseFloat( $p.attr('min') || 0 );
- var max = parseFloat( $p.attr('max') || 100 );
+ var min = parseFloat( $p.attr('min') || datatype_min || 0 );
+ var max = parseFloat( $p.attr('max') || datatype_max || 100 );
var step = parseFloat( $p.attr('step') || 0.5 );
var $actor = $(actor).data({
'events': $(actor).data( 'events' ),
Modified: CometVisu/trunk/visu/transforms/transform_knx.js
===================================================================
--- CometVisu/trunk/visu/transforms/transform_knx.js 2011-03-05 11:52:31 UTC (rev 312)
+++ CometVisu/trunk/visu/transforms/transform_knx.js 2011-03-05 14:44:58 UTC (rev 313)
@@ -59,6 +59,10 @@
'5.001' : {
name : 'DPT_Scaling',
unit : '%',
+ range : {
+ min: 0.0,
+ max: 100.0
+ },
encode: function( phy ){
var val = parseInt( phy * 255 / 100 ).toString( 16 );
return (val.length == 1 ? '800' : '80') + val;
@@ -70,6 +74,10 @@
'5.003' : {
name : 'DPT_Angle',
unit : '°',
+ range : {
+ min: 0.0,
+ max: 360.0
+ },
encode: function( phy ){
var val = parseInt( phy * 255 / 360 ).toString( 16 );
return (val.length == 1 ? '800' : '80') + val;
@@ -81,6 +89,10 @@
'5.004' : {
name : 'DPT_Percent_U8',
unit : '%',
+ range : {
+ min: 0.0,
+ max: 255.0
+ },
encode: function( phy ){
var val = parseInt( phy ).toString( 16 );
return (val.length == 1 ? '800' : '80') + val;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ma...@us...> - 2011-03-05 11:52:37
|
Revision: 312
http://openautomation.svn.sourceforge.net/openautomation/?rev=312&view=rev
Author: mayerch
Date: 2011-03-05 11:52:31 +0000 (Sat, 05 Mar 2011)
Log Message:
-----------
Added demo page to demonstrate the use of the format string
Modified Paths:
--------------
CometVisu/trunk/visu/visu_config_demo.xml
Modified: CometVisu/trunk/visu/visu_config_demo.xml
===================================================================
--- CometVisu/trunk/visu/visu_config_demo.xml 2011-03-04 20:58:14 UTC (rev 311)
+++ CometVisu/trunk/visu/visu_config_demo.xml 2011-03-05 11:52:31 UTC (rev 312)
@@ -169,6 +169,72 @@
</page>
</page>
</page>
+ <page name="Format Test" align="center">
+ <text>
+ Über das Format-Attribut kann die Anzeige von Werten variiert werden.
+ Dazu wird die Synatx des vom "printf" bekannten Formatstrings benutzt.
+ </text>
+ <break/>
+ <slide min="-100" max="101">
+ <label>Test-Slider</label>
+ <address transform="DPT:9">14/4/4</address>
+ </slide>
+ <info>
+ <label>Ohne Format</label>
+ <address transform="DPT:9">14/4/4</address>
+ </info>
+ <line/>
+ <info format="%.0f">
+ <label>Format "%.0f":</label>
+ <address transform="DPT:9">14/4/4</address>
+ </info>
+ <info format="%.1f">
+ <label>Format "%.1f":</label>
+ <address transform="DPT:9">14/4/4</address>
+ </info>
+ <info format="%.2f">
+ <label>Format "%.2f":</label>
+ <address transform="DPT:9">14/4/4</address>
+ </info>
+ <info format="%.3f">
+ <label>Format "%.3f":</label>
+ <address transform="DPT:9">14/4/4</address>
+ </info>
+ <info format="%.4f">
+ <label>Format "%.4f":</label>
+ <address transform="DPT:9">14/4/4</address>
+ </info>
+ <line/>
+ <info format="%01.2f">
+ <label>Format "%01.2f":</label>
+ <address transform="DPT:9">14/4/4</address>
+ </info>
+ <info format="%02.2f">
+ <label>Format "%02.2f":</label>
+ <address transform="DPT:9">14/4/4</address>
+ </info>
+ <info format="%03.2f">
+ <label>Format "%03.3f":</label>
+ <address transform="DPT:9">14/4/4</address>
+ </info>
+ <info format="%04.2f">
+ <label>Format "%04.3f":</label>
+ <address transform="DPT:9">14/4/4</address>
+ </info>
+ <info format="%05.2f">
+ <label>Format "%05.2f":</label>
+ <address transform="DPT:9">14/4/4</address>
+ </info>
+ <info format="%06.2f">
+ <label>Format "%06.2f":</label>
+ <address transform="DPT:9">14/4/4</address>
+ </info>
+ <line/>
+ <info format="%+.2f">
+ <label>Format "%+.2f":</label>
+ <address transform="DPT:9">14/4/4</address>
+ </info>
+ </page>
<colorchooser>
A colorChooser
1/2/59
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ma...@us...> - 2011-03-04 20:58:20
|
Revision: 311
http://openautomation.svn.sourceforge.net/openautomation/?rev=311&view=rev
Author: mayerch
Date: 2011-03-04 20:58:14 +0000 (Fri, 04 Mar 2011)
Log Message:
-----------
Tweak for Android
Modified Paths:
--------------
CometVisu/trunk/visu/plugins/diagram/structure_plugin.js
CometVisu/trunk/visu/transforms/transform_knx.js
Modified: CometVisu/trunk/visu/plugins/diagram/structure_plugin.js
===================================================================
--- CometVisu/trunk/visu/plugins/diagram/structure_plugin.js 2011-02-27 21:26:29 UTC (rev 310)
+++ CometVisu/trunk/visu/plugins/diagram/structure_plugin.js 2011-03-04 20:58:14 UTC (rev 311)
@@ -163,7 +163,7 @@
unit: {type: "string", required: false},
series: {type: "list", required: false, list: {day: "1 day", week: "1 week", month: "1 month", year: "1 year"}},
refresh: {type: "numeric", required: false},
- tooltip: {type: "list", required: false, list: {true: "yes", false: "no"}},
+ tooltip: {type: "list", required: false, list: {'true': "yes", 'false': "no"}},
},
content: {type: "string", required: true}
});
Modified: CometVisu/trunk/visu/transforms/transform_knx.js
===================================================================
--- CometVisu/trunk/visu/transforms/transform_knx.js 2011-02-27 21:26:29 UTC (rev 310)
+++ CometVisu/trunk/visu/transforms/transform_knx.js 2011-03-04 20:58:14 UTC (rev 311)
@@ -267,7 +267,7 @@
},
unit : '-',
range : {
- enum: [ 'auto', 'comfort', 'standby', 'economy', 'building_protection' ]
+ 'enum': [ 'auto', 'comfort', 'standby', 'economy', 'building_protection' ]
},
encode: function( phy ){
var val;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ma...@us...> - 2011-02-27 21:26:36
|
Revision: 310
http://openautomation.svn.sourceforge.net/openautomation/?rev=310&view=rev
Author: mayerch
Date: 2011-02-27 21:26:29 +0000 (Sun, 27 Feb 2011)
Log Message:
-----------
Clean up and unify the tranform
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 2011-02-27 21:00:50 UTC (rev 309)
+++ CometVisu/trunk/visu/designs/structure_pure.js 2011-02-27 21:26:29 UTC (rev 310)
@@ -207,7 +207,7 @@
},
update: function( e, data ) {
var element = $(this);
- var value = Transform[ element.data().address[ e.type ][0] ].decode( data );
+ var value = transformDecode( element.data().address[ e.type ][0], data );
if( element.data( 'value' ) != value )
{
element.data( 'value', value );
@@ -227,8 +227,8 @@
for( var addr in data.address )
{
if( data.address[addr][1] == true ) continue; // skip read only
- var dv = Transform[data.address[addr][0]].encode( asv );
- if( dv != Transform[data.address[addr][0]].encode( data.value ) )
+ var dv = transformEncode( data.address[addr][0], asv );
+ if( dv != transformEncode( data.address[addr][0], data.value ) )
visu.write( addr.substr(1), dv );
}
data.value = actor.slider('value');
@@ -245,8 +245,8 @@
for( var addr in data.address )
{
if( data.address[addr][1] == true ) continue; // skip read only
- var uv = Transform[data.address[addr][0]].encode( ui.value );
- if( uv != Transform[data.address[addr][0]].encode( data.value ) )
+ var uv = transformEncode( data.address[addr][0], ui.value );
+ if( uv != transformEncode( data.address[addr][0], data.value ) )
visu.write( addr.substr(1), uv );
}
},
@@ -304,7 +304,7 @@
for( var addr in data.address )
{
if( data.address[addr][1] == true ) continue; // skip read only
- visu.write( addr.substr(1), Transform[data.address[addr][0]].encode( data.value == 0 ) );
+ visu.write( addr.substr(1), transformEncode( data.address[addr][0], data.value == 0 ) );
}
},
attributes: {
@@ -406,10 +406,7 @@
for( var addr in data.address )
{
if( data.address[addr][1] == true ) continue; // skip read only
- var a = visu.write;
- var b = addr.substr(1);
- var c = Transform[data.address[addr][0]].encode( data.value );
- visu.write( addr.substr(1), Transform[data.address[addr][0]].encode( data.value ) );
+ visu.write( addr.substr(1), transformEncode( data.address[addr][0], data.value ) );
}
},
attributes: {
@@ -470,7 +467,7 @@
for( var addr in data.address )
{
if( data.address[addr][1] == true ) continue; // skip read only
- visu.write( addr.substr(1), Transform[data.address[addr][0]].encode( data.sendValue ) );
+ visu.write( addr.substr(1), transformEncode( data.address[addr][0], data.sendValue ) );
}
},
attributes: {
@@ -754,9 +751,7 @@
{
var element = passedElement || $(this);
var thisTransform = element.data().address[ e.type ][0];
- var value = thisTransform in Transform ?
- Transform[ element.data().address[ e.type ][0] ].decode( data ) :
- data; // fall back - no Transform defined...
+ var value = transformDecode( element.data().address[ e.type ][0], data );
if( element.data( 'precision' ) )
value = Number( value ).toPrecision( element.data( 'precision' ) );
if( element.data( 'format' ) )
Modified: CometVisu/trunk/visu/lib/templateengine.js
===================================================================
--- CometVisu/trunk/visu/lib/templateengine.js 2011-02-27 21:00:50 UTC (rev 309)
+++ CometVisu/trunk/visu/lib/templateengine.js 2011-02-27 21:26:29 UTC (rev 310)
@@ -85,6 +85,20 @@
visu.stop();
});
+function transformEncode( transformation, value )
+{
+ return transformation in Transform ?
+ Transform[ transformation ].encode( value ) :
+ value;
+}
+
+function transformDecode( transformation, value )
+{
+ return transformation in Transform ?
+ Transform[ transformation ].decode( value ) :
+ value;
+}
+
function map( value, element )
{
var map = element.data('mapping');
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ma...@us...> - 2011-02-27 21:00:57
|
Revision: 309
http://openautomation.svn.sourceforge.net/openautomation/?rev=309&view=rev
Author: mayerch
Date: 2011-02-27 21:00:50 +0000 (Sun, 27 Feb 2011)
Log Message:
-----------
2 new transforms: DPT:10.001 and DPT:11.001 for KNX time and date
Note: only the decoding, the encoding is currently missing
Modified Paths:
--------------
CometVisu/trunk/visu/designs/structure_pure.js
CometVisu/trunk/visu/transforms/transform_knx.js
Modified: CometVisu/trunk/visu/designs/structure_pure.js
===================================================================
--- CometVisu/trunk/visu/designs/structure_pure.js 2011-02-27 17:39:50 UTC (rev 308)
+++ CometVisu/trunk/visu/designs/structure_pure.js 2011-02-27 21:00:50 UTC (rev 309)
@@ -762,7 +762,20 @@
if( element.data( 'format' ) )
value = sprintf( element.data( 'format' ), value );
element.data( 'value', value );
- element.find('.value').text( map( value, element ) );
+ value = map( value, element );
+ if( value.constructor == Date )
+ {
+ switch( thisTransform ) // special case for KNX
+ {
+ case 'DPT:10.001':
+ value = value.toLocaleTimeString();
+ break;
+ case 'DPT:11.001':
+ value = value.toLocaleDateString();
+ break;
+ }
+ }
+ element.find('.value').text( value );
var styling = element.data('styling');
if( styling && stylings[styling] && (stylings[styling][value] || stylings[styling]['range']) )
Modified: CometVisu/trunk/visu/transforms/transform_knx.js
===================================================================
--- CometVisu/trunk/visu/transforms/transform_knx.js 2011-02-27 17:39:50 UTC (rev 308)
+++ CometVisu/trunk/visu/transforms/transform_knx.js 2011-02-27 21:00:50 UTC (rev 309)
@@ -174,6 +174,41 @@
link : '9.001'
},
+ '10.001' : {
+ name : 'DPT_TimeOfDay',
+ encode: function( phy ){
+ // FIXME
+ },
+ decode: function( hex ){
+ var date = new Date(); // assume today
+ date.setHours ( parseInt(hex.substr(0,2),16) & 0x1F );
+ date.setMinutes( parseInt(hex.substr(2,2),16) );
+ date.setSeconds( parseInt(hex.substr(4,2),16) );
+ // as KNX thinks the day of the week belongs to the time, but JavaScript
+ // doesn't, tweak the date till it fits...
+ var day = (parseInt(hex.substr(0,2),16) & 0xE0) >> 5;
+ if( day > 0 )
+ {
+ var dayShift = (day - date.getDay()) % 7;
+ date.setDate( date.getDate() + dayShift );
+ }
+ return date;
+ }
+ },
+
+ '11.001' : {
+ name : 'DPT_Date',
+ encode: function( phy ){
+ // FIXME
+ },
+ decode: function( hex ){
+ var year = parseInt(hex.substr(4,2),16) & 0x7F;
+ return new Date(year < 90 ? year+2000 : year+1900, //1990 - 2089
+ (parseInt(hex.substr(2,2),16) & 0x0F) - 1,
+ parseInt(hex.substr(0,2),16) & 0x1F);
+ }
+ },
+
'12.001' : {
name : 'DPT_Value_4_Ucount',
encode: function( phy ){
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ma...@us...> - 2011-02-27 17:39:56
|
Revision: 308
http://openautomation.svn.sourceforge.net/openautomation/?rev=308&view=rev
Author: mayerch
Date: 2011-02-27 17:39:50 +0000 (Sun, 27 Feb 2011)
Log Message:
-----------
New Feature: The CometVisu can be called with an additional parameter in the URL. If "startpage" is set to a valid page ID, this subpage will immediately show up
Hint: The page ID can easily be figured out when you move the mouse over the page link and look where this link will lead to as it has the form "javascript:scrollToPage('<page ID>')"
Modified Paths:
--------------
CometVisu/trunk/visu/lib/templateengine.js
Modified: CometVisu/trunk/visu/lib/templateengine.js
===================================================================
--- CometVisu/trunk/visu/lib/templateengine.js 2011-02-27 17:17:00 UTC (rev 307)
+++ CometVisu/trunk/visu/lib/templateengine.js 2011-02-27 17:39:50 UTC (rev 308)
@@ -243,6 +243,10 @@
// setup the scrollable
main_scroll = $('#main').scrollable({keyboard: false, touch: false}).data('scrollable');
main_scroll.onSeek( updateTopNavigation );
+
+ if ($.getUrlVar('startpage')) {
+ scrollToPage( $.getUrlVar('startpage'), 0 );
+ }
$('.fast').bind('click', function(){
main_scroll.seekTo( $(this).text() );
@@ -292,10 +296,10 @@
return retval;
}
-function scrollToPage( page_id )
+function scrollToPage( page_id, speed )
{
$('#'+page_id).css( 'display', '' ); // show new page
- main_scroll.seekTo( $('.page').index( $('#'+page_id)[0] ) ); // scroll to it
+ main_scroll.seekTo( $('.page').index( $('#'+page_id)[0] ), speed ); // scroll to it
}
function updateTopNavigation()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ma...@us...> - 2011-02-27 17:17:07
|
Revision: 307
http://openautomation.svn.sourceforge.net/openautomation/?rev=307&view=rev
Author: mayerch
Date: 2011-02-27 17:17:00 +0000 (Sun, 27 Feb 2011)
Log Message:
-----------
New Feature: flavours for pages
Modified Paths:
--------------
CometVisu/trunk/visu/designs/pure/basic.css
CometVisu/trunk/visu/designs/structure_pure.js
CometVisu/trunk/visu/lib/templateengine.js
CometVisu/trunk/visu/visu_config_demo.xml
Modified: CometVisu/trunk/visu/designs/pure/basic.css
===================================================================
--- CometVisu/trunk/visu/designs/pure/basic.css 2011-02-27 15:58:17 UTC (rev 306)
+++ CometVisu/trunk/visu/designs/pure/basic.css 2011-02-27 17:17:00 UTC (rev 307)
@@ -320,4 +320,74 @@
padding: 2px;
background-color: #fee;
opacity: 0.80;
-}
\ No newline at end of file
+}
+
+/*****************************************************************************/
+/* The definition of the flavours - overwrite the generic settings */
+/*****************************************************************************/
+
+.flavour_black hr
+{
+ background-color: #000000;
+}
+
+.flavour_black .link a
+{
+ color: #000000;
+}
+
+.flavour_white hr
+{
+ background-color: #ffffff;
+}
+.flavour_white .link a
+{
+ color: #ffffff;
+}
+
+.flavour_antimony hr
+{
+ background-color: #00ddff;
+}
+
+.flavour_antimony .link a
+{
+ color: #00ddff;
+}
+
+.flavour_boron hr
+{
+ background-color: #00ff11;
+}
+.flavour_boron .link a
+{
+ color: #00ff11;
+}
+
+.flavour_lithium hr
+{
+ background-color: #ff0000;
+}
+.flavour_lithium .link a
+{
+ color: #ff0000;
+}
+
+.flavour_potassium hr
+{
+ background-color: #d00055;
+}
+.flavour_potassium .link a
+{
+ color: #d00055;
+}
+
+.flavour_sodium hr
+{
+ background-color: #ff8000;
+}
+.flavour_sodium .link a
+{
+ color: #ff8000;
+}
+
Modified: CometVisu/trunk/visu/designs/structure_pure.js
===================================================================
--- CometVisu/trunk/visu/designs/structure_pure.js 2011-02-27 15:58:17 UTC (rev 306)
+++ CometVisu/trunk/visu/designs/structure_pure.js 2011-02-27 17:17:00 UTC (rev 307)
@@ -51,13 +51,13 @@
* XML config file tags
*/
this.addCreator('page', {
- create: function( page, path ) {
+ create: function( page, path, flavour ) {
var $p = $(page);
var ret_val = $('<div class="widget" />');
var pstyle = ( '0' != path ) ? 'display:none;' : ''; // subPage style
var name = $p.attr('name');
var type = $p.attr('type'); //text, 2d or 3d
- var flavour = $p.attr('flavour'); // sub design choice
+ if( $p.attr('flavour') ) flavour = $p.attr('flavour');// sub design choice
var wstyle = ''; // widget style
if( $p.attr('align') ) wstyle += 'text-align:' + $p.attr('align') + ';';
if( wstyle != '' ) wstyle = 'style="' + wstyle + '"';
@@ -67,9 +67,12 @@
var container = $( '<div class="clearfix"/>' );
container.append( '<h1>' + name + '</h1>' );
$( childs ).each( function(i){
- container.append( create_pages(childs[i], path + '_' + i ) );
+ container.append( create_pages( childs[i], path + '_' + i, flavour ) );
} );
- $('#pages').prepend( $( '<div class="page" id="' + path + '" style="'+pstyle+';"/>' ).append(container) );
+ var subpage = $( '<div class="page" id="' + path + '" style="'+pstyle+';"/>' );
+ subpage.append(container);
+ if( flavour ) subpage.addClass( 'flavour_' + flavour );
+ $('#pages').prepend( subpage );
return ret_val;
},
attributes: {
Modified: CometVisu/trunk/visu/lib/templateengine.js
===================================================================
--- CometVisu/trunk/visu/lib/templateengine.js 2011-02-27 15:58:17 UTC (rev 306)
+++ CometVisu/trunk/visu/lib/templateengine.js 2011-02-27 17:17:00 UTC (rev 307)
@@ -252,10 +252,10 @@
$("#pages").triggerHandler("done");
}
-function create_pages( page, path ) {
+function create_pages( page, path, flavour ) {
var creator = design.getCreator(page.nodeName);
- var retval = creator.create(page, path);
+ var retval = creator.create(page, path, flavour);
node = $(page).get(0);
var attributes = {};
Modified: CometVisu/trunk/visu/visu_config_demo.xml
===================================================================
--- CometVisu/trunk/visu/visu_config_demo.xml 2011-02-27 15:58:17 UTC (rev 306)
+++ CometVisu/trunk/visu/visu_config_demo.xml 2011-02-27 17:17:00 UTC (rev 307)
@@ -19,6 +19,13 @@
<entry value="0">Null</entry>
<entry range_min="0" range_max="1e99">Positiv</entry>
</mapping>
+ <mapping name="KonnexHVAC">
+ <entry value="auto">Auto</entry>
+ <entry value="comfort">Komfort</entry>
+ <entry value="standby">Stand By</entry>
+ <entry value="economy">Economy</entry>
+ <entry value="building_protection">Haus-Schutz</entry>
+ </mapping>
</mappings>
<stylings>
<styling name="RedGreen">
@@ -86,6 +93,10 @@
<label>KONNEX Betriebsart</label>
<address transform="DPT:20.102" readonly="false" type="">3/1/50</address>
</multitrigger>
+ <info mapping="KonnexHVAC">
+ <label>Betriebsart</label>
+ <address transform="DPT:20.102" type="">3/1/50</address>
+ </info>
<line/>
<image src="icon/comet_128_ff8000.png" width="500px" height="46px"/>
<image src="http://www.e-zeeinternet.com/count.php?page=546016&style=default&nbdigits=9&reloads=1" refresh="10">
@@ -95,12 +106,76 @@
<page name="iframe Test" align="center" >
<iframe src="http://www.cometvisu.org" width="500px" height="500px"/>
</page>
+ <page name="Flavour Test" align="center" >
+ <text>The flavours define a page specific look for a choosen design.
+ The CometVisu's pure design was inspired by the colors that a comet out of
+ that material would shine in.
+ </text>
+ <page name="Flavour: Antimony" align="center" flavour="antimony">
+ <text align="center">CometVisu Antimony flavour</text>
+ <line/>
+ <page name="Subpage">
+ <text>An empty page</text>
+ <line/>
+ </page>
+ </page>
+ <page name="Flavour: Boron" align="center" flavour="boron">
+ <text align="center">CometVisu Boron flavour</text>
+ <line/>
+ <page name="Subpage">
+ <text>An empty page</text>
+ <line/>
+ </page>
+ </page>
+ <page name="Flavour: Lithium" align="center" flavour="lithium">
+ <text align="center">CometVisu Lithium flavour</text>
+ <line/>
+ <page name="Subpage">
+ <text>An empty page</text>
+ <line/>
+ </page>
+ </page>
+ <page name="Flavour: Potassium" align="center" flavour="potassium">
+ <text align="center">CometVisu Potassium flavour</text>
+ <line/>
+ <page name="Subpage">
+ <text>An empty page</text>
+ <line/>
+ </page>
+ </page>
+ <page name="Flavour: Sodium" align="center" flavour="sodium">
+ <text align="center">CometVisu Sodium flavour</text>
+ <line/>
+ <page name="Subpage">
+ <text>An empty page</text>
+ <line/>
+ </page>
+ </page>
+ <line />
+ <page name="Flavour: black" align="center" flavour="black">
+ <text align="center">CometVisu black flavour</text>
+ <line/>
+ <page name="Subpage">
+ <text>An empty page</text>
+ <line/>
+ </page>
+ </page>
+ <page name="Flavour: white" align="center" flavour="white">
+ <text align="center">CometVisu white flavour</text>
+ <line/>
+ <page name="Subpage">
+ <text>An empty page</text>
+ <line/>
+ </page>
+ </page>
+ </page>
<colorchooser>
A colorChooser
1/2/59
1/2/60
1/2/61
</colorchooser>
+ <break/>
<info format="%.2f">
<label>R</label>
<address transform="DPT:5.001" type="">1/2/59</address>
@@ -127,6 +202,5 @@
</slide>
<diagram_popup rrd="200_DALI_Linie_1_Strom" unit="mA" series="day" refresh="300">DALI Strom L1</diagram_popup>
<diagram_inline rrd="200_DALI_Linie_1_Strom" width="600" height="400"/>
- <designtoggle/>
</page>
</pages>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ma...@us...> - 2011-02-27 15:58:23
|
Revision: 306
http://openautomation.svn.sourceforge.net/openautomation/?rev=306&view=rev
Author: mayerch
Date: 2011-02-27 15:58:17 +0000 (Sun, 27 Feb 2011)
Log Message:
-----------
- Fix that made the editor place new widgets on a wrong (sub)page
- Inital support for page flavours
Modified Paths:
--------------
CometVisu/trunk/visu/designs/structure_pure.js
Modified: CometVisu/trunk/visu/designs/structure_pure.js
===================================================================
--- CometVisu/trunk/visu/designs/structure_pure.js 2011-02-27 12:54:42 UTC (rev 305)
+++ CometVisu/trunk/visu/designs/structure_pure.js 2011-02-27 15:58:17 UTC (rev 306)
@@ -54,26 +54,28 @@
create: function( page, path ) {
var $p = $(page);
var ret_val = $('<div class="widget" />');
- var style = ( '0' != path ) ? 'display:none' : '';
- var name = $p.attr('name');
- var type = $p.attr('type'); //text, 2d or 3d
- var style = '';
- if( $p.attr('align') ) style += 'text-align:' + $p.attr('align') + ';';
- if( style != '' ) style = 'style="' + style + '"';
+ var pstyle = ( '0' != path ) ? 'display:none;' : ''; // subPage style
+ var name = $p.attr('name');
+ var type = $p.attr('type'); //text, 2d or 3d
+ var flavour = $p.attr('flavour'); // sub design choice
+ var wstyle = ''; // widget style
+ if( $p.attr('align') ) wstyle += 'text-align:' + $p.attr('align') + ';';
+ if( wstyle != '' ) wstyle = 'style="' + wstyle + '"';
ret_val.addClass( 'link' ).addClass('pagelink');
- ret_val.append( '<div ' + style + '><a href="javascript:scrollToPage(\''+path+'\')">' + name + '</a></div>' );
+ ret_val.append( '<div ' + wstyle + '><a href="javascript:scrollToPage(\''+path+'\')">' + name + '</a></div>' );
var childs = $p.children();
var container = $( '<div class="clearfix"/>' );
container.append( '<h1>' + name + '</h1>' );
$( childs ).each( function(i){
container.append( create_pages(childs[i], path + '_' + i ) );
} );
- $('#pages').prepend( $( '<div class="page" id="' + path + '" style="'+style+';"/>' ).append(container) );
+ $('#pages').prepend( $( '<div class="page" id="' + path + '" style="'+pstyle+';"/>' ).append(container) );
return ret_val;
},
attributes: {
- align:{ type: 'string', required: false },
- name: { type: 'string', required: true }
+ align: { type: 'string', required: false },
+ flavour:{ type: 'string', 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.
|