plcopen/types_enums.py
author Andrey Skvortsov <andrej.skvortzov@gmail.com>
Fri, 10 Aug 2018 17:45:33 +0300
changeset 2278 a3ac46366b86
parent 1953 5736d25bb393
child 2524 c80b0d864475
permissions -rw-r--r--
Dirty fix for error '_object_has_no_attribute_'getSlave' in EtherCAT extension

traceback:
File "/home/developer/WorkData/PLC/beremiz/beremiz/IDEFrame.py", line 1433, in OnPouSelectedChanged
window.RefreshView()
File "/home/developer/WorkData/PLC/beremiz/beremiz/etherlab/ConfigEditor.py", line 837, in RefreshView
self.RefreshProcessVariables()
File "/home/developer/WorkData/PLC/beremiz/beremiz/etherlab/ConfigEditor.py", line 886, in RefreshProcessVariables
slaves = self.Controler.GetSlaves(**self.CurrentNodesFilter)
File "/home/developer/WorkData/PLC/beremiz/beremiz/etherlab/EthercatMaster.py", line 341, in GetSlaves
for slave in self.Config.getConfig().getSlave():
<type 'exceptions.AttributeError'>:_'lxml.etree._Element'_object_has_no_attribute_'getSlave'

Steps to reproduce problem:

- Add new EtherCAT master
- Add new EthercatNode to the master
- double click on


this is looks like dirty hack to fix strange problem with initial[0]
changing its type after returning from _init_ method to lxml.etree._Element
As a result all methods generated by class factory are lost.

For example, in function initMethod initial[0].__class__ points to
xmlclass.xmlclass.Config. After map(self.append, initial)
self.Config.__class__ is 'xmlclass.xmlclass.Config' as well.
But after returning from initMethod (_init) in CreateElement
self.Config.__class__ has changed to lxml.etree._Element.


I've noticed similar behavior if copy/deepcopy is used for any child
of etree.ElementBase. See simple example below.
[-------------------------------------------------------------]
#!/usr/bin/python

from __future__ import print_function
from lxml import etree
import copy

class DefaultElementClass(etree.ElementBase):
def getLocalTag(self):
return etree.QName(self.tag).localname


def printInformation(x):
print(x, x.__class__, "getLocalTag" in dir(x))


a = DefaultElementClass()
printInformation(a)

#
printInformation(copy.copy(a))
printInformation(copy.deepcopy(a))
[-------------------------------------------------------------]
1944
6162e34fb246 Moved some code from PLCController.py to other modules. Added necessary imports.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
     1
#!/usr/bin/env python
6162e34fb246 Moved some code from PLCController.py to other modules. Added necessary imports.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
     2
# -*- coding: utf-8 -*-
6162e34fb246 Moved some code from PLCController.py to other modules. Added necessary imports.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
     3
# This file is part of Beremiz
6162e34fb246 Moved some code from PLCController.py to other modules. Added necessary imports.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
     4
# See COPYING file for copyrights details.
6162e34fb246 Moved some code from PLCController.py to other modules. Added necessary imports.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
     5
6162e34fb246 Moved some code from PLCController.py to other modules. Added necessary imports.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
     6
from __future__ import absolute_import
6162e34fb246 Moved some code from PLCController.py to other modules. Added necessary imports.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
     7
from util.TranslationCatalogs import NoTranslate
6162e34fb246 Moved some code from PLCController.py to other modules. Added necessary imports.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
     8
_ = NoTranslate
6162e34fb246 Moved some code from PLCController.py to other modules. Added necessary imports.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
     9
