dialogs/LDElementDialog.py
branchpython3
changeset 3750 f62625418bff
parent 3303 0ffb41625592
equal deleted inserted replaced
3749:fda6c1a37662 3750:f62625418bff
    22 # You should have received a copy of the GNU General Public License
    22 # You should have received a copy of the GNU General Public License
    23 # along with this program; if not, write to the Free Software
    23 # along with this program; if not, write to the Free Software
    24 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
    24 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
    25 
    25 
    26 
    26 
    27 from __future__ import absolute_import
    27 
    28 import wx
    28 import wx
    29 
    29 
    30 from graphics.GraphicCommons import CONTACT_NORMAL, CONTACT_REVERSE, \
    30 from graphics.GraphicCommons import CONTACT_NORMAL, CONTACT_REVERSE, \
    31     CONTACT_RISING, CONTACT_FALLING, COIL_NORMAL, COIL_REVERSE, COIL_SET, \
    31     CONTACT_RISING, CONTACT_FALLING, COIL_NORMAL, COIL_REVERSE, COIL_SET, \
    32     COIL_RESET, COIL_RISING, COIL_FALLING
    32     COIL_RESET, COIL_RISING, COIL_FALLING
   115 
   115 
   116         # Extract list of variables defined in POU
   116         # Extract list of variables defined in POU
   117         self.RefreshVariableList()
   117         self.RefreshVariableList()
   118 
   118 
   119         # Set values in ElementVariable
   119         # Set values in ElementVariable
   120         for name, (var_type, value_type) in self.VariableList.iteritems():
   120         for name, (var_type, value_type) in self.VariableList.items():
   121             # Only select BOOL variable and avoid input for coil
   121             # Only select BOOL variable and avoid input for coil
   122             if (type == "contact" or var_type != "Input") and \
   122             if (type == "contact" or var_type != "Input") and \
   123                value_type == "BOOL":
   123                value_type == "BOOL":
   124                 self.ElementVariable.Append(name)
   124                 self.ElementVariable.Append(name)
   125 
   125 
   132         Return modifier selected for LD element
   132         Return modifier selected for LD element
   133         @return: Modifier selected (None if not found)
   133         @return: Modifier selected (None if not found)
   134         """
   134         """
   135         # Go through radio buttons and return modifier associated to the one
   135         # Go through radio buttons and return modifier associated to the one
   136         # that is selected
   136         # that is selected
   137         for modifier, control in self.ModifierRadioButtons.iteritems():
   137         for modifier, control in self.ModifierRadioButtons.items():
   138             if control.GetValue():
   138             if control.GetValue():
   139                 return modifier
   139                 return modifier
   140         return None
   140         return None
   141 
   141 
   142     def SetValues(self, values):
   142     def SetValues(self, values):
   143         """
   143         """
   144         Set default LD element parameters
   144         Set default LD element parameters
   145         @param values: LD element parameters values
   145         @param values: LD element parameters values
   146         """
   146         """
   147         # For each parameters defined, set corresponding control value
   147         # For each parameters defined, set corresponding control value
   148         for name, value in values.items():
   148         for name, value in list(values.items()):
   149 
   149 
   150             # Parameter is LD element variable
   150             # Parameter is LD element variable
   151             if name == "variable":
   151             if name == "variable":
   152                 self.ElementVariable.SetValue(value)
   152                 self.ElementVariable.SetValue(value)
   153 
   153