canfestival/SlaveEditor.py
author Laurent Bessard
Wed, 31 Oct 2012 12:04:40 +0100
changeset 873 8737f1554494
parent 847 b157705a9024
child 920 1499a4d225db
permissions -rw-r--r--
Fix bug Variable and Continuation BoundingBox not refreshed when using Type modification shortcuts
680
61746934df41 Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff changeset
     1
61746934df41 Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff changeset
     2
import wx
61746934df41 Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff changeset
     3
61746934df41 Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff changeset
     4
from subindextable import EditingPanel
61746934df41 Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff changeset
     5
from nodeeditor import NodeEditorTemplate
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents: 777
diff changeset
     6
from editors.ConfTreeNodeEditor import ConfTreeNodeEditor
680
61746934df41 Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff changeset
     7
717
1c23952dbde1 refactoring
Edouard Tisserant
parents: 680
diff changeset
     8
[ID_SLAVEEDITORCONFNODEMENUNODEINFOS, ID_SLAVEEDITORCONFNODEMENUDS301PROFILE,
1c23952dbde1 refactoring
Edouard Tisserant
parents: 680
diff changeset
     9
 ID_SLAVEEDITORCONFNODEMENUDS302PROFILE, ID_SLAVEEDITORCONFNODEMENUDSOTHERPROFILE,
1c23952dbde1 refactoring
Edouard Tisserant
parents: 680
diff changeset
    10
 ID_SLAVEEDITORCONFNODEMENUADD, 
1c23952dbde1 refactoring
Edouard Tisserant
parents: 680
diff changeset
    11
] = [wx.NewId() for _init_coll_ConfNodeMenu_Items in range(5)]
680
61746934df41 Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff changeset
    12
61746934df41 Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff changeset
    13
[ID_SLAVEEDITORADDMENUSDOSERVER, ID_SLAVEEDITORADDMENUSDOCLIENT,
61746934df41 Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff changeset
    14
 ID_SLAVEEDITORADDMENUPDOTRANSMIT, ID_SLAVEEDITORADDMENUPDORECEIVE,
61746934df41 Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff changeset
    15
 ID_SLAVEEDITORADDMENUMAPVARIABLE, ID_SLAVEEDITORADDMENUUSERTYPE,
61746934df41 Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff changeset
    16
] = [wx.NewId() for _init_coll_AddMenu_Items in range(6)]
61746934df41 Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff changeset
    17
762
aaacc83aa86b Modifying canfestival plugin to following the new Beremiz confnode paradigm
laurent
parents: 738
diff changeset
    18
class SlaveEditor(ConfTreeNodeEditor, NodeEditorTemplate):
680
61746934df41 Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff changeset
    19
    
762
aaacc83aa86b Modifying canfestival plugin to following the new Beremiz confnode paradigm
laurent
parents: 738
diff changeset
    20
    def _init_ConfNodeEditor(self, prnt):
aaacc83aa86b Modifying canfestival plugin to following the new Beremiz confnode paradigm
laurent
parents: 738
diff changeset
    21
        self.ConfNodeEditor = EditingPanel(prnt, self, self.Controler, self.Editable)
680
61746934df41 Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff changeset
    22
        
61746934df41 Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff changeset
    23
    def __init__(self, parent, controler, window, editable=True):
61746934df41 Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff changeset
    24
        self.Editable = editable
762
aaacc83aa86b Modifying canfestival plugin to following the new Beremiz confnode paradigm
laurent
parents: 738
diff changeset
    25
        ConfTreeNodeEditor.__init__(self, parent, controler, window)
680
61746934df41 Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff changeset
    26
        NodeEditorTemplate.__init__(self, controler, window, False)
61746934df41 Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff changeset
    27
    
61746934df41 Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff changeset
    28
    def __del__(self):
61746934df41 Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff changeset
    29
        self.Controler.OnCloseEditor(self)
61746934df41 Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff changeset
    30
    
717
1c23952dbde1 refactoring
Edouard Tisserant
parents: 680
diff changeset
    31
    def GetConfNodeMenuItems(self):
680
61746934df41 Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff changeset
    32
        if self.Editable:
