Disabling definition of enumerated and structure variables for interfacing with PLC in c_ext plug-in
--- a/plugins/c_ext/CFileEditor.py Fri Jun 24 01:17:07 2011 +0200
+++ b/plugins/c_ext/CFileEditor.py Wed Sep 07 16:01:13 2011 +0200
@@ -740,7 +740,7 @@
self.Bind(wx.EVT_MENU, self.GetVariableTypeFunction(base_type), id=new_id)
type_menu.AppendMenu(wx.NewId(), "Base Types", base_menu)
datatype_menu = wx.Menu(title='')
- for datatype in self.Controler.GetDataTypes(basetypes = False):
+ for datatype in self.Controler.GetDataTypes(basetypes=False, only_locatables=True):
new_id = wx.NewId()
AppendMenu(datatype_menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text=datatype)
self.Bind(wx.EVT_MENU, self.GetVariableTypeFunction(datatype), id=new_id)
--- a/plugins/c_ext/c_ext.py Fri Jun 24 01:17:07 2011 +0200
+++ b/plugins/c_ext/c_ext.py Wed Sep 07 16:01:13 2011 +0200
@@ -139,11 +139,11 @@
def GetBaseTypes(self):
return self.GetPlugRoot().GetBaseTypes()
- def GetDataTypes(self, basetypes = False):
- return self.GetPlugRoot().GetDataTypes(basetypes = basetypes)
+ def GetDataTypes(self, basetypes = False, only_locatables = False):
+ return self.GetPlugRoot().GetDataTypes(basetypes=basetypes, only_locatables=only_locatables)
def GetSizeOfType(self, type):
- return TYPECONVERSION[self.GetPlugRoot().GetBaseType(type)]
+ return TYPECONVERSION.get(self.GetPlugRoot().GetBaseType(type), None)
def SetVariables(self, variables):
self.CFile.variables.setvariable([])
@@ -169,17 +169,21 @@
input = memory = output = 0
for var in self.CFile.variables.getvariable():
var_size = self.GetSizeOfType(var.gettype())
+ var_location = ""
if var.getclass() == "input":
var_class = LOCATION_VAR_INPUT
- var_location = "%%I%s%s.%d"%(var_size, current_location, input)
+ if var_size is not None:
+ var_location = "%%I%s%s.%d"%(var_size, current_location, input)
input += 1
elif var.getclass() == "memory":
var_class = LOCATION_VAR_INPUT
- var_location = "%%M%s%s.%d"%(var_size, current_location, memory)
+ if var_size is not None:
+ var_location = "%%M%s%s.%d"%(var_size, current_location, memory)
memory += 1
else:
var_class = LOCATION_VAR_OUTPUT
- var_location = "%%Q%s%s.%d"%(var_size, current_location, output)
+ if var_size is not None:
+ var_location = "%%Q%s%s.%d"%(var_size, current_location, output)
output += 1
vars.append({"name": var.getname(),
"type": var_class,