--- a/LPCBeremiz.py Mon Dec 07 10:25:33 2009 +0100
+++ b/LPCBeremiz.py Mon Dec 07 14:43:27 2009 +0100
@@ -72,6 +72,17 @@
#-------------------------------------------------------------------------------
+LOCATION_TYPES = {"I": LOCATION_VAR_INPUT, + "Q": LOCATION_VAR_OUTPUT, + "M": LOCATION_VAR_MEMORY} +LOCATION_DIRS = dict([(dir, size) for size, dir in LOCATION_TYPES.iteritems()]) +for size, types in LOCATIONDATATYPES.iteritems(): + LOCATION_SIZES[type] = size def _GetModuleChildren(module):
for child in module["children"]:
@@ -96,9 +107,9 @@
-def _GetModuleVariable(module, location):
+def _GetModuleVariable(module, location, direction): for child in _GetModuleChildren(module):
- if child["location"] == location:
+ if child["location"] == location and child["type"] == LOCATION_TYPES[direction]: @@ -110,17 +121,6 @@
if group["type"] == LOCATION_GROUP and child in group["children"]:
group["children"].remove(child)
-LOCATION_TYPES = {"I": LOCATION_VAR_INPUT,
- "Q": LOCATION_VAR_OUTPUT,
- "M": LOCATION_VAR_MEMORY}
-LOCATION_DIRS = dict([(dir, size) for size, dir in LOCATION_TYPES.iteritems()])
-for size, types in LOCATIONDATATYPES.iteritems():
- LOCATION_SIZES[type] = size
BUS_TEXT = """/* Code generated by LPCBus plugin */
/* LPCBus plugin includes */
@@ -893,7 +893,7 @@
for child in _GetModuleChildren(module):
if child["name"] == name:
return "Error: A variable named %s already exists" % name
- if child["location"] == location:
+ if child["location"] == location and child["type"] == LOCATION_TYPES[direction]: return "Error: A variable with location %s already exists" % ".".join(map(str, location))
_GetLastModuleGroup(module).append({"name": name,
@@ -911,7 +911,7 @@
return "Error: No parent found"
for child in _GetModuleChildren(module):
- if child["location"] == location:
+ if child["location"] == location and child["type"] == LOCATION_TYPES[new_direction]: elif child["name"] == new_name:
return "Error: A variable named %s already exists" % new_name
@@ -929,11 +929,11 @@
variable["description"] = new_description
- def RemoveVariable(self, parent, location):
+ def RemoveVariable(self, parent, location, direction): module = self.PluginRoot.GetChildByIECLocation(parent)
return "Error: No parent found"
- child = _GetModuleVariable(module, location)
+ child = _GetModuleVariable(module, location, direction) return "Error: No variable found"
size = LOCATION_SIZES[self.PluginRoot.GetBaseType(child["IEC_type"])]