editors/Viewer.py
changeset 1381 8b0a7eceb76d
parent 1377 cc8f9177d41c
child 1406 82db84fe88ea
equal deleted inserted replaced
1380:10ac2b18437b 1381:8b0a7eceb76d
   103     def powerRailCreationFunction(viewer, id, specific_values):
   103     def powerRailCreationFunction(viewer, id, specific_values):
   104         return LD_PowerRail(viewer, powerrail_type, id, 
   104         return LD_PowerRail(viewer, powerrail_type, id, 
   105                                     specific_values.connectors)
   105                                     specific_values.connectors)
   106     return powerRailCreationFunction
   106     return powerRailCreationFunction
   107 
   107 
       
   108 NEGATED_VALUE = lambda x: x if x is not None else False
   108 MODIFIER_VALUE = lambda x: x if x is not None else 'none'
   109 MODIFIER_VALUE = lambda x: x if x is not None else 'none'
   109 
   110 
   110 CONTACT_TYPES = {(True, "none"): CONTACT_REVERSE,
   111 CONTACT_TYPES = {(True, "none"): CONTACT_REVERSE,
   111                  (False, "rising"): CONTACT_RISING,
   112                  (False, "rising"): CONTACT_RISING,
   112                  (False, "falling"): CONTACT_FALLING}
   113                  (False, "falling"): CONTACT_FALLING}
   113 
   114 
   114 def contactCreationFunction(viewer, id, specific_values):
   115 def contactCreationFunction(viewer, id, specific_values):
   115     contact_type = CONTACT_TYPES.get((specific_values.negated, 
   116     contact_type = CONTACT_TYPES.get((NEGATED_VALUE(specific_values.negated), 
   116                                       MODIFIER_VALUE(specific_values.edge)),
   117                                       MODIFIER_VALUE(specific_values.edge)),
   117                                      CONTACT_NORMAL)
   118                                      CONTACT_NORMAL)
   118     return LD_Contact(viewer, contact_type, specific_values.name, id)
   119     return LD_Contact(viewer, contact_type, specific_values.name, id)
   119 
   120 
   120 COIL_TYPES = {(True, "none", "none"): COIL_REVERSE,
   121 COIL_TYPES = {(True, "none", "none"): COIL_REVERSE,
   122               (False, "none", "reset"): COIL_RESET,
   123               (False, "none", "reset"): COIL_RESET,
   123               (False, "rising", "none"): COIL_RISING,
   124               (False, "rising", "none"): COIL_RISING,
   124               (False, "falling", "none"): COIL_FALLING}
   125               (False, "falling", "none"): COIL_FALLING}
   125 
   126 
   126 def coilCreationFunction(viewer, id, specific_values):
   127 def coilCreationFunction(viewer, id, specific_values):
   127     coil_type = COIL_TYPES.get((specific_values.negated, 
   128     coil_type = COIL_TYPES.get((NEGATED_VALUE(specific_values.negated), 
   128                                 MODIFIER_VALUE(specific_values.edge),
   129                                 MODIFIER_VALUE(specific_values.edge),
   129                                 MODIFIER_VALUE(specific_values.storage)),
   130                                 MODIFIER_VALUE(specific_values.storage)),
   130                                COIL_NORMAL)
   131                                COIL_NORMAL)
   131     return LD_Coil(viewer, coil_type, specific_values.name, id)
   132     return LD_Coil(viewer, coil_type, specific_values.name, id)
   132 
   133