--- a/PLCControler.py Sat Jul 21 01:17:02 2007 +0200
+++ b/PLCControler.py Sat Jul 21 01:20:00 2007 +0200
@@ -611,6 +611,8 @@
tempvar.setInitialValue(value)
if var["Location"] != "":
tempvar.setAddress(var["Location"])
+ else:
+ tempvar.setAddress(None)
# Add variable to varList
current_varlist.appendVariable(tempvar)
return varlist_list
@@ -635,13 +637,17 @@
# Extract variables from every varLists
for varlist in configuration.getGlobalVars():
for var in varlist.getVariable():
- tempvar = {"Name":var.getName(),"Class":"Global","Type":var.getType().getValue(),
- "Location":var.getAddress()}
+ tempvar = {"Name":var.getName(),"Class":"Global","Type":var.getType().getValue()}
initial = var.getInitialValue()
if initial:
tempvar["Initial Value"] = initial.getValue()
else:
tempvar["Initial Value"] = ""
+ address = var.getAddress()
+ if address:
+ tempvar["Location"] = address
+ else:
+ tempvar["Location"] = ""
if varlist.getRetain():
tempvar["Retain"] = "Yes"
else:
@@ -673,13 +679,17 @@
# Extract variables from every varLists
for varlist in resource.getGlobalVars():
for var in varlist.getVariable():
- tempvar = {"Name":var.getName(),"Class":"Global","Type":var.getType().getValue(),
- "Location":var.getAddress()}
+ tempvar = {"Name":var.getName(),"Class":"Global","Type":var.getType().getValue()}
initial = var.getInitialValue()
if initial:
tempvar["Initial Value"] = initial.getValue()
else:
tempvar["Initial Value"] = ""
+ address = var.getAddress()
+ if address:
+ tempvar["Location"] = address
+ else:
+ tempvar["Location"] = ""
if varlist.getRetain():
tempvar["Retain"] = "Yes"
else:
@@ -704,13 +714,17 @@
# Extract variables from every varLists
for type, varlist in pou.getVars():
for var in varlist.getVariable():
- tempvar = {"Name":var.getName(),"Class":type,"Type":var.getType().getValue(),
- "Location":var.getAddress()}
+ tempvar = {"Name":var.getName(),"Class":type,"Type":var.getType().getValue()}
initial = var.getInitialValue()
if initial:
tempvar["Initial Value"] = initial.getValue()
else:
tempvar["Initial Value"] = ""
+ address = var.getAddress()
+ if address:
+ tempvar["Location"] = address
+ else:
+ tempvar["Location"] = ""
if varlist.getRetain():
tempvar["Retain"] = "Yes"
else:
--- a/PLCOpenEditor.py Sat Jul 21 01:17:02 2007 +0200
+++ b/PLCOpenEditor.py Sat Jul 21 01:20:00 2007 +0200
@@ -790,10 +790,11 @@
if self.ProjectTree.GetPyData(item) == ITEM_POU:
block_name = self.ProjectTree.GetItemText(item)
block_type = self.Controler.GetPouType(block_name)
- data = wxTextDataObject(str((block_name, block_type)))
- dragSource = wxDropSource(self.ProjectTree)
- dragSource.SetData(data)
- dragSource.DoDragDrop()
+ if block_type != "program":
+ data = wxTextDataObject(str((block_name, block_type)))
+ dragSource = wxDropSource(self.ProjectTree)
+ dragSource.SetData(data)
+ dragSource.DoDragDrop()
def OnProjectTreeItemEndEdit(self, event):
message = None
@@ -2036,6 +2037,37 @@
self.data = []
self.editors = []
+class VariableDropTarget(wx.TextDropTarget):
+
+ def __init__(self, parent):
+ wx.TextDropTarget.__init__(self)
+ self.Parent = parent
+
+ def OnDropText(self, x, y, data):
+ col = self.Parent.VariablesGrid.XToCol(x)
+ row = self.Parent.VariablesGrid.YToRow(y)
+ if col != wxNOT_FOUND and row != wxNOT_FOUND:
+ if self.Parent.Table.GetColLabelValue(col) != "Location":
+ return
+ try:
+ values = eval(data)
+ except:
+ values = None
+ if values and values[1] == "location":
+ dialog = wxSingleChoiceDialog(self.Parent, "Select a variable class:", "Variable class", ["Input", "Output", "Memory"], wxOK|wxCANCEL)
+ if dialog.ShowModal() == wxID_OK:
+ selected = dialog.GetSelection()
+ if selected == 0:
+ location = "%I" + values[0]
+ elif selected == 1:
+ location = "%Q" + values[0]
+ else:
+ location = "%M" + values[0]
+ self.Parent.Table.SetValue(row - 1, col, location)
+ self.Parent.Table.ResetView(self.Parent.VariablesGrid)
+ self.Parent.SaveValues()
+ dialog.Destroy()
+
[wxID_POUEDITORPANEL, wxID_POUEDITORPANELVIEWER,
wxID_POUEDITORPANELVARIABLESGRID, wxID_POUEDITORPANELRETURNTYPE,
wxID_POUEDITORPANELCLASSFILTER, wxID_POUEDITORPANELADDBUTTON,
@@ -2185,6 +2217,8 @@
self.VariablesGrid.Bind(wx.grid.EVT_GRID_SELECT_CELL, self.OnVariablesGridSelectCell)
self.VariablesGrid.Bind(wx.grid.EVT_GRID_CELL_LEFT_CLICK, self.OnVariablesGridCellLeftClick)
+ self.VariablesGrid.SetDropTarget(VariableDropTarget(self))
+
self.AddButton = wx.Button(id=wxID_POUEDITORPANELADDBUTTON, label='Add',
name='AddButton', parent=self, pos=wx.Point(345, 340),
size=wx.Size(72, 32), style=0)
--- a/TextViewer.py Sat Jul 21 01:17:02 2007 +0200
+++ b/TextViewer.py Sat Jul 21 01:20:00 2007 +0200
@@ -127,7 +127,7 @@
except:
values = event.GetDragText()
if isinstance(values, tuple):
- if values[1] in ["functionBlock", "program"]:
+ if values[1] in ["functionBlock", "program", "location"]:
event.SetDragText("")
else:
event.SetDragText(values[0])
--- a/Viewer.py Sat Jul 21 01:17:02 2007 +0200
+++ b/Viewer.py Sat Jul 21 01:20:00 2007 +0200
@@ -65,7 +65,7 @@
self.Parent.RefreshBlockModel(block)
self.Parent.RefreshScrollBars()
self.Parent.Refresh()
- else:
+ elif values[1] != "location":
id = self.Parent.GetNewId()
if values[1] == "Output":
var_type = OUTPUT