etherlab/EtherCATManagementEditor.py
author Edouard Tisserant <edouard.tisserant@gmail.com>
Wed, 20 Nov 2019 16:57:15 +0100
branchethercat_from_kosmos
changeset 2641 c9deff128c37
parent 2165 02a2b5dee5e3
child 2643 b98d9e08231f
permissions -rw-r--r--
EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
2152
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
     1
#!/usr/bin/env python
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
     2
# -*- coding: utf-8 -*-
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
     3
2165
02a2b5dee5e3 Merged GPL + LGPL v2 or later EtherCAT extension. Fixed headers and copyright notice.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2152
diff changeset
     4
# This file is part of Beremiz
2152
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
     5
#
2165
02a2b5dee5e3 Merged GPL + LGPL v2 or later EtherCAT extension. Fixed headers and copyright notice.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2152
diff changeset
     6
# Copyright (C) 2013: Real-Time & Embedded Systems (RTES) Lab., University of Seoul
2152
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
     7
#
2165
02a2b5dee5e3 Merged GPL + LGPL v2 or later EtherCAT extension. Fixed headers and copyright notice.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2152
diff changeset
     8
# See COPYING file for copyrights details.
2152
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
     9
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
    10
import os
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
    11
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
    12
import wx
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
    13
import wx.grid
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
    14
import wx.gizmos
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
    15
import wx.lib.buttons
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
    16
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
    17
# --------------------------------------------------------------------
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
    18
from controls import CustomGrid, CustomTable
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
    19
# --------------------------------------------------------------------
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
    20
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
    21
# ------------ for SDO Management --------------------
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
    22
import string
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
    23
import wx.grid as gridlib
2641
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
    24
try:
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
    25
    from agw import pyprogress as PP
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
    26
except ImportError:
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
    27
    import wx.lib.agw.pyprogress as PP
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
    28
try:
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
    29
    from agw import genericmessagedialog as GMD
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
    30
except ImportError:
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
    31
    import wx.lib.agw.genericmessagedialog as GMD
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
    32
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
    33
from threading import Timer, Thread, Lock
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
    34
#from time import localtime
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
    35
import time
2152
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
    36
#-------------------------------------------------------------
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
    37
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
    38
# ------------ for register management --------------- 
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
    39
from xml.dom import minidom
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
    40
#-------------------------------------------------------------
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
    41
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
    42
# ----------------------------- For Sync Manager Table -----------------------------------
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
    43
def GetSyncManagersTableColnames():
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
    44
    """
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
    45
    Returns column names of SyncManager Table in Slave state panel.
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
    46
    """
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
    47
    _ = lambda x : x
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
    48
    return ["#", _("Name"), _("Start Address"), _("Default Size"), _("Control Byte"), _("Enable")]
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
    49
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
    50
#-------------------------------------------------------------------------------
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
    51
#                    Sync Managers Table
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
    52
#-------------------------------------------------------------------------------
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
    53
class SyncManagersTable(CustomTable):
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
    54
    def GetValue(self, row, col): 
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
    55
        if row < self.GetNumberRows():
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
    56
            if col == 0:
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
    57
                return row
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
    58
            return self.data[row].get(self.GetColLabelValue(col, False), "")
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
    59
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
    60
#-------------------------------------------------------------------------------
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
    61
#                    EtherCAT Management Treebook
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
    62
#-------------------------------------------------------------------------------
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
    63
class EtherCATManagementTreebook(wx.Treebook):
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
    64
    def __init__(self, parent, controler, node_editor):
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
    65
        """
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
    66
        Constructor
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
    67
        @param parent: Reference to the parent wx.ScrolledWindow object
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
    68
        @param controler: _EthercatSlaveCTN class in EthercatSlave.py
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
    69
        @param node_editor: Reference to Beremiz frame
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
    70
        """
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
    71
        wx.Treebook.__init__(self, parent, -1, size=wx.DefaultSize, style=wx.BK_DEFAULT)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
    72
        self.parent = parent
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
    73
        self.Controler = controler
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
    74
        self.NodeEditor = node_editor
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
    75
        self.EtherCATManagementClassObject = {}
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
    76
        
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
    77
        # fill EtherCAT Management Treebook
2641
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
    78
        #for pname, pclass, subs in [
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
    79
        #    ("Slave State",        SlaveStatePanelClass, []),
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
    80
        #    ("SDO Management",     SDOPanelClass, []),
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
    81
        #    ("PDO Mapping",     PDOPanelClass, []),
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
    82
        #    ("ESC Management",     EEPROMAccessPanel, [        
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
    83
        #            ("Smart View",  SlaveSiiSmartView),
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
    84
        #            ("Hex View",    HexView)]),
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
    85
        #    ("Register Access",    RegisterAccessPanel, [])]:
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
    86
        #        pclass = pclass(self, self.Controler)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
    87
        #        self.AddPage(pclass, pname)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
    88
        #        for spname, spclass in subs:
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
    89
        #            spclass = spclass(self, self.Controler)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
    90
        #            self.AddSubPage(spclass, spname)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
    91
2152
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
    92
        for pname, pclass, subs in [
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
    93
            ("Slave State",        SlaveStatePanelClass, []),
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
    94
            ("SDO Management",     SDOPanelClass, []),
2641
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
    95
            ("PDO Mapping",     PDOPanelClass, [
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
    96
                    ("Rx PDO", RxPDOPanelClass),
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
    97
                    ("Tx PDO", TxPDOPanelClass)]),
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
    98
            ("MDP Setting",		MDPPanel, []),
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
    99
            ("ESC Management",     EEPROMAccessPanel, [
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   100
                    ("Smart View",  SlaveSiiSmartView),
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   101
                    ("Hex View",    HexView)]),
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   102
            ("Register Access",    RegisterAccessPanel, []),
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   103
            ("DC Configuration",    DCConfigPanel, [])
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   104
            ]:
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   105
                pclass = pclass(self, self.Controler)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   106
                self.AddPage(pclass, pname)
2152
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   107
                for spname, spclass in subs:
2641
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   108
                    spclass = spclass(self, self.Controler)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   109
                    self.AddSubPage(spclass, spname)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   110
2152
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   111
#-------------------------------------------------------------------------------
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   112
#                    For SlaveState Panel
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   113
#-------------------------------------------------------------------------------        
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   114
class SlaveStatePanelClass(wx.Panel):
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   115
    def __init__(self, parent, controler):
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   116
        """
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   117
        Constructor
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   118
        @param parent: Reference to the parent EtherCATManagementTreebook class
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   119
        @param controler: _EthercatSlaveCTN class in EthercatSlave.py
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   120
        """
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   121
        wx.Panel.__init__(self, parent, -1, (0, 0), size=wx.DefaultSize, style = wx.SUNKEN_BORDER)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   122
        self.Controler = controler
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   123
        self.parent = parent
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   124
        
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   125
        # initialize SlaveStatePanel UI dictionaries
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   126
        self.StaticBoxDic = {}
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   127
        self.StaticTextDic = {}
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   128
        self.TextCtrlDic = {}
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   129
        self.ButtonDic = {}
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   130
        
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   131
        # iniitalize BoxSizer and FlexGridSizer
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   132
        self.SizerDic = {
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   133
            "SlaveState_main_sizer" : wx.BoxSizer(wx.VERTICAL),
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   134
            "SlaveState_inner_main_sizer" : wx.FlexGridSizer(cols=1, hgap=50, rows=3, vgap=10),
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   135
            "SlaveInfosDetailsInnerSizer" : wx.FlexGridSizer(cols=4, hgap=10, rows=2, vgap=10),
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   136
            "SyncManagerInnerSizer" : wx.FlexGridSizer(cols=1, hgap=5, rows=1, vgap=5),
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   137
            "SlaveState_sizer" : wx.FlexGridSizer(cols=1, hgap=10, rows=2, vgap=10),
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   138
            "SlaveState_up_sizer" : wx.FlexGridSizer(cols=4, hgap=10, rows=2, vgap=10),
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   139
            "SlaveState_down_sizer" : wx.FlexGridSizer(cols=2, hgap=10, rows=1, vgap=10)}
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   140
        
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   141
        # initialize StaticBox and StaticBoxSizer
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   142
        for box_name, box_label in [
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   143
                ("SlaveInfosDetailsBox", "Slave Informations"),
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   144
                ("SyncManagerBox", "Sync Manager"),
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   145
                ("SlaveStateBox", "Slave State Transition && Monitoring")]:
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   146
            self.StaticBoxDic[box_name] = wx.StaticBox(self, label=_(box_label))
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   147
            self.SizerDic[box_name] = wx.StaticBoxSizer(self.StaticBoxDic[box_name])  
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   148
        
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   149
        for statictext_name, statictext_label, textctrl_name in [
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   150
                ("VendorLabel", "Vendor:", "vendor"),
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   151
                ("ProductcodeLabel", "Product code:", "product_code"),
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   152
                ("RevisionnumberLabel", "Slave Count:", "revision_number"),
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   153
                ("PhysicsLabel", "Physics:", "physics")]:
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   154
            self.StaticTextDic[statictext_name] = wx.StaticText(self, label=_(statictext_label))
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   155
            self.TextCtrlDic[textctrl_name] = wx.TextCtrl(self, size=wx.Size(130, 24), style=wx.TE_READONLY)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   156
            self.SizerDic["SlaveInfosDetailsInnerSizer"].AddMany([self.StaticTextDic[statictext_name], 
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   157
                                                               self.TextCtrlDic[textctrl_name]])    
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   158
        
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   159
        self.SizerDic["SlaveInfosDetailsBox"].AddSizer(self.SizerDic["SlaveInfosDetailsInnerSizer"])
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   160
        
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   161
        self.SyncManagersGrid = CustomGrid(self, size=wx.Size(605,155), style=wx.VSCROLL)      
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   162
               
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   163
        self.SizerDic["SyncManagerInnerSizer"].Add(self.SyncManagersGrid)    
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   164
        self.SizerDic["SyncManagerBox"].Add(self.SizerDic["SyncManagerInnerSizer"])
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   165
        
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   166
        for button_name, button_id, button_label, button_tooltipstring, event_method, sub_item in [
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   167
                ("InitButton",   0, "INIT", "State Transition to \"Init\" State",     self.OnButtonClick, []),
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   168
                ("PreOPButton",  1, "PREOP", "State Transition to \"PreOP\" State",   self.OnButtonClick, [
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   169
                        ("TargetStateLabel", "Target State:" , "TargetState")]),
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   170
                ("SafeOPButton", 2, "SAFEOP", "State Transition to \"SafeOP\" State", self.OnButtonClick, []),
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   171
                ("OPButton",     3, "OP",  "State Transition to \"OP\" State",        self.OnButtonClick, [
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   172
                        ("CurrentStateLabel", "Current State:", "CurrentState")])]:
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   173
            self.ButtonDic[button_name] = wx.Button(self, id=button_id ,label=_(button_label))
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   174
            self.ButtonDic[button_name].Bind(wx.EVT_BUTTON, event_method)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   175
            self.ButtonDic[button_name].SetToolTipString(button_tooltipstring)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   176
            self.SizerDic["SlaveState_up_sizer"].Add(self.ButtonDic[button_name])
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   177
            for statictext_name, statictext_label, textctrl_name in sub_item :
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   178
                self.StaticTextDic[statictext_name] = wx.StaticText(self, label=_(statictext_label))
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   179
                self.TextCtrlDic[textctrl_name] = wx.TextCtrl(self, size=wx.DefaultSize, style=wx.TE_READONLY)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   180
                self.SizerDic["SlaveState_up_sizer"].AddMany([self.StaticTextDic[statictext_name], 
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   181
                                                               self.TextCtrlDic[textctrl_name]])
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   182
                
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   183
        for button_name, button_label, button_tooltipstring, event_method in [
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   184
                ("StartTimerButton", "Start State Monitoring", "Slave State Update Restart", self.StartTimer),
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   185
                ("StopTimerButton", "Stop State Monitoring", "Slave State Update Stop", self.CurrentStateThreadStop)]:
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   186
            self.ButtonDic[button_name] = wx.Button(self, label=_(button_label))
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   187
            self.ButtonDic[button_name].Bind(wx.EVT_BUTTON, event_method)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   188
            self.ButtonDic[button_name].SetToolTipString(button_tooltipstring)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   189
            self.SizerDic["SlaveState_down_sizer"].Add(self.ButtonDic[button_name])   
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   190
        
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   191
        self.SizerDic["SlaveState_sizer"].AddMany([self.SizerDic["SlaveState_up_sizer"], 
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   192
            self.SizerDic["SlaveState_down_sizer"]])
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   193
        
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   194
        self.SizerDic["SlaveStateBox"].Add(self.SizerDic["SlaveState_sizer"])
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   195
        
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   196
        self.SizerDic["SlaveState_inner_main_sizer"].AddMany([
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   197
            self.SizerDic["SlaveInfosDetailsBox"], self.SizerDic["SyncManagerBox"],
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   198
            self.SizerDic["SlaveStateBox"]])
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   199
        
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   200
        self.SizerDic["SlaveState_main_sizer"].Add(self.SizerDic["SlaveState_inner_main_sizer"])
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   201
        
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   202
        self.SetSizer(self.SizerDic["SlaveState_main_sizer"])
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   203
        
2641
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   204
        # register a timer for periodic exectuion of slave state update (period: 2000 ms)
2152
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   205
        self.Bind(wx.EVT_TIMER, self.GetCurrentState)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   206
        
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   207
        self.CreateSyncManagerTable()
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   208
        
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   209
        self.Centre()
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   210
    
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   211
    def CreateSyncManagerTable(self):
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   212
        """
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   213
        Create grid for "SyncManager"
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   214
        """
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   215
        # declare Table object 
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   216
        self.SyncManagersTable = SyncManagersTable(self, [], GetSyncManagersTableColnames())
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   217
        self.SyncManagersGrid.SetTable(self.SyncManagersTable)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   218
        # set grid alignment attr. (CENTER)
2641
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   219
        self.SyncManagersGridColAlignements = [wx.ALIGN_CENTER, wx.ALIGN_CENTER, wx.ALIGN_CENTER, 
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   220
                                               wx.ALIGN_CENTER, wx.ALIGN_CENTER, wx.ALIGN_CENTER]
2152
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   221
        # set grid size
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   222
        self.SyncManagersGridColSizes = [40, 150, 100, 100, 100, 100]
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   223
        self.SyncManagersGrid.SetRowLabelSize(0)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   224
        for col in range(self.SyncManagersTable.GetNumberCols()):
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   225
            attr = wx.grid.GridCellAttr()
2641
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   226
            attr.SetAlignment(self.SyncManagersGridColAlignements[col], wx.ALIGN_CENTER)
2152
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   227
            self.SyncManagersGrid.SetColAttr(col, attr)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   228
            self.SyncManagersGrid.SetColMinimalWidth(col, self.SyncManagersGridColSizes[col])
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   229
            self.SyncManagersGrid.AutoSizeColumn(col, False) 
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   230
        
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   231
        self.RefreshSlaveInfos()
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   232
        
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   233
    def RefreshSlaveInfos(self):
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   234
        """
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   235
        Fill data in "Slave Information" and "SyncManager"
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   236
        """
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   237
        slave_infos = self.Controler.GetSlaveInfos()
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   238
        sync_manager_section = ["vendor", "product_code", "revision_number", "physics"]
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   239
        if slave_infos is not None:
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   240
            # this method is same as "TextCtrl.SetValue" 
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   241
            for textctrl_name in sync_manager_section:
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   242
                self.TextCtrlDic[textctrl_name].SetValue(slave_infos[textctrl_name])
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   243
            self.SyncManagersTable.SetData(slave_infos["sync_managers"])
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   244
            self.SyncManagersTable.ResetView(self.SyncManagersGrid)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   245
        else:
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   246
            for textctrl_name in sync_manager_section:
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   247
                self.TextCtrlDic[textctrl_name].SetValue("")
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   248
            self.SyncManagersTable.SetData([])
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   249
            self.SyncManagersTable.ResetView(self.SyncManagersGrid)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   250
        
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   251
    def OnButtonClick(self, event):
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   252
        """
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   253
        Event handler for slave state transition button click (Init, PreOP, SafeOP, OP button)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   254
        @param event : wx.EVT_BUTTON object
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   255
        """
2641
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   256
        # Check whether beremiz connected or not.
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   257
        # If this method is called cyclically, set the cyclic flag true
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   258
        check_connect_flag = self.Controler.CommonMethod.CheckConnect(cyclic_flag = False)
2152
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   259
        if check_connect_flag :
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   260
            state_dic = ["INIT", "PREOP", "SAFEOP", "OP"]
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   261
              
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   262
            # If target state is one of {INIT, PREOP, SAFEOP}, request slave state transition immediately.
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   263
            if event.GetId() < 3 :
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   264
                self.Controler.CommonMethod.RequestSlaveState(state_dic[event.GetId()])
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   265
                self.TextCtrlDic["TargetState"].SetValue(state_dic[event.GetId()])
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   266
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   267
            # If target state is OP, first check "PLC status".
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   268
            #  (1) If current PLC status is "Started", then request slave state transition
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   269
            #  (2) Otherwise, show error message and return
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   270
            else :
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   271
                status, count = self.Controler.GetCTRoot()._connector.GetPLCstatus()
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   272
                if status == "Started" :
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   273
                    self.Controler.CommonMethod.RequestSlaveState("OP")
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   274
                    self.TextCtrlDic["TargetState"].SetValue("OP")
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   275
                else :
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   276
                    self.Controler.CommonMethod.CreateErrorDialog("PLC is Not Started")  
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   277
     
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   278
    def GetCurrentState(self, event):
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   279
        """
2641
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   280
        Timer event handler for periodic slave state monitoring (Default period: 1 sec = 2000 msec).
2152
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   281
        @param event : wx.TIMER object
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   282
        """
2641
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   283
        if self.IsShownOnScreen() is False:
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   284
            return
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   285
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   286
        # Check whether beremiz connected or not.
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   287
        # If this method is called cyclically, set the cyclic flag true
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   288
        check_connect_flag = self.Controler.CommonMethod.CheckConnect(cyclic_flag = True)
2152
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   289
        if check_connect_flag:
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   290
            returnVal = self.Controler.CommonMethod.GetSlaveStateFromSlave()
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   291
            line = returnVal.split("\n")
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   292
            try :
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   293
                self.SetCurrentState(line[self.Controler.GetSlavePos()])
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   294
            except :
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   295
                pass  
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   296
            
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   297
    def SetCurrentState(self, line):
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   298
        """
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   299
        Show current slave state using the executiob result of "ethercat slaves" command.
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   300
        @param line : result of "ethercat slaves" command
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   301
        """
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   302
        state_array = ["INIT", "PREOP", "SAFEOP", "OP"]
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   303
        try :
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   304
            # parse the execution result of  "ethercat slaves" command
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   305
            # Result example : 0  0:0  PREOP  +  EL9800 (V4.30) (PIC24, SPI, ET1100)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   306
            token = line.split("  ")
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   307
            if token[2] in state_array:
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   308
                self.TextCtrlDic["CurrentState"].SetValue(token[2])           
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   309
        except :
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   310
            pass     
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   311
        
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   312
    def StartTimer(self, event):
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   313
        """
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   314
        Event handler for "Start State Monitoring" button.
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   315
          - start slave state monitoring thread
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   316
        @param event : wx.EVT_BUTTON object
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   317
        """
2641
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   318
        # Check whether beremiz connected or not.
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   319
        # If this method is called cyclically, set the cyclic flag true
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   320
        check_connect_flag = self.Controler.CommonMethod.CheckConnect(cyclic_flag = False)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   321
        if check_connect_flag:
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   322
            self.SlaveStateThread = wx.Timer(self)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   323
            # set timer period (2000 ms)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   324
            self.SlaveStateThread.Start(2000)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   325
        else:
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   326
            pass
2152
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   327
        
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   328
    def CurrentStateThreadStop(self, event):
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   329
        """
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   330
        Event handler for "Stop State Monitoring" button.
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   331
          - stop slave state monitoring thread
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   332
        @param event : wx.EVT_BUTTON object
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   333
        """
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   334
        try:
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   335
            self.SlaveStateThread.Stop()
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   336
        except:
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   337
            pass
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   338
        
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   339
#-------------------------------------------------------------------------------
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   340
#                    For SDO Management Panel
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   341
#-------------------------------------------------------------------------------  
2641
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   342
class SDOPanelClass(wx.ScrolledWindow):
2152
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   343
    def __init__(self, parent, controler):
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   344
        """
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   345
        Constructor
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   346
        @param parent: Reference to the parent EtherCATManagementTreebook class
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   347
        @param controler: _EthercatSlaveCTN class in EthercatSlave.py
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   348
        """
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   349
        wx.Panel.__init__(self, parent, -1)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   350
        
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   351
        self.DatatypeDescription, self.CommunicationObject, self.ManufacturerSpecific, \
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   352
        self.ProfileSpecific, self.Reserved, self.AllSDOData = range(6)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   353
        
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   354
        self.Controler = controler
2641
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   355
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   356
        self.SDOMonitorEntries = {}
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   357
        #----------------------------- SDO Monitor -------------------------------#
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   358
        self.RBList = ["ON","OFF"]
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   359
        
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   360
        self.SDOMonitorRB = wx.RadioBox(self, label=_("monitoring"),
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   361
                                        choices=self.RBList, majorDimension=2)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   362
        
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   363
        self.SDOMonitorRB.SetSelection(1)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   364
        self.Bind(wx.EVT_RADIOBOX, self.OnRadioBox, self.SDOMonitorRB)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   365
       
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   366
        self.SDOMonitorGrid = wx.grid.Grid(self,size=wx.Size(850,150),style=wx.EXPAND
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   367
                                                        |wx.ALIGN_CENTER_HORIZONTAL
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   368
                                                        |wx.ALIGN_CENTER_VERTICAL) 
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   369
        self.SDOMonitorGrid.Bind(gridlib.EVT_GRID_CELL_LEFT_DCLICK, 
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   370
                                                    self.onMonitorGridDoubleClick)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   371
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   372
        #----------------------------- SDO Entries ----------------------------#
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   373
        self.SDOUpdateBtn = wx.Button(self, label=_("update"))         
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   374
        self.SDOUpdateBtn.Bind(wx.EVT_BUTTON, self.OnSDOUpdate)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   375
        
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   376
        self.SDOTraceThread = None
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   377
        self.SDOMonitoringFlag = False
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   378
        self.SDOValuesList = []
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   379
        # Default SDO Page Number
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   380
        self.SDOPageNum = 2
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   381
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   382
        #----------------------------- Sizer --------------------------------------#
2152
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   383
        self.SDOManagementMainSizer = wx.BoxSizer(wx.VERTICAL)
2641
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   384
        self.SDOInfoBox = wx.StaticBox(self, label=_("SDO Entries"))
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   385
        self.SDOMonitorBox = wx.StaticBox(self, label=_("SDO Monitor"))
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   386
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   387
        self.SDONoteBook = SDONoteBook(self, controler=self.Controler)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   388
        self.SDOInfoBoxSizer = wx.StaticBoxSizer(self.SDOInfoBox, orient=wx.VERTICAL)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   389
        self.SDOMonitorBoxSizer = wx.StaticBoxSizer(self.SDOMonitorBox, 
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   390
                                                                    orient=wx.VERTICAL)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   391
        self.SDOInfoBoxSizer.Add(self.SDOUpdateBtn)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   392
        
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   393
        self.SDOInfoBoxSizer.Add(self.SDONoteBook, wx.ALL|wx.EXPAND)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   394
        self.SDOMonitorBoxSizer.Add(self.SDOMonitorRB)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   395
        self.SDOMonitorBoxSizer.Add(self.SDOMonitorGrid)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   396
        self.SDOManagementMainSizer.AddMany([self.SDOInfoBoxSizer, 
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   397
                                             self.SDOMonitorBoxSizer])
2152
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   398
        self.SetSizer(self.SDOManagementMainSizer)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   399
        
2641
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   400
        #----------------------------- fill the contents --------------------------# 
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   401
        #self.entries = self.Controler.CTNParent.CTNParent.GetEntriesList()
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   402
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   403
        slave = self.Controler.CTNParent.GetSlave(self.Controler.GetSlavePos())
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   404
        type_infos = slave.getType()
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   405
        device, alignment = self.Controler.CTNParent.GetModuleInfos(type_infos)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   406
        self.entries = device.GetEntriesList()
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   407
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   408
        self.Controler.CommonMethod.SDOVariables = []
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   409
        self.Controler.CommonMethod.SDOSubEntryData = []
2152
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   410
        self.Controler.CommonMethod.ClearSDODataSet()
