|
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.
|