6162e34fb246 Moved some code from PLCController.py to other modules. Added necessary imports.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    10
ITEMS_EDITABLE = [
6162e34fb246 Moved some code from PLCController.py to other modules. Added necessary imports.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    11
    ITEM_PROJECT,
6162e34fb246 Moved some code from PLCController.py to other modules. Added necessary imports.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    12
    ITEM_POU,
6162e34fb246 Moved some code from PLCController.py to other modules. Added necessary imports.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    13
    ITEM_VARIABLE,
6162e34fb246 Moved some code from PLCController.py to other modules. Added necessary imports.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    14
    ITEM_TRANSITION,
6162e34fb246 Moved some code from PLCController.py to other modules. Added necessary imports.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    15
    ITEM_ACTION,
6162e34fb246 Moved some code from PLCController.py to other modules. Added necessary imports.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    16
    ITEM_CONFIGURATION,
6162e34fb246 Moved some code from PLCController.py to other modules. Added necessary imports.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    17
    ITEM_RESOURCE,
6162e34fb246 Moved some code from PLCController.py to other modules. Added necessary imports.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    18
    ITEM_DATATYPE
6162e34fb246 Moved some code from PLCController.py to other modules. Added necessary imports.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    19
] = range(8)
6162e34fb246 Moved some code from PLCController.py to other modules. Added necessary imports.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    20
6162e34fb246 Moved some code from PLCController.py to other modules. Added necessary imports.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    21
ITEMS_UNEDITABLE = [
6162e34fb246 Moved some code from PLCController.py to other modules. Added necessary imports.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    22
    ITEM_DATATYPES,
6162e34fb246 Moved some code from PLCController.py to other modules. Added necessary imports.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    23
    ITEM_FUNCTION,
6162e34fb246 Moved some code from PLCController.py to other modules. Added necessary imports.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    24
    ITEM_FUNCTIONBLOCK,
6162e34fb246 Moved some code from PLCController.py to other modules. Added necessary imports.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    25
    ITEM_PROGRAM,
6162e34fb246 Moved some code from PLCController.py to other modules. Added necessary imports.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    26
    ITEM_TRANSITIONS,
6162e34fb246 Moved some code from PLCController.py to other modules. Added necessary imports.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    27
    ITEM_ACTIONS,
6162e34fb246 Moved some code from PLCController.py to other modules. Added necessary imports.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    28
    ITEM_CONFIGURATIONS,
6162e34fb246 Moved some code from PLCController.py to other modules. Added necessary imports.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    29
    ITEM_RESOURCES,
6162e34fb246 Moved some code from PLCController.py to other modules. Added necessary imports.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    30
    ITEM_PROPERTIES
6162e34fb246 Moved some code from PLCController.py to other modules. Added necessary imports.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    31
] = range(8, 17)
6162e34fb246 Moved some code from PLCController.py to other modules. Added necessary imports.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    32
6162e34fb246 Moved some code from PLCController.py to other modules. Added necessary imports.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    33
ITEMS_VARIABLE = [
6162e34fb246 Moved some code from PLCController.py to other modules. Added necessary imports.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    34
    ITEM_VAR_LOCAL,
6162e34fb246 Moved some code from PLCController.py to other modules. Added necessary imports.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    35
    ITEM_VAR_GLOBAL,
6162e34fb246 Moved some code from PLCController.py to other modules. Added necessary imports.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    36
    ITEM_VAR_EXTERNAL,
6162e34fb246 Moved some code from PLCController.py to other modules. Added necessary imports.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    37
    ITEM_VAR_TEMP,
6162e34fb246 Moved some code from PLCController.py to other modules. Added necessary imports.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    38
    ITEM_VAR_INPUT,
6162e34fb246 Moved some code from PLCController.py to other modules. Added necessary imports.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    39
    ITEM_VAR_OUTPUT,
6162e34fb246 Moved some code from PLCController.py to other modules. Added necessary imports.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    40
    ITEM_VAR_INOUT
6162e34fb246 Moved some code from PLCController.py to other modules. Added necessary imports.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    41
] = range(17, 24)
6162e34fb246 Moved some code from PLCController.py to other modules. Added necessary imports.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    42
1948
b9a3f771aaab Moved some definitions away from controller class, and adaped references them through all code.
Edouard Tisserant
parents: 1944
diff changeset
    43
ITEM_CONFNODE = 25
b9a3f771aaab Moved some definitions away from controller class, and adaped references them through all code.
Edouard Tisserant
parents: 1944
diff changeset
    44
1944
6162e34fb246 Moved some code from PLCController.py to other modules. Added necessary imports.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    45
VAR_CLASS_INFOS = {
6162e34fb246 Moved some code from PLCController.py to other modules. Added necessary imports.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    46
    "Local":    ("localVars",    ITEM_VAR_LOCAL),
6162e34fb246 Moved some code from PLCController.py to other modules. Added necessary imports.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    47
    "Global":   ("globalVars",   ITEM_VAR_GLOBAL),
6162e34fb246 Moved some code from PLCController.py to other modules. Added necessary imports.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    48
    "External": ("externalVars", ITEM_VAR_EXTERNAL),
6162e34fb246 Moved some code from PLCController.py to other modules. Added necessary imports.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    49
    "Temp":     ("tempVars",     ITEM_VAR_TEMP),
6162e34fb246 Moved some code from PLCController.py to other modules. Added necessary imports.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    50
    "Input":    ("inputVars",    ITEM_VAR_INPUT),
6162e34fb246 Moved some code from PLCController.py to other modules. Added necessary imports.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    51
    "Output":   ("outputVars",   ITEM_VAR_OUTPUT),
6162e34fb246 Moved some code from PLCController.py to other modules. Added necessary imports.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    52
    "InOut":    ("inOutVars",    ITEM_VAR_INOUT)}
