DataTypeEditor.py
author lbessard
Fri, 22 Aug 2008 13:49:22 +0200
changeset 235 7b58a3b5b6ec
parent 231 fc2d6cbb8b39
child 295 c6ef6d92ce16
permissions -rw-r--r--
Change in layout from AuiMDIParentFrame to AuiNotebook
Adding support for Instances Tree
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
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
    35
#-------------------------------------------------------------------------------
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
    36
#                          Configuration Editor class
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
    37
#-------------------------------------------------------------------------------
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
    38
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
    39
[ID_DATATYPEEDITOR, ID_DATATYPEEDITORSTATICBOX,
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
    40
 ID_DATATYPEEDITORDERIVATIONTYPE, ID_DATATYPEEDITORDIRECTLYPANEL,
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
    41
 ID_DATATYPEEDITORSUBRANGEPANEL, ID_DATATYPEEDITORDIRECTLYBASETYPE, 
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
    42
 ID_DATATYPEEDITORSUBRANGEBASETYPE, ID_DATATYPEEDITORSUBRANGEMINIMUM, 
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
    43
 ID_DATATYPEEDITORSUBRANGEMAXIMUM, ID_DATATYPEEDITORDIRECTLYINITIALVALUE, 
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
    44
 ID_DATATYPEEDITORSUBRANGEINITIALVALUE, ID_DATATYPEEDITORENUMERATEDPANEL,
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
    45
 ID_DATATYPEEDITORENUMERATEDVALUES, ID_DATATYPEEDITORENUMERATEDINITIALVALUE,
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
    46
 ID_DATATYPEEDITORARRAYPANEL, ID_DATATYPEEDITORARRAYBASETYPE, 
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
    47
 ID_DATATYPEEDITORARRAYDIMENSIONS, ID_DATATYPEEDITORARRAYINITIALVALUE, 
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
    48
 ID_DATATYPEEDITORSTATICTEXT1, ID_DATATYPEEDITORSTATICTEXT2, 
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
    49
 ID_DATATYPEEDITORSTATICTEXT3, ID_DATATYPEEDITORSTATICTEXT4, 
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
    50
 ID_DATATYPEEDITORSTATICTEXT5, ID_DATATYPEEDITORSTATICTEXT6, 
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
    51
 ID_DATATYPEEDITORSTATICTEXT7, ID_DATATYPEEDITORSTATICTEXT8,
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
    52
 ID_DATATYPEEDITORSTATICTEXT9, ID_DATATYPEEDITORSTATICTEXT10, 
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
    53
] = [wx.NewId() for _init_ctrls in range(28)]
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
class DataTypeEditor(wx.Panel):
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
    56
    
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
    57
    def _init_coll_MainSizer_Items(self, parent):
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
    58
        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
    59
        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
    60
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
    61
    def _init_coll_MainSizer_Growables(self, parent):
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
    62
        parent.AddGrowableCol(0)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
    63
        parent.AddGrowableRow(1)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
    64
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
    65
    def _init_coll_TopSizer_Items(self, parent):
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
    66
        parent.AddWindow(self.staticText1, 0, border=5, flag=wx.GROW|wx.LEFT)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
    67
        parent.AddWindow(self.DerivationType, 0, border=0, flag=wx.GROW)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
    68
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
    69
    def _init_coll_TypeInfosSizer_Items(self, parent):
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
    70
        parent.AddWindow(self.DirectlyPanel, 1, border=0, flag=wx.ALL)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
    71
        parent.AddWindow(self.SubrangePanel, 1, border=0, flag=wx.ALL)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
    72
        parent.AddWindow(self.EnumeratedPanel, 1, border=0, flag=wx.GROW|wx.ALL)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
    73
        parent.AddWindow(self.ArrayPanel, 1, border=0, flag=wx.ALL)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
    74
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
    75
    def _init_coll_DirectlyPanelSizer_Items(self, parent):
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
    76
        parent.AddWindow(self.staticText2, 1, border=5, flag=wx.GROW|wx.ALL)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
    77
        parent.AddWindow(self.DirectlyBaseType, 1, border=5, flag=wx.GROW|wx.ALL)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
    78
        parent.AddWindow(self.staticText3, 1, border=5, flag=wx.GROW|wx.ALL)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
    79
        parent.AddWindow(self.DirectlyInitialValue, 1, border=5, flag=wx.GROW|wx.ALL)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
    80
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
    81
    def _init_coll_SubrangePanelSizer_Items(self, parent):
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
    82
        parent.AddWindow(self.staticText4, 1, border=5, flag=wx.GROW|wx.ALL)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
    83
        parent.AddWindow(self.SubrangeBaseType, 1, border=5, flag=wx.GROW|wx.ALL)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
    84
        parent.AddWindow(self.staticText5, 1, border=5, flag=wx.GROW|wx.ALL)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
    85
        parent.AddWindow(self.SubrangeInitialValue, 1, border=5, flag=wx.GROW|wx.ALL)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
    86
        parent.AddWindow(self.staticText6, 1, border=5, flag=wx.GROW|wx.ALL)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
    87
        parent.AddWindow(self.SubrangeMinimum, 1, border=5, flag=wx.GROW|wx.ALL)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
    88
        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
    89
        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
    90
        parent.AddWindow(self.staticText7, 1, border=5, flag=wx.GROW|wx.ALL)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
    91
        parent.AddWindow(self.SubrangeMaximum, 1, border=5, flag=wx.GROW|wx.ALL)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
    92
        
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
    93
    def _init_coll_EnumeratedPanelSizer_Items(self, parent):
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
    94
        parent.AddWindow(self.EnumeratedValues, 2, border=5, flag=wx.GROW|wx.ALL)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
    95
        parent.AddWindow(self.staticText8, 1, border=5, flag=wx.GROW|wx.ALL)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
    96
        parent.AddWindow(self.EnumeratedInitialValue, 1, border=5, flag=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_ArrayPanelSizer_Items(self, parent):
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
    99
        parent.AddSizer(self.ArrayPanelLeftSizer, 0, border=0, flag=wx.GROW)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   100
        parent.AddSizer(self.ArrayPanelRightSizer, 0, border=0, flag=wx.GROW)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   101
        parent.AddWindow(self.ArrayDimensions, 0, border=5, flag=wx.GROW|wx.ALL)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   102
        
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   103
    def _init_coll_ArrayPanelSizer_Growables(self, parent):
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   104
        parent.AddGrowableCol(0)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   105
        parent.AddGrowableCol(1)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   106
        parent.AddGrowableRow(1)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   107
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   108
    def _init_coll_ArrayPanelLeftSizer_Items(self, parent):
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   109
        parent.AddWindow(self.staticText9, 1, border=5, flag=wx.GROW|wx.ALL)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   110
        parent.AddWindow(self.ArrayBaseType, 1, border=5, flag=wx.GROW|wx.ALL)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   111
    
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   112
    def _init_coll_ArrayPanelRightSizer_Items(self, parent):
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   113
        parent.AddWindow(self.staticText10, 1, border=5, flag=wx.GROW|wx.ALL)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   114
        parent.AddWindow(self.ArrayInitialValue, 1, border=5, flag=wx.GROW|wx.ALL)    
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   115
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   116
    def _init_sizers(self):
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   117
        self.MainSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=10)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   118
        self.TopSizer = wx.BoxSizer(wx.HORIZONTAL)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   119
        self.TypeInfosSizer = wx.StaticBoxSizer(self.staticbox, wx.HORIZONTAL)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   120
        self.DirectlyPanelSizer = wx.BoxSizer(wx.HORIZONTAL)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   121
        self.SubrangePanelSizer = wx.GridSizer(cols=4, hgap=0, rows=3, vgap=0)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   122
        self.EnumeratedPanelSizer = wx.BoxSizer(wx.HORIZONTAL)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   123
        self.ArrayPanelSizer = wx.FlexGridSizer(cols=2, hgap=0, rows=2, vgap=0)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   124
        self.ArrayPanelLeftSizer = wx.BoxSizer(wx.HORIZONTAL)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   125
        self.ArrayPanelRightSizer = wx.BoxSizer(wx.HORIZONTAL)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   126
        
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   127
        self._init_coll_MainSizer_Items(self.MainSizer)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   128
        self._init_coll_MainSizer_Growables(self.MainSizer)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   129
        self._init_coll_TopSizer_Items(self.TopSizer)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   130
        self._init_coll_TypeInfosSizer_Items(self.TypeInfosSizer)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   131
        self._init_coll_DirectlyPanelSizer_Items(self.DirectlyPanelSizer)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   132
        self._init_coll_SubrangePanelSizer_Items(self.SubrangePanelSizer)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   133
        self._init_coll_EnumeratedPanelSizer_Items(self.EnumeratedPanelSizer)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   134
        self._init_coll_ArrayPanelSizer_Items(self.ArrayPanelSizer)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   135
        self._init_coll_ArrayPanelSizer_Growables(self.ArrayPanelSizer)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   136
        self._init_coll_ArrayPanelLeftSizer_Items(self.ArrayPanelLeftSizer)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   137
        self._init_coll_ArrayPanelRightSizer_Items(self.ArrayPanelRightSizer)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   138
        
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   139
        self.SetSizer(self.MainSizer)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   140
        self.DirectlyPanel.SetSizer(self.DirectlyPanelSizer)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   141
        self.SubrangePanel.SetSizer(self.SubrangePanelSizer)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   142
        self.EnumeratedPanel.SetSizer(self.EnumeratedPanelSizer)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   143
        self.ArrayPanel.SetSizer(self.ArrayPanelSizer)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   144
    
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   145
    def _init_ctrls(self, prnt):
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   146
        wx.Panel.__init__(self, id=ID_DATATYPEEDITOR, name='', parent=prnt,
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   147
              size=wx.Size(0, 0), style=wx.SUNKEN_BORDER)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   148
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   149
        self.staticbox = wx.StaticBox(id=ID_DATATYPEEDITORSTATICBOX,
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   150
              label='Type infos:', name='staticBox1', parent=self,
231
fc2d6cbb8b39 Adding support for highlighing compiling errors from matiec
lbessard
parents: 215
diff changeset
   151
              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
   152
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   153
        self.staticText1 = wx.StaticText(id=ID_DATATYPEEDITORSTATICTEXT1,
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   154
              label='Derivation Type:', name='staticText1', parent=self,
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   155
              pos=wx.Point(0, 0), size=wx.Size(150, 17), style=0)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   156
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   157
        self.DerivationType = wx.Choice(id=ID_DATATYPEEDITORDERIVATIONTYPE,
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   158
              name='DerivationType', parent=self, pos=wx.Point(0, 0),
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   159
              size=wx.Size(200, 24), style=0)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   160
        self.Bind(wx.EVT_CHOICE, self.OnDerivationTypeChanged, id=ID_DATATYPEEDITORDERIVATIONTYPE)
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
        # Panel for Directly derived data types
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   163
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   164
        self.DirectlyPanel = wx.Panel(id=ID_DATATYPEEDITORDIRECTLYPANEL,
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   165
              name='DirectlyPanel', parent=self, pos=wx.Point(0, 0),
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   166
              size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   167
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   168
        self.staticText2 = wx.StaticText(id=ID_DATATYPEEDITORSTATICTEXT2,
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   169
              label='Base Type:', name='staticText2', parent=self.DirectlyPanel,
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   170
              pos=wx.Point(0, 0), size=wx.Size(150, 17), style=0)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   171
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   172
        self.DirectlyBaseType = wx.Choice(id=ID_DATATYPEEDITORDIRECTLYBASETYPE, 
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   173
              name='DirectlyBaseType', parent=self.DirectlyPanel, pos=wx.Point(0, 0),
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   174
              size=wx.Size(0, 24), style=wx.TAB_TRAVERSAL)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   175
        self.Bind(wx.EVT_CHOICE, self.OnInfosChanged, id=ID_DATATYPEEDITORDIRECTLYBASETYPE)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   176
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   177
        self.staticText3 = wx.StaticText(id=ID_DATATYPEEDITORSTATICTEXT3,
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   178
              label='Initial Value:', name='staticText3', parent=self.DirectlyPanel,
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   179
              pos=wx.Point(0, 0), size=wx.Size(150, 17), style=0)
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.DirectlyInitialValue = wx.TextCtrl(id=ID_DATATYPEEDITORDIRECTLYINITIALVALUE, 
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   182
              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
   183
              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
   184
        self.Bind(wx.EVT_TEXT_ENTER, self.OnReturnKeyPressed, id=ID_DATATYPEEDITORDIRECTLYINITIALVALUE)
125
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   185
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   186
        # Panel for Subrange data types
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   187
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   188
        self.SubrangePanel = wx.Panel(id=ID_DATATYPEEDITORSUBRANGEPANEL,
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   189
              name='SubrangePanel', parent=self, pos=wx.Point(0, 0),
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   190
              size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   191
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   192
        self.staticText4 = wx.StaticText(id=ID_DATATYPEEDITORSTATICTEXT4,
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   193
              label='Base Type:', name='staticText4', parent=self.SubrangePanel,
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   194
              pos=wx.Point(0, 0), size=wx.Size(150, 17), style=0)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   195
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   196
        self.SubrangeBaseType = wx.Choice(id=ID_DATATYPEEDITORSUBRANGEBASETYPE, 
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   197
              name='SubrangeBaseType', parent=self.SubrangePanel, pos=wx.Point(0, 0),
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   198
              size=wx.Size(0, 24), style=wx.TAB_TRAVERSAL)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   199
        self.Bind(wx.EVT_CHOICE, self.OnSubrangeBaseTypeChanged, id=ID_DATATYPEEDITORSUBRANGEBASETYPE)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   200
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   201
        self.staticText5 = wx.StaticText(id=ID_DATATYPEEDITORSTATICTEXT5,
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   202
              label='Initial Value:', name='staticText5', parent=self.SubrangePanel,
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   203
              pos=wx.Point(0, 0), size=wx.Size(150, 17), style=0)
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.SubrangeInitialValue = wx.SpinCtrl(id=ID_DATATYPEEDITORSUBRANGEINITIALVALUE, 
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   206
              name='SubrangeInitialValue', parent=self.SubrangePanel, pos=wx.Point(0, 0),
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   207
              size=wx.Size(0, 24), style=wx.TAB_TRAVERSAL)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   208
        self.Bind(wx.EVT_SPINCTRL, self.OnInfosChanged, id=ID_DATATYPEEDITORSUBRANGEINITIALVALUE)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   209
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   210
        self.staticText6 = wx.StaticText(id=ID_DATATYPEEDITORSTATICTEXT6,
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   211
              label='Minimum:', name='staticText6', parent=self.SubrangePanel,
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   212
              pos=wx.Point(0, 0), size=wx.Size(150, 17), style=0)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   213
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   214
        self.SubrangeMinimum = wx.SpinCtrl(id=ID_DATATYPEEDITORSUBRANGEMINIMUM, 
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   215
              name='SubrangeMinimum', parent=self.SubrangePanel, pos=wx.Point(0, 0),
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   216
              size=wx.Size(0, 24), style=wx.TAB_TRAVERSAL)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   217
        self.Bind(wx.EVT_SPINCTRL, self.OnSubrangeMinimumChanged, id=ID_DATATYPEEDITORSUBRANGEMINIMUM)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   218
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   219
        self.staticText7 = wx.StaticText(id=ID_DATATYPEEDITORSTATICTEXT7,
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   220
              label='Maximum:', name='staticText7', parent=self.SubrangePanel,
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   221
              pos=wx.Point(0, 0), size=wx.Size(150, 17), style=0)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   222
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   223
        self.SubrangeMaximum = wx.SpinCtrl(id=ID_DATATYPEEDITORSUBRANGEMAXIMUM, 
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   224
              name='SubrangeMaximum', parent=self.SubrangePanel, pos=wx.Point(0, 0),
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   225
              size=wx.Size(0, 24), style=wx.TAB_TRAVERSAL)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   226
        self.Bind(wx.EVT_SPINCTRL, self.OnSubrangeMaximumChanged, id=ID_DATATYPEEDITORSUBRANGEMAXIMUM)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   227
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   228
        # Panel for Enumerated data types
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   229
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   230
        self.EnumeratedPanel = wx.Panel(id=ID_DATATYPEEDITORENUMERATEDPANEL,
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   231
              name='EnumeratedPanel', parent=self, pos=wx.Point(0, 0),
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   232
              size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   233
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   234
        self.EnumeratedValues = wx.gizmos.EditableListBox(id=ID_DATATYPEEDITORENUMERATEDVALUES, 
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   235
              name='EnumeratedValues', parent=self.EnumeratedPanel, label="Values:", pos=wx.Point(0, 0),
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   236
              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
   237
        self.EnumeratedValues.GetListCtrl().Bind(wx.EVT_LIST_END_LABEL_EDIT, self.OnEnumeratedValueEndEdit)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   238
        self.EnumeratedValues.GetNewButton().Bind(wx.EVT_BUTTON, self.OnEnumeratedValuesChanged)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   239
        self.EnumeratedValues.GetDelButton().Bind(wx.EVT_BUTTON, self.OnEnumeratedValuesChanged)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   240
        self.EnumeratedValues.GetUpButton().Bind(wx.EVT_BUTTON, self.OnEnumeratedValuesChanged)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   241
        self.EnumeratedValues.GetDownButton().Bind(wx.EVT_BUTTON, self.OnEnumeratedValuesChanged)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   242
        
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   243
        self.staticText8 = wx.StaticText(id=ID_DATATYPEEDITORSTATICTEXT8,
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   244
              label='Initial Value:', name='staticText8', parent=self.EnumeratedPanel,
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   245
              pos=wx.Point(0, 0), size=wx.Size(150, 17), style=0)
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.EnumeratedInitialValue = wx.Choice(id=ID_DATATYPEEDITORENUMERATEDINITIALVALUE, 
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   248
              name='EnumeratedInitialValue', parent=self.EnumeratedPanel, pos=wx.Point(0, 0),
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   249
              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
   250
        self.Bind(wx.EVT_CHOICE, self.OnInfosChanged, id=ID_DATATYPEEDITORENUMERATEDINITIALVALUE)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   251
        
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   252
        # Panel for Array data types
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   253
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   254
        self.ArrayPanel = wx.Panel(id=ID_DATATYPEEDITORARRAYPANEL,
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   255
              name='ArrayPanel', parent=self, pos=wx.Point(0, 0),
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   256
              size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   257
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   258
        self.staticText9 = wx.StaticText(id=ID_DATATYPEEDITORSTATICTEXT9,
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   259
              label='Base Type:', name='staticText9', parent=self.ArrayPanel,
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   260
              pos=wx.Point(0, 0), size=wx.Size(150, 17), style=0)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   261
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   262
        self.ArrayBaseType = wx.Choice(id=ID_DATATYPEEDITORARRAYBASETYPE, 
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   263
              name='SubrangeBaseType', parent=self.ArrayPanel, pos=wx.Point(0, 0),
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   264
              size=wx.Size(0, 24), style=wx.TAB_TRAVERSAL)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   265
        self.Bind(wx.EVT_CHOICE, self.OnInfosChanged, id=ID_DATATYPEEDITORARRAYBASETYPE)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   266
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   267
        self.ArrayDimensions = wx.gizmos.EditableListBox(id=ID_DATATYPEEDITORARRAYDIMENSIONS, 
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   268
              name='ArrayDimensions', parent=self.ArrayPanel, label="Dimensions:", pos=wx.Point(0, 0),
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   269
              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
   270
        self.ArrayDimensions.GetListCtrl().Bind(wx.EVT_LIST_END_LABEL_EDIT, self.OnDimensionsChanged)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   271
        self.ArrayDimensions.GetNewButton().Bind(wx.EVT_BUTTON, self.OnDimensionsChanged)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   272
        self.ArrayDimensions.GetDelButton().Bind(wx.EVT_BUTTON, self.OnDimensionsChanged)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   273
        self.ArrayDimensions.GetUpButton().Bind(wx.EVT_BUTTON, self.OnDimensionsChanged)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   274
        self.ArrayDimensions.GetDownButton().Bind(wx.EVT_BUTTON, self.OnDimensionsChanged)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   275
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   276
        self.staticText10 = wx.StaticText(id=ID_DATATYPEEDITORSTATICTEXT10,
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   277
              label='Initial Value:', name='staticText10', parent=self.ArrayPanel,
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   278
              pos=wx.Point(0, 0), size=wx.Size(150, 17), style=0)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   279
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   280
        self.ArrayInitialValue = wx.TextCtrl(id=ID_DATATYPEEDITORARRAYINITIALVALUE, 
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   281
              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
   282
              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
   283
        self.Bind(wx.EVT_TEXT_ENTER, self.OnReturnKeyPressed, id=ID_DATATYPEEDITORARRAYINITIALVALUE)
125
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   284
        
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   285
        self._init_sizers()
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   286
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   287
    def __init__(self, parent, tagname, window, controler):
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   288
        self._init_ctrls(parent)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   289
        
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   290
        self.DerivationType.Append("Directly")
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   291
        self.DerivationType.Append("Subrange")
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   292
        self.DerivationType.Append("Enumerated")
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   293
        self.DerivationType.Append("Array")
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   294
        self.SubrangePanel.Hide()
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   295
        self.EnumeratedPanel.Hide()
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   296
        self.ArrayPanel.Hide()
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   297
        self.CurrentPanel = "Directly"
231
fc2d6cbb8b39 Adding support for highlighing compiling errors from matiec
lbessard
parents: 215
diff changeset
   298
        self.Errors = []
130
38421cd7c8ff Bug on subrange SpinCtrls with Windows fixed
lbessard
parents: 125
diff changeset
   299
        self.Initializing = False
125
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   300
        
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   301
        self.ParentWindow = window
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   302
        self.Controler = controler
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   303
        self.TagName = tagname
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   304
    
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   305
    def OnEnumeratedValueEndEdit(self, event):
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   306
        text = event.GetText()
192
50926b8abac4 Bug on Enumerated DataType values defining fixed
lbessard
parents: 150
diff changeset
   307
        values = self.EnumeratedValues.GetStrings()
50926b8abac4 Bug on Enumerated DataType values defining fixed
lbessard
parents: 150
diff changeset
   308
        index = event.GetIndex()
50926b8abac4 Bug on Enumerated DataType values defining fixed
lbessard
parents: 150
diff changeset
   309
        if index >= len(values) or values[index].upper() != text.upper():
50926b8abac4 Bug on Enumerated DataType values defining fixed
lbessard
parents: 150
diff changeset
   310
            if text.upper() in [value.upper() for value in values]:
150
f7832baaad84 Bug on enumerated datatype values editor fixed
lbessard
parents: 130
diff changeset
   311
                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
   312
                message.ShowModal()
f7832baaad84 Bug on enumerated datatype values editor fixed
lbessard
parents: 130
diff changeset
   313
                message.Destroy()
f7832baaad84 Bug on enumerated datatype values editor fixed
lbessard
parents: 130
diff changeset
   314
                event.Veto()
f7832baaad84 Bug on enumerated datatype values editor fixed
lbessard
parents: 130
diff changeset
   315
            elif text.upper() in IEC_KEYWORDS:
f7832baaad84 Bug on enumerated datatype values editor fixed
lbessard
parents: 130
diff changeset
   316
                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
   317
                message.ShowModal()
f7832baaad84 Bug on enumerated datatype values editor fixed
lbessard
parents: 130
diff changeset
   318
                message.Destroy()
f7832baaad84 Bug on enumerated datatype values editor fixed
lbessard
parents: 130
diff changeset
   319
            else:
f7832baaad84 Bug on enumerated datatype values editor fixed
lbessard
parents: 130
diff changeset
   320
                wx.CallAfter(self.RefreshEnumeratedValues)
f7832baaad84 Bug on enumerated datatype values editor fixed
lbessard
parents: 130
diff changeset
   321
                wx.CallAfter(self.RefreshTypeInfos)
f7832baaad84 Bug on enumerated datatype values editor fixed
lbessard
parents: 130
diff changeset
   322
                event.Skip()
125
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   323
        else:
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   324
            wx.CallAfter(self.RefreshEnumeratedValues)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   325
            wx.CallAfter(self.RefreshTypeInfos)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   326
            event.Skip()
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   327
    
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   328
    def OnEnumeratedValuesChanged(self, event):
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   329
        wx.CallAfter(self.RefreshEnumeratedValues)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   330
        wx.CallAfter(self.RefreshTypeInfos)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   331
        event.Skip()
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   332
    
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   333
    def SetTagName(self, tagname):
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   334
        self.TagName = tagname
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   335
        
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   336
    def GetTagName(self):
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   337
        return self.TagName
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   338
    
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   339
    def IsViewing(self, tagname):
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   340
        return self.TagName == tagname
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   341
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   342
    def SetMode(self, mode):
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   343
        pass
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 ResetBuffer(self):
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   346
        pass
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   347
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   348
    def RefreshView(self):
130
38421cd7c8ff Bug on subrange SpinCtrls with Windows fixed
lbessard
parents: 125
diff changeset
   349
        self.Initializing = True
125
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   350
        self.DirectlyBaseType.Clear()
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   351
        self.ArrayBaseType.Clear()
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   352
        for datatype in self.Controler.GetDataTypes(self.TagName):
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   353
            self.DirectlyBaseType.Append(datatype)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   354
            self.ArrayBaseType.Append(datatype)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   355
        self.DirectlyBaseType.SetSelection(0)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   356
        self.SubrangeBaseType.Clear()
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   357
        words = self.TagName.split("::")
231
fc2d6cbb8b39 Adding support for highlighing compiling errors from matiec
lbessard
parents: 215
diff changeset
   358
        for base_type in self.Controler.GetSubrangeBaseTypes(words[1]):
125
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   359
            self.SubrangeBaseType.Append(base_type)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   360
        self.SubrangeBaseType.SetSelection(0)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   361
        self.RefreshBoundsRange()
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   362
        type_infos = self.Controler.GetDataTypeInfos(self.TagName)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   363
        if type_infos is not None:
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   364
            self.DerivationType.SetStringSelection(type_infos["type"])
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   365
            if type_infos["type"] == "Directly":
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   366
                self.DirectlyBaseType.SetStringSelection(type_infos["base_type"])
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   367
                self.DirectlyInitialValue.SetValue(type_infos["initial"])
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   368
            elif type_infos["type"] == "Subrange":
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   369
                self.SubrangeBaseType.SetStringSelection(type_infos["base_type"])
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   370
                self.RefreshBoundsRange()
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   371
                self.SubrangeMinimum.SetValue(type_infos["min"])
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   372
                self.SubrangeMaximum.SetValue(type_infos["max"])
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   373
                self.RefreshSubrangeInitialValueRange()
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   374
                if type_infos["initial"] != "":
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   375
                    self.SubrangeInitialValue.SetValue(int(type_infos["initial"]))
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   376
                else:
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   377
                    self.SubrangeInitialValue.SetValue(type_infos["min"])
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   378
            elif type_infos["type"] == "Enumerated":
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   379
                self.EnumeratedValues.SetStrings(type_infos["values"])
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   380
                self.RefreshEnumeratedValues()
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   381
                self.EnumeratedInitialValue.SetStringSelection(type_infos["initial"])
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   382
            elif type_infos["type"] == "Array":
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   383
                self.ArrayBaseType.SetStringSelection(type_infos["base_type"])
207
b1144bb36605 Bug with array dimensions edition fixed
lbessard
parents: 205
diff changeset
   384
                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
   385
                self.ArrayInitialValue.SetValue(type_infos["initial"])
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   386
            self.RefreshDisplayedInfos()
231
fc2d6cbb8b39 Adding support for highlighing compiling errors from matiec
lbessard
parents: 215
diff changeset
   387
        self.ShowErrors()
130
38421cd7c8ff Bug on subrange SpinCtrls with Windows fixed
lbessard
parents: 125
diff changeset
   388
        self.Initializing = False
125
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   389
205
f12ad5b87f99 Bug with missing RefreshScaling fixed
lbessard
parents: 192
diff changeset
   390
    def RefreshScaling(self, refresh=True):
f12ad5b87f99 Bug with missing RefreshScaling fixed
lbessard
parents: 192
diff changeset
   391
        pass
f12ad5b87f99 Bug with missing RefreshScaling fixed
lbessard
parents: 192
diff changeset
   392
125
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   393
    def OnDerivationTypeChanged(self, event):
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   394
        self.RefreshDisplayedInfos()
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   395
        self.RefreshTypeInfos()
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   396
        event.Skip()
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   397
231
fc2d6cbb8b39 Adding support for highlighing compiling errors from matiec
lbessard
parents: 215
diff changeset
   398
    def OnReturnKeyPressed(self, event):
fc2d6cbb8b39 Adding support for highlighing compiling errors from matiec
lbessard
parents: 215
diff changeset
   399
        self.RefreshTypeInfos()
fc2d6cbb8b39 Adding support for highlighing compiling errors from matiec
lbessard
parents: 215
diff changeset
   400
        
125
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   401
    def OnInfosChanged(self, event):
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   402
        self.RefreshTypeInfos()
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   403
        event.Skip()
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   404
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   405
    def OnSubrangeBaseTypeChanged(self, event):
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   406
        self.RefreshBoundsRange()
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   407
        self.RefreshTypeInfos()
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   408
        event.Skip()
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   409
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   410
    def OnSubrangeMinimumChanged(self, event):
215
dd3381f38a9e Fixed various bugs
etisserant
parents: 207
diff changeset
   411
        if not self.Initializing:
130
38421cd7c8ff Bug on subrange SpinCtrls with Windows fixed
lbessard
parents: 125
diff changeset
   412
            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
   413
            wx.CallAfter(self.RefreshSubrangeInitialValueRange)
38421cd7c8ff Bug on subrange SpinCtrls with Windows fixed
lbessard
parents: 125
diff changeset
   414
            wx.CallAfter(self.RefreshTypeInfos)
125
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   415
        event.Skip()
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   416
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   417
    def OnSubrangeMaximumChanged(self, event):
215
dd3381f38a9e Fixed various bugs
etisserant
parents: 207
diff changeset
   418
        if not self.Initializing:
130
38421cd7c8ff Bug on subrange SpinCtrls with Windows fixed
lbessard
parents: 125
diff changeset
   419
            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
   420
            wx.CallAfter(self.RefreshSubrangeInitialValueRange)
38421cd7c8ff Bug on subrange SpinCtrls with Windows fixed
lbessard
parents: 125
diff changeset
   421
            wx.CallAfter(self.RefreshTypeInfos)
125
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   422
        event.Skip()
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   423
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   424
    def OnDimensionsChanged(self, event):
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   425
        wx.CallAfter(self.RefreshTypeInfos)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   426
        event.Skip()
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   427
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   428
    def RefreshDisplayedInfos(self):
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   429
        selected = self.DerivationType.GetStringSelection()
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   430
        if selected != self.CurrentPanel:
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   431
            if self.CurrentPanel == "Directly":
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   432
                self.DirectlyPanel.Hide()
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   433
            elif self.CurrentPanel == "Subrange":
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   434
                self.SubrangePanel.Hide()
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   435
            elif self.CurrentPanel == "Enumerated":
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   436
                self.EnumeratedPanel.Hide()
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   437
            elif self.CurrentPanel == "Array":
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   438
                self.ArrayPanel.Hide()
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   439
            self.CurrentPanel = selected
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   440
            if selected == "Directly":
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   441
                self.DirectlyPanel.Show()
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   442
            elif selected == "Subrange":
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   443
                self.SubrangePanel.Show()
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   444
            elif selected == "Enumerated":
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   445
                self.EnumeratedPanel.Show()
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   446
            elif selected == "Array":
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   447
                self.ArrayPanel.Show()
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   448
            self.MainSizer.Layout()
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   449
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   450
    def RefreshEnumeratedValues(self):
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   451
        selected = self.EnumeratedInitialValue.GetStringSelection()
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   452
        self.EnumeratedInitialValue.Clear()
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   453
        self.EnumeratedInitialValue.Append("")
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   454
        for value in self.EnumeratedValues.GetStrings():
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   455
            self.EnumeratedInitialValue.Append(value)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   456
        self.EnumeratedInitialValue.SetStringSelection(selected)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   457
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   458
    def RefreshBoundsRange(self):
231
fc2d6cbb8b39 Adding support for highlighing compiling errors from matiec
lbessard
parents: 215
diff changeset
   459
        range = self.Controler.GetDataTypeRange(self.SubrangeBaseType.GetStringSelection())
125
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   460
        if range is not None:
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   461
            min_value, max_value = range
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   462
            self.SubrangeMinimum.SetRange(min_value, max_value)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   463
            self.SubrangeMinimum.SetValue(min(max(min_value, self.SubrangeMinimum.GetValue()), max_value))
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   464
            self.SubrangeMaximum.SetRange(min_value, max_value)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   465
            self.SubrangeMaximum.SetValue(min(max(min_value, self.SubrangeMaximum.GetValue()), max_value))
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 RefreshSubrangeInitialValueRange(self):
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   468
        self.SubrangeInitialValue.SetRange(self.SubrangeMinimum.GetValue(), self.SubrangeMaximum.GetValue())
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   469
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   470
    def RefreshTypeInfos(self):
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   471
        selected = self.DerivationType.GetStringSelection()
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   472
        infos = {"type" : selected}
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   473
        if selected == "Directly":
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   474
            infos["base_type"] = self.DirectlyBaseType.GetStringSelection()
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   475
            infos["initial"] = self.DirectlyInitialValue.GetValue()
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   476
        elif selected == "Subrange":
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   477
            infos["base_type"] = self.SubrangeBaseType.GetStringSelection()
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   478
            infos["min"] = self.SubrangeMinimum.GetValue()
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   479
            infos["max"] = self.SubrangeMaximum.GetValue()
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   480
            initial_value = self.SubrangeInitialValue.GetValue()
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   481
            if initial_value == infos["min"]:
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   482
                infos["initial"] = ""
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   483
            else:
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   484
                infos["initial"] = str(initial_value)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   485
        elif selected == "Enumerated":
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   486
            infos["values"] = self.EnumeratedValues.GetStrings()
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   487
            infos["initial"] = self.EnumeratedInitialValue.GetStringSelection()
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   488
        elif selected == "Array":
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   489
            infos["base_type"] = self.ArrayBaseType.GetStringSelection()
207
b1144bb36605 Bug with array dimensions edition fixed
lbessard
parents: 205
diff changeset
   490
            infos["dimensions"] = []
b1144bb36605 Bug with array dimensions edition fixed
lbessard
parents: 205
diff changeset
   491
            for dimensions in self.ArrayDimensions.GetStrings():
b1144bb36605 Bug with array dimensions edition fixed
lbessard
parents: 205
diff changeset
   492
                result = DIMENSION_MODEL.match(dimensions)
b1144bb36605 Bug with array dimensions edition fixed
lbessard
parents: 205
diff changeset
   493
                if result is None:
b1144bb36605 Bug with array dimensions edition fixed
lbessard
parents: 205
diff changeset
   494
                    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
   495
                    message.ShowModal()
b1144bb36605 Bug with array dimensions edition fixed
lbessard
parents: 205
diff changeset
   496
                    message.Destroy()
b1144bb36605 Bug with array dimensions edition fixed
lbessard
parents: 205
diff changeset
   497
                    self.RefreshView()
b1144bb36605 Bug with array dimensions edition fixed
lbessard
parents: 205
diff changeset
   498
                    return
b1144bb36605 Bug with array dimensions edition fixed
lbessard
parents: 205
diff changeset
   499
                bounds = result.groups()
b1144bb36605 Bug with array dimensions edition fixed
lbessard
parents: 205
diff changeset
   500
                if bounds[0] >= bounds[1]:
b1144bb36605 Bug with array dimensions edition fixed
lbessard
parents: 205
diff changeset
   501
                    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
   502
                    message.ShowModal()
b1144bb36605 Bug with array dimensions edition fixed
lbessard
parents: 205
diff changeset
   503
                    message.Destroy()
b1144bb36605 Bug with array dimensions edition fixed
lbessard
parents: 205
diff changeset
   504
                    self.RefreshView()
b1144bb36605 Bug with array dimensions edition fixed
lbessard
parents: 205
diff changeset
   505
                    return
b1144bb36605 Bug with array dimensions edition fixed
lbessard
parents: 205
diff changeset
   506
                infos["dimensions"].append(map(int, bounds))
125
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   507
            infos["initial"] = self.ArrayInitialValue.GetValue()
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   508
        self.Controler.SetDataTypeInfos(self.TagName, infos)
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   509
        self.ParentWindow.RefreshTitle()
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   510
        self.ParentWindow.RefreshEditMenu()
394d9f168258 Adding support for execution order in PLCGenerator
lbessard
parents:
diff changeset
   511
231
fc2d6cbb8b39 Adding support for highlighing compiling errors from matiec
lbessard
parents: 215
diff changeset
   512
#-------------------------------------------------------------------------------
fc2d6cbb8b39 Adding support for highlighing compiling errors from matiec
lbessard
parents: 215
diff changeset
   513
#                        Errors showing functions
fc2d6cbb8b39 Adding support for highlighing compiling errors from matiec
lbessard
parents: 215
diff changeset
   514
#-------------------------------------------------------------------------------
fc2d6cbb8b39 Adding support for highlighing compiling errors from matiec
lbessard
parents: 215
diff changeset
   515
fc2d6cbb8b39 Adding support for highlighing compiling errors from matiec
lbessard
parents: 215
diff changeset
   516
    def ClearErrors(self):
fc2d6cbb8b39 Adding support for highlighing compiling errors from matiec
lbessard
parents: 215
diff changeset
   517
        self.Errors = []
fc2d6cbb8b39 Adding support for highlighing compiling errors from matiec
lbessard
parents: 215
diff changeset
   518
        self.RefreshView()
fc2d6cbb8b39 Adding support for highlighing compiling errors from matiec
lbessard
parents: 215
diff changeset
   519
fc2d6cbb8b39 Adding support for highlighing compiling errors from matiec
lbessard
parents: 215
diff changeset
   520
    def AddShownError(self, infos, start, end):
fc2d6cbb8b39 Adding support for highlighing compiling errors from matiec
lbessard
parents: 215
diff changeset
   521
        self.Errors.append((infos, start, end))
fc2d6cbb8b39 Adding support for highlighing compiling errors from matiec
lbessard
parents: 215
diff changeset
   522
fc2d6cbb8b39 Adding support for highlighing compiling errors from matiec
lbessard
parents: 215
diff changeset
   523
    def ShowErrors(self):
fc2d6cbb8b39 Adding support for highlighing compiling errors from matiec
lbessard
parents: 215
diff changeset
   524
        type_infos = self.Controler.GetDataTypeInfos(self.TagName)
fc2d6cbb8b39 Adding support for highlighing compiling errors from matiec
lbessard
parents: 215
diff changeset
   525
        for infos, start, end in self.Errors:
fc2d6cbb8b39 Adding support for highlighing compiling errors from matiec
lbessard
parents: 215
diff changeset
   526
            if infos[0] == "base":
fc2d6cbb8b39 Adding support for highlighing compiling errors from matiec
lbessard
parents: 215
diff changeset
   527
                if type_infos["type"] == "Directly":
fc2d6cbb8b39 Adding support for highlighing compiling errors from matiec
lbessard
parents: 215
diff changeset
   528
                    self.DirectlyBaseType.SetBackgroundColour(wx.Colour(255, 255, 0))
fc2d6cbb8b39 Adding support for highlighing compiling errors from matiec
lbessard
parents: 215
diff changeset
   529
                    self.DirectlyBaseType.SetForegroundColour(wx.RED)
fc2d6cbb8b39 Adding support for highlighing compiling errors from matiec
lbessard
parents: 215
diff changeset
   530
                elif type_infos["type"] == "Subrange":
fc2d6cbb8b39 Adding support for highlighing compiling errors from matiec
lbessard
parents: 215
diff changeset
   531
                    self.SubrangeBaseType.SetBackgroundColour(wx.Colour(255, 255, 0))
fc2d6cbb8b39 Adding support for highlighing compiling errors from matiec
lbessard
parents: 215
diff changeset
   532
                    self.SubrangeBaseType.SetForegroundColour(wx.RED)
fc2d6cbb8b39 Adding support for highlighing compiling errors from matiec
lbessard
parents: 215
diff changeset
   533
                elif type_infos["type"] == "Array":
fc2d6cbb8b39 Adding support for highlighing compiling errors from matiec
lbessard
parents: 215
diff changeset
   534
                    self.ArrayBaseType.SetBackgroundColour(wx.Colour(255, 255, 0))
fc2d6cbb8b39 Adding support for highlighing compiling errors from matiec
lbessard
parents: 215
diff changeset
   535
                    self.ArrayBaseType.SetForegroundColour(wx.RED)
fc2d6cbb8b39 Adding support for highlighing compiling errors from matiec
lbessard
parents: 215
diff changeset
   536
            elif infos[0] == "lower":
fc2d6cbb8b39 Adding support for highlighing compiling errors from matiec
lbessard
parents: 215
diff changeset
   537
                self.SubrangeMinimum.SetBackgroundColour(wx.Colour(255, 255, 0))
fc2d6cbb8b39 Adding support for highlighing compiling errors from matiec
lbessard
parents: 215
diff changeset
   538
                self.SubrangeMaximum.SetForegroundColour(wx.RED)
fc2d6cbb8b39 Adding support for highlighing compiling errors from matiec
lbessard
parents: 215
diff changeset
   539
            elif infos[0] == "upper":
fc2d6cbb8b39 Adding support for highlighing compiling errors from matiec
lbessard
parents: 215
diff changeset
   540
                self.SubrangeMinimum.SetBackgroundColour(wx.Colour(255, 255, 0))
fc2d6cbb8b39 Adding support for highlighing compiling errors from matiec
lbessard
parents: 215
diff changeset
   541
                self.SubrangeMaximum.SetForegroundColour(wx.RED)
fc2d6cbb8b39 Adding support for highlighing compiling errors from matiec
lbessard
parents: 215
diff changeset
   542
            elif infos[0] == "value":
fc2d6cbb8b39 Adding support for highlighing compiling errors from matiec
lbessard
parents: 215
diff changeset
   543
                listctrl = self.EnumeratedValues.GetListCtrl()
fc2d6cbb8b39 Adding support for highlighing compiling errors from matiec
lbessard
parents: 215
diff changeset
   544
                listctrl.SetItemBackgroundColour(infos[1], wx.Colour(255, 255, 0))
fc2d6cbb8b39 Adding support for highlighing compiling errors from matiec
lbessard
parents: 215
diff changeset
   545
                listctrl.SetItemTextColour(infos[1], wx.RED)
fc2d6cbb8b39 Adding support for highlighing compiling errors from matiec
lbessard
parents: 215
diff changeset
   546
                listctrl.Select(listctrl.FocusedItem, False)
fc2d6cbb8b39 Adding support for highlighing compiling errors from matiec
lbessard
parents: 215
diff changeset
   547
            elif infos[0] == "range":
fc2d6cbb8b39 Adding support for highlighing compiling errors from matiec
lbessard
parents: 215
diff changeset
   548
                listctrl = self.EnumeratedValues.GetListCtrl()
fc2d6cbb8b39 Adding support for highlighing compiling errors from matiec
lbessard
parents: 215
diff changeset
   549
                listctrl.SetItemBackgroundColour(infos[1], wx.Colour(255, 255, 0))
fc2d6cbb8b39 Adding support for highlighing compiling errors from matiec
lbessard
parents: 215
diff changeset
   550
                listctrl.SetItemTextColour(infos[1], wx.RED)
fc2d6cbb8b39 Adding support for highlighing compiling errors from matiec
lbessard
parents: 215
diff changeset
   551
                listctrl.SetStringSelection("")
fc2d6cbb8b39 Adding support for highlighing compiling errors from matiec
lbessard
parents: 215
diff changeset
   552
            elif infos[0] == "initial":
fc2d6cbb8b39 Adding support for highlighing compiling errors from matiec
lbessard
parents: 215
diff changeset
   553
                if type_infos["type"] == "Directly":
fc2d6cbb8b39 Adding support for highlighing compiling errors from matiec
lbessard
parents: 215
diff changeset
   554
                    text = self.DirectlyInitialValue.GetValue()
fc2d6cbb8b39 Adding support for highlighing compiling errors from matiec
lbessard
parents: 215
diff changeset
   555
                    self.DirectlyInitialValue.SetValue(text[:start[1]])
fc2d6cbb8b39 Adding support for highlighing compiling errors from matiec
lbessard
parents: 215
diff changeset
   556
                    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
   557
                    self.DirectlyInitialValue.AppendText(text[start[1]:end[1] + 1])
fc2d6cbb8b39 Adding support for highlighing compiling errors from matiec
lbessard
parents: 215
diff changeset
   558
                    self.DirectlyInitialValue.SetDefaultStyle(wx.TextAttr(wx.BLACK, wx.WHITE))
fc2d6cbb8b39 Adding support for highlighing compiling errors from matiec
lbessard
parents: 215
diff changeset
   559
                    self.DirectlyInitialValue.AppendText(text[end[1] + 1:])
fc2d6cbb8b39 Adding support for highlighing compiling errors from matiec
lbessard
parents: 215
diff changeset
   560
                elif type_infos["type"] == "Subrange":
fc2d6cbb8b39 Adding support for highlighing compiling errors from matiec
lbessard
parents: 215
diff changeset
   561
                    self.SubrangeInitialValue.SetBackgroundColour(wx.Colour(255, 255, 0))
fc2d6cbb8b39 Adding support for highlighing compiling errors from matiec
lbessard
parents: 215
diff changeset
   562
                    self.SubrangeInitialValue.SetForegroundColour(wx.RED)
fc2d6cbb8b39 Adding support for highlighing compiling errors from matiec
lbessard
parents: 215
diff changeset
   563
                elif type_infos["type"] == "Enumerated":
fc2d6cbb8b39 Adding support for highlighing compiling errors from matiec
lbessard
parents: 215
diff changeset
   564
                    self.EnumeratedInitialValue.SetBackgroundColour(wx.Colour(255, 255, 0))
fc2d6cbb8b39 Adding support for highlighing compiling errors from matiec
lbessard
parents: 215
diff changeset
   565
                    self.EnumeratedInitialValue.SetForegroundColour(wx.RED)
fc2d6cbb8b39 Adding support for highlighing compiling errors from matiec
lbessard
parents: 215
diff changeset
   566
                elif type_infos["type"] == "Array":
fc2d6cbb8b39 Adding support for highlighing compiling errors from matiec
lbessard
parents: 215
diff changeset
   567
                    text = self.ArrayInitialValue.GetValue()
fc2d6cbb8b39 Adding support for highlighing compiling errors from matiec
lbessard
parents: 215
diff changeset
   568
                    self.ArrayInitialValue.SetValue(text[:start[1]])
fc2d6cbb8b39 Adding support for highlighing compiling errors from matiec
lbessard
parents: 215
diff changeset
   569
                    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
   570
                    self.ArrayInitialValue.AppendText(text[start[1]:end[1] + 1])
fc2d6cbb8b39 Adding support for highlighing compiling errors from matiec
lbessard
parents: 215
diff changeset
   571
                    self.ArrayInitialValue.SetDefaultStyle(wx.TextAttr(wx.BLACK, wx.WHITE))
fc2d6cbb8b39 Adding support for highlighing compiling errors from matiec
lbessard
parents: 215
diff changeset
   572
                    self.ArrayInitialValue.AppendText(text[end[1] + 1:])