Adding support for twisted website HMI
authorlaurent
Wed, 12 Aug 2009 11:40:26 +0200
changeset 369 bd54d41a7573
parent 368 86ecd8374dae
child 370 ee802ef00ca5
Adding support for twisted website HMI
Beremiz_service.py
webinterface.js
--- a/Beremiz_service.py	Mon Aug 10 14:42:54 2009 +0200
+++ b/Beremiz_service.py	Wed Aug 12 11:40:26 2009 +0200
@@ -549,7 +549,7 @@
         def HMIexec(self, function, *args, **kwargs):
             if self.HMI is not None:
                 getattr(self.HMI, function, lambda:None)(*args, **kwargs)
-        athena.expose(executeOnHMI)
+        athena.expose(HMIexec)
         
         def resetHMI(self):
             self.HMI = None
@@ -564,8 +564,8 @@
                 f = self.PLCStartedHMIClass()
             else:
                 f = PLCStoppedHMI()
+            f.setFragmentParent(self)
             self.HMI = f
-            f.setFragmentParent(self)
             return f
         athena.expose(getPLCElement)
 
@@ -593,10 +593,10 @@
         def getHMI(self):
             return self.MainPage.getHMI()
         
-        def LoadHMI(self, plc, jsmodules):
+        def LoadHMI(self, hmi, jsmodules):
             for name, path in jsmodules.iteritems():
                 self.jsModules.mapping[name] = os.path.join(WorkingDir, path)
-            self.MainPage.setPLCStarted(plc)
+            self.MainPage.setPLCStartedHMI(hmi)
         
         def UnLoadHMI(self):
             self.MainPage.resetPLCStartedHMI()
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/webinterface.js	Wed Aug 12 11:40:26 2009 +0200
@@ -0,0 +1,17 @@
+// import Nevow.Athena
+
+WebInterface.PLC = Nevow.Athena.Widget.subclass('WebInterface.PLC');
+WebInterface.PLC.method(
+	 'updateHMI',
+	 function (self, data) {
+	   d = self.callRemote('getPLCElement');
+	   d.addCallback(
+			 function liveElementReceived(le) {
+				d2 = self.addChildWidgetFromWidgetInfo(le);
+				d2.addCallback(
+						function childAdded(widget) {
+						var node = self.nodeById('content');
+						node.replaceChild(widget.node, node.getElementsByTagName('div')[0]);
+						});
+				});
+	   });
\ No newline at end of file