Adding support for Beremiz c_ext plugin
authorlbessard
Fri, 23 May 2008 10:42:09 +0200
changeset 210 17ce08b81775
parent 209 babfecf81c33
child 211 ac7ba3dc027b
Adding support for Beremiz c_ext plugin
PLCControler.py
PLCOpenEditor.py
plcopen/structures.py
--- a/PLCControler.py	Fri Apr 25 10:53:18 2008 +0200
+++ b/PLCControler.py	Fri May 23 10:42:09 2008 +0200
@@ -1152,6 +1152,10 @@
                     datatypes.append(datatype_name)
         return datatypes
 
+    # Return Base Type of given possible derived type
+    def GetBaseType(self, type):
+        return GetBaseType(type)
+
     # Return Base Types
     def GetBaseTypes(self):
         return [value for value, parent in TypeHierarchy_list if not value.startswith("ANY")]
--- a/PLCOpenEditor.py	Fri Apr 25 10:53:18 2008 +0200
+++ b/PLCOpenEditor.py	Fri May 23 10:42:09 2008 +0200
@@ -3349,26 +3349,34 @@
                     location = values[0]
                     variable_type = self.ParentWindow.Table.GetValueByName(row, "Type")
                     message = None
-                    if location[0].isdigit() and variable_type != "BOOL":
-                        message = "Incompatible size of data between \"%s\" and \"BOOL\""%location
-                    elif location[0] not in LOCATIONDATATYPES:
-                        message = "Unrecognized data size \"%s\""%location[0]
-                    elif variable_type not in LOCATIONDATATYPES[location[0]]:
-                        message = "Incompatible size of data between \"%s\" and \"%s\""%(location, variable_type)
-                    else:
-                        dialog = wx.SingleChoiceDialog(self.ParentWindow, "Select a variable class:", "Variable class", ["Input", "Output", "Memory"], wx.OK|wx.CANCEL)
-                        if dialog.ShowModal() == wx.ID_OK:
-                            selected = dialog.GetSelection()
-                            if selected == 0:
-                                location = "%I" + location
-                            elif selected == 1:
-                                location = "%Q" + location
-                            else:
-                                location = "%M" + location
+                    if location.startswith("%"):
+                        if variable_type != values[2]:
+                            message = "Incompatible data types between \"%s\" and \"%s\""%(values[2], variable_type)
+                        else:
                             self.ParentWindow.Table.SetValue(row, col, location)
                             self.ParentWindow.Table.ResetView(self.ParentWindow.VariablesGrid)
                             self.ParentWindow.SaveValues()
-                        dialog.Destroy()
+                    else:
+                        if location[0].isdigit() and variable_type != "BOOL":
+                            message = "Incompatible size of data between \"%s\" and \"BOOL\""%location
+                        elif location[0] not in LOCATIONDATATYPES:
+                            message = "Unrecognized data size \"%s\""%location[0]
+                        elif variable_type not in LOCATIONDATATYPES[location[0]]:
+                            message = "Incompatible size of data between \"%s\" and \"%s\""%(location, variable_type)
+                        else:
+                            dialog = wx.SingleChoiceDialog(self.ParentWindow, "Select a variable class:", "Variable class", ["Input", "Output", "Memory"], wx.OK|wx.CANCEL)
+                            if dialog.ShowModal() == wx.ID_OK:
+                                selected = dialog.GetSelection()
+                                if selected == 0:
+                                    location = "%I" + location
+                                elif selected == 1:
+                                    location = "%Q" + location
+                                else:
+                                    location = "%M" + location
+                                self.ParentWindow.Table.SetValue(row, col, location)
+                                self.ParentWindow.Table.ResetView(self.ParentWindow.VariablesGrid)
+                                self.ParentWindow.SaveValues()
+                            dialog.Destroy()
             if message is not None:
                 message = wx.MessageDialog(self.ParentWindow, message, "Error", wx.OK|wx.ICON_ERROR)
                 message.ShowModal()
--- a/plcopen/structures.py	Fri Apr 25 10:53:18 2008 +0200
+++ b/plcopen/structures.py	Fri May 23 10:42:09 2008 +0200
@@ -334,6 +334,13 @@
     else:
         return True
 
+def GetBaseType(type):
+    parent_type = TypeHierarchy[type]
+    if parent_type.startswith("ANY"):
+        return type
+    else:
+        return GetBaseType(parent_type)
+
 def GetDataTypeRange(reference):
     while reference is not None:
         if reference in DataTypeRange: