From d4b04e2dd1a58431107705d8a14dc1b69ce64037 Mon Sep 17 00:00:00 2001
From: aschwinn <al.schwinn@gsi.de>
Date: Wed, 7 Jun 2017 10:40:39 +0200
Subject: [PATCH] Bug 1407 - Remove Plugin specific design validation Rules

---
 silecs-codegen/src/xml/iecommon.py       | 42 -----------
 silecs-codegen/src/xml/model/Register.py | 90 +++++++++++++++++++++---
 2 files changed, 80 insertions(+), 52 deletions(-)

diff --git a/silecs-codegen/src/xml/iecommon.py b/silecs-codegen/src/xml/iecommon.py
index 120f37b..27f4e4d 100644
--- a/silecs-codegen/src/xml/iecommon.py
+++ b/silecs-codegen/src/xml/iecommon.py
@@ -149,40 +149,6 @@ def fillAttributes(element, attrs):
         element.setProp(name, value)
     return element
 
-#-------------------------------------------------------------------------
-# Given an SILECS data type, returns the corresponding FESA data type
-# For the time being FESA does not support unsigned data types in properties
-# so here unsigned types are considered as signed to allow users to link
-# any field to properties
-#-------------------------------------------------------------------------
-def getFesaDataType(silecsDataType):
-    return  {
-             'int8'     :'int8_t',
-             'uint8'    :'int16_t',
-             'int16'    :'int16_t',
-             'uint16'   :'int32_t',
-             'int32'    :'int32_t',
-             'uint32'   :'int64_t',
-             'int64'    :'int64_t',
-             'uint64'   :'uint64_t',  # only for PXI, but not supported from Java! Not possible to use it in FESA properties
-             'float32'  :'float',
-             'float64'  :'double',
-             'date'     :'double',
-             'char'     :'int8_t',
-             'byte'     :'int16_t',
-             'word'     :'int32_t',
-             'dword'    :'int64_t',
-             'int'      :'int16_t',
-             'dint'     :'int32_t',
-             'real'     :'float',
-             'dt'       :'double',
-             'string'   :'char'
-    }[silecsDataType]
-
-def registerFormatType2FesaType(registerFormatType):
-    type = iecommon.getSilecsDataType(registerFormatType)
-    return getFesaDataType(type)
-
 def getCDataType(silecsDataType):
     return  {
              'int8'     :'int8_t',
@@ -207,9 +173,6 @@ def getCDataType(silecsDataType):
              'string'   :'std::string'
     }[silecsDataType]
     
-def registerFormatType2CType(registerFormatType):
-    type = iecommon.getSilecsDataType(registerFormatType)
-    return getCDataType(type)
 #-------------------------------------------------------------------------
 # Given PLC data type, returns the corresponding
 # SILECS data type
@@ -245,11 +208,6 @@ def getSilecsDataType(registerFormatType):
              'string'       : 'string'
     }[registerFormatType]
 
-def isUnsignedType(registerFormatType):
-    type = iecommon.getSilecsDataType(registerFormatType)
-    if type[0] == 'u':
-        return True
-    return False
 #Needed for SilecsMethodNames
 def getSilecsDataTypeUpperCase(registerFormatType):
     type = iecommon.getSilecsDataType(registerFormatType)
diff --git a/silecs-codegen/src/xml/model/Register.py b/silecs-codegen/src/xml/model/Register.py
index 6695e7e..0eb5445 100644
--- a/silecs-codegen/src/xml/model/Register.py
+++ b/silecs-codegen/src/xml/model/Register.py
@@ -20,9 +20,6 @@ import libxml2
 class Register(object):
     
     def __init__(self, xmlNode):
-        self.initWithDesignRegisterNode(xmlNode)
-    
-    def initWithDesignRegisterNode(self, xmlNode):
         self.xmlNode = xmlNode
         
         #xmlNode.shellPrintNode()
@@ -56,14 +53,29 @@ class Register(object):
             
         self.format = self.valueTypeNode.prop("format")
             