2641
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   411
        self.SDOParserXML(self.entries)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   412
        self.SDONoteBook.CreateNoteBook()      
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   413
        self.CreateSDOMonitorGrid()
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   414
        self.Refresh()
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   415
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   416
    def OnSDOUpdate(self, event):
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   417
        SlavePos = self.Controler.GetSlavePos()
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   418
        num = self.SDOPageNum - 1
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   419
        if num < 0:
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   420
            for i in range(len(self.Controler.CommonMethod.SDOVariables)):
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   421
                data = self.Controler.GetCTRoot()._connector.GetSDOEntriesData(
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   422
                           self.Controler.CommonMethod.SDOVariables[i], SlavePos)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   423
                self.Controler.CommonMethod.SDOVariables[i] = data
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   424
        else :
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   425
            SDOUploadEntries = self.Controler.CommonMethod.SDOVariables[num]        
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   426
            data = self.Controler.GetCTRoot()._connector.GetSDOEntriesData(SDOUploadEntries, SlavePos)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   427
            self.Controler.CommonMethod.SDOVariables[num] = data
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   428
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   429
        self.SDONoteBook.CreateNoteBook()      
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   430
        self.Refresh()
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   431
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   432
    def OnRadioBox(self, event):
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   433
        """
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   434
        There are two selections that are on and off.
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   435
        If the on is selected, the monitor thread begins to run.
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   436
        If the off is selected, the monitor thread gets off.
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   437
        @param event: wx.EVT_RADIOBOX object 
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   438
        """
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   439
        on, off = range(2)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   440
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   441
        if event.GetInt() == on:
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   442
            CheckThreadFlag = self.SDOMonitoringThreadOn()
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   443
            if not CheckThreadFlag:
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   444
                self.SDOMonitorRB.SetSelection(off)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   445
        elif event.GetInt() == off:
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   446
            self.SDOMonitoringThreadOff()
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   447
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   448
    def SDOMonitoringThreadOn(self):
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   449
        check_connect_flag = self.Controler.CommonMethod.CheckConnect(cyclic_flag = False)
2152
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   450
        if check_connect_flag:
2641
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   451
            self.SetSDOTraceValues(self.SDOMonitorEntries)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   452
            self.Controler.GetCTRoot()._connector.GetSDOData()
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   453
            self.SDOTraceThread = Thread(target=self.SDOMonitorThreadProc)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   454
            self.SDOMonitoringFlag = True
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   455
            self.SDOTraceThread.start()
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   456
        return check_connect_flag
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   457
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   458
    def SDOMonitoringThreadOff(self):
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   459
        check_connect_flag = self.Controler.CommonMethod.CheckConnect(cyclic_flag = False)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   460
        if check_connect_flag:
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   461
            self.SDOMonitoringFlag = False
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   462
            if self.SDOTraceThread is not None:
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   463
                self.SDOTraceThread.join()
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   464
            self.SDOTraceThread = None
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   465
            self.Controler.GetCTRoot()._connector.StopSDOThread()
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   466
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   467
    def SetSDOTraceValues(self, SDOMonitorEntries):
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   468
        SlavePos = self.Controler.GetSlavePos()
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   469
        check_connect_flag = self.Controler.CommonMethod.CheckConnect(cyclic_flag = True)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   470
        if check_connect_flag:
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   471
            self.Controler.GetCTRoot()._connector.SetSDOTraceValues(SDOMonitorEntries, SlavePos)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   472
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   473
    def SDOMonitorThreadProc(self):
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   474
        while self.SDOMonitoringFlag and self.Controler.GetCTRoot()._connector.PLCStatus != "Started":
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   475
            self.SDOValuesList = self.Controler.GetCTRoot()._connector.GetSDOData()
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   476
            LocalData = self.SDOValuesList[0].items()
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   477
            LocalData.sort()
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   478
            if self.SDOValuesList[1] != self.Controler.GetSlavePos():
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   479
                continue
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   480
            row = 0
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   481
            for (idx, subidx), data in LocalData:
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   482
                self.SDOMonitorGrid.SetCellValue(row, 6, str(data["value"]))
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   483
                row += 1
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   484
            time.sleep(0.5)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   485
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   486
    def CreateSDOMonitorGrid(self):
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   487
        """
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   488
        It creates SDO Monitor table and specifies cell size and labels.
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   489
        """
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   490
        self.SDOMonitorGrid.CreateGrid(0,7) 
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   491
        SDOCellSize = [(0, 65), (1, 65), (2, 50), (3, 70), 
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   492
                         (4, 40), (5, 450), (6, 85)]
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   493
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   494
        for (index, size) in SDOCellSize:
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   495
            self.SDOMonitorGrid.SetColSize(index, size)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   496
        
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   497
        self.SDOMonitorGrid.SetRowLabelSize(0)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   498
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   499
        SDOTableLabel = [(0, "Index"), (1, "Subindex"), (2, "Access"),
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   500
                         (3, "Type"), (4, "Size"), (5, "Name"), (6, "Value")]
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   501
        
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   502
        for (index, label) in SDOTableLabel:
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   503
            self.SDOMonitorGrid.SetColLabelValue(index, label)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   504
            self.SDOMonitorGrid.SetColLabelAlignment(index, wx.ALIGN_CENTER)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   505
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   506
    def onMonitorGridDoubleClick(self, event):
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   507
        """
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   508
        Event Handler for double click on the SDO entries table.
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   509
        It adds the entry into the SDO monitor table.
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   510
        If the entry is already in the SDO monitor table, 
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   511
        then it's removed from the SDO monitor table.
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   512
        @pram event: gridlib.EVT_GRID_CELL_LEFT_DCLICK object
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   513
        """
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   514
        row = event.GetRow()
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   515
        idx = self.SDOMonitorGrid.GetCellValue(row, 0)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   516
        subIdx = self.SDOMonitorGrid.GetCellValue(row, 1)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   517
        
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   518
        del self.SDOMonitorEntries[(idx, subIdx)]
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   519
        self.SDOMonitorGrid.DeleteRows(row, 1)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   520
        # add jblee
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   521
        self.SetSDOTraceValues(self.SDOMonitorEntries)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   522
        self.SDOMonitorGrid.Refresh()
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   523
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   524
    def SDOParserXML(self, entries):
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   525
        """
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   526
        Parse SDO data set that obtain "ESI file"
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   527
        @param entries: SDO entry list 
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   528
        """  
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   529
        entries_list = entries.items()
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   530
        entries_list.sort()
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   531
        self.ForDefaultValueFlag = False
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   532
        self.CompareValue = ""
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   533
        self.sub_entry_value_list = []
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   534
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   535
        for (index, subidx), entry in entries_list:
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   536
            # exclude entry that isn't in the objects
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   537
            check_mapping = entry["PDOMapping"]
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   538
            if check_mapping is "T" or check_mapping is "R":
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   539
                if "PDO index" not in entry.keys():
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   540
                    continue
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   541
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   542
            idx = "0" + entry["Index"].strip("#")
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   543
            #subidx = hex(int(entry["SubIndex"], 0))
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   544
            try :        
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   545
                subidx = "0x" + entry["SubIndex"]
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   546
            except :
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   547
                subidx = "0x0"
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   548
            datatype = entry["Type"]
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   549
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   550
            try :
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   551
                default_value = entry["DefaultData"]
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   552
            except :
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   553
                default_value = " --- "
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   554
            # Result of SlaveSDO data parsing. (data type : dictionary)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   555
            self.Data = {'idx':idx, 'subIdx':subidx, 'access':entry["Access"], 
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   556
                         'type':datatype, 'size': str(entry["BitSize"]), 
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   557
                         'name':entry["Name"], 'value':default_value}
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   558
            category_divide_value = [0x1000, 0x2000, 0x6000, 0xa000, 0xffff]
2152
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   559
                
2641
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   560
            for count in range(len(category_divide_value)) :
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   561
                if int(idx, 0) < category_divide_value[count]:
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   562
                    self.Controler.CommonMethod.SDOVariables[count].append(self.Data)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   563
                    break
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   564
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   565
        self.Controler.CommonMethod.SDOSubEntryData = self.sub_entry_value_list
2152
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   566
    
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   567
#-------------------------------------------------------------------------------
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   568
#                    For SDO Notebook (divide category)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   569
#-------------------------------------------------------------------------------  
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   570
class SDONoteBook(wx.Notebook):
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   571
    def __init__(self, parent, controler):
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   572
        """
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   573
        Constructor
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   574
        @param parent: Reference to the parent SDOPanelClass class
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   575
        @param controler: _EthercatSlaveCTN class in EthercatSlave.py
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   576
        """
2641
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   577
        wx.Notebook.__init__(self, parent, id = -1, size=(850, 350))
2152
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   578
        self.Controler = controler
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   579
        self.parent = parent
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   580
        
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   581
        self.CreateNoteBook()
2641
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   582
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   583
        self.Bind(wx.EVT_NOTEBOOK_PAGE_CHANGED, self.OnPageChanged)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   584
        self.Bind(wx.EVT_NOTEBOOK_PAGE_CHANGING, self.OnPageChanging)
2152
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   585
        
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   586
    def CreateNoteBook(self): 
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   587
        """
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   588
        Create each NoteBook page, divided SDO index
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   589
        According to EtherCAT Communication(03/2011), 158p
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   590
        """   
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   591
        self.Data = []
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   592
        count = 1
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   593
        
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   594
        page_texts = [("all", self.parent.AllSDOData),
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   595
                     ("0x0000 - 0x0ff", self.parent.DatatypeDescription),
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   596
                     ("0x1000 - 0x1fff", self.parent.CommunicationObject),
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   597
                     ("0x2000 - 0x5fff", self.parent.ManufacturerSpecific),
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   598
                     ("0x6000 - 0x9fff", self.parent.ProfileSpecific),
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   599
                     ("0xa000 - 0xffff", self.parent.Reserved)]
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   600
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   601
        page_tooltip_string = ["SDO Index 0x0000 - 0x0fff : Data Type Description",
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   602
                               "SDO Index 0x1000 - 0x1fff : Communication object",
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   603
                               "SDO Index 0x2000 - 0x5fff : Manufacturer specific",
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   604
                               "SDO Index 0x6000 - 0x9fff : Profile specific",
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   605
                               "SDO Index 0xa000 - 0xffff : Reserved",
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   606
                               "All SDO Object"]
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   607
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   608
        self.DeleteAllPages()
2641
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   609
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   610
        self.Controler.CommonMethod.SDOVariables[5] = []
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   611
        for i in range(4):
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   612
            self.Controler.CommonMethod.SDOVariables[5] += self.Controler.CommonMethod.SDOVariables[i]
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   613
            
2152
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   614
        for txt, count in page_texts:
2641
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   615
            self.Data = self.Controler.CommonMethod.SDOVariables[count]
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   616
            self.SubEntryData = self.Controler.CommonMethod.SDOSubEntryData
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   617
            self.Win = SlaveSDOTable(self, self.Data, self.SubEntryData)
2152
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   618
            self.AddPage(self.Win, txt)
2641
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   619
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   620
    # add jblee
2152
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   621
    def OnPageChanged(self, event):
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   622
        old = event.GetOldSelection()
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   623
        new = event.GetSelection()
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   624
        sel = self.GetSelection()
2641
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   625
        self.parent.SDOPageNum = new
2152
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   626
        event.Skip()
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   627
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   628
    def OnPageChanging(self, event):
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   629
        old = event.GetOldSelection()
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   630
        new = event.GetSelection()
2641
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   631
        sel = self.GetSelection()        
2152
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   632
        event.Skip()
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   633
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   634
#-------------------------------------------------------------------------------
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   635
#                    For SDO Grid (fill index, subindex, etc...)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   636
#-------------------------------------------------------------------------------  
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   637
class SlaveSDOTable(wx.grid.Grid):  
2641
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   638
    def __init__(self, parent, data, fixed_value):
2152
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   639
        """
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   640
        Constructor
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   641
        @param parent: Reference to the parent SDOPanelClass class
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   642
        @param data: SDO data after parsing "SDOParser" method
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   643
        """
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   644
        wx.grid.Grid.__init__(self, parent, -1, size=(830,490), 
2641
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   645
                              style=wx.EXPAND|wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL)
2152
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   646
        
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   647
        self.Controler = parent.Controler
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   648
        self.parent = parent
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   649
        self.SDOFlag = True
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   650
        if data is None :
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   651
            self.SDOs = []
2641
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   652
            self.sub_entry_value = []
2152
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   653
        else :
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   654
            self.SDOs = data
2641
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   655
            self.sub_entry_value = fixed_value
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   656
        
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   657
        self.CreateGrid(len(self.SDOs), 7)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   658
        SDOCellSize = [(0, 65), (1, 65), (2, 50), (3, 70), 
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   659
                         (4, 40), (5, 400), (6, 135)]
2152
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   660
        
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   661
        for (index, size) in SDOCellSize:
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   662
            self.SetColSize(index, size)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   663
        
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   664
        self.SetRowLabelSize(0)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   665
        
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   666
        SDOTableLabel = [(0, "Index"), (1, "Subindex"), (2, "Access"),
2641
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   667
                         (3, "Type"), (4, "Size"), (5, "Name"), (6, "Value")]
2152
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   668
        
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   669
        for (index, label) in SDOTableLabel:
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   670
            self.SetColLabelValue(index, label)
2641
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   671
            self.SetColLabelAlignment(index, wx.ALIGN_CENTER)
2152
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   672
            
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   673
        attr = wx.grid.GridCellAttr()
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   674
2641
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   675
        # for SDO download and monitoring 
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   676
        self.Bind(gridlib.EVT_GRID_CELL_LEFT_DCLICK, self.onGridDoubleClick)
2152
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   677
        
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   678
        for i in range(7): 
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   679
            self.SetColAttr(i,attr)                   
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   680
        
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   681
        self.SetColLabelAlignment(wx.ALIGN_CENTER, wx.ALIGN_CENTER)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   682
            
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   683
        self.SetTableValue()  
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   684
             
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   685
    def SetTableValue(self):
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   686
        """
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   687
        Cell is filled by new parsing data
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   688
        """
2641
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   689
        sdo_list = ['idx', 'subIdx', 'access', 'type', 'size', 'name', 'value']
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   690
        count = 0
2152
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   691
        for row_idx in range(len(self.SDOs)):
2641
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   692
            for col_idx in range(len(self.SDOs[row_idx])):
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   693
                
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   694
                # the top entries that have sub index is shaded.
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   695
                if int(self.SDOs[row_idx]['subIdx'], 16) == 0x00:
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   696
                    try:
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   697
                        if int(self.SDOs[row_idx + 1]['subIdx'], 16) is not 0x00:
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   698
                            self.SetCellBackgroundColour(row_idx, col_idx, \
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   699
                                                                wx.LIGHT_GREY)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   700
                    except:
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   701
                        pass
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   702
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   703
                if self.SDOs[row_idx][sdo_list[col_idx]] == "modifying":
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   704
                    if len(self.sub_entry_value) == count:
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   705
                        continue
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   706
                    self.SetCellValue(row_idx, col_idx, self.sub_entry_value[count])
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   707
                    count += 1
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   708
                else :
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   709
                    self.SetCellValue(row_idx, col_idx, \
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   710
                                  self.SDOs[row_idx][sdo_list[col_idx]])
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   711
2152
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   712
                self.SetReadOnly(row_idx, col_idx, True)
2641
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   713
2152
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   714
                if col_idx < 5 :
2641
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   715
                    self.SetCellAlignment(row_idx, col_idx, wx.ALIGN_CENTER, wx.ALIGN_CENTER)
2152
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   716
        
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   717
    def CheckSDODataAccess(self, row):
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   718
        """
2641
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   719
        check that access field has "rw"
2152
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   720
        @param row : Selected cell by user
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   721
        @return Write_flag : If data has "w", flag is true
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   722
        """
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   723
        check = self.SDOs[row]['access']
2641
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   724
        if check == "rw":
2152
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   725
            return True
2641
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   726
        else:
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   727
            return False
2152
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   728
    
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   729
    def ClearStateFlag(self):
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   730
        """
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   731
        Initialize StateFlag
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   732
        StateFlag is notice SDOData access each slave state
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   733
        """
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   734
        self.Controler.CommonMethod.Check_PREOP = False
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   735
        self.Controler.CommonMethod.Check_SAFEOP = False
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   736
        self.Controler.CommonMethod.Check_OP = False
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   737
    
2641
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   738
    def onGridDoubleClick (self, event):
2152
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   739
        """
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   740
        Create dialog for SDO value modify
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   741
        if user enter data, perform command "ethercat download"  
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   742
        @param event : gridlib.EVT_GRID_CELL_LEFT_DCLICK object
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   743
        """
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   744
        self.ClearStateFlag()
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   745
        
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   746
        # CheckSDODataAccess is checking that OD(Object Dictionary) has "w" 
2641
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   747
        if event.GetCol() == 6 and self.CheckSDODataAccess(event.GetRow()) :    
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   748
            dlg = wx.TextEntryDialog (self, 
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   749
                    "Enter hex or dec value (if enter dec value, " \
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   750
                  + "it automatically conversed hex value)",
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   751
                    "SDOModifyDialog", style = wx.OK | wx.CANCEL)
2152
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   752
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   753
            start_value = self.GetCellValue(event.GetRow(), event.GetCol()) 
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   754
            dlg.SetValue(start_value)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   755
            
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   756
            if dlg.ShowModal() == wx.ID_OK:
2641
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   757
                # Check whether beremiz connected or not.
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   758
                # If this method is called cyclically, set the cyclic flag true
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   759
                check_connect_flag = self.Controler.CommonMethod.CheckConnect(cyclic_flag = False)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   760
                if check_connect_flag:
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   761
                    try :
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   762
                        input_val = hex(int(dlg.GetValue(), 0))
2152
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   763
                        # Request "SDODownload"
2641
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   764
                        return_val = self.Controler.CommonMethod.SDODownload(
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   765
                                                self.SDOs[event.GetRow()]["type"], 
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   766
                                                self.SDOs[event.GetRow()]["idx"], 
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   767
                                                self.SDOs[event.GetRow()]["subIdx"], 
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   768
                                                dlg.GetValue())
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   769
                        if return_val is "":
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   770
                            SDOUploadEntry = {"idx" : self.SDOs[event.GetRow()]["idx"],
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   771
                                              "subIdx" : self.SDOs[event.GetRow()]["subIdx"],
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   772
                                              "size" : self.SDOs[event.GetRow()]["size"]
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   773
                                             }
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   774
                            data = self.Controler.GetCTRoot()._connector.GetSDOEntryData(
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   775
                                SDOUploadEntry, self.Controler.GetSlavePos())
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   776
                            hex_val = hex(data)[:-1]                           
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   777
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   778
                            # download data check
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   779
                            if input_val == hex_val:
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   780
                                display_val = "%s(%d)" % (hex_val, data) 
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   781
                                self.SetCellValue(event.GetRow(), event.GetCol(), 
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   782
                                                  display_val)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   783
                            else :
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   784
                                self.Controler.CommonMethod.CreateErrorDialog(\
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   785
                                            'SDO Value not completely download, please try again')    
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   786
                        else:
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   787
                            self.Controler.GetCTRoot().logger.write_error(return_val)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   788
                            
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   789
                    # Error occured process of "int(variable)"
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   790
                    # User input is not hex, dec value
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   791
                    except ValueError:
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   792
                        self.Controler.CommonMethod.CreateErrorDialog(\
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   793
                                            'You can input only hex, dec value')    
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   794
        else:
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   795
            SDOPanel = self.parent.parent
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   796
            row = event.GetRow() 
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   797
            
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   798
            idx = self.SDOs[row]["idx"]
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   799
            subIdx = self.SDOs[row]["subIdx"]
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   800
            SDOPanel.SDOMonitorEntries[(idx, subIdx)] = {
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   801
                                                "access": self.SDOs[row]["access"],
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   802
                                                "type": self.SDOs[row]["type"],
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   803
                                                "size": self.SDOs[row]["size"],
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   804
                                                "name": self.SDOs[row]["name"],
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   805
                                                # add jblee
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   806
                                                "value": ""}
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   807
            
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   808
            del_rows = SDOPanel.SDOMonitorGrid.GetNumberRows()
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   809
            
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   810
            try: 
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   811
                SDOPanel.SDOMonitorGrid.DeleteRows(0, del_rows)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   812
            except:
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   813
                pass
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   814
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   815
            SDOPanel.SDOMonitorGrid.AppendRows(len(SDOPanel.SDOMonitorEntries))
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   816
            SDOPanel.SetSDOTraceValues(SDOPanel.SDOMonitorEntries)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   817
            
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   818
            SME_list = SDOPanel.SDOMonitorEntries.items()
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   819
            SME_list.sort()
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   820
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   821
            gridRow = 0
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   822
            for (idx, subIdx), entry in SME_list:
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   823
                SDOPanel.SDOMonitorGrid.SetCellValue(gridRow, 0, str(idx))
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   824
                SDOPanel.SDOMonitorGrid.SetCellValue(gridRow, 1, str(subIdx))
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   825
                for col, key in [(2, "access"),
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   826
                                 (3, "type"),
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   827
                                 (4, "size"),
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   828
                                 (5, "name")]:
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   829
                    SDOPanel.SDOMonitorGrid.SetCellValue(gridRow, col, entry[key])
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   830
                for col in range(7):
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   831
                    SDOPanel.SDOMonitorGrid.SetReadOnly(gridRow, col, True)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   832
                    if col < 5 :
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   833
                        SDOPanel.SDOMonitorGrid.SetCellAlignment(\
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   834
                                        gridRow, col, wx.ALIGN_CENTER, wx.ALIGN_CENTER)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   835
                gridRow += 1
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   836
            
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   837
            SDOPanel.SDOMonitorGrid.Refresh()
2152
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   838
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   839
#-------------------------------------------------------------------------------
2641
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   840
#                 For PDO Mapping Panel
2152
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   841
# PDO Class UI  : Panel -> Choicebook (RxPDO, TxPDO) -> 
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   842
#                 Notebook (PDO Index) -> Grid (PDO entry)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   843
#-------------------------------------------------------------------------------  
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   844
class PDOPanelClass(wx.Panel):
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   845
    def __init__(self, parent, controler):
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   846
        """
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   847
        Constructor
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   848
        @param parent: Reference to the parent EtherCATManagementTreebook class
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   849
        @param controler: _EthercatSlaveCTN class in EthercatSlave.py
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   850
        """
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   851
        wx.Panel.__init__(self, parent, -1)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   852
        self.Controler = controler
