DataTypeEditor.py
author etisserant
Tue, 19 Aug 2008 18:06:41 +0200
changeset 233 de7ddb376150
parent 231 fc2d6cbb8b39
child 235 7b58a3b5b6ec
permissions -rw-r--r--
Now generated global variable declaration is done in one separate block. Also "fixed" (masked?) problem when deleting blocks with invalid type
125
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
     1
#!/usr/bin/env python
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
     2
# -*- coding: utf-8 -*-
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
     3
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
     4
#This file is part of PLCOpenEditor, a library implementing an IEC 61131-3 editor
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
     5
#based on the plcopen standard. 
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
     6
#
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
     7
#Copyright (C) 2007: Edouard TISSERANT and Laurent BESSARD
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
     8
#
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
     9
#See COPYING file for copyrights details.
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
    10
#
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
    11
#This library is free software; you can redistribute it and/or
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
    12
#modify it under the terms of the GNU General Public
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
    13
#License as published by the Free Software Foundation; either
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
    14
#version 2.1 of the License, or (at your option) any later version.
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
    15
#
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
    16
#This library is distributed in the hope that it will be useful,
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
    17
#but WITHOUT ANY WARRANTY; without even the implied warranty of
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
    18
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
    19
#General Public License for more details.
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
    20
#
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
    21
#You should have received a copy of the GNU General Public
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
    22
#License along with this library; if not, write to the Free Software
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
    23
#Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
    24
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
    25
import wx
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
    26
import wx.grid
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
    27
import wx.gizmos
231
fc2d6cbb8b39 Adding support for highlighing compiling errors from matiec
lbessard
parents: 215
diff changeset
    28
from plcopen.structures import IEC_KEYWORDS
125
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
    29
207
b1144bb36605 Bug with array dimensions edition fixed
lbessard
parents: 205
diff changeset
    30
import re
b1144bb36605 Bug with array dimensions edition fixed
lbessard
parents: 205
diff changeset
    31
b1144bb36605 Bug with array dimensions edition fixed
lbessard
parents: 205
diff changeset
    32
DIMENSION_MODEL = re.compile("([0-9]+)\.\.([0-9]+)$")
b1144bb36605 Bug with array dimensions edition fixed
lbessard
parents: 205
diff changeset
    33
125
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
    34
if wx.VERSION >= (2, 8, 0):
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
    35
    import wx.aui
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
    36
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
    37
    class MDIDataTypeEditor(wx.aui.AuiMDIChildFrame):
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
    38
        def __init__(self, parent, tagname, window, controler):
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
    39
            wx.aui.AuiMDIChildFrame.__init__(self, parent, -1, title = "")
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
    40
            
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
    41
            sizer = wx.BoxSizer(wx.HORIZONTAL)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
    42
            
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
    43
            self.Viewer = DataTypeEditor(self, tagname, window, controler)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
    44
            
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
    45
            sizer.AddWindow(self.Viewer, 1, border=0, flag=wx.GROW)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
    46
            
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
    47
            self.SetSizer(sizer)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
    48
        
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
    49
        def GetViewer(self):
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
    50
            return self.Viewer
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
    51
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
    52
#-------------------------------------------------------------------------------
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
    53
#                          Configuration Editor class
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
    54
#-------------------------------------------------------------------------------
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
    55
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
    56
[ID_DATATYPEEDITOR, ID_DATATYPEEDITORSTATICBOX,
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
    57
 ID_DATATYPEEDITORDERIVATIONTYPE, ID_DATATYPEEDITORDIRECTLYPANEL,
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
    58
 ID_DATATYPEEDITORSUBRANGEPANEL, ID_DATATYPEEDITORDIRECTLYBASETYPE, 
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
    59
 ID_DATATYPEEDITORSUBRANGEBASETYPE, ID_DATATYPEEDITORSUBRANGEMINIMUM, 
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
    60
 ID_DATATYPEEDITORSUBRANGEMAXIMUM, ID_DATATYPEEDITORDIRECTLYINITIALVALUE, 
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
    61
 ID_DATATYPEEDITORSUBRANGEINITIALVALUE, ID_DATATYPEEDITORENUMERATEDPANEL,
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
    62
 ID_DATATYPEEDITORENUMERATEDVALUES, ID_DATATYPEEDITORENUMERATEDINITIALVALUE,
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
    63
 ID_DATATYPEEDITORARRAYPANEL, ID_DATATYPEEDITORARRAYBASETYPE, 
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
    64
 ID_DATATYPEEDITORARRAYDIMENSIONS, ID_DATATYPEEDITORARRAYINITIALVALUE, 
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
    65
 ID_DATATYPEEDITORSTATICTEXT1, ID_DATATYPEEDITORSTATICTEXT2, 
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
    66
 ID_DATATYPEEDITORSTATICTEXT3, ID_DATATYPEEDITORSTATICTEXT4, 
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
    67
 ID_DATATYPEEDITORSTATICTEXT5, ID_DATATYPEEDITORSTATICTEXT6, 
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
    68
 ID_DATATYPEEDITORSTATICTEXT7, ID_DATATYPEEDITORSTATICTEXT8,
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
    69
 ID_DATATYPEEDITORSTATICTEXT9, ID_DATATYPEEDITORSTATICTEXT10, 
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
    70
] = [wx.NewId() for _init_ctrls in range(28)]
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
    71
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
    72
