Implicit setting type to part/drivable if not set explicitly

This commit is contained in:
Douglas Clowes
2014-03-18 15:02:39 +11:00
parent 2db71ba537
commit 9f8eabd3ec
5 changed files with 23 additions and 11 deletions

View File

@@ -17,10 +17,6 @@
# - type part ???
# - nxalias xxxxx
# - sdsinfo
# fix code for driving
# - make each node driveable
# - use [sct] in place of ${tc_root}
# - associate sensor and call ansto_makesctdrive
# check simulation works
# handle environmental monitoring (emon)
# - figure out how to do it
@@ -559,27 +555,30 @@ def build_variable(MyDriver, p):
if Verbose:
print 'Variable:', p
MyVar = {}
MyVar['Property'] = {}
# Copy items for this variable
for item in p:
if Verbose:
print "Variable Item:", item
for key in item.keys():
if key == 'Property':
if not 'Property' in MyVar:
MyVar['Property'] = {}
MyVar['Property'][item[key][0]] = item[key][1]
else:
MyVar[key] = item[key]
# copy the defaults for missing items
for key in ContextStack[ContextIndex]:
if key == 'Property':
if 'Property' not in MyVar:
MyVar['Property'] = {}
for key2 in ContextStack[ContextIndex][key]:
if key2 not in MyVar['Property']:
MyVar['Property'][key2] = ContextStack[ContextIndex][key][key2]
elif not key in MyVar:
MyVar[key] = ContextStack[ContextIndex][key]
# set the type if not explicitly set
if 'type' not in MyVar['Property']:
if 'driveable' in MyVar and MyVar['driveable']:
MyVar['Property']['type'] = 'drivable'
else:
MyVar['Property']['type'] = 'part'
# if this variable is driveable
if 'driveable' in MyVar and MyVar['driveable']:
# insert defaults for missing driveable functions