2641
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   853
        sizer = wx.FlexGridSizer(cols=1, hgap=20,rows=3, vgap=20)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   854
        line = wx.StaticText(self, -1, "\n In order to control Ethercat device, user must select proper PDO set.\
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   855
                                        \n Each PDO sets describe operation modes (CSP, CSV, CST) supported by Ethercat devices.\
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   856
                                      \n\n PDOs have two types, RxPDO and TxPDO.\
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   857
                                        \n  - RxPDO refers to the Receive Process Data Object. It means the control parameters which sent from controller to the EtherCAT Slave device.\
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   858
                                        \n    In general, ControlWord (0x6040), Modes of Operations (0x6060), and TargetPosition (0x607A) are regarded as RxPDO.\
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   859
                                        \n  - TxPDO refers to the Transmit Process Data Object. It used to report status of EtherCAT Slave device to the controller in order to calibrate their next actuation.\
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   860
                                        \n    StatusWord (0x6041), Modes of Operation Display (0x6061), and ActualPosition (0x607A) include in TxPDO.\
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   861
                                      \n\n PDO Mapping feature provides available RxPDO and TxPDO sets which defined in Ethercat slave description XML.\
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   862
                                        \n If there is no selection of PDO set, first set (0x1600, 0x1A00) will be chosen as default configuration.")
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   863
        
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   864
        sizer.Add(line)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   865
        self.SetSizer(sizer)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   866
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   867
class RxPDOPanelClass(wx.Panel):
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   868
    def __init__(self, parent, controler):
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   869
        """
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   870
        Constructor
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   871
        @param parent: Reference to the parent EtherCATManagementTreebook class
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   872
        @param controler: _EthercatSlaveCTN class in EthercatSlave.py
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   873
        """
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   874
        wx.Panel.__init__(self, parent, -1)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   875
        self.Controler = controler
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   876
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   877
        # add jblee
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   878
        #self.PDOIndexList = ["RxPDO"]
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   879
        self.PDOIndexList = []
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   880
        self.LoadPDOSelectData()
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   881
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   882
        #HSAHN ADD. 2015.7.26 PDO Select Function ADD
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   883
        self.Controler.CommonMethod.RequestPDOInfo()
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   884
        self.PDOcheckBox = []
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   885
        self.rx_pdo_entries = self.Controler.CommonMethod.GetRxPDOCategory()
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   886
        if len(self.rx_pdo_entries):
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   887
            for i in range(len(self.rx_pdo_entries)):
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   888
                self.PDOcheckBox.append(wx.CheckBox(self, label=str(hex(self.rx_pdo_entries[i]['pdo_index'])), size=(120,15)))
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   889
                if not self.Controler.SelectedRxPDOIndex and self.rx_pdo_entries[i]['sm'] is not None:
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   890
                    self.PDOcheckBox[-1].SetValue(True)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   891
                    self.Controler.SelectedRxPDOIndex.append(int(self.PDOcheckBox[-1].GetLabel(), 0))
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   892
                    self.InitSavePDO()
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   893
                elif self.rx_pdo_entries[i]['pdo_index'] in self.Controler.SelectedRxPDOIndex:
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   894
                    self.PDOIndexList.append(str(hex(self.rx_pdo_entries[i]['pdo_index'])))
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   895
                    self.PDOcheckBox[-1].SetValue(True)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   896
                    
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   897
            for cb in self.PDOcheckBox:
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   898
                self.Bind(wx.EVT_CHECKBOX, self.PDOSelectCheck, cb)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   899
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   900
            self.PDOListBox = wx.StaticBox(self, label=_("PDO Mapping Select"))
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   901
            self.PDOListBoxSizer = wx.StaticBoxSizer(self.PDOListBox, orient=wx.HORIZONTAL)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   902
            self.RxPDOListBox = wx.StaticBox(self, label=_("RxPDO"))
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   903
            self.RxPDOListBoxSizer = wx.StaticBoxSizer(self.RxPDOListBox, orient=wx.VERTICAL)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   904
            self.RxPDOListBoxInnerSizer = wx.FlexGridSizer(cols=3, hgap=5, rows=10, vgap=5)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   905
            self.RxPDOListBoxInnerSizer.AddMany(self.PDOcheckBox[0:len(self.rx_pdo_entries)])
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   906
            self.RxPDOListBoxSizer.Add(self.RxPDOListBoxInnerSizer)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   907
            self.PDOListBoxSizer.Add(self.RxPDOListBoxSizer)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   908
            self.PDOWarningText = wx.StaticText(self, -1,
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   909
                       "  *Warning*\n\n By default configuration, \n\n first mapping set is selected. \n\n Choose the PDO mapping!",
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   910
                       size=(220, -1))
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   911
            self.PDOListBoxSizer.Add(self.PDOWarningText)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   912
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   913
            self.PDOMonitoringEditorMainSizer = wx.BoxSizer(wx.VERTICAL)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   914
            self.PDOMonitoringEditorInnerMainSizer = wx.FlexGridSizer(cols=1, hgap=10, rows=2, vgap=10)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   915
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   916
        
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   917
            self.CallPDOChoicebook = PDONoteBook(self, controler=self.Controler, name="Rx")
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   918
            self.PDOMonitoringEditorInnerMainSizer.Add(self.CallPDOChoicebook, wx.ALL)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   919
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   920
            self.PDOInformationBox = wx.StaticBox(self, label=_("RxPDO Mapping List"))
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   921
            self.PDOInformationBoxSizer = wx.StaticBoxSizer(self.PDOInformationBox, orient=wx.VERTICAL)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   922
            self.PDOInformationBoxSizer.Add(self.PDOMonitoringEditorInnerMainSizer)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   923
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   924
            self.PDOMonitoringEditorMainSizer.Add(self.PDOListBoxSizer)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   925
            self.PDOMonitoringEditorMainSizer.Add(self.PDOInformationBoxSizer)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   926
            self.SetSizer(self.PDOMonitoringEditorMainSizer)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   927
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   928
            # add jblee
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   929
            self.PDOExcludeCheck()
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   930
        else:
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   931
            sizer = wx.FlexGridSizer(cols=1, hgap=20,rows=3, vgap=20)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   932
            line = wx.StaticText(self, -1, "\n  This device does not support RxPDO.")
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   933
        
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   934
            sizer.Add(line)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   935
            self.SetSizer(sizer)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   936
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   937
    def LoadPDOSelectData(self):
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   938
        RxPDOData = self.Controler.BaseParams.getRxPDO()
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   939
        RxPDOs = []
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   940
        if RxPDOData != "None":
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   941
            RxPDOs = RxPDOData.split()
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   942
        if RxPDOs :
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   943
            for RxPDO in RxPDOs :
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   944
                self.Controler.SelectedRxPDOIndex.append(int(RxPDO, 0))
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   945
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   946
    def PDOSelectCheck(self, event):
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   947
        # add jblee for Save User Select
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   948
        cb = event.GetEventObject()
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   949
                         # prevent duplicated check
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   950
        if cb.GetValue() and int(cb.GetLabel(), 0) not in self.Controler.SelectedRxPDOIndex:
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   951
            self.Controler.SelectedRxPDOIndex.append(int(cb.GetLabel(), 0))
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   952
            self.PDOIndexList.append(cb.GetLabel())
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   953
        else:
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   954
            self.Controler.SelectedRxPDOIndex.remove(int(cb.GetLabel(), 0))
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   955
            self.PDOIndexList.remove(cb.GetLabel())
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   956
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   957
        data = ""
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   958
        for PDOIndex in self.PDOIndexList:            
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   959
            data = data + " " + PDOIndex
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   960
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   961
        self.Controler.BaseParams.setRxPDO(data)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   962
        self.Controler.GetCTRoot().CTNRequestSave()
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   963
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   964
        self.PDOExcludeCheck()
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   965
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   966
    def InitSavePDO(self):
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   967
        for PDOIndex in self.Controler.SelectedRxPDOIndex:
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   968
            self.PDOIndexList.append(str(hex(PDOIndex)))
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   969
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   970
        data = ""
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   971
        for PDOIndex in self.PDOIndexList:            
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   972
            data = data + " " + PDOIndex
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   973
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   974
        self.Controler.BaseParams.setRxPDO(data)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   975
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   976
    # 2016.06.21
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   977
    # add jblee for check exclude pdo list
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   978
    def PDOExcludeCheck(self):
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   979
        #files = os.listdir(self.Controler.CTNPath())
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   980
        #filepath = os.path.join(self.Controler.CTNPath(), "DataForPDO.txt")
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   981
        CurIndexs = self.Controler.SelectedRxPDOIndex
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   982
        for CB in self.PDOcheckBox:
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   983
            if len(CB.GetLabel().split()) > 1:
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   984
                CB.Enable()
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   985
                CB.SetLabel(CB.GetLabel().split()[0])
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   986
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   987
        for pdo in self.rx_pdo_entries:
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   988
            for CurIndex in CurIndexs:
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   989
                if pdo["pdo_index"] == CurIndex:
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   990
                    ex_list = pdo["exclude_list"]
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   991
                    for ex_item in ex_list:
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   992
                        for CB in self.PDOcheckBox:
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   993
                            if CB.GetLabel() == hex(ex_item):
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   994
                                CB.SetLabel(CB.GetLabel() + " (Excluded)")
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   995
                                CB.Disable()
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   996
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   997
    def RefreshPDOInfo(self):
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
   998
        pass
2152
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
   999
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1000
    def PDOInfoUpdate(self):
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1001
        """
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1002
        Call RequestPDOInfo method and create Choicebook
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1003
        """
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1004
        self.Controler.CommonMethod.RequestPDOInfo()
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1005
        self.CallPDOChoicebook.Destroy()
2641
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1006
        self.CallPDOChoicebook = PDOChoicebook(self, controler=self.Controler, name="Rx")
2152
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1007
        self.Refresh()
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1008
2641
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1009
class TxPDOPanelClass(wx.Panel):
2152
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1010
    def __init__(self, parent, controler):
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1011
        """
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1012
        Constructor
2641
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1013
        @param parent: Reference to the parent EtherCATManagementTreebook class
2152
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1014
        @param controler: _EthercatSlaveCTN class in EthercatSlave.py
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1015
        """
2641
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1016
        wx.Panel.__init__(self, parent, -1)
2152
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1017
        self.Controler = controler
2641
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1018
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1019
        # add jblee
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1020
        self.PDOIndexList = []
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1021
        self.LoadPDOSelectData()
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1022
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1023
        #HSAHN ADD. 2015.7.26 PDO Select Function ADD
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1024
        self.Controler.CommonMethod.RequestPDOInfo()
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1025
        self.PDOcheckBox = []
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1026
        self.tx_pdo_entries = self.Controler.CommonMethod.GetTxPDOCategory()
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1027
        if len(self.tx_pdo_entries):
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1028
            for i in range(len(self.tx_pdo_entries)):
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1029
                self.PDOcheckBox.append(wx.CheckBox(self, label=str(hex(self.tx_pdo_entries[i]['pdo_index'])), size=(120,15)))
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1030
                if not self.Controler.SelectedTxPDOIndex and self.tx_pdo_entries[i]['sm'] is not None:
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1031
                    self.PDOcheckBox[-1].SetValue(True)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1032
                    self.Controler.SelectedTxPDOIndex.append(int(self.PDOcheckBox[-1].GetLabel(), 0))
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1033
                    self.InitSavePDO()
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1034
                elif self.tx_pdo_entries[i]['pdo_index'] in self.Controler.SelectedTxPDOIndex:
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1035
                    self.PDOIndexList.append(str(hex(self.tx_pdo_entries[i]['pdo_index'])))
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1036
                    self.PDOcheckBox[-1].SetValue(True)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1037
            for cb in self.PDOcheckBox:
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1038
                self.Bind(wx.EVT_CHECKBOX, self.PDOSelectCheck, cb)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1039
        
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1040
            self.PDOListBox = wx.StaticBox(self, label=_("PDO Mapping Select"))
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1041
            self.PDOListBoxSizer = wx.StaticBoxSizer(self.PDOListBox, orient=wx.HORIZONTAL)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1042
            self.TxPDOListBox = wx.StaticBox(self, label=_("TxPDO"))
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1043
            self.TxPDOListBoxSizer = wx.StaticBoxSizer(self.TxPDOListBox, orient=wx.VERTICAL)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1044
            self.TxPDOListBoxInnerSizer = wx.FlexGridSizer(cols=3, hgap=5, rows=10, vgap=5)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1045
            self.TxPDOListBoxInnerSizer.AddMany(self.PDOcheckBox[0:len(self.tx_pdo_entries)])
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1046
            self.TxPDOListBoxSizer.Add(self.TxPDOListBoxInnerSizer)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1047
            self.PDOListBoxSizer.Add(self.TxPDOListBoxSizer)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1048
            self.PDOWarningText = wx.StaticText(self, -1,
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1049
                       "  *Warning*\n\n By default configuration, \n\n first mapping set is selected. \n\n Choose the PDO mapping!",
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1050
                       size=(220, -1))
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1051
            self.PDOListBoxSizer.Add(self.PDOWarningText)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1052
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1053
            self.PDOMonitoringEditorMainSizer = wx.BoxSizer(wx.VERTICAL)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1054
            self.PDOMonitoringEditorInnerMainSizer = wx.FlexGridSizer(cols=1, hgap=10, rows=2, vgap=10)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1055
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1056
            self.CallPDOChoicebook = PDONoteBook(self, controler=self.Controler, name="Tx")
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1057
            self.PDOMonitoringEditorInnerMainSizer.Add(self.CallPDOChoicebook, wx.ALL)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1058
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1059
            self.PDOInformationBox = wx.StaticBox(self, label=_("TxPDO Mapping List"))
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1060
            self.PDOInformationBoxSizer = wx.StaticBoxSizer(self.PDOInformationBox, orient=wx.VERTICAL)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1061
            self.PDOInformationBoxSizer.Add(self.PDOMonitoringEditorInnerMainSizer)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1062
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1063
            self.PDOMonitoringEditorMainSizer.Add(self.PDOListBoxSizer)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1064
            self.PDOMonitoringEditorMainSizer.Add(self.PDOInformationBoxSizer)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1065
            self.SetSizer(self.PDOMonitoringEditorMainSizer)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1066
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1067
            # add jblee
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1068
            self.PDOExcludeCheck()
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1069
        else:
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1070
            sizer = wx.FlexGridSizer(cols=1, hgap=20,rows=3, vgap=20)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1071
            line = wx.StaticText(self, -1, "\n  This device does not support TxPDO.")
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1072
        
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1073
            sizer.Add(line)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1074
            self.SetSizer(sizer)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1075
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1076
    def LoadPDOSelectData(self):
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1077
        TxPDOData = self.Controler.BaseParams.getTxPDO()
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1078
        TxPDOs = []
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1079
        if TxPDOData != "None":
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1080
            TxPDOs = TxPDOData.split()
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1081
        if TxPDOs :
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1082
            for TxPDO in TxPDOs :
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1083
                self.Controler.SelectedTxPDOIndex.append(int(TxPDO, 0))
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1084
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1085
    def PDOSelectCheck(self, event):
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1086
        # add jblee for Save User Select
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1087
        cb = event.GetEventObject()
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1088
                         # prevent duplicated check
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1089
        if cb.GetValue() and int(cb.GetLabel(), 0) not in self.Controler.SelectedTxPDOIndex:
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1090
            self.Controler.SelectedTxPDOIndex.append(int(cb.GetLabel(), 0))
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1091
            self.PDOIndexList.append(cb.GetLabel())
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1092
        else:
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1093
            self.Controler.SelectedTxPDOIndex.remove(int(cb.GetLabel(), 0))
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1094
            self.PDOIndexList.remove(cb.GetLabel())
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1095
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1096
        data = ""
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1097
        for PDOIndex in self.PDOIndexList:            
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1098
            data = data + " " + PDOIndex
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1099
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1100
        self.Controler.BaseParams.setTxPDO(data)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1101
        self.Controler.GetCTRoot().CTNRequestSave()
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1102
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1103
        self.PDOExcludeCheck()
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1104
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1105
    def InitSavePDO(self):
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1106
        for PDOIndex in self.Controler.SelectedTxPDOIndex:
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1107
            self.PDOIndexList.append(str(hex(PDOIndex)))
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1108
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1109
        data = ""
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1110
        for PDOIndex in self.PDOIndexList:            
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1111
            data = data + " " + PDOIndex
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1112
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1113
        self.Controler.BaseParams.setTxPDO(data)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1114
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1115
    # 2016.06.21
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1116
    # add jblee for check exclude pdo list
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1117
    def PDOExcludeCheck(self):
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1118
        CurIndexs = self.Controler.SelectedTxPDOIndex
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1119
        for CB in self.PDOcheckBox:
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1120
            if len(CB.GetLabel().split()) > 1:
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1121
                CB.Enable()
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1122
                CB.SetLabel(CB.GetLabel().split()[0])
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1123
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1124
        for pdo in self.tx_pdo_entries:
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1125
            for CurIndex in CurIndexs:
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1126
                if pdo["pdo_index"] == CurIndex:
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1127
                    ex_list = pdo["exclude_list"]
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1128
                    for ex_item in ex_list:
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1129
                        for CB in self.PDOcheckBox:
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1130
                            if CB.GetLabel() == hex(ex_item):
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1131
                                CB.SetLabel(CB.GetLabel() + " (Excluded)")
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1132
                                CB.Disable()
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1133
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1134
    def PDOInfoUpdate(self):
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1135
        """
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1136
        Call RequestPDOInfo method and create Choicebook
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1137
        """
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1138
        self.Controler.CommonMethod.RequestPDOInfo()
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1139
        self.CallPDOChoicebook.Destroy()
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1140
        self.CallPDOChoicebook = PDOChoicebook(self, controler=self.Controler, name="Tx")
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1141
        self.Refresh()
2152
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1142
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1143
#-------------------------------------------------------------------------------
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1144
#                    For PDO Notebook (divide PDO index)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1145
#-------------------------------------------------------------------------------  
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1146
class PDONoteBook(wx.Notebook):
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1147
    def __init__(self, parent, name, controler):
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1148
        """
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1149
        Constructor
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1150
        @param parent: Reference to the parent PDOChoicebook class
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1151
        @param name: identifier whether RxPDO or TxPDO
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1152
        @param controler: _EthercatSlaveCTN class in EthercatSlave.py
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1153
        """
2641
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1154
        wx.Notebook.__init__(self, parent, id=-1, size=(600, 400))
2152
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1155
        self.Controler = controler
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1156
        
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1157
        count = 0
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1158
        page_texts = []
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1159
        
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1160
        if name == "Tx" :
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1161
            # obtain pdo_info and pdo_entry
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1162
            # pdo_info include (PDO index, name, number of entry)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1163
            pdo_info =  self.Controler.CommonMethod.GetTxPDOCategory()
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1164
            pdo_entry = self.Controler.CommonMethod.GetTxPDOInfo()
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1165
            for tmp in pdo_info :
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1166
                title = str(hex(tmp['pdo_index']))
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1167
                page_texts.append(title)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1168
        # RX PDO case
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1169
        else :  
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1170
            pdo_info = self.Controler.CommonMethod.GetRxPDOCategory()
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1171
            pdo_entry = self.Controler.CommonMethod.GetRxPDOInfo()
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1172
            for tmp in pdo_info :
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1173
                title = str(hex(tmp['pdo_index']))
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1174
                page_texts.append(title)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1175
               
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1176
        # Add page depending on the number of pdo_info
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1177
        for txt in page_texts:
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1178
            win = PDOEntryTable(self, pdo_info, pdo_entry, count)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1179
            self.AddPage(win, txt)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1180
            count += 1  
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1181
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1182
#-------------------------------------------------------------------------------
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1183
#                    For PDO Grid (fill entry index, subindex etc...)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1184
#-------------------------------------------------------------------------------  
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1185
class PDOEntryTable(wx.grid.Grid):
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1186
    def __init__(self, parent, info, entry, count):
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1187
        """
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1188
        Constructor
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1189
        @param parent: Reference to the parent PDONoteBook class
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1190
        @param info : data structure including entry index, sub index, name, length, type
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1191
        @param entry : data structure including index, name, entry number
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1192
        @param count : page number
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1193
        """
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1194
        wx.grid.Grid.__init__(self, parent, -1, size=(500, 400), pos=wx.Point(0,0), 
2641
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1195
                              style=wx.EXPAND|wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL)
2152
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1196
        
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1197
        self.Controler = parent.Controler
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1198
        
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1199
        self.PDOInfo = info
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1200
        self.PDOEntry = entry
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1201
        self.Count = count
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1202
        
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1203
        self.CreateGrid(self.PDOInfo[self.Count]['number_of_entry'], 5)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1204
        self.SetColLabelSize(25)   
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1205
        self.SetRowLabelSize(0)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1206
        
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1207
        PDOTableLabel = [(0, "Index"), (1, "Subindex"), (2, "Length"),
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1208
                         (3, "Type"), (4, "Name")]
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1209
        
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1210
        for (index, label) in PDOTableLabel:
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1211
            self.SetColLabelValue(index, label)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1212
        
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1213
        PDOCellSize = [(0, 45), (1, 65), (2, 55), (3, 40), (4, 300)]
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1214
        
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1215
        for (index, size) in PDOCellSize:
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1216
            self.SetColSize(index, size)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1217
            self.SetColLabelAlignment(index, wx.ALIGN_LEFT)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1218
        
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1219
        attr = wx.grid.GridCellAttr()
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1220
        
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1221
        for i in range(5):
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1222
            self.SetColAttr(i, attr)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1223
         
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1224
        self.SetTableValue()
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1225
            
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1226
    def SetTableValue(self):
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1227
        """
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1228
        Cell is filled by new parsing data in XML
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1229
        """
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1230
        list_index = 0
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1231
        # number of entry
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1232
        for i in range(self.Count + 1) :
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1233
            list_index += self.PDOInfo[i]['number_of_entry']
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1234
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1235
        start_value = list_index - self.PDOInfo[self.Count]['number_of_entry']
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1236
        
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1237
        pdo_list = ['entry_index', 'subindex', 'bitlen', 'type', 'name']
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1238
        for row_idx in range(self.PDOInfo[self.Count]['number_of_entry']):
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1239
            for col_idx in range(len(self.PDOEntry[row_idx])):
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1240
                # entry index is converted hex value.
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1241
                if col_idx == 0 :
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1242
                    self.SetCellValue(row_idx, col_idx, hex(self.PDOEntry[start_value][pdo_list[col_idx]]))
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1243
                else :
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1244
                    self.SetCellValue(row_idx, col_idx, str(self.PDOEntry[start_value][pdo_list[col_idx]]))
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1245
                if col_idx != 4 :
2641
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1246
                    self.SetCellAlignment(row_idx, col_idx, wx.ALIGN_CENTER, wx.ALIGN_CENTER)
2152
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1247
                else :
2641
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1248
                    self.SetCellAlignment(row_idx, col_idx, wx.ALIGN_LEFT, wx.ALIGN_CENTER)
2152
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1249
                self.SetReadOnly(row_idx, col_idx, True)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1250
                self.SetRowSize(row_idx, 25)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1251
            start_value += 1
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1252
2641
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1253
#-------------------------------------------------------------------------------
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1254
#                    For MDP Main Panel         
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1255
#-------------------------------------------------------------------------------  
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1256
class MDPPanel(wx.Panel):
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1257
    def __init__(self, parent, controler):
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1258
        """
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1259
        Constructor
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1260
        @param parent: Reference to the parent EtherCATManagementTreebook class
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1261
        @param controler: _EthercatSlaveCTN class in EthercatSlave.py
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1262
        """
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1263
        wx.Panel.__init__(self, parent, -1)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1264
        self.parent = parent
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1265
        self.Controler = controler
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1266
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1267
        sizer = wx.FlexGridSizer(cols=3, hgap=20, rows=1, vgap=20)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1268
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1269
        # Include Module ListBox
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1270
        leftInnerSizer = wx.FlexGridSizer(cols=1, hgap=10,rows=2, vgap=10)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1271
        # Include Add, Delete Button
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1272
        middleInnerSizer = wx.FlexGridSizer(cols=1, hgap=10,rows=2, vgap=10)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1273
        # Include Slot ListBox
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1274
        rightInnerSizer = wx.FlexGridSizer(cols=1, hgap=10,rows=2, vgap=10)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1275
        
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1276
        # Get Module Name as Array
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1277
        # MDPArray = {SlaveName, [data0, data1, ...], SlotIndexIncrement, SlotPdoIncrement}
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1278
        # data = [ModuleName, ModuleInfo, [PDOInfo1, PDOInfo2, ...]]
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1279
        # PDOInfo = {Index, Name, BitSize, Access, PDOMapping, SubIndex, Type}
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1280
        slave = self.Controler.CTNParent.GetSlave(self.Controler.GetSlavePos())
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1281
        type_infos = slave.getType()
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1282
        MDPArray = self.Controler.CTNParent.CTNParent.GetMDPInfos(type_infos)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1283
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1284
        NameSet = []
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1285
        if MDPArray:
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1286
            for info in MDPArray[0][1]:
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1287
                NameSet.append(info[0])
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1288
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1289
        # Module ListBox
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1290
        self.ModuleLabel = wx.StaticText(self, -1, "Module")
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1291
        self.ModuleListBox = wx.ListBox(self, size = (150, 200), choices = NameSet)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1292
        #self.ModuleListBox = wx.ListBox(self, size = (150, 200), choices = [])
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1293
        self.Bind(wx.EVT_LISTBOX_DCLICK, self.OnModuleListBoxDCClick, self.ModuleListBox)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1294
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1295
        # Button
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1296
        self.AddButton = wx.Button(self, label=_(" Add Module  "))
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1297
        self.DeleteButton = wx.Button(self, label=_("Delete Module"))
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1298
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1299
        # Button Event Mapping
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1300
        self.AddButton.Bind(wx.EVT_BUTTON, self.OnAddButton)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1301
        self.DeleteButton.Bind(wx.EVT_BUTTON, self.OnDeleteButton)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1302
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1303
        # Slot ListBox
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1304
        self.SlotLabel = wx.StaticText(self, -1, "Slot")
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1305
        self.SlotListBox = wx.ListBox(self, size = (150, 200))
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1306
        self.Bind(wx.EVT_LISTBOX_DCLICK, self.OnSlotListBoxDCClick, self.SlotListBox)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1307
        self.SelectModule = []
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1308
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1309
        # Add Object Each Sizer
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1310
        leftInnerSizer.AddMany([self.ModuleLabel, self.ModuleListBox])
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1311
        middleInnerSizer.Add(self.AddButton, 0, wx.TOP, 100)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1312
        middleInnerSizer.Add(self.DeleteButton, 0, wx.BOTTOM, 120)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1313
        rightInnerSizer.AddMany([self.SlotLabel, self.SlotListBox])
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1314
        
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1315
        sizer.AddMany([leftInnerSizer, middleInnerSizer, rightInnerSizer])
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1316
        
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1317
        self.SetSizer(sizer)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1318
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1319
        self.InitMDPSet()
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1320
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1321
    def InitMDPSet(self):
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1322
        files = os.listdir(self.Controler.CTNPath())
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1323
        filepath = os.path.join(self.Controler.CTNPath(), "DataForMDP.txt")
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1324
        try:
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1325
            moduleDataFile = open(filepath, 'r')
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1326
            lines = moduleDataFile.readlines()
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1327
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1328
            for line in lines:
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1329
                if line == "\n":
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1330
                    continue
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1331
                module_pos = line.split()[-1]
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1332
                name_len_limit = len(line) - len(module_pos) - 2
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1333
                module_name = line[0:name_len_limit]
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1334
                
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1335
                self.SelectModule.append((module_name, int(module_pos)))
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1336
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1337
            localModuleInfo = []        
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1338
            count = 1
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1339
            for (item, pos) in self.SelectModule:
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1340
                slotString = "Slot %d %s : " % (count, item.split()[1]) + item.split()[0]
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1341
                localModuleInfo.append(slotString)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1342
                count += 1
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1343
            self.SlotListBox.SetItems(localModuleInfo)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1344
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1345
        except:
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1346
            moduleDataFile = open(filepath, 'w')
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1347
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1348
        moduleDataFile.close()
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1349
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1350
    def OnAddButton(self, event):
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1351
        files = os.listdir(self.Controler.CTNPath())
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1352
        filepath = os.path.join(self.Controler.CTNPath(), "DataForMDP.txt")
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1353
        moduleDataFile = open(filepath, 'w')
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1354
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1355
        selectNum = self.ModuleListBox.GetSelection()
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1356
        if selectNum >= 0:
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1357
            selectStr = self.ModuleListBox.GetString(selectNum)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1358
            self.SelectModule.append((selectStr, selectNum))
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1359
            localModuleInfo = []
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1360
            count = 1
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1361
            for (item, pos) in self.SelectModule:
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1362
                slotString = "Slot %d %s : " % (count, item.split()[1]) + item.split()[0]
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1363
                localModuleInfo.append(slotString)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1364
                count += 1
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1365
            self.SlotListBox.SetItems(localModuleInfo)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1366
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1367
        moduleDataFile.close()
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1368
        
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1369
    def OnDeleteButton(self, event):
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1370
        files = os.listdir(self.Controler.CTNPath())
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1371
        filepath = os.path.join(self.Controler.CTNPath(), "DataForMDP.txt")
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1372
        moduleDataFile = open(filepath, 'w')
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1373
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1374
        selectNum = self.SlotListBox.GetSelection()
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1375
        if selectNum >= 0:
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1376
            selectStr = self.SlotListBox.GetString(selectNum)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1377
            self.SelectModule.pop(selectNum)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1378
            localModuleInfo = []
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1379
            count = 1
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1380
            for (item, pos) in self.SelectModule:
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1381
                moduleDataFile.write(item + " " + str(pos) + "\n")
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1382
                slotString = "Slot %d %s : " % (count, item.split()[1]) + item.split()[0]
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1383
                localModuleInfo.append(slotString)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1384
                count += 1
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1385
            self.SlotListBox.SetItems(localModuleInfo)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1386
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1387
        moduleDataFile.close()
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1388
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1389
    def OnModuleListBoxDCClick(self, event):
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1390
        files = os.listdir(self.Controler.CTNPath())
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1391
        filepath = os.path.join(self.Controler.CTNPath(), "DataForMDP.txt")
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1392
        moduleDataFile = open(filepath, 'w')
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1393
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1394
        selectNum = self.ModuleListBox.GetSelection()
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1395
        if selectNum >= 0:
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1396
            selectStr = self.ModuleListBox.GetString(selectNum)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1397
            self.SelectModule.append((selectStr, selectNum))
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1398
            localModuleInfo = []
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1399
            count = 1
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1400
            for (item, pos) in self.SelectModule:
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1401
                moduleDataFile.write(item + " " + str(pos) + "\n")
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1402
                slotString = "Slot %d %s : " % (count, item.split()[1]) + item.split()[0]
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1403
                localModuleInfo.append(slotString)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1404
                module = self.Controler.CTNParent.CTNParent.GetSelectModule(pos)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1405
                self.Controler.CommonMethod.SavePDOData(module)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1406
                count += 1
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1407
            self.SlotListBox.SetItems(localModuleInfo)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1408
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1409
        moduleDataFile.close()
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1410
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1411
    def OnSlotListBoxDCClick(self, event):
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1412
        files = os.listdir(self.Controler.CTNPath())
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1413
        filepath = os.path.join(self.Controler.CTNPath(), "DataForMDP.txt")
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1414
        moduleDataFile = open(filepath, 'w')
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1415
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1416
        selectNum = self.SlotListBox.GetSelection()
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1417
        if selectNum >= 0:
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1418
            selectStr = self.SlotListBox.GetString(selectNum)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1419
            self.SelectModule.pop(selectNum)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1420
            localModuleInfo = []
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1421
            count = 1
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1422
            for (item, pos) in self.SelectModule:
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1423
                moduleDataFile.write(item + " " + str(pos) + "\n")
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1424
                slotString = "Slot %d %s : " % (count, item.split()[1]) + item.split()[0]
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1425
                localModuleInfo.append(slotString)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1426
                count += 1
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1427
            self.SlotListBox.SetItems(localModuleInfo)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1428
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1429
        moduleDataFile.close()
2152
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1430
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1431
#-------------------------------------------------------------------------------
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1432
#                    For EEPROM Access Main Panel 
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1433
#                 (This class explain EEPROM Access)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1434
#-------------------------------------------------------------------------------  
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1435
class EEPROMAccessPanel(wx.Panel):
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1436
    def __init__(self, parent, controler):
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1437
        """
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1438
        Constructor
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1439
        @param parent: Reference to the parent EtherCATManagementTreebook class
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1440
        @param controler: _EthercatSlaveCTN class in EthercatSlave.py
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1441
        """
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1442
        wx.Panel.__init__(self, parent, -1)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1443
        sizer = wx.FlexGridSizer(cols=1, hgap=20,rows=3, vgap=20)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1444
        
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1445
        line = wx.StaticText(self, -1, "\n  EEPROM Access is composed to SmartView and HexView. \
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1446
                                              \n\n   - SmartView shows Config Data, Device Identity, Mailbox settings, etc. \
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1447
                                              \n\n   - HexView shows EEPROM's contents.")
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1448
        
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1449
        sizer.Add(line)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1450
        
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1451
        self.SetSizer(sizer)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1452
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1453
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1454
#-------------------------------------------------------------------------------
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1455
#                    For Smart View Panel 
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1456
#-------------------------------------------------------------------------------  
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1457
class SlaveSiiSmartView(wx.Panel):
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1458
    def __init__(self, parent, controler):
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1459
        """
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1460
        Constructor
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1461
        @param parent: Reference to the parent EtherCATManagementTreebook class
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1462
        @param controler: _EthercatSlaveCTN class in EthercatSlave.py
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1463
        """
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1464
        wx.Panel.__init__(self, parent, -1)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1465
        self.parent = parent
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1466
        self.Controler = controler
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1467
        
2641
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1468
        # PDI Type 1, 13 unknown Type, Fix Future
2152
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1469
        self.PDIType = {0  :['none', '00000000'], 
2641
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1470
                        1  :['unknown', '00000000'],
2152
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1471
                        4  :['Digital I/O', '00000100'],
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1472
                        5  :['SPI Slave', '00000101'],
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1473
                        7  :['EtherCAT Bridge (port3)', '00000111'],
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1474
                        8  :['uC async. 16bit', '00001000'],
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1475
                        9  :['uC async. 8bit', '00001001'],
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1476
                        10 :['uC sync. 16bit', '00001010'],
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1477
                        11 :['uC sync. 8bit', '00001011'],
2641
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1478
                        13 :['unknown', '00000000'],
2152
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1479
                        16 :['32 Digtal Input and 0 Digital Output', '00010000'],
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1480
                        17 :['24 Digtal Input and 8 Digital Output', '00010001'],
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1481
                        18 :['16 Digtal Input and 16 Digital Output','00010010'],
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1482
                        19 :['8 Digtal Input and 24 Digital Output', '00010011'],
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1483
                        20 :['0 Digtal Input and 32 Digital Output', '00010100'],
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1484
                        128:['On-chip bus', '11111111']
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1485
                        }
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1486
        
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1487
        sizer = wx.FlexGridSizer(cols=1, hgap=5, rows=2, vgap=5)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1488
        button_sizer = wx.FlexGridSizer(cols=2, hgap=5, rows=1, vgap=5)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1489
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1490
        for button, mapping_method in [("Write EEPROM", self.WriteToEEPROM),
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1491
                                       ("Read EEPROM", self.ReadFromEEPROM)]:
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1492
            btn = wx.Button(self, -1, button, size=(150, 40))
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1493
            button_sizer.Add(btn, border=10, flag=wx.ALL)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1494
            btn.Bind(wx.EVT_BUTTON, mapping_method)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1495
        
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1496
        self.TreeListCtrl = SmartViewTreeListCtrl(self, self.Controler)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1497
        
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1498
        sizer.Add(button_sizer, border=10, flag=wx.ALL)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1499
        sizer.Add(self.TreeListCtrl, border=10, flag=wx.ALL)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1500
        self.SetSizer(sizer)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1501
        
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1502
        self.Create_SmartView()
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1503
        
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1504
    def Create_SmartView(self):
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1505
        """
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1506
        SmartView shows information based on XML as initial value.
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1507
        """  
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1508
        self.Controler.CommonMethod.SmartViewInfosFromXML = self.Controler.CommonMethod.GetSmartViewInfos()
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1509
        self.SetXMLData()
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1510
                
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1511
    def WriteToEEPROM(self, event):
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1512
        """
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1513
        Open binary file (user select) and write the selected binary data to EEPROM
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1514
        @param event : wx.EVT_BUTTON object
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1515
        """  
2641
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1516
        # Check whether beremiz connected or not. 
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1517
        # If this method is called cyclically, set the cyclic flag true
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1518
        check_connect_flag = self.Controler.CommonMethod.CheckConnect(cyclic_flag = False)
2152
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1519
        if check_connect_flag:
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1520
            status, count = self.Controler.GetCTRoot()._connector.GetPLCstatus()
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1521
            if status is not "Started":
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1522
                dialog = wx.FileDialog(self, _("Choose a binary file"), os.getcwd(), "",  _("bin files (*.bin)|*.bin"), wx.OPEN)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1523
                
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1524
                if dialog.ShowModal() == wx.ID_OK:
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1525
                    filepath = dialog.GetPath()
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1526
                    try:
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1527
                        binfile = open(filepath,"rb")
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1528
                        self.SiiBinary = binfile.read()
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1529
                        dialog.Destroy()
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1530
                        
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1531
                        self.Controler.CommonMethod.SiiWrite(self.SiiBinary)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1532
                        # refresh data structure kept by master
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1533
                        self.Controler.CommonMethod.Rescan()
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1534
                        # save binary data as inner global data of beremiz 
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1535
                        # for fast loading when slave plugin node is reopened.
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1536
                        self.Controler.CommonMethod.SiiData = self.SiiBinary
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1537
                        self.SetEEPROMData()
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1538
                    except:
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1539
                        self.Controler.CommonMethod.CreateErrorDialog('The file does not exist!')
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1540
                        dialog.Destroy()
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1541
    
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1542
    def ReadFromEEPROM(self, event):
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1543
        """
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1544
        Refresh displayed data based on slave EEPROM and save binary file through dialog
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1545
        @param event : wx.EVT_BUTTON object
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1546
        """  
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1547
        # Check whether beremiz connected or not.
2641
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1548
        # If this method is called cyclically, set the cyclic flag true
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1549
        check_connect_flag = self.Controler.CommonMethod.CheckConnect(cyclic_flag = False)
2152
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1550
        if check_connect_flag:
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1551
            self.SiiBinary = self.Controler.CommonMethod.LoadData()
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1552
            self.SetEEPROMData()
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1553
            dialog = wx.FileDialog(self, _("Save as..."), os.getcwd(), 
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1554
                                   "slave0.bin",  _("bin files (*.bin)|*.bin|All files|*.*"), 
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1555
                                   wx.SAVE|wx.OVERWRITE_PROMPT)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1556
        
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1557
            if dialog.ShowModal() == wx.ID_OK:
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1558
                filepath = dialog.GetPath()
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1559
                binfile = open(filepath,"wb")
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1560
                binfile.write(self.SiiBinary)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1561
                binfile.close()
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1562
    
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1563
            dialog.Destroy()
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1564
    
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1565
    def SetXMLData(self):
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1566
        """
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1567
        Set data based on XML initially
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1568
        """  
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1569
        # Config Data: EEPROM Size, PDI Type, Device Emulation
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1570
        # Find PDI Type in pdiType dictionary
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1571
        cnt_pdi_type = self.Controler.CommonMethod.SmartViewInfosFromXML["pdi_type"]
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1572
        for i in self.PDIType.keys():
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1573
            if cnt_pdi_type == i:
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1574
                cnt_pdi_type = self.PDIType[i][0]
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1575
                break
2641
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1576
        # Set Config Data
2152
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1577
        for treelist, data in [("EEPROM Size (Bytes)", 
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1578
                                str(self.Controler.CommonMethod.SmartViewInfosFromXML["eeprom_size"])),
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1579
                               ("PDI Type", 
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1580
                                cnt_pdi_type),
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1581
                               ("Device Emulation", 
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1582
                                self.Controler.CommonMethod.SmartViewInfosFromXML["device_emulation"])]:
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1583
            self.TreeListCtrl.Tree.SetItemText(self.TreeListCtrl.ConfigData[treelist], data, 1)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1584
        
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1585
        # Device Identity: Vendor ID, Product Code, Revision No., Serial No.
2641
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1586
        # Set Device Identity
2152
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1587
        for treelist, data in [("Vendor ID", self.Controler.CommonMethod.SmartViewInfosFromXML["vendor_id"]),
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1588
                               ("Product Code", self.Controler.CommonMethod.SmartViewInfosFromXML["product_code"]),
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1589
                               ("Revision No.", self.Controler.CommonMethod.SmartViewInfosFromXML["revision_no"]),
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1590
                               ("Serial No.", self.Controler.CommonMethod.SmartViewInfosFromXML["serial_no"])]:
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1591
            self.TreeListCtrl.Tree.SetItemText(self.TreeListCtrl.DeviceIdentity[treelist], data, 1)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1592
             
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1593
        # Mailbox: Supported Mailbox, Bootstrap Configuration, Standard Configuration
2641
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1594
        # Set Mailbox
2152
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1595
        for treelist, data in [("Supported Mailbox", self.Controler.CommonMethod.SmartViewInfosFromXML["supported_mailbox"]),
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1596
                               ("Bootstrap Configuration", ""),
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1597
                               ("Standard Configuration", "")]:
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1598
            self.TreeListCtrl.Tree.SetItemText(self.TreeListCtrl.Mailbox[treelist], data, 1)       
2641
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1599
        # Set Bootstrap Configuration: Receive Offset, Receive Size, Send Offset, Send Size
2152
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1600
        for treelist, data in [("Receive Offset", self.Controler.CommonMethod.SmartViewInfosFromXML["mailbox_bootstrapconf_outstart"]),
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1601
                               ("Receive Size", self.Controler.CommonMethod.SmartViewInfosFromXML["mailbox_bootstrapconf_outlength"]),
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1602
                               ("Send Offset", self.Controler.CommonMethod.SmartViewInfosFromXML["mailbox_bootstrapconf_instart"]),
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1603
                               ("Send Size", self.Controler.CommonMethod.SmartViewInfosFromXML["mailbox_bootstrapconf_inlength"])]:
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1604
            self.TreeListCtrl.Tree.SetItemText(self.TreeListCtrl.BootstrapConfig[treelist], data, 1)      
2641
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1605
        # Set Standard Configuration: Receive Offset, Receive Size, Send Offset, Send Size
2152
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1606
        for treelist, data in [("Receive Offset", self.Controler.CommonMethod.SmartViewInfosFromXML["mailbox_standardconf_outstart"]),
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1607
                               ("Receive Size", self.Controler.CommonMethod.SmartViewInfosFromXML["mailbox_standardconf_outlength"]),
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1608
                               ("Send Offset", self.Controler.CommonMethod.SmartViewInfosFromXML["mailbox_standardconf_instart"]),
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1609
                               ("Send Size", self.Controler.CommonMethod.SmartViewInfosFromXML["mailbox_standardconf_inlength"])]:
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1610
            self.TreeListCtrl.Tree.SetItemText(self.TreeListCtrl.StandardConfig[treelist], data, 1)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1611
        
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1612
    def SetEEPROMData(self):
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1613
        """
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1614
        Set data based on slave EEPROM.
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1615
        """  
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1616
        sii_dict= { 'PDIControl' :                          ( '0', 1),
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1617
                    'PDIConfiguration' :                    ( '1', 1),
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1618
                    'PulseLengthOfSYNCSignals' :            ( '2', 1),
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1619
                    'ExtendedPDIConfiguration' :            ( '3', 1),
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1620
                    'ConfiguredStationAlias' :              ( '4', 1),
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1621
                    'Checksum' :                            ( '7', 1),
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1622
                    'VendorID' :                            ( '8', 2),
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1623
                    'ProductCode' :                         ( 'a', 2),
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1624
                    'RevisionNumber' :                      ( 'c', 2),
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1625
                    'SerialNumber' :                        ( 'e', 2),
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1626
                    'Execution Delay' :                     ('10', 1),
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1627
                    'Port0Delay' :                          ('11', 1),
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1628
                    'Port1Delay' :                          ('12', 1),
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1629
                    'BootstrapReceiveMailboxOffset' :       ('14', 1),
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1630
                    'BootstrapReceiveMailboxSize' :         ('15', 1),
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1631
                    'BootstrapSendMailboxOffset' :          ('16', 1),
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1632
                    'BootstrapSendMailboxSize' :            ('17', 1),
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1633
                    'StandardReceiveMailboxOffset' :        ('18', 1),
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1634
                    'StandardReceiveMailboxSize' :          ('19', 1),
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1635
                    'StandardSendMailboxOffset' :           ('1a', 1),
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1636
                    'StandardSendMailboxSize' :             ('1b', 1),
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1637
                    'MailboxProtocol' :                     ('1c', 1),
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1638
                    'Size' :                                ('3e', 1),
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1639
                    'Version' :                             ('3f', 1),
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1640
                    'First Category Type/Vendor Specific' : ('40', 1),
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1641
                    'Following Category Word Size' :        ('41', 1),
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1642
                    'Category Data' :                       ('42', 1),
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1643
                }
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1644
        
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1645
        # Config Data: EEPROM Size, PDI Type, Device Emulation
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1646
        # EEPROM's data in address '0x003f' is Size of EEPROM in KBit-1
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1647
        eeprom_size = str((int(self.GetWordAddressData( sii_dict.get('Size'),10 ))+1)/8*1024)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1648
        # Find PDI Type in pdiType dictionary
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1649
        cnt_pdi_type = int(self.GetWordAddressData( sii_dict.get('PDIControl'),16 ).split('x')[1][2:4], 16)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1650
        for i in self.PDIType.keys():
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1651
            if cnt_pdi_type == i:
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1652
                cnt_pdi_type = self.PDIType[i][0]
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1653
                break
2641
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1654
        # Get Device Emulation
2152
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1655
        device_emulation = str(bool(int("{:0>16b}".format(int(self.GetWordAddressData( sii_dict.get('PDIControl'),16 ), 16))[7])))    
2641
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1656
        # Set Config Data
2152
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1657
        for treelist, data in [("EEPROM Size (Bytes)", eeprom_size),
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1658
                               ("PDI Type", cnt_pdi_type),
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1659
                               ("Device Emulation", device_emulation)]:
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1660
            self.TreeListCtrl.Tree.SetItemText(self.TreeListCtrl.ConfigData[treelist], data, 1)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1661
        
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1662
        # Device Identity: Vendor ID, Product Code, Revision No., Serial No.
2641
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1663
        # Set Device Identity
2152
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1664
        for treelist, data in [("Vendor ID", self.GetWordAddressData( sii_dict.get('VendorID'),16 )),
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1665
                               ("Product Code", self.GetWordAddressData( sii_dict.get('ProductCode'),16 )),
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1666
                               ("Revision No.", self.GetWordAddressData( sii_dict.get('RevisionNumber'),16 )),
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1667
                               ("Serial No.", self.GetWordAddressData( sii_dict.get('SerialNumber'),16 ))]:
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1668
            self.TreeListCtrl.Tree.SetItemText(self.TreeListCtrl.DeviceIdentity[treelist], data, 1)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1669
      
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1670
        # Mailbox
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1671
        # EEORPOM's word address '1c' indicates supported mailbox protocol.
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1672
        # each value of mailbox protocol : 
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1673
        # VoE(0x0020), SoE(0x0010), FoE(0x0008), CoE(0x0004), EoE(0x0002), AoE(0x0001)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1674
        supported_mailbox = ""
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1675
        mailbox_protocol=["VoE,  ", "SoE,  ", "FoE,  ", "CoE,  ", "EoE,  ", "AoE,  "]
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1676
        mailbox_data = "{:0>8b}".format(int(self.GetWordAddressData( sii_dict.get('MailboxProtocol'),16 ), 16))
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1677
        for protocol in range(6):
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1678
            if mailbox_data[protocol+2] == '1':
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1679
                supported_mailbox += mailbox_protocol[protocol]
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1680
        supported_mailbox = supported_mailbox.strip(",  ")
2641
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1681
        # Set Mailbox
2152
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1682
        for treelist, data in [("Supported Mailbox", supported_mailbox),
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1683
                               ("Bootstrap Configuration", ""),
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1684
                               ("Standard Configuration", "")]:
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1685
            self.TreeListCtrl.Tree.SetItemText(self.TreeListCtrl.Mailbox[treelist], data, 1)       
2641
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1686
        # Set Bootstrap Configuration: Receive Offset, Receive Size, Send Offset, Send Size
2152
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1687
        for treelist, data in [("Receive Offset", self.GetWordAddressData( sii_dict.get('BootstrapReceiveMailboxOffset'),10 )),
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1688
                               ("Receive Size", self.GetWordAddressData( sii_dict.get('BootstrapReceiveMailboxSize'),10 )),
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1689
                               ("Send Offset", self.GetWordAddressData( sii_dict.get('BootstrapSendMailboxOffset'),10 )),
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1690
                               ("Send Size", self.GetWordAddressData( sii_dict.get('BootstrapSendMailboxSize'),10 ))]:
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1691
            self.TreeListCtrl.Tree.SetItemText(self.TreeListCtrl.BootstrapConfig[treelist], data, 1)      
2641
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1692
        # Set Standard Configuration: Receive Offset, Receive Size, Send Offset, Send Size
2152
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1693
        for treelist, data in [("Receive Offset", self.GetWordAddressData( sii_dict.get('StandardReceiveMailboxOffset'),10 )),
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1694
                               ("Receive Size", self.GetWordAddressData( sii_dict.get('StandardReceiveMailboxSize'),10 )),
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1695
                               ("Send Offset", self.GetWordAddressData( sii_dict.get('StandardSendMailboxOffset'),10 )),
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1696
                               ("Send Size", self.GetWordAddressData( sii_dict.get('StandardSendMailboxSize'),10 ))]:
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1697
            self.TreeListCtrl.Tree.SetItemText(self.TreeListCtrl.StandardConfig[treelist], data, 1)         
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1698
                
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1699
    def MakeStaticBoxSizer(self, boxlabel):
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1700
        """
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1701
        Make StaticBoxSizer
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1702
        @param boxlabel : label of box sizer
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1703
        @return sizer : the StaticBoxSizer labeled 'boxlabel'
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1704
        """
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1705
        box = wx.StaticBox(self, -1, boxlabel)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1706
        sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1707
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1708
        return sizer
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1709
        
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1710
    def GetWordAddressData(self, dict_tuple, format):
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1711
        """
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1712
        This method converts word address data from EEPROM binary.
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1713
        @param dict_tuple : element of 'sii_dict' dictionary in SetEEPROMData()
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1714
        @param format : format of data. It can be 16(hex), 10(decimal) and 2(binary).
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1715
        @return formatted value
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1716
        """  
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1717
        offset = int(str(dict_tuple[0]), 16) * 2
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1718
        length = int(str(dict_tuple[1]), 16) * 2
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1719
        list = []
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1720
        data = ''
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1721
        for index in range(length):
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1722
            hexdata = hex(ord(self.SiiBinary[offset + index]))[2:]
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1723
            list.append(hexdata.zfill(2))
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1724
            
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1725
        list.reverse()
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1726
        data = list[0:length]
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1727
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1728
        if format == 16:
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1729
            return '0x' + ''.join(data) 
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1730
        elif format == 10:
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1731
            return str(int(str(''.join(data)), 16))
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1732
        elif format == 2: 
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1733
            ''.join(data)           
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1734
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1735
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1736
#-------------------------------------------------------------------------------
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1737
#                    For Smart View TreeListCtrl
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1738
#-------------------------------------------------------------------------------  
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1739
class SmartViewTreeListCtrl(wx.Panel):
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1740
    def __init__(self, parent, Controler):
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1741
        """
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1742
        Constructor
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1743
        @param parent: Reference to the parent SlaveSiiSmartView class
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1744
        @param controler: _EthercatSlaveCTN class in EthercatSlave.py
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1745
        """
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1746
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1747
        wx.Panel.__init__(self, parent, -1, size=(350, 500))
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1748
        
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1749
        self.Tree = wx.gizmos.TreeListCtrl(self, -1, size=(350, 500), 
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1750
                                           style=wx.TR_DEFAULT_STYLE
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1751
                                                |wx.TR_FULL_ROW_HIGHLIGHT
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1752
                                                |wx.TR_HIDE_ROOT
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1753
                                                |wx.TR_COLUMN_LINES
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1754
                                                |wx.TR_ROW_LINES)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1755
        
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1756
        self.Tree.AddColumn("Description", width=200)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1757
        self.Tree.AddColumn("Value", width=140)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1758
        self.Tree.SetMainColumn(0)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1759
        
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1760
        self.Root = self.Tree.AddRoot("")
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1761
        
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1762
        # Add item
2641
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1763
        # Level 1 nodes
2152
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1764
        self.Level1Nodes = {}
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1765
        for lv1 in ["Config Data", "Device Identity", "Mailbox"]:
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1766
            self.Level1Nodes[lv1] = self.Tree.AppendItem(self.Root, lv1)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1767
        
2641
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1768
        # Level 2 nodes
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1769
        # Config Data
2152
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1770
        self.ConfigData = {}
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1771
        for lv2 in ["EEPROM Size (Bytes)", "PDI Type", "Device Emulation"]:
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1772
            self.ConfigData[lv2] = self.Tree.AppendItem(self.Level1Nodes["Config Data"], lv2)
2641
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1773
        # Device Identity
2152
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1774
        self.DeviceIdentity = {}
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1775
        for lv2 in ["Vendor ID", "Product Code", "Revision No.", "Serial No."]:
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1776
            self.DeviceIdentity[lv2] = self.Tree.AppendItem(self.Level1Nodes["Device Identity"], lv2)
2641
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1777
        # Mailbox
2152
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1778
        self.Mailbox = {}
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1779
        for lv2 in ["Supported Mailbox", "Bootstrap Configuration", "Standard Configuration"]:
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1780
            self.Mailbox[lv2] = self.Tree.AppendItem(self.Level1Nodes["Mailbox"], lv2)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1781
        
2641
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1782
        # Level 3 nodes
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1783
        # Children of Bootstrap Configuration
2152
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1784
        self.BootstrapConfig = {}
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1785
        for lv3 in ["Receive Offset", "Receive Size", "Send Offset", "Send Size"]:
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1786
            self.BootstrapConfig[lv3] = self.Tree.AppendItem(self.Mailbox["Bootstrap Configuration"], lv3)
2641
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1787
        # Children of Standard Configuration
2152
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1788
        self.StandardConfig = {}
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1789
        for lv3 in ["Receive Offset", "Receive Size", "Send Offset", "Send Size"]:
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1790
            self.StandardConfig[lv3] = self.Tree.AppendItem(self.Mailbox["Standard Configuration"], lv3)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1791
        
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1792
        # Expand Tree
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1793
        for tree in [self.Root, 
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1794
                     self.Level1Nodes["Config Data"], 
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1795
                     self.Level1Nodes["Device Identity"], 
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1796
                     self.Level1Nodes["Mailbox"],
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1797
                     self.Mailbox["Bootstrap Configuration"], 
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1798
                     self.Mailbox["Standard Configuration"]]:
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1799
            self.Tree.Expand(tree)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1800
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1801
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1802
#-------------------------------------------------------------------------------
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1803
#                         For Hex View Panel
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1804
#            shows EEPROM binary as hex data and characters.
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1805
#-------------------------------------------------------------------------------  
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1806
class HexView(wx.Panel):
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1807
    def __init__(self, parent, controler):
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1808
        """
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1809
        Constructor
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1810
        @param parent: Reference to the parent EtherCATManagementTreebook class
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1811
        @param controler: _EthercatSlaveCTN class in EthercatSlave.py
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1812
        """
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1813
        wx.Panel.__init__(self, parent, -1)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1814
        self.parent = parent
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1815
        self.Controler = controler
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1816
                
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1817
        self.HexRow = 8
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1818
        self.HexCol = 17
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1819
        
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1820
        self.HexViewSizer = {"view" : wx.FlexGridSizer(cols=1, hgap=10, rows=2, vgap=10),
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1821
                             "siiButton" : wx.BoxSizer()}
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1822
        self.HexViewButton = {}
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1823
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1824
        for key, evt_handler in [("Sii Upload", self.OnButtonSiiUpload),
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1825
                                ("Sii Download", self.OnButtonSiiDownload),
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1826
                                ("Write to File", self.OnButtonWriteToBinFile),
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1827
                                ("Read from File", self.OnButtonReadFromBinFile),
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1828
                                ("XML to EEPROM Image", self.OnButtonXmlToEEPROMImg)]:
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1829
            self.HexViewButton[key] = wx.Button(self, -1, key) 
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1830
            self.HexViewButton[key].Bind(wx.EVT_BUTTON, evt_handler)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1831
            self.HexViewSizer["siiButton"].Add(self.HexViewButton[key])
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1832
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1833
        self.SiiBinary = self.Controler.CommonMethod.XmlToEeprom()
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1834
        self.HexCode, self.HexRow, self.HexCol = self.Controler.CommonMethod.HexRead(self.SiiBinary)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1835
        self.SiiGrid = SiiGridTable(self, self.Controler, self.HexRow, self.HexCol)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1836
        self.HexViewSizer["view"].AddMany([self.HexViewSizer["siiButton"], self.SiiGrid]) 
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1837
        self.SiiGrid.CreateGrid(self.HexRow, self.HexCol)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1838
        self.SetSizer(self.HexViewSizer["view"])     
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1839
        self.HexViewSizer["view"].FitInside(self.parent.parent)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1840
        self.parent.parent.FitInside()
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1841
        self.SiiGrid.SetValue(self.HexCode)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1842
        self.SiiGrid.Update()
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1843
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1844
    def UpdateSiiGridTable(self, row, col):
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1845
        """
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1846
        Destroy existing grid and recreate
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1847
        @param row, col : Hex View grid size
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1848
        """  
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1849
        self.HexViewSizer["view"].Detach(self.SiiGrid)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1850
        self.SiiGrid.Destroy()
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1851
        self.SiiGrid = SiiGridTable(self, self.Controler, row, col)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1852
        self.HexViewSizer["view"].Add(self.SiiGrid)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1853
        self.SiiGrid.CreateGrid(row, col)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1854
        self.SetSizer(self.HexViewSizer["view"])
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1855
        self.HexViewSizer["view"].FitInside(self.parent.parent)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1856
        self.parent.parent.FitInside()
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1857
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1858
    def OnButtonSiiUpload(self, event):
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1859
        """
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1860
        Load EEPROM data from slave and refresh Hex View grid
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1861
        Binded to 'Sii Upload' button.
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1862
        @param event : wx.EVT_BUTTON object
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1863
        """  
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1864
        # Check whether beremiz connected or not.
2641
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1865
        # If this method is called cyclically, set the cyclic flag true
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1866
        check_connect_flag = self.Controler.CommonMethod.CheckConnect(cyclic_flag = False)
2152
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1867
        if check_connect_flag:
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1868
            # load from EEPROM data and parsing
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1869
            self.SiiBinary = self.Controler.CommonMethod.LoadData()
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1870
            self.HexCode, self.HexRow, self.HexCol = self.Controler.CommonMethod.HexRead(self.SiiBinary)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1871
            self.UpdateSiiGridTable(self.HexRow, self.HexCol)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1872
            self.SiiGrid.SetValue(self.HexCode)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1873
            self.SiiGrid.Update()
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1874
            
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1875
    def OnButtonSiiDownload(self, event):
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1876
        """
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1877
        Write current EEPROM data to slave and refresh data structure kept by master 
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1878
        Binded to 'Sii Download' button.
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1879
        @param event : wx.EVT_BUTTON object
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1880
        """  
2641
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1881
        # Check whether beremiz connected or not.
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1882
        # If this method is called cyclically, set the cyclic flag true
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1883
        check_connect_flag = self.Controler.CommonMethod.CheckConnect(cyclic_flag = False)
2152
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1884
        if check_connect_flag:
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1885
            status, count = self.Controler.GetCTRoot()._connector.GetPLCstatus()
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1886
            if status is not "Started":
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1887
                self.Controler.CommonMethod.SiiWrite(self.SiiBinary)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1888
                self.Controler.CommonMethod.Rescan()
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1889
        
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1890
    def OnButtonWriteToBinFile(self, event):
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1891
        """ 
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1892
        Save current EEPROM data to binary file through FileDialog
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1893
        Binded to 'Write to File' button.
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1894
        @param event : wx.EVT_BUTTON object
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1895
        """ 
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1896
        dialog = wx.FileDialog(self, _("Save as..."), os.getcwd(), "slave0.bin",  
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1897
                               _("bin files (*.bin)|*.bin|All files|*.*"), wx.SAVE|wx.OVERWRITE_PROMPT)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1898
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1899
        if dialog.ShowModal() == wx.ID_OK:
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1900
            filepath = dialog.GetPath()
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1901
            binfile = open(filepath,"wb")
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1902
            binfile.write(self.SiiBinary)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1903
            binfile.close()
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1904
    
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1905
        dialog.Destroy()  
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1906
    
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1907
    def OnButtonReadFromBinFile(self, event):
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1908
        """
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1909
        Load binary file through FileDialog
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1910
        Binded to 'Read from File' button.
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1911
        @param event : wx.EVT_BUTTON object
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1912
        """
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1913
        dialog = wx.FileDialog(self, _("Choose a binary file"), os.getcwd(), "",  
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1914
                               _("bin files (*.bin)|*.bin"), wx.OPEN)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1915
        
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1916
        if dialog.ShowModal() == wx.ID_OK:
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1917
            filepath = dialog.GetPath()
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1918
            
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1919
            try:
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1920
                binfile = open(filepath, "rb")
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1921
                self.SiiBinary = binfile.read()
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1922
                self.HexCode, self.HexRow, self.HexCol = self.Controler.CommonMethod.HexRead(self.SiiBinary)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1923
                self.UpdateSiiGridTable(self.HexRow, self.HexCol)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1924
                self.SiiGrid.SetValue(self.HexCode)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1925
                self.SiiGrid.Update()
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1926
            except:
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1927
                self.Controler.CommonMethod.CreateErrorDialog('The file does not exist!')
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1928
            
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1929
        dialog.Destroy()
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1930
            
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1931
    def OnButtonXmlToEEPROMImg(self, event):
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1932
        """
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1933
        Create EEPROM data based XML data that current imported
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1934
        Binded to 'XML to EEPROM' button.
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1935
        @param event : wx.EVT_BUTTON object
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1936
        """
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1937
        self.SiiBinary = self.Controler.CommonMethod.XmlToEeprom()
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1938
        self.HexCode, self.HexRow, self.HexCol = self.Controler.CommonMethod.HexRead(self.SiiBinary)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1939
        self.UpdateSiiGridTable(self.HexRow, self.HexCol)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1940
        self.SiiGrid.SetValue(self.HexCode)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1941
        self.SiiGrid.Update()
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1942
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1943
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1944
#-------------------------------------------------------------------------------
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1945
#                    For Hex View grid (fill hex data)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1946
#-------------------------------------------------------------------------------  
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1947
class SiiGridTable(wx.grid.Grid):  
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1948
    def __init__(self, parent, controler, row, col):
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1949
        """
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1950
        Constructor
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1951
        @param parent: Reference to the parent HexView class
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1952
        @param controler: _EthercatSlaveCTN class in EthercatSlave.py
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1953
        @param row, col: Hex View grid size
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1954
        """
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1955
        self.parent = parent
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1956
        self.Controler = controler
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1957
        self.Row = row
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1958
        self.Col = col    
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1959
        
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1960
        wx.grid.Grid.__init__(self, parent, -1, size=(830,450), 
2641
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1961
                              style=wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL)        
2152
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1962
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1963
    def SetValue(self, value):
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1964
        """
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1965
        Set data in the table
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1966
        @param value: EEPROM data list of which element is 1 Byte hex data
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1967
        """
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1968
        # set label name and size
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1969
        self.SetRowLabelSize(100)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1970
        for col in range(self.Col):
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1971
            if col == 16:
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1972
                self.SetColLabelValue(16, "Text View")
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1973
                self.SetColSize(16, (self.GetSize().x-120)*4/20)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1974
            else:
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1975
                self.SetColLabelValue(col, '%s'%col)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1976
                self.SetColSize(col, (self.GetSize().x-120)/20)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1977
            
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1978
        # set data into table
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1979
        row = col = 0
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1980
        for row_idx in value: 
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1981
            col = 0
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1982
            self.SetRowLabelValue(row, "0x"+"{:0>4x}".format(row*(self.Col-1)))
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1983
            for hex in row_idx:
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1984
                self.SetCellValue(row, col, hex)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1985
                
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1986
                if col == 16: 
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1987
                    self.SetCellAlignment(row, col, wx.ALIGN_LEFT, wx.ALIGN_CENTER)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1988
                else:
2641
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  1989
                    self.SetCellAlignment(row, col, wx.ALIGN_CENTER, wx.ALIGN_CENTER)
2152
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1990
                    
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1991
                self.SetReadOnly(row, col, True)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1992
                col = col + 1
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1993
            row = row + 1
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1994
        
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1995
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1996
#-------------------------------------------------------------------------------
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1997
#                    For Register Access Panel
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1998
#-------------------------------------------------------------------------------  
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  1999
class RegisterAccessPanel(wx.Panel):
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2000
    def __init__(self, parent, controler):
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2001
        """
2641
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2002
	Constructor
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2003
	@param parent: EEPROMAccessPanel object
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2004
	@param controler: _EthercatSlaveCTN class in EthercatSlave.py
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2005
	"""
2152
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2006
        self.parent = parent
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2007
        self.Controler = controler
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2008
        self.__init_data()
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2009
        
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2010
        wx.Panel.__init__(self, parent, -1)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2011
        
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2012
        sizer = wx.FlexGridSizer(cols=1, hgap=20, rows=2, vgap=5)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2013
        button_sizer = wx.FlexGridSizer(cols=2, hgap=10, rows=1, vgap=10)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2014
        
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2015
        self.ReloadButton = wx.Button(self, -1, "Reload")
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2016
        self.CompactViewCheckbox = wx.CheckBox(self, -1, "Compact View")        
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2017
        self.RegisterNotebook = RegisterNotebook(self, self.Controler)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2018
        
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2019
        button_sizer.AddMany([self.ReloadButton, self.CompactViewCheckbox])
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2020
        sizer.AddMany([button_sizer, self.RegisterNotebook])
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2021
        self.SetSizer(sizer)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2022
        
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2023
        self.ReloadButton.Bind(wx.EVT_BUTTON, self.OnReloadButton)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2024
        self.CompactViewCheckbox.Bind(wx.EVT_CHECKBOX, self.ToggleCompactViewCheckbox)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2025
        
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2026
        for index in range(4):
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2027
            self.RegisterNotebook.RegPage[index].MainTable.CreateGrid(self.MainRow[index], self.MainCol)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2028
            self.RegisterNotebook.RegPage[index].MainTable.SetValue(self, 0, index*512, (index+1)*512)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2029
        
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2030
        # data default setting
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2031
        if self.Controler.CommonMethod.RegData == "": 
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2032
            self.CompactViewCheckbox.Disable() 
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2033
            for index in range(4): 
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2034
                self.RegisterNotebook.RegPage[index].MainTable.SetValue(self, 0, index*512, (index+1)*512)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2035
        else: # If data was saved,
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2036
            self.BasicSetData()
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2037
            self.ParseData()
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2038
            for index in range(4):
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2039
                self.RegisterNotebook.RegPage[index].MainTable.SetValue(self, self.RegMonitorData, index*512, (index+1)*512)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2040
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2041
    def __init_data(self):
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2042
        """
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2043
	    Declare initial data.
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2044
	    """
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2045
        # flag for compact view
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2046
        self.CompactFlag = False
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2047
        
2641
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2048
        # main grid��rows and cols
2152
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2049
        self.MainRow = [512, 512, 512, 512]
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2050
        self.MainCol = 4
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2051
        
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2052
        # main grids' data range
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2053
        self.PageRange = []
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2054
        for index in range(4):
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2055
            self.PageRange.append([512*index, 512*(index+1)])
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2056
        
2641
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2057
        # Previous value of register data for register description configuration
2152
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2058
        self.PreRegSpec = {"ESCType": "",
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2059
                           "FMMUNumber": "",
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2060
                           "SMNumber": "",
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2061
                           "PDIType": ""}
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2062
        
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2063
    def LoadData(self):
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2064
        """
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2065
        Get data from the register.
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2066
        """
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2067
        self.Controler.CommonMethod.RegData = ""
2641
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2068
        # ethercat reg_read
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2069
        # ex : ethercat reg_read -p 0 0x0000 0x0001
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2070
        # return value : 0x11
2152
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2071
        for index in range(4):
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2072
            self.Controler.CommonMethod.RegData = self.Controler.CommonMethod.RegData + " " + self.Controler.CommonMethod.RegRead("0x"+"{:0>4x}".format(index*1024), "0x0400")
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2073
        
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2074
        # store previous value 
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2075
        # (ESC type, port number of FMMU, port number of SM, and PDI type))
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2076
        for reg_spec in ["ESCType","FMMUNumber","SMNumber", "PDIType"]:
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2077
            self.PreRegSpec[reg_spec] = self.Controler.CommonMethod.CrtRegSpec[reg_spec]
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2078
        
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2079
        # update registers' description 
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2080
        # (ESC type, port number of FMMU, port number of SM, and PDI type)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2081
        for reg_spec, address in [("ESCType", "0x0000"),
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2082
                                  ("FMMUNumber", "0x0004"),
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2083
                                  ("SMNumber", "0x0005"),
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2084
                                  ("PDIType", "0x0140")]:
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2085
            self.Controler.CommonMethod.CrtRegSpec[reg_spec] = self.Controler.CommonMethod.RegRead(address, "0x0001")
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2086
                 
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2087
        # Enable compactView checkbox
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2088
        self.CompactViewCheckbox.Enable()
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2089
    
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2090
    def BasicSetData(self):
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2091
        """
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2092
        Get and save the description of registers. 
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2093
        It's done by parsing register_information.xml.
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2094
        """
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2095
        # parse the above register's value
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2096
        # If the value is 0x12, the result is 12
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2097
        self.ESCType = self.Controler.CommonMethod.CrtRegSpec["ESCType"].split('x')[1]
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2098
        self.PDIType = self.Controler.CommonMethod.CrtRegSpec["PDIType"].split('x')[1]
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2099
        # If the value is 0x12, the result is 18 (It's converted to decimal value)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2100
        self.FMMUNumber = int(self.Controler.CommonMethod.CrtRegSpec["FMMUNumber"], 16)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2101
        self.SMNumber = int(self.Controler.CommonMethod.CrtRegSpec["SMNumber"], 16)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2102
        
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2103
        # initialize description dictionary of register main table and register sub table.
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2104
        self.RegisterDescriptionDict = {}
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2105
        self.RegisterSubGridDict = {}
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2106
        
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2107
        # ./EthercatMaster/register_information.xml contains register description.
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2108
        if wx.Platform == '__WXMSW__':
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2109
            reg_info_file = open("../../EthercatMaster/register_information.xml", 'r')
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2110
        else:
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2111
            reg_info_file = open("./EthercatMaster/register_information.xml", 'r')
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2112
        reg_info_tree = minidom.parse(reg_info_file)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2113
        reg_info_file.close()
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2114
        
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2115
        # parse register description
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2116
        for register_info in reg_info_tree.childNodes:
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2117
            for register in register_info.childNodes:
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2118
                if register.nodeType == reg_info_tree.ELEMENT_NODE and register.nodeName == "Register":
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2119
                    # If it depends on the property(ESC type, PDI type, FMMU number, SM number)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2120
                    for property, type, value in [("esc", "type", self.ESCType),
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2121
                                                  ("pdi", "type", self.PDIType),
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2122
                                                  ("fmmu", "number", self.FMMUNumber),
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2123
                                                  ("sm", "number", self.SMNumber)]:
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2124
                        if property in register.attributes.keys(): 
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2125
                            if type == "type":
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2126
                                if register.attributes[property].value == value:
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2127
                                    self.GetRegisterInfo(reg_info_tree, register)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2128
                                    break
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2129
                            else: # type == "number"
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2130
                                if register.attributes[property].value < value:
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2131
                                    self.GetRegisterInfo(reg_info_tree, register)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2132
                                    break
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2133
                        else:
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2134
                            self.GetRegisterInfo(reg_info_tree, register)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2135
                            break
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2136
                            
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2137
    def GetRegisterInfo(self, reg_info_tree, register):
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2138
        """
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2139
        Save the register's description into the dictionary.
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2140
        reg_info_tree is based on the register_information.xml.
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2141
        @param reg_info_tree: XML tree
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2142
        @param register: register which you want to get the description
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2143
        """
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2144
        # temporary variables for register main table idescription dictionary
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2145
        reg_index = ""
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2146
        reg_main_description = ""
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2147
        
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2148
        for data in register.childNodes:
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2149
            if data.nodeType == reg_info_tree.ELEMENT_NODE and data.nodeName == "Index":
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2150
                for index in data.childNodes:
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2151
                    reg_index = index.nodeValue
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2152
            if data.nodeType == reg_info_tree.ELEMENT_NODE and data.nodeName == "Description":
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2153
                for description in data.childNodes:
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2154
                    reg_main_description = description.nodeValue
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2155
                    
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2156
            # Add description for register main table 
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2157
            if reg_index is not "" and reg_main_description is not "":
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2158
                self.RegisterDescriptionDict[reg_index] = reg_main_description
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2159
                    
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2160
            if data.nodeType == reg_info_tree.ELEMENT_NODE and data.nodeName == "Details":
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2161
                # declare register sub table description dictionary about this index
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2162
                self.RegisterSubGridDict[reg_index] = []
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2163
                
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2164
                for detail in data.childNodes:
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2165
                    if detail.nodeType == reg_info_tree.ELEMENT_NODE and detail.nodeName == "Detail":
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2166
                        # If it depends on the property(ESC type, PDI type, FMMU number, SM number)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2167
                        for property, type, value in [("esc", "type", self.ESCType),
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2168
                                                      ("pdi", "type", self.PDIType),
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2169
                                                      ("fmmu", "number", self.FMMUNumber),
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2170
                                                      ("sm", "number", self.SMNumber)]:
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2171
                            if property in detail.attributes.keys(): 
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2172
                                if type == "type":
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2173
                                    if detail.attributes[property].value == value:
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2174
                                        self.GetRegisterDetailInfo(reg_info_tree, reg_index, detail)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2175
                                        break
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2176
                                else: # type == "number"
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2177
                                    if detail.attributes[property].value < value:
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2178
                                        self.GetRegisterDetailInfo(reg_info_tree, reg_index, detail)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2179
                                        break
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2180
                            else:
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2181
                                self.GetRegisterDetailInfo(reg_info_tree, reg_index, detail)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2182
                                break
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2183
                                          
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2184
    def GetRegisterDetailInfo(self, reg_info_tree, reg_index, detail):
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2185
        """
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2186
        Get the resgister's detailed description(for sub table) from the reg_info_tree.
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2187
        @param reg_info_tree: XML tree (register_information.xml)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2188
        @param reg_index: index of the register
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2189
        @param detail: description of the register
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2190
        """
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2191
        # temporary variables for register sub table description dictionary 
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2192
        # - It is initialized in every sub description 
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2193
        reg_bit_range = ""
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2194
        reg_sub_description = ""
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2195
        reg_enum_dictionary = {}
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2196
        
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2197
        for detail_data in detail.childNodes:
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2198
            if detail_data.nodeType == reg_info_tree.ELEMENT_NODE and detail_data.nodeName == "Range":                                            
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2199
                for range in detail_data.childNodes:
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2200
                    reg_bit_range = range.nodeValue
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2201
            if detail_data.nodeType == reg_info_tree.ELEMENT_NODE and detail_data.nodeName == "Description":
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2202
                for description in detail_data.childNodes:
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2203
                    reg_sub_description = description.nodeValue
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2204
                    
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2205
            if detail_data.nodeType == reg_info_tree.ELEMENT_NODE and detail_data.nodeName == "Enum":
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2206
                for enum in detail_data.childNodes:
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2207
                    if enum.nodeType == reg_info_tree.ELEMENT_NODE and enum.nodeName == "item":
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2208
                        
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2209
                        # temporary variables for a description of each value 
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2210
                        # For example, if the bit is 1, it is 'enabled'('On', 'True', etc.), 
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2211
                        # otherwise 'disabled'('Off', 'False', etc.). 
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2212
                        reg_sub_value = ""
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2213
                        reg_sub_value_description = ""
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2214
                        
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2215
                        for item in enum.childNodes:
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2216
                            if item.nodeType == reg_info_tree.ELEMENT_NODE and item.nodeName == "value":
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2217
                                for value in item.childNodes:
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2218
                                    reg_sub_value = value.nodeValue
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2219
                            if item.nodeType == reg_info_tree.ELEMENT_NODE and item.nodeName == "Description":
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2220
                                for description in item.childNodes:
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2221
                                    reg_sub_value_description = description.nodeValue
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2222
                                    
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2223
                            # Add a description of each value to register enum dictionary
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2224
                            if reg_sub_value is not "" and reg_sub_value_description is not "":
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2225
                                reg_enum_dictionary[reg_sub_value] = reg_sub_value_description
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2226
                            
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2227
        # add a description to register sub table description dictionary
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2228
        if reg_bit_range is not "" and reg_sub_description is not "":
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2229
            self.RegisterSubGridDict[reg_index].append([reg_bit_range, 
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2230
                                                         reg_sub_description, reg_enum_dictionary])
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2231
    
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2232
    def ParseData(self):
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2233
        """
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2234
        Transform the data into dec, hex, string, and description
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2235
        """
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2236
        row_data = []
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2237
        self.RegMonitorData = []
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2238
        reg_word = ""
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2239
        
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2240
        reg_data = self.Controler.CommonMethod.RegData.split()
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2241
        
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2242
        # loop for register(0x0000:0x0fff)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2243
        for address in range(0x1000):
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2244
            # arrange 2 Bytes of register data 
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2245
            reg_word = reg_data[address].split('x')[1] + reg_word
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2246
            if (address%2) == 1:
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2247
                # append address
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2248
                hex_address = "{:0>4x}".format(address-1)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2249
                row_data.append(hex_address)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2250
                
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2251
                # append description
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2252
                if self.RegisterDescriptionDict.has_key(hex_address):
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2253
                    row_data.append(self.RegisterDescriptionDict[hex_address])
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2254
                else:
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2255
                    row_data.append("")
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2256
                    
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2257
                # append Decimal value
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2258
                row_data.append(str(int(reg_word, 16)))
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2259
                
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2260
                # append Hex value
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2261
                row_data.append('0x'+reg_word)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2262
                
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2263
                # append ASCII value
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2264
                char_data = ""
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2265
                for iter in range(2):
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2266
                    if int(reg_word[iter*2:iter*2+2], 16)>=32 and int(reg_word[iter*2:iter*2+2], 16)<=126:
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2267
                        char_data = char_data + chr(int(reg_word[iter*2:iter*2+2], 16))
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2268
                    else:
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2269
                        char_data = char_data + "."
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2270
                row_data.append(char_data)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2271
                
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2272
                self.RegMonitorData.append(row_data)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2273
                reg_word = "" # initialize regWord
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2274
                row_data = []
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2275
    
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2276
    def OnReloadButton(self, event):
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2277
        """
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2278
        Handle the click event of the 'Reload' button.
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2279
        Get the data from registers again, and update the table.
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2280
        @param event: wx.EVT_BUTTON object
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2281
        """
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2282
        # Check whether beremiz connected or not.
2641
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2283
        # If this method is called cyclically, set the cyclic flag true
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2284
        check_connect_flag = self.Controler.CommonMethod.CheckConnect(cyclic_flag = False)
2152
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2285
        if check_connect_flag:
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2286
            self.LoadData()
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2287
            self.BasicSetData()
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2288
            self.ParseData()
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2289
            # set data into UI
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2290
            if self.CompactFlag:
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2291
                self.ToggleCompactViewCheckbox(True)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2292
            else : 
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2293
                for index in range(4):
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2294
                    self.RegisterNotebook.RegPage[index].UpdateMainTable(self.MainRow[index], self.MainCol, 
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2295
                                                                         self.PageRange[index][0], self.PageRange[index][1], 
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2296
                                                                         self.RegMonitorData)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2297
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2298
    def ToggleCompactViewCheckbox(self, event):
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2299
        """
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2300
        Handles the event of the 'Compact view' check box.
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2301
        If it's checked, show only the registers that have a description.
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2302
        If not, show all the registers.
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2303
        @param event: wx.EVT_CHECKBOX object
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2304
        """
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2305
        
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2306
        # If "Compact View" Checkbox is True
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2307
        ## 'event' is argument of this method or event of checkbox.
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2308
        if event==True or event.GetEventObject().GetValue():
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2309
            self.CompactFlag = True
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2310
            
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2311
            reg_compact_data = []
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2312
            page_row = [0, 0, 0, 0]
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2313
            for index in range(4):
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2314
                self.PageRange[index] = [0, 0]
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2315
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2316
            for reg_row_data in self.RegMonitorData:
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2317
                if reg_row_data[1] is not "":
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2318
                    # data structure for "compact view"
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2319
                    reg_compact_data.append(reg_row_data)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2320
                    # count for each register notebooks' row
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2321
                    # It compare with register's address.
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2322
                    for index in range(4):
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2323
                        if int('0x'+reg_row_data[0], 16) < (index+1)*1024:
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2324
                            page_row[index] += 1
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2325
                            break
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2326
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2327
            # Setting tables' rows and cols, range for compact view
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2328
            for index in range(4):
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2329
                self.MainRow[index] = page_row[index]
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2330
                self.PageRange[index][1] = page_row[index]
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2331
                for iter in range(index):
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2332
                    self.PageRange[index][0] += page_row[iter]
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2333
                    self.PageRange[index][1] += page_row[iter] 
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2334
                          
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2335
            # Update table
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2336
            for index in range(4):
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2337
                self.RegisterNotebook.RegPage[index].UpdateMainTable(self.MainRow[index], self.MainCol, 
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2338
                                                                      self.PageRange[index][0], self.PageRange[index][1], 
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2339
                                                                      reg_compact_data)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2340
            
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2341
        # Compact View Checkbox is False    
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2342
        else:
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2343
            self.CompactFlag = False
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2344
            # Setting original rows, cols and range
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2345
            self.MainRow = [512, 512, 512, 512]
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2346
            self.PageRange = []
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2347
            
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2348
            for index in range(4):
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2349
                self.PageRange.append([512*index, 512*(index+1)])
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2350
            
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2351
            # Update table 
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2352
            for index in range(4):
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2353
                self.RegisterNotebook.RegPage[index].UpdateMainTable(self.MainRow[index], self.MainCol, 
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2354
                                                                      self.PageRange[index][0], self.PageRange[index][1], 
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2355
                                                                      self.RegMonitorData)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2356
                
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2357
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2358
#-------------------------------------------------------------------------------
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2359
#                    For Register Access Notebook (divide index range)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2360
#-------------------------------------------------------------------------------  
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2361
class RegisterNotebook(wx.Notebook):
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2362
    def __init__(self, parent, controler):
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2363
        """
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2364
        Constructor
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2365
        @param parent: RegisterAccessPanel object
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2366
        @param controler: _EthercatSlaveCTN class in EthercatSlave.py
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2367
        """
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2368
        wx.Notebook.__init__(self, parent, id = -1)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2369
        
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2370
        self.parent = parent
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2371
        self.Controler = controler
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2372
        
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2373
        # Initialize pages
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2374
        self.RegPage = []
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2375
        for iter in range(4):
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2376
            self.RegPage.append(None)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2377
        
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2378
        for index in range(4):
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2379
            self.RegPage[index] = RegisterNotebookPanel(self, self.Controler, 
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2380
                                                    parent.MainRow[index], parent.MainCol)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2381
            self.AddPage(self.RegPage[index], 
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2382
                         "0x"+"{:0>4x}".format(index*1024)+" - 0x"+"{:0>4x}".format((index+1)*1024-1))
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2383
        
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2384
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2385
#-------------------------------------------------------------------------------
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2386
#                    For Register Access Notebook Panel 
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2387
#                  (Main UI : including main, sub table)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2388
#-------------------------------------------------------------------------------  
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2389
class RegisterNotebookPanel(wx.Panel):
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2390
    def __init__(self, parent, controler, row, col):
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2391
        """
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2392
        Constructor
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2393
        @param parent: RegisterAccessPanel object
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2394
        @param controler: _EthercatSlaveCTN class in EthercatSlave.py
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2395
        @param row, col: size of the table
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2396
    	"""
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2397
        wx.Panel.__init__(self, parent, -1)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2398
        
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2399
        self.parent = parent
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2400
        self.Controler = controler
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2401
        self.Row = row
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2402
        self.Col = col
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2403
        sub_row = 0
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2404
        sub_col = 4
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2405
        
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2406
        self.Sizer = wx.FlexGridSizer(cols=1, hgap=10, rows=2, vgap=30)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2407
        
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2408
        self.MainTable = RegisterMainTable(self, self.Row, self.Col, self.Controler)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2409
        self.SubTable = RegisterSubTable(self, sub_row, sub_col)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2410
        
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2411
        self.SubTable.CreateGrid(sub_row, sub_col)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2412
        self.SubTable.SetValue(self, [])
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2413
        
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2414
        self.Sizer.AddMany([self.MainTable, self.SubTable])
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2415
        
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2416
        self.SetSizer(self.Sizer)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2417
     
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2418
    def UpdateMainTable(self, row, col, low_index, high_index, data):
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2419
        """
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2420
        Updates main table.
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2421
        It's done by deleting the main table and creating it again.
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2422
        @param row, col: size of the table
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2423
        @param low_index: the lowest index of the page
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2424
        @param high_index: the highest index of the page
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2425
        @param data: data
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2426
    	"""
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2427
        self.MainTable.Destroy()
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2428
        self.MainTable = RegisterMainTable(self, row, col, self.Controler)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2429
        self.Sizer.Detach(self.SubTable)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2430
        self.Sizer.AddMany([self.MainTable, self.SubTable])
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2431
        self.SetSizer(self.Sizer)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2432
        self.MainTable.CreateGrid(row, col)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2433
        self.MainTable.SetValue(self, data, low_index, high_index)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2434
        self.MainTable.Update()
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2435
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2436
    def UpdateSubTable(self, row, col, data):
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2437
        """
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2438
        Updates sub table.
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2439
        It's done by deleting the sub table and creating it again.
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2440
        @param row, col: size of the table
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2441
        @param data: data
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2442
    	"""
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2443
        self.SubTable.Destroy()
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2444
        self.SubTable = RegisterSubTable(self, row, col)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2445
        self.Sizer.Detach(self.MainTable)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2446
        self.Sizer.AddMany([self.MainTable, self.SubTable])
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2447
        self.Sizer.Layout()
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2448
        self.SetSizer(self.Sizer)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2449
        self.SubTable.CreateGrid(row, col)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2450
        self.SubTable.SetValue(self, data)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2451
        self.SubTable.Update()
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2452
        
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2453
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2454
#-------------------------------------------------------------------------------
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2455
#                    For Register Access Notebook Panel (Main Table)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2456
#-------------------------------------------------------------------------------  
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2457
class RegisterMainTable(wx.grid.Grid):
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2458
    def __init__(self, parent, row, col, controler):        
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2459
        """
2641
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2460
	Constructor
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2461
	@param parent: RegisterNotebook object
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2462
	@param row, col: size of the table
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2463
	@param controler: _EthercatSlaveCTN class in EthercatSlave.py
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2464
	"""
2152
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2465
        self.parent = parent
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2466
        self.Data = {}
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2467
        self.Row = row
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2468
        self.Col = col
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2469
        self.Controler = controler
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2470
        self.RegisterAccessPanel = self.parent.parent.parent
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2471
        wx.grid.Grid.__init__(self, parent, -1, size=(820,300), 
2641
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2472
                              style=wx.EXPAND|wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL)        
2152
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2473
        
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2474
        for evt, mapping_method in [(gridlib.EVT_GRID_CELL_LEFT_CLICK, self.OnSelectCell),
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2475
                                    (gridlib.EVT_GRID_CELL_LEFT_CLICK, self.OnSelectCell),
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2476
                                    (gridlib.EVT_GRID_CELL_LEFT_DCLICK, self.OnRegModifyDialog)]:
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2477
            self.Bind(evt, mapping_method)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2478
       
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2479
    def SetValue(self, parent, reg_monitor_data, low_index, high_index):  
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2480
        """
2641
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2481
	Set the RegMonitorData into the main table.
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2482
	@param parent: RegisterNotebook object
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2483
	@param reg_monitor_data: data
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2484
	@param low_index: the lowest index of the page
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2485
	@param high_index: the highest index of the page
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2486
	"""
2152
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2487
        self.RegMonitorData = reg_monitor_data
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2488
        
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2489
        # set label name and size
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2490
        register_maintable_label = [(0, "Description"), (1, "Dec"), 
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2491
                                    (2, "Hex"), (3, "Char")]
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2492
        
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2493
        for (index, label) in register_maintable_label:
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2494
            self.SetColLabelValue(index, label)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2495
        
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2496
        self.SetColSize(0, 200)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2497
    
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2498
        # if reg_monitor_data is 0, it is initialization of register access.
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2499
        if reg_monitor_data == 0:
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2500
            return 0
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2501
    
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2502
        # set data into UI 
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2503
        row = col = 0
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2504
        for row_index in reg_monitor_data[low_index:high_index]:
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2505
            col = 0
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2506
            self.SetRowLabelValue(row, row_index[0])
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2507
            for data_index in range(4):
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2508
                self.SetCellValue(row, col, row_index[data_index+1])
2641
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2509
                self.SetCellAlignment(row, col, wx.ALIGN_CENTER, wx.ALIGN_CENTER)
2152
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2510
                self.SetReadOnly(row, col, True)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2511
                col = col + 1
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2512
            row = row + 1
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2513
    
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2514
    def OnSelectCell(self, event): 
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2515
        """
2641
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2516
	Handles the event of the cell of the main table.
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2517
	@param event: gridlib object (left click)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2518
	"""
2152
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2519
        # if reg_monitor_data is 0, it is initialization of register access.
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2520
        if self.RegMonitorData == 0:
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2521
            event.Skip()
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2522
            return 0
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2523
        
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2524
        sub_row = 0
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2525
        sub_col = 4
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2526
        
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2527
        address = self.GetRowLabelValue(event.GetRow())
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2528
        
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2529
        reg_sub_grid_data = []
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2530
        
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2531
        BIT_RANGE, NAME, DESCRIPTIONS = range(3)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2532
        
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2533
        # Check if this register's detail description is exist or not, 
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2534
        # and create data structure for the detail description table ; sub grid
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2535
        if address in self.RegisterAccessPanel.RegisterSubGridDict:
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2536
            for element in self.RegisterAccessPanel.RegisterSubGridDict[address]:
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2537
                row_data =[]
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2538
                row_data.append(element[BIT_RANGE])
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2539
                row_data.append(element[NAME])
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2540
                bin_data = "{:0>16b}".format(int(self.GetCellValue(event.GetRow(), 1)))
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2541
                value_range = element[BIT_RANGE].split('-')
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2542
                value = (bin_data[8:16][::-1]+bin_data[0:8][::-1])[int(value_range[0]):(int(value_range[-1])+1)][::-1]
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2543
                row_data.append(str(int(('0b'+str(value)), 2)))
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2544
                if value in element[DESCRIPTIONS]:
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2545
                    row_data.append(element[DESCRIPTIONS][value])
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2546
                else:
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2547
                    row_data.append('')
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2548
                reg_sub_grid_data.append(row_data)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2549
                sub_row = sub_row + 1
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2550
        
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2551
        self.parent.UpdateSubTable(sub_row, sub_col, reg_sub_grid_data)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2552
        # event.Skip() updates UI of selecting cell
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2553
        event.Skip()
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2554
    
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2555
    def OnRegModifyDialog(self, event):
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2556
        """
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2557
        Handle the event of the cell of the main table.
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2558
        Display the window where the user modifies the value of the cell.
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2559
        @param event: gridlib object (double click)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2560
	    """
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2561
        # user can enter a value in case that user double-clicked 'Dec' or 'Hex' value.
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2562
        if event.GetCol() == 1 or event.GetCol() == 2:
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2563
            dlg = wx.TextEntryDialog(self, "Enter hex(0xnnnn) or dec(n) value", 
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2564
                                     "Register Modify Dialog", style = wx.OK|wx.CANCEL)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2565
            
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2566
            # Setting value in initial dialog value
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2567
            start_value = self.GetCellValue(event.GetRow(), event.GetCol())
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2568
            dlg.SetValue(start_value)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2569
        
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2570
            if dlg.ShowModal() == wx.ID_OK:
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2571
                try:
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2572
                    # It int(input) success, this input is dev or hex value. 
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2573
                    # Otherwise, it's error, so it goes except.
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2574
                    int(dlg.GetValue(), 0)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2575
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2576
                    # reg_write
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2577
                    # ex) ethercat reg_write -p 0 -t uint16 0x0000 0x0000
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2578
                    return_val = self.Controler.CommonMethod.RegWrite('0x'+self.GetRowLabelValue(event.GetRow()), dlg.GetValue())
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2579
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2580
                    if len(return_val)==0:
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2581
                        # set dec
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2582
                        self.SetCellValue(event.GetRow(), 1, str(int(dlg.GetValue(), 0))) 
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2583
                        # set hex
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2584
                        hex_data = '0x'+"{:0>4x}".format(int(dlg.GetValue(), 0))
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2585
                        self.SetCellValue(event.GetRow(), 2, hex_data)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2586
                        # set char
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2587
                        char_data = ""
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2588
                        # If hex_data is been able to convert to ascii code, append ascii code.
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2589
                        for iter in range(2):
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2590
                            if int(hex_data[(iter+1)*2:(iter+2)*2], 16)>=32 and int(hex_data[(iter+1)*2:(iter+2)*2], 16)<=126:
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2591
                                char_data = char_data + chr(int(hex_data[(iter+1)*2:(iter+2)*2], 16))
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2592
                            else:
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2593
                                char_data = char_data + "."
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2594
                            
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2595
                        self.SetCellValue(event.GetRow(), 3, char_data) 
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2596
                    
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2597
                    else:
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2598
                        self.Controler.CommonMethod.CreateErrorDialog('You can\'t modify it. This register is read-only or it\'s not connected.')
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2599
                
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2600
                except ValueError:
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2601
                    self.Controler.CommonMethod.CreateErrorDialog('You entered wrong value. You can enter dec or hex value only.')
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2602
        
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2603
    
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2604
#-------------------------------------------------------------------------------
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2605
#                    For Register Access Notebook Panel (Sub Table)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2606
#-------------------------------------------------------------------------------  
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2607
class RegisterSubTable(wx.grid.Grid):
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2608
    def __init__(self, parent, row, col):
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2609
        """
2641
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2610
    	Constructor
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2611
    	@param parent: RegisterNotebook object
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2612
    	@param row, col: size of the table
2152
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2613
    	"""
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2614
        self.parent = parent
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2615
        self.Data = {}
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2616
        self.Row = row
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2617
        self.Col = col
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2618
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2619
        wx.grid.Grid.__init__(self, parent, -1, size=(820,150), 
2641
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2620
                              style=wx.EXPAND|wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL)        
2152
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2621
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2622
    def SetValue(self, parent, data):
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2623
        """
2641
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2624
	Set the data into the subtable.
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2625
	@param parent: RegisterNotebook object
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2626
	@param data: data
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2627
	"""
2152
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2628
        # lset label name and size
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2629
        Register_SubTable_Label = [(0, "Bits"), (1, "Name"), 
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2630
                                    (2, "Value"), (3, "Enum")]
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2631
        
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2632
        for (index, label) in Register_SubTable_Label:
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2633
            self.SetColLabelValue(index, label)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2634
        
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2635
        self.SetColSize(1, 200)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2636
        self.SetColSize(3, 200)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2637
            
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2638
        # set data into table
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2639
        row = col = 0
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2640
        for rowData in data: 
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2641
            col = 0     
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2642
            for element in rowData:
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2643
                self.SetCellValue(row, col, element)
2641
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2644
                self.SetCellAlignment(row, col, wx.ALIGN_CENTER, wx.ALIGN_CENTER)
2152
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2645
                self.SetReadOnly(row, col, True)
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2646
                col = col + 1
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2647
            row = row + 1
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2648
                
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2649
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2650
#-------------------------------------------------------------------------------
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2651
#                    For Master State Panel
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2652
#-------------------------------------------------------------------------------  
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2653
class MasterStatePanelClass(wx.Panel):
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2654
    def __init__(self, parent, controler):
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2655
        """
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2656
        Constructor
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2657
        @param parent: wx.ScrollWindow object
2641
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2658
        @Param controler: _EthercatCTN class in EthercatMaster.py
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2659
        """
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2660
        wx.Panel.__init__(self, parent)
2152
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2661
        self.Controler = controler
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2662
        self.parent = parent
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2663
        self.StaticBox = {}
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2664
        self.StaticText = {}
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2665
        self.TextCtrl = {}
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2666
          
2641
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2667
        # ---------------------------- Main Sizer and Buttons --------------------------------------------
2152
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2668
        self.MasterStateSizer = {"main" : wx.BoxSizer(wx.VERTICAL)}
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2669
        for key, attr in [
2641
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2670
            ("innerTop",            [2, 10, 1, 10]),
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2671
            ("innerMiddle",         [1, 10, 1, 10]),
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2672
            ("innerBottom",         [1, 10, 1, 10]),
2152
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2673
            ("innerMasterState",    [2, 10, 3, 10]),
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2674
            ("innerDeviceInfo",     [4, 10, 3, 10]),
2641
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2675
            ("innerFrameInfo",      [4, 10, 5, 10]),
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2676
            ("innerSlaveInfo",     [1, 10, 2, 10])]:
2152
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2677
            self.MasterStateSizer[key] = wx.FlexGridSizer(cols=attr[0], hgap=attr[1], rows=attr[2], vgap=attr[3])
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2678
2641
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2679
        self.MSUpdateButton = wx.Button(self, label=_("Update"))
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2680
        self.MSUpdateButton.Bind(wx.EVT_BUTTON, self.OnMSUpdateButtonClick)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2681
        self.SIUpdateButton = wx.Button(self, label=_("Update"))
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2682
        self.SIUpdateButton.Bind(wx.EVT_BUTTON, self.OnSIUpdateButtonClick)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2683
        
2152
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2684
        for key, label in [                
2641
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2685
            ("masterState", "EtherCAT Master State"),
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2686
            ("deviceInfo", "Ethernet Network Card Information"),
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2687
            ("frameInfo", "Network Frame Information"),
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2688
            ("slaveInfo", "Slave Information")]: 
2152
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2689
            self.StaticBox[key] = wx.StaticBox(self, label=_(label))
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2690
            self.MasterStateSizer[key] = wx.StaticBoxSizer(self.StaticBox[key])
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2691
        
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2692
        # ----------------------- Master State -----------------------------------------------------------
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2693
        for key, label in [
2641
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2694
            ("Phase", "Phase:"),
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2695
            ("Active", "Active:"),
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2696
            ("Slaves", "Slave Count:")]:
2152
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2697
            self.StaticText[key] = wx.StaticText(self, label=_(label))
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2698
            self.TextCtrl[key] = wx.TextCtrl(self, size=wx.Size(130, 24), style=wx.TE_READONLY)
2641
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2699
            self.MasterStateSizer["innerMasterState"].AddMany([self.StaticText[key], self.TextCtrl[key]])    
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2700
        
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2701
        self.MasterStateSizer["masterState"].AddSizer(self.MasterStateSizer["innerMasterState"])
2152
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2702
        
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2703
        # ----------------------- Ethernet Network Card Information --------------------------------------- 
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2704
        for key, label in [
2641
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2705
            ("Main", "MAC Address:"),
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2706
            ("Link", "Link State:"),
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2707
            ("Tx frames", "Tx Frames:"),
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2708
            ("Rx frames", "Rx Frames:"),
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2709
            ("Lost frames", "Lost Frames:")]:
2152
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2710
            self.StaticText[key] = wx.StaticText(self, label=_(label))
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2711
            self.TextCtrl[key] = wx.TextCtrl(self, size=wx.Size(130, 24), style=wx.TE_READONLY)
2641
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2712
            self.MasterStateSizer["innerDeviceInfo"].AddMany([self.StaticText[key], self.TextCtrl[key]])
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2713
        
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2714
        self.MasterStateSizer["deviceInfo"].AddSizer(self.MasterStateSizer["innerDeviceInfo"])
2152
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2715
        
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2716
        # ----------------------- Network Frame Information -----------------------------------------------
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2717
        for key, label in [
2641
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2718
            ("Tx frame rate [1/s]", "Tx Frame Rate [1/s]:"), 
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2719
            ("Tx rate [KByte/s]", "Tx Rate [KByte/s]:"), 
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2720
            ("Rx frame rate [1/s]", "Rx Frame Rate [1/s]:"), 
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2721
            ("Rx rate [KByte/s]", "Rx Rate [KByte/s]:"), 
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2722
            ("Loss rate [1/s]", "Loss Rate [1/s]:"),
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2723
            ("Frame loss [%]", "Frame Loss [%]:")]:
2152
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2724
            self.StaticText[key] = wx.StaticText(self, label=_(label))
2641
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2725
            self.MasterStateSizer["innerFrameInfo"].Add(self.StaticText[key])
2152
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2726
            self.TextCtrl[key] = {} 
2641
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2727
            for index in ["0", "1", "2"]:                
2152
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2728
                self.TextCtrl[key][index] = wx.TextCtrl(self, size=wx.Size(130, 24), style=wx.TE_READONLY)
2641
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2729
                self.MasterStateSizer["innerFrameInfo"].Add(self.TextCtrl[key][index])
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2730
        
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2731
        self.MasterStateSizer["frameInfo"].AddSizer(self.MasterStateSizer["innerFrameInfo"])
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2732
        
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2733
        # ------------------------------- Slave Information  -----------------------------------------------
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2734
        self.SITreeListCtrl = SITreeListCtrl(self, self.Controler) 
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2735
        self.MasterStateSizer["innerSlaveInfo"].AddMany([self.SIUpdateButton,
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2736
                                                               self.SITreeListCtrl])
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2737
        self.MasterStateSizer["slaveInfo"].AddSizer(
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2738
                self.MasterStateSizer["innerSlaveInfo"]) 
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2739
2152
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2740
        # --------------------------------- Main Sizer ----------------------------------------------------
2641
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2741
        self.MasterStateSizer["main"].Add(self.MSUpdateButton)
2152
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2742
        for key, sub, in [
2641
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2743
            ("innerTop", [
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2744
                    "masterState", "deviceInfo"]),
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2745
            ("innerMiddle", [
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2746
                    "frameInfo"]),
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2747
            ("innerBottom", [
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2748
                    "slaveInfo"]),
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2749
            ("main", [
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2750
                    "innerTop", "innerMiddle", "innerBottom"])]:
2152
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2751
            for key2 in sub:
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2752
                self.MasterStateSizer[key].AddSizer(self.MasterStateSizer[key2])
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2753
2641
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2754
        self.SetSizer(self.MasterStateSizer["main"])
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2755
    
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2756
    def OnMSUpdateButtonClick(self, event):
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2757
        """
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2758
        Handle the event of the "Update" button.
2152
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2759
        Update the data of the master state.
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2760
        @param event: wx.EVT_BUTTON object
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2761
        """
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2762
        if self.Controler.GetCTRoot()._connector is not None:
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2763
            self.MasterState = self.Controler.CommonMethod.GetMasterState()
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2764
            # Update each TextCtrl
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2765
            if self.MasterState:
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2766
                for key in self.TextCtrl:
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2767
                    if isinstance(self.TextCtrl[key], dict):
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2768
                        for index in self.TextCtrl[key]:
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2769
                            self.TextCtrl[key][index].SetValue(self.MasterState[key][int(index)])
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2770
                    else:
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2771
                        self.TextCtrl[key].SetValue(self.MasterState[key][0])
2641
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2772
        
2152
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2773
        else :
e6946c298a42 Cherry-pick and re-commit to legitimate ancestor of commit 'Ethercat Management Function Refactoring Source by RTES Lab.' from youcu <youcu1022@gmail.com>
Edouard Tisserant
parents:
diff changeset
  2774
            self.Controler.CommonMethod.CreateErrorDialog('PLC not connected!')
2641
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2775
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2776
    def OnSIUpdateButtonClick(self, event):
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2777
        """
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2778
        Handle the event of the radio box in the slave information 
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2779
        @param event: wx.EVT_RADIOBOX object
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2780
        """
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2781
        if self.Controler.GetCTRoot()._connector is not None:
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2782
            self.SITreeListCtrl.UpdateSI()
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2783
        
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2784
        else :
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2785
            self.Controler.CommonMethod.CreateErrorDialog('PLC not connected!')
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2786
    
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2787
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2788
#-------------------------------------------------------------------------------
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2789
#                    For Slave Information  Panel
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2790
#------------------------------------------------------------------------------- 
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2791
class SITreeListCtrl(wx.Panel):
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2792
    
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2793
    EC_Addrs = ["0x0300", "0x0302", "0x0304", "0x0306", "0x0301", "0x0303", "0x0305", 
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2794
                "0x0307", "0x0308", "0x0309", "0x030A", "0x030B", "0x030C", "0x030D",
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2795
                "0x0310", "0x0311", "0x0312", "0x0313", "0x0442", "0x0443"]
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2796
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2797
    def __init__(self, parent, controler):
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2798
        """
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2799
        Constructor
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2800
        @param parent: Reference to the MasterStatePanel class
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2801
        @param Controler: _EthercatCTN class in EthercatMaster.py
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2802
        """
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2803
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2804
        wx.Panel.__init__(self, parent, -1, size=wx.Size(750, 350))
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2805
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2806
        self.Controler=controler
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2807
        
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2808
        self.Tree = wx.gizmos.TreeListCtrl(self, -1, size=wx.Size(750,350), 
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2809
                                                            style=wx.TR_HAS_BUTTONS
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2810
                                                            |wx.TR_HIDE_ROOT
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2811
                                                            |wx.TR_ROW_LINES
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2812
                                                            |wx.TR_COLUMN_LINES
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2813
                                                            |wx.TR_FULL_ROW_HIGHLIGHT)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2814
        for label, width in [
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2815
                ("name",        400),
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2816
                ("position",    100),
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2817
                ("state",       100),
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2818
                ("error",       100)]:
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2819
            self.Tree.AddColumn(label, width=width)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2820
        
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2821
        self.Tree.SetMainColumn(0)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2822
        
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2823
    def UpdateSI(self):
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2824
        """
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2825
        Update the data of the slave information.
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2826
        """
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2827
        position, not_used, state, not_used, name = range(5)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2828
        
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2829
        slave_node = []
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2830
        slave_info_list = []
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2831
        error_counter= []
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2832
        
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2833
        # get slave informations (name, position, state)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2834
        slaves_infos = self.Controler.CommonMethod.GetSlaveStateFromSlave()
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2835
        slave_info_lines = slaves_infos.splitlines()
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2836
        
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2837
        for line in slave_info_lines:
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2838
            slave_info_list.append(line.split(None,4))
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2839
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2840
        slave_num = len(slave_info_lines)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2841
        
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2842
        reg_info = []
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2843
        for ec in self.EC_Addrs:
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2844
            reg_info.append(ec + ",0x001")
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2845
        
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2846
        # get error counts of slaves
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2847
        err_count_list = self.Controler.CommonMethod.MultiRegRead(slave_num, reg_info)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2848
                
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2849
        self.Tree.DeleteAllItems()
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2850
        
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2851
        root = self.Tree.AddRoot("") 
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2852
        ec_list_idx = 0
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2853
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2854
        for slave_idx in range(slave_num):
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2855
            slave_node = self.Tree.AppendItem(root, "")
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2856
            
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2857
            # set name, postion, state 
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2858
            col_num = 0 
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2859
            for info_idx in [name, position, state]:
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2860
                self.Tree.SetItemText(slave_node, 
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2861
                                      slave_info_list[slave_idx][info_idx], col_num)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2862
                col_num += 1
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2863
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2864
            error_counter = {}
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2865
            ec_idx = 0
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2866
            
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2867
            # set error counter's name and default value 
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2868
            for ec, sub_ecs in [("Port Error Counters 0/1/2/3",[
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2869
                                    "Invaild Frame Counter 0/1/2/3",
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2870
                                    "RX Error Counter 0/1/2/3"]),
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2871
                                ("Forward RX Error Counter 0/1/2/3", []),       
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2872
                                ("ECAT Processing Unit Error Counter", []),
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2873
                                ("PDI Error Counter", []),
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2874
                                ("Lost Link Counter 0/1/2/3", []),
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2875
                                ("Watchdog Counter Process Data", []),
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2876
                                ("Watchdog Counter PDI", [])]:
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2877
                ec_sub_idx = 0
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2878
                ec_name = ec
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2879
                tree_node = self.Tree.AppendItem(slave_node, "%s" % ec)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2880
                
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2881
                if ec_name.find("0/1/2/3") > 0:
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2882
                    num_ports = 4
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2883
                    err_count = [0, 0, 0, 0]
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2884
                else:
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2885
                    num_ports = 1
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2886
                    err_count = [0]
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2887
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2888
                error_counter[(ec_idx, ec_sub_idx)] = {
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2889
                        "name": ec_name,
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2890
                        "tree_node": tree_node,
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2891
                        "num_ports": num_ports,
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2892
                        "err_count": err_count}
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2893
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2894
                for sub_ec in sub_ecs:
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2895
                    ec_sub_idx += 1
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2896
                    ec_name = sub_ec
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2897
                    tree_node = self.Tree.AppendItem(\
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2898
                        error_counter[(ec_idx, 0)]["tree_node"], 
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2899
                            "%s" % sub_ec)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2900
                    
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2901
                    if ec_name.find("0/1/2/3") > 0:
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2902
                        num_ports = 4
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2903
                        err_count = [0, 0, 0, 0]
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2904
                    else:
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2905
                        num_ports = 1
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2906
                        err_count = [0]
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2907
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2908
                    error_counter[(ec_idx, ec_sub_idx)] = {
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2909
                            "name": ec_name,
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2910
                            "tree_node": tree_node, 
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2911
                            "num_ports": num_ports,
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2912
                            "err_count": err_count}
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2913
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2914
                    for port_num in range(num_ports):
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2915
                        try:
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2916
                            error_counter[(ec_idx, ec_sub_idx)]["err_count"][port_num] += \
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2917
                                    int(err_count_list[ec_list_idx].split(",")[2], 16)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2918
                        except:
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2919
                            error_counter[(ec_idx, ec_sub_idx)]["err_count"][port_num] = -1
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2920
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2921
                        ec_list_idx += 1
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2922
                
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2923
                if ec_sub_idx > 0:
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2924
                    for port_num in range(num_ports):
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2925
                        err_sum = 0
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2926
                        for sub_idx in range(1, ec_sub_idx+1):
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2927
                            err_sum += error_counter[(ec_idx, sub_idx)]\
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2928
                                                ["err_count"][port_num]
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2929
                        error_counter[(ec_idx, 0)]["err_count"][port_num] = err_sum
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2930
                        
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2931
                else:
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2932
                    for port_num in range(num_ports):
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2933
                        try:
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2934
                            error_counter[(ec_idx, ec_sub_idx)]["err_count"][port_num] += \
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2935
                                    int(err_count_list[ec_list_idx].split(",")[2], 16)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2936
                        except:
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2937
                            error_counter[(ec_idx, ec_sub_idx)]["err_count"][port_num] = -1
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2938
                        ec_list_idx += 1
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2939
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2940
                ec_idx += 1
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2941
            
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2942
            # set texts in "error" column. 
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2943
            ec_info_list = error_counter.items()
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2944
            ec_info_list.sort()
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2945
            
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2946
            err_checker = "none"
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2947
           
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2948
            for (idx, sub_idx), ec_info in ec_info_list:
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2949
                ec_text = ""
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2950
                for port_num in range(ec_info["num_ports"]):
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2951
                    if ec_info["err_count"][port_num] != 0:
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2952
                        err_checker = "occurred"
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2953
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2954
                    if ec_info["err_count"][port_num] < 0:
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2955
                        ec_text = "reg I/O error"
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2956
                    else:
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2957
                        ec_text = ec_text + "%d/" % ec_info["err_count"][port_num]
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2958
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2959
                ec_text = ec_text.strip("/")
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2960
                
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2961
                self.Tree.SetItemText(ec_info["tree_node"], ec_text, col_num)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2962
            
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2963
            self.Tree.SetItemText(slave_node, err_checker, col_num)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2964
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2965
class DCConfigPanel(wx.Panel):
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2966
    def __init__(self, parent, controler):
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2967
        """
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2968
        Constructor
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2969
        @param parent: Reference to the MasterStatePanel class
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2970
        @param Controler: _EthercatCTN class in EthercatMaster.py
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2971
        """
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2972
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2973
        wx.Panel.__init__(self, parent, -1, size=wx.Size(750, 350))
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2974
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2975
        self.Controler = controler
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2976
        self.parent = parent
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2977
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2978
        self.ESI_DC_Data = self.Controler.CommonMethod.LoadESIData()
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2979
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2980
        # initialize SlaveStatePanel UI dictionaries
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2981
        self.StaticBoxDic = {}
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2982
        self.StaticTextDic = {}
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2983
        self.TextCtrlDic = {}
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2984
        self.ComboBoxDic = {}
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2985
        self.CheckBoxDic = {}
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2986
        self.RadioButtonDic = {}
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2987
        OperationModeComboList = []
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2988
        Sync1CycleComboList = []
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2989
        
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2990
        for ESI_Data in self.ESI_DC_Data:
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2991
            OperationModeComboList.append(ESI_Data["desc"])
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2992
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2993
        UnitComboList = [ "/100", "/ 50", "/ 40", "/ 30", "/ 25", "/ 20", "/16",
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2994
            "/ 10", "/ 8", "/ 5", "/ 4", "/ 3", "/ 2", "x 1", "x 2", "x 3", "x 4", 
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2995
            "x 5", "x 8", "x 10", "x 16", "x 20", "x 25", "x 30", "x 40", "x 50", 
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2996
            "x 100"
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2997
        ]
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2998
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  2999
        UnitComboListPlus = [ "/100", "/ 50", "/ 40", "/ 30", "/ 25", "/ 20", "/16",
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3000
            "/ 10", "/ 8", "/ 5", "/ 4", "/ 3", "/ 2", "x 0", "x 1", "x 2", "x 3", 
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3001
            "x 4", "x 5", "x 8", "x 10", "x 16", "x 20", "x 25", "x 30", "x 40", 
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3002
            "x 50", "x 100"
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3003
        ]
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3004
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3005
        for i in range(1024):
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3006
            Sync1CycleComboList.append("x " + str(i + 1))
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3007
        
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3008
        # iniitalize BoxSizer and FlexGridSizer
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3009
        self.SizerDic = {
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3010
            "DCConfig_main_sizer" : wx.BoxSizer(wx.VERTICAL),
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3011
            "DCConfig_inner_main_sizer" : wx.FlexGridSizer(cols=1, hgap=50, rows=2, vgap=10),
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3012
            "CyclicMode_InnerSizer" : wx.FlexGridSizer(cols=1, hgap=5, rows=2, vgap=5),
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3013
            "SyncMode_InnerSizer" : wx.FlexGridSizer(cols=2, hgap=5, rows=1, vgap=5),
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3014
            "OperationMode_InnerSizer" : wx.FlexGridSizer(cols=2, hgap=100, rows=2, vgap=10),
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3015
            "CheckEnable_InnerSizer" : wx.FlexGridSizer(cols=2, hgap=10, rows=1, vgap=10),
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3016
            "Sync0_InnerSizer" : wx.FlexGridSizer(cols=1, hgap=15, rows=3, vgap=10),
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3017
            "Sync0_CycleTimeSizer" : wx.FlexGridSizer(cols=2, hgap=10, rows=2, vgap=5),
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3018
            "Sync0_ShiftTimeSizer" : wx.FlexGridSizer(cols=2, hgap=20, rows=2, vgap=5),
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3019
            "Sync1_InnerSizer" : wx.FlexGridSizer(cols=1, hgap=15, rows=3, vgap=10),
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3020
            "Sync1_CycleTimeSizer" : wx.FlexGridSizer(cols=2, hgap=10, rows=2, vgap=5),
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3021
            "Sync1_ShiftTimeSizer" : wx.FlexGridSizer(cols=2, hgap=20, rows=2, vgap=5)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3022
        }
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3023
        
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3024
        # initialize StaticBox and StaticBoxSizer
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3025
        for box_name, box_label in [
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3026
                ("CyclicModeBox", "Cyclic Mode"),
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3027
                ("Sync0Box", "Sync0"),
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3028
                ("Sync0CycleTimeBox", "Cycle Time (us):"),
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3029
                ("Sync0ShiftTimeBox", "Shift Time (us):"),
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3030
                ("Sync1Box", "Sync1"),
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3031
                ("Sync1CycleTimeBox", "Cycle Time (us):"),
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3032
                ("Sync1ShiftTimeBox", "Shift Time (us):")
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3033
            ]:
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3034
            self.StaticBoxDic[box_name] = wx.StaticBox(self, label=_(box_label))
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3035
            self.SizerDic[box_name] = wx.StaticBoxSizer(self.StaticBoxDic[box_name])  
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3036
        
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3037
        for statictext_name, statictext_label in [
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3038
                ("MainLabel", "Distributed Clock"),
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3039
                ("OperationModeLabel", "Operation Mode:"),
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3040
                ("SyncUnitCycleLabel", "Sync Unit Cycle (us)"),
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3041
                ("Sync0ShiftTimeUserDefinedLabel", "User Defined"),
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3042
                ("Sync1ShiftTimeUserDefinedLabel", "User Defined"),
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3043
                ("BlankObject", ""),
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3044
                ("BlankObject1", "")
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3045
            ]:
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3046
            self.StaticTextDic[statictext_name] = wx.StaticText(self, label=_(statictext_label))
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3047
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3048
        for textctl_name in [
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3049
                ("SyncUnitCycle_Ctl"),
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3050
                ("Sync0CycleTimeUserDefined_Ctl"),
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3051
                ("Sync0ShiftTimeUserDefined_Ctl"),
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3052
                ("Sync1CycleTimeUserDefined_Ctl"),
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3053
                ("Sync1ShiftTimeUserDefined_Ctl"),
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3054
            ]:
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3055
            self.TextCtrlDic[textctl_name] = wx.TextCtrl(
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3056
                self, size=wx.Size(130, 24), style=wx.TE_READONLY)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3057
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3058
        for checkbox_name, checkbox_label in [
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3059
                ("DCEnable", "Enable"),
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3060
                ("Sync0Enable", "Enable Sync0"),
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3061
                ("Sync1Enable", "Enable Sync1")
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3062
            ]:
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3063
            self.CheckBoxDic[checkbox_name] = wx.CheckBox(self, -1, checkbox_label)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3064
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3065
        for combobox_name, combobox_list, size in [
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3066
                ("OperationModeChoice", OperationModeComboList, 250),
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3067
                ("Sync0UnitCycleChoice", UnitComboList, 130),
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3068
                ("Sync1UnitCycleChoice", UnitComboList, 130)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3069
            ]:
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3070
            self.ComboBoxDic[combobox_name] = wx.ComboBox(self, size=wx.Size(size, 24), 
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3071
                choices = combobox_list, style = wx.CB_DROPDOWN | wx.CB_READONLY)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3072
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3073
        for radiobutton_name, radiobutton_label in [
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3074
                ("Sync0CycleTimeUnitRadioButton", "Sync Unit Cycle"),
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3075
                ("Sync0CycleTimeUserDefinedRadioButton", "User Defined"),
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3076
                ("Sync1CycleTimeUnitRadioButton", "Sync Unit Cycle"),
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3077
                ("Sync1CycleTimeUserDefinedRadioButton", "User Defined")
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3078
            ]:
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3079
            self.RadioButtonDic[radiobutton_name] = wx.RadioButton(
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3080
                self, label = radiobutton_label, style = wx.RB_SINGLE)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3081
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3082
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3083
        self.ApplyButton = wx.Button(self, label="Apply")
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3084
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3085
        # binding event
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3086
        self.Bind(wx.EVT_CHECKBOX, self.CheckDCEnable, self.CheckBoxDic["DCEnable"])
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3087
        #self.Bind(wx.EVT_COMBOBOX, self.SelectOperationMode, self.ComboBoxDic["OperationModeChoice"])
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3088
        #self.Bind(wx.EVT_COMBOBOX, self.SelectUnitCycle, self.ComboBoxDic["Sync0UnitChoice"])
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3089
        self.Bind(wx.EVT_RADIOBUTTON, self.SelectSync0CycleTime, 
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3090
            self.RadioButtonDic["Sync0CycleTimeUnitRadioButton"])
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3091
        self.Bind(wx.EVT_RADIOBUTTON, self.SelectSync0CycleTime, 
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3092
            self.RadioButtonDic["Sync0CycleTimeUserDefinedRadioButton"])
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3093
        self.Bind(wx.EVT_RADIOBUTTON, self.SelectSync1CycleTime, 
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3094
            self.RadioButtonDic["Sync1CycleTimeUnitRadioButton"])
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3095
        self.Bind(wx.EVT_RADIOBUTTON, self.SelectSync1CycleTime, 
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3096
            self.RadioButtonDic["Sync1CycleTimeUserDefinedRadioButton"])
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3097
        self.Bind(wx.EVT_CHECKBOX, self.CheckSync0Enable, self.CheckBoxDic["Sync0Enable"])
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3098
        self.Bind(wx.EVT_CHECKBOX, self.CheckSync1Enable, self.CheckBoxDic["Sync1Enable"])
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3099
        self.Bind(wx.EVT_BUTTON, self.OnClickApplyButton, self.ApplyButton)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3100
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3101
        # sync1 shifttime box contents
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3102
        self.SizerDic["Sync1_ShiftTimeSizer"].AddMany([
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3103
            self.StaticTextDic["Sync1ShiftTimeUserDefinedLabel"],
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3104
            self.TextCtrlDic["Sync1ShiftTimeUserDefined_Ctl"]
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3105
        ])
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3106
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3107
        # sync1 shifttime box
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3108
        self.SizerDic["Sync1ShiftTimeBox"].Add(self.SizerDic["Sync1_ShiftTimeSizer"])
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3109
        
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3110
        # sync1 cycletime box contents
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3111
        self.SizerDic["Sync1_CycleTimeSizer"].AddMany([
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3112
            self.RadioButtonDic["Sync1CycleTimeUnitRadioButton"], 
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3113
            self.ComboBoxDic["Sync1UnitCycleChoice"],
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3114
            self.RadioButtonDic["Sync1CycleTimeUserDefinedRadioButton"],
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3115
            self.TextCtrlDic["Sync1CycleTimeUserDefined_Ctl"]
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3116
        ])
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3117
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3118
        # sync0 cycletime box
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3119
        self.SizerDic["Sync1CycleTimeBox"].Add(self.SizerDic["Sync1_CycleTimeSizer"])
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3120
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3121
        self.SizerDic["Sync1_InnerSizer"].AddMany([
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3122
            self.CheckBoxDic["Sync1Enable"], self.SizerDic["Sync1CycleTimeBox"], 
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3123
            self.SizerDic["Sync1ShiftTimeBox"]
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3124
        ])
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3125
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3126
        # sync1 box
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3127
        self.SizerDic["Sync1Box"].Add(self.SizerDic["Sync1_InnerSizer"])
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3128
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3129
        # sync0 shifttime box contents
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3130
        self.SizerDic["Sync0_ShiftTimeSizer"].AddMany([
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3131
            self.StaticTextDic["Sync0ShiftTimeUserDefinedLabel"],
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3132
            self.TextCtrlDic["Sync0ShiftTimeUserDefined_Ctl"]
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3133
        ])
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3134
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3135
        # sync0 shifttime box
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3136
        self.SizerDic["Sync0ShiftTimeBox"].Add(self.SizerDic["Sync0_ShiftTimeSizer"])
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3137
        
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3138
        # sync0 cycletime box contents
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3139
        self.SizerDic["Sync0_CycleTimeSizer"].AddMany([
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3140
            self.RadioButtonDic["Sync0CycleTimeUnitRadioButton"], 
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3141
            self.ComboBoxDic["Sync0UnitCycleChoice"],
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3142
            self.RadioButtonDic["Sync0CycleTimeUserDefinedRadioButton"],
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3143
            self.TextCtrlDic["Sync0CycleTimeUserDefined_Ctl"]
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3144
        ])
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3145
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3146
        # sync0 cycletime box
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3147
        self.SizerDic["Sync0CycleTimeBox"].Add(self.SizerDic["Sync0_CycleTimeSizer"])
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3148
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3149
        self.SizerDic["Sync0_InnerSizer"].AddMany([
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3150
            self.CheckBoxDic["Sync0Enable"], self.SizerDic["Sync0CycleTimeBox"], 
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3151
            self.SizerDic["Sync0ShiftTimeBox"]
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3152
        ])
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3153
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3154
        # sync0 box
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3155
        self.SizerDic["Sync0Box"].Add(self.SizerDic["Sync0_InnerSizer"])
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3156
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3157
        # sync0, sync1 box
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3158
        self.SizerDic["SyncMode_InnerSizer"].AddMany([
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3159
            self.SizerDic["Sync0Box"], self.SizerDic["Sync1Box"]
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3160
        ])
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3161
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3162
        # CyclicMode Box
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3163
        self.SizerDic["CheckEnable_InnerSizer"].AddMany([
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3164
            self.StaticTextDic["SyncUnitCycleLabel"], 
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3165
            self.TextCtrlDic["SyncUnitCycle_Ctl"]
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3166
        ])
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3167
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3168
        self.SizerDic["OperationMode_InnerSizer"].AddMany([
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3169
            self.StaticTextDic["OperationModeLabel"], 
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3170
            self.ComboBoxDic["OperationModeChoice"],
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3171
            self.CheckBoxDic["DCEnable"], self.SizerDic["CheckEnable_InnerSizer"]
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3172
        ])
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3173
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3174
        self.SizerDic["CyclicMode_InnerSizer"].AddMany([
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3175
            self.SizerDic["OperationMode_InnerSizer"], 
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3176
            self.SizerDic["SyncMode_InnerSizer"]
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3177
        ])
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3178
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3179
        self.SizerDic["CyclicModeBox"].Add(self.SizerDic["CyclicMode_InnerSizer"])
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3180
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3181
        # Main Sizer
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3182
        self.SizerDic["DCConfig_inner_main_sizer"].AddMany([
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3183
            self.StaticTextDic["MainLabel"], self.ApplyButton,
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3184
            self.SizerDic["CyclicModeBox"]
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3185
        ])
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3186
        
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3187
        self.SizerDic["DCConfig_main_sizer"].Add(self.SizerDic["DCConfig_inner_main_sizer"])
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3188
        
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3189
        self.SetSizer(self.SizerDic["DCConfig_main_sizer"])
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3190
        
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3191
        self.Centre()
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3192
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3193
        self.UIOnOffSet(False)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3194
        self.LoadProjectDCData()
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3195
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3196
    def UIOnOffSet(self, activate):
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3197
        if activate :
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3198
            for object in self.RadioButtonDic:
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3199
                self.RadioButtonDic[object].Enable()
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3200
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3201
            for object in self.ComboBoxDic:
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3202
                if object == "OperationModeChoice":
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3203
                    continue
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3204
                self.ComboBoxDic[object].Enable()
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3205
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3206
            for object in self.TextCtrlDic:
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3207
                if object in ["SyncUnitCycle_Ctl", "InputReference_Ctl"]:
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3208
                    continue
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3209
                self.TextCtrlDic[object].Enable()
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3210
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3211
            for object in self.CheckBoxDic:
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3212
                if object == "DCEnable":
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3213
                    continue
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3214
                self.CheckBoxDic[object].Enable()
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3215
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3216
        # initial set or DC enable uncheck
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3217
        else :
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3218
            for object in self.RadioButtonDic:
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3219
                self.RadioButtonDic[object].Disable()
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3220
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3221
            for object in self.ComboBoxDic:
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3222
                if object == "OperationModeChoice":
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3223
                    continue
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3224
                self.ComboBoxDic[object].Disable()
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3225
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3226
            for object in self.TextCtrlDic:
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3227
                if object == "SyncUnitCycle_Ctl":
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3228
                    continue
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3229
                self.TextCtrlDic[object].Disable()
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3230
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3231
            for object in self.CheckBoxDic:
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3232
                if object == "DCEnable":
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3233
                    continue
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3234
                self.CheckBoxDic[object].Disable()
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3235
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3236
            for data in self.ESI_DC_Data:
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3237
                index = self.Controler.ExtractHexDecValue(data["assign_activate"])
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3238
                if index == 0:
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3239
                    config_name = data["desc"]
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3240
                    self.ComboBoxDic["OperationModeChoice"].SetStringSelection(config_name)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3241
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3242
    def CheckSync0Enable(self, evt):
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3243
        if evt.GetInt():
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3244
            self.ComboBoxDic["Sync0UnitCycleChoice"].Enable()
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3245
            self.RadioButtonDic["Sync0CycleTimeUnitRadioButton"].Enable()
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3246
            self.RadioButtonDic["Sync0CycleTimeUserDefinedRadioButton"].Enable()
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3247
            self.TextCtrlDic["Sync0CycleTimeUserDefined_Ctl"].Enable()
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3248
            self.TextCtrlDic["Sync0ShiftTimeUserDefined_Ctl"].Enable()
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3249
        else :
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3250
            self.ComboBoxDic["Sync0UnitCycleChoice"].Disable()
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3251
            self.RadioButtonDic["Sync0CycleTimeUnitRadioButton"].Disable()
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3252
            self.RadioButtonDic["Sync0CycleTimeUserDefinedRadioButton"].Disable()
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3253
            self.TextCtrlDic["Sync0CycleTimeUserDefined_Ctl"].Disable()
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3254
            self.TextCtrlDic["Sync0ShiftTimeUserDefined_Ctl"].Disable()
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3255
            self.RadioButtonDic["Sync0CycleTimeUnitRadioButton"].SetValue(False)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3256
            self.RadioButtonDic["Sync0CycleTimeUserDefinedRadioButton"].SetValue(False)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3257
            self.TextCtrlDic["Sync0CycleTimeUserDefined_Ctl"].SetValue("")
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3258
            self.TextCtrlDic["Sync0ShiftTimeUserDefined_Ctl"].SetValue("")
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3259
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3260
    def CheckSync1Enable(self, evt):
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3261
        if evt.GetInt():
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3262
            self.ComboBoxDic["Sync1UnitCycleChoice"].Enable()
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3263
            self.RadioButtonDic["Sync1CycleTimeUnitRadioButton"].Enable()
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3264
            self.RadioButtonDic["Sync1CycleTimeUserDefinedRadioButton"].Enable()
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3265
            self.TextCtrlDic["Sync1CycleTimeUserDefined_Ctl"].Enable()
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3266
            self.TextCtrlDic["Sync1ShiftTimeUserDefined_Ctl"].Enable()
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3267
        else :
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3268
            self.ComboBoxDic["Sync1UnitCycleChoice"].Disable()
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3269
            self.RadioButtonDic["Sync1CycleTimeUnitRadioButton"].Disable()
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3270
            self.RadioButtonDic["Sync1CycleTimeUserDefinedRadioButton"].Disable()
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3271
            self.TextCtrlDic["Sync1CycleTimeUserDefined_Ctl"].Disable()
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3272
            self.TextCtrlDic["Sync1ShiftTimeUserDefined_Ctl"].Disable()
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3273
            self.RadioButtonDic["Sync1CycleTimeUnitRadioButton"].SetValue(False)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3274
            self.RadioButtonDic["Sync1CycleTimeUserDefinedRadioButton"].SetValue(False)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3275
            self.TextCtrlDic["Sync1CycleTimeUserDefined_Ctl"].SetValue("")
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3276
            self.TextCtrlDic["Sync1ShiftTimeUserDefined_Ctl"].SetValue("")
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3277
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3278
    def CheckDCEnable(self, evt):
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3279
        ns_mode = 1
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3280
        task_cycle_ns = self.GetInterval(ns_mode)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3281
        sync0_cycle_factor = None
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3282
        sync1_cycle_factor = None
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3283
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3284
        #task_cycle_ns = self.Controler.GetCTRoot()._Ticktime
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3285
        if (task_cycle_ns > 0):
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3286
            self.UIOnOffSet(evt.GetInt())
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3287
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3288
            if evt.GetInt():
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3289
                # default select DC enable sync0
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3290
                default_list_num = 0
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3291
                config_name = self.ESI_DC_Data[default_list_num]["desc"]
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3292
                assign_act = self.ESI_DC_Data[default_list_num]["assign_activate"]
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3293
                sync0_cycle_time_ns = self.ESI_DC_Data[default_list_num]["cycletime_sync0"]
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3294
                if sync0_cycle_time_ns == 0 :
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3295
                    sync0_cycle_factor = self.ESI_DC_Data[default_list_num]["cycletime_sync0_factor"]
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3296
                sync0_shift_time_ns = self.ESI_DC_Data[default_list_num]["shifttime_sync0"]
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3297
                sync1_cycle_time_ns = self.ESI_DC_Data[default_list_num]["cycletime_sync1"]
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3298
                if sync1_cycle_time_ns == 0 :
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3299
                    sync1_cycle_factor = self.ESI_DC_Data[default_list_num]["cycletime_sync1_factor"]
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3300
                sync1_shift_time_ns = self.ESI_DC_Data[default_list_num]["shifttime_sync1"]
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3301
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3302
                cal_assign_act = self.Controler.ExtractHexDecValue(assign_act)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3303
                sync0_cycle_time_us = str(int(sync0_cycle_time_ns) / 1000)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3304
                sync0_shift_time_us = str(int(sync0_shift_time_ns) / 1000)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3305
                sync1_cycle_time_us = str(int(sync1_cycle_time_ns) / 1000)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3306
                sync1_shift_time_us = str(int(sync1_shift_time_ns) / 1000)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3307
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3308
                task_cycle_to_us = str(int(task_cycle_ns) / 1000)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3309
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3310
                # DC sync0 mode
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3311
                if cal_assign_act == 768:
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3312
                    # Disable About Sync1 Objects
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3313
                    self.CheckBoxDic["Sync1Enable"].SetValue(False)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3314
                    self.RadioButtonDic["Sync1CycleTimeUnitRadioButton"].Disable()
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3315
                    self.ComboBoxDic["Sync1UnitCycleChoice"].Disable()
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3316
                    self.RadioButtonDic["Sync1CycleTimeUserDefinedRadioButton"].Disable()
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3317
                    self.TextCtrlDic["Sync1CycleTimeUserDefined_Ctl"].Disable()
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3318
                    self.TextCtrlDic["Sync1ShiftTimeUserDefined_Ctl"].Disable()
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3319
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3320
                else :
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3321
                    self.CheckBoxDic["Sync1Enable"].SetValue(True)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3322
                    if sync1_cycle_factor is not None:
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3323
                        self.RadioButtonDic["Sync1CycleTimeUnitRadioButton"].SetValue(True)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3324
                        self.RadioButtonDic["Sync1CycleTimeUserDefinedRadioButton"].SetValue(False)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3325
                        self.TextCtrlDic["Sync1CycleTimeUserDefined_Ctl"].Disable()
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3326
                        self.SetSyncUnitCycle(sync1_cycle_factor, 
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3327
                            self.ComboBoxDic["Sync1UnitCycleChoice"])
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3328
                    else :
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3329
                        self.RadioButtonDic["Sync1CycleTimeUnitRadioButton"].SetValue(False)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3330
                        self.RadioButtonDic["Sync1CycleTimeUserDefinedRadioButton"].SetValue(True)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3331
                        self.ComboBoxDic["Sync1UnitCycleChoice"].Disable()
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3332
                        self.TextCtrlDic["Sync1CycleTimeUserDefined_Ctl"].SetValue(sync1_cycle_time_us)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3333
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3334
                    self.TextCtrlDic["Sync1ShiftTimeUserDefined_Ctl"].SetValue(sync1_shift_time_us)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3335
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3336
                # Set Sync0 Objects
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3337
                self.CheckBoxDic["Sync0Enable"].SetValue(True)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3338
                if sync0_cycle_factor is not None:
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3339
                    self.RadioButtonDic["Sync0CycleTimeUnitRadioButton"].SetValue(True)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3340
                    self.RadioButtonDic["Sync0CycleTimeUserDefinedRadioButton"].SetValue(False)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3341
                    self.TextCtrlDic["Sync0CycleTimeUserDefined_Ctl"].Disable()
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3342
                    self.SetSyncUnitCycle(sync0_cycle_factor, 
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3343
                        self.ComboBoxDic["Sync0UnitCycleChoice"])
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3344
                else :
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3345
                    self.RadioButtonDic["Sync0CycleTimeUnitRadioButton"].SetValue(False)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3346
                    self.RadioButtonDic["Sync0CycleTimeUserDefinedRadioButton"].SetValue(True)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3347
                    self.ComboBoxDic["Sync0UnitCycleChoice"].Disable()
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3348
                    self.TextCtrlDic["Sync0CycleTimeUserDefined_Ctl"].SetValue(sync0_cycle_time_us)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3349
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3350
                self.TextCtrlDic["Sync0ShiftTimeUserDefined_Ctl"].SetValue(sync0_shift_time_us)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3351
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3352
                self.ComboBoxDic["OperationModeChoice"].SetStringSelection(config_name)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3353
                self.TextCtrlDic["SyncUnitCycle_Ctl"].SetValue(task_cycle_to_us)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3354
            else :
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3355
                self.CheckBoxDic["Sync0Enable"].SetValue(False)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3356
                self.CheckBoxDic["Sync1Enable"].SetValue(False)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3357
                self.RadioButtonDic["Sync0CycleTimeUnitRadioButton"].SetValue(False)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3358
                self.RadioButtonDic["Sync0CycleTimeUserDefinedRadioButton"].SetValue(False)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3359
                self.RadioButtonDic["Sync1CycleTimeUnitRadioButton"].SetValue(False)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3360
                self.RadioButtonDic["Sync1CycleTimeUserDefinedRadioButton"].SetValue(False)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3361
                self.TextCtrlDic["Sync0CycleTimeUserDefined_Ctl"].SetValue("")
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3362
                self.TextCtrlDic["Sync0ShiftTimeUserDefined_Ctl"].SetValue("")
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3363
                self.TextCtrlDic["Sync1CycleTimeUserDefined_Ctl"].SetValue("")
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3364
                self.TextCtrlDic["Sync1ShiftTimeUserDefined_Ctl"].SetValue("")
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3365
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3366
        else :
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3367
            self.UIOnOffSet(False)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3368
            #error_str = "DC Enable is not possble, please set task interval"
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3369
            error_str = "Can't Set DC Enable"
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3370
            self.Controler.CommonMethod.CreateErrorDialog(error_str)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3371
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3372
    def SetSyncUnitCycle(self, factor, object):
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3373
        # factor > 0 ==> * factor, factor < 0 ==> / factor
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3374
        factor_to_int = int(factor)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3375
        if factor_to_int > 0:
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3376
            lists = object.GetStrings()
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3377
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3378
            for token in lists:
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3379
                temp = token.split(" ")
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3380
                if (temp[0] == "x") and (int(temp[1]) == factor_to_int):
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3381
                    object.SetStringSelection(token)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3382
                    return True
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3383
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3384
        else : 
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3385
            lists = object.GetStrings()
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3386
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3387
            for token in lists:
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3388
                temp = token.split(" ")
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3389
                if (temp[0] == "/") and (int(temp[1]) == factor_to_int):
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3390
                    object.SetStringSelection(token)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3391
                    return True
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3392
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3393
        return False
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3394
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3395
    def GetInterval(self, mode):
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3396
        project_infos = self.Controler.GetCTRoot().GetProjectInfos()
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3397
        for project_info_list in project_infos["values"]:
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3398
            if project_info_list["name"] == "Resources" :
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3399
                token = project_info_list["values"][0]["tagname"]
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3400
       
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3401
        tasks, instances = self.Controler.GetCTRoot().GetEditedResourceInfos(token)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3402
        try:
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3403
            task_cycle_ns = self.ParseTime(tasks[0]["Interval"])
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3404
        except :
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3405
            task_cycle_ns = 0
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3406
        task_cycle_us = int(task_cycle_ns) / 1000
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3407
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3408
        # mode == 1 ==> return ns
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3409
        # mode == 2 ==> return us
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3410
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3411
        if mode == 1:
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3412
            return task_cycle_ns
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3413
        if mode == 2:
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3414
            return str(task_cycle_us)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3415
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3416
    def ParseTime(self, input):
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3417
        # input example : 't#1ms'
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3418
        # temp.split('#') -> ['t', '1ms']
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3419
        temp = input.split('#')
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3420
         
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3421
        # temp[1] : '1ms'
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3422
        # temp[-2:] : 'ms'
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3423
        # temp[:-2] : '1'
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3424
        if temp[1][-2:] == "ms":
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3425
           # convert nanosecond unit
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3426
           result = int(temp[1][:-2]) * 1000000
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3427
        elif temp[1][-2:] == "us":
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3428
           result = int(temp[1][:-2]) * 1000
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3429
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3430
        return str(result)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3431
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3432
    def SelectSync0CycleTime(self, evt):
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3433
        selected_object = evt.GetEventObject()
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3434
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3435
        if selected_object.GetLabel() == "User Defined" :
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3436
            self.RadioButtonDic["Sync0CycleTimeUnitRadioButton"].SetValue(False)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3437
            self.TextCtrlDic["Sync0CycleTimeUserDefined_Ctl"].Enable()
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3438
            self.ComboBoxDic["Sync0UnitCycleChoice"].Disable()
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3439
        elif selected_object.GetLabel() == "Sync Unit Cycle" :
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3440
            self.RadioButtonDic["Sync0CycleTimeUserDefinedRadioButton"].SetValue(False)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3441
            self.ComboBoxDic["Sync0UnitCycleChoice"].Enable()
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3442
            self.TextCtrlDic["Sync0CycleTimeUserDefined_Ctl"].Disable()
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3443
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3444
    def SelectSync1CycleTime(self, evt):
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3445
        selected_object = evt.GetEventObject()
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3446
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3447
        if selected_object.GetLabel() == "User Defined" :
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3448
            self.RadioButtonDic["Sync1CycleTimeUnitRadioButton"].SetValue(False)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3449
            self.TextCtrlDic["Sync1CycleTimeUserDefined_Ctl"].Enable()
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3450
            self.ComboBoxDic["Sync1UnitCycleChoice"].Disable()
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3451
        elif selected_object.GetLabel() == "Sync Unit Cycle" :
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3452
            self.RadioButtonDic["Sync1CycleTimeUserDefinedRadioButton"].SetValue(False)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3453
            self.ComboBoxDic["Sync1UnitCycleChoice"].Enable()
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3454
            self.TextCtrlDic["Sync1CycleTimeUserDefined_Ctl"].Disable()
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3455
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3456
    def GetCycle(self, period, section):
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3457
        temp = section.split(" ")
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3458
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3459
        if temp[0] == "x":
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3460
            result = int(period) * int(temp[1])
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3461
        elif temp[0] == "/" :
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3462
            result = int(period) / int(temp[1])
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3463
        else :
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3464
            result = ""
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3465
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3466
        return result
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3467
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3468
    def OnClickApplyButton(self, evt):
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3469
        us_mode = 2
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3470
        dc_enable = self.CheckBoxDic["DCEnable"].GetValue()
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3471
        dc_desc = self.ComboBoxDic["OperationModeChoice"].GetStringSelection()
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3472
        dc_assign_activate = self.ESI_DC_Data[0]["assign_activate"]
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3473
        dc_assign_activate_mod = dc_assign_activate.split('x')[1]
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3474
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3475
        if self.RadioButtonDic["Sync0CycleTimeUnitRadioButton"].GetValue():
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3476
            temp = self.ComboBoxDic["Sync0UnitCycleChoice"].GetStringSelection()
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3477
            dc_sync0_cycle = "1_" + str(self.GetCycle(self.GetInterval(us_mode), temp))
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3478
        elif  self.RadioButtonDic["Sync0CycleTimeUserDefinedRadioButton"].GetValue():
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3479
            dc_sync0_cycle = "2_" + self.TextCtrlDic["Sync0CycleTimeUserDefined_Ctl"].GetValue()
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3480
        else :
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3481
            dc_sync0_cycle = ""
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3482
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3483
        if self.RadioButtonDic["Sync1CycleTimeUnitRadioButton"].GetValue():
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3484
            temp = self.ComboBoxDic["Sync1UnitCycleChoice"].GetStringSelection()
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3485
            dc_sync1_cycle = "1_" + self.GetCycle(self.GetInterval(us_mode), temp)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3486
        elif  self.RadioButtonDic["Sync1CycleTimeUserDefinedRadioButton"].GetValue():
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3487
            dc_sync1_cycle = "2_" + self.TextCtrlDic["Sync1CycleTimeUserDefined_Ctl"].GetValue()
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3488
        else :
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3489
            dc_sync1_cycle = ""
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3490
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3491
        dc_sync0_shift = self.TextCtrlDic["Sync0ShiftTimeUserDefined_Ctl"].GetValue()
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3492
        dc_sync1_shift = self.TextCtrlDic["Sync1ShiftTimeUserDefined_Ctl"].GetValue()
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3493
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3494
        self.Controler.BaseParams.setDC_Enable(dc_enable)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3495
        self.Controler.BaseParams.setDC_Desc(dc_desc)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3496
        self.Controler.BaseParams.setDC_Assign_Activate(dc_assign_activate_mod)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3497
        if dc_sync0_cycle:
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3498
            self.Controler.BaseParams.setDC_Sync0_Cycle_Time(dc_sync0_cycle)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3499
        if dc_sync0_shift:
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3500
            self.Controler.BaseParams.setDC_Sync0_Shift_Time(dc_sync0_shift)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3501
        if dc_sync1_cycle:
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3502
            self.Controler.BaseParams.setDC_Sync1_Cycle_Time(dc_sync1_cycle)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3503
        if dc_sync1_shift:
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3504
            self.Controler.BaseParams.setDC_Sync1_Shift_Time(dc_sync1_shift)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3505
        project_infos = self.Controler.GetCTRoot().CTNRequestSave()
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3506
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3507
    def GetSymbol(self, period, cycle):
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3508
        cmp1 = int(period)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3509
        cmp2 = int(cycle)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3510
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3511
        if cmp1 == cmp2 :
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3512
            return "x 1"
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3513
        elif cmp2 > cmp1 :
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3514
            temp = cmp2 / cmp1
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3515
            result = "x " + str(temp)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3516
        else :
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3517
            temp = cmp1 / cmp2
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3518
            result = "/ " + str(temp)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3519
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3520
        return result
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3521
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3522
    def SetSyncCycle(self, period, sync0_cycle, sync1_cycle):
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3523
        if sync0_cycle != "None":
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3524
            self.CheckBoxDic["Sync0Enable"].SetValue(True)               
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3525
            temp = sync0_cycle.split("_")
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3526
            if temp[0] == "1":
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3527
                symbol = self.GetSymbol(period, temp[1])
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3528
                self.ComboBoxDic["Sync0UnitCycleChoice"].SetStringSelection(symbol)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3529
                self.TextCtrlDic["Sync0CycleTimeUserDefined_Ctl"].Disable()
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3530
                self.RadioButtonDic["Sync0CycleTimeUnitRadioButton"].SetValue(True)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3531
            else :
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3532
                self.TextCtrlDic["Sync0CycleTimeUserDefined_Ctl"].SetValue(temp[1])
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3533
                self.ComboBoxDic["Sync0UnitCycleChoice"].Disable()
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3534
                self.RadioButtonDic["Sync0CycleTimeUserDefinedRadioButton"].SetValue(True)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3535
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3536
        if sync1_cycle != "None":
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3537
            self.CheckBoxDic["Sync1Enable"].SetValue(True)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3538
            temp = sync1_cycle.split("_")
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3539
            if temp[0] == "1":
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3540
                symbol = self.GetSymbol(period, temp[1])
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3541
                self.ComboBoxDic["Sync1UnitChoice"].SetStringSelection(symbol)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3542
                self.TextCtrlDic["Sync1CycleTimeUserDefined_Ctl"].Disable()
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3543
                self.RadioButtonDic["Sync1CycleTimeUnitRadioButton"].SetValue(True)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3544
            else :
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3545
                self.TextCtrlDic["Sync1CycleTimeUserDefined_Ctl"].SetValue(temp[1])
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3546
                self.ComboBoxDic["Sync1UnitChoice"].Disable()
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3547
                self.RadioButtonDic["Sync1CycleTimeUserDefinedRadioButton"].SetValue(True)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3548
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3549
    def LoadProjectDCData(self):
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3550
        ns_mode = 1
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3551
        task_cycle_ns = self.GetInterval(ns_mode)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3552
        task_cycle_to_us = int(task_cycle_ns) / 1000
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3553
        dc_enable = self.Controler.BaseParams.getDC_Enable()
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3554
        dc_desc = self.Controler.BaseParams.getDC_Desc()
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3555
        dc_assign_activate = self.Controler.BaseParams.getDC_Assign_Activate()
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3556
        dc_sync0_cycle = self.Controler.BaseParams.getDC_Sync0_Cycle_Time()
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3557
        dc_sync0_shift = self.Controler.BaseParams.getDC_Sync0_Shift_Time()
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3558
        dc_sync1_cycle = self.Controler.BaseParams.getDC_Sync1_Cycle_Time()
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3559
        dc_sync1_shift = self.Controler.BaseParams.getDC_Sync1_Shift_Time()
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3560
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3561
        self.UIOnOffSet(dc_enable)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3562
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3563
        if dc_enable:
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3564
            self.CheckBoxDic["DCEnable"].SetValue(dc_enable)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3565
            self.ComboBoxDic["OperationModeChoice"].SetStringSelection(dc_desc)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3566
            self.TextCtrlDic["SyncUnitCycle_Ctl"].SetValue(str(task_cycle_to_us))
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3567
            self.SetSyncCycle(str(task_cycle_to_us), dc_sync0_cycle, dc_sync1_cycle)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3568
            if dc_sync0_shift != "None":
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3569
                self.TextCtrlDic["Sync0ShiftTimeUserDefined_Ctl"].SetValue(dc_sync0_shift)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3570
            if dc_sync1_shift != "None":
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3571
                self.TextCtrlDic["Sync1ShiftTimeUserDefined_Ctl"].SetValue(dc_sync1_shift)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3572
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3573
            if dc_assign_activate == "300":
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3574
                self.CheckBoxDic["Sync1Enable"].SetValue(False)
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3575
                self.RadioButtonDic["Sync1CycleTimeUnitRadioButton"].Disable()
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3576
                self.ComboBoxDic["Sync1UnitCycleChoice"].Disable()
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3577
                self.RadioButtonDic["Sync1CycleTimeUserDefinedRadioButton"].Disable()
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3578
                self.TextCtrlDic["Sync1CycleTimeUserDefined_Ctl"].Disable()
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3579
                self.TextCtrlDic["Sync1ShiftTimeUserDefined_Ctl"].Disable()
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3580
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3581
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3582
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3583
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3584
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3585
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3586
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3587
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3588
c9deff128c37 EtherCat master plugin : commit changes recovered from KOSMOS 2018 installer, unkown author(s).
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2165
diff changeset
  3589