61746934df41 Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff changeset
    33
            add_menu = [(wx.ITEM_NORMAL, (_('SDO Server'), ID_SLAVEEDITORADDMENUSDOSERVER, '', self.OnAddSDOServerMenu)),
61746934df41 Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff changeset
    34
                        (wx.ITEM_NORMAL, (_('SDO Client'), ID_SLAVEEDITORADDMENUSDOCLIENT, '', self.OnAddSDOClientMenu)),
61746934df41 Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff changeset
    35
                        (wx.ITEM_NORMAL, (_('PDO Transmit'), ID_SLAVEEDITORADDMENUPDOTRANSMIT, '', self.OnAddPDOTransmitMenu)),
61746934df41 Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff changeset
    36
                        (wx.ITEM_NORMAL, (_('PDO Receive'), ID_SLAVEEDITORADDMENUPDORECEIVE, '', self.OnAddPDOReceiveMenu)),
61746934df41 Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff changeset
    37
                        (wx.ITEM_NORMAL, (_('Map Variable'), ID_SLAVEEDITORADDMENUMAPVARIABLE, '', self.OnAddMapVariableMenu)),
61746934df41 Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff changeset
    38
                        (wx.ITEM_NORMAL, (_('User Type'), ID_SLAVEEDITORADDMENUUSERTYPE, '', self.OnAddUserTypeMenu))]
61746934df41 Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff changeset
    39
            
61746934df41 Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff changeset
    40
            profile = self.Controler.GetCurrentProfileName()
61746934df41 Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff changeset
    41
            if profile not in ("None", "DS-301"):
61746934df41 Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff changeset
    42
                other_profile_text = _("%s Profile") % profile
61746934df41 Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff changeset
    43
                add_menu.append((wx.ITEM_SEPARATOR, None))
61746934df41 Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff changeset
    44
                for text, indexes in self.Manager.GetCurrentSpecificMenu():
61746934df41 Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff changeset
    45
                    add_menu.append((wx.ITEM_NORMAL, (text, wx.NewId(), '', self.GetProfileCallBack(text))))
61746934df41 Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff changeset
    46
            else:
61746934df41 Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff changeset
    47
                other_profile_text = _('Other Profile')
61746934df41 Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff changeset
    48
            
845
412a9f05070f Fixing CanFestival master and slave nodeid when generating code for PLC
laurent
parents: 816
diff changeset
    49
            return [(wx.ITEM_NORMAL, (_('DS-301 Profile'), ID_SLAVEEDITORCONFNODEMENUDS301PROFILE, '', self.OnCommunicationMenu)),
717
1c23952dbde1 refactoring
Edouard Tisserant
parents: 680
diff changeset
    50
                    (wx.ITEM_NORMAL, (_('DS-302 Profile'), ID_SLAVEEDITORCONFNODEMENUDS302PROFILE, '', self.OnOtherCommunicationMenu)),
1c23952dbde1 refactoring
Edouard Tisserant
parents: 680
diff changeset
    51
                    (wx.ITEM_NORMAL, (other_profile_text, ID_SLAVEEDITORCONFNODEMENUDSOTHERPROFILE, '', self.OnEditProfileMenu)),
680
61746934df41 Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff changeset
    52
                    (wx.ITEM_SEPARATOR, None),
717
1c23952dbde1 refactoring
Edouard Tisserant
parents: 680
diff changeset
    53
                    (add_menu, (_('Add'), ID_SLAVEEDITORCONFNODEMENUADD))]
680
61746934df41 Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff changeset
    54
        return []
61746934df41 Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff changeset
    55
    
717
1c23952dbde1 refactoring
Edouard Tisserant
parents: 680
diff changeset
    56
    def RefreshConfNodeMenu(self, confnode_menu):
816
079ed646266f Fix bug in canfestivel extension when Show Master Generated on Windows
laurent
parents: 814
diff changeset
    57
        if self.Editable:
079ed646266f Fix bug in canfestivel extension when Show Master Generated on Windows
laurent
parents: 814
diff changeset
    58
            confnode_menu.Enable(ID_SLAVEEDITORCONFNODEMENUDSOTHERPROFILE, False)
680
61746934df41 Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff changeset
    59
61746934df41 Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff changeset
    60
    def RefreshView(self):