class DataTypeEditor(wx.Panel):
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
    73
    
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
    74
    def _init_coll_MainSizer_Items(self, parent):
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
    75
        parent.AddSizer(self.TopSizer, 0, border=5, flag=wx.GROW|wx.TOP|wx.LEFT|wx.RIGHT)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
    76
        parent.AddSizer(self.TypeInfosSizer, 0, border=5, flag=wx.GROW|wx.BOTTOM|wx.LEFT|wx.RIGHT)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
    77
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
    78
    def _init_coll_MainSizer_Growables(self, parent):
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
    79
        parent.AddGrowableCol(0)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
    80
        parent.AddGrowableRow(1)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
    81
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
    82
    def _init_coll_TopSizer_Items(self, parent):
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
    83
        parent.AddWindow(self.staticText1, 0, border=5, flag=wx.GROW|wx.LEFT)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
    84
        parent.AddWindow(self.DerivationType, 0, border=0, flag=wx.GROW)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
    85
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
    86
    def _init_coll_TypeInfosSizer_Items(self, parent):
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
    87
        parent.AddWindow(self.DirectlyPanel, 1, border=0, flag=wx.ALL)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
    88
        parent.AddWindow(self.SubrangePanel, 1, border=0, flag=wx.ALL)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
    89
        parent.AddWindow(self.EnumeratedPanel, 1, border=0, flag=wx.GROW|wx.ALL)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
    90
        parent.AddWindow(self.ArrayPanel, 1, border=0, flag=wx.ALL)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
    91
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
    92
    def _init_coll_DirectlyPanelSizer_Items(self, parent):
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
    93
        parent.AddWindow(self.staticText2, 1, border=5, flag=wx.GROW|wx.ALL)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
    94
        parent.AddWindow(self.DirectlyBaseType, 1, border=5, flag=wx.GROW|wx.ALL)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
    95
        parent.AddWindow(self.staticText3, 1, border=5, flag=wx.GROW|wx.ALL)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
    96
        parent.AddWindow(self.DirectlyInitialValue, 1, border=5, flag=wx.GROW|wx.ALL)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
    97
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
    98
    def _init_coll_SubrangePanelSizer_Items(self, parent):
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
    99
        parent.AddWindow(self.staticText4, 1, border=5, flag=wx.GROW|wx.ALL)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   100
        parent.AddWindow(self.SubrangeBaseType, 1, border=5, flag=wx.GROW|wx.ALL)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   101
        parent.AddWindow(self.staticText5, 1, border=5, flag=wx.GROW|wx.ALL)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   102
        parent.AddWindow(self.SubrangeInitialValue, 1, border=5, flag=wx.GROW|wx.ALL)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   103
        parent.AddWindow(self.staticText6, 1, border=5, flag=wx.GROW|wx.ALL)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   104
        parent.AddWindow(self.SubrangeMinimum, 1, border=5, flag=wx.GROW|wx.ALL)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   105
        parent.AddWindow(wx.Size(0, 0), 1, border=5, flag=wx.GROW|wx.ALL)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   106
        parent.AddWindow(wx.Size(0, 0), 1, border=5, flag=wx.GROW|wx.ALL)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   107
        parent.AddWindow(self.staticText7, 1, border=5, flag=wx.GROW|wx.ALL)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   108
        parent.AddWindow(self.SubrangeMaximum, 1, border=5, flag=wx.GROW|wx.ALL)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   109
        
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   110
    def _init_coll_EnumeratedPanelSizer_Items(self, parent):
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   111
        parent.AddWindow(self.EnumeratedValues, 2, border=5, flag=wx.GROW|wx.ALL)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   112
        parent.AddWindow(self.staticText8, 1, border=5, flag=wx.GROW|wx.ALL)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   113
        parent.AddWindow(self.EnumeratedInitialValue, 1, border=5, flag=wx.ALL)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   114
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   115
    def _init_coll_ArrayPanelSizer_Items(self, parent):
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   116
        parent.AddSizer(self.ArrayPanelLeftSizer, 0, border=0, flag=wx.GROW)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   117
        parent.AddSizer(self.ArrayPanelRightSizer, 0, border=0, flag=wx.GROW)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   118
        parent.AddWindow(self.ArrayDimensions, 0, border=5, flag=wx.GROW|wx.ALL)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   119
        
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   120
    def _init_coll_ArrayPanelSizer_Growables(self, parent):
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   121
        parent.AddGrowableCol(0)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   122
        parent.AddGrowableCol(1)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   123
        parent.AddGrowableRow(1)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   124
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   125
    def _init_coll_ArrayPanelLeftSizer_Items(self, parent):
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   126
        parent.AddWindow(self.staticText9, 1, border=5, flag=wx.GROW|wx.ALL)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   127
        parent.AddWindow(self.ArrayBaseType, 1, border=5, flag=wx.GROW|wx.ALL)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   128
    
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   129
    def _init_coll_ArrayPanelRightSizer_Items(self, parent):
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   130
        parent.AddWindow(self.staticText10, 1, border=5, flag=wx.GROW|wx.ALL)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   131
        parent.AddWindow(self.ArrayInitialValue, 1, border=5, flag=wx.GROW|wx.ALL)    
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   132
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   133
    def _init_sizers(self):
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   134
        self.MainSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=10)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   135
        self.TopSizer = wx.BoxSizer(wx.HORIZONTAL)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   136
        self.TypeInfosSizer = wx.StaticBoxSizer(self.staticbox, wx.HORIZONTAL)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   137
        self.DirectlyPanelSizer = wx.BoxSizer(wx.HORIZONTAL)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   138
        self.SubrangePanelSizer = wx.GridSizer(cols=4, hgap=0, rows=3, vgap=0)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   139
        self.EnumeratedPanelSizer = wx.BoxSizer(wx.HORIZONTAL)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   140
        self.ArrayPanelSizer = wx.FlexGridSizer(cols=2, hgap=0, rows=2, vgap=0)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   141
        self.ArrayPanelLeftSizer = wx.BoxSizer(wx.HORIZONTAL)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   142
        self.ArrayPanelRightSizer = wx.BoxSizer(wx.HORIZONTAL)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   143
        
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   144
        self._init_coll_MainSizer_Items(self.MainSizer)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   145
        self._init_coll_MainSizer_Growables(self.MainSizer)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   146
        self._init_coll_TopSizer_Items(self.TopSizer)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   147
        self._init_coll_TypeInfosSizer_Items(self.TypeInfosSizer)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   148
        self._init_coll_DirectlyPanelSizer_Items(self.DirectlyPanelSizer)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   149
        self._init_coll_SubrangePanelSizer_Items(self.SubrangePanelSizer)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   150
        self._init_coll_EnumeratedPanelSizer_Items(self.EnumeratedPanelSizer)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   151
        self._init_coll_ArrayPanelSizer_Items(self.ArrayPanelSizer)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   152
        self._init_coll_ArrayPanelSizer_Growables(self.ArrayPanelSizer)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   153
        self._init_coll_ArrayPanelLeftSizer_Items(self.ArrayPanelLeftSizer)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   154
        self._init_coll_ArrayPanelRightSizer_Items(self.ArrayPanelRightSizer)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   155
        
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   156
        self.SetSizer(self.MainSizer)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   157
        self.DirectlyPanel.SetSizer(self.DirectlyPanelSizer)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   158
        self.SubrangePanel.SetSizer(self.SubrangePanelSizer)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   159
        self.EnumeratedPanel.SetSizer(self.EnumeratedPanelSizer)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   160
        self.ArrayPanel.SetSizer(self.ArrayPanelSizer)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   161
    
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   162
    def _init_ctrls(self, prnt):
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   163
        wx.Panel.__init__(self, id=ID_DATATYPEEDITOR, name='', parent=prnt,
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   164
              size=wx.Size(0, 0), style=wx.SUNKEN_BORDER)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   165
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   166
        self.staticbox = wx.StaticBox(id=ID_DATATYPEEDITORSTATICBOX,
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   167
              label='Type infos:', name='staticBox1', parent=self,
231
fc2d6cbb8b39 Adding support for highlighing compiling errors from matiec
lbessard
parents: 215
diff changeset
   168
              pos=wx.Point(0, 0), size=wx.Size(10, 0), style=0)