+        
+    def isUnsigned(self):
+        type = iecommon.getSilecsDataType(self.format)
+        if type[0] == 'u':
+            return True
+        return False
+    
+    def getCType():
+        type = iecommon.getSilecsDataType(self.format)
+        return iecommon.getCDataType(type)
+    
+    def getSilecsTypeCapitalized(self):
+        return iecommon.getSilecsDataTypeUpperCase(self.format)
+    
     def isArray(self):
-        return self.valueType == 'array' or 'stringArray'
+        return self.valueType == 'array' or self.valueType == 'stringArray'
     
     def isArray2D(self):
-        return self.valueType == 'array2D' or 'stringArray2D'
+        return self.valueType == 'array2D' or self.valueType == 'stringArray2D'
     
     def isStringType(self):
-        return self.valueType == 'string' or 'stringArray' or 'stringArray2D'
+        return self.valueType == 'string' or self.valueType == 'stringArray' or self.valueType == 'stringArray2D'
+    
 
 #has some additionalValues
 class ParamRegister(Register):
@@ -95,12 +107,70 @@ class ParamRegister(Register):
 class DesignRegister(Register):
     def __init__(self, xmlNode):
         super(DesignRegister, self).__init__(xmlNode)
-        self.fesaFieldName = ""
+        self.fesaFieldName = self.name
+        self.generateFesaValueItem = True
         if self.xmlNode.hasProp("fesaFieldName"):
             self.fesaFieldName = xmlNode.prop("fesaFieldName")
         if self.xmlNode.hasProp("generateFesaValueItem"): #SilecsHEader does not have this attribute 
             self.generateFesaValueItem = xsdBooleanToBoolean(xmlNode.prop("generateFesaValueItem"))
-    def getFesaName(self):
-        if self.fesaFieldName == "":
-            return self.name
+            
+    def getFesaFieldName(self):
         return self.fesaFieldName
+    
+    #-------------------------------------------------------------------------
+    # Given an SILECS data type, returns the corresponding FESA data type
+    # For the time being FESA does not support unsigned data types in properties
+    # so here unsigned types are considered as signed to allow users to link
+    # any field to properties
+    #-------------------------------------------------------------------------
+    def getFesaType(self):
+        return  {
+                 'int8'     :'int8_t',
+                 'uint8'    :'int16_t',
+                 'int16'    :'int16_t',
+                 'uint16'   :'int32_t',
+                 'int32'    :'int32_t',
+                 'uint32'   :'int64_t',
+                 'int64'    :'int64_t',
+                 'uint64'   :'uint64_t',  # only for PXI, but not supported from Java! Not possible to use it in FESA properties
+                 'float32'  :'float',
+                 'float64'  :'double',
+                 'date'     :'double',
+                 'char'     :'int8_t',
+                 'byte'     :'int16_t',
+                 'word'     :'int32_t',
+                 'dword'    :'int64_t',
+                 'int'      :'int16_t',
+                 'dint'     :'int32_t',
+                 'real'     :'float',
+                 'dt'       :'double',
+                 'string'   :'char'
+        }[iecommon.getSilecsDataType(self.format)]
+
+    def getFesaFieldNameCapitalized(self):
+        return  iecommon.capitalizeString(self.fesaFieldName)
+
+    def getFesaDataType(self,silecsDataType):
+        return  {
+                 'int8'     :'int8_t',
+                 'uint8'    :'int16_t',
+                 'int16'    :'int16_t',
+                 'uint16'   :'int32_t',
+                 'int32'    :'int32_t',
+                 'uint32'   :'int64_t',
+                 'int64'    :'int64_t',
+                 'uint64'   :'uint64_t',  # only for PXI, but not supported from Java! Not possible to use it in FESA properties
+                 'float32'  :'float',
+                 'float64'  :'double',
+                 'date'     :'double',
+                 'char'     :'int8_t',
+                 'byte'     :'int16_t',
+                 'word'     :'int32_t',
+                 'dword'    :'int64_t',
+                 'int'      :'int16_t',
+                 'dint'     :'int32_t',
+                 'real'     :'float',
+                 'dt'       :'double',
+                 'string'   :'char'
+        }[silecsDataType]
+    
-- 
GitLab