762
aaacc83aa86b Modifying canfestival plugin to following the new Beremiz confnode paradigm
laurent
parents: 738
diff changeset
    61
        ConfTreeNodeEditor.RefreshView(self)
aaacc83aa86b Modifying canfestival plugin to following the new Beremiz confnode paradigm
laurent
parents: 738
diff changeset
    62
        self.ConfNodeEditor.RefreshIndexList()
680
61746934df41 Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff changeset
    63
61746934df41 Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff changeset
    64
    def RefreshCurrentIndexList(self):
61746934df41 Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff changeset
    65
        self.RefreshView()
61746934df41 Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff changeset
    66
    
61746934df41 Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff changeset
    67
    def RefreshBufferState(self):
61746934df41 Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff changeset
    68
        self.ParentWindow.RefreshTitle()
61746934df41 Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff changeset
    69
        self.ParentWindow.RefreshFileMenu()
61746934df41 Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff changeset
    70
        self.ParentWindow.RefreshEditMenu()
61746934df41 Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff changeset
    71
        self.ParentWindow.RefreshPageTitles()
777
daa6941fe21a Fix bug with Show Master functionality
laurent
parents: 762
diff changeset
    72
daa6941fe21a Fix bug with Show Master functionality
laurent
parents: 762
diff changeset
    73
class MasterViewer(SlaveEditor):
daa6941fe21a Fix bug with Show Master functionality
laurent
parents: 762
diff changeset
    74
    SHOW_PARAMS = False
daa6941fe21a Fix bug with Show Master functionality
laurent
parents: 762
diff changeset
    75
847
b157705a9024 Fix bug in generated master panel in CanFestival extension
laurent
parents: 845
diff changeset
    76
    def __init__(self, parent, controler, window, tagname):
777
daa6941fe21a Fix bug with Show Master functionality
laurent
parents: 762
diff changeset
    77
        SlaveEditor.__init__(self, parent, controler, window, False)
847
b157705a9024 Fix bug in generated master panel in CanFestival extension
laurent
parents: 845
diff changeset
    78
    
b157705a9024 Fix bug in generated master panel in CanFestival extension
laurent
parents: 845
diff changeset
    79
        self.TagName = tagname
b157705a9024 Fix bug in generated master panel in CanFestival extension
laurent
parents: 845
diff changeset
    80
    
b157705a9024 Fix bug in generated master panel in CanFestival extension
laurent
parents: 845
diff changeset
    81
    def GetTagName(self):
b157705a9024 Fix bug in generated master panel in CanFestival extension
laurent
parents: 845
diff changeset
    82
        return self.TagName
b157705a9024 Fix bug in generated master panel in CanFestival extension
laurent
parents: 845
diff changeset
    83
    
b157705a9024 Fix bug in generated master panel in CanFestival extension
laurent
parents: 845
diff changeset
    84
    def GetCurrentNodeId(self):
b157705a9024 Fix bug in generated master panel in CanFestival extension
laurent
parents: 845
diff changeset
    85
        return None
b157705a9024 Fix bug in generated master panel in CanFestival extension
laurent
parents: 845
diff changeset
    86
    
b157705a9024 Fix bug in generated master panel in CanFestival extension
laurent
parents: 845
diff changeset
    87
    def GetInstancePath(self):
b157705a9024 Fix bug in generated master panel in CanFestival extension
laurent
parents: 845
diff changeset
    88
        return self.Controler.CTNFullName() + ".generated_master"
b157705a9024 Fix bug in generated master panel in CanFestival extension
laurent
parents: 845
diff changeset
    89
    
b157705a9024 Fix bug in generated master panel in CanFestival extension
laurent
parents: 845
diff changeset
    90
    def GetTitle(self):
b157705a9024 Fix bug in generated master panel in CanFestival extension
laurent
parents: 845
diff changeset
    91
        return self.GetInstancePath()
b157705a9024 Fix bug in generated master panel in CanFestival extension
laurent
parents: 845
diff changeset
    92
        
b157705a9024 Fix bug in generated master panel in CanFestival extension
laurent
parents: 845
diff changeset
    93
    def IsViewing(self, tagname):
b157705a9024 Fix bug in generated master panel in CanFestival extension
laurent
parents: 845
diff changeset
    94
        return self.GetInstancePath() == tagname