6162e34fb246 Moved some code from PLCController.py to other modules. Added necessary imports.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    53
6162e34fb246 Moved some code from PLCController.py to other modules. Added necessary imports.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    54
POU_TYPES = {
6162e34fb246 Moved some code from PLCController.py to other modules. Added necessary imports.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    55
    "program": ITEM_PROGRAM,
6162e34fb246 Moved some code from PLCController.py to other modules. Added necessary imports.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    56
    "functionBlock": ITEM_FUNCTIONBLOCK,
6162e34fb246 Moved some code from PLCController.py to other modules. Added necessary imports.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    57
    "function": ITEM_FUNCTION,
6162e34fb246 Moved some code from PLCController.py to other modules. Added necessary imports.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    58
}
6162e34fb246 Moved some code from PLCController.py to other modules. Added necessary imports.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    59
6162e34fb246 Moved some code from PLCController.py to other modules. Added necessary imports.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    60
CLASS_TYPES = {
6162e34fb246 Moved some code from PLCController.py to other modules. Added necessary imports.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    61
    "configuration": ITEM_CONFIGURATION,
6162e34fb246 Moved some code from PLCController.py to other modules. Added necessary imports.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    62
    "resource": ITEM_RESOURCE,
6162e34fb246 Moved some code from PLCController.py to other modules. Added necessary imports.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    63
    "action": ITEM_ACTION,
6162e34fb246 Moved some code from PLCController.py to other modules. Added necessary imports.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    64
    "transition": ITEM_TRANSITION,
6162e34fb246 Moved some code from PLCController.py to other modules. Added necessary imports.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    65
    "program": ITEM_PROGRAM
6162e34fb246 Moved some code from PLCController.py to other modules. Added necessary imports.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    66
}
6162e34fb246 Moved some code from PLCController.py to other modules. Added necessary imports.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    67
6162e34fb246 Moved some code from PLCController.py to other modules. Added necessary imports.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    68
LOCATIONS_ITEMS = [LOCATION_CONFNODE,
6162e34fb246 Moved some code from PLCController.py to other modules. Added necessary imports.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    69
                   LOCATION_MODULE,
6162e34fb246 Moved some code from PLCController.py to other modules. Added necessary imports.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    70
                   LOCATION_GROUP,
6162e34fb246 Moved some code from PLCController.py to other modules. Added necessary imports.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    71
                   LOCATION_VAR_INPUT,
6162e34fb246 Moved some code from PLCController.py to other modules. Added necessary imports.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    72
                   LOCATION_VAR_OUTPUT,
6162e34fb246 Moved some code from PLCController.py to other modules. Added necessary imports.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    73
                   LOCATION_VAR_MEMORY] = range(6)
6162e34fb246 Moved some code from PLCController.py to other modules. Added necessary imports.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    74
6162e34fb246 Moved some code from PLCController.py to other modules. Added necessary imports.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    75
UNEDITABLE_NAMES = [_("User-defined POUs"), _("Functions"), _("Function Blocks"),
1953
5736d25bb393 PEP8 and PyLint conformance: whitespaces and stuff
Edouard Tisserant
parents: 1948
diff changeset
    76
                    _("Programs"), _("Data Types"), _("Transitions"), _("Actions"),
5736d25bb393 PEP8 and PyLint conformance: whitespaces and stuff
Edouard Tisserant
parents: 1948
diff changeset
    77
                    _("Configurations"), _("Resources"), _("Properties")]
1944
6162e34fb246 Moved some code from PLCController.py to other modules. Added necessary imports.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    78
6162e34fb246 Moved some code from PLCController.py to other modules. Added necessary imports.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    79
[USER_DEFINED_POUS, FUNCTIONS, FUNCTION_BLOCKS, PROGRAMS,
6162e34fb246 Moved some code from PLCController.py to other modules. Added necessary imports.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    80
 DATA_TYPES, TRANSITIONS, ACTIONS, CONFIGURATIONS,
6162e34fb246 Moved some code from PLCController.py to other modules. Added necessary imports.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    81
 RESOURCES, PROPERTIES] = UNEDITABLE_NAMES
