--- a/svgui/svgui_server.py Mon Aug 14 22:30:41 2017 +0300
+++ b/svgui/svgui_server.py Mon Aug 14 23:27:15 2017 +0300
@@ -32,11 +32,14 @@
svguiWidgets = {}
currentId = 0
+
+
def getNewId():
global currentId
currentId += 1
return currentId
+
class SvguiWidget:
def __init__(self, classname, id, **kwargs):
@@ -83,6 +86,7 @@
if self.changed:
self.RefreshInterface()
+
def get_object_init_state(obj):
# Convert objects to a dictionary of their representation
attrs = obj.attrs.copy()
@@ -93,6 +97,7 @@
}
return d
+
def get_object_current_state(obj):
# Convert objects to a dictionary of their representation
d = { '__class__': obj.classname,
@@ -101,6 +106,7 @@
}
return d
+
class SVGUI_HMI(website.PLCHMI):
jsClass = u"LiveSVGPage.LiveSVGWidget"
@@ -123,6 +129,7 @@
def setattr(self, id, attrname, value):
svguiWidgets[id].setinput(attrname, value)
+
def createSVGUIControl(*args, **kwargs):
id = getNewId()
gad = SvguiWidget(args[0], id, **kwargs)
@@ -133,16 +140,19 @@
interface.callRemote('init', gadget)
return id
+
def setAttr(id, attrname, value):
gad = svguiWidgets.get(id, None)
if gad is not None:
gad.setoutput(attrname, value)
+
def updateAttr(id, **kwargs):
gad = svguiWidgets.get(id, None)
if gad is not None:
gad.updateoutput(**kwargs)
+
def getAttr(id, attrname, default=None):
gad = svguiWidgets.get(id, None)
if gad is not None: