canfestival/SlaveEditor.py
author Edouard Tisserant
Fri, 20 Jun 2014 21:36:23 +0200
changeset 1420 71b1545d746f
parent 1286 adda406d3960
child 1511 91538d0c242c
permissions -rw-r--r--
Enable overloading of task triggerring source cell editor (SINGLE) in resource editor. PLCGenerator now generates MULTI keywork instead of SINGLE when task's activation is surroundes with square brackets
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
1021
939b1a1c7aa5 Fixed bug when importing NodeEditorTemplate
Laurent Bessard
parents: 920
diff changeset
     5
from nodeeditortemplate 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
    
920
1499a4d225db Replaced SplitterWindow in ConfTreeNodeEditor by Notebook
Laurent Bessard
parents: 847
diff changeset
    20
    CONFNODEEDITOR_TABS = [
1499a4d225db Replaced SplitterWindow in ConfTreeNodeEditor by Notebook
Laurent Bessard
parents: 847
diff changeset
    21
        (_("CANOpen slave"), "_create_SlaveNodeEditor")]
1499a4d225db Replaced SplitterWindow in ConfTreeNodeEditor by Notebook
Laurent Bessard
parents: 847
diff changeset
    22
    
1499a4d225db Replaced SplitterWindow in ConfTreeNodeEditor by Notebook
Laurent Bessard
parents: 847
diff changeset
    23
    def _create_SlaveNodeEditor(self, prnt):
1499a4d225db Replaced SplitterWindow in ConfTreeNodeEditor by Notebook
Laurent Bessard
parents: 847
diff changeset
    24
        self.SlaveNodeEditor = EditingPanel(prnt, self, self.Controler, self.Editable)
1499a4d225db Replaced SplitterWindow in ConfTreeNodeEditor by Notebook
Laurent Bessard
parents: 847
diff changeset
    25
        return self.SlaveNodeEditor
680
61746934df41 Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff changeset
    26
        
61746934df41 Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff changeset
    27
    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
    28
        self.Editable = editable
762
aaacc83aa86b Modifying canfestival plugin to following the new Beremiz confnode paradigm
laurent
parents: 738
diff changeset
    29
        ConfTreeNodeEditor.__init__(self, parent, controler, window)
680
61746934df41 Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff changeset
    30
        NodeEditorTemplate.__init__(self, controler, window, False)
61746934df41 Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff changeset
    31
    
61746934df41 Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff changeset
    32
    def __del__(self):
61746934df41 Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff changeset
    33
        self.Controler.OnCloseEditor(self)
61746934df41 Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff changeset
    34
    
717
1c23952dbde1 refactoring
Edouard Tisserant
parents: 680
diff changeset
    35
    def GetConfNodeMenuItems(self):
680
61746934df41 Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff changeset
    36
        if self.Editable:
61746934df41 Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff changeset
    37
            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
    38
                        (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
    39
                        (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
    40
                        (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
    41
                        (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
    42
                        (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
    43
            
61746934df41 Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff changeset
    44
            profile = self.Controler.GetCurrentProfileName()
61746934df41 Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff changeset
    45
            if profile not in ("None", "DS-301"):
61746934df41 Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff changeset
    46
                other_profile_text = _("%s Profile") % profile
61746934df41 Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff changeset
    47
                add_menu.append((wx.ITEM_SEPARATOR, None))
61746934df41 Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff changeset
    48
                for text, indexes in self.Manager.GetCurrentSpecificMenu():
61746934df41 Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff changeset
    49
                    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
    50
            else:
61746934df41 Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff changeset
    51
                other_profile_text = _('Other Profile')
61746934df41 Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff changeset
    52
            
845
412a9f05070f Fixing CanFestival master and slave nodeid when generating code for PLC
laurent
parents: 816
diff changeset
    53
            return [(wx.ITEM_NORMAL, (_('DS-301 Profile'), ID_SLAVEEDITORCONFNODEMENUDS301PROFILE, '', self.OnCommunicationMenu)),
717
1c23952dbde1 refactoring
Edouard Tisserant
parents: 680
diff changeset
    54
                    (wx.ITEM_NORMAL, (_('DS-302 Profile'), ID_SLAVEEDITORCONFNODEMENUDS302PROFILE, '', self.OnOtherCommunicationMenu)),
1c23952dbde1 refactoring
Edouard Tisserant
parents: 680
diff changeset
    55
                    (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
    56
                    (wx.ITEM_SEPARATOR, None),
717
1c23952dbde1 refactoring
Edouard Tisserant
parents: 680
diff changeset
    57
                    (add_menu, (_('Add'), ID_SLAVEEDITORCONFNODEMENUADD))]
680
61746934df41 Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff changeset
    58
        return []
61746934df41 Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff changeset
    59
    
717
1c23952dbde1 refactoring
Edouard Tisserant
parents: 680
diff changeset
    60
    def RefreshConfNodeMenu(self, confnode_menu):
816
079ed646266f Fix bug in canfestivel extension when Show Master Generated on Windows
laurent
parents: 814
diff changeset
    61
        if self.Editable:
079ed646266f Fix bug in canfestivel extension when Show Master Generated on Windows
laurent
parents: 814
diff changeset
    62
            confnode_menu.Enable(ID_SLAVEEDITORCONFNODEMENUDSOTHERPROFILE, False)
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 RefreshView(self):
762
aaacc83aa86b Modifying canfestival plugin to following the new Beremiz confnode paradigm
laurent
parents: 738
diff changeset
    65
        ConfTreeNodeEditor.RefreshView(self)
920
1499a4d225db Replaced SplitterWindow in ConfTreeNodeEditor by Notebook
Laurent Bessard
parents: 847
diff changeset
    66
        self.SlaveNodeEditor.RefreshIndexList()
680
61746934df41 Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff changeset
    67
61746934df41 Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff changeset
    68
    def RefreshCurrentIndexList(self):
61746934df41 Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff changeset
    69
        self.RefreshView()
61746934df41 Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff changeset
    70
    
61746934df41 Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff changeset
    71
    def RefreshBufferState(self):
61746934df41 Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff changeset
    72
        self.ParentWindow.RefreshTitle()
61746934df41 Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff changeset
    73
        self.ParentWindow.RefreshFileMenu()
61746934df41 Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff changeset
    74
        self.ParentWindow.RefreshEditMenu()
61746934df41 Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff changeset
    75
        self.ParentWindow.RefreshPageTitles()
777
daa6941fe21a Fix bug with Show Master functionality
laurent
parents: 762
diff changeset
    76
daa6941fe21a Fix bug with Show Master functionality
laurent
parents: 762
diff changeset
    77
class MasterViewer(SlaveEditor):
1286
adda406d3960 Fixed bug when displaying Master generated Object Dictionary in canfestival extension
Laurent Bessard
parents: 1021
diff changeset
    78
    SHOW_BASE_PARAMS = False
777
daa6941fe21a Fix bug with Show Master functionality
laurent
parents: 762
diff changeset
    79
    SHOW_PARAMS = False
1286
adda406d3960 Fixed bug when displaying Master generated Object Dictionary in canfestival extension
Laurent Bessard
parents: 1021
diff changeset
    80
    
847
b157705a9024 Fix bug in generated master panel in CanFestival extension
laurent
parents: 845
diff changeset
    81
    def __init__(self, parent, controler, window, tagname):
777
daa6941fe21a Fix bug with Show Master functionality
laurent
parents: 762
diff changeset
    82
        SlaveEditor.__init__(self, parent, controler, window, False)
847
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
        self.TagName = tagname
b157705a9024 Fix bug in generated master panel in CanFestival extension
laurent
parents: 845
diff changeset
    85
    
b157705a9024 Fix bug in generated master panel in CanFestival extension
laurent
parents: 845
diff changeset
    86
    def GetTagName(self):
b157705a9024 Fix bug in generated master panel in CanFestival extension
laurent
parents: 845
diff changeset
    87
        return self.TagName
b157705a9024 Fix bug in generated master panel in CanFestival extension
laurent
parents: 845
diff changeset
    88
    
b157705a9024 Fix bug in generated master panel in CanFestival extension
laurent
parents: 845
diff changeset
    89
    def GetCurrentNodeId(self):
b157705a9024 Fix bug in generated master panel in CanFestival extension
laurent
parents: 845
diff changeset
    90
        return None
b157705a9024 Fix bug in generated master panel in CanFestival extension
laurent
parents: 845
diff changeset
    91
    
b157705a9024 Fix bug in generated master panel in CanFestival extension
laurent
parents: 845
diff changeset
    92
    def GetInstancePath(self):
b157705a9024 Fix bug in generated master panel in CanFestival extension
laurent
parents: 845
diff changeset
    93
        return self.Controler.CTNFullName() + ".generated_master"
b157705a9024 Fix bug in generated master panel in CanFestival extension
laurent
parents: 845
diff changeset
    94
    
b157705a9024 Fix bug in generated master panel in CanFestival extension
laurent
parents: 845
diff changeset
    95
    def GetTitle(self):
b157705a9024 Fix bug in generated master panel in CanFestival extension
laurent
parents: 845
diff changeset
    96
        return self.GetInstancePath()
b157705a9024 Fix bug in generated master panel in CanFestival extension
laurent
parents: 845
diff changeset
    97
        
b157705a9024 Fix bug in generated master panel in CanFestival extension
laurent
parents: 845
diff changeset
    98
    def IsViewing(self, tagname):
b157705a9024 Fix bug in generated master panel in CanFestival extension
laurent
parents: 845
diff changeset
    99
        return self.GetInstancePath() == tagname
1286
adda406d3960 Fixed bug when displaying Master generated Object Dictionary in canfestival extension
Laurent Bessard
parents: 1021
diff changeset
   100
adda406d3960 Fixed bug when displaying Master generated Object Dictionary in canfestival extension
Laurent Bessard
parents: 1021
diff changeset
   101
    def RefreshView(self):
adda406d3960 Fixed bug when displaying Master generated Object Dictionary in canfestival extension
Laurent Bessard
parents: 1021
diff changeset
   102
        self.SlaveNodeEditor.RefreshIndexList()
adda406d3960 Fixed bug when displaying Master generated Object Dictionary in canfestival extension
Laurent Bessard
parents: 1021
diff changeset
   103