controls/VariablePanel.py
changeset 1734 750eeb7230a1
parent 1731 6ebd9c40b2be
child 1736 7e61baa047f0
equal deleted inserted replaced
1733:dea107dce0c4 1734:750eeb7230a1
   250         message = None
   250         message = None
   251         element_type = self.ParentWindow.ElementType
   251         element_type = self.ParentWindow.ElementType
   252         try:
   252         try:
   253             values = eval(data)
   253             values = eval(data)
   254         except:
   254         except:
   255             message = _("Invalid value \"%s\" for variable grid element")%data
   255             message = _("Invalid value \"%s\" for variable grid element") % data
   256             values = None
   256             values = None
   257         if not isinstance(values, TupleType):
   257         if not isinstance(values, TupleType):
   258             message = _("Invalid value \"%s\" for variable grid element")%data
   258             message = _("Invalid value \"%s\" for variable grid element") % data
   259             values = None
   259             values = None
   260         if values is not None:
   260         if values is not None:
   261             if col != wx.NOT_FOUND and row != wx.NOT_FOUND:
   261             if col != wx.NOT_FOUND and row != wx.NOT_FOUND:
   262                 colname = self.ParentWindow.Table.GetColLabelValue(col, False)
   262                 colname = self.ParentWindow.Table.GetColLabelValue(col, False)
   263                 if colname == "Location" and values[1] == "location":
   263                 if colname == "Location" and values[1] == "location":
   277                                           format(a1 = values[2], a2 = variable_type)
   277                                           format(a1 = values[2], a2 = variable_type)
   278 
   278 
   279                         if message is None:
   279                         if message is None:
   280                             if not location.startswith("%"):
   280                             if not location.startswith("%"):
   281                                 if location[0].isdigit() and base_type != "BOOL":
   281                                 if location[0].isdigit() and base_type != "BOOL":
   282                                     message = _("Incompatible size of data between \"%s\" and \"BOOL\"")%location
   282                                     message = _("Incompatible size of data between \"%s\" and \"BOOL\"") % location
   283                                 elif location[0] not in LOCATIONDATATYPES:
   283                                 elif location[0] not in LOCATIONDATATYPES:
   284                                     message = _("Unrecognized data size \"%s\"")%location[0]
   284                                     message = _("Unrecognized data size \"%s\"") % location[0]
   285                                 elif base_type not in LOCATIONDATATYPES[location[0]]:
   285                                 elif base_type not in LOCATIONDATATYPES[location[0]]:
   286                                     message = _("Incompatible size of data between \"{a1}\" and \"{a2}\"").\
   286                                     message = _("Incompatible size of data between \"{a1}\" and \"{a2}\"").\
   287                                               format(a1 = location, a2 = variable_type)
   287                                               format(a1 = location, a2 = variable_type)
   288                                 else:
   288                                 else:
   289                                     dialog = wx.SingleChoiceDialog(self.ParentWindow.ParentWindow.ParentWindow,
   289                                     dialog = wx.SingleChoiceDialog(self.ParentWindow.ParentWindow.ParentWindow,
   333                 if var_name is None:
   333                 if var_name is None:
   334                     return
   334                     return
   335                 elif var_name.upper() in [name.upper()
   335                 elif var_name.upper() in [name.upper()
   336                         for name in self.ParentWindow.Controler.\
   336                         for name in self.ParentWindow.Controler.\
   337                             GetProjectPouNames(self.ParentWindow.Debug)]:
   337                             GetProjectPouNames(self.ParentWindow.Debug)]:
   338                     message = _("\"%s\" pou already exists!")%var_name
   338                     message = _("\"%s\" pou already exists!") % var_name
   339                 elif not var_name.upper() in [name.upper()
   339                 elif not var_name.upper() in [name.upper()
   340                         for name in self.ParentWindow.Controler.\
   340                         for name in self.ParentWindow.Controler.\
   341                             GetEditedElementVariables(tagname, self.ParentWindow.Debug)]:
   341                             GetEditedElementVariables(tagname, self.ParentWindow.Debug)]:
   342                     var_infos = self.ParentWindow.DefaultValue.copy()
   342                     var_infos = self.ParentWindow.DefaultValue.copy()
   343                     var_infos.Name = var_name
   343                     var_infos.Name = var_name
   391                     var_infos.Number = len(self.ParentWindow.Values)
   391                     var_infos.Number = len(self.ParentWindow.Values)
   392                     self.ParentWindow.Values.append(var_infos)
   392                     self.ParentWindow.Values.append(var_infos)
   393                     self.ParentWindow.SaveValues()
   393                     self.ParentWindow.SaveValues()
   394                     self.ParentWindow.RefreshValues()
   394                     self.ParentWindow.RefreshValues()
   395                 else:
   395                 else:
   396                     message = _("\"%s\" element for this pou already exists!")%var_name
   396                     message = _("\"%s\" element for this pou already exists!") % var_name
   397 
   397 
   398         if message is not None:
   398         if message is not None:
   399             wx.CallAfter(self.ShowMessage, message)
   399             wx.CallAfter(self.ShowMessage, message)
   400 
   400 
   401     def ShowMessage(self, message):
   401     def ShowMessage(self, message):