125
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   169
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   170
        self.staticText1 = wx.StaticText(id=ID_DATATYPEEDITORSTATICTEXT1,
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   171
              label='Derivation Type:', name='staticText1', parent=self,
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   172
              pos=wx.Point(0, 0), size=wx.Size(150, 17), style=0)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   173
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   174
        self.DerivationType = wx.Choice(id=ID_DATATYPEEDITORDERIVATIONTYPE,
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   175
              name='DerivationType', parent=self, pos=wx.Point(0, 0),
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   176
              size=wx.Size(200, 24), style=0)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   177
        self.Bind(wx.EVT_CHOICE, self.OnDerivationTypeChanged, id=ID_DATATYPEEDITORDERIVATIONTYPE)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   178
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   179
        # Panel for Directly derived data types
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   180
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   181
        self.DirectlyPanel = wx.Panel(id=ID_DATATYPEEDITORDIRECTLYPANEL,
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   182
              name='DirectlyPanel', parent=self, pos=wx.Point(0, 0),
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   183
              size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   184
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   185
        self.staticText2 = wx.StaticText(id=ID_DATATYPEEDITORSTATICTEXT2,
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   186
              label='Base Type:', name='staticText2', parent=self.DirectlyPanel,
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   187
              pos=wx.Point(0, 0), size=wx.Size(150, 17), style=0)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   188
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   189
        self.DirectlyBaseType = wx.Choice(id=ID_DATATYPEEDITORDIRECTLYBASETYPE, 
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   190
              name='DirectlyBaseType', parent=self.DirectlyPanel, pos=wx.Point(0, 0),
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   191
              size=wx.Size(0, 24), style=wx.TAB_TRAVERSAL)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   192
        self.Bind(wx.EVT_CHOICE, self.OnInfosChanged, id=ID_DATATYPEEDITORDIRECTLYBASETYPE)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   193
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   194
        self.staticText3 = wx.StaticText(id=ID_DATATYPEEDITORSTATICTEXT3,
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   195
              label='Initial Value:', name='staticText3', parent=self.DirectlyPanel,
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   196
              pos=wx.Point(0, 0), size=wx.Size(150, 17), style=0)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   197
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   198
        self.DirectlyInitialValue = wx.TextCtrl(id=ID_DATATYPEEDITORDIRECTLYINITIALVALUE, 
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   199
              name='DirectlyInitialValue', parent=self.DirectlyPanel, pos=wx.Point(0, 0),
231
fc2d6cbb8b39 Adding support for highlighing compiling errors from matiec
lbessard
parents: 215
diff changeset
   200
              size=wx.Size(0, 24), style=wx.TAB_TRAVERSAL|wx.TE_PROCESS_ENTER|wx.TE_MULTILINE|wx.TE_RICH)
fc2d6cbb8b39 Adding support for highlighing compiling errors from matiec
lbessard
parents: 215
diff changeset
   201
        self.Bind(wx.EVT_TEXT_ENTER, self.OnReturnKeyPressed, id=ID_DATATYPEEDITORDIRECTLYINITIALVALUE)
125
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   202
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   203
        # Panel for Subrange data types
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   204
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   205
        self.SubrangePanel = wx.Panel(id=ID_DATATYPEEDITORSUBRANGEPANEL,
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   206
              name='SubrangePanel', parent=self, pos=wx.Point(0, 0),
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   207
              size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   208
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   209
        self.staticText4 = wx.StaticText(id=ID_DATATYPEEDITORSTATICTEXT4,
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   210
              label='Base Type:', name='staticText4', parent=self.SubrangePanel,
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   211
              pos=wx.Point(0, 0), size=wx.Size(150, 17), style=0)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   212
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   213
        self.SubrangeBaseType = wx.Choice(id=ID_DATATYPEEDITORSUBRANGEBASETYPE, 
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   214
              name='SubrangeBaseType', parent=self.SubrangePanel, pos=wx.Point(0, 0),
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   215
              size=wx.Size(0, 24), style=wx.TAB_TRAVERSAL)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   216
        self.Bind(wx.EVT_CHOICE, self.OnSubrangeBaseTypeChanged, id=ID_DATATYPEEDITORSUBRANGEBASETYPE)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   217
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   218
        self.staticText5 = wx.StaticText(id=ID_DATATYPEEDITORSTATICTEXT5,
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   219
              label='Initial Value:', name='staticText5', parent=self.SubrangePanel,
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   220
              pos=wx.Point(0, 0), size=wx.Size(150, 17), style=0)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   221
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   222
        self.SubrangeInitialValue = wx.SpinCtrl(id=ID_DATATYPEEDITORSUBRANGEINITIALVALUE, 
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   223
              name='SubrangeInitialValue', parent=self.SubrangePanel, pos=wx.Point(0, 0),
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   224
              size=wx.Size(0, 24), style=wx.TAB_TRAVERSAL)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   225
        self.Bind(wx.EVT_SPINCTRL, self.OnInfosChanged, id=ID_DATATYPEEDITORSUBRANGEINITIALVALUE)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   226
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   227
        self.staticText6 = wx.StaticText(id=ID_DATATYPEEDITORSTATICTEXT6,
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   228
              label='Minimum:', name='staticText6', parent=self.SubrangePanel,
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   229
              pos=wx.Point(0, 0), size=wx.Size(150, 17), style=0)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   230
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   231
        self.SubrangeMinimum = wx.SpinCtrl(id=ID_DATATYPEEDITORSUBRANGEMINIMUM, 
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   232
              name='SubrangeMinimum', parent=self.SubrangePanel, pos=wx.Point(0, 0),
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   233
              size=wx.Size(0, 24), style=wx.TAB_TRAVERSAL)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   234
        self.Bind(wx.EVT_SPINCTRL, self.OnSubrangeMinimumChanged, id=ID_DATATYPEEDITORSUBRANGEMINIMUM)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   235
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   236
        self.staticText7 = wx.StaticText(id=ID_DATATYPEEDITORSTATICTEXT7,
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   237
              label='Maximum:', name='staticText7', parent=self.SubrangePanel,
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   238
              pos=wx.Point(0, 0), size=wx.Size(150, 17), style=0)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   239
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   240
        self.SubrangeMaximum = wx.SpinCtrl(id=ID_DATATYPEEDITORSUBRANGEMAXIMUM, 
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   241
              name='SubrangeMaximum', parent=self.SubrangePanel, pos=wx.Point(0, 0),
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   242
              size=wx.Size(0, 24), style=wx.TAB_TRAVERSAL)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   243
        self.Bind(wx.EVT_SPINCTRL, self.OnSubrangeMaximumChanged, id=ID_DATATYPEEDITORSUBRANGEMAXIMUM)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   244
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   245
        # Panel for Enumerated data types
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   246
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   247
        self.EnumeratedPanel = wx.Panel(id=ID_DATATYPEEDITORENUMERATEDPANEL,
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   248
              name='EnumeratedPanel', parent=self, pos=wx.Point(0, 0),
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   249
              size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   250
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   251
        self.EnumeratedValues = wx.gizmos.EditableListBox(id=ID_DATATYPEEDITORENUMERATEDVALUES, 
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   252
              name='EnumeratedValues', parent=self.EnumeratedPanel, label="Values:", pos=wx.Point(0, 0),
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   253
              size=wx.Size(0, 0), style=wx.gizmos.EL_ALLOW_NEW | wx.gizmos.EL_ALLOW_EDIT | wx.gizmos.EL_ALLOW_DELETE)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   254
        self.EnumeratedValues.GetListCtrl().Bind(wx.EVT_LIST_END_LABEL_EDIT, self.OnEnumeratedValueEndEdit)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   255
        self.EnumeratedValues.GetNewButton().Bind(wx.EVT_BUTTON, self.OnEnumeratedValuesChanged)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   256
        self.EnumeratedValues.GetDelButton().Bind(wx.EVT_BUTTON, self.OnEnumeratedValuesChanged)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   257
        self.EnumeratedValues.GetUpButton().Bind(wx.EVT_BUTTON, self.OnEnumeratedValuesChanged)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   258
        self.EnumeratedValues.GetDownButton().Bind(wx.EVT_BUTTON, self.OnEnumeratedValuesChanged)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   259
        
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   260
        self.staticText8 = wx.StaticText(id=ID_DATATYPEEDITORSTATICTEXT8,
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   261
              label='Initial Value:', name='staticText8', parent=self.EnumeratedPanel,
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   262
              pos=wx.Point(0, 0), size=wx.Size(150, 17), style=0)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   263
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   264
        self.EnumeratedInitialValue = wx.Choice(id=ID_DATATYPEEDITORENUMERATEDINITIALVALUE, 
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   265
              name='EnumeratedInitialValue', parent=self.EnumeratedPanel, pos=wx.Point(0, 0),
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   266
              size=wx.Size(0, 24), style=wx.TAB_TRAVERSAL|wx.TE_PROCESS_ENTER)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   267
        self.Bind(wx.EVT_CHOICE, self.OnInfosChanged, id=ID_DATATYPEEDITORENUMERATEDINITIALVALUE)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   268
        
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   269
        # Panel for Array data types
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   270
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   271
        self.ArrayPanel = wx.Panel(id=ID_DATATYPEEDITORARRAYPANEL,
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   272
              name='ArrayPanel', parent=self, pos=wx.Point(0, 0),
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   273
              size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   274
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   275
        self.staticText9 = wx.StaticText(id=ID_DATATYPEEDITORSTATICTEXT9,
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   276
              label='Base Type:', name='staticText9', parent=self.ArrayPanel,
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   277
              pos=wx.Point(0, 0), size=wx.Size(150, 17), style=0)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   278
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   279
        self.ArrayBaseType = wx.Choice(id=ID_DATATYPEEDITORARRAYBASETYPE, 
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   280
              name='SubrangeBaseType', parent=self.ArrayPanel, pos=wx.Point(0, 0),
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   281
              size=wx.Size(0, 24), style=wx.TAB_TRAVERSAL)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   282
        self.Bind(wx.EVT_CHOICE, self.OnInfosChanged, id=ID_DATATYPEEDITORARRAYBASETYPE)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   283
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   284
        self.ArrayDimensions = wx.gizmos.EditableListBox(id=ID_DATATYPEEDITORARRAYDIMENSIONS, 
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   285
              name='ArrayDimensions', parent=self.ArrayPanel, label="Dimensions:", pos=wx.Point(0, 0),
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   286
              size=wx.Size(0, 24), style=wx.gizmos.EL_ALLOW_NEW | wx.gizmos.EL_ALLOW_EDIT | wx.gizmos.EL_ALLOW_DELETE)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   287
        self.ArrayDimensions.GetListCtrl().Bind(wx.EVT_LIST_END_LABEL_EDIT, self.OnDimensionsChanged)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   288
        self.ArrayDimensions.GetNewButton().Bind(wx.EVT_BUTTON, self.OnDimensionsChanged)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   289
        self.ArrayDimensions.GetDelButton().Bind(wx.EVT_BUTTON, self.OnDimensionsChanged)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   290
        self.ArrayDimensions.GetUpButton().Bind(wx.EVT_BUTTON, self.OnDimensionsChanged)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   291
        self.ArrayDimensions.GetDownButton().Bind(wx.EVT_BUTTON, self.OnDimensionsChanged)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   292
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   293
        self.staticText10 = wx.StaticText(id=ID_DATATYPEEDITORSTATICTEXT10,
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   294
              label='Initial Value:', name='staticText10', parent=self.ArrayPanel,
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   295
              pos=wx.Point(0, 0), size=wx.Size(150, 17), style=0)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   296
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   297
        self.ArrayInitialValue = wx.TextCtrl(id=ID_DATATYPEEDITORARRAYINITIALVALUE, 
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   298
              name='ArrayInitialValue', parent=self.ArrayPanel, pos=wx.Point(0, 0),
231
fc2d6cbb8b39 Adding support for highlighing compiling errors from matiec
lbessard
parents: 215
diff changeset
   299
              size=wx.Size(0, 24), style=wx.TAB_TRAVERSAL|wx.TE_PROCESS_ENTER|wx.TE_MULTILINE|wx.TE_RICH)
fc2d6cbb8b39 Adding support for highlighing compiling errors from matiec
lbessard
parents: 215
diff changeset
   300
        self.Bind(wx.EVT_TEXT_ENTER, self.OnReturnKeyPressed, id=ID_DATATYPEEDITORARRAYINITIALVALUE)
125
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   301
        
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   302
        self._init_sizers()
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   303
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   304
    def __init__(self, parent, tagname, window, controler):
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   305
        self._init_ctrls(parent)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   306
        
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   307
        self.DerivationType.Append("Directly")
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   308
        self.DerivationType.Append("Subrange")
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   309
        self.DerivationType.Append("Enumerated")
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   310
        self.DerivationType.Append("Array")
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   311
        self.SubrangePanel.Hide()
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   312
        self.EnumeratedPanel.Hide()
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   313
        self.ArrayPanel.Hide()
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   314
        self.CurrentPanel = "Directly"
231
fc2d6cbb8b39 Adding support for highlighing compiling errors from matiec
lbessard
parents: 215
diff changeset
   315
        self.Errors = []
130
38421cd7c8ff Bug on subrange SpinCtrls with Windows fixed
lbessard
parents: 125
diff changeset
   316
        self.Initializing = False
125
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   317
        
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   318
        self.ParentWindow = window
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   319
        self.Controler = controler
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   320
        self.TagName = tagname
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   321
    
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   322
    def OnEnumeratedValueEndEdit(self, event):
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   323
        text = event.GetText()
192
50926b8abac4 Bug on Enumerated DataType values defining fixed
lbessard
parents: 150
diff changeset
   324
        values = self.EnumeratedValues.GetStrings()
50926b8abac4 Bug on Enumerated DataType values defining fixed
lbessard
parents: 150
diff changeset
   325
        index = event.GetIndex()
50926b8abac4 Bug on Enumerated DataType values defining fixed
lbessard
parents: 150
diff changeset
   326
        if index >= len(values) or values[index].upper() != text.upper():
50926b8abac4 Bug on Enumerated DataType values defining fixed
lbessard
parents: 150
diff changeset
   327
            if text.upper() in [value.upper() for value in values]:
150
f7832baaad84 Bug on enumerated datatype values editor fixed
lbessard
parents: 130
diff changeset
   328
                message = wx.MessageDialog(self, "\"%s\" value already defined!"%text, "Error", wx.OK|wx.ICON_ERROR)
f7832baaad84 Bug on enumerated datatype values editor fixed
lbessard
parents: 130
diff changeset
   329
                message.ShowModal()
f7832baaad84 Bug on enumerated datatype values editor fixed
lbessard
parents: 130
diff changeset
   330
                message.Destroy()
f7832baaad84 Bug on enumerated datatype values editor fixed
lbessard
parents: 130
diff changeset
   331
                event.Veto()
f7832baaad84 Bug on enumerated datatype values editor fixed
lbessard
parents: 130
diff changeset
   332
            elif text.upper() in IEC_KEYWORDS:
f7832baaad84 Bug on enumerated datatype values editor fixed
lbessard
parents: 130
diff changeset
   333
                message = wx.MessageDialog(self, "\"%s\" is a keyword. It can't be used!"%text, "Error", wx.OK|wx.ICON_ERROR)
f7832baaad84 Bug on enumerated datatype values editor fixed
lbessard
parents: 130
diff changeset
   334
                message.ShowModal()
f7832baaad84 Bug on enumerated datatype values editor fixed
lbessard
parents: 130
diff changeset
   335
                message.Destroy()
f7832baaad84 Bug on enumerated datatype values editor fixed
lbessard
parents: 130
diff changeset
   336
            else:
f7832baaad84 Bug on enumerated datatype values editor fixed
lbessard
parents: 130
diff changeset
   337
                wx.CallAfter(self.RefreshEnumeratedValues)
f7832baaad84 Bug on enumerated datatype values editor fixed
lbessard
parents: 130
diff changeset
   338
                wx.CallAfter(self.RefreshTypeInfos)
f7832baaad84 Bug on enumerated datatype values editor fixed
lbessard
parents: 130
diff changeset
   339
                event.Skip()
125
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   340
        else:
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   341
            wx.CallAfter(self.RefreshEnumeratedValues)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   342
            wx.CallAfter(self.RefreshTypeInfos)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   343
            event.Skip()
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   344
    
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   345
    def OnEnumeratedValuesChanged(self, event):
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   346
        wx.CallAfter(self.RefreshEnumeratedValues)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   347
        wx.CallAfter(self.RefreshTypeInfos)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   348
        event.Skip()
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   349
    
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   350
    def SetTagName(self, tagname):
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   351
        self.TagName = tagname
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   352
        
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   353
    def GetTagName(self):
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   354
        return self.TagName
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   355
    
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   356
    def IsViewing(self, tagname):
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   357
        return self.TagName == tagname
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   358
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   359
    def SetMode(self, mode):
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   360
        pass
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   361
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   362
    def ResetBuffer(self):
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   363
        pass
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   364
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   365
    def RefreshView(self):
130
38421cd7c8ff Bug on subrange SpinCtrls with Windows fixed
lbessard
parents: 125
diff changeset
   366
        self.Initializing = True
125
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   367
        self.DirectlyBaseType.Clear()
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   368
        self.ArrayBaseType.Clear()
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   369
        for datatype in self.Controler.GetDataTypes(self.TagName):
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   370
            self.DirectlyBaseType.Append(datatype)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   371
            self.ArrayBaseType.Append(datatype)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   372
        self.DirectlyBaseType.SetSelection(0)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   373
        self.SubrangeBaseType.Clear()
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   374
        words = self.TagName.split("::")
231
fc2d6cbb8b39 Adding support for highlighing compiling errors from matiec
lbessard
parents: 215
diff changeset
   375
        for base_type in self.Controler.GetSubrangeBaseTypes(words[1]):
125
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   376
            self.SubrangeBaseType.Append(base_type)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   377
        self.SubrangeBaseType.SetSelection(0)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   378
        self.RefreshBoundsRange()
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   379
        type_infos = self.Controler.GetDataTypeInfos(self.TagName)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   380
        if type_infos is not None:
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   381
            self.DerivationType.SetStringSelection(type_infos["type"])
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   382
            if type_infos["type"] == "Directly":
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   383
                self.DirectlyBaseType.SetStringSelection(type_infos["base_type"])
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   384
                self.DirectlyInitialValue.SetValue(type_infos["initial"])
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   385
            elif type_infos["type"] == "Subrange":
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   386
                self.SubrangeBaseType.SetStringSelection(type_infos["base_type"])
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   387
                self.RefreshBoundsRange()
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   388
                self.SubrangeMinimum.SetValue(type_infos["min"])
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   389
                self.SubrangeMaximum.SetValue(type_infos["max"])
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   390
                self.RefreshSubrangeInitialValueRange()
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   391
                if type_infos["initial"] != "":
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   392
                    self.SubrangeInitialValue.SetValue(int(type_infos["initial"]))
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   393
                else:
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   394
                    self.SubrangeInitialValue.SetValue(type_infos["min"])
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   395
            elif type_infos["type"] == "Enumerated":
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   396
                self.EnumeratedValues.SetStrings(type_infos["values"])
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   397
                self.RefreshEnumeratedValues()
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   398
                self.EnumeratedInitialValue.SetStringSelection(type_infos["initial"])
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   399
            elif type_infos["type"] == "Array":
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   400
                self.ArrayBaseType.SetStringSelection(type_infos["base_type"])
207
b1144bb36605 Bug with array dimensions edition fixed
lbessard
parents: 205
diff changeset
   401
                self.ArrayDimensions.SetStrings(map(lambda x : "..".join(map(str, x)), type_infos["dimensions"]))
125
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   402
                self.ArrayInitialValue.SetValue(type_infos["initial"])
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   403
            self.RefreshDisplayedInfos()
231
fc2d6cbb8b39 Adding support for highlighing compiling errors from matiec
lbessard
parents: 215
diff changeset
   404
        self.ShowErrors()
130
38421cd7c8ff Bug on subrange SpinCtrls with Windows fixed
lbessard
parents: 125
diff changeset
   405
        self.Initializing = False
125
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   406
205
f12ad5b87f99 Bug with missing RefreshScaling fixed
lbessard
parents: 192
diff changeset
   407
    def RefreshScaling(self, refresh=True):
f12ad5b87f99 Bug with missing RefreshScaling fixed
lbessard
parents: 192
diff changeset
   408
        pass
f12ad5b87f99 Bug with missing RefreshScaling fixed
lbessard
parents: 192
diff changeset
   409
125
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   410
    def OnDerivationTypeChanged(self, event):
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   411
        self.RefreshDisplayedInfos()
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   412
        self.RefreshTypeInfos()
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   413
        event.Skip()
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   414
231
fc2d6cbb8b39 Adding support for highlighing compiling errors from matiec
lbessard
parents: 215
diff changeset
   415
    def OnReturnKeyPressed(self, event):
fc2d6cbb8b39 Adding support for highlighing compiling errors from matiec
lbessard
parents: 215
diff changeset
   416
        self.RefreshTypeInfos()
fc2d6cbb8b39 Adding support for highlighing compiling errors from matiec
lbessard
parents: 215
diff changeset
   417
        
125
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   418
    def OnInfosChanged(self, event):
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   419
        self.RefreshTypeInfos()
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   420
        event.Skip()
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   421
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   422
    def OnSubrangeBaseTypeChanged(self, event):
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   423
        self.RefreshBoundsRange()
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   424
        self.RefreshTypeInfos()
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   425
        event.Skip()
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   426
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   427
    def OnSubrangeMinimumChanged(self, event):
215
dd3381f38a9e Fixed various bugs
etisserant
parents: 207
diff changeset
   428
        if not self.Initializing:
130
38421cd7c8ff Bug on subrange SpinCtrls with Windows fixed
lbessard
parents: 125
diff changeset
   429
            wx.CallAfter(self.SubrangeMinimum.SetValue, min(self.SubrangeMaximum.GetValue(), self.SubrangeMinimum.GetValue()))
38421cd7c8ff Bug on subrange SpinCtrls with Windows fixed
lbessard
parents: 125
diff changeset
   430
            wx.CallAfter(self.RefreshSubrangeInitialValueRange)
38421cd7c8ff Bug on subrange SpinCtrls with Windows fixed
lbessard
parents: 125
diff changeset
   431
            wx.CallAfter(self.RefreshTypeInfos)
125
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   432
        event.Skip()
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   433
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   434
    def OnSubrangeMaximumChanged(self, event):
215
dd3381f38a9e Fixed various bugs
etisserant
parents: 207
diff changeset
   435
        if not self.Initializing:
130
38421cd7c8ff Bug on subrange SpinCtrls with Windows fixed
lbessard
parents: 125
diff changeset
   436
            wx.CallAfter(self.SubrangeMaximum.SetValue, max(self.SubrangeMinimum.GetValue(), self.SubrangeMaximum.GetValue()))
38421cd7c8ff Bug on subrange SpinCtrls with Windows fixed
lbessard
parents: 125
diff changeset
   437
            wx.CallAfter(self.RefreshSubrangeInitialValueRange)
38421cd7c8ff Bug on subrange SpinCtrls with Windows fixed
lbessard
parents: 125
diff changeset
   438
            wx.CallAfter(self.RefreshTypeInfos)
125
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   439
        event.Skip()
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   440
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   441
    def OnDimensionsChanged(self, event):
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   442
        wx.CallAfter(self.RefreshTypeInfos)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   443
        event.Skip()
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   444
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   445
    def RefreshDisplayedInfos(self):
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   446
        selected = self.DerivationType.GetStringSelection()
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   447
        if selected != self.CurrentPanel:
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   448
            if self.CurrentPanel == "Directly":
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   449
                self.DirectlyPanel.Hide()
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   450
            elif self.CurrentPanel == "Subrange":
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   451
                self.SubrangePanel.Hide()
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   452
            elif self.CurrentPanel == "Enumerated":
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   453
                self.EnumeratedPanel.Hide()
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   454
            elif self.CurrentPanel == "Array":
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   455
                self.ArrayPanel.Hide()
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   456
            self.CurrentPanel = selected
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   457
            if selected == "Directly":
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   458
                self.DirectlyPanel.Show()
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   459
            elif selected == "Subrange":
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   460
                self.SubrangePanel.Show()
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   461
            elif selected == "Enumerated":
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   462
                self.EnumeratedPanel.Show()
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   463
            elif selected == "Array":
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   464
                self.ArrayPanel.Show()
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   465
            self.MainSizer.Layout()
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   466
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   467
    def RefreshEnumeratedValues(self):
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   468
        selected = self.EnumeratedInitialValue.GetStringSelection()
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   469
        self.EnumeratedInitialValue.Clear()
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   470
        self.EnumeratedInitialValue.Append("")
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   471
        for value in self.EnumeratedValues.GetStrings():
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   472
            self.EnumeratedInitialValue.Append(value)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   473
        self.EnumeratedInitialValue.SetStringSelection(selected)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   474
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   475
    def RefreshBoundsRange(self):
231
fc2d6cbb8b39 Adding support for highlighing compiling errors from matiec
lbessard
parents: 215
diff changeset
   476
        range = self.Controler.GetDataTypeRange(self.SubrangeBaseType.GetStringSelection())
125
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   477
        if range is not None:
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   478
            min_value, max_value = range
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   479
            self.SubrangeMinimum.SetRange(min_value, max_value)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   480
            self.SubrangeMinimum.SetValue(min(max(min_value, self.SubrangeMinimum.GetValue()), max_value))
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   481
            self.SubrangeMaximum.SetRange(min_value, max_value)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   482
            self.SubrangeMaximum.SetValue(min(max(min_value, self.SubrangeMaximum.GetValue()), max_value))
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   483
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   484
    def RefreshSubrangeInitialValueRange(self):
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   485
        self.SubrangeInitialValue.SetRange(self.SubrangeMinimum.GetValue(), self.SubrangeMaximum.GetValue())
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   486
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   487
    def RefreshTypeInfos(self):
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   488
        selected = self.DerivationType.GetStringSelection()
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   489
        infos = {"type" : selected}
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   490
        if selected == "Directly":
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   491
            infos["base_type"] = self.DirectlyBaseType.GetStringSelection()
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   492
            infos["initial"] = self.DirectlyInitialValue.GetValue()
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   493
        elif selected == "Subrange":
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   494
            infos["base_type"] = self.SubrangeBaseType.GetStringSelection()
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   495
            infos["min"] = self.SubrangeMinimum.GetValue()
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   496
            infos["max"] = self.SubrangeMaximum.GetValue()
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   497
            initial_value = self.SubrangeInitialValue.GetValue()
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   498
            if initial_value == infos["min"]:
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   499
                infos["initial"] = ""
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   500
            else:
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   501
                infos["initial"] = str(initial_value)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   502
        elif selected == "Enumerated":
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   503
            infos["values"] = self.EnumeratedValues.GetStrings()
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   504
            infos["initial"] = self.EnumeratedInitialValue.GetStringSelection()
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   505
        elif selected == "Array":
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   506
            infos["base_type"] = self.ArrayBaseType.GetStringSelection()
207
b1144bb36605 Bug with array dimensions edition fixed
lbessard
parents: 205
diff changeset
   507
            infos["dimensions"] = []
b1144bb36605 Bug with array dimensions edition fixed
lbessard
parents: 205
diff changeset
   508
            for dimensions in self.ArrayDimensions.GetStrings():
b1144bb36605 Bug with array dimensions edition fixed
lbessard
parents: 205
diff changeset
   509
                result = DIMENSION_MODEL.match(dimensions)
b1144bb36605 Bug with array dimensions edition fixed
lbessard
parents: 205
diff changeset
   510
                if result is None:
b1144bb36605 Bug with array dimensions edition fixed
lbessard
parents: 205
diff changeset
   511
                    message = wx.MessageDialog(self, "\"%s\" value isn't a valid array dimension!"%dimensions, "Error", wx.OK|wx.ICON_ERROR)
b1144bb36605 Bug with array dimensions edition fixed
lbessard
parents: 205
diff changeset
   512
                    message.ShowModal()
b1144bb36605 Bug with array dimensions edition fixed
lbessard
parents: 205
diff changeset
   513
                    message.Destroy()
b1144bb36605 Bug with array dimensions edition fixed
lbessard
parents: 205
diff changeset
   514
                    self.RefreshView()
b1144bb36605 Bug with array dimensions edition fixed
lbessard
parents: 205
diff changeset
   515
                    return
b1144bb36605 Bug with array dimensions edition fixed
lbessard
parents: 205
diff changeset
   516
                bounds = result.groups()
b1144bb36605 Bug with array dimensions edition fixed
lbessard
parents: 205
diff changeset
   517
                if bounds[0] >= bounds[1]:
b1144bb36605 Bug with array dimensions edition fixed
lbessard
parents: 205
diff changeset
   518
                    message = wx.MessageDialog(self, "\"%s\" value isn't a valid array dimension!\nRight value must be greater than left value."%dimensions, "Error", wx.OK|wx.ICON_ERROR)
b1144bb36605 Bug with array dimensions edition fixed
lbessard
parents: 205
diff changeset
   519
                    message.ShowModal()
b1144bb36605 Bug with array dimensions edition fixed
lbessard
parents: 205
diff changeset
   520
                    message.Destroy()
b1144bb36605 Bug with array dimensions edition fixed
lbessard
parents: 205
diff changeset
   521
                    self.RefreshView()
b1144bb36605 Bug with array dimensions edition fixed
lbessard
parents: 205
diff changeset
   522
                    return
b1144bb36605 Bug with array dimensions edition fixed
lbessard
parents: 205
diff changeset
   523
                infos["dimensions"].append(map(int, bounds))
125
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   524
            infos["initial"] = self.ArrayInitialValue.GetValue()
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   525
        self.Controler.SetDataTypeInfos(self.TagName, infos)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   526
        self.ParentWindow.RefreshTitle()
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   527
        self.ParentWindow.RefreshEditMenu()
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   528
231
fc2d6cbb8b39 Adding support for highlighing compiling errors from matiec
lbessard
parents: 215
diff changeset
   529
#-------------------------------------------------------------------------------
fc2d6cbb8b39 Adding support for highlighing compiling errors from matiec
lbessard
parents: 215
diff changeset
   530
#                        Errors showing functions
fc2d6cbb8b39 Adding support for highlighing compiling errors from matiec
lbessard
parents: 215
diff changeset
   531
#-------------------------------------------------------------------------------
fc2d6cbb8b39 Adding support for highlighing compiling errors from matiec
lbessard
parents: 215
diff changeset
   532
fc2d6cbb8b39 Adding support for highlighing compiling errors from matiec
lbessard
parents: 215
diff changeset
   533
    def ClearErrors(self):
fc2d6cbb8b39 Adding support for highlighing compiling errors from matiec
lbessard
parents: 215
diff changeset
   534
        self.Errors = []
fc2d6cbb8b39 Adding support for highlighing compiling errors from matiec
lbessard
parents: 215
diff changeset
   535
        self.RefreshView()
fc2d6cbb8b39 Adding support for highlighing compiling errors from matiec
lbessard
parents: 215
diff changeset
   536
fc2d6cbb8b39 Adding support for highlighing compiling errors from matiec
lbessard
parents: 215
diff changeset
   537
    def AddShownError(self, infos, start, end):
fc2d6cbb8b39 Adding support for highlighing compiling errors from matiec
lbessard
parents: 215
diff changeset
   538
        self.Errors.append((infos, start, end))
fc2d6cbb8b39 Adding support for highlighing compiling errors from matiec
lbessard
parents: 215
diff changeset
   539
fc2d6cbb8b39 Adding support for highlighing compiling errors from matiec
lbessard
parents: 215
diff changeset
   540
    def ShowErrors(self):
fc2d6cbb8b39 Adding support for highlighing compiling errors from matiec
lbessard
parents: 215
diff changeset
   541
        type_infos = self.Controler.GetDataTypeInfos(self.TagName)
fc2d6cbb8b39 Adding support for highlighing compiling errors from matiec
lbessard
parents: 215
diff changeset
   542
        for infos, start, end in self.Errors:
fc2d6cbb8b39 Adding support for highlighing compiling errors from matiec
lbessard
parents: 215
diff changeset
   543
            if infos[0] == "base":
fc2d6cbb8b39 Adding support for highlighing compiling errors from matiec
lbessard
parents: 215
diff changeset
   544
                if type_infos["type"] == "Directly":
fc2d6cbb8b39 Adding support for highlighing compiling errors from matiec
lbessard
parents: 215
diff changeset
   545
                    self.DirectlyBaseType.SetBackgroundColour(wx.Colour(255, 255, 0))
fc2d6cbb8b39 Adding support for highlighing compiling errors from matiec
lbessard
parents: 215
diff changeset
   546
                    self.DirectlyBaseType.SetForegroundColour(wx.RED)
fc2d6cbb8b39 Adding support for highlighing compiling errors from matiec
lbessard
parents: 215
diff changeset
   547
                elif type_infos["type"] == "Subrange":
fc2d6cbb8b39 Adding support for highlighing compiling errors from matiec
lbessard
parents: 215
diff changeset
   548
                    self.SubrangeBaseType.SetBackgroundColour(wx.Colour(255, 255, 0))
fc2d6cbb8b39 Adding support for highlighing compiling errors from matiec
lbessard
parents: 215
diff changeset
   549
                    self.SubrangeBaseType.SetForegroundColour(wx.RED)
fc2d6cbb8b39 Adding support for highlighing compiling errors from matiec
lbessard
parents: 215
diff changeset
   550
                elif type_infos["type"] == "Array":
fc2d6cbb8b39 Adding support for highlighing compiling errors from matiec
lbessard
parents: 215
diff changeset
   551
                    self.ArrayBaseType.SetBackgroundColour(wx.Colour(255, 255, 0))
fc2d6cbb8b39 Adding support for highlighing compiling errors from matiec
lbessard
parents: 215
diff changeset
   552
                    self.ArrayBaseType.SetForegroundColour(wx.RED)
fc2d6cbb8b39 Adding support for highlighing compiling errors from matiec
lbessard
parents: 215
diff changeset
   553
            elif infos[0] == "lower":
fc2d6cbb8b39 Adding support for highlighing compiling errors from matiec
lbessard
parents: 215
diff changeset
   554
                self.SubrangeMinimum.SetBackgroundColour(wx.Colour(255, 255, 0))
fc2d6cbb8b39 Adding support for highlighing compiling errors from matiec
lbessard
parents: 215
diff changeset
   555
                self.SubrangeMaximum.SetForegroundColour(wx.RED)
fc2d6cbb8b39 Adding support for highlighing compiling errors from matiec
lbessard
parents: 215
diff changeset
   556
            elif infos[0] == "upper":
fc2d6cbb8b39 Adding support for highlighing compiling errors from matiec
lbessard
parents: 215
diff changeset
   557
                self.SubrangeMinimum.SetBackgroundColour(wx.Colour(255, 255, 0))
fc2d6cbb8b39 Adding support for highlighing compiling errors from matiec
lbessard
parents: 215
diff changeset
   558
                self.SubrangeMaximum.SetForegroundColour(wx.RED)
fc2d6cbb8b39 Adding support for highlighing compiling errors from matiec
lbessard
parents: 215
diff changeset
   559
            elif infos[0] == "value":
fc2d6cbb8b39 Adding support for highlighing compiling errors from matiec
lbessard
parents: 215
diff changeset
   560
                listctrl = self.EnumeratedValues.GetListCtrl()
fc2d6cbb8b39 Adding support for highlighing compiling errors from matiec
lbessard
parents: 215
diff changeset
   561
                listctrl.SetItemBackgroundColour(infos[1], wx.Colour(255, 255, 0))
fc2d6cbb8b39 Adding support for highlighing compiling errors from matiec
lbessard
parents: 215
diff changeset
   562
                listctrl.SetItemTextColour(infos[1], wx.RED)
fc2d6cbb8b39 Adding support for highlighing compiling errors from matiec
lbessard
parents: 215
diff changeset
   563
                listctrl.Select(listctrl.FocusedItem, False)
fc2d6cbb8b39 Adding support for highlighing compiling errors from matiec
lbessard
parents: 215
diff changeset
   564
            elif infos[0] == "range":
fc2d6cbb8b39 Adding support for highlighing compiling errors from matiec
lbessard
parents: 215
diff changeset
   565
                listctrl = self.EnumeratedValues.GetListCtrl()
fc2d6cbb8b39 Adding support for highlighing compiling errors from matiec
lbessard
parents: 215
diff changeset
   566
                listctrl.SetItemBackgroundColour(infos[1], wx.Colour(255, 255, 0))
fc2d6cbb8b39 Adding support for highlighing compiling errors from matiec
lbessard
parents: 215
diff changeset
   567
                listctrl.SetItemTextColour(infos[1], wx.RED)
fc2d6cbb8b39 Adding support for highlighing compiling errors from matiec
lbessard
parents: 215
diff changeset
   568
                listctrl.SetStringSelection("")
fc2d6cbb8b39 Adding support for highlighing compiling errors from matiec
lbessard
parents: 215
diff changeset
   569
            elif infos[0] == "initial":
fc2d6cbb8b39 Adding support for highlighing compiling errors from matiec
lbessard
parents: 215
diff changeset
   570
                if type_infos["type"] == "Directly":
fc2d6cbb8b39 Adding support for highlighing compiling errors from matiec
lbessard
parents: 215
diff changeset
   571
                    text = self.DirectlyInitialValue.GetValue()
fc2d6cbb8b39 Adding support for highlighing compiling errors from matiec
lbessard
parents: 215
diff changeset
   572
                    self.DirectlyInitialValue.SetValue(text[:start[1]])
fc2d6cbb8b39 Adding support for highlighing compiling errors from matiec
lbessard
parents: 215
diff changeset
   573
                    self.DirectlyInitialValue.SetDefaultStyle(wx.TextAttr(wx.RED, wx.Colour(255, 255, 0)))
fc2d6cbb8b39 Adding support for highlighing compiling errors from matiec
lbessard
parents: 215
diff changeset
   574
                    self.DirectlyInitialValue.AppendText(text[start[1]:end[1] + 1])
fc2d6cbb8b39 Adding support for highlighing compiling errors from matiec
lbessard
parents: 215
diff changeset
   575
                    self.DirectlyInitialValue.SetDefaultStyle(wx.TextAttr(wx.BLACK, wx.WHITE))
fc2d6cbb8b39 Adding support for highlighing compiling errors from matiec
lbessard
parents: 215
diff changeset
   576
                    self.DirectlyInitialValue.AppendText(text[end[1] + 1:])
fc2d6cbb8b39 Adding support for highlighing compiling errors from matiec
lbessard
parents: 215
diff changeset
   577
                elif type_infos["type"] == "Subrange":
fc2d6cbb8b39 Adding support for highlighing compiling errors from matiec
lbessard
parents: 215
diff changeset
   578
                    self.SubrangeInitialValue.SetBackgroundColour(wx.Colour(255, 255, 0))
fc2d6cbb8b39 Adding support for highlighing compiling errors from matiec
lbessard
parents: 215
diff changeset
   579
                    self.SubrangeInitialValue.SetForegroundColour(wx.RED)
fc2d6cbb8b39 Adding support for highlighing compiling errors from matiec
lbessard
parents: 215
diff changeset
   580
                elif type_infos["type"] == "Enumerated":
fc2d6cbb8b39 Adding support for highlighing compiling errors from matiec
lbessard
parents: 215
diff changeset
   581
                    self.EnumeratedInitialValue.SetBackgroundColour(wx.Colour(255, 255, 0))
fc2d6cbb8b39 Adding support for highlighing compiling errors from matiec
lbessard
parents: 215
diff changeset
   582
                    self.EnumeratedInitialValue.SetForegroundColour(wx.RED)
fc2d6cbb8b39 Adding support for highlighing compiling errors from matiec
lbessard
parents: 215
diff changeset
   583
                elif type_infos["type"] == "Array":
fc2d6cbb8b39 Adding support for highlighing compiling errors from matiec
lbessard
parents: 215
diff changeset
   584
                    text = self.ArrayInitialValue.GetValue()
fc2d6cbb8b39 Adding support for highlighing compiling errors from matiec
lbessard
parents: 215
diff changeset
   585
                    self.ArrayInitialValue.SetValue(text[:start[1]])
fc2d6cbb8b39 Adding support for highlighing compiling errors from matiec
lbessard
parents: 215
diff changeset
   586
                    self.ArrayInitialValue.SetDefaultStyle(wx.TextAttr(wx.RED, wx.Colour(255, 255, 0)))
fc2d6cbb8b39 Adding support for highlighing compiling errors from matiec
lbessard
parents: 215
diff changeset
   587
                    self.ArrayInitialValue.AppendText(text[start[1]:end[1] + 1])
fc2d6cbb8b39 Adding support for highlighing compiling errors from matiec
lbessard
parents: 215
diff changeset
   588
                    self.ArrayInitialValue.SetDefaultStyle(wx.TextAttr(wx.BLACK, wx.WHITE))
fc2d6cbb8b39 Adding support for highlighing compiling errors from matiec
lbessard
parents: 215
diff changeset
   589
                    self.ArrayInitialValue.AppendText(text[end[1] + 1:])