6162e34fb246 Moved some code from PLCController.py to other modules. Added necessary imports.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    82
1948
b9a3f771aaab Moved some definitions away from controller class, and adaped references them through all code.
Edouard Tisserant
parents: 1944
diff changeset
    83
# -------------------------------------------------------------------------------
b9a3f771aaab Moved some definitions away from controller class, and adaped references them through all code.
Edouard Tisserant
parents: 1944
diff changeset
    84
#                   Project Element tag name computation functions
b9a3f771aaab Moved some definitions away from controller class, and adaped references them through all code.
Edouard Tisserant
parents: 1944
diff changeset
    85
# -------------------------------------------------------------------------------
b9a3f771aaab Moved some definitions away from controller class, and adaped references them through all code.
Edouard Tisserant
parents: 1944
diff changeset
    86
1953
5736d25bb393 PEP8 and PyLint conformance: whitespaces and stuff
Edouard Tisserant
parents: 1948
diff changeset
    87
1948
b9a3f771aaab Moved some definitions away from controller class, and adaped references them through all code.
Edouard Tisserant
parents: 1944
diff changeset
    88
# Compute a data type name
b9a3f771aaab Moved some definitions away from controller class, and adaped references them through all code.
Edouard Tisserant
parents: 1944
diff changeset
    89
def ComputeDataTypeName(datatype):
b9a3f771aaab Moved some definitions away from controller class, and adaped references them through all code.
Edouard Tisserant
parents: 1944
diff changeset
    90
    return "D::%s" % datatype
b9a3f771aaab Moved some definitions away from controller class, and adaped references them through all code.
Edouard Tisserant
parents: 1944
diff changeset
    91
1953
5736d25bb393 PEP8 and PyLint conformance: whitespaces and stuff
Edouard Tisserant
parents: 1948
diff changeset
    92
1948
b9a3f771aaab Moved some definitions away from controller class, and adaped references them through all code.
Edouard Tisserant
parents: 1944
diff changeset
    93
# Compute a pou name
b9a3f771aaab Moved some definitions away from controller class, and adaped references them through all code.
Edouard Tisserant
parents: 1944
diff changeset
    94
def ComputePouName(pou):
b9a3f771aaab Moved some definitions away from controller class, and adaped references them through all code.
Edouard Tisserant
parents: 1944
diff changeset
    95
    return "P::%s" % pou
b9a3f771aaab Moved some definitions away from controller class, and adaped references them through all code.
Edouard Tisserant
parents: 1944
diff changeset
    96
1953
5736d25bb393 PEP8 and PyLint conformance: whitespaces and stuff
Edouard Tisserant
parents: 1948
diff changeset
    97
1948
b9a3f771aaab Moved some definitions away from controller class, and adaped references them through all code.
Edouard Tisserant
parents: 1944
diff changeset
    98
# Compute a pou transition name
b9a3f771aaab Moved some definitions away from controller class, and adaped references them through all code.
Edouard Tisserant
parents: 1944
diff changeset
    99
def ComputePouTransitionName(pou, transition):
b9a3f771aaab Moved some definitions away from controller class, and adaped references them through all code.
Edouard Tisserant
parents: 1944
diff changeset
   100
    return "T::%s::%s" % (pou, transition)
b9a3f771aaab Moved some definitions away from controller class, and adaped references them through all code.
Edouard Tisserant
parents: 1944
diff changeset
   101
1953
5736d25bb393 PEP8 and PyLint conformance: whitespaces and stuff
Edouard Tisserant
parents: 1948
diff changeset
   102
1948
b9a3f771aaab Moved some definitions away from controller class, and adaped references them through all code.
Edouard Tisserant
parents: 1944
diff changeset
   103
# Compute a pou action name
b9a3f771aaab Moved some definitions away from controller class, and adaped references them through all code.
Edouard Tisserant
parents: 1944
diff changeset
   104
def ComputePouActionName(pou, action):
b9a3f771aaab Moved some definitions away from controller class, and adaped references them through all code.
Edouard Tisserant
parents: 1944
diff changeset
   105
    return "A::%s::%s" % (pou, action)
