runtime/webinterface.js
author Andrey Skvortsov <andrej.skvortzov@gmail.com>
Thu, 07 Jun 2018 13:45:35 +0300
changeset 2173 976841968d74
parent 719 db54ccc96309
permissions -rw-r--r--
Add retain basic implementation on GNU/Linux

Retain is saved in file and backup of this file is done every time.
File isn't saved on every PLC cycle to avoid high I/O load.
By default, retain is saved every second and on PLC stop/shutdown.
It's possible to override retain flush period by using CFLAGS option
in project's settings. For example, for 0.5 seconds period
use "-DFILE_RETAIN_SAVE_PERIOD_S=0.5".
// import Nevow.Athena

function init() {
  Nevow.Athena.Widget.fromAthenaID(1).callRemote('HMIexec', 'HMIinitialisation');
}

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]);
						init();
						});
				});
	   });

Divmod.Base.addLoadEvent(init);