--- a/PLCControler.py Sat Feb 17 23:58:47 2018 +0100
+++ b/PLCControler.py Sun Feb 18 21:30:48 2018 +0100
@@ -38,6 +38,8 @@
import util.paths as paths
from util.TranslationCatalogs import NoTranslate
+from plcopen.types_enums import * +from plcopen.XSLTModelQuery import _StringValue, _BoolValue, _translate_args from plcopen.InstancesPathCollector import InstancesPathCollector
from plcopen.POUVariablesCollector import POUVariablesCollector
from graphics.GraphicCommons import *
@@ -45,77 +47,8 @@
duration_model = re.compile("(?:([0-9]{1,2})h)?(?:([0-9]{1,2})m(?!s))?(?:([0-9]{1,2})s)?(?:([0-9]{1,3}(?:\.[0-9]*)?)ms)?")
- "Local": ("localVars", ITEM_VAR_LOCAL),
- "Global": ("globalVars", ITEM_VAR_GLOBAL),
- "External": ("externalVars", ITEM_VAR_EXTERNAL),
- "Temp": ("tempVars", ITEM_VAR_TEMP),
- "Input": ("inputVars", ITEM_VAR_INPUT),
- "Output": ("outputVars", ITEM_VAR_OUTPUT),
- "InOut": ("inOutVars", ITEM_VAR_INOUT)}
- "program": ITEM_PROGRAM,
- "functionBlock": ITEM_FUNCTIONBLOCK,
- "function": ITEM_FUNCTION,
-LOCATIONS_ITEMS = [LOCATION_CONFNODE,
- LOCATION_VAR_MEMORY] = range(6)
ScriptDirectory = paths.AbsDir(__file__)
-def GetUneditableNames():
- return [_("User-defined POUs"), _("Functions"), _("Function Blocks"),
- _("Programs"), _("Data Types"), _("Transitions"), _("Actions"),
- _("Configurations"), _("Resources"), _("Properties")]
-UNEDITABLE_NAMES = GetUneditableNames()
-[USER_DEFINED_POUS, FUNCTIONS, FUNCTION_BLOCKS, PROGRAMS,
- DATA_TYPES, TRANSITIONS, ACTIONS, CONFIGURATIONS,
- RESOURCES, PROPERTIES] = UNEDITABLE_NAMES
class LibraryResolver(etree.Resolver):
"""Helper object for loading library in xslt stylesheets"""
@@ -138,24 +71,6 @@
lib_el.append(deepcopy(ctn["types"]))
return self.resolve_string(etree.tostring(lib_el), context)
-# -------------------------------------------------------------------------------
-# Helpers functions for translating list of arguments
-# from xslt to valid arguments
-# -------------------------------------------------------------------------------
- return x in ["true", "0"]
-def _translate_args(translations, args):
- return [translate(arg[0]) if len(arg) > 0 else None
- zip(translations, args)]
# -------------------------------------------------------------------------------
# Helpers object for generating pou var list
--- a/plcopen/POUVariablesCollector.py Sat Feb 17 23:58:47 2018 +0100
+++ b/plcopen/POUVariablesCollector.py Sun Feb 18 21:30:48 2018 +0100
@@ -4,15 +4,11 @@
# See COPYING file for copyrights details.
from __future__ import absolute_import
-from plcopen.XSLTModelQuery import XSLTModelQuery
+from plcopen.XSLTModelQuery import XSLTModelQuery, _StringValue, _BoolValue, _translate_args +from plcopen.types_enums import CLASS_TYPES, POU_TYPES, VAR_CLASS_INFOS def class_extraction(value):
- "configuration": ITEM_CONFIGURATION,
- "resource": ITEM_RESOURCE,
- "transition": ITEM_TRANSITION,
- "program": ITEM_PROGRAM}.get(value)
+ class_type = CLASS_TYPES.get(value) if class_type is not None:
--- a/plcopen/XSLTModelQuery.py Sat Feb 17 23:58:47 2018 +0100
+++ b/plcopen/XSLTModelQuery.py Sun Feb 18 21:30:48 2018 +0100
@@ -11,6 +11,7 @@
ScriptDirectory = paths.AbsDir(__file__)
class XSLTModelQuery(object):
""" a class to handle XSLT queries on project and libs """
def __init__(self, controller, xsltpath, ext = []):
@@ -39,3 +40,24 @@
res = self.xslt(root,**{k:etree.XSLT.strparam(v) for k,v in kwargs.iteritems()})
# print(self.xslt.error_log)
+# ------------------------------------------------------------------------------- +# Helpers functions for translating list of arguments +# from xslt to valid arguments +# ------------------------------------------------------------------------------- + return x in ["true", "0"] +def _translate_args(translations, args): + return [translate(arg[0]) if len(arg) > 0 else None + zip(translations, args)] --- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/plcopen/types_enums.py Sun Feb 18 21:30:48 2018 +0100
@@ -0,0 +1,82 @@
+# This file is part of Beremiz +# See COPYING file for copyrights details. +from __future__ import absolute_import +from util.TranslationCatalogs import NoTranslate + "Local": ("localVars", ITEM_VAR_LOCAL), + "Global": ("globalVars", ITEM_VAR_GLOBAL), + "External": ("externalVars", ITEM_VAR_EXTERNAL), + "Temp": ("tempVars", ITEM_VAR_TEMP), + "Input": ("inputVars", ITEM_VAR_INPUT), + "Output": ("outputVars", ITEM_VAR_OUTPUT), + "InOut": ("inOutVars", ITEM_VAR_INOUT)} + "program": ITEM_PROGRAM, + "functionBlock": ITEM_FUNCTIONBLOCK, + "function": ITEM_FUNCTION, + "configuration": ITEM_CONFIGURATION, + "resource": ITEM_RESOURCE, + "transition": ITEM_TRANSITION, + "program": ITEM_PROGRAM +LOCATIONS_ITEMS = [LOCATION_CONFNODE, + LOCATION_VAR_MEMORY] = range(6) +UNEDITABLE_NAMES = [_("User-defined POUs"), _("Functions"), _("Function Blocks"), + _("Programs"), _("Data Types"), _("Transitions"), _("Actions"), + _("Configurations"), _("Resources"), _("Properties")] +[USER_DEFINED_POUS, FUNCTIONS, FUNCTION_BLOCKS, PROGRAMS, + DATA_TYPES, TRANSITIONS, ACTIONS, CONFIGURATIONS, + RESOURCES, PROPERTIES] = UNEDITABLE_NAMES +# remove gettext override