b9a3f771aaab Moved some definitions away from controller class, and adaped references them through all code.
Edouard Tisserant
parents: 1944
diff changeset
   106
1953
5736d25bb393 PEP8 and PyLint conformance: whitespaces and stuff
Edouard Tisserant
parents: 1948
diff changeset
   107
1948
b9a3f771aaab Moved some definitions away from controller class, and adaped references them through all code.
Edouard Tisserant
parents: 1944
diff changeset
   108
# Compute a pou  name
b9a3f771aaab Moved some definitions away from controller class, and adaped references them through all code.
Edouard Tisserant
parents: 1944
diff changeset
   109
def ComputeConfigurationName(config):
b9a3f771aaab Moved some definitions away from controller class, and adaped references them through all code.
Edouard Tisserant
parents: 1944
diff changeset
   110
    return "C::%s" % config
b9a3f771aaab Moved some definitions away from controller class, and adaped references them through all code.
Edouard Tisserant
parents: 1944
diff changeset
   111
1953
5736d25bb393 PEP8 and PyLint conformance: whitespaces and stuff
Edouard Tisserant
parents: 1948
diff changeset
   112
1948
b9a3f771aaab Moved some definitions away from controller class, and adaped references them through all code.
Edouard Tisserant
parents: 1944
diff changeset
   113
# Compute a pou  name
b9a3f771aaab Moved some definitions away from controller class, and adaped references them through all code.
Edouard Tisserant
parents: 1944
diff changeset
   114
def ComputeConfigurationResourceName(config, resource):
b9a3f771aaab Moved some definitions away from controller class, and adaped references them through all code.
Edouard Tisserant
parents: 1944
diff changeset
   115
    return "R::%s::%s" % (config, resource)
b9a3f771aaab Moved some definitions away from controller class, and adaped references them through all code.
Edouard Tisserant
parents: 1944
diff changeset
   116
1953
5736d25bb393 PEP8 and PyLint conformance: whitespaces and stuff
Edouard Tisserant
parents: 1948
diff changeset
   117
1948
b9a3f771aaab Moved some definitions away from controller class, and adaped references them through all code.
Edouard Tisserant
parents: 1944
diff changeset
   118
def GetElementType(tagname):
b9a3f771aaab Moved some definitions away from controller class, and adaped references them through all code.
Edouard Tisserant
parents: 1944
diff changeset
   119
    words = tagname.split("::")
b9a3f771aaab Moved some definitions away from controller class, and adaped references them through all code.
Edouard Tisserant
parents: 1944
diff changeset
   120
    return {
b9a3f771aaab Moved some definitions away from controller class, and adaped references them through all code.
Edouard Tisserant
parents: 1944
diff changeset
   121
        "D": ITEM_DATATYPE,
b9a3f771aaab Moved some definitions away from controller class, and adaped references them through all code.
Edouard Tisserant
parents: 1944
diff changeset
   122
        "P": ITEM_POU,
b9a3f771aaab Moved some definitions away from controller class, and adaped references them through all code.
Edouard Tisserant
parents: 1944
diff changeset
   123
        "T": ITEM_TRANSITION,
b9a3f771aaab Moved some definitions away from controller class, and adaped references them through all code.
Edouard Tisserant
parents: 1944
diff changeset
   124
        "A": ITEM_ACTION,
b9a3f771aaab Moved some definitions away from controller class, and adaped references them through all code.
Edouard Tisserant
parents: 1944
diff changeset
   125
        "C": ITEM_CONFIGURATION,
b9a3f771aaab Moved some definitions away from controller class, and adaped references them through all code.
Edouard Tisserant
parents: 1944
diff changeset
   126
        "R": ITEM_RESOURCE
b9a3f771aaab Moved some definitions away from controller class, and adaped references them through all code.
Edouard Tisserant
parents: 1944
diff changeset
   127
    }[words[0]]
b9a3f771aaab Moved some definitions away from controller class, and adaped references them through all code.
Edouard Tisserant
parents: 1944
diff changeset
   128
b9a3f771aaab Moved some definitions away from controller class, and adaped references them through all code.
Edouard Tisserant
parents: 1944
diff changeset
   129
1944
6162e34fb246 Moved some code from PLCController.py to other modules. Added necessary imports.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   130
# remove gettext override
6162e34fb246 Moved some code from PLCController.py to other modules. Added necessary imports.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   131
del _